PostgisIndexer bugfixes

This commit is contained in:
Fabio Sinibaldi 2022-03-17 17:54:00 +01:00
parent bffae85071
commit f106045775
17 changed files with 275 additions and 138 deletions

View File

@ -21,8 +21,9 @@ public class BaseExecutionRequest extends BaseRequest{
this.document = document;
}
public void validate() throws InvalidPluginRequestException {
public BaseExecutionRequest validate() throws InvalidPluginRequestException {
super.validate();
if(document==null) throw new InvalidPluginRequestException("Document cannot be null");
return this;
}
}

View File

@ -1,5 +1,6 @@
package org.gcube.application.cms.plugins.requests;
import com.fasterxml.jackson.databind.ser.Serializers;
import lombok.*;
import org.bson.Document;
import org.gcube.application.cms.plugins.faults.InvalidPluginRequestException;
@ -32,8 +33,14 @@ public class BaseRequest {
return params.getString(param);
}
public void validate() throws InvalidPluginRequestException {
public BaseRequest validate() throws InvalidPluginRequestException {
if(useCaseDescriptor ==null)throw new InvalidPluginRequestException("UseCaseDescriptor cannot be null ");
return this;
}
public BaseRequest setParameter(String key,Object value){
if(callParameters==null) callParameters=new Document();
callParameters.put(key, value);
return this;
}
}

View File

@ -3,19 +3,22 @@ package org.gcube.application.cms.tests;
import org.gcube.application.cms.implementations.ISInterface;
import org.gcube.application.cms.implementations.ImplementationProvider;
import org.gcube.application.cms.plugins.InitializablePlugin;
import org.gcube.application.cms.plugins.LifecycleManager;
import org.gcube.application.cms.plugins.Plugin;
import org.gcube.application.cms.plugins.PluginsReflections;
import org.gcube.application.cms.plugins.faults.InitializationException;
import org.gcube.application.cms.plugins.faults.PluginExecutionException;
import org.gcube.application.geoportal.common.model.document.accounting.Context;
import org.gcube.application.geoportal.common.model.document.accounting.User;
import org.gcube.application.geoportal.common.model.rest.ConfigurationException;
import org.gcube.application.geoportal.common.utils.tests.GCubeTest;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.*;
import java.util.HashMap;
import java.util.Map;
import static org.junit.Assume.assumeTrue;
public class BasicPluginTest {
@ -69,9 +72,15 @@ public class BasicPluginTest {
System.out.println("Plugin Loading OK");
if(GCubeTest.isTestInfrastructureEnabled()){
}
}
@Before
public void initContext(){
assumeTrue(GCubeTest.isTestInfrastructureEnabled());
TokenSetter.set(GCubeTest.getContext());
}
}

View File

