/** * {@inheritDoc} * * @see org.modeshape.graph.Location#with(java.util.UUID) */ @Override public Location with( UUID uuid ) { return Location.create(uuid); }
/** * {@inheritDoc} * * @see Location#with(Path) */ @Override public Location with( Path newPath ) { if (newPath == null) return this; Property idProperty = getIdProperties().get(0); // fast return Location.create(newPath, idProperty); }
/** * Request to lock the node at the given path. This request is submitted to the repository immediately. * * @param at the path of the node that is to be locked * @return an object that allows the scope of the lock to be defined */ public LockScope<LockTimeout<Conjunction<Graph>>> lock( Path at ) { return lock(Location.create(at)); }
/** * Request to lock the node with the given unique identification property. This request is submitted to the repository * immediately. * * @param idProperty the unique identifying property of the node that is to be locked * @return an object that allows the scope of the lock to be defined */ public LockScope<LockTimeout<Conjunction<Graph>>> lock( Property idProperty ) { return lock(Location.create(idProperty)); }
/** * Request to unlock the node at the given path. This request is submitted to the repository immediately. * * @param at the path of the node that is to be unlocked * @return an object that may be used to start another request */ public Conjunction<Graph> unlock( Path at ) { return unlock(Location.create(at)); }
/** * Request to delete the node at the given path. This request is submitted to the repository immediately. * * @param at the path of the node that is to be deleted * @return an object that may be used to start another request */ public Conjunction<Graph> delete( Path at ) { return delete(Location.create(at)); }
/** * Request to delete the node with the given identification properties. The identification properties should uniquely identify * a single node. This request is submitted to the repository immediately. * * @param firstIdProperty the first identification property of the node that is to be copied * @param additionalIdProperties the remaining identification properties of the node that is to be copied * @return an object that may be used to start another request */ public Conjunction<Graph> delete( Property firstIdProperty, Property... additionalIdProperties ) { return delete(Location.create(firstIdProperty, additionalIdProperties)); }
/** * Request to read the node at the supplied path. * * @param path the path of the node that is to be read * @return the node that is read from the repository */ public Node getNodeAt( Path path ) { return getNodeAt(Location.create(path)); }
/** * {@inheritDoc} * * @see org.modeshape.graph.Graph.To#to(org.modeshape.graph.property.Path) */ public Map<String, Serializable> to( Path desiredPath ) { return to(Location.create(desiredPath)); }
/** * Request to unlock the node with the given unique identification property. This request is submitted to the repository * immediately. * * @param idProperty the unique identifying property of the node that is to be unlocked * @return the interface that can either execute the batched requests or continue to add additional requests to the batch */ public BatchConjunction unlock( Property idProperty ) { return unlock(Location.create(idProperty)); }
/** * {@inheritDoc} * * @see org.modeshape.graph.connector.base.Transaction#getParent(org.modeshape.graph.connector.base.Workspace, * org.modeshape.graph.connector.base.Node) */ public NodeType getParent( WorkspaceType workspace, NodeType node ) { Path parentPath = node.getParent(); if (parentPath == null) return null; return getNode(workspace, Location.create(parentPath)); }
/** * Request to lock the node at the given path. This request is submitted to the repository immediately. * * @param atPath the path of the node that is to be locked * @return an object that allows the scope of the lock to be defined */ public LockScope<LockTimeout<Conjunction<Graph>>> lock( String atPath ) { return lock(Location.create(createPath(atPath))); }
/** * Request to delete the node at the given path. This request is submitted to the repository immediately. * * @param atPath the path of the node that is to be deleted * @return an object that may be used to start another request */ public Conjunction<Graph> delete( String atPath ) { return delete(Location.create(createPath(atPath))); }
/** * {@inheritDoc} * * @see org.modeshape.graph.Graph.To#to(java.lang.String) */ public java.util.Map<String, Serializable> to( String desiredPath ) { return to(Location.create(createPath(desiredPath))); } };
public Map<Location, Property> on( String first, String... additional ) { CheckArg.isNotNull(first, "first"); final List<ReadPropertyRequest> requests = new LinkedList<ReadPropertyRequest>(); String workspace = getCurrentWorkspaceName(); requests.add(new ReadPropertyRequest(Location.create(createPath(first)), workspace, name)); for (String path : additional) { requests.add(new ReadPropertyRequest(Location.create(createPath(path)), workspace, name)); } return execute(requests); }
@Test public void locationsWithSamePathsAndDifferentPropertyAreNotSame() { Location locationA1 = Location.create(pathA, propA); Location locationA2 = Location.create(pathA, propB); assertThat("isSame must not return true for locations created with identical paths and property", locationA1.isSame(locationA2), is(false)); }
public void addChild( Location parent, String childName ) { Path path = context.getValueFactories().getPathFactory().create(parent.getPath(), segment(childName)); Map<Name, Property> properties = Collections.emptyMap(); List<ProjectedNode> grandChildren = Collections.emptyList(); PlaceholderNode child = new PlaceholderNode(Location.create(path), properties, grandChildren); this.children.add(child); }
@Test public void shouldUnlockNode() { graph.unlock(validPath); assertNextRequestIsUnlock(Location.create(validPath)); }
@Test public void shouldSetMultiplePropertiesAtOnce() { Property p1 = createProperty("propName1", new Float(3.0f)); Property p2 = createProperty("propName2", new Double(1.0)); Property p3 = createProperty("propName3", "String value"); graph.batch().set(p1, p2, p3).on(validPath).execute(); assertNextRequestUpdateProperties(Location.create(validPath), p1, p2, p3); }
@Test public void shouldLockNodeAndItsDescendants() { graph.lock(validPath).andItsDescendants().withTimeoutOf(12345); assertNextRequestIsLock(Location.create(validPath), LockScope.SELF_AND_DESCENDANTS, 12345); }