batch.set(actual.getName()).on(path).to(unionedValues).and();
@Override public void startElement( String uri, String localName, String qName, Attributes attributes ) { Path nodePath; if (parents.isEmpty()) { nodePath = pathFactory.createRootPath(); } else { nodePath = path(parents.peek(), qName); batch.create(nodePath).and(); } parents.push(nodePath); for (int i = 0; i < attributes.getLength(); i++) { String rawValue = attributes.getValue(i); String[] values = rawValue.split(","); Property prop = propFactory.create(name(attributes.getQName(i)), (Object[])values); batch.set(prop).on(nodePath).and(); } }
protected ThisType setProperty( Name propertyName, Object value ) { // Set the property via the batch ... batch.set(propertyName).on(path).to(value).and(); // Record that we changed this property ... properties.put(propertyName, context.getPropertyFactory().create(propertyName, value)); return thisType(); }
.with("propB", "valueB") .and("propC", "valueC") .and() .create("/b") .with("propD", "valueD")
graph.batch().set("description").on("/testnodeC/testnodeD").to("This is the value").and().execute();
protected boolean doUnregister( String uri ) { // Read the store ... ValueFactory<String> stringFactory = store.getContext().getValueFactories().getStringFactory(); boolean result = false; try { Subgraph nsGraph = store.getSubgraphOfDepth(2).at(parentOfNamespaceNodes); // Iterate over the existing mappings, looking for one that uses the prefix and uri ... Set<Location> locationsToRemove = new HashSet<Location>(); for (Location nsLocation : nsGraph.getRoot().getChildren()) { Node ns = nsGraph.getNode(nsLocation); String actualUri = stringFactory.create(ns.getProperty(uriPropertyName).getFirstValue()); if (actualUri.equals(uri)) { locationsToRemove.add(ns.getLocation()); result = true; } } // Remove any other nodes that have the same URI ... Graph.Batch batch = store.batch(); for (Location namespaceToRemove : locationsToRemove) { batch.delete(namespaceToRemove).and(); } // Execute all these changes ... batch.execute(); } catch (PathNotFoundException e) { // Nothing stored yet, so do nothing ... } return result; }
/** * This method attempts to create a very small subgraph and then delete all of the nodes in that subgraph, all within the same * batch operation. */ @FixFor( "MODE-788" ) @Test public void shouldCreateAndDeleteTwoNodeSubgraphInSameOperation() { // Look for the root before we do anyting ... Node root = graph.getNodeAt("/"); assertThat(root, is(notNullValue())); assertThat(root, hasProperty(ModeShapeLexicon.UUID, getRootNodeUuid())); assertThat(root.getChildren(), isEmpty()); graph.batch().create("/a").and().create("/a/b").and().delete("/a").and().execute(); // Now look up the root node ... root = graph.getNodeAt("/"); assertThat(root, is(notNullValue())); assertThat(root, hasProperty(ModeShapeLexicon.UUID, getRootNodeUuid())); assertThat(root.getChildren(), isEmpty()); }
@Test public void shouldNotCombineNonAdjacentSetPropertyCalls() { 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).on(validPath).and().set(p2).on(validPath).and().set(p3).on(validUuid).execute(); extractRequestsFromComposite(); assertNextRequestUpdateProperties(Location.create(validPath), p1, p2); assertNextRequestSetProperty(Location.create(validUuid), p3); }
@Override protected Batch submit( String workspaceName, Location on, Name property, List<Object> values ) { requestQueue.removeValues(workspaceName, on, property, values); return nextRequests.and(); } };
/** * This method attempts to create a small subgraph and then delete all of the nodes in that subgraph, all within the same * batch operation. */ @FixFor( "MODE-788" ) @Test public void shouldCreateAndDeleteNodeInSameOperation() { graph.batch().create("/a").with("propB", "valueB").and("propC", "valueC").and().delete("/a").and().execute(); }
@Test public void shouldSendAllRequestsToSynchronousWrappedSourceWhenRequestsAreNotSearchOrQueryRequests() throws Exception { assertThatSourceIsNotSearchable(wrapped); loadContentInto(wrapped, "aircraft.xml"); searchable = newSynchronousSearchable(); Graph graph = Graph.create(searchable, context); Node boeing777 = graph.getNodeAt("/Aircraft/Commercial/Boeing 777"); assertThat(boeing777, is(notNullValue())); // Now do a batch ... graph.batch().read("/Aircraft/Commercial/Boeing 777").and().read("/Aircraft/Commercial/Boeing 787").execute(); }
@Test public void shouldCombineAdjacentSetPropertyCalls() { 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).on(validPath).and().set(p2).on(validPath).and().set(p3).on(validPath).execute(); assertNextRequestUpdateProperties(Location.create(validPath), p1, p2, p3); }
protected void assertReadUsingBatch( String... pathsInFederated ) { Graph.Batch batch = federated.batch(); for (String pathInFederated : pathsInFederated) { batch.read(pathInFederated).and(); } Results results = batch.execute(); for (String pathInFederated : pathsInFederated) { assertThat(results.getNode(pathInFederated), is(notNullValue())); } } }
public ThisType setProperty( Name propertyName, Object[] values ) { // Set the property via the batch ... batch.set(propertyName).on(path).to(values).and(); // Record that we changed this property ... properties.put(propertyName, context.getPropertyFactory().create(propertyName, values)); return thisType(); }
@Test public void shouldCreateNodesWithBatch() { graph.batch().create(validPath, validIdProperty1).and().remove("prop").on(validPathString).execute(); graph.batch().move(validPath).and(validPath).into(validPathString).and().create(validPath).and().execute(); graph.batch().createUnder(validLocation).nodeNamed("someName").and().delete(validLocation).execute(); }
@Override protected Batch submit( String workspaceName, Location on, Name property, List<Object> values ) { requestQueue.addValues(workspaceName, on, property, values); return nextRequests.and(); } };
@Test public void shouldSendAllRequestsToAsynchronousWrappedSourceWhenRequestsAreNotSearchOrQueryRequests() throws Exception { assertThatSourceIsNotSearchable(wrapped); loadContentInto(wrapped, "aircraft.xml"); searchable = newAsynchronousSearchable(); Graph graph = Graph.create(searchable, context); Node boeing777 = graph.getNodeAt("/Aircraft/Commercial/Boeing 777"); assertThat(boeing777, is(notNullValue())); // Now do a batch ... graph.batch().read("/Aircraft/Commercial/Boeing 777").and().read("/Aircraft/Commercial/Boeing 787").execute(); } }