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:12 UTC

[incubator-streampipes] 04/29: [STREAMPIPES-349] Add implementation of endpoint for 'removing all stored 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 2540b3e9025cf54084df1dbf86d505db54b69381
Author: Daniel Ebi <eb...@fzi.de>
AuthorDate: Fri Apr 30 10:31:21 2021 +0200

    [STREAMPIPES-349] Add implementation of endpoint for 'removing all stored measurement series'
---
 .../streampipes/dataexplorer/DataLakeManagementV4.java    | 15 +++++++++++++++
 .../org/apache/streampipes/ps/DataLakeResourceV4.java     |  6 ++----
 2 files changed, 17 insertions(+), 4 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 06e055c..2f177f6 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
@@ -18,8 +18,10 @@
 
 package org.apache.streampipes.dataexplorer;
 
+import org.apache.streampipes.dataexplorer.query.DeleteDataQuery;
 import org.apache.streampipes.dataexplorer.utils.DataExplorerUtils;
 import org.apache.streampipes.model.datalake.DataLakeMeasure;
+import org.influxdb.dto.QueryResult;
 
 import java.util.List;
 
@@ -29,4 +31,17 @@ public class DataLakeManagementV4 {
         List<DataLakeMeasure> allMeasurements = DataExplorerUtils.getInfos();
         return allMeasurements;
     }
+
+    public boolean removeAllMeasurements() {
+        List<DataLakeMeasure> allMeasurements = getAllMeasurements();
+
+        for (DataLakeMeasure measure : allMeasurements) {
+            QueryResult queryResult = new DeleteDataQuery(measure).executeQuery();
+            if (queryResult.hasError() || queryResult.getResults().get(0).getError() != null) {
+                return false;
+            }
+        }
+        return true;
+    }
+}
 }
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 942d32a..f16dc3a 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
@@ -160,9 +160,7 @@ public class DataLakeResourceV4 extends AbstractRestResource {
             responses = {
                     @ApiResponse(responseCode = "200", description = "All measurement series successfully removed")})
     public Response removeAll(@Parameter(in = ParameterIn.PATH, description = "username", required = true) @PathParam("username") String username) {
-        /**
-         * TODO: implementation of method stump
-         */
-        return null;
+        boolean isSuccess = this.dataLakeManagement.removeAllMeasurements();
+        return Response.ok(isSuccess).build();
     }
 }