From 4d52bf71237b66ea0ca75e4f3c94724d839a7c87 Mon Sep 17 00:00:00 2001 From: Fabio Sinibaldi Date: Fri, 27 May 2022 15:04:35 +0200 Subject: [PATCH] Merged from patches --- .../geoportal/service/GeoPortalService.java | 3 ++- .../service/engine/postgis/PostgisIndex.java | 16 ++++++++-------- .../providers/PostgisConnectionProvider.java | 7 ++++--- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/geoportal-service/src/main/java/org/gcube/application/geoportal/service/GeoPortalService.java b/geoportal-service/src/main/java/org/gcube/application/geoportal/service/GeoPortalService.java index 4c06509..bead820 100644 --- a/geoportal-service/src/main/java/org/gcube/application/geoportal/service/GeoPortalService.java +++ b/geoportal-service/src/main/java/org/gcube/application/geoportal/service/GeoPortalService.java @@ -8,6 +8,7 @@ import org.gcube.application.geoportal.common.rest.InterfaceConstants; import org.gcube.application.geoportal.common.utils.StorageUtils; import org.gcube.application.geoportal.service.engine.mongo.UCDManagerI; import org.gcube.application.geoportal.service.engine.postgis.PostgisDBManager; +import org.gcube.application.geoportal.service.engine.postgis.PostgisDBManagerI; import org.gcube.application.geoportal.service.engine.providers.*; import org.gcube.application.geoportal.service.engine.providers.ucd.ProfileMap; import org.gcube.application.geoportal.service.engine.providers.ucd.LocalFolderProfileMapCache; @@ -50,7 +51,7 @@ public class GeoPortalService extends ResourceConfig{ ImplementationProvider.get().setEngine(new MongoClientProvider(), Mongo.class); ImplementationProvider.get().setEngine(new StorageClientProvider(), StorageUtils.class); - ImplementationProvider.get().setEngine(new PostgisConnectionProvider(), PostgisDBManager.class); + ImplementationProvider.get().setEngine(new PostgisConnectionProvider(), PostgisDBManagerI.class); ImplementationProvider.get().setEngine(new SingleISResourceUCDProvider(), ProfileMap.class); ImplementationProvider.get().setEngine(new PluginManager(), PluginManager.PluginMap.class); ImplementationProvider.get().setEngine(new StorageHubProvider(), StorageHubClient.class); diff --git a/geoportal-service/src/main/java/org/gcube/application/geoportal/service/engine/postgis/PostgisIndex.java b/geoportal-service/src/main/java/org/gcube/application/geoportal/service/engine/postgis/PostgisIndex.java index e21fcc2..8df7e0f 100644 --- a/geoportal-service/src/main/java/org/gcube/application/geoportal/service/engine/postgis/PostgisIndex.java +++ b/geoportal-service/src/main/java/org/gcube/application/geoportal/service/engine/postgis/PostgisIndex.java @@ -1,19 +1,19 @@ package org.gcube.application.geoportal.service.engine.postgis; import lombok.extern.slf4j.Slf4j; +import org.gcube.application.cms.implementations.ImplementationProvider; +import org.gcube.application.cms.serialization.Serialization; import org.gcube.application.geoportal.common.model.legacy.Concessione; +import org.gcube.application.geoportal.common.model.rest.ConfigurationException; import org.gcube.application.geoportal.common.model.rest.DatabaseConnection; import org.gcube.application.geoportal.common.model.rest.PostgisIndexDescriptor; -import org.gcube.application.geoportal.service.engine.ImplementationProvider; import org.gcube.application.geoportal.service.engine.materialization.SDIManager; import org.gcube.application.geoportal.service.model.internal.db.DBConstants; import org.gcube.application.geoportal.service.model.internal.db.PostgisTable; import org.gcube.application.geoportal.service.model.internal.db.PostgisTable.Field; import org.gcube.application.geoportal.service.model.internal.db.PostgisTable.FieldType; -import org.gcube.application.geoportal.service.model.internal.faults.ConfigurationException; import org.gcube.application.geoportal.service.model.internal.faults.PublishException; import org.gcube.application.geoportal.service.model.internal.faults.SDIInteractionException; -import org.gcube.application.geoportal.service.utils.Serialization; import java.sql.PreparedStatement; import java.sql.SQLException; @@ -39,7 +39,7 @@ public class PostgisIndex { private SDIManager sdiManager; private String wmsLink=null; private static PostgisDBManagerI getDB() throws ConfigurationException { - return ImplementationProvider.get().getDbProvider().getObject(); + return ImplementationProvider.get().getProvidedObjectByClass(PostgisDBManagerI.class); }; public PostgisIndex() throws SDIInteractionException, SQLException, ConfigurationException { @@ -60,7 +60,7 @@ public class PostgisIndex { public String init() throws SQLException, ConfigurationException, SDIInteractionException { log.debug("Contacting postgis DB .. "); - PostgisDBManagerI db=ImplementationProvider.get().getDbProvider().getObject(); + PostgisDBManagerI db=ImplementationProvider.get().getProvidedObjectByClass(PostgisDBManagerI.class); log.debug("Checking if centroids table exists.."); PostgisTable table=getCentroidsTable(); db.create(table); @@ -77,7 +77,7 @@ public class PostgisIndex { Map centroidRow=evaluateCentroid(record); log.debug("Contacting postgis DB .. "); - PostgisDBManagerI db=ImplementationProvider.get().getDbProvider().getObject(); + PostgisDBManagerI db=ImplementationProvider.get().getProvidedObjectByClass(PostgisDBManagerI.class); PostgisTable centroidsTable=getCentroidsTable(); log.debug("Inserting / updated centroid Row {} ",centroidRow); @@ -107,7 +107,7 @@ public class PostgisIndex { public void removeCentroid(Concessione record) { try { - PostgisDBManagerI db=ImplementationProvider.get().getDbProvider().getObject(); + PostgisDBManagerI db=ImplementationProvider.get().getProvidedObjectByClass(PostgisDBManagerI.class); PostgisTable centroidsTable=getCentroidsTable(); log.debug("Deleting centroid if present. ID is "+record.getMongo_id()); int result= db.deleteByFieldValue(centroidsTable, new Field(DBConstants.Concessioni.PRODUCT_ID,FieldType.TEXT), record.getMongo_id()); @@ -164,7 +164,7 @@ public class PostgisIndex { centroidsRow.put(DBConstants.Concessioni.FINANZIAMENTO,asString(record.getFontiFinanziamento())); centroidsRow.put(DBConstants.Concessioni.SOGGETTO,asString(record.getSoggetto())); centroidsRow.put(DBConstants.Concessioni.RISORSE,asString(record.getRisorseCorrelate())); - centroidsRow.put(DBConstants.Concessioni.DATE_SCAVO,Serialization.FULL_FORMATTER.format(record.getDataFineProgetto())); + centroidsRow.put(DBConstants.Concessioni.DATE_SCAVO, Serialization.FULL_FORMATTER.format(record.getDataFineProgetto())); centroidsRow.put(DBConstants.Concessioni.DATA_ARCHIVIAZIONE,Serialization.FULL_FORMATTER.format(record.getLastUpdateTime())); centroidsRow.put(DBConstants.Concessioni.VERSIONE,record.getVersion()); centroidsRow.put(DBConstants.Concessioni.LICENZA,record.getLicenzaID()); diff --git a/geoportal-service/src/main/java/org/gcube/application/geoportal/service/engine/providers/PostgisConnectionProvider.java b/geoportal-service/src/main/java/org/gcube/application/geoportal/service/engine/providers/PostgisConnectionProvider.java index 60a8b24..87d9f12 100644 --- a/geoportal-service/src/main/java/org/gcube/application/geoportal/service/engine/providers/PostgisConnectionProvider.java +++ b/geoportal-service/src/main/java/org/gcube/application/geoportal/service/engine/providers/PostgisConnectionProvider.java @@ -1,14 +1,15 @@ package org.gcube.application.geoportal.service.engine.providers; +import org.gcube.application.cms.caches.AbstractScopedMap; +import org.gcube.application.geoportal.common.model.rest.ConfigurationException; import org.gcube.application.geoportal.service.engine.postgis.PostgisDBManager; import org.gcube.application.geoportal.service.engine.postgis.PostgisDBManagerI; -import org.gcube.application.geoportal.service.model.internal.faults.ConfigurationException; import java.sql.SQLException; import java.time.Duration; import java.time.temporal.ChronoUnit; -public class PostgisConnectionProvider extends AbstractScopedMap{ +public class PostgisConnectionProvider extends AbstractScopedMap { public PostgisConnectionProvider() { @@ -17,7 +18,7 @@ public class PostgisConnectionProvider extends AbstractScopedMap