From a11a3ba8e8f4d34d6ed5fe117bcecf6d31402461 Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Tue, 6 Feb 2024 12:38:15 +0100 Subject: [PATCH] Fixing inheritance --- .../gcube/accounting/aggregator/aggregation/Aggregator.java | 6 +++--- .../aggregator/persistence/AggregatorPersistence.java | 4 +--- .../aggregator/persistence/AggregatorPersistenceDst.java | 4 ++-- .../aggregator/persistence/AggregatorPersistenceSrc.java | 3 ++- .../aggregator/persistence/AggregatorPersistenceStatus.java | 3 ++- .../aggregator/persistence/PostgreSQLConnector.java | 3 ++- .../aggregator/persistence/PostgreSQLConnectorDst.java | 4 ++-- 7 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/gcube/accounting/aggregator/aggregation/Aggregator.java b/src/main/java/org/gcube/accounting/aggregator/aggregation/Aggregator.java index 66e7671..bfcd68d 100644 --- a/src/main/java/org/gcube/accounting/aggregator/aggregation/Aggregator.java +++ b/src/main/java/org/gcube/accounting/aggregator/aggregation/Aggregator.java @@ -10,7 +10,7 @@ import java.util.UUID; import java.util.concurrent.TimeUnit; import org.gcube.accounting.aggregator.persistence.AggregatorPersistenceFactory; -import org.gcube.accounting.aggregator.persistence.AggregatorPersistenceStatus; +import org.gcube.accounting.aggregator.persistence.AggregatorPersistenceSrc; import org.gcube.accounting.aggregator.status.AggregationState; import org.gcube.accounting.aggregator.status.AggregationStatus; import org.gcube.accounting.aggregator.utility.Constant; @@ -64,8 +64,8 @@ public class Aggregator { if(AggregationState.canContinue(aggregationStatus.getAggregationState(),AggregationState.STARTED)) { startTime = Utility.getUTCCalendarInstance(); - AggregatorPersistenceStatus aggregatorPersistenceStatus = AggregatorPersistenceFactory.getAggregatorPersistenceStatus(); - ResultSet resultSet = aggregatorPersistenceStatus.getResultSetOfRecordToBeAggregated(aggregationStatus); + AggregatorPersistenceSrc aggregatorPersistenceSrc = AggregatorPersistenceFactory.getAggregatorPersistenceSrc(); + ResultSet resultSet = aggregatorPersistenceSrc.getResultSetOfRecordToBeAggregated(aggregationStatus); retrieveAndAggregate(resultSet); } diff --git a/src/main/java/org/gcube/accounting/aggregator/persistence/AggregatorPersistence.java b/src/main/java/org/gcube/accounting/aggregator/persistence/AggregatorPersistence.java index b9fd312..4350e0e 100644 --- a/src/main/java/org/gcube/accounting/aggregator/persistence/AggregatorPersistence.java +++ b/src/main/java/org/gcube/accounting/aggregator/persistence/AggregatorPersistence.java @@ -1,10 +1,8 @@ package org.gcube.accounting.aggregator.persistence; -import org.gcube.accounting.analytics.persistence.AccountingPersistenceBackendQuery; - /** * @author Luca Frosini (ISTI - CNR) */ -public interface AggregatorPersistence extends AccountingPersistenceBackendQuery { +public interface AggregatorPersistence { } diff --git a/src/main/java/org/gcube/accounting/aggregator/persistence/AggregatorPersistenceDst.java b/src/main/java/org/gcube/accounting/aggregator/persistence/AggregatorPersistenceDst.java index 02f28e9..308aa10 100644 --- a/src/main/java/org/gcube/accounting/aggregator/persistence/AggregatorPersistenceDst.java +++ b/src/main/java/org/gcube/accounting/aggregator/persistence/AggregatorPersistenceDst.java @@ -7,8 +7,8 @@ import org.gcube.documentstore.records.Record; */ public interface AggregatorPersistenceDst extends AggregatorPersistence { - void insert(Record record); + public void insert(Record record) throws Exception; - void commitAndClose(); + public void commitAndClose() throws Exception; } diff --git a/src/main/java/org/gcube/accounting/aggregator/persistence/AggregatorPersistenceSrc.java b/src/main/java/org/gcube/accounting/aggregator/persistence/AggregatorPersistenceSrc.java index 84802cb..1b09bcb 100644 --- a/src/main/java/org/gcube/accounting/aggregator/persistence/AggregatorPersistenceSrc.java +++ b/src/main/java/org/gcube/accounting/aggregator/persistence/AggregatorPersistenceSrc.java @@ -3,12 +3,13 @@ package org.gcube.accounting.aggregator.persistence; import java.sql.ResultSet; import org.gcube.accounting.aggregator.status.AggregationStatus; +import org.gcube.accounting.analytics.persistence.AccountingPersistenceBackendQuery; import org.gcube.com.fasterxml.jackson.databind.JsonNode; /** * @author Luca Frosini (ISTI - CNR) */ -public interface AggregatorPersistenceSrc extends AggregatorPersistence { +public interface AggregatorPersistenceSrc extends AggregatorPersistence, AccountingPersistenceBackendQuery { public ResultSet getResultSetOfRecordToBeAggregated(AggregationStatus aggregationStatus) throws Exception; diff --git a/src/main/java/org/gcube/accounting/aggregator/persistence/AggregatorPersistenceStatus.java b/src/main/java/org/gcube/accounting/aggregator/persistence/AggregatorPersistenceStatus.java index cc447ae..6f206f2 100644 --- a/src/main/java/org/gcube/accounting/aggregator/persistence/AggregatorPersistenceStatus.java +++ b/src/main/java/org/gcube/accounting/aggregator/persistence/AggregatorPersistenceStatus.java @@ -5,11 +5,12 @@ import java.util.List; import org.gcube.accounting.aggregator.aggregation.AggregationType; import org.gcube.accounting.aggregator.status.AggregationStatus; +import org.gcube.accounting.analytics.persistence.AccountingPersistenceBackendQuery; /** * @author Luca Frosini (ISTI - CNR) */ -public interface AggregatorPersistenceStatus extends AggregatorPersistence { +public interface AggregatorPersistenceStatus extends AggregatorPersistence, AccountingPersistenceBackendQuery { public List getUnterminated(String recordType, AggregationType aggregationType, Date aggregationStartDate, Date aggregationEndDate, boolean forceRestart) throws Exception; diff --git a/src/main/java/org/gcube/accounting/aggregator/persistence/PostgreSQLConnector.java b/src/main/java/org/gcube/accounting/aggregator/persistence/PostgreSQLConnector.java index 1f7c25c..ad741ec 100644 --- a/src/main/java/org/gcube/accounting/aggregator/persistence/PostgreSQLConnector.java +++ b/src/main/java/org/gcube/accounting/aggregator/persistence/PostgreSQLConnector.java @@ -23,6 +23,7 @@ import org.gcube.accounting.aggregator.status.AggregationStateEvent; import org.gcube.accounting.aggregator.status.AggregationStatus; import org.gcube.accounting.aggregator.utility.Constant; import org.gcube.accounting.aggregator.utility.Utility; +import org.gcube.accounting.analytics.persistence.AccountingPersistenceBackendQuery; import org.gcube.accounting.analytics.persistence.AccountingPersistenceBackendQueryConfiguration; import org.gcube.accounting.analytics.persistence.postgresql.AccountingPersistenceQueryPostgreSQL; import org.gcube.accounting.datamodel.AggregatedUsageRecord; @@ -46,7 +47,7 @@ public class PostgreSQLConnector extends AccountingPersistenceQueryPostgreSQL im protected Connection connection; - protected PostgreSQLConnector(Class clazz) throws Exception { + protected PostgreSQLConnector(Class clazz) throws Exception { this.configuration = new AccountingPersistenceBackendQueryConfiguration(clazz); Map>> aggregatedRecords = RecordUtility.getAggregatedRecordClassesFound(); for(String typeName : aggregatedRecords.keySet()) { diff --git a/src/main/java/org/gcube/accounting/aggregator/persistence/PostgreSQLConnectorDst.java b/src/main/java/org/gcube/accounting/aggregator/persistence/PostgreSQLConnectorDst.java index fb7a4a3..c7f77da 100644 --- a/src/main/java/org/gcube/accounting/aggregator/persistence/PostgreSQLConnectorDst.java +++ b/src/main/java/org/gcube/accounting/aggregator/persistence/PostgreSQLConnectorDst.java @@ -33,12 +33,12 @@ public class PostgreSQLConnectorDst implements AggregatorPersistenceDst { } @Override - public void insert(Record record) { + public void insert(Record record) throws Exception { persistencePostgreSQL.insert(record); } @Override - public void commitAndClose() { + public void commitAndClose() throws Exception { persistencePostgreSQL.commitAndClose(); }