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/incubator-streampipes.git


The following commit(s) were added to refs/heads/dev by this push:
     new 8617c35  [STREAMPIPES-250] Add Siddhi EPL object model for select 
statements
     new f015efc  Merge branch 'dev' of github.com:apache/incubator-streampipes 
into dev
8617c35 is described below

commit 8617c358e29e7ffca0501bb6ad934cf6f84bc07b
Author: Dominik Riemer <[email protected]>
AuthorDate: Thu Oct 22 20:43:15 2020 +0200

    [STREAMPIPES-250] Add Siddhi EPL object model for select statements
---
 .../wrapper/siddhi/constants/SiddhiConstants.java     |  4 ++++
 .../wrapper/siddhi/query/SelectClause.java            |  2 +-
 .../wrapper/siddhi/query/expression/Expression.java   |  9 +++++++++
 .../wrapper/siddhi/query/expression/Expressions.java  | 13 ++++++++-----
 .../siddhi/query/expression/PropertyExpression.java   | 16 ++++++++++++++--
 ...yExpression.java => PropertyRenameExpression.java} | 19 +++++++++++--------
 .../streampipes/wrapper/siddhi/utils/SiddhiUtils.java |  4 ++++
 7 files changed, 51 insertions(+), 16 deletions(-)

diff --git 
a/streampipes-wrapper-siddhi/src/main/java/org/apache/streampipes/wrapper/siddhi/constants/SiddhiConstants.java
 
