batch.set(actual.getName()).on(path).to(unionedValues).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(); }
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(); }
graph.set("sequencedProperty").on("/a/b/c").to(new ByteArrayInputStream(sampleData.getBytes()));
configRepository.set(ModeShapeLexicon.CLASSNAME).on("/mode:system/mode:sources/source A").to(className); configRepository.set(ModeShapeLexicon.CLASSPATH).on("/mode:system/mode:sources/source A").to(""); configRepository.set(ModeShapeLexicon.CLASSNAME).on("/mode:system/mode:sources/source A/objectParam").to(className); configRepository.set(ModeShapeLexicon.CLASSPATH).on("/mode:system/mode:sources/source A/objectParam").to(""); configRepository.set("string").on("/mode:system/mode:sources/source A/objectParam").to("test string"); configRepository.set(ModeShapeLexicon.CLASSNAME).on("/mode:system/mode:sources/source B/objectParam").to(className); configRepository.set(ModeShapeLexicon.CLASSPATH).on("/mode:system/mode:sources/source B/objectParam").to(""); configRepository.set("string").on("/mode:system/mode:sources/source B/objectParam").to("test string"); configRepository.set(ModeShapeLexicon.CLASSNAME).on("/mode:system/mode:sources/source B").to(className); configRepository.set(ModeShapeLexicon.CLASSPATH).on("/mode:system/mode:sources/source B").to(""); configRepository.set("overloadedParam").on("/mode:system/mode:sources/source B").to("true");
graph.set("refProp").on("/refererringNode").to(graph.getNodeAt("/newUuids/node1/shouldBeRemoved"));
configRepository.set(ModeShapeLexicon.CLASSNAME).on("/mode:system/mode:sources/source A").to(className); configRepository.set(ModeShapeLexicon.CLASSPATH).on("/mode:system/mode:sources/source A").to(""); configRepository.set("retryLimit").on("/mode:system/mode:sources/source A").to(3); configRepository.set("intParam").on("/mode:system/mode:sources/source A").to("3"); configRepository.set("shortParam").on("/mode:system/mode:sources/source A").to("32"); configRepository.set("booleanParam").on("/mode:system/mode:sources/source A").to("true"); configRepository.set("stringParam").on("/mode:system/mode:sources/source A").to("string value"); configRepository.set("intArrayParam").on("/mode:system/mode:sources/source A").to("3"); configRepository.set("booleanArrayParam").on("/mode:system/mode:sources/source A").to("true"); configRepository.set("longObjectArrayParam").on("/mode:system/mode:sources/source A").to("987654321"); configRepository.set("booleanObjectArrayParam").on("/mode:system/mode:sources/source A").to("true"); configRepository.set("stringArrayParam").on("/mode:system/mode:sources/source A").to("string value");
graph.set("sequencedProperty").on("/a/b/c").to(new ByteArrayInputStream(sampleData.getBytes()));
graph.set("sequencedProperty").on("/a/b/c").to(new ByteArrayInputStream(sampleData.getBytes()));
@Test( expected = SequencerException.class ) public void shouldExecuteSequencerOnExistingNodeWithMissingSequencedPropertyAndOutputToExistingNode() throws Exception { // Set up the repository for the test ... graph.create("/a").and().create("/a/b").and().create("/a/b/c").and(); graph.create("/d").and().create("/d/e").and(); Node nodeC = graph.getNodeAt("/a/b/c"); Node nodeE = graph.getNodeAt("/d/e"); assertThat(nodeC, is(notNullValue())); assertThat(nodeE, is(notNullValue())); assertThat(nodeE.getChildren().size(), is(0)); assertThat(nodeE.getProperties().size(), is(1)); // jcr:uuid // assertThat(nodeE.getProperty("jcr:primaryType").getString(), is("nt:unstructured")); // Set the property that will be sequenced ... // THIS TEST REQUIRES THIS PROPERTY TO BE NULL OR NON-EXISTANT graph.set("sequencedProperty").on(nodeC.getLocation()).to((String)null); // Set up the node changes ... Location location = Location.create(context.getValueFactories().getPathFactory().create("/a/b/c")); Property sequencedProperty = nodeC.getProperty("sequencedProperty"); NetChange nodeChange = new NetChange(repositoryWorkspaceName, location, EnumSet.of(ChangeType.PROPERTY_CHANGED), null, Collections.singleton(sequencedProperty), null, null, null, false); // Set up the output directory ... Set<RepositoryNodePath> outputPaths = new HashSet<RepositoryNodePath>(); outputPaths.add(new RepositoryNodePath(repositorySourceName, repositoryWorkspaceName, "/d/e")); // Generate the output data that the sequencer subclass will produce and that should be saved to the repository ... sequencerOutput.setProperty(path("alpha/beta"), name("isSomething"), true); // Call the sequencer, which should cause the exception ... sequencer.execute(nodeC, "sequencedProperty", nodeChange, outputPaths, seqContext, problems); }
@Test public void shouldExecuteSequencerOnExistingNodeAndOutputToExistingNode() throws Exception { // Set up the repository for the test ... graph.create("/a").and().create("/a/b").and().create("/a/b/c").and(); graph.create("/d").and().create("/d/e").and(); graph.set("sequencedProperty").on("/a/b/c").to(new ByteArrayInputStream(sampleData.getBytes())); Node nodeC = graph.getNodeAt("/a/b/c"); Node nodeE = graph.getNodeAt("/d/e"); assertThat(nodeC, is(notNullValue())); assertThat(nodeE, is(notNullValue())); assertThat(nodeE.getChildren().size(), is(0)); assertThat(nodeE.getProperties().size(), is(1)); // jcr:uuid // assertThat(nodeE.getProperty("jcr:primaryType").getString(), is("nt:unstructured")); // Set the property that will be sequenced ... // Set up the node changes ... Location location = Location.create(context.getValueFactories().getPathFactory().create("/a/b/c")); Property sequencedProperty = nodeC.getProperty("sequencedProperty"); NetChange nodeChange = new NetChange(repositoryWorkspaceName, location, EnumSet.of(ChangeType.PROPERTY_CHANGED), null, Collections.singleton(sequencedProperty), null, null, null, false); // Set up the output directory ... Set<RepositoryNodePath> outputPaths = new HashSet<RepositoryNodePath>(); outputPaths.add(new RepositoryNodePath(repositorySourceName, repositoryWorkspaceName, "/d/e")); // Generate the output data that the sequencer subclass will produce and that should be saved to the repository ... sequencerOutput.setProperty(path("alpha/beta"), name("isSomething"), true); // Call the sequencer ... sequencer.execute(nodeC, "sequencedProperty", nodeChange, outputPaths, seqContext, problems); }
@Test public void shouldSetPropertyValueToPrimitiveTypes() { graph.set("propName").on(validPath).to(3.0F); assertNextRequestSetProperty(Location.create(validPath), createProperty("propName", new Float(3.0f))); graph.set("propName").on(validPath).to(1.0D); assertNextRequestSetProperty(Location.create(validPath), createProperty("propName", new Double(1.0))); graph.set("propName").on(validPath).to(false); assertNextRequestSetProperty(Location.create(validPath), createProperty("propName", Boolean.FALSE)); graph.set("propName").on(validPath).to(3); assertNextRequestSetProperty(Location.create(validPath), createProperty("propName", new Integer(3))); graph.set("propName").on(validPath).to(5L); assertNextRequestSetProperty(Location.create(validPath), createProperty("propName", new Long(5))); graph.set("propName").on(validPath).to(validPath); assertNextRequestSetProperty(Location.create(validPath), createProperty("propName", validPath)); graph.set("propName").on(validPath).to(validPath.getLastSegment().getName()); assertNextRequestSetProperty(Location.create(validPath), createProperty("propName", validPath.getLastSegment().getName())); Date now = new Date(); graph.set("propName").on(validPath).to(now); assertNextRequestSetProperty(Location.create(validPath), createProperty("propName", now)); DateTime dtNow = context.getValueFactories().getDateFactory().create(now); graph.set("propName").on(validPath).to(dtNow); assertNextRequestSetProperty(Location.create(validPath), createProperty("propName", dtNow)); Calendar calNow = Calendar.getInstance(); calNow.setTime(now); graph.set("propName").on(validPath).to(calNow); assertNextRequestSetProperty(Location.create(validPath), createProperty("propName", dtNow)); }
@Test public void shouldExecuteSequencerOnExistingNodeAndOutputToNonExistingNode() throws Exception { // Set up the repository for the test ... graph.create("/a").and().create("/a/b").and().create("/a/b/c").and(); // Set the property that will be sequenced ... graph.set("sequencedProperty").on("/a/b/c").to(new ByteArrayInputStream(sampleData.getBytes())); Node nodeC = graph.getNodeAt("/a/b/c"); assertThat(nodeC, is(notNullValue())); assertNodeDoesNotExist(graph, "/d"); // Set up the node changes ... Location location = Location.create(context.getValueFactories().getPathFactory().create("/a/b/c")); Property sequencedProperty = nodeC.getProperty("sequencedProperty"); NetChange nodeChange = new NetChange(repositoryWorkspaceName, location, EnumSet.of(ChangeType.PROPERTY_CHANGED), null, Collections.singleton(sequencedProperty), null, null, null, false); // Set up the output directory ... Set<RepositoryNodePath> outputPaths = new HashSet<RepositoryNodePath>(); outputPaths.add(new RepositoryNodePath(repositorySourceName, repositoryWorkspaceName, "/d/e")); // Generate the output data that the sequencer subclass will produce and that should be saved to the repository ... sequencerOutput.setProperty(path("alpha/beta"), name("isSomething"), true); // Call the sequencer ... sequencer.execute(nodeC, "sequencedProperty", nodeChange, outputPaths, seqContext, problems); // Check to see that the "/d/e" node has been created ... assertThat(graph.getNodeAt("/d/e"), is(notNullValue())); }
protected void testSequencer( final StreamSequencer sequencer ) throws Throwable { StreamSequencer streamSequencer = new StreamSequencer() { @Override public void sequence( InputStream stream, SequencerOutput output, StreamSequencerContext context ) { sequencer.sequence(stream, output, context); } }; StreamSequencerAdapter adapter = new StreamSequencerAdapter(streamSequencer); graph.create("/a").and().create("/a/b").and().create("/a/b/c").and(); graph.create("/d").and().create("/d/e").and(); graph.set("sequencedProperty").on("/a/b/c").to(new ByteArrayInputStream(sampleData.getBytes())); Node inputNode = graph.getNodeAt("/a/b/c"); Location location = Location.create(context.getValueFactories().getPathFactory().create("/a/b/c")); Property sequencedProperty = inputNode.getProperty("sequencedProperty"); NetChange nodeChange = new NetChange(repositoryWorkspaceName, location, EnumSet.of(ChangeType.PROPERTY_CHANGED), null, Collections.singleton(sequencedProperty), null, null, null, false); Set<RepositoryNodePath> outputPaths = new HashSet<RepositoryNodePath>(); outputPaths.add(new RepositoryNodePath(repositorySourceName, repositoryWorkspaceName, "/d/e")); sequencerOutput.setProperty(path("alpha/beta"), name("isSomething"), true); adapter.execute(inputNode, "sequencedProperty", nodeChange, outputPaths, seqContext, problems); }
@FixFor( "MODE-1168" ) @Test public void shouldUseCorrectSetterForOverloadedSimpleProperties() { Path configPath = context.getValueFactories().getPathFactory().create("/mode:system"); service = new RepositoryService(configRepositorySource, configWorkspaceName, configPath, context, bus, problems); // Set up the configuration repository ... configRepository.useWorkspace("default"); configRepository.create("/mode:system").and(); configRepository.create("/mode:system/mode:sources").and(); configRepository.create("/mode:system/mode:sources/source A").and(); final String className = FakeRepositorySource.class.getName(); configRepository.set(ModeShapeLexicon.CLASSNAME).on("/mode:system/mode:sources/source A").to(className); configRepository.set(ModeShapeLexicon.CLASSPATH).on("/mode:system/mode:sources/source A").to(""); configRepository.set("overloadedParam").on("/mode:system/mode:sources/source A").to("true"); // Now, start up the service ... service.getAdministrator().start(); // Get the source, which should be configured ... RepositorySource repositorySourceA = service.getRepositoryLibrary().getSource("source A"); assertThat(repositorySourceA, is(instanceOf(FakeRepositorySource.class))); FakeRepositorySource sourceA = (FakeRepositorySource)repositorySourceA; assertThat(sourceA.isBooleanParam(), is(true)); }
@Test public void shouldProvideInputProperties() throws Exception { this.sequencedProperty = mock(Property.class); graph.create("/a").and().create("/a/b").and().create("/a/b/c").and(); graph.set("x").on("/a/b/c").to(true); graph.set("y").on("/a/b/c").to(Arrays.asList(new String[] {"asdf", "xyzzy"})); Node input = graph.getNodeAt("/a/b/c"); StreamSequencerContext sequencerContext = sequencer.createStreamSequencerContext(input, sequencedProperty, seqContext, problems); assertThat(sequencerContext.getInputProperties(), notNullValue()); assertThat(sequencerContext.getInputProperties().isEmpty(), is(false)); assertThat(sequencerContext.getInputProperties().size(), is(3)); // verifyProperty(sequencerContext, "jcr:uuid", /* some UUID */null ); verifyProperty(sequencerContext, "x", true); verifyProperty(sequencerContext, "y", "asdf", "xyzzy"); }
/** * {@inheritDoc} * * @see org.modeshape.graph.sequencer.SequencerOutput#setProperty(org.modeshape.graph.property.Path, * org.modeshape.graph.property.Name, java.lang.Object[]) */ public void setProperty( Path nodePath, Name propertyName, Object... values ) { assert valuesAreNotIterators(values); nodePath = absolute(nodePath); if (paths.add(nodePath)) { batch.create(nodePath).and(); } batch.set(propertyName).on(nodePath).to(values); }
/** * {@inheritDoc} * * @see org.modeshape.graph.sequencer.SequencerOutput#setProperty(java.lang.String, java.lang.String, java.lang.Object[]) */ public void setProperty( String nodePath, String propertyName, Object... values ) { assert valuesAreNotIterators(values); Path path = pathFactory.create(nodePath); path = absolute(path); if (paths.add(path)) { batch.create(path).and(); } batch.set(propertyName).on(path).to(values); }
/** * {@inheritDoc} * * @see org.modeshape.graph.sequencer.SequencerOutput#setReference(java.lang.String, java.lang.String, java.lang.String[]) */ public void setReference( String nodePath, String propertyName, String... paths ) { Path path = pathFactory.create(nodePath); path = absolute(path); if (this.paths.add(path)) { batch.create(path).and(); } batch.set(propertyName).on(nodePath).to(paths); }
@Test public void shouldSetPropertyWithEitherOnOrToMethodsCalledFirst() { graph.set("propName").on(validPath).to(3.0f); assertNextRequestSetProperty(Location.create(validPath), createProperty("propName", 3.0f)); graph.set("propName").to(3.0f).on(validPath); assertNextRequestSetProperty(Location.create(validPath), createProperty("propName", 3.0f)); }