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:36 UTC
[incubator-streampipes] 22/29: [STREAMPIPES-349] Add implementation
of endpoint for removing data from a single measurement series
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 228b5d137dc1f10561cd2501eca0789f33c9aa7b
Author: Daniel Ebi <eb...@fzi.de>
AuthorDate: Fri Jun 11 19:57:54 2021 +0200
[STREAMPIPES-349] Add implementation of endpoint for removing data from a single measurement series
---
.../dataexplorer/DataLakeManagementV4.java | 21 +++++++++++++++++++++
.../apache/streampipes/ps/DataLakeResourceV4.java | 12 ++++++------
2 files changed, 27 insertions(+), 6 deletions(-)
diff --git a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/DataLakeManagementV4.java b/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/DataLakeManagementV4.java
index f1bc058..76a7577 100644
--- a/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/DataLakeManagementV4.java
+++ b/streampipes-data-explorer/src/main/java/org/apache/streampipes/dataexplorer/DataLakeManagementV4.java
@@ -23,12 +23,19 @@ import org.apache.streampipes.dataexplorer.query.DeleteDataQuery;
import org.apache.streampipes.dataexplorer.query.EditRetentionPolicyQuery;
import org.apache.streampipes.dataexplorer.query.ShowRetentionPolicyQuery;
import org.apache.streampipes.dataexplorer.utils.DataExplorerUtils;
+import org.apache.streampipes.dataexplorer.v4.params.DeleteFromStatementParams;
+import org.apache.streampipes.dataexplorer.v4.params.QueryParamsV4;
+import org.apache.streampipes.dataexplorer.v4.params.TimeBoundaryParams;
+import org.apache.streampipes.dataexplorer.v4.query.DataExplorerQueryV4;
import org.apache.streampipes.model.datalake.DataLakeConfiguration;
import org.apache.streampipes.model.datalake.DataLakeMeasure;
import org.apache.streampipes.model.datalake.DataLakeRetentionPolicy;
+import org.apache.streampipes.model.datalake.DataResult;
import org.influxdb.dto.QueryResult;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
public class DataLakeManagementV4 {
@@ -49,6 +56,11 @@ public class DataLakeManagementV4 {
return true;
}
+ public DataResult deleteData(String measurementID, Long startDate, Long endDate) {
+ Map<String, QueryParamsV4> queryParts = getDeleteQueryParams(measurementID, startDate, endDate);
+ return new DataExplorerQueryV4(queryParts).executeQuery();
+ }
+
public DataLakeConfiguration getDataLakeConfiguration() {
List<DataLakeRetentionPolicy> retentionPolicies = getAllExistingRetentionPolicies();
return new DataLakeConfiguration(retentionPolicies);
@@ -91,4 +103,13 @@ public class DataLakeManagementV4 {
*/
return new ShowRetentionPolicyQuery(RetentionPolicyQueryParams.from("", "0s")).executeQuery();
}
+
+ public Map<String, QueryParamsV4> getDeleteQueryParams(String measurementID, Long startDate, Long endDate) {
+ Map<String, QueryParamsV4> queryParts = new HashMap<>();
+ queryParts.put("DELETE", DeleteFromStatementParams.from(measurementID));
+ if (startDate != null || endDate != null) {
+ queryParts.put("WHERE", TimeBoundaryParams.from(measurementID, startDate, endDate));
+ }
+ return queryParts;
+ }
}
diff --git a/streampipes-platform-services/src/main/java/org/apache/streampipes/ps/DataLakeResourceV4.java b/streampipes-platform-services/src/main/java/org/apache/streampipes/ps/DataLakeResourceV4.java
index 91807c1..cbef9de 100644
--- a/streampipes-platform-services/src/main/java/org/apache/streampipes/ps/DataLakeResourceV4.java
+++ b/streampipes-platform-services/src/main/java/org/apache/streampipes/ps/DataLakeResourceV4.java
@@ -28,6 +28,7 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse;
import org.apache.streampipes.dataexplorer.DataLakeManagementV4;
import org.apache.streampipes.model.datalake.DataLakeConfiguration;
import org.apache.streampipes.model.datalake.DataLakeMeasure;
+import org.apache.streampipes.model.datalake.DataResult;
import org.apache.streampipes.rest.impl.AbstractRestResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -76,12 +77,11 @@ public class DataLakeResourceV4 extends AbstractRestResource {
@ApiResponse(responseCode = "400", description = "Measurement series with given id not found")})
public Response deleteData(@Parameter(in = ParameterIn.PATH, description = "username", required = true) @PathParam("username") String username
, @Parameter(in = ParameterIn.PATH, description = "the id of the measurement series", required = true) @PathParam("measurementID") String measurementID
- , @Parameter(in = ParameterIn.QUERY, description = "start date for slicing operation") @QueryParam("startDate") String startDate
- , @Parameter(in = ParameterIn.QUERY, description = "end date for slicing operation") @QueryParam("endDate") String endDate) {
- /**
- * TODO: implementation of method stump
- */
- return null;
+ , @Parameter(in = ParameterIn.QUERY, description = "start date for slicing operation") @QueryParam("startDate") Long startDate
+ , @Parameter(in = ParameterIn.QUERY, description = "end date for slicing operation") @QueryParam("endDate") Long endDate) {
+
+ DataResult result = this.dataLakeManagement.deleteData(measurementID, startDate, endDate);
+ return ok();
}
@GET