From deaa100953f7ba39e612a7ceee0da1ba038aa009 Mon Sep 17 00:00:00 2001 From: Philipp Zehnder Date: Thu, 7 Mar 2024 08:22:41 +0100 Subject: [PATCH] refactor: Remove unused MonitoringDataStorage (#2514) --- .../storage/api/INoSqlStorage.java | 2 - .../api/IPipelineMonitoringDataStorage.java | 36 ---------- .../couchdb/CouchDbStorageManager.java | 7 -- .../impl/MonitoringDataStorageImpl.java | 69 ------------------- 4 files changed, 114 deletions(-) delete mode 100644 streampipes-storage-api/src/main/java/org/apache/streampipes/storage/api/IPipelineMonitoringDataStorage.java delete mode 100644 streampipes-storage-couchdb/src/main/java/org/apache/streampipes/storage/couchdb/impl/MonitoringDataStorageImpl.java diff --git a/streampipes-storage-api/src/main/java/org/apache/streampipes/storage/api/INoSqlStorage.java b/streampipes-storage-api/src/main/java/org/apache/streampipes/storage/api/INoSqlStorage.java index 473e8d1ca6..a87b0fabff 100644 --- a/streampipes-storage-api/src/main/java/org/apache/streampipes/storage/api/INoSqlStorage.java +++ b/streampipes-storage-api/src/main/java/org/apache/streampipes/storage/api/INoSqlStorage.java @@ -38,8 +38,6 @@ public interface INoSqlStorage { IUserStorage getUserStorageAPI(); - IPipelineMonitoringDataStorage getMonitoringDataStorageApi(); - INotificationStorage getNotificationStorageApi(); IPipelineCategoryStorage getPipelineCategoryStorageApi(); diff --git a/streampipes-storage-api/src/main/java/org/apache/streampipes/storage/api/IPipelineMonitoringDataStorage.java b/streampipes-storage-api/src/main/java/org/apache/streampipes/storage/api/IPipelineMonitoringDataStorage.java deleted file mode 100644 index eade25eabc..0000000000 --- a/streampipes-storage-api/src/main/java/org/apache/streampipes/storage/api/IPipelineMonitoringDataStorage.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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.storage.api; - -import org.apache.streampipes.model.client.monitoring.JobReport; - -import java.util.List; - -public interface IPipelineMonitoringDataStorage { - - List getAllMonitoringJobReports(); - - List getAllMonitoringJobReportsByElement(String elementUri); - - JobReport getLatestJobReport(String elementUri); - - boolean storeJobReport(JobReport jobReport); - - -} diff --git a/streampipes-storage-couchdb/src/main/java/org/apache/streampipes/storage/couchdb/CouchDbStorageManager.java b/streampipes-storage-couchdb/src/main/java/org/apache/streampipes/storage/couchdb/CouchDbStorageManager.java index 1ae99a5527..87886fc7c9 100644 --- a/streampipes-storage-couchdb/src/main/java/org/apache/streampipes/storage/couchdb/CouchDbStorageManager.java +++ b/streampipes-storage-couchdb/src/main/java/org/apache/streampipes/storage/couchdb/CouchDbStorageManager.java @@ -42,7 +42,6 @@ import org.apache.streampipes.storage.api.IPipelineElementConnectionStorage; import org.apache.streampipes.storage.api.IPipelineElementDescriptionStorage; import org.apache.streampipes.storage.api.IPipelineElementTemplateStorage; -import org.apache.streampipes.storage.api.IPipelineMonitoringDataStorage; import org.apache.streampipes.storage.api.IPipelineStorage; import org.apache.streampipes.storage.api.ISpCoreConfigurationStorage; import org.apache.streampipes.storage.api.IUserActivationTokenStorage; @@ -68,7 +67,6 @@ import org.apache.streampipes.storage.couchdb.impl.FileMetadataStorageImpl; import org.apache.streampipes.storage.couchdb.impl.GenericStorageImpl; import org.apache.streampipes.storage.couchdb.impl.ImageStorageImpl; -import org.apache.streampipes.storage.couchdb.impl.MonitoringDataStorageImpl; import org.apache.streampipes.storage.couchdb.impl.NotificationStorageImpl; import org.apache.streampipes.storage.couchdb.impl.PasswordRecoveryTokenImpl; import org.apache.streampipes.storage.couchdb.impl.PermissionStorageImpl; @@ -126,11 +124,6 @@ public IUserStorage getUserStorageAPI() { return new UserStorage(); } - @Override - public IPipelineMonitoringDataStorage getMonitoringDataStorageApi() { - return new MonitoringDataStorageImpl(); - } - @Override public INotificationStorage getNotificationStorageApi() { return new NotificationStorageImpl(); diff --git a/streampipes-storage-couchdb/src/main/java/org/apache/streampipes/storage/couchdb/impl/MonitoringDataStorageImpl.java b/streampipes-storage-couchdb/src/main/java/org/apache/streampipes/storage/couchdb/impl/MonitoringDataStorageImpl.java deleted file mode 100644 index 1b51d44f24..0000000000 --- a/streampipes-storage-couchdb/src/main/java/org/apache/streampipes/storage/couchdb/impl/MonitoringDataStorageImpl.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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.storage.couchdb.impl; - -import org.apache.streampipes.model.client.monitoring.JobReport; -import org.apache.streampipes.storage.api.IPipelineMonitoringDataStorage; -import org.apache.streampipes.storage.couchdb.dao.AbstractDao; -import org.apache.streampipes.storage.couchdb.utils.Utils; - -import java.util.Comparator; -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -public class MonitoringDataStorageImpl extends AbstractDao implements IPipelineMonitoringDataStorage { - - public MonitoringDataStorageImpl() { - super(Utils::getCouchDbMonitoringClient, JobReport.class); - } - - @Override - public List getAllMonitoringJobReports() { - return findAll(); - } - - @Override - public List getAllMonitoringJobReportsByElement(String elementUri) { - List allReports = findAll(); - return getJobReportStream(elementUri, allReports) - .collect(Collectors.toList()); - } - - private Stream getJobReportStream(String elementUri, List allReports) { - return allReports - .stream() - .filter(r -> r.getElementId().equals(elementUri)); - } - - @Override - public JobReport getLatestJobReport(String elementUri) { - List allReports = findAll(); - return getJobReportStream(elementUri, allReports) - .sorted(Comparator.comparing(JobReport::getGenerationDate)) - .findFirst() - .get(); - } - - @Override - public boolean storeJobReport(JobReport jobReport) { - return persist(jobReport).k; - } - -}