You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ze...@apache.org on 2020/05/16 22:24:02 UTC

[incubator-streampipes] branch dev updated: Add image property method to EpProperties

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


The following commit(s) were added to refs/heads/dev by this push:
     new 9d5ff76  Add image property method to EpProperties
9d5ff76 is described below

commit 9d5ff7680f0f4b722bb634df3a1e266f52117dad
Author: Philipp Zehnder <ze...@fzi.de>
AuthorDate: Sun May 17 00:23:31 2020 +0200

    Add image property method to EpProperties
---
 .../connect/adapter/format/image/ImageParser.java         | 10 +++-------
 .../org/apache/streampipes/sdk/helpers/EpProperties.java  | 15 +++++++++++++++
 2 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/streampipes-connect/src/main/java/org/apache/streampipes/connect/adapter/format/image/ImageParser.java b/streampipes-connect/src/main/java/org/apache/streampipes/connect/adapter/format/image/ImageParser.java
index 9bc3087..8fe436c 100644
--- a/streampipes-connect/src/main/java/org/apache/streampipes/connect/adapter/format/image/ImageParser.java
+++ b/streampipes-connect/src/main/java/org/apache/streampipes/connect/adapter/format/image/ImageParser.java
@@ -33,6 +33,8 @@ import java.net.URI;
 import java.util.Arrays;
 import java.util.List;
 
+import static org.apache.streampipes.sdk.helpers.EpProperties.imageProperty;
+
 
 public class ImageParser extends Parser {
 
@@ -55,13 +57,7 @@ public class ImageParser extends Parser {
     @Override
     public EventSchema getEventSchema(List<byte[]> oneEvent) {
         EventSchema resultSchema = new EventSchema();
-        EventPropertyPrimitive p = new EventPropertyPrimitive();
-        p.setRuntimeName("image");
-        p.setLabel("Image");
-        p.setRuntimeType(XSD._string.toString());
-
-        p.setDomainProperties(Arrays.asList(URI.create("https://image.com")));
-        resultSchema.addEventProperty(p);
+        resultSchema.addEventProperty(imageProperty("image"));
         return resultSchema;
     }
 }
diff --git a/streampipes-sdk/src/main/java/org/apache/streampipes/sdk/helpers/EpProperties.java b/streampipes-sdk/src/main/java/org/apache/streampipes/sdk/helpers/EpProperties.java
index f03555a..a08b0f1 100644
--- a/streampipes-sdk/src/main/java/org/apache/streampipes/sdk/helpers/EpProperties.java
+++ b/streampipes-sdk/src/main/java/org/apache/streampipes/sdk/helpers/EpProperties.java
@@ -27,7 +27,9 @@ import org.apache.streampipes.model.schema.EventPropertyPrimitive;
 import org.apache.streampipes.model.schema.PropertyScope;
 import org.apache.streampipes.model.schema.QuantitativeValue;
 import org.apache.streampipes.sdk.utils.Datatypes;
+import org.apache.streampipes.vocabulary.SPSensor;
 import org.apache.streampipes.vocabulary.XSD;
+import org.eclipse.rdf4j.model.vocabulary.SP;
 
 import java.net.URI;
 import java.util.ArrayList;
@@ -77,6 +79,19 @@ public class EpProperties {
   }
 
   /**
+   * Creates a new primitive property of type image (with data type string and domain property image
+   *
+   * @param runtimeName The field identifier of the event property at runtime.
+   * @return {@link org.apache.streampipes.model.schema.EventPropertyPrimitive}
+   */
+  public static EventPropertyPrimitive imageProperty(String runtimeName) {
+    EventPropertyPrimitive ep = ep(Labels.from("", "Image", ""),
+            XSD._string.toString(), runtimeName, SPSensor.IMAGE);
+    ep.setPropertyScope(PropertyScope.MEASUREMENT_PROPERTY.name());
+    return ep;
+  }
+
+  /**
    * Creates a new list-based event property of type integer and with the assigned domain property.
    *
    * @param label          A human-readable label of the property