diff --git a/sdi-plugins/pom.xml b/sdi-plugins/pom.xml
index 1c2e5f4..4eda049 100644
--- a/sdi-plugins/pom.xml
+++ b/sdi-plugins/pom.xml
@@ -49,6 +49,13 @@
[1.2.1,2.0.0]
+
+
+ net.postgis
+ postgis-jdbc
+ 2.5.0
+
+
org.gcube.application.cms
cms-test-commons
diff --git a/sdi-plugins/src/main/java/org/gcube/application/cms/sdi/engine/PostgisTable.java b/sdi-plugins/src/main/java/org/gcube/application/cms/sdi/engine/PostgisTable.java
index e72059d..d20c121 100644
--- a/sdi-plugins/src/main/java/org/gcube/application/cms/sdi/engine/PostgisTable.java
+++ b/sdi-plugins/src/main/java/org/gcube/application/cms/sdi/engine/PostgisTable.java
@@ -231,7 +231,9 @@ public class PostgisTable {
break;
}
case GEOMETRY : {
- toFill.setBytes(psFieldIndex, (byte[])value);
+ if(value instanceof String)
+ toFill.setString(psFieldIndex, ((String) value));
+ else toFill.setBytes(psFieldIndex, (byte[])value);
}
}
}
diff --git a/sdi-plugins/src/main/java/org/gcube/application/cms/sdi/plugins/SDIAbstractPlugin.java b/sdi-plugins/src/main/java/org/gcube/application/cms/sdi/plugins/SDIAbstractPlugin.java
index 467eba8..597fa3a 100644
--- a/sdi-plugins/src/main/java/org/gcube/application/cms/sdi/plugins/SDIAbstractPlugin.java
+++ b/sdi-plugins/src/main/java/org/gcube/application/cms/sdi/plugins/SDIAbstractPlugin.java
@@ -17,6 +17,7 @@ import org.gcube.application.cms.sdi.engine.SDIManager;
import org.gcube.application.cms.sdi.engine.SDIManagerWrapper;
import org.gcube.application.geoportal.common.model.rest.ConfigurationException;
import org.gcube.application.geoportal.common.model.rest.DatabaseConnection;
+import org.gcube.application.geoportal.common.utils.ContextUtils;
import org.gcube.data.transfer.model.ServiceConstants;
import java.time.Duration;
@@ -52,8 +53,10 @@ public abstract class SDIAbstractPlugin extends AbstractPlugin implements Initia
@Override
protected DatabaseConnection retrieveObject() throws ConfigurationException {
try {
- return ImplementationProvider.get().getEngineByClass(ISInterface.class).
+ DatabaseConnection db = ImplementationProvider.get().getEngineByClass(ISInterface.class).
queryForDatabase("Database","postgis", "GNA_DB","Concessioni");
+ log.debug("Postgis Connection in {} is {} ", ContextUtils.getCurrentScope(),db);
+ return db;
} catch (Exception e) {
throw new ConfigurationException(e);
}
diff --git a/sdi-plugins/src/main/java/org/gcube/application/cms/sdi/plugins/SDIIndexerPlugin.java b/sdi-plugins/src/main/java/org/gcube/application/cms/sdi/plugins/SDIIndexerPlugin.java
index 4e7e4c7..451242c 100644
--- a/sdi-plugins/src/main/java/org/gcube/application/cms/sdi/plugins/SDIIndexerPlugin.java
+++ b/sdi-plugins/src/main/java/org/gcube/application/cms/sdi/plugins/SDIIndexerPlugin.java
@@ -4,7 +4,9 @@ import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.bson.Document;
import org.gcube.application.cms.plugins.IndexerPluginInterface;
+import org.gcube.application.cms.plugins.faults.IndexingException;
import org.gcube.application.cms.plugins.faults.InitializationException;
+import org.gcube.application.cms.plugins.faults.InvalidPluginRequestException;
import org.gcube.application.cms.plugins.faults.InvalidProfileException;
import org.gcube.application.cms.plugins.model.PluginDescriptor;
import org.gcube.application.cms.plugins.reports.IndexDocumentReport;
@@ -19,6 +21,7 @@ import org.gcube.application.geoportal.common.model.JSONPathWrapper;
import org.gcube.application.cms.plugins.model.ComparableVersion;
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
import org.gcube.application.geoportal.common.model.document.filesets.GCubeSDILayer;
+import org.gcube.application.geoportal.common.model.document.spatial.SpatialReference;
import org.gcube.application.geoportal.common.model.profile.Profile;
import java.util.ArrayList;
@@ -33,10 +36,10 @@ public class SDIIndexerPlugin extends SDIAbstractPlugin implements IndexerPlugin
private String type;
private String path;
- public void validate () throws RuntimeException {
- if(name==null) throw new RuntimeException("Invalid mapping "+this+" : name is null");
- if(type==null) throw new RuntimeException("Invalid mapping "+this+" : type is null");
- if(path==null) throw new RuntimeException("Invalid mapping "+this+" : path is null");
+ public void validate () throws InvalidProfileException {
+ if(name==null) throw new InvalidProfileException("Invalid mapping "+this+" : name is null");
+ if(type==null) throw new InvalidProfileException("Invalid mapping "+this+" : type is null");
+ if(path==null) throw new InvalidProfileException("Invalid mapping "+this+" : path is null");
}
}
@@ -68,13 +71,14 @@ public class SDIIndexerPlugin extends SDIAbstractPlugin implements IndexerPlugin
* Expected parameters :
* - indexName (unique)
* - workspace
+ * - centroidRecord (OPT)
*
* @param request
* @return
*/
@Override
- public IndexDocumentReport index(IndexDocumentRequest request) {
+ public IndexDocumentReport index(IndexDocumentRequest request) throws InvalidPluginRequestException {
log.info("Indexer {} : Performing {} ",this.getDescriptor().getId(),request);
@@ -100,17 +104,23 @@ public class SDIIndexerPlugin extends SDIAbstractPlugin implements IndexerPlugin
fields.add(new PostgisTable.Field("geom", PostgisTable.FieldType.GEOMETRY));
fields.add(new PostgisTable.Field("projectid", PostgisTable.FieldType.TEXT));
List mappingObjs= profileConfiguration.get("explicitFieldMapping",List.class);
+
+ log.trace("Loading mappings from profile.. ");
+ List mappingObjects= new ArrayList<>();
if(mappingObjs!=null){
- mappingObjs.forEach(o -> {
- log.trace("Mapping is {} ",o);
- MappingObject m = Serialization.convert(o,MappingObject.class);
+ for (Object mappingObj : mappingObjs) {
+ log.trace("Mapping is {} ",mappingObj);
+ MappingObject m = Serialization.convert(mappingObj,MappingObject.class);
m.validate();
+
fields.add(new PostgisTable.Field(m.getName(), PostgisTable.FieldType.valueOf(m.getType())));
- });
+ }
}
+
+
indexer.initIndex(requestArguments.getString("indexName"),
fields,
requestArguments.getString("workspace"),
@@ -123,9 +133,11 @@ public class SDIIndexerPlugin extends SDIAbstractPlugin implements IndexerPlugin
JSONPathWrapper documentNavigator=new JSONPathWrapper(Serialization.write(profiledDocument));
- Document doc = requestArguments;
+ Document centroidDoc = new Document();
+ if(requestArguments.containsKey("centroidRecord"))
+ centroidDoc.putAll(requestArguments.get("centroidRecords",Document.class));
// DEFAULT VALUES
- doc.put("projectid",profiledDocument.getId());
+ centroidDoc.put("projectid",profiledDocument.getId());
// ********************** EVALAUTE POSITION
log.debug("indexing Profile {} : Evaluating Centroid... ",profile.getId());
@@ -142,9 +154,10 @@ public class SDIIndexerPlugin extends SDIAbstractPlugin implements IndexerPlugin
GCubeSDILayer.BBOX toSet = null;
for(Object pathObj : bboxEvaluationPaths){
log.debug("Profile {} : Evaluating path {} ",profile.getId(),pathObj);
- for(String path : documentNavigator.getMatchingPaths(pathObj.toString())) {
- Object bboxObject = documentNavigator.getByPath(path).get(0);
- log.info("Matched path {}, value is {} ",path,bboxObject);
+ List