From commits-return-111-archive-asf-public=cust-asf.ponee.io@streampipes.apache.org Tue Dec 17 09:48:05 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 5B10E18066C for ; Tue, 17 Dec 2019 10:48:03 +0100 (CET) Received: (qmail 5221 invoked by uid 500); 17 Dec 2019 09:48:02 -0000 Mailing-List: contact commits-help@streampipes.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@streampipes.apache.org Delivered-To: mailing list commits@streampipes.apache.org Received: (qmail 4913 invoked by uid 99); 17 Dec 2019 09:48:01 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Dec 2019 09:48:01 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id CA36B8D815; Tue, 17 Dec 2019 09:48:01 +0000 (UTC) Date: Tue, 17 Dec 2019 09:48:05 +0000 To: "commits@streampipes.apache.org" Subject: [incubator-streampipes] 04/25: Add example components from dev guide MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit From: zehnder@apache.org In-Reply-To: <157657608143.22396.11647261036651743252@gitbox.apache.org> References: <157657608143.22396.11647261036651743252@gitbox.apache.org> X-Git-Host: gitbox.apache.org X-Git-Repo: incubator-streampipes X-Git-Refname: refs/heads/dev X-Git-Reftype: branch X-Git-Rev: 256311bef2319266784a940d27de5253cc758554 X-Git-NotificationType: diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated Message-Id: <20191217094801.CA36B8D815@gitbox.apache.org> This is an automated email from the ASF dual-hosted git repository. zehnder pushed a commit to branch dev in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git commit 256311bef2319266784a940d27de5253cc758554 Author: Dominik Riemer AuthorDate: Sun Feb 17 22:49:51 2019 +0100 Add example components from dev guide --- .../streampipes/pe/examples/jvm/ExamplesInit.java | 16 ++++++++++++++- .../pe/examples/jvm/base/DummyEngine.java | 6 +++--- ...oller.java => CollectionExampleController.java} | 16 ++++++++------- ...a => MultiValueSelectionExampleController.java} | 12 ++++++----- ...a => NaryMappingPropertyExampleController.java} | 21 ++++++++++---------- .../NumberParameterExampleController.java | 17 +++++++++++----- ...NumberParameterWithRangeExampleController.java} | 16 ++++++++------- ...ller.java => RuntimeResolvableSingleValue.java} | 23 ++++++++++++++++------ ... => SingleValueSelectionExampleController.java} | 15 +++++++------- ... => UnaryMappingPropertyExampleController.java} | 21 +++++++++----------- 10 files changed, 99 insertions(+), 64 deletions(-) diff --git a/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/ExamplesInit.java b/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/ExamplesInit.java index 48a9a4f..548722b 100644 --- a/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/ExamplesInit.java +++ b/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/ExamplesInit.java @@ -21,8 +21,15 @@ import org.streampipes.dataformat.json.JsonDataFormatFactory; import org.streampipes.messaging.jms.SpJmsProtocolFactory; import org.streampipes.messaging.kafka.SpKafkaProtocolFactory; import org.streampipes.pe.examples.jvm.config.ExamplesJvmConfig; +import org.streampipes.pe.examples.jvm.staticproperty.CollectionExampleController; +import org.streampipes.pe.examples.jvm.staticproperty.MultiValueSelectionExampleController; +import org.streampipes.pe.examples.jvm.staticproperty.NaryMappingPropertyExampleController; import org.streampipes.pe.examples.jvm.staticproperty.NumberParameterExampleController; +import org.streampipes.pe.examples.jvm.staticproperty.NumberParameterWithRangeExampleController; +import org.streampipes.pe.examples.jvm.staticproperty.RuntimeResolvableSingleValue; +import org.streampipes.pe.examples.jvm.staticproperty.SingleValueSelectionExampleController; import org.streampipes.pe.examples.jvm.staticproperty.TextParameterExampleController; +import org.streampipes.pe.examples.jvm.staticproperty.UnaryMappingPropertyExampleController; public class ExamplesInit extends StandaloneModelSubmitter { @@ -30,7 +37,14 @@ public class ExamplesInit extends StandaloneModelSubmitter { DeclarersSingleton .getInstance() .add(new TextParameterExampleController()) - .add(new NumberParameterExampleController()); + .add(new NumberParameterExampleController()) + .add(new NumberParameterWithRangeExampleController()) + .add(new UnaryMappingPropertyExampleController()) + .add(new NaryMappingPropertyExampleController()) + .add(new SingleValueSelectionExampleController()) + .add(new MultiValueSelectionExampleController()) + .add(new CollectionExampleController()) + .add(new RuntimeResolvableSingleValue()); DeclarersSingleton.getInstance().registerDataFormat(new JsonDataFormatFactory()); DeclarersSingleton.getInstance().registerProtocol(new SpKafkaProtocolFactory()); diff --git a/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/base/DummyEngine.java b/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/base/DummyEngine.java index dcf3897..d7b5b48 100644 --- a/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/base/DummyEngine.java +++ b/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/base/DummyEngine.java @@ -18,14 +18,14 @@ package org.streampipes.pe.examples.jvm.base; import org.streampipes.commons.exceptions.SpRuntimeException; import org.streampipes.model.runtime.Event; import org.streampipes.wrapper.context.EventProcessorRuntimeContext; -import org.streampipes.wrapper.params.binding.EventProcessorBindingParams; import org.streampipes.wrapper.routing.SpOutputCollector; import org.streampipes.wrapper.runtime.EventProcessor; -public class DummyEngine implements EventProcessor { +public class DummyEngine implements EventProcessor { @Override - public void onInvocation(B parameters, SpOutputCollector spOutputCollector, EventProcessorRuntimeContext runtimeContext) throws SpRuntimeException { + public void onInvocation(DummyParameters parameters, SpOutputCollector spOutputCollector, + EventProcessorRuntimeContext runtimeContext) throws SpRuntimeException { } diff --git a/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/NumberParameterExampleController.java b/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/CollectionExampleController.java similarity index 79% copy from streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/NumberParameterExampleController.java copy to streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/CollectionExampleController.java index 1493510..5392018 100644 --- a/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/NumberParameterExampleController.java +++ b/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/CollectionExampleController.java @@ -19,6 +19,7 @@ import org.streampipes.model.graph.DataProcessorDescription; import org.streampipes.model.graph.DataProcessorInvocation; import org.streampipes.pe.examples.jvm.base.DummyEngine; import org.streampipes.pe.examples.jvm.base.DummyParameters; +import org.streampipes.sdk.StaticProperties; import org.streampipes.sdk.builder.ProcessingElementBuilder; import org.streampipes.sdk.builder.StreamRequirementsBuilder; import org.streampipes.sdk.extractor.ProcessingElementParameterExtractor; @@ -30,14 +31,14 @@ import org.streampipes.sdk.helpers.SupportedProtocols; import org.streampipes.wrapper.standalone.ConfiguredEventProcessor; import org.streampipes.wrapper.standalone.declarer.StandaloneEventProcessingDeclarer; -public class NumberParameterExampleController extends StandaloneEventProcessingDeclarer { +import java.util.List; - private static final String SP_KEY = "my-example-key"; +public class CollectionExampleController extends StandaloneEventProcessingDeclarer { @Override public DataProcessorDescription declareModel() { return ProcessingElementBuilder.create("org.streampipes.examples.staticproperty" + - ".numberparameter", "Number Parameter Example", "") + ".collection", "Collection Example", "") .requiredStream(StreamRequirementsBuilder. create() .requiredProperty(EpRequirements.anyProperty()) @@ -46,9 +47,10 @@ public class NumberParameterExampleController extends StandaloneEventProcessingD .supportedProtocols(SupportedProtocols.kafka()) .supportedFormats(SupportedFormats.jsonFormat()) - // create a simple text parameter - .requiredIntegerParameter(Labels.from(SP_KEY, "Example Name", "Example Description")) - + // create a collection parameter + .requiredParameterAsCollection(Labels.from("collection", "Example Name", "Example " + + "Description"), StaticProperties.stringFreeTextProperty(Labels + .from("text-property","Text",""))) .build(); } @@ -56,7 +58,7 @@ public class NumberParameterExampleController extends StandaloneEventProcessingD public ConfiguredEventProcessor onInvocation(DataProcessorInvocation graph, ProcessingElementParameterExtractor extractor) { // Extract the text parameter value - String textParameter = extractor.singleValueParameter(SP_KEY, String.class); + List textParameters = extractor.singleValueParameterFromCollection("collection", String.class); // now the text parameter would be added to a parameter class (omitted for this example) diff --git a/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/NumberParameterExampleController.java b/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/MultiValueSelectionExampleController.java similarity index 82% copy from streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/NumberParameterExampleController.java copy to streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/MultiValueSelectionExampleController.java index 1493510..79d95d0 100644 --- a/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/NumberParameterExampleController.java +++ b/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/MultiValueSelectionExampleController.java @@ -24,20 +24,21 @@ import org.streampipes.sdk.builder.StreamRequirementsBuilder; import org.streampipes.sdk.extractor.ProcessingElementParameterExtractor; import org.streampipes.sdk.helpers.EpRequirements; import org.streampipes.sdk.helpers.Labels; +import org.streampipes.sdk.helpers.Options; import org.streampipes.sdk.helpers.OutputStrategies; import org.streampipes.sdk.helpers.SupportedFormats; import org.streampipes.sdk.helpers.SupportedProtocols; import org.streampipes.wrapper.standalone.ConfiguredEventProcessor; import org.streampipes.wrapper.standalone.declarer.StandaloneEventProcessingDeclarer; -public class NumberParameterExampleController extends StandaloneEventProcessingDeclarer { +import java.util.List; - private static final String SP_KEY = "my-example-key"; +public class MultiValueSelectionExampleController extends StandaloneEventProcessingDeclarer { @Override public DataProcessorDescription declareModel() { return ProcessingElementBuilder.create("org.streampipes.examples.staticproperty" + - ".numberparameter", "Number Parameter Example", "") + ".multivalue", "Multi value selection example", "") .requiredStream(StreamRequirementsBuilder. create() .requiredProperty(EpRequirements.anyProperty()) @@ -47,7 +48,8 @@ public class NumberParameterExampleController extends StandaloneEventProcessingD .supportedFormats(SupportedFormats.jsonFormat()) // create a simple text parameter - .requiredIntegerParameter(Labels.from(SP_KEY, "Example Name", "Example Description")) + .requiredMultiValueSelection(Labels.from("id", "Example Name", "Example " + + "Description"), Options.from("Value A", "Value B", "Value C")) .build(); } @@ -56,7 +58,7 @@ public class NumberParameterExampleController extends StandaloneEventProcessingD public ConfiguredEventProcessor onInvocation(DataProcessorInvocation graph, ProcessingElementParameterExtractor extractor) { // Extract the text parameter value - String textParameter = extractor.singleValueParameter(SP_KEY, String.class); + List selectedSingleValue = extractor.selectedMultiValues("id", String.class); // now the text parameter would be added to a parameter class (omitted for this example) diff --git a/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/NumberParameterExampleController.java b/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/NaryMappingPropertyExampleController.java similarity index 77% copy from streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/NumberParameterExampleController.java copy to streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/NaryMappingPropertyExampleController.java index 1493510..c1620f0 100644 --- a/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/NumberParameterExampleController.java +++ b/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/NaryMappingPropertyExampleController.java @@ -17,6 +17,7 @@ package org.streampipes.pe.examples.jvm.staticproperty; import org.streampipes.model.graph.DataProcessorDescription; import org.streampipes.model.graph.DataProcessorInvocation; +import org.streampipes.model.schema.PropertyScope; import org.streampipes.pe.examples.jvm.base.DummyEngine; import org.streampipes.pe.examples.jvm.base.DummyParameters; import org.streampipes.sdk.builder.ProcessingElementBuilder; @@ -30,35 +31,33 @@ import org.streampipes.sdk.helpers.SupportedProtocols; import org.streampipes.wrapper.standalone.ConfiguredEventProcessor; import org.streampipes.wrapper.standalone.declarer.StandaloneEventProcessingDeclarer; -public class NumberParameterExampleController extends StandaloneEventProcessingDeclarer { +import java.util.List; - private static final String SP_KEY = "my-example-key"; +public class NaryMappingPropertyExampleController extends + StandaloneEventProcessingDeclarer { @Override public DataProcessorDescription declareModel() { return ProcessingElementBuilder.create("org.streampipes.examples.staticproperty" + - ".numberparameter", "Number Parameter Example", "") + ".mappingnary", "Nary Mapping Property Example", "") .requiredStream(StreamRequirementsBuilder. create() - .requiredProperty(EpRequirements.anyProperty()) + .requiredPropertyWithNaryMapping(EpRequirements.numberReq(), + Labels.from("mp-key", "My Mapping", ""), + PropertyScope.NONE) .build()) .outputStrategy(OutputStrategies.keep()) .supportedProtocols(SupportedProtocols.kafka()) .supportedFormats(SupportedFormats.jsonFormat()) - // create a simple text parameter - .requiredIntegerParameter(Labels.from(SP_KEY, "Example Name", "Example Description")) - .build(); } @Override public ConfiguredEventProcessor onInvocation(DataProcessorInvocation graph, ProcessingElementParameterExtractor extractor) { - // Extract the text parameter value - String textParameter = extractor.singleValueParameter(SP_KEY, String.class); - - // now the text parameter would be added to a parameter class (omitted for this example) + // Extract the mapping property value + List mappingPropertySelectors = extractor.mappingPropertyValues("mp-key"); return new ConfiguredEventProcessor<>(new DummyParameters(graph), DummyEngine::new); } diff --git a/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/NumberParameterExampleController.java b/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/NumberParameterExampleController.java index 1493510..1346efb 100644 --- a/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/NumberParameterExampleController.java +++ b/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/NumberParameterExampleController.java @@ -46,8 +46,12 @@ public class NumberParameterExampleController extends StandaloneEventProcessingD .supportedProtocols(SupportedProtocols.kafka()) .supportedFormats(SupportedFormats.jsonFormat()) - // create a simple text parameter - .requiredIntegerParameter(Labels.from(SP_KEY, "Example Name", "Example Description")) + // create an integer parameter + .requiredIntegerParameter(Labels.from(SP_KEY, "Integer Parameter", "Example Description")) + + // create a float parameter + .requiredFloatParameter(Labels.from("float-key", "Float Parameter", "Example Description")) + .build(); } @@ -55,10 +59,13 @@ public class NumberParameterExampleController extends StandaloneEventProcessingD @Override public ConfiguredEventProcessor onInvocation(DataProcessorInvocation graph, ProcessingElementParameterExtractor extractor) { - // Extract the text parameter value - String textParameter = extractor.singleValueParameter(SP_KEY, String.class); + // Extract the integer parameter value + Integer integerParameter = extractor.singleValueParameter(SP_KEY, Integer.class); + + // Extract the float parameter value + Float floatParameter = extractor.singleValueParameter("float-key", Float.class); - // now the text parameter would be added to a parameter class (omitted for this example) + // now the parameters would be added to a parameter class (omitted for this example) return new ConfiguredEventProcessor<>(new DummyParameters(graph), DummyEngine::new); } diff --git a/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/NumberParameterExampleController.java b/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/NumberParameterWithRangeExampleController.java similarity index 79% copy from streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/NumberParameterExampleController.java copy to streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/NumberParameterWithRangeExampleController.java index 1493510..041dbca 100644 --- a/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/NumberParameterExampleController.java +++ b/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/NumberParameterWithRangeExampleController.java @@ -30,14 +30,15 @@ import org.streampipes.sdk.helpers.SupportedProtocols; import org.streampipes.wrapper.standalone.ConfiguredEventProcessor; import org.streampipes.wrapper.standalone.declarer.StandaloneEventProcessingDeclarer; -public class NumberParameterExampleController extends StandaloneEventProcessingDeclarer { +public class NumberParameterWithRangeExampleController extends + StandaloneEventProcessingDeclarer { private static final String SP_KEY = "my-example-key"; @Override public DataProcessorDescription declareModel() { return ProcessingElementBuilder.create("org.streampipes.examples.staticproperty" + - ".numberparameter", "Number Parameter Example", "") + ".numberparameterrange", "Number Parameter With Range", "") .requiredStream(StreamRequirementsBuilder. create() .requiredProperty(EpRequirements.anyProperty()) @@ -46,8 +47,9 @@ public class NumberParameterExampleController extends StandaloneEventProcessingD .supportedProtocols(SupportedProtocols.kafka()) .supportedFormats(SupportedFormats.jsonFormat()) - // create a simple text parameter - .requiredIntegerParameter(Labels.from(SP_KEY, "Example Name", "Example Description")) + // create an integer parameter + .requiredIntegerParameter(Labels.from(SP_KEY, "Integer Parameter", "Example " + + "Description"), 0, 100, 1) .build(); } @@ -55,10 +57,10 @@ public class NumberParameterExampleController extends StandaloneEventProcessingD @Override public ConfiguredEventProcessor onInvocation(DataProcessorInvocation graph, ProcessingElementParameterExtractor extractor) { - // Extract the text parameter value - String textParameter = extractor.singleValueParameter(SP_KEY, String.class); + // Extract the integer parameter value + Integer integerParameter = extractor.singleValueParameter(SP_KEY, Integer.class); - // now the text parameter would be added to a parameter class (omitted for this example) + // now the parameter would be added to a parameter class (omitted for this example) return new ConfiguredEventProcessor<>(new DummyParameters(graph), DummyEngine::new); } diff --git a/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/NumberParameterExampleController.java b/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/RuntimeResolvableSingleValue.java similarity index 71% copy from streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/NumberParameterExampleController.java copy to streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/RuntimeResolvableSingleValue.java index 1493510..26850f2 100644 --- a/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/NumberParameterExampleController.java +++ b/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/RuntimeResolvableSingleValue.java @@ -15,8 +15,11 @@ limitations under the License. */ package org.streampipes.pe.examples.jvm.staticproperty; +import org.streampipes.container.api.ResolvesContainerProvidedOptions; import org.streampipes.model.graph.DataProcessorDescription; import org.streampipes.model.graph.DataProcessorInvocation; +import org.streampipes.model.runtime.RuntimeOptions; +import org.streampipes.model.schema.EventProperty; import org.streampipes.pe.examples.jvm.base.DummyEngine; import org.streampipes.pe.examples.jvm.base.DummyParameters; import org.streampipes.sdk.builder.ProcessingElementBuilder; @@ -30,14 +33,16 @@ import org.streampipes.sdk.helpers.SupportedProtocols; import org.streampipes.wrapper.standalone.ConfiguredEventProcessor; import org.streampipes.wrapper.standalone.declarer.StandaloneEventProcessingDeclarer; -public class NumberParameterExampleController extends StandaloneEventProcessingDeclarer { +import java.util.Arrays; +import java.util.List; - private static final String SP_KEY = "my-example-key"; +public class RuntimeResolvableSingleValue extends + StandaloneEventProcessingDeclarer implements ResolvesContainerProvidedOptions { @Override public DataProcessorDescription declareModel() { return ProcessingElementBuilder.create("org.streampipes.examples.staticproperty" + - ".numberparameter", "Number Parameter Example", "") + ".runtimeresolvablesingle", "Runtime-resolvable single value example", "") .requiredStream(StreamRequirementsBuilder. create() .requiredProperty(EpRequirements.anyProperty()) @@ -46,8 +51,9 @@ public class NumberParameterExampleController extends StandaloneEventProcessingD .supportedProtocols(SupportedProtocols.kafka()) .supportedFormats(SupportedFormats.jsonFormat()) - // create a simple text parameter - .requiredIntegerParameter(Labels.from(SP_KEY, "Example Name", "Example Description")) + // create a single value selection parameter that is resolved at runtime + .requiredSingleValueSelectionFromContainer(Labels.from("id", "Example Name", "Example " + + "Description")) .build(); } @@ -56,10 +62,15 @@ public class NumberParameterExampleController extends StandaloneEventProcessingD public ConfiguredEventProcessor onInvocation(DataProcessorInvocation graph, ProcessingElementParameterExtractor extractor) { // Extract the text parameter value - String textParameter = extractor.singleValueParameter(SP_KEY, String.class); + String selectedSingleValue = extractor.selectedSingleValue("id", String.class); // now the text parameter would be added to a parameter class (omitted for this example) return new ConfiguredEventProcessor<>(new DummyParameters(graph), DummyEngine::new); } + + @Override + public List resolveOptions(String requestId, EventProperty linkedEventProperty) { + return Arrays.asList(new RuntimeOptions("I was defined at runtime", "")); + } } diff --git a/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/NumberParameterExampleController.java b/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/SingleValueSelectionExampleController.java similarity index 81% copy from streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/NumberParameterExampleController.java copy to streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/SingleValueSelectionExampleController.java index 1493510..8f32778 100644 --- a/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/NumberParameterExampleController.java +++ b/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/SingleValueSelectionExampleController.java @@ -24,20 +24,20 @@ import org.streampipes.sdk.builder.StreamRequirementsBuilder; import org.streampipes.sdk.extractor.ProcessingElementParameterExtractor; import org.streampipes.sdk.helpers.EpRequirements; import org.streampipes.sdk.helpers.Labels; +import org.streampipes.sdk.helpers.Options; import org.streampipes.sdk.helpers.OutputStrategies; import org.streampipes.sdk.helpers.SupportedFormats; import org.streampipes.sdk.helpers.SupportedProtocols; import org.streampipes.wrapper.standalone.ConfiguredEventProcessor; import org.streampipes.wrapper.standalone.declarer.StandaloneEventProcessingDeclarer; -public class NumberParameterExampleController extends StandaloneEventProcessingDeclarer { - - private static final String SP_KEY = "my-example-key"; +public class SingleValueSelectionExampleController extends + StandaloneEventProcessingDeclarer { @Override public DataProcessorDescription declareModel() { return ProcessingElementBuilder.create("org.streampipes.examples.staticproperty" + - ".numberparameter", "Number Parameter Example", "") + ".singlevalue", "Single value selection example", "") .requiredStream(StreamRequirementsBuilder. create() .requiredProperty(EpRequirements.anyProperty()) @@ -46,8 +46,9 @@ public class NumberParameterExampleController extends StandaloneEventProcessingD .supportedProtocols(SupportedProtocols.kafka()) .supportedFormats(SupportedFormats.jsonFormat()) - // create a simple text parameter - .requiredIntegerParameter(Labels.from(SP_KEY, "Example Name", "Example Description")) + // create a single value selection parameter + .requiredSingleValueSelection(Labels.from("id", "Example Name", "Example " + + "Description"), Options.from("Option A", "Option B", "Option C")) .build(); } @@ -56,7 +57,7 @@ public class NumberParameterExampleController extends StandaloneEventProcessingD public ConfiguredEventProcessor onInvocation(DataProcessorInvocation graph, ProcessingElementParameterExtractor extractor) { // Extract the text parameter value - String textParameter = extractor.singleValueParameter(SP_KEY, String.class); + String selectedSingleValue = extractor.selectedSingleValue("id", String.class); // now the text parameter would be added to a parameter class (omitted for this example) diff --git a/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/NumberParameterExampleController.java b/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/UnaryMappingPropertyExampleController.java similarity index 77% copy from streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/NumberParameterExampleController.java copy to streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/UnaryMappingPropertyExampleController.java index 1493510..1385302 100644 --- a/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/NumberParameterExampleController.java +++ b/streampipes-pipeline-elements-examples-processors-jvm/src/main/java/org/streampipes/pe/examples/jvm/staticproperty/UnaryMappingPropertyExampleController.java @@ -17,6 +17,7 @@ package org.streampipes.pe.examples.jvm.staticproperty; import org.streampipes.model.graph.DataProcessorDescription; import org.streampipes.model.graph.DataProcessorInvocation; +import org.streampipes.model.schema.PropertyScope; import org.streampipes.pe.examples.jvm.base.DummyEngine; import org.streampipes.pe.examples.jvm.base.DummyParameters; import org.streampipes.sdk.builder.ProcessingElementBuilder; @@ -30,35 +31,31 @@ import org.streampipes.sdk.helpers.SupportedProtocols; import org.streampipes.wrapper.standalone.ConfiguredEventProcessor; import org.streampipes.wrapper.standalone.declarer.StandaloneEventProcessingDeclarer; -public class NumberParameterExampleController extends StandaloneEventProcessingDeclarer { - - private static final String SP_KEY = "my-example-key"; +public class UnaryMappingPropertyExampleController extends + StandaloneEventProcessingDeclarer { @Override public DataProcessorDescription declareModel() { return ProcessingElementBuilder.create("org.streampipes.examples.staticproperty" + - ".numberparameter", "Number Parameter Example", "") + ".mappingunary", "Unary Mapping Property Example", "") .requiredStream(StreamRequirementsBuilder. create() - .requiredProperty(EpRequirements.anyProperty()) + .requiredPropertyWithUnaryMapping(EpRequirements.numberReq(), + Labels.from("mp-key", "My Mapping", ""), + PropertyScope.NONE) .build()) .outputStrategy(OutputStrategies.keep()) .supportedProtocols(SupportedProtocols.kafka()) .supportedFormats(SupportedFormats.jsonFormat()) - // create a simple text parameter - .requiredIntegerParameter(Labels.from(SP_KEY, "Example Name", "Example Description")) - .build(); } @Override public ConfiguredEventProcessor onInvocation(DataProcessorInvocation graph, ProcessingElementParameterExtractor extractor) { - // Extract the text parameter value - String textParameter = extractor.singleValueParameter(SP_KEY, String.class); - - // now the text parameter would be added to a parameter class (omitted for this example) + // Extract the mapping property value + String mappingPropertySelector = extractor.mappingPropertyValue("mp-key"); return new ConfiguredEventProcessor<>(new DummyParameters(graph), DummyEngine::new); }