task_24859 #13
|
@ -1,5 +1,10 @@
|
||||||
# Changelog for org.gcube.application.cms.ckan-plugin
|
# Changelog for org.gcube.application.cms.ckan-plugin
|
||||||
|
|
||||||
|
## [v1.2.0-SNAPSHOT]
|
||||||
|
|
||||||
|
- Integrated the field 'geov_link' (Geoportal GisViewer link) in the centroid layer [#24859]
|
||||||
|
- Fixed Draft execution step executing dematerialization and de-indexing actions [#24877]
|
||||||
|
|
||||||
## [v1.1.1] - 2023-03-06
|
## [v1.1.1] - 2023-03-06
|
||||||
|
|
||||||
- [#24570] Integrated the UnPublish operation
|
- [#24570] Integrated the UnPublish operation
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<artifactId>default-lc-managers</artifactId>
|
<artifactId>default-lc-managers</artifactId>
|
||||||
<version>1.1.1</version>
|
<version>1.2.0-SNAPSHOT</version>
|
||||||
<name>gCube CMS - Default LC Managers</name>
|
<name>gCube CMS - Default LC Managers</name>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -171,14 +171,17 @@ public class Default3PhaseManager extends SimpleLifeCycleManager implements Life
|
||||||
protected Document getInternalIndexParams(BaseRequest req){
|
protected Document getInternalIndexParams(BaseRequest req){
|
||||||
Document callParameters = new Document();
|
Document callParameters = new Document();
|
||||||
|
|
||||||
callParameters.put("workspace", Files.fixFilename(req.getUseCaseDescriptor().getId()+"_internal_"+req.getContext().getName()));
|
callParameters.put(IndexConstants.INDEX_PARAMETER_WORKSPACE, Files.fixFilename(req.getUseCaseDescriptor().getId()+"_internal_"+req.getContext().getName()));
|
||||||
callParameters.put("indexName",Files.fixFilename(req.getUseCaseDescriptor().getId()+"_internal_"+req.getContext().getName()+"_centroids"));
|
callParameters.put(IndexConstants.INDEX_PARAMETER_INDEXNAME,Files.fixFilename(req.getUseCaseDescriptor().getId()+"_internal_"+req.getContext().getName()+"_centroids"));
|
||||||
|
//Added by Francesco
|
||||||
|
callParameters.put(IndexConstants.INDEX_PARAMETER_FLAGINTERNALINDEX, Boolean.TRUE);
|
||||||
return callParameters;
|
return callParameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected StepExecutionReport executeSubmit(StepExecutionReport theReport) throws Exception {
|
protected StepExecutionReport executeSubmit(StepExecutionReport theReport) throws Exception {
|
||||||
// Materialize
|
log.info(STEPS.SUBMIT + " running...");
|
||||||
|
|
||||||
|
// Materialize
|
||||||
for (MaterializationPlugin mat : getMaterializers(theReport.getTheRequest()))
|
for (MaterializationPlugin mat : getMaterializers(theReport.getTheRequest()))
|
||||||
theReport = materializeDocument(theReport, mat, getMaterializationParameters(theReport.getTheRequest()));
|
theReport = materializeDocument(theReport, mat, getMaterializationParameters(theReport.getTheRequest()));
|
||||||
if (theReport.getToSetLifecycleInformation().getLastOperationStatus().equals(LifecycleInformation.Status.OK)) {
|
if (theReport.getToSetLifecycleInformation().getLastOperationStatus().equals(LifecycleInformation.Status.OK)) {
|
||||||
|
@ -186,13 +189,16 @@ public class Default3PhaseManager extends SimpleLifeCycleManager implements Life
|
||||||
for (IndexerPluginInterface indexer : getIndexers(theReport.getTheRequest()))
|
for (IndexerPluginInterface indexer : getIndexers(theReport.getTheRequest()))
|
||||||
theReport = index(theReport, indexer, getInternalIndexParams(theReport.getTheRequest()));
|
theReport = index(theReport, indexer, getInternalIndexParams(theReport.getTheRequest()));
|
||||||
// setPhase
|
// setPhase
|
||||||
if(theReport.getToSetLifecycleInformation().getLastOperationStatus().equals(LifecycleInformation.Status.OK))
|
if (theReport.getToSetLifecycleInformation().getLastOperationStatus()
|
||||||
|
.equals(LifecycleInformation.Status.OK))
|
||||||
theReport.getToSetLifecycleInformation().setPhase(Phases.PENDING_APPROVAL);
|
theReport.getToSetLifecycleInformation().setPhase(Phases.PENDING_APPROVAL);
|
||||||
}
|
}
|
||||||
return theReport;
|
return theReport;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected StepExecutionReport executeApprove(StepExecutionReport theReport) throws Exception {
|
protected StepExecutionReport executeApprove(StepExecutionReport theReport) throws Exception {
|
||||||
|
log.info(STEPS.APPROVE + " running...");
|
||||||
|
|
||||||
// Index
|
// Index
|
||||||
for (IndexerPluginInterface indexer : getIndexers(theReport.getTheRequest()))
|
for (IndexerPluginInterface indexer : getIndexers(theReport.getTheRequest()))
|
||||||
theReport = index(theReport, indexer, getPublicIndexParams(theReport.getTheRequest()));
|
theReport = index(theReport, indexer, getPublicIndexParams(theReport.getTheRequest()));
|
||||||
|
@ -202,9 +208,30 @@ public class Default3PhaseManager extends SimpleLifeCycleManager implements Life
|
||||||
return theReport;
|
return theReport;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Updated by Francesco, see #24877
|
||||||
protected StepExecutionReport executeReject(StepExecutionReport theReport) throws Exception {
|
protected StepExecutionReport executeReject(StepExecutionReport theReport) throws Exception {
|
||||||
|
log.info(STEPS.REJECT + " running...");
|
||||||
|
|
||||||
|
// DeMaterialize
|
||||||
|
JSONPathWrapper wrapper = new JSONPathWrapper(theReport.getTheRequest().getDocument().getTheDocument().toJson());
|
||||||
|
for (String s : wrapper.getMatchingPaths("$..[?(@." + RegisteredFileSet.PAYLOADS + ")]")) {
|
||||||
|
log.info("Requesting dematerialization for {} ", s);
|
||||||
|
for (MaterializationPlugin mat : getMaterializers(theReport.getTheRequest()))
|
||||||
|
theReport = deMaterialize(theReport, mat, new Document("fileSetPath", s));
|
||||||
|
if (!theReport.getToSetLifecycleInformation().getLastOperationStatus().equals(LifecycleInformation.Status.OK))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// DeIndexing
|
||||||
|
if (theReport.getToSetLifecycleInformation().getLastOperationStatus().equals(LifecycleInformation.Status.OK)) {
|
||||||
|
for (IndexerPluginInterface indexer : getIndexers(theReport.getTheRequest())) {
|
||||||
|
log.info("Requesting deindexing for {} ", indexer.getDescriptor());
|
||||||
|
theReport = deIndex(theReport, indexer, getInternalIndexParams(theReport.getTheRequest()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (theReport.getToSetLifecycleInformation().getLastOperationStatus().equals(LifecycleInformation.Status.OK))
|
if (theReport.getToSetLifecycleInformation().getLastOperationStatus().equals(LifecycleInformation.Status.OK))
|
||||||
theReport.getToSetLifecycleInformation().setPhase(LifecycleInformation.CommonPhases.DRAFT_PHASE);
|
theReport.getToSetLifecycleInformation().setPhase(LifecycleInformation.CommonPhases.DRAFT_PHASE);
|
||||||
|
|
||||||
return theReport;
|
return theReport;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
package org.gcube.application.cms.plugins.implementations;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class IndexConstants.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||||
|
*
|
||||||
|
* Mar 29, 2023
|
||||||
|
*/
|
||||||
|
public class IndexConstants {
|
||||||
|
|
||||||
|
public static final String INDEX_PARAMETER_FLAGINTERNALINDEX = "flagInternalIndex";
|
||||||
|
public static final String INDEX_PARAMETER_INDEXNAME = "indexName";
|
||||||
|
public static final String INDEX_PARAMETER_WORKSPACE = "workspace";
|
||||||
|
|
||||||
|
}
|
|
@ -93,8 +93,9 @@ public class SimpleLifeCycleManager extends AbstractLifeCycleManager implements
|
||||||
|
|
||||||
protected Document getPublicIndexParams(BaseRequest req){
|
protected Document getPublicIndexParams(BaseRequest req){
|
||||||
Document callParameters = new Document();
|
Document callParameters = new Document();
|
||||||
callParameters.put("workspace",Files.fixFilename(req.getUseCaseDescriptor().getId()+req.getContext().getName()));
|
callParameters.put(IndexConstants.INDEX_PARAMETER_WORKSPACE,Files.fixFilename(req.getUseCaseDescriptor().getId()+req.getContext().getName()));
|
||||||
callParameters.put("indexName",Files.fixFilename(req.getUseCaseDescriptor().getId()+req.getContext().getName()+"_centroids"));
|
callParameters.put(IndexConstants.INDEX_PARAMETER_INDEXNAME,Files.fixFilename(req.getUseCaseDescriptor().getId()+req.getContext().getName()+"_centroids"));
|
||||||
|
callParameters.put(IndexConstants.INDEX_PARAMETER_FLAGINTERNALINDEX, Boolean.FALSE);
|
||||||
return callParameters;
|
return callParameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
# Changelog for org.gcube.application.geoportal-service
|
# Changelog for org.gcube.application.geoportal-service
|
||||||
|
|
||||||
|
## [v1.0.14-SNAPSHOT]
|
||||||
|
|
||||||
|
- Fixed deploying of multiple versions of the default-lc-managers [#24875]
|
||||||
|
|
||||||
## [v1.0.13] - 2023-02-23
|
## [v1.0.13] - 2023-02-23
|
||||||
- Integrating new facilities and bug fixing released in the Plugins
|
- Integrating new facilities and bug fixing released in the Plugins
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.gcube.application</groupId>
|
<groupId>org.gcube.application</groupId>
|
||||||
<artifactId>geoportal-service</artifactId>
|
<artifactId>geoportal-service</artifactId>
|
||||||
<version>1.0.13</version>
|
<version>1.0.14-SNAPSHOT</version>
|
||||||
<name>Geoportal Service</name>
|
<name>Geoportal Service</name>
|
||||||
<packaging>war</packaging>
|
<packaging>war</packaging>
|
||||||
|
|
||||||
|
@ -21,16 +21,12 @@
|
||||||
<webappDirectory>${project.basedir}${file.separator}${project.artifactId}${file.separator}src${file.separator}main${file.separator}webapp${file.separator}WEB-INF</webappDirectory>
|
<webappDirectory>${project.basedir}${file.separator}${project.artifactId}${file.separator}src${file.separator}main${file.separator}webapp${file.separator}WEB-INF</webappDirectory>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<scm>
|
<scm>
|
||||||
<connection>scm:git:${gitBaseUrl}/gcube-cms-suite</connection>
|
<connection>scm:git:${gitBaseUrl}/gcube-cms-suite</connection>
|
||||||
<developerConnection>scm:git:${gitBaseUrl}/gcube-cms-suite</developerConnection>
|
<developerConnection>scm:git:${gitBaseUrl}/gcube-cms-suite</developerConnection>
|
||||||
<url>${gitBaseUrl}/gcube-cms-suite</url>
|
<url>${gitBaseUrl}/gcube-cms-suite</url>
|
||||||
</scm>
|
</scm>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -94,7 +90,6 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- enunciate deps -->
|
<!-- enunciate deps -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.webcohesion.enunciate</groupId>
|
<groupId>com.webcohesion.enunciate</groupId>
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
# Changelog for org.gcube.application.cms.sdi-plugins
|
# Changelog for org.gcube.application.cms.sdi-plugins
|
||||||
|
|
||||||
|
## [v1.1.0-SNAPSHOT]
|
||||||
|
|
||||||
|
- Integrated the field 'geov_link' (Geoportal GisViewer link) in the centroid layer [#24859]
|
||||||
|
|
||||||
## [v1.0.4] - 2023-03-06
|
## [v1.0.4] - 2023-03-06
|
||||||
- Fixed the import from joda-time to java.time
|
- Fixed the import from joda-time to java.time
|
||||||
- [#24702] Fixed the default-lc-managers dependency
|
- [#24702] Fixed the default-lc-managers dependency
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<artifactId>sdi-plugins</artifactId>
|
<artifactId>sdi-plugins</artifactId>
|
||||||
<version>1.0.4</version>
|
<version>1.1.0-SNAPSHOT</version>
|
||||||
<name>gCube CMS - SDI Plugins</name>
|
<name>gCube CMS - SDI Plugins</name>
|
||||||
|
|
||||||
|
|
||||||
|
@ -85,12 +85,19 @@
|
||||||
<version>1.14</version>
|
<version>1.14</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.portlets.user</groupId>
|
||||||
|
<artifactId>uri-resolver-manager</artifactId>
|
||||||
|
<version>[1.0.0,2.0.0-SNAPSHOT)</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.application.cms</groupId>
|
<groupId>org.gcube.application.cms</groupId>
|
||||||
<artifactId>cms-test-commons</artifactId>
|
<artifactId>cms-test-commons</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -2,7 +2,9 @@ package org.gcube.application.cms.sdi.engine;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import static org.gcube.application.cms.sdi.engine.PostgisTable.*;
|
import org.gcube.application.cms.sdi.engine.PostgisTable.Field;
|
||||||
|
import org.gcube.application.cms.sdi.engine.PostgisTable.FieldType;
|
||||||
|
import org.gcube.application.cms.sdi.engine.PostgisTable.GeometryType;
|
||||||
|
|
||||||
public class DBConstants {
|
public class DBConstants {
|
||||||
|
|
||||||
|
@ -19,6 +21,8 @@ public class DBConstants {
|
||||||
|
|
||||||
public static final String DISPLAYED="displayed_project";
|
public static final String DISPLAYED="displayed_project";
|
||||||
|
|
||||||
|
public static final String GEOVIEWER_LINK_FIELD="geov_link";
|
||||||
|
|
||||||
|
|
||||||
public static final String XCOORD_FIELD="xcoord";
|
public static final String XCOORD_FIELD="xcoord";
|
||||||
public static final String YCOORD_FIELD="ycoord";
|
public static final String YCOORD_FIELD="ycoord";
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
package org.gcube.application.cms.sdi.engine;
|
package org.gcube.application.cms.sdi.engine;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.gcube.application.cms.sdi.faults.DataParsingException;
|
|
||||||
import org.gcube.application.geoportal.common.model.legacy.BBOX;
|
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
|
@ -11,6 +7,11 @@ import java.sql.SQLException;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import org.gcube.application.cms.sdi.faults.DataParsingException;
|
||||||
|
import org.gcube.application.geoportal.common.model.legacy.BBOX;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class PostgisDBManager implements PostgisDBManagerI {
|
public class PostgisDBManager implements PostgisDBManagerI {
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,5 @@
|
||||||
package org.gcube.application.cms.sdi.engine;
|
package org.gcube.application.cms.sdi.engine;
|
||||||
|
|
||||||
import lombok.NonNull;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.bson.Document;
|
|
||||||
import org.gcube.application.cms.sdi.faults.SDIInteractionException;
|
|
||||||
import org.gcube.application.cms.sdi.model.CrossReferencedLayer;
|
|
||||||
import org.gcube.application.cms.sdi.plugins.SDIIndexerPlugin;
|
|
||||||
import org.gcube.application.geoportal.common.model.configuration.Index;
|
|
||||||
import org.gcube.application.geoportal.common.model.document.filesets.sdi.GCubeSDILayer;
|
|
||||||
import org.gcube.application.geoportal.common.model.rest.DatabaseConnection;
|
|
||||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
|
|
||||||
|
|
||||||
import java.sql.DriverManager;
|
import java.sql.DriverManager;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
@ -18,6 +7,17 @@ import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bson.Document;
|
||||||
|
import org.gcube.application.cms.sdi.faults.SDIInteractionException;
|
||||||
|
import org.gcube.application.cms.sdi.model.CrossReferencedLayer;
|
||||||
|
import org.gcube.application.geoportal.common.model.configuration.Index;
|
||||||
|
import org.gcube.application.geoportal.common.model.document.filesets.sdi.GCubeSDILayer;
|
||||||
|
import org.gcube.application.geoportal.common.model.rest.DatabaseConnection;
|
||||||
|
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
|
||||||
|
|
||||||
|
import lombok.NonNull;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class PostgisIndexer {
|
public class PostgisIndexer {
|
||||||
|
@ -39,8 +39,8 @@ public class PostgisIndexer {
|
||||||
public static class StandardFields{
|
public static class StandardFields{
|
||||||
public static final PostgisTable.Field PROJECT_ID= new PostgisTable.Field(DBConstants.Defaults.PROJECT_ID, PostgisTable.FieldType.TEXT);
|
public static final PostgisTable.Field PROJECT_ID= new PostgisTable.Field(DBConstants.Defaults.PROJECT_ID, PostgisTable.FieldType.TEXT);
|
||||||
public static final PostgisTable.Field GEOM= new PostgisTable.Field(DBConstants.Defaults.DEFAULT_GEOMETRY_COLUMN_NAME, PostgisTable.FieldType.GEOMETRY);
|
public static final PostgisTable.Field GEOM= new PostgisTable.Field(DBConstants.Defaults.DEFAULT_GEOMETRY_COLUMN_NAME, PostgisTable.FieldType.GEOMETRY);
|
||||||
|
|
||||||
public static final PostgisTable.Field DISPLAY=new PostgisTable.Field(DBConstants.Defaults.DISPLAYED,PostgisTable.FieldType.BOOLEAN);
|
public static final PostgisTable.Field DISPLAY=new PostgisTable.Field(DBConstants.Defaults.DISPLAYED,PostgisTable.FieldType.BOOLEAN);
|
||||||
|
public static final PostgisTable.Field GEOV_LINK=new PostgisTable.Field(DBConstants.Defaults.GEOVIEWER_LINK_FIELD,PostgisTable.FieldType.TEXT);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,10 +85,10 @@ public class PostgisIndexer {
|
||||||
tableFields.add(StandardFields.GEOM);
|
tableFields.add(StandardFields.GEOM);
|
||||||
tableFields.add(StandardFields.PROJECT_ID);
|
tableFields.add(StandardFields.PROJECT_ID);
|
||||||
tableFields.add(StandardFields.DISPLAY);
|
tableFields.add(StandardFields.DISPLAY);
|
||||||
|
tableFields.add(StandardFields.GEOV_LINK);
|
||||||
|
|
||||||
tableFields.addAll(customFields);
|
tableFields.addAll(customFields);
|
||||||
|
|
||||||
|
|
||||||
table = new PostgisTable(indexName,tableFields, PostgisTable.GeometryType.POINT);
|
table = new PostgisTable(indexName,tableFields, PostgisTable.GeometryType.POINT);
|
||||||
log.trace("Index Postgis Table is {} ",table);
|
log.trace("Index Postgis Table is {} ",table);
|
||||||
log.debug("Create if missing..");
|
log.debug("Create if missing..");
|
||||||
|
|
|
@ -1,20 +1,29 @@
|
||||||
package org.gcube.application.cms.sdi.engine;
|
package org.gcube.application.cms.sdi.engine;
|
||||||
|
|
||||||
import lombok.*;
|
import java.sql.PreparedStatement;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import java.sql.SQLException;
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.text.NumberFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.gcube.application.cms.sdi.faults.DataParsingException;
|
import org.gcube.application.cms.sdi.faults.DataParsingException;
|
||||||
import org.gcube.application.cms.sdi.model.MappingObject;
|
import org.gcube.application.cms.sdi.model.MappingObject;
|
||||||
import org.gcube.application.geoportal.common.model.legacy.BBOX;
|
import org.gcube.application.geoportal.common.model.legacy.BBOX;
|
||||||
|
|
||||||
import java.sql.Array;
|
import lombok.AllArgsConstructor;
|
||||||
import java.sql.PreparedStatement;
|
import lombok.Getter;
|
||||||
import java.sql.SQLException;
|
import lombok.NonNull;
|
||||||
import java.sql.Types;
|
import lombok.RequiredArgsConstructor;
|
||||||
import java.text.DecimalFormat;
|
import lombok.Setter;
|
||||||
import java.text.NumberFormat;
|
import lombok.ToString;
|
||||||
import java.util.*;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
|
@ -22,20 +31,18 @@ import java.util.regex.Pattern;
|
||||||
@ToString
|
@ToString
|
||||||
public class PostgisTable {
|
public class PostgisTable {
|
||||||
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public static enum GeometryType {
|
public static enum GeometryType {
|
||||||
MULTIPOINT("4326","geometry (MULTIPOINT,4326)","",""),
|
MULTIPOINT("4326", "geometry (MULTIPOINT,4326)", "", ""), POINT("4326", "geometry (POINT,4326)", "", ""),
|
||||||
POINT("4326","geometry (POINT,4326)","",""),
|
|
||||||
LINE("4326", "geometry (MULTILINESTRING,4326)", "", ""),
|
LINE("4326", "geometry (MULTILINESTRING,4326)", "", ""),
|
||||||
POLYGON("4326", "geometry (MULTIPOLYGON,4326)", "", "");
|
POLYGON("4326", "geometry (MULTIPOLYGON,4326)", "", "");
|
||||||
|
|
||||||
private final String SRID;
|
private final String SRID;
|
||||||
private final String definition;
|
private final String definition;
|
||||||
private final String InsertWKT;
|
private final String InsertWKT;
|
||||||
private final String insertWKB;
|
private final String insertWKB;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
|
@ -65,18 +72,14 @@ public class PostgisTable {
|
||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public enum FieldType {
|
public enum FieldType {
|
||||||
INT("int",java.sql.Types.INTEGER),
|
INT("int", java.sql.Types.INTEGER), BOOLEAN("boolean", java.sql.Types.BOOLEAN),
|
||||||
BOOLEAN("boolean", java.sql.Types.BOOLEAN),
|
TEXT("text", java.sql.Types.LONGVARCHAR), FLOAT("float", java.sql.Types.FLOAT), GEOMETRY("", 0),
|
||||||
TEXT("text",java.sql.Types.LONGVARCHAR),
|
|
||||||
FLOAT("float",java.sql.Types.FLOAT),
|
|
||||||
GEOMETRY("",0),
|
|
||||||
AUTOINCREMENT("BIGSERIAL PRIMARY KEY", java.sql.Types.BIGINT);
|
AUTOINCREMENT("BIGSERIAL PRIMARY KEY", java.sql.Types.BIGINT);
|
||||||
|
|
||||||
private String definition;
|
private String definition;
|
||||||
private int sqlType;
|
private int sqlType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Getter
|
@Getter
|
||||||
@ToString
|
@ToString
|
||||||
|
@ -91,10 +94,12 @@ public class PostgisTable {
|
||||||
log.debug("Parsing POINT " + point);
|
log.debug("Parsing POINT " + point);
|
||||||
Matcher m = pattern.matcher(point);
|
Matcher m = pattern.matcher(point);
|
||||||
|
|
||||||
if(!m.find()) throw new DataParsingException("Unable to get x ");
|
if (!m.find())
|
||||||
|
throw new DataParsingException("Unable to get x ");
|
||||||
Double x = Double.parseDouble(m.group(1));
|
Double x = Double.parseDouble(m.group(1));
|
||||||
|
|
||||||
if(!m.find()) throw new DataParsingException("Unable to get y ");
|
if (!m.find())
|
||||||
|
throw new DataParsingException("Unable to get y ");
|
||||||
Double y = Double.parseDouble(m.group(1));
|
Double y = Double.parseDouble(m.group(1));
|
||||||
|
|
||||||
return new POINT(x, y);
|
return new POINT(x, y);
|
||||||
|
@ -110,17 +115,16 @@ public class PostgisTable {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static final NumberFormat DECIMAL_FORMAT = NumberFormat.getInstance(Locale.US);
|
private static final NumberFormat DECIMAL_FORMAT = NumberFormat.getInstance(Locale.US);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
((DecimalFormat) DECIMAL_FORMAT).setGroupingUsed(false);
|
((DecimalFormat) DECIMAL_FORMAT).setGroupingUsed(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getGeometryColumn() {
|
public String getGeometryColumn() {
|
||||||
for (Field f : fields)
|
for (Field f : fields)
|
||||||
if(f.getType().equals(FieldType.GEOMETRY)) return f.getName();
|
if (f.getType().equals(FieldType.GEOMETRY))
|
||||||
|
return f.getName();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +134,6 @@ public class PostgisTable {
|
||||||
@NonNull
|
@NonNull
|
||||||
private List<Field> fields;
|
private List<Field> fields;
|
||||||
|
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
private GeometryType geometryColumnType;
|
private GeometryType geometryColumnType;
|
||||||
|
|
||||||
|
@ -164,14 +167,14 @@ public class PostgisTable {
|
||||||
return "DELETE FROM " + tablename + " WHERE " + field.getName() + " = ? ";
|
return "DELETE FROM " + tablename + " WHERE " + field.getName() + " = ? ";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getInsertionStatement(boolean geometryText) {
|
public String getInsertionStatement(boolean geometryText) {
|
||||||
StringBuilder fieldList = new StringBuilder();
|
StringBuilder fieldList = new StringBuilder();
|
||||||
StringBuilder fieldInsertion = new StringBuilder();
|
StringBuilder fieldInsertion = new StringBuilder();
|
||||||
|
|
||||||
for (Field field : fields) {
|
for (Field field : fields) {
|
||||||
switch (field.getType()) {
|
switch (field.getType()) {
|
||||||
case AUTOINCREMENT : break;
|
case AUTOINCREMENT:
|
||||||
|
break;
|
||||||
case GEOMETRY: {
|
case GEOMETRY: {
|
||||||
fieldList.append(field.getName() + ",");
|
fieldList.append(field.getName() + ",");
|
||||||
if (geometryText)
|
if (geometryText)
|
||||||
|
@ -190,19 +193,15 @@ public class PostgisTable {
|
||||||
fieldList.deleteCharAt(fieldList.lastIndexOf(","));
|
fieldList.deleteCharAt(fieldList.lastIndexOf(","));
|
||||||
fieldInsertion.deleteCharAt(fieldInsertion.lastIndexOf(","));
|
fieldInsertion.deleteCharAt(fieldInsertion.lastIndexOf(","));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return "Insert into " + tablename + " (" + fieldList + ") VALUES (" + fieldInsertion + ")";
|
return "Insert into " + tablename + " (" + fieldList + ") VALUES (" + fieldInsertion + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void fillObjectsPreparedStatement(Map<String, Object> row, PreparedStatement toFill) throws SQLException {
|
public void fillObjectsPreparedStatement(Map<String, Object> row, PreparedStatement toFill) throws SQLException {
|
||||||
int psFieldIndex = 0;
|
int psFieldIndex = 0;
|
||||||
HashMap<String, Object> rowValues = new HashMap<String, Object>();
|
HashMap<String, Object> rowValues = new HashMap<String, Object>();
|
||||||
for (Map.Entry<String, Object> entry : row.entrySet())
|
for (Map.Entry<String, Object> entry : row.entrySet())
|
||||||
rowValues.put(sanitizeFieldName(entry.getKey()), entry.getValue());
|
rowValues.put(sanitizeFieldName(entry.getKey()), entry.getValue());
|
||||||
|
|
||||||
|
|
||||||
for (Field field : fields) {
|
for (Field field : fields) {
|
||||||
if (!field.getType().equals(FieldType.AUTOINCREMENT)) {
|
if (!field.getType().equals(FieldType.AUTOINCREMENT)) {
|
||||||
psFieldIndex++;
|
psFieldIndex++;
|
||||||
|
@ -212,12 +211,11 @@ public class PostgisTable {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setObjectInPreparedStatement(Field field, Object value, PreparedStatement toFill, int psFieldIndex)
|
||||||
public void setObjectInPreparedStatement(Field field,Object value, PreparedStatement toFill, int psFieldIndex) throws SQLException {
|
throws SQLException {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
try {
|
try {
|
||||||
toFill.setNull(psFieldIndex, field.getType().sqlType);
|
toFill.setNull(psFieldIndex, field.getType().sqlType);
|
||||||
|
@ -225,8 +223,7 @@ public class PostgisTable {
|
||||||
log.error("Unable to set null for field " + field);
|
log.error("Unable to set null for field " + field);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
switch (field.getType()) {
|
switch (field.getType()) {
|
||||||
case FLOAT: {
|
case FLOAT: {
|
||||||
toFill.setFloat(psFieldIndex, (Float) value);
|
toFill.setFloat(psFieldIndex, (Float) value);
|
||||||
|
@ -243,7 +240,8 @@ public class PostgisTable {
|
||||||
case GEOMETRY: {
|
case GEOMETRY: {
|
||||||
if (value instanceof String)
|
if (value instanceof String)
|
||||||
toFill.setString(psFieldIndex, ((String) value));
|
toFill.setString(psFieldIndex, ((String) value));
|
||||||
else toFill.setBytes(psFieldIndex, (byte[])value);
|
else
|
||||||
|
toFill.setBytes(psFieldIndex, (byte[]) value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BOOLEAN: {
|
case BOOLEAN: {
|
||||||
|
@ -253,10 +251,26 @@ public class PostgisTable {
|
||||||
toFill.setBoolean(psFieldIndex, (Boolean) value);
|
toFill.setBoolean(psFieldIndex, (Boolean) value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
// Added by Francesco
|
||||||
|
default: {
|
||||||
|
if (value instanceof String) {
|
||||||
|
toFill.setString(psFieldIndex, ((String) value));
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
String toStringValue = value.toString();
|
||||||
|
toFill.setString(psFieldIndex, toStringValue);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// silence
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fillCSVPreparedStatament(Map<String,String> row, PreparedStatement toFill,boolean explicitGeometry) throws SQLException {
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fillCSVPreparedStatament(Map<String, String> row, PreparedStatement toFill, boolean explicitGeometry)
|
||||||
|
throws SQLException {
|
||||||
int psFieldIndex = 0;
|
int psFieldIndex = 0;
|
||||||
|
|
||||||
HashMap<String, String> rowValues = new HashMap<String, String>();
|
HashMap<String, String> rowValues = new HashMap<String, String>();
|
||||||
|
@ -265,7 +279,6 @@ public class PostgisTable {
|
||||||
|
|
||||||
for (Field field : fields) {
|
for (Field field : fields) {
|
||||||
|
|
||||||
|
|
||||||
if (!field.getType().equals(FieldType.AUTOINCREMENT)) {
|
if (!field.getType().equals(FieldType.AUTOINCREMENT)) {
|
||||||
psFieldIndex++;
|
psFieldIndex++;
|
||||||
|
|
||||||
|
@ -301,11 +314,12 @@ public class PostgisTable {
|
||||||
} else {
|
} else {
|
||||||
switch (geometryColumnType) {
|
switch (geometryColumnType) {
|
||||||
case POINT: {
|
case POINT: {
|
||||||
String xRepresentation=DECIMAL_FORMAT.format(Double.parseDouble(rowValues.get(DBConstants.Defaults.XCOORD_FIELD)));
|
String xRepresentation = DECIMAL_FORMAT
|
||||||
String yRepresentation=DECIMAL_FORMAT.format(Double.parseDouble(rowValues.get(DBConstants.Defaults.YCOORD_FIELD)));
|
.format(Double.parseDouble(rowValues.get(DBConstants.Defaults.XCOORD_FIELD)));
|
||||||
|
String yRepresentation = DECIMAL_FORMAT
|
||||||
|
.format(Double.parseDouble(rowValues.get(DBConstants.Defaults.YCOORD_FIELD)));
|
||||||
|
|
||||||
toFill.setString(psFieldIndex, "POINT("+xRepresentation+" "+
|
toFill.setString(psFieldIndex, "POINT(" + xRepresentation + " " + yRepresentation + ")");
|
||||||
yRepresentation+")");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
|
@ -319,9 +333,6 @@ public class PostgisTable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -330,7 +341,4 @@ public class PostgisTable {
|
||||||
return fieldName.toLowerCase().replaceAll("[^a-z0-9_\\\\]", "_");
|
return fieldName.toLowerCase().replaceAll("[^a-z0-9_\\\\]", "_");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,22 @@
|
||||||
package org.gcube.application.cms.sdi.engine;
|
package org.gcube.application.cms.sdi.engine;
|
||||||
|
|
||||||
|
|
||||||
import it.geosolutions.geoserver.rest.encoder.datastore.GSPostGISDatastoreEncoder;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.gcube.application.cms.sdi.faults.SDIInteractionException;
|
|
||||||
import org.gcube.application.geoportal.common.model.rest.DatabaseConnection;
|
|
||||||
import org.gcube.data.transfer.library.DataTransferClient;
|
|
||||||
import org.gcube.spatial.data.gis.GISInterface;
|
|
||||||
import org.gcube.spatial.data.gis.is.AbstractGeoServerDescriptor;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import org.gcube.application.cms.sdi.faults.SDIInteractionException;
|
||||||
|
import org.gcube.application.geoportal.common.model.rest.DatabaseConnection;
|
||||||
|
import org.gcube.data.transfer.library.DataTransferClient;
|
||||||
|
import org.gcube.spatial.data.gis.GISInterface;
|
||||||
|
import org.gcube.spatial.data.gis.is.AbstractGeoServerDescriptor;
|
||||||
|
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.datastore.GSPostGISDatastoreEncoder;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class SDIManager {
|
public class SDIManager {
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
package org.gcube.application.cms.sdi.engine;
|
package org.gcube.application.cms.sdi.engine;
|
||||||
|
|
||||||
import it.geosolutions.geoserver.rest.GeoServerRESTPublisher;
|
import static it.geosolutions.geoserver.rest.encoder.GSResourceEncoder.ProjectionPolicy.REPROJECT_TO_DECLARED;
|
||||||
import it.geosolutions.geoserver.rest.GeoServerRESTReader;
|
import static org.gcube.application.cms.sdi.model.GCubeSDILayerBuilder.EPSG_4326;
|
||||||
import it.geosolutions.geoserver.rest.decoder.RESTFeatureType;
|
import static org.gcube.application.cms.sdi.model.GCubeSDILayerBuilder.WGS84_FULL;
|
||||||
import it.geosolutions.geoserver.rest.decoder.RESTLayer;
|
|
||||||
import it.geosolutions.geoserver.rest.encoder.GSLayerEncoder;
|
import java.io.File;
|
||||||
import it.geosolutions.geoserver.rest.encoder.feature.GSAttributeEncoder;
|
import java.net.MalformedURLException;
|
||||||
import it.geosolutions.geoserver.rest.encoder.feature.GSFeatureTypeEncoder;
|
import java.net.URL;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.bson.Document;
|
import org.bson.Document;
|
||||||
import org.gcube.application.cms.plugins.requests.BaseExecutionRequest;
|
import org.gcube.application.cms.plugins.requests.BaseExecutionRequest;
|
||||||
import org.gcube.application.cms.sdi.faults.SDIInteractionException;
|
import org.gcube.application.cms.sdi.faults.SDIInteractionException;
|
||||||
|
@ -21,23 +23,25 @@ import org.gcube.application.geoportal.common.model.document.filesets.sdi.GeoSer
|
||||||
import org.gcube.application.geoportal.common.model.document.filesets.sdi.PlatformInfo;
|
import org.gcube.application.geoportal.common.model.document.filesets.sdi.PlatformInfo;
|
||||||
import org.gcube.application.geoportal.common.model.rest.DatabaseConnection;
|
import org.gcube.application.geoportal.common.model.rest.DatabaseConnection;
|
||||||
import org.gcube.application.geoportal.common.utils.Files;
|
import org.gcube.application.geoportal.common.utils.Files;
|
||||||
import org.gcube.data.transfer.library.DataTransferClient;
|
|
||||||
import org.gcube.data.transfer.library.TransferResult;
|
import org.gcube.data.transfer.library.TransferResult;
|
||||||
import org.gcube.data.transfer.library.client.Client;
|
import org.gcube.data.transfer.library.client.Client;
|
||||||
import org.gcube.data.transfer.library.faults.*;
|
import org.gcube.data.transfer.library.faults.DestinationNotSetException;
|
||||||
|
import org.gcube.data.transfer.library.faults.FailedTransferException;
|
||||||
|
import org.gcube.data.transfer.library.faults.InitializationException;
|
||||||
|
import org.gcube.data.transfer.library.faults.InvalidDestinationException;
|
||||||
|
import org.gcube.data.transfer.library.faults.InvalidSourceException;
|
||||||
|
import org.gcube.data.transfer.library.faults.SourceNotSetException;
|
||||||
import org.gcube.data.transfer.model.Destination;
|
import org.gcube.data.transfer.model.Destination;
|
||||||
import org.gcube.data.transfer.model.DestinationClashPolicy;
|
import org.gcube.data.transfer.model.DestinationClashPolicy;
|
||||||
import org.gcube.spatial.data.gis.is.AbstractGeoServerDescriptor;
|
import org.gcube.spatial.data.gis.is.AbstractGeoServerDescriptor;
|
||||||
|
|
||||||
import java.io.File;
|
import it.geosolutions.geoserver.rest.GeoServerRESTPublisher;
|
||||||
import java.net.MalformedURLException;
|
import it.geosolutions.geoserver.rest.GeoServerRESTReader;
|
||||||
import java.net.URL;
|
import it.geosolutions.geoserver.rest.decoder.RESTFeatureType;
|
||||||
import java.util.ArrayList;
|
import it.geosolutions.geoserver.rest.decoder.RESTLayer;
|
||||||
import java.util.List;
|
import it.geosolutions.geoserver.rest.encoder.GSLayerEncoder;
|
||||||
|
import it.geosolutions.geoserver.rest.encoder.feature.GSFeatureTypeEncoder;
|
||||||
import static it.geosolutions.geoserver.rest.encoder.GSResourceEncoder.ProjectionPolicy.REPROJECT_TO_DECLARED;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import static org.gcube.application.cms.sdi.model.GCubeSDILayerBuilder.EPSG_4326;
|
|
||||||
import static org.gcube.application.cms.sdi.model.GCubeSDILayerBuilder.WGS84_FULL;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class SDIManagerWrapper extends SDIManager{
|
public class SDIManagerWrapper extends SDIManager{
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
package org.gcube.application.cms.sdi.engine.bboxes;
|
package org.gcube.application.cms.sdi.engine.bboxes;
|
||||||
|
|
||||||
import lombok.Data;
|
import java.util.List;
|
||||||
import lombok.ToString;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.bson.Document;
|
import org.bson.Document;
|
||||||
import org.gcube.application.cms.serialization.Serialization;
|
import org.gcube.application.cms.serialization.Serialization;
|
||||||
import org.gcube.application.geoportal.common.model.JSONPathWrapper;
|
import org.gcube.application.geoportal.common.model.JSONPathWrapper;
|
||||||
import org.gcube.application.geoportal.common.model.document.filesets.sdi.GCubeSDILayer;
|
import org.gcube.application.geoportal.common.model.document.filesets.sdi.GCubeSDILayer;
|
||||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
|
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
|
||||||
|
|
||||||
import java.util.List;
|
import lombok.Data;
|
||||||
|
import lombok.ToString;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class BBOXByCoordinatePaths extends BBOXEvaluator{
|
public class BBOXByCoordinatePaths extends BBOXEvaluator{
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
package org.gcube.application.cms.sdi.engine.bboxes;
|
package org.gcube.application.cms.sdi.engine.bboxes;
|
||||||
|
|
||||||
|
import org.bson.Document;
|
||||||
|
import org.gcube.application.geoportal.common.model.JSONPathWrapper;
|
||||||
|
import org.gcube.application.geoportal.common.model.document.filesets.sdi.GCubeSDILayer;
|
||||||
|
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
|
||||||
|
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.bson.Document;
|
|
||||||
import org.gcube.application.geoportal.common.model.JSONPathWrapper;
|
|
||||||
import org.gcube.application.geoportal.common.model.document.filesets.sdi.GCubeSDILayer;
|
|
||||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
|
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@ToString
|
@ToString
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
package org.gcube.application.cms.sdi.engine.bboxes;
|
package org.gcube.application.cms.sdi.engine.bboxes;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bson.Document;
|
import org.bson.Document;
|
||||||
import org.gcube.application.cms.serialization.Serialization;
|
import org.gcube.application.cms.serialization.Serialization;
|
||||||
import org.gcube.application.geoportal.common.model.JSONPathWrapper;
|
import org.gcube.application.geoportal.common.model.JSONPathWrapper;
|
||||||
import org.gcube.application.geoportal.common.model.document.filesets.sdi.GCubeSDILayer;
|
import org.gcube.application.geoportal.common.model.document.filesets.sdi.GCubeSDILayer;
|
||||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
|
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
|
||||||
|
|
||||||
import java.util.List;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class BBOXPathScanner extends BBOXEvaluator{
|
public class BBOXPathScanner extends BBOXEvaluator{
|
||||||
|
|
|
@ -1,16 +1,17 @@
|
||||||
package org.gcube.application.cms.sdi.model;
|
package org.gcube.application.cms.sdi.model;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import org.bson.Document;
|
|
||||||
import org.gcube.application.geoportal.common.model.document.filesets.sdi.GCubeSDILayer;
|
|
||||||
import org.gcube.application.geoportal.common.model.document.filesets.sdi.GeoServerPlatform;
|
|
||||||
import org.gcube.application.geoportal.common.model.document.filesets.sdi.PlatformInfo;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.bson.Document;
|
||||||
|
import org.gcube.application.geoportal.common.model.document.filesets.sdi.GCubeSDILayer;
|
||||||
|
import org.gcube.application.geoportal.common.model.document.filesets.sdi.GeoServerPlatform;
|
||||||
|
import org.gcube.application.geoportal.common.model.document.filesets.sdi.PlatformInfo;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
public class GCubeSDILayerBuilder {
|
public class GCubeSDILayerBuilder {
|
||||||
|
|
||||||
public static enum OGC_TYPE{
|
public static enum OGC_TYPE{
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
package org.gcube.application.cms.sdi.model;
|
package org.gcube.application.cms.sdi.model;
|
||||||
|
|
||||||
import lombok.Data;
|
import java.util.ArrayList;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bson.Document;
|
import org.bson.Document;
|
||||||
import org.gcube.application.cms.plugins.faults.InvalidProfileException;
|
import org.gcube.application.cms.plugins.faults.InvalidProfileException;
|
||||||
import org.gcube.application.cms.serialization.Serialization;
|
import org.gcube.application.cms.serialization.Serialization;
|
||||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.HandlerDeclaration;
|
import org.gcube.application.geoportal.common.model.useCaseDescriptor.HandlerDeclaration;
|
||||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
|
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import lombok.Data;
|
||||||
import java.util.List;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@Slf4j
|
@Slf4j
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package org.gcube.application.cms.sdi.model;
|
package org.gcube.application.cms.sdi.model;
|
||||||
|
|
||||||
import org.bson.Document;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.bson.Document;
|
||||||
|
|
||||||
public class SDIConfiguration {
|
public class SDIConfiguration {
|
||||||
|
|
||||||
public static final String GEOSERVER_PLATFORM="GeoServer";
|
public static final String GEOSERVER_PLATFORM="GeoServer";
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
package org.gcube.application.cms.sdi.model;
|
package org.gcube.application.cms.sdi.model;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.gcube.application.geoportal.common.model.document.filesets.RegisteredFile;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.gcube.application.geoportal.common.model.document.filesets.RegisteredFile;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
@Getter
|
@Getter
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public abstract class SupportedFormat {
|
public abstract class SupportedFormat {
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
package org.gcube.application.cms.sdi.plugins;
|
package org.gcube.application.cms.sdi.plugins;
|
||||||
|
|
||||||
import lombok.Synchronized;
|
import java.time.Duration;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import java.time.temporal.ChronoUnit;
|
||||||
|
|
||||||
import org.gcube.application.cms.caches.AbstractScopedMap;
|
import org.gcube.application.cms.caches.AbstractScopedMap;
|
||||||
import org.gcube.application.cms.implementations.ISInterface;
|
import org.gcube.application.cms.implementations.ISInterface;
|
||||||
import org.gcube.application.cms.implementations.ImplementationProvider;
|
import org.gcube.application.cms.implementations.ImplementationProvider;
|
||||||
|
@ -16,8 +17,8 @@ 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.ConfigurationException;
|
||||||
import org.gcube.application.geoportal.common.model.rest.DatabaseConnection;
|
import org.gcube.application.geoportal.common.model.rest.DatabaseConnection;
|
||||||
|
|
||||||
import java.time.Duration;
|
import lombok.Synchronized;
|
||||||
import java.time.temporal.ChronoUnit;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public abstract class SDIAbstractPlugin extends AbstractPlugin implements InitializablePlugin {
|
public abstract class SDIAbstractPlugin extends AbstractPlugin implements InitializablePlugin {
|
||||||
|
|
|
@ -1,13 +1,18 @@
|
||||||
package org.gcube.application.cms.sdi.plugins;
|
package org.gcube.application.cms.sdi.plugins;
|
||||||
|
|
||||||
import com.vdurmont.semver4j.Semver;
|
import java.sql.SQLException;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.bson.Document;
|
import org.bson.Document;
|
||||||
import org.gcube.application.cms.plugins.IndexerPluginInterface;
|
import org.gcube.application.cms.plugins.IndexerPluginInterface;
|
||||||
import org.gcube.application.cms.plugins.faults.IndexingException;
|
import org.gcube.application.cms.plugins.faults.IndexingException;
|
||||||
import org.gcube.application.cms.plugins.faults.InitializationException;
|
import org.gcube.application.cms.plugins.faults.InitializationException;
|
||||||
import org.gcube.application.cms.plugins.faults.InvalidPluginRequestException;
|
import org.gcube.application.cms.plugins.faults.InvalidPluginRequestException;
|
||||||
import org.gcube.application.cms.plugins.faults.InvalidProfileException;
|
import org.gcube.application.cms.plugins.faults.InvalidProfileException;
|
||||||
|
import org.gcube.application.cms.plugins.implementations.IndexConstants;
|
||||||
import org.gcube.application.cms.plugins.reports.IndexDocumentReport;
|
import org.gcube.application.cms.plugins.reports.IndexDocumentReport;
|
||||||
import org.gcube.application.cms.plugins.reports.InitializationReport;
|
import org.gcube.application.cms.plugins.reports.InitializationReport;
|
||||||
import org.gcube.application.cms.plugins.reports.Report;
|
import org.gcube.application.cms.plugins.reports.Report;
|
||||||
|
@ -33,38 +38,33 @@ import org.gcube.application.geoportal.common.model.plugins.IndexerPluginDescrip
|
||||||
import org.gcube.application.geoportal.common.model.plugins.PluginDescriptor;
|
import org.gcube.application.geoportal.common.model.plugins.PluginDescriptor;
|
||||||
import org.gcube.application.geoportal.common.model.rest.ConfigurationException;
|
import org.gcube.application.geoportal.common.model.rest.ConfigurationException;
|
||||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
|
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
|
||||||
|
import org.gcube.portlets.user.uriresolvermanager.UriResolverManager;
|
||||||
|
import org.gcube.portlets.user.uriresolvermanager.resolvers.query.GeoportalResolverQueryStringBuilder;
|
||||||
|
import org.gcube.portlets.user.uriresolvermanager.resolvers.query.GeoportalResolverQueryStringBuilder.RESOLVE_AS;
|
||||||
import org.geojson.Crs;
|
import org.geojson.Crs;
|
||||||
import org.geojson.GeoJsonObject;
|
import org.geojson.GeoJsonObject;
|
||||||
import org.geojson.LngLatAlt;
|
import org.geojson.LngLatAlt;
|
||||||
import org.geojson.Point;
|
import org.geojson.Point;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import com.vdurmont.semver4j.Semver;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class SDIIndexerPlugin extends SDIAbstractPlugin implements IndexerPluginInterface {
|
public class SDIIndexerPlugin extends SDIAbstractPlugin implements IndexerPluginInterface {
|
||||||
|
|
||||||
|
|
||||||
static final PluginDescriptor DESCRIPTOR = new PluginDescriptor(Constants.INDEXER_PLUGIN_ID,
|
static final PluginDescriptor DESCRIPTOR = new PluginDescriptor(Constants.INDEXER_PLUGIN_ID,
|
||||||
IndexerPluginDescriptor.INDEXER);
|
IndexerPluginDescriptor.INDEXER);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static final ArrayList<BBOXEvaluator> BBOX_EVALUATORS = new ArrayList<>();
|
static final ArrayList<BBOXEvaluator> BBOX_EVALUATORS = new ArrayList<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
DESCRIPTOR.setDescription("SDI Indexer. " +
|
DESCRIPTOR.setDescription("SDI Indexer. " + "Manage Centroids layers.");
|
||||||
"Manage Centroids layers.");
|
|
||||||
DESCRIPTOR.setVersion(new Semver("1.0.0"));
|
DESCRIPTOR.setVersion(new Semver("1.0.0"));
|
||||||
|
|
||||||
BBOX_EVALUATORS.add(new BBOXPathScanner());
|
BBOX_EVALUATORS.add(new BBOXPathScanner());
|
||||||
BBOX_EVALUATORS.add(new BBOXByCoordinatePaths());
|
BBOX_EVALUATORS.add(new BBOXByCoordinatePaths());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -72,7 +72,6 @@ public class SDIIndexerPlugin extends SDIAbstractPlugin implements IndexerPlugin
|
||||||
return DESCRIPTOR;
|
return DESCRIPTOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InitializationReport initInContext() throws InitializationException {
|
public InitializationReport initInContext() throws InitializationException {
|
||||||
InitializationReport report = new InitializationReport();
|
InitializationReport report = new InitializationReport();
|
||||||
|
@ -81,13 +80,12 @@ public class SDIIndexerPlugin extends SDIAbstractPlugin implements IndexerPlugin
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Expected parameters :
|
* Expected parameters : - indexName (unique) - workspace - flagInternalIndex as
|
||||||
* - indexName (unique)
|
* Boolean; boolean - centroidRecord (OPT).
|
||||||
* - workspace
|
|
||||||
* - centroidRecord (OPT)
|
|
||||||
*
|
*
|
||||||
* @param request
|
* @param request the request
|
||||||
* @return
|
* @return the index document report
|
||||||
|
* @throws InvalidPluginRequestException the invalid plugin request exception
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -99,10 +97,10 @@ public class SDIIndexerPlugin extends SDIAbstractPlugin implements IndexerPlugin
|
||||||
UseCaseDescriptor useCaseDescriptor = request.getUseCaseDescriptor();
|
UseCaseDescriptor useCaseDescriptor = request.getUseCaseDescriptor();
|
||||||
Document requestArguments = request.getCallParameters();
|
Document requestArguments = request.getCallParameters();
|
||||||
|
|
||||||
|
log.debug("requestArguments is {} ", requestArguments);
|
||||||
|
|
||||||
IndexDocumentReport report = new IndexDocumentReport(request);
|
IndexDocumentReport report = new IndexDocumentReport(request);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// ********* INIT INDEX
|
// ********* INIT INDEX
|
||||||
// TODO CACHE
|
// TODO CACHE
|
||||||
|
@ -111,10 +109,8 @@ public class SDIIndexerPlugin extends SDIAbstractPlugin implements IndexerPlugin
|
||||||
Document profileConfiguration = getConfigurationFromProfile(useCaseDescriptor).getConfiguration();
|
Document profileConfiguration = getConfigurationFromProfile(useCaseDescriptor).getConfiguration();
|
||||||
log.debug("UseCaseDescriptor Configuration is {} ", profileConfiguration);
|
log.debug("UseCaseDescriptor Configuration is {} ", profileConfiguration);
|
||||||
|
|
||||||
|
|
||||||
// ************* PREPARE RECORD
|
// ************* PREPARE RECORD
|
||||||
|
|
||||||
|
|
||||||
JSONPathWrapper documentNavigator = new JSONPathWrapper(Serialization.write(project));
|
JSONPathWrapper documentNavigator = new JSONPathWrapper(Serialization.write(project));
|
||||||
|
|
||||||
Document centroidDoc = new Document();
|
Document centroidDoc = new Document();
|
||||||
|
@ -124,12 +120,45 @@ public class SDIIndexerPlugin extends SDIAbstractPlugin implements IndexerPlugin
|
||||||
centroidDoc.put(DBConstants.Defaults.PROJECT_ID, project.getId());
|
centroidDoc.put(DBConstants.Defaults.PROJECT_ID, project.getId());
|
||||||
centroidDoc.put(DBConstants.Defaults.DISPLAYED, true);
|
centroidDoc.put(DBConstants.Defaults.DISPLAYED, true);
|
||||||
|
|
||||||
|
// Added by Francesco. Creating Gis Viewer Link as public or private
|
||||||
|
Boolean isInternalIndex = null;
|
||||||
|
try {
|
||||||
|
isInternalIndex = requestArguments
|
||||||
|
.getBoolean(IndexConstants.INDEX_PARAMETER_FLAGINTERNALINDEX);
|
||||||
|
log.debug(IndexConstants.INDEX_PARAMETER_FLAGINTERNALINDEX + " read as {} ", isInternalIndex);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// TODO: handle exception
|
||||||
|
}
|
||||||
|
log.info(IndexConstants.INDEX_PARAMETER_FLAGINTERNALINDEX + " is {} ", isInternalIndex);
|
||||||
|
|
||||||
|
if (isInternalIndex != null) {
|
||||||
|
try {
|
||||||
|
log.debug("Trying to generate Geoportal Gis Link...");
|
||||||
|
// Contacting the Geoportal-Resolver via UriResolverManager
|
||||||
|
UriResolverManager uriResolverManager = new UriResolverManager("GEO");
|
||||||
|
GeoportalResolverQueryStringBuilder builder = new GeoportalResolverQueryStringBuilder(
|
||||||
|
project.getProfileID(), project.getId());
|
||||||
|
builder.scope(request.getContext().getId());
|
||||||
|
|
||||||
|
if (isInternalIndex) {
|
||||||
|
builder.resolverAs(RESOLVE_AS.PRIVATE);
|
||||||
|
} else {
|
||||||
|
builder.resolverAs(RESOLVE_AS.PUBLIC);
|
||||||
|
}
|
||||||
|
Map<String, String> params = builder.buildQueryParameters();
|
||||||
|
String shortLink = uriResolverManager.getLink(params, true);
|
||||||
|
log.info("Geoportal GisViewer link is {} ", shortLink);
|
||||||
|
centroidDoc.put(DBConstants.Defaults.GEOVIEWER_LINK_FIELD, shortLink);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Error on creating the Geoportal GisViewer link for project id {}", project.getId(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ********************** EVALAUTE POSITION
|
// ********************** EVALAUTE POSITION
|
||||||
log.debug("indexing UseCaseDescriptor {} : Evaluating Centroid... ", useCaseDescriptor.getId());
|
log.debug("indexing UseCaseDescriptor {} : Evaluating Centroid... ", useCaseDescriptor.getId());
|
||||||
SpatialReference reference = null;
|
SpatialReference reference = null;
|
||||||
List<IdentificationReference> refs=project.getIdentificationReferenceByType(SpatialReference.SPATIAL_REFERENCE_TYPE);
|
List<IdentificationReference> refs = project
|
||||||
|
.getIdentificationReferenceByType(SpatialReference.SPATIAL_REFERENCE_TYPE);
|
||||||
if (!refs.isEmpty()) {
|
if (!refs.isEmpty()) {
|
||||||
|
|
||||||
// Use existing Reference
|
// Use existing Reference
|
||||||
|
@ -138,7 +167,6 @@ public class SDIIndexerPlugin extends SDIAbstractPlugin implements IndexerPlugin
|
||||||
|
|
||||||
log.debug("Using already defined spatial reference " + reference);
|
log.debug("Using already defined spatial reference " + reference);
|
||||||
|
|
||||||
|
|
||||||
GeoJsonObject object = Serialization.convert(reference.getGeoJson(), GeoJsonObject.class);
|
GeoJsonObject object = Serialization.convert(reference.getGeoJson(), GeoJsonObject.class);
|
||||||
|
|
||||||
GCubeSDILayer.BBOX bbox = GCubeSDILayer.BBOX.fromGeoJSON(object.getBbox());
|
GCubeSDILayer.BBOX bbox = GCubeSDILayer.BBOX.fromGeoJSON(object.getBbox());
|
||||||
|
@ -146,20 +174,20 @@ public class SDIIndexerPlugin extends SDIAbstractPlugin implements IndexerPlugin
|
||||||
log.info("Found declared BBOX {} ", bbox);
|
log.info("Found declared BBOX {} ", bbox);
|
||||||
Double pointX = (bbox.getMaxX() + bbox.getMinX()) / 2;
|
Double pointX = (bbox.getMaxX() + bbox.getMinX()) / 2;
|
||||||
Double pointY = (bbox.getMaxY() + bbox.getMinY()) / 2;
|
Double pointY = (bbox.getMaxY() + bbox.getMinY()) / 2;
|
||||||
String wkt = String.format("POINT (%1$f %2$f) ",
|
String wkt = String.format("POINT (%1$f %2$f) ", pointX, pointY);
|
||||||
pointX, pointY);
|
|
||||||
|
|
||||||
|
|
||||||
centroidDoc.put("geom", wkt);
|
centroidDoc.put("geom", wkt);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// unable to use current Spatial reference, try evaluating it
|
// unable to use current Spatial reference, try evaluating it
|
||||||
log.debug("UseCaseDescriptor {} : Getting evaluation paths from useCaseDescriptor.. ", useCaseDescriptor.getId());
|
log.debug("UseCaseDescriptor {} : Getting evaluation paths from useCaseDescriptor.. ",
|
||||||
|
useCaseDescriptor.getId());
|
||||||
|
|
||||||
// for each configuration option try until found
|
// for each configuration option try until found
|
||||||
GCubeSDILayer.BBOX toSet = null;
|
GCubeSDILayer.BBOX toSet = null;
|
||||||
for (BBOXEvaluator evaluator : BBOX_EVALUATORS) {
|
for (BBOXEvaluator evaluator : BBOX_EVALUATORS) {
|
||||||
log.trace("UCD {}, Project {}. Evaluating BBOX with {}",useCaseDescriptor.getId(),project.getId(),evaluator);
|
log.trace("UCD {}, Project {}. Evaluating BBOX with {}", useCaseDescriptor.getId(), project.getId(),
|
||||||
|
evaluator);
|
||||||
try {
|
try {
|
||||||
if (evaluator.isConfigured(profileConfiguration)) {
|
if (evaluator.isConfigured(profileConfiguration)) {
|
||||||
toSet = evaluator.evaluate(profileConfiguration, useCaseDescriptor, documentNavigator);
|
toSet = evaluator.evaluate(profileConfiguration, useCaseDescriptor, documentNavigator);
|
||||||
|
@ -170,8 +198,8 @@ public class SDIIndexerPlugin extends SDIAbstractPlugin implements IndexerPlugin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
log.warn("UCD {}, Project {}. Exception with {}",
|
log.warn("UCD {}, Project {}. Exception with {}", useCaseDescriptor.getId(), project.getId(),
|
||||||
useCaseDescriptor.getId(),project.getId(),evaluator,t);
|
evaluator, t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (toSet == null)
|
if (toSet == null)
|
||||||
|
@ -180,12 +208,10 @@ public class SDIIndexerPlugin extends SDIAbstractPlugin implements IndexerPlugin
|
||||||
Double pointX = (toSet.getMaxX() + toSet.getMinX()) / 2;
|
Double pointX = (toSet.getMaxX() + toSet.getMinX()) / 2;
|
||||||
Double pointY = (toSet.getMaxY() + toSet.getMinY()) / 2;
|
Double pointY = (toSet.getMaxY() + toSet.getMinY()) / 2;
|
||||||
log.info("Evaluated BBOX {} ", toSet);
|
log.info("Evaluated BBOX {} ", toSet);
|
||||||
String wkt = String .format("POINT (%1$f %2$f) ",
|
String wkt = String.format("POINT (%1$f %2$f) ", pointX, pointY);
|
||||||
pointX, pointY);
|
|
||||||
// TODO support altitude
|
// TODO support altitude
|
||||||
Double pointZ = 0d;
|
Double pointZ = 0d;
|
||||||
|
|
||||||
|
|
||||||
centroidDoc.put("geom", wkt);
|
centroidDoc.put("geom", wkt);
|
||||||
|
|
||||||
Point point = new Point();
|
Point point = new Point();
|
||||||
|
@ -195,12 +221,11 @@ public class SDIIndexerPlugin extends SDIAbstractPlugin implements IndexerPlugin
|
||||||
// TODO Manage CRS
|
// TODO Manage CRS
|
||||||
point.setCrs(new Crs());
|
point.setCrs(new Crs());
|
||||||
reference = new SpatialReference(Serialization.asDocument(point));
|
reference = new SpatialReference(Serialization.asDocument(point));
|
||||||
log.info("UCD {} project {}, Setting Spatial Reference {} ",useCaseDescriptor.getId(),project.getId(),Serialization.write(reference));
|
log.info("UCD {} project {}, Setting Spatial Reference {} ", useCaseDescriptor.getId(), project.getId(),
|
||||||
|
Serialization.write(reference));
|
||||||
report.addIdentificationReference(reference);
|
report.addIdentificationReference(reference);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// *********** Additional Values from useCaseDescriptor
|
// *********** Additional Values from useCaseDescriptor
|
||||||
|
|
||||||
log.info("Setting additional values to centroid from mappings ..");
|
log.info("Setting additional values to centroid from mappings ..");
|
||||||
|
@ -212,8 +237,10 @@ public class SDIIndexerPlugin extends SDIAbstractPlugin implements IndexerPlugin
|
||||||
StringBuilder b = new StringBuilder();
|
StringBuilder b = new StringBuilder();
|
||||||
foundValues.forEach(o -> {
|
foundValues.forEach(o -> {
|
||||||
// Parser returns list of list
|
// Parser returns list of list
|
||||||
if (o instanceof Collection) ((Collection<?>) o).forEach(v ->b.append(v + ","));
|
if (o instanceof Collection)
|
||||||
else b.append(o+",");
|
((Collection<?>) o).forEach(v -> b.append(v + ","));
|
||||||
|
else
|
||||||
|
b.append(o + ",");
|
||||||
});
|
});
|
||||||
b.deleteCharAt(b.length() - 1);
|
b.deleteCharAt(b.length() - 1);
|
||||||
toSetValue = b.toString();
|
toSetValue = b.toString();
|
||||||
|
@ -240,8 +267,6 @@ public class SDIIndexerPlugin extends SDIAbstractPlugin implements IndexerPlugin
|
||||||
indexer.updateIsVisible(true, ids);
|
indexer.updateIsVisible(true, ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
report.setStatus(Report.Status.OK);
|
report.setStatus(Report.Status.OK);
|
||||||
} catch (SDIInteractionException e) {
|
} catch (SDIInteractionException e) {
|
||||||
log.error("Unable to index " + request, e);
|
log.error("Unable to index " + request, e);
|
||||||
|
@ -281,9 +306,7 @@ public class SDIIndexerPlugin extends SDIAbstractPlugin implements IndexerPlugin
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Expected parameters :
|
* Expected parameters : workspace indexName
|
||||||
* workspace
|
|
||||||
* indexName
|
|
||||||
*
|
*
|
||||||
* @param request
|
* @param request
|
||||||
* @return
|
* @return
|
||||||
|
@ -294,31 +317,24 @@ public class SDIIndexerPlugin extends SDIAbstractPlugin implements IndexerPlugin
|
||||||
try {
|
try {
|
||||||
return getIndexer(request.getUseCaseDescriptor(), request.getCallParameters()).getIndexConfiguration();
|
return getIndexer(request.getUseCaseDescriptor(), request.getCallParameters()).getIndexConfiguration();
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
throw new ConfigurationException("Unable to get Postgis index for ucd "+request.getUseCaseDescriptor().getId()+" in "+ request.getContext(),t);
|
throw new ConfigurationException("Unable to get Postgis index for ucd "
|
||||||
|
+ request.getUseCaseDescriptor().getId() + " in " + request.getContext(), t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Inits index
|
// Inits index
|
||||||
// TODO CACHE
|
// TODO CACHE
|
||||||
private PostgisIndexer getIndexer(UseCaseDescriptor ucd,Document params) throws ConfigurationException, SQLException, InvalidProfileException, SDIInteractionException {
|
private PostgisIndexer getIndexer(UseCaseDescriptor ucd, Document params)
|
||||||
|
throws ConfigurationException, SQLException, InvalidProfileException, SDIInteractionException {
|
||||||
PostgisIndexer indexer = new PostgisIndexer(sdiCache.getObject(), ucd, postgisCache.getObject());
|
PostgisIndexer indexer = new PostgisIndexer(sdiCache.getObject(), ucd, postgisCache.getObject());
|
||||||
|
|
||||||
List<MappingObject> mappingObjects = getMappings(ucd);
|
List<MappingObject> mappingObjects = getMappings(ucd);
|
||||||
List<PostgisTable.Field> fields = PostgisTable.Field.fromMappings(mappingObjects);
|
List<PostgisTable.Field> fields = PostgisTable.Field.fromMappings(mappingObjects);
|
||||||
|
|
||||||
indexer.initIndex(params.getString("indexName"),
|
indexer.initIndex(params.getString(IndexConstants.INDEX_PARAMETER_INDEXNAME), fields,
|
||||||
fields,
|
params.getString(IndexConstants.INDEX_PARAMETER_WORKSPACE),
|
||||||
params.getString("workspace"),
|
params.getString(IndexConstants.INDEX_PARAMETER_INDEXNAME));
|
||||||
params.getString("indexName"));
|
|
||||||
return indexer;
|
return indexer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
package org.gcube.application.cms.sdi.plugins;
|
package org.gcube.application.cms.sdi.plugins;
|
||||||
|
|
||||||
import com.vdurmont.semver4j.Semver;
|
import java.util.ArrayList;
|
||||||
import lombok.Data;
|
import java.util.HashMap;
|
||||||
import lombok.Synchronized;
|
import java.util.List;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.bson.Document;
|
import org.bson.Document;
|
||||||
import org.gcube.application.cms.implementations.utils.UserUtils;
|
import org.gcube.application.cms.implementations.utils.UserUtils;
|
||||||
import org.gcube.application.cms.plugins.MaterializationPlugin;
|
import org.gcube.application.cms.plugins.MaterializationPlugin;
|
||||||
|
@ -28,12 +29,12 @@ import org.gcube.application.geoportal.common.model.plugins.MaterializerPluginDe
|
||||||
import org.gcube.application.geoportal.common.model.plugins.PluginDescriptor;
|
import org.gcube.application.geoportal.common.model.plugins.PluginDescriptor;
|
||||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.Field;
|
import org.gcube.application.geoportal.common.model.useCaseDescriptor.Field;
|
||||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
|
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
|
||||||
import org.gcube.application.geoportal.common.utils.ContextUtils;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import com.vdurmont.semver4j.Semver;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import lombok.Data;
|
||||||
import java.util.Map;
|
import lombok.Synchronized;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class SDIMaterializerPlugin extends AbstractPlugin implements MaterializationPlugin {
|
public class SDIMaterializerPlugin extends AbstractPlugin implements MaterializationPlugin {
|
||||||
|
|
Loading…
Reference in New Issue