This is an automated email from the ASF dual-hosted git repository.

zehnder pushed a commit to branch 2350-new-processor-staticmetadataenrichment
in repository https://gitbox.apache.org/repos/asf/streampipes.git


The following commit(s) were added to 
refs/heads/2350-new-processor-staticmetadataenrichment by this push:
     new 6ba5617a9 fix(#2350): Add resources for new processor
6ba5617a9 is described below

commit 6ba5617a933d40eee75d30fee8ef2adabe76912e
Author: Philipp Zehnder <[email protected]>
AuthorDate: Wed Dec 20 18:02:54 2023 +0100

    fix(#2350): Add resources for new processor
---
 .../jvm/TransformationExtensionModuleExport.java   |   2 +
 .../StaticMetaDataEnrichmentProcessor.java         | 118 +++++++++++++++++++++
 .../documentation.md                               |  71 +++++++++++++
 .../icon.png                                       | Bin 0 -> 30181 bytes
 .../strings.en                                     |  35 ++++++
 5 files changed, 226 insertions(+)

diff --git 
a/streampipes-extensions/streampipes-processors-transformation-jvm/src/main/java/org/apache/streampipes/processors/transformation/jvm/TransformationExtensionModuleExport.java
 
b/streampipes-extensions/streampipes-processors-transformation-jvm/src/main/java/org/apache/streampipes/processors/transformation/jvm/TransformationExtensionModuleExport.java
index 3afa98d2f..fbd6f3180 100644
--- 
a/streampipes-extensions/streampipes-processors-transformation-jvm/src/main/java/org/apache/streampipes/processors/transformation/jvm/TransformationExtensionModuleExport.java
+++ 
b/streampipes-extensions/streampipes-processors-transformation-jvm/src/main/java/org/apache/streampipes/processors/transformation/jvm/TransformationExtensionModuleExport.java
@@ -39,6 +39,7 @@ import 
org.apache.streampipes.processors.transformation.jvm.processor.mapper.Fie
 import 
org.apache.streampipes.processors.transformation.jvm.processor.measurementconverter.MeasurementUnitConverterProcessor;
 import 
org.apache.streampipes.processors.transformation.jvm.processor.round.RoundProcessor;
 import 
org.apache.streampipes.processors.transformation.jvm.processor.state.labeler.number.NumberLabelerProcessor;
+import 
org.apache.streampipes.processors.transformation.jvm.processor.staticmetadata.StaticMetaDataEnrichmentProcessor;
 import 
org.apache.streampipes.processors.transformation.jvm.processor.stringoperator.counter.StringCounterProcessor;
 import 
org.apache.streampipes.processors.transformation.jvm.processor.stringoperator.state.StringToStateProcessor;
 import 
org.apache.streampipes.processors.transformation.jvm.processor.stringoperator.timer.StringTimerProcessor;
@@ -77,6 +78,7 @@ public class TransformationExtensionModuleExport implements 
IExtensionModuleExpo
         new MeasurementUnitConverterProcessor(),
         new TaskDurationProcessor(),
         new TransformToBooleanProcessor(),
+        new StaticMetaDataEnrichmentProcessor(),
         new StringTimerProcessor(),
         new SignalEdgeFilterProcessor(),
         new BooleanToStateProcessor(),
diff --git 
a/streampipes-extensions/streampipes-processors-transformation-jvm/src/main/java/org/apache/streampipes/processors/transformation/jvm/processor/staticmetadata/StaticMetaDataEnrichmentProcessor.java
 
b/streampipes-extensions/streampipes-processors-transformation-jvm/src/main/java/org/apache/streampipes/processors/transformation/jvm/processor/staticmetadata/StaticMetaDataEnrichmentProcessor.java
new file mode 100644
index 000000000..c1354892a
--- /dev/null
+++ 
b/streampipes-extensions/streampipes-processors-transformation-jvm/src/main/java/org/apache/streampipes/processors/transformation/jvm/processor/staticmetadata/StaticMetaDataEnrichmentProcessor.java
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package 
org.apache.streampipes.processors.transformation.jvm.processor.staticmetadata;
+
+import org.apache.streampipes.commons.exceptions.SpConfigurationException;
+import org.apache.streampipes.commons.exceptions.SpRuntimeException;
+import 
org.apache.streampipes.extensions.api.pe.context.EventProcessorRuntimeContext;
+import org.apache.streampipes.extensions.api.pe.routing.SpOutputCollector;
+import 
org.apache.streampipes.extensions.api.runtime.ResolvesContainerProvidedOutputStrategy;
+import org.apache.streampipes.model.DataProcessorType;
+import org.apache.streampipes.model.graph.DataProcessorDescription;
+import org.apache.streampipes.model.graph.DataProcessorInvocation;
+import org.apache.streampipes.model.runtime.Event;
+import org.apache.streampipes.model.schema.EventSchema;
+import org.apache.streampipes.sdk.StaticProperties;
+import org.apache.streampipes.sdk.builder.ProcessingElementBuilder;
+import org.apache.streampipes.sdk.builder.StreamRequirementsBuilder;
+import 
org.apache.streampipes.sdk.extractor.ProcessingElementParameterExtractor;
+import org.apache.streampipes.sdk.helpers.Labels;
+import org.apache.streampipes.sdk.helpers.Locales;
+import org.apache.streampipes.sdk.helpers.Options;
+import org.apache.streampipes.sdk.helpers.OutputStrategies;
+import org.apache.streampipes.sdk.utils.Assets;
+import org.apache.streampipes.wrapper.params.compat.ProcessorParams;
+import org.apache.streampipes.wrapper.standalone.StreamPipesDataProcessor;
+
+public class StaticMetaDataEnrichmentProcessor extends StreamPipesDataProcessor
+    implements 
ResolvesContainerProvidedOutputStrategy<DataProcessorInvocation, 
ProcessingElementParameterExtractor> {
+
+  private static final String STATIC_METADATA_INPUT = "static-metadata-input";
+  private static final String STATIC_METADATA_INPUT_COLLECTION = 
"static-metadata-input-collection";
+  private static final String STATIC_METADATA_INPUT_RUNTIME_NAME = 
"static-metadata-input-runtime-name";
+  private static final String STATIC_METADATA_INPUT_VALUE = 
"static-metadata-input-value";
+  private static final String STATIC_METADATA_INPUT_DATATYPE = 
"static-metadata-input-datatype";
+
+  private static final String OPTION_BOOL = "Bool";
+  private static final String OPTION_STRING = "String";
+  private static final String OPTION_FLOAT = "Float";
+  private static final String OPTION_INTEGER = "Integer";
+
+
+  @Override
+  public DataProcessorDescription declareModel() {
+    return ProcessingElementBuilder.create(
+                                       
"org.apache.streampipes.processors.transformation.jvm.processor.staticmetadata",
+                                       1
+                                   )
+                                   .category(DataProcessorType.ENRICH)
+                                   .withLocales(Locales.EN)
+                                   .withAssets(Assets.DOCUMENTATION, 
Assets.ICON)
+                                   .requiredParameterAsCollection(
+                                       Labels.withId(STATIC_METADATA_INPUT),
+                                       StaticProperties.collection(
+                                           
Labels.withId(STATIC_METADATA_INPUT_COLLECTION),
+                                           
StaticProperties.stringFreeTextProperty(Labels.withId(
+                                               
STATIC_METADATA_INPUT_RUNTIME_NAME)),
+                                           
StaticProperties.stringFreeTextProperty(
+                                               
Labels.withId(STATIC_METADATA_INPUT_VALUE)),
+                                           
StaticProperties.singleValueSelection(
+                                               
Labels.withId(STATIC_METADATA_INPUT_DATATYPE),
+                                               Options.from(
+                                                   OPTION_BOOL,
+                                                   OPTION_STRING,
+                                                   OPTION_FLOAT,
+                                                   OPTION_INTEGER
+                                               )
+                                           )
+                                       )
+                                   )
+                                   
.requiredStream(StreamRequirementsBuilder.any())
+                                   
.outputStrategy(OutputStrategies.customTransformation())
+                                   .build();
+  }
+
+  @Override
+  public EventSchema resolveOutputStrategy(
+      DataProcessorInvocation processingElement,
+      ProcessingElementParameterExtractor parameterExtractor
+  ) throws SpConfigurationException {
+    return null;
+  }
+
+  @Override
+  public void onInvocation(
+      ProcessorParams parameters,
+      SpOutputCollector spOutputCollector,
+      EventProcessorRuntimeContext runtimeContext
+  ) throws SpRuntimeException {
+
+  }
+
+  @Override
+  public void onEvent(Event event, SpOutputCollector collector) {
+
+  }
+
+  @Override
+  public void onDetach() {
+
+  }
+
+}
diff --git 
a/streampipes-extensions/streampipes-processors-transformation-jvm/src/main/resources/org.apache.streampipes.processors.transformation.jvm.processors.staticmetadata/documentation.md
 
b/streampipes-extensions/streampipes-processors-transformation-jvm/src/main/resources/org.apache.streampipes.processors.transformation.jvm.processors.staticmetadata/documentation.md
new file mode 100644
index 000000000..9080e2d09
--- /dev/null
+++ 
b/streampipes-extensions/streampipes-processors-transformation-jvm/src/main/resources/org.apache.streampipes.processors.transformation.jvm.processors.staticmetadata/documentation.md
@@ -0,0 +1,71 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~    http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  ~
+  -->
+
+## CSV Metadata Enrichment
+Enrich a datastream with information provided in a CSV file.
+The data of the CSV file is matched by an id column with a property value of a 
String in the data stream.
+
+***
+
+## Description
+Upload a CSV file with static meta information that will be appended to each 
event.
+The file can contain different information for different keys in the stream.
+
+
+### Structure of CSV file
+The first row containes the runtime names for the properties to insert.
+Once the file is uploaded the user can select which column to use for the 
matching property
+and which values should be appended.
+Delimiter: ';'
+
+
+***
+
+## Example
+Add the location of a production line to the event
+
+### Input  event
+```
+{
+  'line_id': 'line1',
+  'timestamp': 1586378041
+}
+```
+
+### CSV File
+```
+production_line;location
+line1;germany
+line2;uk
+line3;usa
+```
+
+### Configuration
+* The field that is used for the lookup (Example: line_id)
+* The CSV file (Example: Upload the csv file)
+* Field to match (Example: production_line)
+* Fields to append (Example: location)
+
+### Output event
+```
+{
+  'line_id': 'line1',
+  'timestamp': 1586378041,
+  'location': 'germany'
+}
+```
diff --git 
a/streampipes-extensions/streampipes-processors-transformation-jvm/src/main/resources/org.apache.streampipes.processors.transformation.jvm.processors.staticmetadata/icon.png
 
b/streampipes-extensions/streampipes-processors-transformation-jvm/src/main/resources/org.apache.streampipes.processors.transformation.jvm.processors.staticmetadata/icon.png
new file mode 100644
index 000000000..61caf18b7
Binary files /dev/null and 
b/streampipes-extensions/streampipes-processors-transformation-jvm/src/main/resources/org.apache.streampipes.processors.transformation.jvm.processors.staticmetadata/icon.png
 differ
diff --git 
a/streampipes-extensions/streampipes-processors-transformation-jvm/src/main/resources/org.apache.streampipes.processors.transformation.jvm.processors.staticmetadata/strings.en
 
b/streampipes-extensions/streampipes-processors-transformation-jvm/src/main/resources/org.apache.streampipes.processors.transformation.jvm.processors.staticmetadata/strings.en
new file mode 100644
index 000000000..5c8ca0447
--- /dev/null
+++ 
b/streampipes-extensions/streampipes-processors-transformation-jvm/src/main/resources/org.apache.streampipes.processors.transformation.jvm.processors.staticmetadata/strings.en
@@ -0,0 +1,35 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+org.apache.streampipes.processors.transformation.jvm.processor.staticmetadata.title=Static
 Metadata Enricher
+org.apache.streampipes.processors.transformation.jvm.processor.staticmetadata.description=Enriches
 event with metadata
+
+static-metadata-input.title=Metadata Input
+static-metadata-input.description=Input collection of metadata that will be 
enriched to the event
+
+static-metadata-input-collection.title=Input Collection
+static-metadata-input-collection.description=
+
+static-metadata-input-runtime-name.title=Runtime Name
+static-metadata-input-runtime-name.description=This is used for the runtime 
name in the event
+
+static-metadata-input-value.title=Runtime Value
+static-metadata-input-value.description=This is used for the runtime value in 
the event
+
+static-metadata-input-datatype.title=Data Type
+static-metadata-input-datatype.description=Select the data type of the value
+

Reply via email to