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:47:35 UTC
[incubator-streampipes] 02/16: [STREAMPIPES-349] Add query element
'Grouping By Tags' 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 02685370be59f02e92f8a327124cb2eb23ebba80
Author: Daniel Ebi <eb...@fzi.de>
AuthorDate: Fri Jun 11 19:08:43 2021 +0200
[STREAMPIPES-349] Add query element 'Grouping By Tags' and corresponding parameter class
---
.../v4/params/GroupingByTagsParams.java | 42 +++++++++++++++++++++
.../v4/query/elements/GroupingByTags.java | 43 ++++++++++++++++++++++
2 files changed, 85 insertions(+)
diff --git a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/v4/params/GroupingByTagsParams.java b/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/v4/params/GroupingByTagsParams.java
new file mode 100644
index 0000000..bcbb02b
--- /dev/null
+++ b/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/v4/params/GroupingByTagsParams.java
@@ -0,0 +1,42 @@
+/*
+ * 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 java.util.ArrayList;
+import java.util.List;
+
+public class GroupingByTagsParams extends QueryParamsV4 {
+ private final List<String> groupingTags;
+
+ public static GroupingByTagsParams from(String measurementID, String groupingTagsSeparatedByComma) {
+ return new GroupingByTagsParams(measurementID, groupingTagsSeparatedByComma);
+ }
+
+ public GroupingByTagsParams(String measurementID, String groupingTagsSeparatedByComma) {
+ super(measurementID);
+ this.groupingTags = new ArrayList<>();
+ for (String tag : groupingTagsSeparatedByComma.split(",")) {
+ this.groupingTags.add(tag);
+ }
+ }
+
+ public List<String> getGroupingTags() {
+ return groupingTags;
+ }
+}
diff --git a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/v4/query/elements/GroupingByTags.java b/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/v4/query/elements/GroupingByTags.java
new file mode 100644
index 0000000..61b9b9e
--- /dev/null
+++ b/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/v4/query/elements/GroupingByTags.java
@@ -0,0 +1,43 @@
+/*
+ * 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.GroupingByTagsParams;
+import org.apache.streampipes.dataexplorer.v4.template.QueryTemplatesV4;
+
+public class GroupingByTags extends QueryElement<GroupingByTagsParams> {
+
+ public GroupingByTags(GroupingByTagsParams groupingByTagsParams) {
+ super(groupingByTagsParams);
+ }
+
+ @Override
+ protected String buildStatement(GroupingByTagsParams groupingByTagsParams) {
+ String tags = "";
+ for (String tag : groupingByTagsParams.getGroupingTags()) {
+ if (tags.equals("")) {
+ tags = tag;
+ } else {
+ tags = tags + ", " + tag;
+ }
+ }
+
+ return QueryTemplatesV4.groupByTags(tags);
+ }
+}