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:20:21 UTC
[incubator-streampipes] 13/29: Add query element "Time Boundary"
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 c8ca2a67249a3491f8214babd85bda01410f8daa
Author: Daniel Ebi <eb...@fzi.de>
AuthorDate: Fri Jun 11 19:03:56 2021 +0200
Add query element "Time Boundary" and corresponding parameter class
---
.../dataexplorer/v4/params/TimeBoundaryParams.java | 43 ++++++++++++++++++++++
.../v4/query/elements/TimeBoundary.java | 40 ++++++++++++++++++++
2 files changed, 83 insertions(+)
diff --git a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/v4/params/TimeBoundaryParams.java b/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/v4/params/TimeBoundaryParams.java
new file mode 100644
index 0000000..c893829
--- /dev/null
+++ b/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/v4/params/TimeBoundaryParams.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.params;
+
+public class TimeBoundaryParams extends QueryParamsV4 {
+
+ private final Long startDate;
+ private final Long endDate;
+
+ public static TimeBoundaryParams from(String measurementID, Long startDate, Long endDate) {
+ return new TimeBoundaryParams(measurementID, startDate, endDate);
+ }
+
+ protected TimeBoundaryParams(String measurementID, Long startDate, Long endDate) {
+ super(measurementID);
+ this.startDate = startDate;
+ this.endDate = endDate;
+ }
+
+ public Long getStartDate() {
+ return startDate;
+ }
+
+ public Long getEndDate() {
+ return endDate;
+ }
+}
diff --git a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/v4/query/elements/TimeBoundary.java b/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/v4/query/elements/TimeBoundary.java
new file mode 100644
index 0000000..bae5f27
--- /dev/null
+++ b/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/v4/query/elements/TimeBoundary.java
@@ -0,0 +1,40 @@
+/*
+ * 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.TimeBoundaryParams;
+import org.apache.streampipes.dataexplorer.v4.template.QueryTemplatesV4;
+
+public class TimeBoundary extends QueryElement<TimeBoundaryParams> {
+
+ public TimeBoundary(TimeBoundaryParams timeBoundaryParams) {
+ super(timeBoundaryParams);
+ }
+
+ @Override
+ protected String buildStatement(TimeBoundaryParams timeBoundaryParams) {
+ if (timeBoundaryParams.getStartDate() == null) {
+ return QueryTemplatesV4.whereTimeRightBound(timeBoundaryParams.getEndDate());
+ } else if (timeBoundaryParams.getEndDate() == null) {
+ return QueryTemplatesV4.whereTimeLeftBound(timeBoundaryParams.getStartDate());
+ } else {
+ return QueryTemplatesV4.whereTimeWithin(timeBoundaryParams.getStartDate(), timeBoundaryParams.getEndDate());
+ }
+ }
+}