@Override protected Graph submit( String workspaceName, Location on, Name property, List<Object> values ) { requests.addValues(workspaceName, on, property, values); return nextGraph.and(); } };
@Override protected Graph submit( String fromWorkspaceName, Location from, String intoWorkspaceName, Location into, Name desiredName, Segment desiredSegment, boolean removeExisting ) { requests.cloneBranch(from, fromWorkspaceName, into, intoWorkspaceName, desiredName, desiredSegment, removeExisting); return and(); } };
@Override protected Graph submit( Location parent, String workspaceName, Name childName, Collection<Property> properties, NodeConflictBehavior behavior ) { requests.createNode(parent, workspaceName, childName, properties.iterator(), behavior); return Graph.this; }
public Subgraph at( Location location ) { return new SubgraphResults(requests.readBranch(location, getCurrentWorkspaceName(), depth)); }
/** * {@inheritDoc} * * @see org.modeshape.graph.Graph.NameWorkspace#named(java.lang.String) */ public Workspace named( String workspaceName ) { CreateWorkspaceRequest request = requests.createWorkspace(workspaceName, CreateConflictBehavior.DO_NOT_CREATE); return setWorkspace(request.getActualWorkspaceName(), request.getActualLocationOfRoot()); }
/** * Request to delete the node at the given location. This request is submitted to the repository immediately. * * @param at the location of the node that is to be deleted * @return an object that may be used to start another request */ public Conjunction<Graph> delete( Location at ) { requests.deleteBranch(at, getCurrentWorkspaceName()); return nextGraph; }
/** * Get the set of workspace names that are known to this source and accessible by this {@link #getContext() context}. * * @return the set of workspace names; never null */ public Set<String> getWorkspaces() { return requests.getWorkspaces().getAvailableWorkspaceNames(); }
/** * {@inheritDoc} * * @see org.modeshape.graph.Graph.To#to(org.modeshape.graph.Location) */ public Map<String, Serializable> to( Location desiredLocation ) { return requests.applyFunction(function, inputs, desiredLocation, getCurrentWorkspaceName()).outputs(); }
/** * {@inheritDoc} * * @see org.modeshape.graph.Graph.DestroyWorkspace#named(java.lang.String) */ public boolean named( String workspaceName ) { CheckArg.isNotNull(workspaceName, "workspaceName"); if (getCurrentWorkspaceName().equals(workspaceName)) { String msg = GraphI18n.currentWorkspaceCannotBeDeleted.text(workspaceName, getSourceName()); throw new InvalidWorkspaceException(msg); } DestroyWorkspaceRequest request = requests.destroyWorkspace(workspaceName); if (request.hasError()) return false; return true; } };
@Override protected Graph submit( String fromWorkspaceName, Locations from, Location into, Name childName ) { String workspaceName = fromWorkspaceName != null ? fromWorkspaceName : getCurrentWorkspaceName(); do { requests.copyBranch(from.getLocation(), workspaceName, into, getCurrentWorkspaceName(), childName, NodeConflictBehavior.APPEND); } while ((from = from.next()) != null); return and(); } };
@Override public void run( FunctionContext context ) { // Read the input parameter(s) ... int maxDepth = context.input("maxDepth", PropertyType.LONG, new Long(Integer.MAX_VALUE)).intValue(); // Read the subgraph under the location ... ReadBranchRequest readSubgraph = context.builder().readBranch(context.appliedAt(), context.workspace(), maxDepth); // Process that request ... if (readSubgraph.hasError()) { readSubgraph.getError().printStackTrace(); context.setError(readSubgraph.getError()); } else { // And count the number of nodes within the subgraph ... int counter = 0; for (Location location : readSubgraph) { if (location != null) ++counter; } // And write the count as an output parameter ... context.setOutput("nodeCount", counter); } } }
/** * {@inheritDoc} * * @see org.modeshape.graph.Graph.CreateWorkspace#namedSomethingLike(java.lang.String) */ public Workspace namedSomethingLike( String workspaceName ) { CreateWorkspaceRequest request = requests.createWorkspace(workspaceName, CreateConflictBehavior.CREATE_WITH_ADJUSTED_NAME); return setWorkspace(request.getActualWorkspaceName(), request.getActualLocationOfRoot()); }
/** * Request to delete the specified node. This request is submitted to the repository immediately. * * @param at the node that is to be deleted * @return an object that may be used to start another request */ public Conjunction<Graph> delete( Node at ) { requests.deleteBranch(at.getLocation(), getCurrentWorkspaceName()); return nextGraph; }
public Graph and() { requests.createNode(Location.create(parent), workspaceName, childName, this.properties.iterator()); return Graph.this; } };
public Location getLocation() { Location parentLoc = Location.create(parent); CreateNodeRequest request = requests.createNode(parentLoc, workspaceName, childName, this.properties.iterator()); return request.getActualLocationOfNode(); }
public Conjunction<Graph> node( String name, Iterable<Property> properties ) { Name child = nameFactory.create(name); requests.createNode(parent, getCurrentWorkspaceName(), child, properties.iterator()); return nextGraph; } };
public Conjunction<Graph> node( String name, Property... properties ) { Name child = nameFactory.create(name); requests.createNode(parent, getCurrentWorkspaceName(), child, properties); return nextGraph; }
public Conjunction<Graph> node( String name, Iterator<Property> properties ) { Name child = nameFactory.create(name); requests.createNode(parent, getCurrentWorkspaceName(), child, properties); return nextGraph; }
public Node getNode() { Location parentLoc = Location.create(parent); CreateNodeRequest request = requests.createNode(parentLoc, workspaceName, childName, this.properties.iterator()); return getNodeAt(request.getActualLocationOfNode()); }