b/streampipes-wrapper-siddhi/src/main/java/org/apache/streampipes/wrapper/siddhi/constants/SiddhiConstants.java
index 2bcd492..0decddd 100644
--- 
a/streampipes-wrapper-siddhi/src/main/java/org/apache/streampipes/wrapper/siddhi/constants/SiddhiConstants.java
+++ 
b/streampipes-wrapper-siddhi/src/main/java/org/apache/streampipes/wrapper/siddhi/constants/SiddhiConstants.java
@@ -24,6 +24,10 @@ public class SiddhiConstants {
 
   public static final String WHITESPACE = " ";
   public static final String COMMA = ", ";
+  public static final String EMPTY = "";
+  public static final String PARENTHESIS_OPEN = "(";
+  public static final String PARENTHESIS_CLOSE = ")";
+  public static final String AS = "as";
 
   public static final String ASTERISK = "*";
 
diff --git 
a/streampipes-wrapper-siddhi/src/main/java/org/apache/streampipes/wrapper/siddhi/query/SelectClause.java
 
b/streampipes-wrapper-siddhi/src/main/java/org/apache/streampipes/wrapper/siddhi/query/SelectClause.java
index 2b64e9d..2d6d7f1 100644
--- 
a/streampipes-wrapper-siddhi/src/main/java/org/apache/streampipes/wrapper/siddhi/query/SelectClause.java
+++ 
b/streampipes-wrapper-siddhi/src/main/java/org/apache/streampipes/wrapper/siddhi/query/SelectClause.java
@@ -68,7 +68,7 @@ public class SelectClause extends Expression {
     String properties = join(SiddhiConstants.COMMA,
             
this.outputProperties.stream().map(Expression::toSiddhiEpl).collect(Collectors.toList()));
 
-    return join(SiddhiConstants.WHITESPACE, properties);
+    return join(SiddhiConstants.WHITESPACE, SiddhiConstants.SELECT, 
properties);
   }
 
   @Override
diff --git 
a/streampipes-wrapper-siddhi/src/main/java/org/apache/streampipes/wrapper/siddhi/query/expression/Expression.java
 
b/streampipes-wrapper-siddhi/src/main/java/org/apache/streampipes/wrapper/siddhi/query/expression/Expression.java
index 3d5d15a..df93f57 100644
--- 
a/streampipes-wrapper-siddhi/src/main/java/org/apache/streampipes/wrapper/siddhi/query/expression/Expression.java
+++ 
b/streampipes-wrapper-siddhi/src/main/java/org/apache/streampipes/wrapper/siddhi/query/expression/Expression.java
@@ -17,6 +17,8 @@
  */
 package org.apache.streampipes.wrapper.siddhi.query.expression;
 
+import org.apache.streampipes.wrapper.siddhi.constants.SiddhiConstants;
+
 import java.util.Arrays;
 import java.util.List;
 import java.util.StringJoiner;
@@ -27,6 +29,13 @@ public abstract class Expression {
     return join(delimiter, Arrays.asList(substrings));
   }
 
+  protected String joinWithParenthesis(String delimiter, String... substrings) 
{
+    return join(SiddhiConstants.EMPTY,
+            SiddhiConstants.PARENTHESIS_OPEN,
+            join(delimiter, substrings),
+            SiddhiConstants.PARENTHESIS_CLOSE);
+  }
+
   protected String join(String delimiter, List<String> substrings) {
     StringJoiner joiner = new StringJoiner(delimiter);
     substrings.forEach(joiner::add);
diff --git 
a/streampipes-wrapper-siddhi/src/main/java/org/apache/streampipes/wrapper/siddhi/query/expression/Expressions.java
 
b/streampipes-wrapper-siddhi/src/main/java/org/apache/streampipes/wrapper/siddhi/query/expression/Expressions.java
index 30905df..4d52445 100644
--- 
a/streampipes-wrapper-siddhi/src/main/java/org/apache/streampipes/wrapper/siddhi/query/expression/Expressions.java
+++ 
b/streampipes-wrapper-siddhi/src/main/java/org/apache/streampipes/wrapper/siddhi/query/expression/Expressions.java
@@ -22,20 +22,23 @@ import 
org.apache.streampipes.wrapper.siddhi.model.EventPropertyDef;
 
 public class Expressions {
 
+  public static PropertyExpression property(String streamName, String 
propertyName) {
+    return new PropertyExpression(streamName, propertyName);
+  }
+
   public static PropertyExpression property(String propertyName) {
-    //return new PropertyExpression(propertyName);
-    return null;
+    return new PropertyExpression(propertyName);
   }
 
   public static PropertyExpression property(SiddhiStreamSelector selector, 
String propertyName) {
-    return null;
+    return new PropertyExpression(selector, propertyName);
   }
 
   public static PropertyExpression property(EventPropertyDef propertyDef) {
-    return null;
+    return new PropertyExpression(propertyDef);
   }
 
-  public static Expression as(Expression property, String targetName) {
+  public static Expression as(PropertyExpression property, String targetName) {
     return null;
   }
 }
diff --git 
a/streampipes-wrapper-siddhi/src/main/java/org/apache/streampipes/wrapper/siddhi/query/expression/PropertyExpression.java
 
b/streampipes-wrapper-siddhi/src/main/java/org/apache/streampipes/wrapper/siddhi/query/expression/PropertyExpression.java
index 2a2610d..2c2fab8 100644
--- 
a/streampipes-wrapper-siddhi/src/main/java/org/apache/streampipes/wrapper/siddhi/query/expression/PropertyExpression.java
+++ 
b/streampipes-wrapper-siddhi/src/main/java/org/apache/streampipes/wrapper/siddhi/query/expression/PropertyExpression.java
@@ -17,20 +17,32 @@
  */
 package org.apache.streampipes.wrapper.siddhi.query.expression;
 
+import org.apache.streampipes.wrapper.siddhi.constants.SiddhiStreamSelector;
 import org.apache.streampipes.wrapper.siddhi.model.EventPropertyDef;
+import org.apache.streampipes.wrapper.siddhi.utils.SiddhiUtils;
 
 public class PropertyExpression extends Expression {
 
-  public PropertyExpression(String property) {
+  private String siddhiPropertyName;
 
+  public PropertyExpression(String streamName, String property) {
+    this.siddhiPropertyName = join(".", streamName, property);
+  }
+
+  public PropertyExpression(String property) {
+    this.siddhiPropertyName = property;
   }
 
   public PropertyExpression(EventPropertyDef propertyDef) {
+    this.siddhiPropertyName = propertyDef.getSelectorPrefix() + 
propertyDef.getFieldName();
+  }
 
+  public PropertyExpression(SiddhiStreamSelector selector, String 
propertyName) {
+    this.siddhiPropertyName = selector.getPrefix() + propertyName;
   }
 
   @Override
   public String toSiddhiEpl() {
-    return null;
+    return SiddhiUtils.prepareProperty(siddhiPropertyName);
   }
 }
diff --git 
a/streampipes-wrapper-siddhi/src/main/java/org/apache/streampipes/wrapper/siddhi/query/expression/PropertyExpression.java
 
b/streampipes-wrapper-siddhi/src/main/java/org/apache/streampipes/wrapper/siddhi/query/expression/PropertyRenameExpression.java
similarity index 62%
copy from 
streampipes-wrapper-siddhi/src/main/java/org/apache/streampipes/wrapper/siddhi/query/expression/PropertyExpression.java
copy to 
streampipes-wrapper-siddhi/src/main/java/org/apache/streampipes/wrapper/siddhi/query/expression/PropertyRenameExpression.java
index 2a2610d..1739a91 100644
--- 
a/streampipes-wrapper-siddhi/src/main/java/org/apache/streampipes/wrapper/siddhi/query/expression/PropertyExpression.java
+++ 
b/streampipes-wrapper-siddhi/src/main/java/org/apache/streampipes/wrapper/siddhi/query/expression/PropertyRenameExpression.java
@@ -17,20 +17,23 @@
  */
 package org.apache.streampipes.wrapper.siddhi.query.expression;
 
-import org.apache.streampipes.wrapper.siddhi.model.EventPropertyDef;
+import org.apache.streampipes.wrapper.siddhi.constants.SiddhiConstants;
 
-public class PropertyExpression extends Expression {
+public class PropertyRenameExpression extends Expression {
 
-  public PropertyExpression(String property) {
-
-  }
-
-  public PropertyExpression(EventPropertyDef propertyDef) {
+  private PropertyExpression propertyExpression;
+  private String newPropertyName;
 
+  public PropertyRenameExpression(PropertyExpression property, String 
newPropertyName) {
+    this.propertyExpression = property;
+    this.newPropertyName = newPropertyName;
   }
 
   @Override
   public String toSiddhiEpl() {
-    return null;
+    return joinWithParenthesis(SiddhiConstants.WHITESPACE,
+            propertyExpression.toSiddhiEpl(),
+            SiddhiConstants.AS,
+            newPropertyName);
   }
 }
diff --git 
a/streampipes-wrapper-siddhi/src/main/java/org/apache/streampipes/wrapper/siddhi/utils/SiddhiUtils.java
 
b/streampipes-wrapper-siddhi/src/main/java/org/apache/streampipes/wrapper/siddhi/utils/SiddhiUtils.java
index b5bc847..fb98d38 100644
--- 
a/streampipes-wrapper-siddhi/src/main/java/org/apache/streampipes/wrapper/siddhi/utils/SiddhiUtils.java
+++ 
b/streampipes-wrapper-siddhi/src/main/java/org/apache/streampipes/wrapper/siddhi/utils/SiddhiUtils.java
@@ -77,4 +77,8 @@ public class SiddhiUtils {
             .replaceAll("-", "")
             .replaceAll("::", "");
   }
+
+  public static String prepareProperty(String propertyName) {
+    return propertyName.replaceAll("::", "");
+  }
 }

Reply via email to