Removed static usage

This commit is contained in:
Luca Frosini 2024-02-29 16:13:50 +01:00
parent 2ffffd1515
commit bea1660252
5 changed files with 13 additions and 6 deletions

BIN
.DS_Store vendored

Binary file not shown.

1
.gitignore vendored
View File

@ -28,3 +28,4 @@ hs_err_pid*
/.project /.project
/.settings /.settings
/.DS_Store

View File

@ -2,6 +2,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
# Changelog for Document Store Backend Connector Library for PostgreSQL # Changelog for Document Store Backend Connector Library for PostgreSQL
## [v1.0.1-SNAPSHOT]
- Enhanced accounting-postgresql-utilities range
## [v1.0.0] ## [v1.0.0]

View File

@ -10,7 +10,7 @@
<groupId>org.gcube.data.publishing</groupId> <groupId>org.gcube.data.publishing</groupId>
<artifactId>document-store-lib-postgresql</artifactId> <artifactId>document-store-lib-postgresql</artifactId>
<version>1.0.0</version> <version>1.0.1-SNAPSHOT</version>
<name>Document Store Backend Connector Library for PostgreSQL</name> <name>Document Store Backend Connector Library for PostgreSQL</name>
<description>Document Store Backend Connector Library for PostgreSQL</description> <description>Document Store Backend Connector Library for PostgreSQL</description>
@ -51,7 +51,7 @@
<dependency> <dependency>
<groupId>org.gcube.accounting</groupId> <groupId>org.gcube.accounting</groupId>
<artifactId>accounting-postgresql-utilities</artifactId> <artifactId>accounting-postgresql-utilities</artifactId>
<version>[1.0.0, 2.0.0-SNAPSHOT)</version> <version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/org.postgresql/postgresql --> <!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
<dependency> <dependency>

View File

@ -24,14 +24,16 @@ public class StatementMap {
}; };
private PersistenceBackendConfiguration configuration; private PersistenceBackendConfiguration configuration;
private RecordToDBMapping recordToDBMapping;
public StatementMap(PersistenceBackendConfiguration configuration) { public StatementMap(PersistenceBackendConfiguration configuration) {
this.configuration = configuration; this.configuration = configuration;
this.recordToDBMapping = new RecordToDBMapping();
Map<String, Class<? extends AggregatedRecord<?,?>>> aggregatedRecords = RecordUtility.getAggregatedRecordClassesFound(); Map<String, Class<? extends AggregatedRecord<?,?>>> aggregatedRecords = RecordUtility.getAggregatedRecordClassesFound();
for(String typeName : aggregatedRecords.keySet()) { for(String typeName : aggregatedRecords.keySet()) {
try { try {
Class<? extends AggregatedRecord<?,?>> clz = aggregatedRecords.get(typeName); Class<? extends AggregatedRecord<?,?>> clz = aggregatedRecords.get(typeName);
RecordToDBMapping.addRecordToDB(clz, configuration); recordToDBMapping.addRecordToDB(clz, configuration);
} catch (Exception e) { } catch (Exception e) {
new RuntimeException(e); new RuntimeException(e);
} }
@ -39,10 +41,10 @@ public class StatementMap {
} }
protected Connection getConnection(Class<? extends AggregatedRecord<?, ?>> clz) throws Exception { protected Connection getConnection(Class<? extends AggregatedRecord<?, ?>> clz) throws Exception {
RecordToDBConnection recordDBInfo = RecordToDBMapping.getRecordDBInfo(clz); RecordToDBConnection recordDBInfo = recordToDBMapping.getRecordDBInfo(clz);
if(recordDBInfo == null) { if(recordDBInfo == null) {
RecordToDBMapping.addRecordToDB(clz, configuration); recordToDBMapping.addRecordToDB(clz, configuration);
recordDBInfo = RecordToDBMapping.getRecordDBInfo(clz); recordDBInfo = recordToDBMapping.getRecordDBInfo(clz);
} }
return recordDBInfo.getConnection(); return recordDBInfo.getConnection();
} }