/** * Begin a batch of requests to perform various operations. Use this approach when multiple operations are to be built and * then executed with one submission to the underlying {@link #getSourceName() repository source}. The {@link Results results} * are not available until the {@link Batch#execute()} method is invoked. * * @return the batch object used to build and accumulate multiple requests and to submit them all for processing at once. * @see Batch#execute() * @see Results */ public Batch batch() { return new Batch(new BatchRequestBuilder()); }
/** * Add a request to destroy an existing workspace. * * @param workspaceName the name of the workspace that is to be destroyed * @return this builder for method chaining; never null * @throws IllegalArgumentException if the workspace name is null */ public BatchRequestBuilder destroyWorkspace( String workspaceName ) { return add(new DestroyWorkspaceRequest(workspaceName)); }
protected final BatchRequestBuilder add( Request request ) { addPending(); requests.add(request); return this; }
this.requestBuilder.finishPendingRequest(); final Graph.Batch branchBatch = store.batch(new BatchRequestBuilder(branchRequests)); this.requestBuilder = new BatchRequestBuilder(this.requests); this.operations = store.batch(this.requestBuilder);
/** * {@inheritDoc} * * @see org.modeshape.graph.Graph.ApplyFunctionAction#submit(org.modeshape.graph.Location, java.lang.String, * org.modeshape.graph.request.function.Function, java.util.Map) */ @Override protected Batch submit( Location to, String workspaceName, Function function, Map<String, Serializable> inputs ) { requestQueue.applyFunction(function, inputs, to, workspaceName); return Batch.this; } };
@Override protected Batch submit( Location parent, String workspaceName, Name childName, Collection<Property> properties, NodeConflictBehavior behavior ) { requestQueue.createNode(parent, workspaceName, childName, properties.iterator(), behavior); return Batch.this; } };
@Override protected Batch submit( String workspaceName, Location on, Name property, List<Object> values ) { requestQueue.addValues(workspaceName, on, property, values); return nextRequests.and(); } };
@Override protected BatchConjunction submit( String fromWorkspaceName, Location from, String intoWorkspaceName, Location into, Name desiredName, Segment desiredSegment, boolean removeExisting ) { requestQueue.cloneBranch(from, fromWorkspaceName, into, intoWorkspaceName, desiredName, desiredSegment, removeExisting); return and(); } };
/** * Request to delete the node at the given location. * <p> * Like all other methods on the {@link Batch}, the request will be performed when the {@link #execute()} method is * called. * </p> * * @param at the location of the node that is to be deleted * @return an object that may be used to start another request */ public BatchConjunction delete( Location at ) { assertNotExecuted(); this.requestQueue.deleteBranch(at, getCurrentWorkspaceName()); return nextRequests; }
@Override protected BatchConjunction submit( String fromWorkspaceName, Locations from, Location into, Name copyName ) { String intoWorkspaceName = getCurrentWorkspaceName(); if (fromWorkspaceName == null) fromWorkspaceName = intoWorkspaceName; do { requestQueue.copyBranch(from.getLocation(), fromWorkspaceName, into, intoWorkspaceName, copyName, null); } while ((from = from.next()) != null); return and(); } };
this.requestBuilder.finishPendingRequest();
/** * Add a request to read the branch at the supplied location, to a maximum depth of 2. * * @param at the location of the branch * @param workspaceName the name of the workspace containing the branch * @return this builder for method chaining; never null * @throws IllegalArgumentException if the location or workspace name is null or if the maximum depth is not positive */ public BatchRequestBuilder readBranch( Location at, String workspaceName ) { return add(new ReadBranchRequest(at, workspaceName)); }
/** * Add a request to remove the property with the supplied name from the given node. Supplying a name for a property that does * not exist will not cause an error. * * @param on the location of the node to be read * @param workspaceName the name of the workspace containing the node * @param propertyName the name of the property that is to be removed * @return this builder for method chaining; never null * @throws IllegalArgumentException if the location or workspace name is null or if there are no properties to remove */ public BatchRequestBuilder removeProperty( Location on, String workspaceName, Name propertyName ) { // If there's a pending request ... if (pendingRequest != null) { // Compare the supplied location with that of the pending request if (pendingRequest.location.isSame(on)) { // They are the same location, so we can add the properties to the pending request ... pendingRequest.pendingProperties.put(propertyName, null); return this; } // Not the exact same location, so push the existing pending request ... addPending(); } // Record this operation as a pending change ... pendingRequest = new NodeChange(on, workspaceName); pendingRequest.pendingProperties.put(propertyName, null); return this; }
this.requestBuilder = new BatchRequestBuilder(this.requests); this.operations = this.store.batch(this.requestBuilder);
/** * Submit any request to this batch. * * @param request the request to be batched; may not be null * @return this builder for method chaining; never null * @throws IllegalArgumentException if the request is null */ public BatchRequestBuilder submit( Request request ) { CheckArg.isNotNull(request, "request"); return add(request); }
this.requestBuilder = new BatchRequestBuilder(this.requests); this.operations = store.batch(this.requestBuilder);
/** * Add a request to read the children of a node at the supplied location in the designated workspace. * * @param of the location of the node whose children are to be read * @param workspaceName the name of the workspace * @return this builder for method chaining; never null * @throws IllegalArgumentException if the location or workspace name is null */ public BatchRequestBuilder readAllChildren( Location of, String workspaceName ) { return add(new ReadAllChildrenRequest(of, workspaceName)); }
addPending(); ++number; } else {
/** * Add a request to delete a branch. * * @param at the location of the top node in the existing branch that is to be deleted * @param workspaceName the name of the workspace containing the parent * @return this builder for method chaining; never null * @throws IllegalArgumentException if the location or workspace name is null */ public BatchRequestBuilder deleteBranch( Location at, String workspaceName ) { return add(new DeleteBranchRequest(at, workspaceName)); }