Refactoring persistence to support src and dst

This commit is contained in:
Luca Frosini 2024-02-05 17:29:27 +01:00
parent abec9f97f8
commit 750c5ebb19
5 changed files with 55 additions and 12 deletions

View File

@ -1,8 +1,10 @@
package org.gcube.accounting.aggregator.persistence;
import org.gcube.accounting.analytics.persistence.AccountingPersistenceBackendQuery;
/**
* @author Luca Frosini (ISTI - CNR)
*/
public interface AggregatorPersistence {
public interface AggregatorPersistence extends AccountingPersistenceBackendQuery {
}

View File

@ -0,0 +1,26 @@
package org.gcube.accounting.aggregator.persistence;
import org.gcube.accounting.persistence.AccountingPersistenceConfiguration;
/**
* @author Luca Frosini (ISTI-CNR)
*/
public class AggregatorPersitenceConfiguration extends AccountingPersistenceConfiguration {
/**
* Default Constructor
*/
public AggregatorPersitenceConfiguration() {
super();
}
/**
* @param persistence The class of the persistence to instantiate
* @throws Exception if fails
*/
@SuppressWarnings({ "rawtypes" })
public AggregatorPersitenceConfiguration(Class<?> persistence) throws Exception {
super((Class) persistence);
}
}

View File

@ -46,17 +46,8 @@ public class PostgreSQLConnector extends AccountingPersistenceQueryPostgreSQL {
protected Connection connection;
private static PostgreSQLConnector postgreSQLConnector;
public static PostgreSQLConnector getPostgreSQLConnector() throws Exception {
if(postgreSQLConnector == null) {
postgreSQLConnector = new PostgreSQLConnector();
}
return postgreSQLConnector;
}
private PostgreSQLConnector() throws Exception {
this.configuration = new AccountingPersistenceBackendQueryConfiguration(AccountingPersistenceQueryPostgreSQL.class);
protected PostgreSQLConnector(Class<? extends AggregatorPersistence> clazz) throws Exception {
this.configuration = new AccountingPersistenceBackendQueryConfiguration(clazz);
Map<String, Class<? extends AggregatedRecord<?,?>>> aggregatedRecords = RecordUtility.getAggregatedRecordClassesFound();
for(String typeName : aggregatedRecords.keySet()) {
try {

View File

@ -0,0 +1,12 @@
package org.gcube.accounting.aggregator.persistence;
/**
* @author Luca Frosini (ISTI-CNR)
*/
public class PostgreSQLConnectorDst extends PostgreSQLConnector implements AggregatorPersistenceDst {
protected PostgreSQLConnectorDst() throws Exception {
super(AggregatorPersistenceDst.class);
}
}

View File

@ -0,0 +1,12 @@
package org.gcube.accounting.aggregator.persistence;
/**
* @author Luca Frosini (ISTI-CNR)
*/
public class PostgreSQLConnectorSrc extends PostgreSQLConnector implements AggregatorPersistenceSrc {
protected PostgreSQLConnectorSrc(Class<? extends AggregatorPersistenceSrc> clazz) throws Exception {
super(AggregatorPersistenceSrc.class);
}
}