@ -162,9 +162,7 @@ public class ConcessioniLifeCycleManager implements LifecycleManager {
IndexDocumentRequest indexRequest = new IndexDocumentRequest(request.getUseCaseDescriptor(),request.getCaller(), request.getContext(),request.getDocument());
Document callParameters = new Document();
callParameters.put("workspace",Files.fixFilename("gna_concessioni_"+request.getContext().getId()));
callParameters.put("indexName",Files.fixFilename("gna_concessioni_centroids_"+request.getContext().getId()));
Document callParameters = getPublicIndexParams(request);
indexRequest.setCallParameters(callParameters);
IndexDocumentReport indexReport = indexerPlugin.index(indexRequest);
@ -254,19 +252,18 @@ public class ConcessioniLifeCycleManager implements LifecycleManager {
@Override
public Configuration getCurrentConfiguration(BaseRequest req) throws ConfigurationException {
Configuration toReturn = new Configuration();
toReturn.setArchives(new ArrayList<>());
toReturn.setIndexes(new ArrayList<>());
IndexerPluginInterface indexerPlugin;
indexerPlugin = (IndexerPluginInterface) pluginManager.getById("SDI-Indexer-Plugin");
Document callParameters = new Document();
callParameters.put("workspace",Files.fixFilename("gna_concessioni_"+req.getContext()));
callParameters.put("indexName",Files.fixFilename("gna_concessioni_centroids_"+req.getContext()));
BaseRequest indexRequest = new BaseRequest(req.getUseCaseDescriptor(),req.getCaller(),req.getContext());
indexRequest.setCallParameters(callParameters);
// Info on Public index
indexRequest.setCallParameters(getPublicIndexParams(req));
toReturn.getIndexes().add(indexerPlugin.getIndex(indexRequest));
// Info on internal_index
indexRequest.setCallParameters(getInternalIndexParams(req));
toReturn.getIndexes().add(indexerPlugin.getIndex(indexRequest));
return toReturn;
@ -278,6 +275,21 @@ public class ConcessioniLifeCycleManager implements LifecycleManager {
}
private Document getInternalIndexParams(BaseRequest req){
Document callParameters = new Document();
callParameters.put("workspace",Files.fixFilename(req.getUseCaseDescriptor().getId()+"_internal_"+req.getContext().getName()));
callParameters.put("indexName",Files.fixFilename(req.getUseCaseDescriptor().getId()+"_internal_"+req.getContext().getName()+"_centroids"));
return callParameters;
}
private Document getPublicIndexParams(BaseRequest req){
Document callParameters = new Document();
callParameters.put("workspace",Files.fixFilename(req.getUseCaseDescriptor().getId()+req.getContext().getName()));
callParameters.put("indexName",Files.fixFilename(req.getUseCaseDescriptor().getId()+req.getContext().getName()+"_centroids"));
return callParameters;
}
// STATIC ROUTINES

View File

@ -88,17 +88,17 @@ public class GCubeSDILayer extends Materialization{
}
@JsonIgnore
public void setMaxX(Double d){this.put(MAX_X,d);}
public BBOX setMaxX(Double d){this.put(MAX_X,d);return this;}
@JsonIgnore
public void setMaxY(Double d){this.put(MAX_Y,d);}
public BBOX setMaxY(Double d){this.put(MAX_Y,d);return this;}
@JsonIgnore
public void setMaxZ(Double d){this.put(MAX_Z,d);}
public BBOX setMaxZ(Double d){this.put(MAX_Z,d);return this;}
@JsonIgnore
public void setMinX(Double d){this.put(MIN_X,d);}
public BBOX setMinX(Double d){this.put(MIN_X,d);return this;}
@JsonIgnore
public void setMinY(Double d){this.put(MIN_Y,d);}
public BBOX setMinY(Double d){this.put(MIN_Y,d);return this;}
@JsonIgnore
public void setMinZ(Double d){this.put(MIN_Z,d);}
public BBOX setMinZ(Double d){this.put(MIN_Z,d);return this;}
@JsonIgnore
public Double getMinY(){return (Double) this.getOrDefault(MIN_Y,-90d);}
@JsonIgnore
@ -135,4 +135,5 @@ public class GCubeSDILayer extends Materialization{
@JsonIgnore
public List getPlatformInfo(){return this.get(PLATFORM_INFO,List.class);}
}

View File

@ -96,6 +96,6 @@ public class Files {
toFix=toFix.substring(0,toFix.indexOf("."));
}
return toFix.toLowerCase().
replaceAll("[\\*\\+\\/\\\\ \\[\\]\\(\\)\\.\\\"\\:\\;\\|\\=]","_")+extension;
replaceAll("[\\-\\*\\+\\/\\\\ \\[\\]\\(\\)\\.\\\"\\:\\;\\|\\=]","_")+extension;
}
}

View File

@ -12,7 +12,7 @@ public class GCubeTest {
//testContext = "/pred4s/preprod/preVRE";
//testContext = "/gcube/devsec/devVRE";
testContext = "/gcube/devsec/devVRE";
System.out.println("TEST CONTEXT = "+testContext);

View File

@ -101,11 +101,18 @@ public class PostgisDBManager implements PostgisDBManagerI {
conn.createStatement().executeUpdate("TRUNCATE Table "+tableName);
}
// @Override
// public ResultSet queryAll(PostgisTable table) throws SQLException {
// // TODO Check schema
// return conn.createStatement().executeQuery("Select * from "+table.getTablename());
// }
@Override
public ResultSet queryAll(PostgisTable table) throws SQLException {
// TODO Check schema
return conn.createStatement().executeQuery("Select * from "+table.getTablename());
}
@Override
public long count(PostgisTable table) throws SQLException {
ResultSet rs = conn.createStatement().executeQuery("Select count(*) from "+table.getTablename());
rs.next();
return rs.getLong(1);
}
// *********************** INNER UTILS CLASS

View File

@ -24,7 +24,7 @@ public interface PostgisDBManagerI {
void truncate(String tableName) throws SQLException;
int deleteByFieldValue(PostgisTable target, PostgisTable.Field field, Object value) throws SQLException;
long count(PostgisTable table)throws SQLException;
// DatabaseConnection getConnectionDescriptor();
@ -32,7 +32,7 @@ public interface PostgisDBManagerI {
// PostgisTable.POINT evaluateCentroid(PostgisTable table) throws SQLException, DataParsingException;
// ResultSet queryAll(PostgisTable table) throws SQLException;
ResultSet queryAll(PostgisTable table) throws SQLException;
}

View File

@ -5,7 +5,9 @@ import lombok.extern.slf4j.Slf4j;
import org.bson.Document;
import org.gcube.application.cms.plugins.requests.BaseRequest;
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.GCubeSDILayer;
import org.gcube.application.geoportal.common.model.legacy.SDILayerDescriptor;
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
import org.gcube.application.geoportal.common.model.rest.DatabaseConnection;
@ -22,6 +24,10 @@ import java.util.List;
public class PostgisIndexer {
public static final String INDEX_TYPE="GIS-CENTROIDS";
public static void init() throws ClassNotFoundException {
Class.forName("org.postgresql.Driver");
@ -38,6 +44,12 @@ public class PostgisIndexer {
DatabaseConnection connectionParameters;
PostgisDBManagerI dbManager=null;
PostgisTable table = null;
GCubeSDILayer indexLayer = null;
String indexName = null;
private List<CrossReferencedLayer> crossReferenceableLayers= new ArrayList<>();
public PostgisIndexer(SDIManagerWrapper manager, UseCaseDescriptor useCaseDescriptor,
DatabaseConnection postgisConnection) throws SQLException {
@ -52,13 +64,7 @@ public class PostgisIndexer {
}
PostgisTable table = null;
private String storeName = null;
private String workspace = null;
private SDILayerDescriptor indexLayer = null;
private List<SDILayerDescriptor> crossReferenceableLayers= new ArrayList<>();
public void initIndex(String indexName, List<PostgisTable.Field> fields, String workspace,String storeName) throws SQLException, SDIInteractionException {
@ -70,31 +76,28 @@ public class PostgisIndexer {
dbManager.create(table);
log.debug("Checking/ registering index layer in GS ");
String wmsUrl=manager.configureCentroidLayer(indexName,workspace,storeName,table,connectionParameters);
indexName = indexName;
indexLayer = manager.configureCentroidLayer(indexName,workspace,storeName,table,connectionParameters);
// TODO Additional layers
// Create layer
// Publish cross related layers
// register cross related layers
}
HashMap<String,String> wmsUrls=new HashMap<>();
//private String wmsByIndex(String indexName){}
HashMap<String,GCubeSDILayer> crossReferenced = new HashMap<>();
public Index getIndexConfiguration(){
Index toReturn = new Index("GIS-CENTROIDS");
Index toReturn = new Index(INDEX_TYPE);
// SDI Layers
// cross reference info
toReturn.put("",null);
toReturn.put("layer",indexLayer);
toReturn.put("indexName",indexName);
try {
toReturn.put("records", dbManager.count(table));
}catch (SQLException e) {
log.warn("Unable to count records for index " + indexName, e);
}
toReturn.put("crossReferencedLayers",crossReferenced);
return toReturn;
}

View File

@ -113,7 +113,6 @@ public class PostgisTable {
return null;
}
@NonNull
private String tablename;

View File

@ -1,38 +1,22 @@
package org.gcube.application.cms.sdi.engine;
import it.geosolutions.geoserver.rest.GeoServerRESTPublisher;
import it.geosolutions.geoserver.rest.GeoServerRESTReader;
import it.geosolutions.geoserver.rest.decoder.RESTFeatureType;
import it.geosolutions.geoserver.rest.decoder.RESTLayer;
import it.geosolutions.geoserver.rest.encoder.datastore.GSPostGISDatastoreEncoder;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.bson.Document;
import org.gcube.application.cms.sdi.faults.SDIInteractionException;
import org.gcube.application.cms.plugins.requests.BaseExecutionRequest;
import org.gcube.application.cms.serialization.Serialization;
import org.gcube.application.geoportal.common.model.document.filesets.GCubeSDILayer;
import org.gcube.application.geoportal.common.model.document.filesets.RegisteredFile;
import org.gcube.application.geoportal.common.model.document.filesets.RegisteredFileSet;
import org.gcube.application.geoportal.common.model.rest.DatabaseConnection;
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.model.Destination;
import org.gcube.data.transfer.model.DestinationClashPolicy;
import org.gcube.spatial.data.gis.GISInterface;
import org.gcube.spatial.data.gis.is.AbstractGeoServerDescriptor;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -40,11 +24,6 @@ import java.util.regex.Pattern;
public class SDIManager {
static protected final String EPSG_4326="EPSG:4326";
static final String WGS84_FULL="GEOGCS[\"WGS 84\", DATUM[\"World Geodetic System 1984\", SPHEROID[\"WGS 84\", 6378137.0, 298.257223563, AUTHORITY[\"EPSG\",\"7030\"]],"+
"AUTHORITY[\"EPSG\",\"6326\"]], PRIMEM[\"Greenwich\", 0.0, AUTHORITY[\"EPSG\",\"8901\"]], UNIT[\"degree\", 0.017453292519943295],"+
"AXIS[\"Geodetic longitude\", EAST], AXIS[\"Geodetic latitude\", NORTH], AUTHORITY[\"EPSG\",\"4326\"]]";
public static final Pattern HOSTNAME_PATTERN=Pattern.compile("(?<=\\:\\/\\/)[^\\:]*");
public static final Pattern PORT_PATTERN=Pattern.compile("(?<=\\:)[\\d]+");

View File

@ -11,6 +11,7 @@ import org.bson.Document;
import org.gcube.application.cms.caches.AbstractScopedMap;
import org.gcube.application.cms.plugins.requests.BaseExecutionRequest;
import org.gcube.application.cms.sdi.faults.SDIInteractionException;
import org.gcube.application.cms.sdi.model.GCubeSDILayerBuilder;
import org.gcube.application.cms.serialization.Serialization;
import org.gcube.application.geoportal.common.model.document.filesets.GCubeSDILayer;
import org.gcube.application.geoportal.common.model.document.filesets.RegisteredFile;
@ -28,6 +29,9 @@ import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import static org.gcube.application.cms.sdi.model.GCubeSDILayerBuilder.EPSG_4326;
import static org.gcube.application.cms.sdi.model.GCubeSDILayerBuilder.WGS84_FULL;
@Slf4j
public class SDIManagerWrapper extends SDIManager{
@ -60,9 +64,10 @@ public class SDIManagerWrapper extends SDIManager{
if (fileSet.getPayloads().isEmpty()) throw new SDIInteractionException("No payload to materialize");
Document geoserverInfo = new Document();
geoserverInfo.put("_type", "Geoserver");
geoserverInfo.put("workspace", workspace);
// Document geoserverInfo = new Document();
GCubeSDILayerBuilder layerBuilder=new GCubeSDILayerBuilder();
layerBuilder.setWorkspace(workspace);
layerBuilder.setHost(getGeoserverHostName());
// Evaluate Layer Name
@ -77,13 +82,13 @@ public class SDIManagerWrapper extends SDIManager{
toSetLayerName = baseName + "_" + count;
log.debug("layer for " + baseName + " already existing, trying " + toSetLayerName);
}
geoserverInfo.put("layerName", toSetLayerName);
log.debug("Layer name will be {}", toSetLayerName);
layerBuilder.setLayerName(toSetLayerName);
String folderRelativePath = basePersistencePAth + "/" + documentID + "/" + fileSet.getUUID() + "/" + toSetLayerName;
log.debug("GS Relative destination path is {}", folderRelativePath);
geoserverInfo.put("persistencePath", folderRelativePath);
layerBuilder.setPersistencePath(folderRelativePath);
List<String> filenames = new ArrayList<>();
@ -114,11 +119,12 @@ public class SDIManagerWrapper extends SDIManager{
//geoserverInfo.put(""result.getRemotePath().substring(0, result.getRemotePath().lastIndexOf("/")));
absolutePath = result.getRemotePath().substring(0, result.getRemotePath().lastIndexOf("/"));
}
geoserverInfo.put("files", filenames);
layerBuilder.setFiles(filenames);
// Publishing layer in GS
String storeName = toSetLayerName + "_store";
geoserverInfo.put("storeName", storeName);
layerBuilder.setStoreName(storeName);
GeoServerRESTPublisher publisher = getCurrentGeoserver().getPublisher();
log.debug("Trying to create remote workspace : " + workspace);
@ -150,35 +156,7 @@ public class SDIManagerWrapper extends SDIManager{
RESTFeatureType f = gsReader.getFeatureType(l);
List<Document> ogcLinks = new ArrayList<>();
Document wmsLink = new Document();
wmsLink.put("wms", String.format("https://%1$s/geoserver/%2$s/wms?"
+ "service=WMS&version=1.1.0&request=GetMap&layers=%2$s:%3$s&"
+ "styles=&bbox=%4$f,%5$f,%6$f,%7$f&srs=%8$s&format=application/openlayers&width=%9$d&height=%10$d",
getGeoserverHostName(),
workspace,
toSetLayerName,
f.getMinX(),
f.getMinY(),
f.getMaxX(),
f.getMaxY(),
EPSG_4326,
400,
400));
ogcLinks.add(wmsLink);
List<Document> platformInfo = new ArrayList<>();
platformInfo.add(geoserverInfo);
// TODO Metadata
// Materialization object
GCubeSDILayer materialization = new GCubeSDILayer();
materialization.put(GCubeSDILayer.OGC_LINKS, ogcLinks);
materialization.put(GCubeSDILayer.B_BOX, new GCubeSDILayer.BBOX(f.getMaxX(), f.getMaxY(), f.getMinX(), f.getMinY()));
materialization.put(GCubeSDILayer.PLATFORM_INFO, platformInfo);
GCubeSDILayer materialization = layerBuilder.getLayer();
log.info("Generated Materialization {}", materialization);
//Add Materialization to registered file set
@ -196,7 +174,12 @@ public class SDIManagerWrapper extends SDIManager{
}
public String configureCentroidLayer(String name, String workspace, String storeName, PostgisTable table, DatabaseConnection connection) throws SDIInteractionException {
public GCubeSDILayer configureCentroidLayer(String name, String workspace, String storeName, PostgisTable table, DatabaseConnection connection) throws SDIInteractionException {
GCubeSDILayerBuilder builder = new GCubeSDILayerBuilder()
.setWorkspace(workspace)
.setStoreName(storeName)
.setHost(getGeoserverHostName());
GSFeatureTypeEncoder fte=new GSFeatureTypeEncoder();
fte.setAbstract("Centroid layer for "+name);
@ -205,11 +188,6 @@ public class SDIManagerWrapper extends SDIManager{
fte.setTitle(name);
fte.setName(name);
// GeoServer loads all fields
// fte.setAttribute(attrs);
fte.setLatLonBoundingBox(-180.0, -90.0, 180.0, 90.0, WGS84_FULL);
String style="clustered_centroids";
@ -233,25 +211,9 @@ public class SDIManagerWrapper extends SDIManager{
log.debug("layer "+name+" already exists");
String link=String.format("https://%1$s/geoserver/%2$s/wms?"
+"service=WMS&version=1.1.0&request=GetMap&layers=%2$s:%3$s&"
+ "styles=&bbox=%4$s,%5$s,%6$s,%7$s&srs=%8$s&format=application/openlayers&width=%9$d&height=%10$d",
getGeoserverHostName(),
workspace,
name,
"-1563071.166172796",
"4789738.204048398",
"4334926.486925308",
"5828118.072551585",
EPSG_4326,
400,
400);
return name;
return builder.getLayer();
} catch (IllegalArgumentException | MalformedURLException e) {
throw new SDIInteractionException("Unable to create layer "+name,e);
}
}
}
}

View File

@ -0,0 +1,4 @@
package org.gcube.application.cms.sdi.model;
public class CrossReferencedLayer {
}

View File

@ -0,0 +1,121 @@
package org.gcube.application.cms.sdi.model;
import freemarker.core.PlainTextOutputFormat;
import lombok.Getter;
import org.bson.Document;
import org.gcube.application.geoportal.common.model.document.filesets.GCubeSDILayer;
import sun.misc.GC;
import javax.print.Doc;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class GCubeSDILayerBuilder {
public static enum OGC_TYPE{
wms,wfs,wcs,csw
}
public static final String EPSG_4326="EPSG:4326";
public static final String WGS84_FULL="GEOGCS[\"WGS 84\", DATUM[\"World Geodetic System 1984\", SPHEROID[\"WGS 84\", 6378137.0, 298.257223563, AUTHORITY[\"EPSG\",\"7030\"]],"+
"AUTHORITY[\"EPSG\",\"6326\"]], PRIMEM[\"Greenwich\", 0.0, AUTHORITY[\"EPSG\",\"8901\"]], UNIT[\"degree\", 0.017453292519943295],"+
"AXIS[\"Geodetic longitude\", EAST], AXIS[\"Geodetic latitude\", NORTH], AUTHORITY[\"EPSG\",\"4326\"]]";
public static final String GS_PLATFORM="Geoserver";
GCubeSDILayer theObject = new GCubeSDILayer();
@Getter
Document platformInfo= new Document(GCubeSDILayer.PLATFORM_INFO,GS_PLATFORM);
@Getter
GCubeSDILayer.BBOX bbox = GCubeSDILayer.BBOX.WORLD;
@Getter
Map<OGC_TYPE,Document> ogcLinks = new HashMap<>();
public GCubeSDILayerBuilder(){
}
public GCubeSDILayer getLayer(){
theObject.put(GCubeSDILayer.PLATFORM_INFO,platformInfo);
theObject.put(GCubeSDILayer.B_BOX,bbox);
prepareOGCLinks();
theObject.put(GCubeSDILayer.OGC_LINKS,ogcLinks);
return theObject;
}
// @@@@@@@@@@@@@@@@@@ Platform info
public GCubeSDILayerBuilder setWorkspace(String ws){
platformInfo.put("workspace",ws);
return this;
}
public GCubeSDILayerBuilder setHost(String ws){
platformInfo.put("host",ws);
return this;
}
public GCubeSDILayerBuilder setEngineVersion(String ws){
platformInfo.put("engineVersion",ws);
return this;
}
public GCubeSDILayerBuilder setLayerName(String ws){
platformInfo.put("layerName",ws);
return this;
}
public GCubeSDILayerBuilder setPersistencePath(String ws){
platformInfo.put("persistencePath",ws);
return this;
}
public GCubeSDILayerBuilder setStoreName(String ws){
platformInfo.put("storeName",ws);
return this;
}
public GCubeSDILayerBuilder setFiles(List<String> ws){
platformInfo.put("files",ws);
return this;
}
private void prepareOGCLinks(){
if(!ogcLinks.containsKey(OGC_TYPE.wms)){
addLink(OGC_TYPE.wms,String.format("https://%1$s/geoserver/%2$s/wms?"
+ "service=WMS&version=1.1.0&request=GetMap&layers=%2$s:%3$s&"
+ "styles=&bbox=%4$f,%5$f,%6$f,%7$f&srs=%8$s&format=application/openlayers&width=%9$d&height=%10$d",
platformInfo.get("host"),
platformInfo.get("workspace"),
platformInfo.get("layerName"),
bbox.getMinX(),
bbox.getMinY(),
bbox.getMaxX(),
bbox.getMaxY(),
EPSG_4326,
400,
400));
}
}
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@ OGC
public GCubeSDILayerBuilder addLink(OGC_TYPE type,String link){
ogcLinks.put(type,new Document(type.name(),link));
return this;
}
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@ BBOX
}

View File

@ -215,6 +215,15 @@ public class SDIIndexerPlugin extends SDIAbstractPlugin implements IndexerPlugin
}
}
/**
* Expected parameters :
* workspace
* indexName
*
* @param request
* @return
* @throws ConfigurationException
*/
@Override
public Index getIndex(BaseRequest request) throws ConfigurationException {
try {

View File

@ -6,18 +6,27 @@ import org.gcube.application.cms.plugins.IndexerPluginInterface;
import org.gcube.application.cms.plugins.faults.PluginExecutionException;
import org.gcube.application.cms.plugins.reports.IndexDocumentReport;
import org.gcube.application.cms.plugins.reports.Report;
import org.gcube.application.cms.plugins.requests.BaseRequest;
import org.gcube.application.cms.plugins.requests.IndexDocumentRequest;
import org.gcube.application.cms.sdi.engine.PostgisIndexer;
import org.gcube.application.cms.sdi.plugins.SDIIndexerPlugin;
import org.gcube.application.cms.serialization.Serialization;
import org.gcube.application.cms.tests.BasicPluginTest;
import org.gcube.application.cms.tests.TestDocuments;
import org.gcube.application.cms.tests.TestProfiles;
import org.gcube.application.geoportal.common.model.configuration.Index;
import org.gcube.application.geoportal.common.model.document.Project;
import org.gcube.application.geoportal.common.model.document.accounting.Context;
import org.gcube.application.geoportal.common.model.document.accounting.User;
import org.gcube.application.geoportal.common.model.rest.ConfigurationException;
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
import org.gcube.application.geoportal.common.utils.Files;
import org.gcube.application.geoportal.common.utils.tests.GCubeTest;
import org.gcube.spatial.data.geonetwork.utils.UserUtils;
import org.junit.Test;
import ucar.units.Base;
import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.assertTrue;
import static org.junit.Assume.assumeTrue;
@ -47,4 +56,18 @@ public class IndexerTest extends BasicPluginTest {
assertTrue(response.prepareResult().getSpatialReference()!=null);
}
@Test
public void getIndex() throws ConfigurationException {
assumeTrue(GCubeTest.isTestInfrastructureEnabled());
IndexerPluginInterface plugin = (IndexerPluginInterface) plugins.get(SDIIndexerPlugin.DESCRIPTOR.getId());
UseCaseDescriptor descriptor=TestProfiles.profiles.get("profiledConcessioni");
Index index = plugin.getIndex(new BaseRequest(descriptor,getTestUser(),getTestContext())
.setParameter("workspace", Files.fixFilename(GCubeTest.getContext()+"_test-ws"))
.setParameter("indexName",Files.fixFilename(GCubeTest.getContext()+"test_index")));
System.out.println("Test Index Is "+index);
assertEquals(index.getType(), PostgisIndexer.INDEX_TYPE);
}
}