You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by eb...@apache.org on 2021/06/11 18:43:26 UTC
[incubator-streampipes] 12/29: [STREAMPIPES-349] Add query element
'Select From Statement' and corresponding parameter class
This is an automated email from the ASF dual-hosted git repository.
ebi pushed a commit to branch STREAMPIPES-349
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git
commit 84f16a616c419093752e19583256f292771838f0
Author: Daniel Ebi <eb...@fzi.de>
AuthorDate: Fri Jun 11 19:02:30 2021 +0200
[STREAMPIPES-349] Add query element 'Select From Statement' and corresponding parameter class
---
.../v4/params/SelectFromStatementParams.java | 45 ++++++++++++++++++++++
.../v4/query/elements/SelectFromStatement.java | 37 ++++++++++++++++++
2 files changed, 82 insertions(+)
diff --git a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/v4/params/SelectFromStatementParams.java b/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/v4/params/SelectFromStatementParams.java
new file mode 100644
index 0000000..0385963
--- /dev/null
+++ b/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/v4/params/SelectFromStatementParams.java
@@ -0,0 +1,45 @@
+/*
+ * 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.dataexplorer.v4.params;
+
+import javax.annotation.Nullable;
+
+public class SelectFromStatementParams extends QueryParamsV4 {
+
+ private final String aggregationFunction;
+
+ public static SelectFromStatementParams from(String measurementID, @Nullable String aggregationFunction) {
+ return new SelectFromStatementParams(measurementID, aggregationFunction);
+ }
+
+ public SelectFromStatementParams(String measurementID) {
+ super(measurementID);
+ this.aggregationFunction = null;
+ }
+
+ public SelectFromStatementParams(String measurementID, String aggregationFunction) {
+ super(measurementID);
+ this.aggregationFunction = aggregationFunction;
+ }
+
+
+ public String getAggregationFunction() {
+ return aggregationFunction;
+ }
+}
diff --git a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/v4/query/elements/SelectFromStatement.java b/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/v4/query/elements/SelectFromStatement.java
new file mode 100644
index 0000000..efd7654
--- /dev/null
+++ b/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/v4/query/elements/SelectFromStatement.java
@@ -0,0 +1,37 @@
+/*
+ * 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.dataexplorer.v4.query.elements;
+
+import org.apache.streampipes.dataexplorer.v4.params.SelectFromStatementParams;
+import org.apache.streampipes.dataexplorer.v4.template.QueryTemplatesV4;
+
+public class SelectFromStatement extends QueryElement<SelectFromStatementParams> {
+ public SelectFromStatement(SelectFromStatementParams selectFromStatementParams) {
+ super(selectFromStatementParams);
+ }
+
+ @Override
+ protected String buildStatement(SelectFromStatementParams selectFromStatementParams) {
+ if (selectFromStatementParams.getAggregationFunction() == null) {
+ return QueryTemplatesV4.selectWildcardFrom(selectFromStatementParams.getIndex());
+ } else {
+ return QueryTemplatesV4.selectAggregationFrom(selectFromStatementParams.getIndex(), selectFromStatementParams.getAggregationFunction());
+ }
+ }
+}