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

riemer pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/streampipes.git


The following commit(s) were added to refs/heads/dev by this push:
     new 052c7dc85a fix: Add timestamp to Image enricher, fix SO error (#2924)
052c7dc85a is described below

commit 052c7dc85a5923163f21c5a3156ef5a3880636f2
Author: Dominik Riemer <[email protected]>
AuthorDate: Tue Jun 11 06:31:39 2024 +0200

    fix: Add timestamp to Image enricher, fix SO error (#2924)
---
 .../jvm/ImageProcessingExtensionModuleExport.java  |  5 +-
 .../jvm/processor/commons/ImageTransformer.java    |  5 --
 .../imageenrichment/ImageEnrichmentProcessor.java  | 11 ++--
 .../ImageEnrichmentProcessorMigrationv1.java       | 58 ++++++++++++++++++++++
 4 files changed, 70 insertions(+), 9 deletions(-)

diff --git 
a/streampipes-extensions/streampipes-processors-image-processing-jvm/src/main/java/org/apache/streampipes/processors/imageprocessing/jvm/ImageProcessingExtensionModuleExport.java
 
b/streampipes-extensions/streampipes-processors-image-processing-jvm/src/main/java/org/apache/streampipes/processors/imageprocessing/jvm/ImageProcessingExtensionModuleExport.java
index 79b82aa3d0..505490c9a5 100644
--- 
a/streampipes-extensions/streampipes-processors-image-processing-jvm/src/main/java/org/apache/streampipes/processors/imageprocessing/jvm/ImageProcessingExtensionModuleExport.java
+++ 
b/streampipes-extensions/streampipes-processors-image-processing-jvm/src/main/java/org/apache/streampipes/processors/imageprocessing/jvm/ImageProcessingExtensionModuleExport.java
@@ -25,6 +25,7 @@ import 
org.apache.streampipes.extensions.api.pe.IStreamPipesPipelineElement;
 import 
org.apache.streampipes.processors.imageprocessing.jvm.processor.genericclassification.GenericImageClassificationProcessor;
 import 
org.apache.streampipes.processors.imageprocessing.jvm.processor.imagecropper.ImageCropperProcessor;
 import 
org.apache.streampipes.processors.imageprocessing.jvm.processor.imageenrichment.ImageEnrichmentProcessor;
+import 
org.apache.streampipes.processors.imageprocessing.jvm.processor.migration.ImageEnrichmentProcessorMigrationv1;
 import 
org.apache.streampipes.processors.imageprocessing.jvm.processor.qrreader.QrCodeReaderProcessor;
 
 import java.util.Collections;
@@ -48,6 +49,8 @@ public class ImageProcessingExtensionModuleExport implements 
IExtensionModuleExp
 
   @Override
   public List<IModelMigrator<?, ?>> migrators() {
-    return Collections.emptyList();
+    return List.of(
+        new ImageEnrichmentProcessorMigrationv1()
+    );
   }
 }
diff --git 
a/streampipes-extensions/streampipes-processors-image-processing-jvm/src/main/java/org/apache/streampipes/processors/imageprocessing/jvm/processor/commons/ImageTransformer.java
 
b/streampipes-extensions/streampipes-processors-image-processing-jvm/src/main/java/org/apache/streampipes/processors/imageprocessing/jvm/processor/commons/ImageTransformer.java
index c4ec892f4d..408ff86bed 100644
--- 
a/streampipes-extensions/streampipes-processors-image-processing-jvm/src/main/java/org/apache/streampipes/processors/imageprocessing/jvm/processor/commons/ImageTransformer.java
+++ 
b/streampipes-extensions/streampipes-processors-image-processing-jvm/src/main/java/org/apache/streampipes/processors/imageprocessing/jvm/processor/commons/ImageTransformer.java
@@ -38,11 +38,6 @@ public class ImageTransformer extends PlainImageTransformer {
     super(in);
   }
 
-  public Optional<BufferedImage> getImage(String imageProperty) {
-
-    return getImage(imageProperty);
-  }
-
   public List<Map<String, Object>> getAllBoxCoordinates(String 
boxArrayProperty) {
     List<Map<String, AbstractField>> allBoxes = 
in.getFieldBySelector(boxArrayProperty)
         .getAsList()
diff --git 
a/streampipes-extensions/streampipes-processors-image-processing-jvm/src/main/java/org/apache/streampipes/processors/imageprocessing/jvm/processor/imageenrichment/ImageEnrichmentProcessor.java
 
b/streampipes-extensions/streampipes-processors-image-processing-jvm/src/main/java/org/apache/streampipes/processors/imageprocessing/jvm/processor/imageenrichment/ImageEnrichmentProcessor.java
index 4f959c4ade..36407611ee 100644
--- 
a/streampipes-extensions/streampipes-processors-image-processing-jvm/src/main/java/org/apache/streampipes/processors/imageprocessing/jvm/processor/imageenrichment/ImageEnrichmentProcessor.java
+++ 
b/streampipes-extensions/streampipes-processors-image-processing-jvm/src/main/java/org/apache/streampipes/processors/imageprocessing/jvm/processor/imageenrichment/ImageEnrichmentProcessor.java
@@ -21,6 +21,7 @@ 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.model.DataProcessorType;
+import org.apache.streampipes.model.extensions.ExtensionAssetType;
 import org.apache.streampipes.model.graph.DataProcessorDescription;
 import org.apache.streampipes.model.runtime.Event;
 import 
org.apache.streampipes.processors.imageprocessing.jvm.processor.commons.ImagePropertyConstants;
@@ -32,7 +33,6 @@ import org.apache.streampipes.sdk.helpers.EpProperties;
 import org.apache.streampipes.sdk.helpers.Labels;
 import org.apache.streampipes.sdk.helpers.Locales;
 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;
 
@@ -49,17 +49,21 @@ import java.util.Map;
 import java.util.Optional;
 
 public class ImageEnrichmentProcessor extends StreamPipesDataProcessor {
+
+  public static final String ID = 
"org.apache.streampipes.processor.imageclassification.jvm.image-enricher";
+
   private String imageProperty;
   private String boxArray;
 
   @Override
   public DataProcessorDescription declareModel() {
-    return 
ProcessingElementBuilder.create("org.apache.streampipes.processor.imageclassification.jvm.image-enricher")
-        .withAssets(Assets.DOCUMENTATION, Assets.ICON)
+    return ProcessingElementBuilder.create(ID, 1)
+        .withAssets(ExtensionAssetType.DOCUMENTATION, ExtensionAssetType.ICON)
         .withLocales(Locales.EN)
         .category(DataProcessorType.IMAGE_PROCESSING)
         .requiredStream(RequiredBoxStream.getBoxStream())
         .outputStrategy(OutputStrategies.fixed(
+            EpProperties.timestampProperty("timestamp"),
             EpProperties.stringEp(Labels.empty(), 
ImagePropertyConstants.IMAGE.getProperty(),
                 "https://image.com";)
         ))
@@ -118,6 +122,7 @@ public class ImageEnrichmentProcessor extends 
StreamPipesDataProcessor {
 
       if (finalImage.isPresent()) {
         Event outEvent = new Event();
+        outEvent.addField("timestamp", System.currentTimeMillis());
         outEvent.addField(ImagePropertyConstants.IMAGE.getProperty(),
             Base64.getEncoder().encodeToString(finalImage.get()));
         out.collect(outEvent);
diff --git 
a/streampipes-extensions/streampipes-processors-image-processing-jvm/src/main/java/org/apache/streampipes/processors/imageprocessing/jvm/processor/migration/ImageEnrichmentProcessorMigrationv1.java
 
b/streampipes-extensions/streampipes-processors-image-processing-jvm/src/main/java/org/apache/streampipes/processors/imageprocessing/jvm/processor/migration/ImageEnrichmentProcessorMigrationv1.java
new file mode 100644
index 0000000000..67cf63a285
--- /dev/null
+++ 
b/streampipes-extensions/streampipes-processors-image-processing-jvm/src/main/java/org/apache/streampipes/processors/imageprocessing/jvm/processor/migration/ImageEnrichmentProcessorMigrationv1.java
@@ -0,0 +1,58 @@
+/*
+ * 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.imageprocessing.jvm.processor.migration;
+
+import 
org.apache.streampipes.extensions.api.extractor.IDataProcessorParameterExtractor;
+import org.apache.streampipes.extensions.api.migration.IDataProcessorMigrator;
+import org.apache.streampipes.model.extensions.svcdiscovery.SpServiceTagPrefix;
+import org.apache.streampipes.model.graph.DataProcessorInvocation;
+import org.apache.streampipes.model.migration.MigrationResult;
+import org.apache.streampipes.model.migration.ModelMigratorConfig;
+import 
org.apache.streampipes.processors.imageprocessing.jvm.processor.commons.ImagePropertyConstants;
+import 
org.apache.streampipes.processors.imageprocessing.jvm.processor.imageenrichment.ImageEnrichmentProcessor;
+import org.apache.streampipes.sdk.helpers.EpProperties;
+import org.apache.streampipes.sdk.helpers.Labels;
+import org.apache.streampipes.sdk.helpers.OutputStrategies;
+
+import java.util.List;
+
+public class ImageEnrichmentProcessorMigrationv1 implements 
IDataProcessorMigrator {
+  @Override
+  public ModelMigratorConfig config() {
+    return new ModelMigratorConfig(
+        ImageEnrichmentProcessor.ID,
+        SpServiceTagPrefix.DATA_PROCESSOR,
+        0,
+        1);
+  }
+
+  @Override
+  public MigrationResult<DataProcessorInvocation> 
migrate(DataProcessorInvocation element,
+                                                          
IDataProcessorParameterExtractor extractor)
+      throws RuntimeException {
+    element.setOutputStrategies(List.of(
+        OutputStrategies.fixed(
+            EpProperties.timestampProperty("timestamp"),
+            EpProperties.stringEp(Labels.empty(), 
ImagePropertyConstants.IMAGE.getProperty(),
+                "https://image.com";)
+        )
+    ));
+    return MigrationResult.success(element);
+  }
+}

Reply via email to