Refactoring to Projects and UCD
This commit is contained in:
parent
8b5f25cb75
commit
148554d3c9
|
@ -1,13 +1,8 @@
|
|||
package org.gcube.application.cms.plugins;
|
||||
|
||||
import org.gcube.application.cms.plugins.faults.InvalidProfileException;
|
||||
import org.gcube.application.cms.plugins.faults.PluginExecutionException;
|
||||
import org.gcube.application.cms.plugins.model.PluginDescriptor;
|
||||
import org.gcube.application.cms.plugins.reports.DocumentHandlingReport;
|
||||
import org.gcube.application.cms.plugins.requests.BaseExecutionRequest;
|
||||
import org.gcube.application.geoportal.common.faults.InvalidRequestException;
|
||||
import org.gcube.application.geoportal.common.model.profile.HandlerDeclaration;
|
||||
import org.gcube.application.geoportal.common.model.profile.Profile;
|
||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.HandlerDeclaration;
|
||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -18,11 +13,11 @@ public abstract class AbstractPlugin implements Plugin{
|
|||
|
||||
|
||||
|
||||
protected HandlerDeclaration getConfigurationFromProfile(Profile profile) throws InvalidProfileException{
|
||||
return getMultipleDeclarationsFromProfile(profile).get(0);
|
||||
protected HandlerDeclaration getConfigurationFromProfile(UseCaseDescriptor useCaseDescriptor) throws InvalidProfileException{
|
||||
return getMultipleDeclarationsFromProfile(useCaseDescriptor).get(0);
|
||||
}
|
||||
|
||||
protected List<HandlerDeclaration> getMultipleDeclarationsFromProfile(Profile p)throws InvalidProfileException {
|
||||
protected List<HandlerDeclaration> getMultipleDeclarationsFromProfile(UseCaseDescriptor p)throws InvalidProfileException {
|
||||
Map<String,List<HandlerDeclaration>> map = p.getHandlersMapByID();
|
||||
if(map.containsKey(getDescriptor().getId()))
|
||||
return map.get(getDescriptor().getId());
|
||||
|
|
|
@ -3,14 +3,12 @@ package org.gcube.application.cms.plugins.reports;
|
|||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bson.Document;
|
||||
import org.gcube.application.cms.plugins.faults.InvalidPluginRequestException;
|
||||
import org.gcube.application.cms.plugins.faults.PluginExecutionException;
|
||||
import org.gcube.application.cms.plugins.requests.BaseExecutionRequest;
|
||||
import org.gcube.application.cms.serialization.Serialization;
|
||||
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
|
||||
import org.gcube.application.geoportal.common.model.document.Project;
|
||||
import org.gcube.application.geoportal.common.model.document.lifecycle.LifecycleInformation;
|
||||
|
||||
|
||||
|
@ -45,11 +43,11 @@ public class DocumentHandlingReport<T extends BaseExecutionRequest> extends Repo
|
|||
}
|
||||
}
|
||||
|
||||
public ProfiledDocument prepareResult() throws JsonProcessingException, PluginExecutionException {
|
||||
public Project prepareResult() throws JsonProcessingException, PluginExecutionException {
|
||||
log.trace("Preparing document ID {} from report ... ",theRequest.getDocument().getId());
|
||||
this.validate();
|
||||
|
||||
ProfiledDocument toReturn = theRequest.getDocument();
|
||||
Project toReturn = theRequest.getDocument();
|
||||
toReturn.setTheDocument(resultingDocument);
|
||||
toReturn.setLifecycleInformation(toSetLifecycleInformation);
|
||||
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
package org.gcube.application.cms.plugins.reports;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
import org.gcube.application.cms.plugins.faults.InvalidPluginRequestException;
|
||||
import org.gcube.application.cms.plugins.requests.EventExecutionRequest;
|
||||
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
|
||||
import org.gcube.application.geoportal.common.model.document.lifecycle.LifecycleInformation;
|
||||
|
||||
@ToString(callSuper = true)
|
||||
|
|
|
@ -7,7 +7,7 @@ import lombok.Setter;
|
|||
import org.gcube.application.cms.plugins.faults.InvalidPluginRequestException;
|
||||
import org.gcube.application.cms.plugins.faults.PluginExecutionException;
|
||||
import org.gcube.application.cms.plugins.requests.IndexDocumentRequest;
|
||||
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
|
||||
import org.gcube.application.geoportal.common.model.document.Project;
|
||||
import org.gcube.application.geoportal.common.model.document.spatial.SpatialReference;
|
||||
import org.gcube.application.geoportal.common.model.document.temporal.TemporalReference;
|
||||
|
||||
|
@ -24,8 +24,8 @@ public class IndexDocumentReport extends DocumentHandlingReport<IndexDocumentReq
|
|||
}
|
||||
|
||||
@Override
|
||||
public ProfiledDocument prepareResult() throws JsonProcessingException, PluginExecutionException {
|
||||
ProfiledDocument toReturn= super.prepareResult();
|
||||
public Project prepareResult() throws JsonProcessingException, PluginExecutionException {
|
||||
Project toReturn= super.prepareResult();
|
||||
if(toSetSpatialReference != null) toReturn.setSpatialReference(toSetSpatialReference);
|
||||
if(toSetTemporalReference != null) toReturn.setTemporalReference(toSetTemporalReference);
|
||||
return toReturn;
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
package org.gcube.application.cms.plugins.reports;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import org.gcube.application.cms.plugins.faults.InvalidPluginRequestException;
|
||||
import org.gcube.application.cms.plugins.requests.MaterializationRequest;
|
||||
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
|
||||
|
||||
|
||||
public class MaterializationReport extends DocumentHandlingReport<MaterializationRequest>{
|
||||
|
|
|
@ -4,7 +4,6 @@ import lombok.*;
|
|||
import org.gcube.application.cms.plugins.faults.InvalidPluginRequestException;
|
||||
import org.gcube.application.cms.plugins.requests.EventExecutionRequest;
|
||||
import org.gcube.application.cms.plugins.requests.StepExecutionRequest;
|
||||
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
|
@ -3,15 +3,14 @@ package org.gcube.application.cms.plugins.requests;
|
|||
import lombok.Data;
|
||||
import org.bson.Document;
|
||||
import org.gcube.application.cms.plugins.faults.InvalidPluginRequestException;
|
||||
import org.gcube.application.geoportal.common.faults.InvalidRequestException;
|
||||
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
|
||||
import org.gcube.application.geoportal.common.model.profile.Profile;
|
||||
import org.gcube.application.geoportal.common.model.document.Project;
|
||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
|
||||
|
||||
@Data
|
||||
public class BaseExecutionRequest {
|
||||
|
||||
Profile profile;
|
||||
ProfiledDocument document;
|
||||
UseCaseDescriptor useCaseDescriptor;
|
||||
Project document;
|
||||
Document callParameters;
|
||||
|
||||
public final String getMandatory(String param) throws InvalidPluginRequestException {
|
||||
|
@ -24,7 +23,7 @@ public class BaseExecutionRequest {
|
|||
}
|
||||
|
||||
public void validate() throws InvalidPluginRequestException {
|
||||
if(profile==null)throw new InvalidPluginRequestException("Profile cannot be null ");
|
||||
if(useCaseDescriptor ==null)throw new InvalidPluginRequestException("UseCaseDescriptor cannot be null ");
|
||||
if(document==null) throw new InvalidPluginRequestException("Document cannot be null");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,10 +2,6 @@ package org.gcube.application.cms.plugins.requests;
|
|||
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bson.Document;
|
||||
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
|
||||
import org.gcube.application.geoportal.common.model.profile.Profile;
|
||||
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
package org.gcube.application.cms.plugins.requests;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
import org.bson.Document;
|
||||
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
|
||||
import org.gcube.application.geoportal.common.model.profile.Profile;
|
||||
|
||||
@ToString(callSuper = true)
|
||||
public class MaterializationRequest extends BaseExecutionRequest{
|
||||
|
|
|
@ -2,11 +2,8 @@ package org.gcube.application.cms.plugins.requests;
|
|||
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
import org.bson.Document;
|
||||
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
|
||||
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.profile.Profile;
|
||||
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
|
|
|
@ -11,7 +11,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.bson.Document;
|
||||
import org.bson.types.ObjectId;
|
||||
import org.gcube.application.cms.plugins.model.ComparableVersion;
|
||||
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
|
||||
import org.gcube.application.geoportal.common.model.document.Project;
|
||||
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -85,10 +85,10 @@ public class Serialization {
|
|||
return Document.parse(mapper.writeValueAsString(obj));
|
||||
}
|
||||
|
||||
public static final Document asDocumentWithId(ProfiledDocument doc) throws JsonProcessingException {
|
||||
public static final Document asDocumentWithId(Project doc) throws JsonProcessingException {
|
||||
Document toReturn =Document.parse(mapper.writeValueAsString(doc));
|
||||
if(doc.getId()!=null)
|
||||
toReturn.put(ProfiledDocument.ID,new ObjectId(doc.getId()));
|
||||
toReturn.put(Project.ID,new ObjectId(doc.getId()));
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
package org.gcube.application.cms.tests;
|
||||
|
||||
import org.gcube.application.cms.serialization.Serialization;
|
||||
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
|
||||
import org.gcube.application.geoportal.common.model.profile.Profile;
|
||||
import org.gcube.application.geoportal.common.model.document.Project;
|
||||
import org.gcube.application.geoportal.common.utils.Files;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -12,15 +11,15 @@ import java.util.HashMap;
|
|||
|
||||
public class TestDocuments {
|
||||
public static File BASE_FOLDER =new File("../test-data/profiledDocuments");
|
||||
public static final HashMap<String, ProfiledDocument> documentMap =new HashMap<>();
|
||||
public static final HashMap<String, Project> documentMap =new HashMap<>();
|
||||
|
||||
static{
|
||||
|
||||
for(File f:BASE_FOLDER.listFiles()){
|
||||
try {
|
||||
if(!f.isDirectory()) {
|
||||
ProfiledDocument p = Serialization.read(
|
||||
Files.readFileAsString(f.getAbsolutePath(), Charset.defaultCharset()), ProfiledDocument.class);
|
||||
Project p = Serialization.read(
|
||||
Files.readFileAsString(f.getAbsolutePath(), Charset.defaultCharset()), Project.class);
|
||||
documentMap.put(f.getName(), p);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package org.gcube.application.cms.tests;
|
||||
|
||||
import org.gcube.application.cms.serialization.Serialization;
|
||||
import org.gcube.application.geoportal.common.model.profile.Profile;
|
||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
|
||||
import org.gcube.application.geoportal.common.utils.Files;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -13,14 +13,14 @@ public class TestProfiles {
|
|||
|
||||
|
||||
public static File BASE_FOLDER =new File("../test-data/profiledDocuments/profiles");
|
||||
public static final HashMap<String, Profile> profiles =new HashMap<>();
|
||||
public static final HashMap<String, UseCaseDescriptor> profiles =new HashMap<>();
|
||||
|
||||
static{
|
||||
|
||||
for(File f:BASE_FOLDER.listFiles()){
|
||||
try {
|
||||
Profile p =Serialization.read(
|
||||
Files.readFileAsString(f.getAbsolutePath(), Charset.defaultCharset()),Profile.class);
|
||||
UseCaseDescriptor p =Serialization.read(
|
||||
Files.readFileAsString(f.getAbsolutePath(), Charset.defaultCharset()), UseCaseDescriptor.class);
|
||||
profiles.put(p.getId(), p);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Unable to read "+f.getAbsolutePath(),e);
|
||||
|
|
|
@ -6,8 +6,6 @@ import java.io.IOException;
|
|||
import org.gcube.application.cms.tests.model.concessioni.TestConcessioniModel;
|
||||
import org.gcube.application.geoportal.common.model.legacy.AccessPolicy;
|
||||
import org.gcube.application.geoportal.common.model.legacy.Concessione;
|
||||
import org.gcube.application.geoportal.common.model.profile.Profile;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
|
@ -37,9 +35,9 @@ public class SerializationTest {
|
|||
// @Test
|
||||
// public void readProfile() throws JsonProcessingException, IOException {
|
||||
//
|
||||
// Profile concessione=mapper.readerFor(Profile.class).readValue(new File(TestConcessioniModel.getBaseFolder(),"ProfileConcessioni.json"));
|
||||
// UseCaseDescriptor concessione=mapper.readerFor(UseCaseDescriptor.class).readValue(new File(TestConcessioniModel.getBaseFolder(),"ProfileConcessioni.json"));
|
||||
//
|
||||
// System.out.println("Profile is "+mapper.writeValueAsString(concessione));
|
||||
// System.out.println("UseCaseDescriptor is "+mapper.writeValueAsString(concessione));
|
||||
//
|
||||
// //Assert.assertTrue(concessione .getFields().size()>0);
|
||||
//
|
||||
|
|
|
@ -110,9 +110,9 @@ public class ConcessioniLifeCycleManager implements LifecycleManager {
|
|||
//Materialize layers
|
||||
MaterializationRequest matReq = new MaterializationRequest();
|
||||
matReq.setDocument(request.getDocument());
|
||||
matReq.setProfile(request.getProfile());
|
||||
matReq.setUseCaseDescriptor(request.getUseCaseDescriptor());
|
||||
Document params = new Document();
|
||||
String workspace = request.getProfile().getId() + request.getContext().getId();
|
||||
String workspace = request.getUseCaseDescriptor().getId() + request.getContext().getId();
|
||||
params.put("workspace", Files.fixFilename(workspace));
|
||||
|
||||
|
||||
|
@ -161,7 +161,7 @@ public class ConcessioniLifeCycleManager implements LifecycleManager {
|
|||
|
||||
IndexDocumentRequest indexRequest = new IndexDocumentRequest();
|
||||
indexRequest.setDocument(request.getDocument());
|
||||
indexRequest.setProfile(request.getProfile());
|
||||
indexRequest.setUseCaseDescriptor(request.getUseCaseDescriptor());
|
||||
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()));
|
||||
|
@ -263,7 +263,7 @@ public class ConcessioniLifeCycleManager implements LifecycleManager {
|
|||
|
||||
// STATIC ROUTINES
|
||||
|
||||
private static final ProfiledDocument setDefaults(ProfiledDocument document){
|
||||
private static final Project setDefaults(Project document){
|
||||
ProfiledConcessione c=Serialization.convert(document,ProfiledConcessione.class);
|
||||
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package org.gcube.application.cms.custom.gna.concessioni.model;
|
||||
|
||||
|
||||
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
|
||||
import org.gcube.application.geoportal.common.model.document.Project;
|
||||
|
||||
|
||||
public class ProfiledConcessione extends ProfiledDocument {
|
||||
public class ProfiledConcessione extends Project {
|
||||
|
||||
public static final String NOME="nome";
|
||||
//Introduzione (descrizione del progetto)
|
||||
|
|
|
@ -5,14 +5,13 @@ import lombok.RequiredArgsConstructor;
|
|||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bson.Document;
|
||||
import org.gcube.application.geoportal.client.utils.Serialization;
|
||||
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
|
||||
import org.gcube.application.geoportal.common.model.legacy.Concessione;
|
||||
import org.gcube.application.geoportal.common.model.document.Project;
|
||||
import org.gcube.application.geoportal.common.model.rest.Configuration;
|
||||
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
|
||||
import org.gcube.application.geoportal.common.model.rest.RegisterFileSetRequest;
|
||||
import org.gcube.application.geoportal.common.model.rest.StepExecutionRequest;
|
||||
import org.gcube.application.geoportal.common.rest.InterfaceConstants;
|
||||
import org.gcube.application.geoportal.common.rest.ProfiledDocumentsI;
|
||||
import org.gcube.application.geoportal.common.rest.Projects;
|
||||
import org.gcube.common.clients.Call;
|
||||
import org.gcube.common.clients.delegates.ProxyDelegate;
|
||||
|
||||
|
@ -21,13 +20,12 @@ import javax.ws.rs.client.WebTarget;
|
|||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.io.IOException;
|
||||
import java.rmi.Remote;
|
||||
import java.rmi.RemoteException;
|
||||
import java.util.Iterator;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class DefaultProfiledDocumentsClient<T extends ProfiledDocument> implements ProfiledDocumentsI<T> {
|
||||
public class DefaultProfiledDocumentsClient<T extends Project> implements Projects<T> {
|
||||
|
||||
@NonNull
|
||||
protected final ProxyDelegate<WebTarget> delegate;
|
||||
|
@ -44,7 +42,7 @@ public class DefaultProfiledDocumentsClient<T extends ProfiledDocument> implemen
|
|||
@Override
|
||||
public T createNew(Document toCreate) throws RemoteException {
|
||||
try {
|
||||
log.debug("Creating Profiled Document (class {}, profile {}) with content {} ",
|
||||
log.debug("Creating Profiled Document (class {}, useCaseDescriptor {}) with content {} ",
|
||||
getManagedClass(),profileID, toCreate);
|
||||
Call<WebTarget, T> call = endpoint -> {
|
||||
return check(endpoint.path(profileID).request(MediaType.APPLICATION_JSON).
|
||||
|
@ -70,14 +68,14 @@ public class DefaultProfiledDocumentsClient<T extends ProfiledDocument> implemen
|
|||
@Override
|
||||
public void deleteById(String id, Boolean force) throws RemoteException {
|
||||
try {
|
||||
log.debug("Deleting ID {} profile {} force {} ", id, profileID, force);
|
||||
log.debug("Deleting ID {} useCaseDescriptor {} force {} ", id, profileID, force);
|
||||
Call<WebTarget, T> call = endpoint -> {
|
||||
return check(endpoint.path(profileID).path(id).
|
||||
queryParam(InterfaceConstants.Parameters.FORCE,force).
|
||||
request(MediaType.APPLICATION_JSON).delete(),getManagedClass());
|
||||
};
|
||||
delegate.make(call);
|
||||
log.info("Deleted ID {} profile {} force {} ", id, profileID, force);
|
||||
log.info("Deleted ID {} useCaseDescriptor {} force {} ", id, profileID, force);
|
||||
}catch(RemoteException e){
|
||||
log.error("Unexpected error ",e);
|
||||
throw e;
|
||||
|
@ -90,7 +88,7 @@ public class DefaultProfiledDocumentsClient<T extends ProfiledDocument> implemen
|
|||
@Override
|
||||
public T getById(String id) throws RemoteException {
|
||||
try {
|
||||
log.info("Loading Document ID {} (class {}, profile {})",
|
||||
log.info("Loading Document ID {} (class {}, useCaseDescriptor {})",
|
||||
id, getManagedClass(),profileID);
|
||||
Call<WebTarget, T> call = endpoint -> {
|
||||
return check(endpoint.path(profileID).path(id).
|
||||
|
@ -109,7 +107,7 @@ public class DefaultProfiledDocumentsClient<T extends ProfiledDocument> implemen
|
|||
@Override
|
||||
public Configuration getConfiguration() throws RemoteException {
|
||||
try {
|
||||
log.info("Loading Configuration for profile {}", profileID);
|
||||
log.info("Loading Configuration for useCaseDescriptor {}", profileID);
|
||||
Call<WebTarget, Configuration> call = endpoint -> {
|
||||
return check(endpoint.path(profileID).path(InterfaceConstants.Methods.CONFIGURATION_PATH).
|
||||
request(MediaType.APPLICATION_JSON).get(), Configuration.class);
|
||||
|
@ -145,7 +143,7 @@ public class DefaultProfiledDocumentsClient<T extends ProfiledDocument> implemen
|
|||
@Override
|
||||
public String queryForJSON(QueryRequest request) throws RemoteException {
|
||||
try {
|
||||
log.debug("Querying profile {} for {}",profileID,request);
|
||||
log.debug("Querying useCaseDescriptor {} for {}",profileID,request);
|
||||
Call<WebTarget, String> call = endpoint -> {
|
||||
return check(endpoint.path(profileID).path(InterfaceConstants.Methods.QUERY_PATH).
|
||||
request(MediaType.APPLICATION_JSON).get(), String.class);
|
||||
|
@ -163,14 +161,14 @@ public class DefaultProfiledDocumentsClient<T extends ProfiledDocument> implemen
|
|||
@Override
|
||||
public T performStep(String id, StepExecutionRequest request) throws RemoteException{
|
||||
try {
|
||||
log.debug("Executing step on {} (class {}, profile {}) with request {} ",
|
||||
log.debug("Executing step on {} (class {}, useCaseDescriptor {}) with request {} ",
|
||||
id, getManagedClass(),profileID, request);
|
||||
Call<WebTarget, T> call = endpoint -> {
|
||||
return check(endpoint.path(profileID).path(id).request(MediaType.APPLICATION_JSON).
|
||||
post(Entity.entity(request, MediaType.APPLICATION_JSON)),getManagedClass());
|
||||
};
|
||||
T toReturn = delegate.make(call);
|
||||
log.info("Executed STEP {} on {} [profile {}, class {}] ",request.getStepID(),
|
||||
log.info("Executed STEP {} on {} [useCaseDescriptor {}, class {}] ",request.getStepID(),
|
||||
id,profileID,getManagedClass());
|
||||
return toReturn;
|
||||
}catch(RemoteException e){
|
||||
|
@ -185,7 +183,7 @@ public class DefaultProfiledDocumentsClient<T extends ProfiledDocument> implemen
|
|||
@Override
|
||||
public T registerFileSet(String id, RegisterFileSetRequest req) throws RemoteException {
|
||||
try {
|
||||
log.debug("Registering FileSet on {} (class {}, profile {}) with request {} ",
|
||||
log.debug("Registering FileSet on {} (class {}, useCaseDescriptor {}) with request {} ",
|
||||
id, getManagedClass(),profileID, req);
|
||||
Call<WebTarget, T> call = endpoint -> {
|
||||
return check(endpoint.path(profileID).path(InterfaceConstants.Methods.REGISTER_FILES_PATH)
|
||||
|
@ -193,7 +191,7 @@ public class DefaultProfiledDocumentsClient<T extends ProfiledDocument> implemen
|
|||
post(Entity.entity(req, MediaType.APPLICATION_JSON)),getManagedClass());
|
||||
};
|
||||
T toReturn = delegate.make(call);
|
||||
log.info("Registered FileSet on {} [profile {}, class {}] with {}",
|
||||
log.info("Registered FileSet on {} [useCaseDescriptor {}, class {}] with {}",
|
||||
id,profileID,getManagedClass(),req);
|
||||
return toReturn;
|
||||
}catch(RemoteException e){
|
||||
|
@ -208,7 +206,7 @@ public class DefaultProfiledDocumentsClient<T extends ProfiledDocument> implemen
|
|||
@Override
|
||||
public T deleteFileSet(String id, String path, Boolean force) throws RemoteException {
|
||||
try {
|
||||
log.debug("Deleting Fileset for ID {} [profile {} , class {}] at {} (force {} )",
|
||||
log.debug("Deleting Fileset for ID {} [useCaseDescriptor {} , class {}] at {} (force {} )",
|
||||
id, profileID,getManagedClass(),path, force);
|
||||
Call<WebTarget, T> call = endpoint -> {
|
||||
return check(endpoint.path(profileID).path(InterfaceConstants.Methods.DELETE_FILES_PATH).
|
||||
|
@ -217,7 +215,7 @@ public class DefaultProfiledDocumentsClient<T extends ProfiledDocument> implemen
|
|||
post(Entity.entity(path, MediaType.APPLICATION_JSON)),getManagedClass());
|
||||
};
|
||||
T toReturn=delegate.make(call);
|
||||
log.info("Deleted ID {} profile {} force {} ", id, profileID, force);
|
||||
log.info("Deleted ID {} useCaseDescriptor {} force {} ", id, profileID, force);
|
||||
return toReturn;
|
||||
}catch(RemoteException e){
|
||||
log.error("Unexpected error ",e);
|
||||
|
@ -231,7 +229,7 @@ public class DefaultProfiledDocumentsClient<T extends ProfiledDocument> implemen
|
|||
@Override
|
||||
public T updateDocument(String id, Document updatedDocument) throws RemoteException {
|
||||
try {
|
||||
log.debug("Updateing {} [profile {} , class {}] with ",
|
||||
log.debug("Updateing {} [useCaseDescriptor {} , class {}] with ",
|
||||
id, profileID,getManagedClass(),updatedDocument);
|
||||
Call<WebTarget, T> call = endpoint -> {
|
||||
return check(endpoint.path(profileID).path(id).
|
||||
|
@ -239,7 +237,7 @@ public class DefaultProfiledDocumentsClient<T extends ProfiledDocument> implemen
|
|||
put(Entity.entity(updatedDocument, MediaType.APPLICATION_JSON)),getManagedClass());
|
||||
};
|
||||
T toReturn=delegate.make(call);
|
||||
log.info("Updated ID {} profile {} ", id, profileID);
|
||||
log.info("Updated ID {} useCaseDescriptor {} ", id, profileID);
|
||||
return toReturn;
|
||||
}catch(RemoteException e){
|
||||
log.error("Unexpected error ",e);
|
||||
|
|
|
@ -6,11 +6,11 @@ import org.gcube.application.geoportal.client.legacy.ConcessioniManagerI;
|
|||
import org.gcube.application.geoportal.client.legacy.ConcessioniPlugin;
|
||||
import org.gcube.application.geoportal.client.legacy.MongoConcessioniPlugin;
|
||||
import org.gcube.application.geoportal.client.legacy.StatefulMongoConcessioniPlugin;
|
||||
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
|
||||
import org.gcube.application.geoportal.common.model.document.Project;
|
||||
import org.gcube.application.geoportal.common.rest.ConcessioniI;
|
||||
import org.gcube.application.geoportal.common.rest.InterfaceConstants;
|
||||
import org.gcube.application.geoportal.common.rest.MongoConcessioni;
|
||||
import org.gcube.application.geoportal.common.rest.ProfiledDocumentsI;
|
||||
import org.gcube.application.geoportal.common.rest.Projects;
|
||||
import org.gcube.common.clients.Plugin;
|
||||
import org.gcube.common.clients.ProxyBuilder;
|
||||
import org.gcube.common.clients.ProxyBuilderImpl;
|
||||
|
@ -24,25 +24,25 @@ public abstract class GeoportalAbstractPlugin <S, P> implements Plugin<S, P>{
|
|||
|
||||
|
||||
|
||||
public static ProxyBuilder<ProfiledDocumentsI<ProfiledDocument>> profiledDocuments(String profileID) {
|
||||
public static ProxyBuilder<Projects<Project>> profiledDocuments(String profileID) {
|
||||
ProjectsInterfacePlugin plugin=new ProjectsInterfacePlugin(profileID);
|
||||
return new ProxyBuilderImpl<WebTarget, ProfiledDocumentsI<ProfiledDocument>>(plugin);
|
||||
return new ProxyBuilderImpl<WebTarget, Projects<Project>>(plugin);
|
||||
}
|
||||
|
||||
public static <C extends ProfiledDocumentsI<ProfiledDocument>> ProxyBuilder<C> profiledDocuments(String profileID, Class<C> customClient) {
|
||||
public static <C extends Projects<Project>> ProxyBuilder<C> profiledDocuments(String profileID, Class<C> customClient) {
|
||||
ProjectsInterfacePlugin plugin=new ProjectsInterfacePlugin(profileID);
|
||||
plugin.setCustomClientImplementation(customClient);
|
||||
return new ProxyBuilderImpl<WebTarget, C>(plugin);
|
||||
}
|
||||
|
||||
public static <P extends ProfiledDocument> ProxyBuilder<ProfiledDocumentsI<P>>
|
||||
public static <P extends Project> ProxyBuilder<Projects<P>>
|
||||
profiledModel(String profileID, Class<P> customModel ) {
|
||||
ProjectsInterfacePlugin plugin=new ProjectsInterfacePlugin(profileID);
|
||||
plugin.setProfiledModel(customModel);
|
||||
return new ProxyBuilderImpl<WebTarget, ProfiledDocumentsI<P>>(plugin);
|
||||
return new ProxyBuilderImpl<WebTarget, Projects<P>>(plugin);
|
||||
}
|
||||
|
||||
public static <P extends ProfiledDocument,C extends ProfiledDocumentsI<P>> ProxyBuilder<C>
|
||||
public static <P extends Project,C extends Projects<P>> ProxyBuilder<C>
|
||||
profiledModel(String profileID, Class<P> customModel ,Class<C> customClient) {
|
||||
ProjectsInterfacePlugin plugin=new ProjectsInterfacePlugin(profileID);
|
||||
plugin.setProfiledModel(customModel);
|
||||
|
|
|
@ -10,9 +10,9 @@ import lombok.RequiredArgsConstructor;
|
|||
import lombok.Setter;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
|
||||
import org.gcube.application.geoportal.common.model.document.Project;
|
||||
import org.gcube.application.geoportal.common.rest.InterfaceConstants;
|
||||
import org.gcube.application.geoportal.common.rest.ProfiledDocumentsI;
|
||||
import org.gcube.application.geoportal.common.rest.Projects;
|
||||
import org.gcube.common.calls.jaxrs.GcubeService;
|
||||
import org.gcube.common.calls.jaxrs.TargetFactory;
|
||||
import org.gcube.common.clients.config.ProxyConfig;
|
||||
|
@ -21,7 +21,7 @@ import org.w3c.dom.Node;
|
|||
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class ProjectsInterfacePlugin<C extends DefaultProfiledDocumentsClient,P extends ProfiledDocument> extends GeoportalAbstractPlugin<WebTarget, ProfiledDocumentsI<P>>{
|
||||
public class ProjectsInterfacePlugin<C extends DefaultProfiledDocumentsClient,P extends Project> extends GeoportalAbstractPlugin<WebTarget, Projects<P>>{
|
||||
|
||||
@NonNull
|
||||
private String profileID;
|
||||
|
@ -40,7 +40,7 @@ public class ProjectsInterfacePlugin<C extends DefaultProfiledDocumentsClient,P
|
|||
|
||||
@SneakyThrows //no such constructor
|
||||
@Override
|
||||
public ProfiledDocumentsI<P> newProxy(ProxyDelegate<WebTarget> delegate) {
|
||||
public Projects<P> newProxy(ProxyDelegate<WebTarget> delegate) {
|
||||
return customClientImplementation.getConstructor(ProxyDelegate.class,String.class,Class.class).
|
||||
newInstance(delegate,profileID,profiledModel);
|
||||
}
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
package org.gcube.application.geoportal.clients;
|
||||
|
||||
import lombok.Data;
|
||||
import org.apache.commons.beanutils.MutableDynaClass;
|
||||
import org.bson.Document;
|
||||
import org.gcube.application.cms.serialization.Serialization;
|
||||
import org.gcube.application.geoportal.common.model.JSONPathWrapper;
|
||||
import org.gcube.application.geoportal.common.model.profile.HandlerDeclaration;
|
||||
import org.gcube.application.geoportal.common.model.profile.Profile;
|
||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.HandlerDeclaration;
|
||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
|
||||
|
||||
public class ProfiledConcessioniTest {
|
||||
|
||||
|
@ -18,7 +16,7 @@ public class ProfiledConcessioniTest {
|
|||
|
||||
public void test(){
|
||||
|
||||
Profile p=null;
|
||||
UseCaseDescriptor p=null;
|
||||
|
||||
HandlerDeclaration h = p.getHandlersMapByID().get("MyID").get(0);
|
||||
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
package org.gcube.application.geoportal.clients;
|
||||
|
||||
import com.fasterxml.jackson.databind.ser.std.StdKeySerializers;
|
||||
import org.gcube.application.geoportal.client.DefaultProfiledDocumentsClient;
|
||||
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
|
||||
import org.gcube.application.geoportal.common.model.document.Project;
|
||||
import org.gcube.application.geoportal.common.model.rest.Configuration;
|
||||
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
|
||||
import org.gcube.application.geoportal.common.rest.ProfiledDocumentsI;
|
||||
import org.gcube.application.geoportal.common.rest.Projects;
|
||||
import org.gcube.application.geoportal.common.utils.tests.GCubeTest;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -16,19 +15,19 @@ import static junit.framework.TestCase.assertTrue;
|
|||
import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.*;
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
|
||||
public class ProfiledDocumentsTest<M extends ProfiledDocument,C extends ProfiledDocumentsI<M>> extends BasicVreTests{
|
||||
public class ProfiledDocumentsTest<M extends Project,C extends Projects<M>> extends BasicVreTests{
|
||||
|
||||
protected String getProfileID(){return "profiledConcessioni";}
|
||||
|
||||
protected C getClient(){
|
||||
return (C) profiledModel(getProfileID(),ProfiledDocument.class,DefaultProfiledDocumentsClient.class).build();
|
||||
return (C) profiledModel(getProfileID(), Project.class,DefaultProfiledDocumentsClient.class).build();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void getConfiguration() throws Exception {
|
||||
assumeTrue(GCubeTest.isTestInfrastructureEnabled());
|
||||
ProfiledDocumentsI<M> client = (ProfiledDocumentsI<M>) getClient();
|
||||
Projects<M> client = (Projects<M>) getClient();
|
||||
Configuration config=client.getConfiguration();
|
||||
System.out.println("Configuration is "+ config);
|
||||
}
|
||||
|
@ -37,7 +36,7 @@ public class ProfiledDocumentsTest<M extends ProfiledDocument,C extends Profiled
|
|||
@Test
|
||||
public void list() throws Exception {
|
||||
assumeTrue(GCubeTest.isTestInfrastructureEnabled());
|
||||
ProfiledDocumentsI<M> client = (ProfiledDocumentsI<M>) getClient();
|
||||
Projects<M> client = (Projects<M>) getClient();
|
||||
AtomicLong counter=new AtomicLong(0);
|
||||
client.query(new QueryRequest()).forEachRemaining( M -> counter.incrementAndGet());
|
||||
System.out.println("Found "+counter.get()+" elements");
|
||||
|
@ -48,7 +47,7 @@ public class ProfiledDocumentsTest<M extends ProfiledDocument,C extends Profiled
|
|||
@Test
|
||||
public void scanStatusByID() throws Exception {
|
||||
assumeTrue(GCubeTest.isTestInfrastructureEnabled());
|
||||
ProfiledDocumentsI<M> client = (ProfiledDocumentsI<M>) getClient();
|
||||
Projects<M> client = (Projects<M>) getClient();
|
||||
AtomicLong counter=new AtomicLong(0);
|
||||
client.query(new QueryRequest()).forEachRemaining( m -> {
|
||||
System.out.print(counter.incrementAndGet()+ ", ID : "+m.getId());
|
||||
|
|
|
@ -1,15 +1,11 @@
|
|||
package org.gcube.application.geoportal.clients.serialization;
|
||||
|
||||
import ch.qos.logback.core.net.SyslogOutputStream;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import junit.framework.Assert;
|
||||
import org.gcube.application.cms.tests.TestProfiles;
|
||||
import org.gcube.application.geoportal.client.utils.Serialization;
|
||||
import org.gcube.application.geoportal.common.model.JSONPathWrapper;
|
||||
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
|
||||
import org.gcube.application.geoportal.common.model.profile.Field;
|
||||
import org.gcube.application.geoportal.common.model.profile.HandlerDeclaration;
|
||||
import org.gcube.application.geoportal.common.model.profile.Profile;
|
||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.Field;
|
||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.HandlerDeclaration;
|
||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
|
||||
import org.gcube.application.geoportal.common.utils.Files;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -22,10 +18,10 @@ import java.util.Map;
|
|||
import static junit.framework.TestCase.assertEquals;
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
|
||||
public class Profiles {
|
||||
public class UseCaseDescriptors {
|
||||
|
||||
private static Profile readProfile(String file) throws IOException {
|
||||
return Serialization.read(getJSON(file), Profile.class);
|
||||
private static UseCaseDescriptor readProfile(String file) throws IOException {
|
||||
return Serialization.read(getJSON(file), UseCaseDescriptor.class);
|
||||
}
|
||||
|
||||
private static String getJSON(String file) throws IOException {
|
||||
|
@ -35,17 +31,17 @@ public class Profiles {
|
|||
|
||||
@Test
|
||||
public void read () throws IOException {
|
||||
for (Map.Entry<String, Profile> entry : TestProfiles.profiles.entrySet()) {
|
||||
for (Map.Entry<String, UseCaseDescriptor> entry : TestProfiles.profiles.entrySet()) {
|
||||
String s = entry.getKey();
|
||||
Profile profile = entry.getValue();
|
||||
UseCaseDescriptor useCaseDescriptor = entry.getValue();
|
||||
System.out.println("Checking " + s);
|
||||
|
||||
validate(profile);
|
||||
System.out.println(profile);
|
||||
Profile converted = Serialization.convert(profile, Profile.class);
|
||||
assertEquals(profile, converted);
|
||||
JSONPathWrapper wrapper = new JSONPathWrapper(Serialization.asDocument(profile).toJson());
|
||||
List<List> foundObjects = wrapper.getByPath("$." + Profile.HANDLERS, List.class);
|
||||
validate(useCaseDescriptor);
|
||||
System.out.println(useCaseDescriptor);
|
||||
UseCaseDescriptor converted = Serialization.convert(useCaseDescriptor, UseCaseDescriptor.class);
|
||||
assertEquals(useCaseDescriptor, converted);
|
||||
JSONPathWrapper wrapper = new JSONPathWrapper(Serialization.asDocument(useCaseDescriptor).toJson());
|
||||
List<List> foundObjects = wrapper.getByPath("$." + UseCaseDescriptor.HANDLERS, List.class);
|
||||
|
||||
foundObjects.get(0).forEach(o -> {
|
||||
HandlerDeclaration h = Serialization.convert(o, HandlerDeclaration.class);
|
||||
|
@ -57,12 +53,12 @@ public class Profiles {
|
|||
}
|
||||
|
||||
|
||||
private void validate(Profile profile){
|
||||
assertTrue(profile.getId()!=null);
|
||||
if(profile.getHandlers()!=null)
|
||||
profile.getHandlers().forEach(handlerDeclaration -> validate(handlerDeclaration));
|
||||
if(profile.getSchema()!=null)
|
||||
validate(profile.getSchema());
|
||||
private void validate(UseCaseDescriptor useCaseDescriptor){
|
||||
assertTrue(useCaseDescriptor.getId()!=null);
|
||||
if(useCaseDescriptor.getHandlers()!=null)
|
||||
useCaseDescriptor.getHandlers().forEach(handlerDeclaration -> validate(handlerDeclaration));
|
||||
if(useCaseDescriptor.getSchema()!=null)
|
||||
validate(useCaseDescriptor.getSchema());
|
||||
|
||||
}
|
||||
private void validate(HandlerDeclaration handler){
|
|
@ -15,7 +15,7 @@ import org.gcube.application.geoportal.common.model.document.temporal.TemporalRe
|
|||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class ProfiledDocument {
|
||||
public class Project {
|
||||
|
||||
public static final String ID="_id";
|
||||
public static final String VERSION="_version";
|
||||
|
@ -39,7 +39,7 @@ public class ProfiledDocument {
|
|||
@JsonProperty(INFO)
|
||||
private PublicationInfo info;
|
||||
|
||||
// Profile reference
|
||||
// UseCaseDescriptor reference
|
||||
@JsonProperty(PROFILE_ID)
|
||||
private String profileID;
|
||||
@JsonProperty(PROFILE_VERSION)
|
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.application.geoportal.common.model.profile;
|
||||
package org.gcube.application.geoportal.common.model.useCaseDescriptor;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.*;
|
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.application.geoportal.common.model.profile;
|
||||
package org.gcube.application.geoportal.common.model.useCaseDescriptor;
|
||||
|
||||
import lombok.*;
|
||||
import org.bson.Document;
|
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.application.geoportal.common.model.profile;
|
||||
package org.gcube.application.geoportal.common.model.useCaseDescriptor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.application.geoportal.common.model.profile;
|
||||
package org.gcube.application.geoportal.common.model.useCaseDescriptor;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.application.geoportal.common.model.profile;
|
||||
package org.gcube.application.geoportal.common.model.useCaseDescriptor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
@ -19,7 +19,7 @@ import org.gcube.application.geoportal.common.model.document.accounting.Accounti
|
|||
@NoArgsConstructor
|
||||
@XmlRootElement
|
||||
@Slf4j
|
||||
public class Profile{
|
||||
public class UseCaseDescriptor {
|
||||
|
||||
public static final String ID="_id";
|
||||
public static final String VERSION="_version";
|
||||
|
@ -65,7 +65,7 @@ public class Profile{
|
|||
if(!toReturn.containsKey(h.getType()))
|
||||
toReturn.put(h.getType(),new ArrayList<>());
|
||||
toReturn.get(h.getType()).add(h);
|
||||
}catch (Throwable t){log.error("Invalid profile : unable to get Handler Map by Type with {} in profile [ID {}]",h,this.getId(),t);}
|
||||
}catch (Throwable t){log.error("Invalid useCaseDescriptor : unable to get Handler Map by Type with {} in useCaseDescriptor [ID {}]",h,this.getId(),t);}
|
||||
});
|
||||
return toReturn;
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ public class Profile{
|
|||
toReturn.put(h.getId(), new ArrayList<>());
|
||||
toReturn.get(h.getId()).add(h);
|
||||
}catch (Throwable t){
|
||||
log.error("Invalid profile : unable to get Handler Map by ID with {} in profile [ID {}]",h,this.getId(),t);}
|
||||
log.error("Invalid useCaseDescriptor : unable to get Handler Map by ID with {} in useCaseDescriptor [ID {}]",h,this.getId(),t);}
|
||||
});
|
||||
return toReturn;
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
package org.gcube.application.geoportal.common.rest;
|
||||
|
||||
import org.bson.Document;
|
||||
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
|
||||
import org.gcube.application.geoportal.common.model.document.Project;
|
||||
import org.gcube.application.geoportal.common.model.rest.Configuration;
|
||||
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
|
||||
import org.gcube.application.geoportal.common.model.rest.RegisterFileSetRequest;
|
||||
|
@ -10,7 +10,7 @@ import org.gcube.application.geoportal.common.model.rest.StepExecutionRequest;
|
|||
import java.rmi.RemoteException;
|
||||
import java.util.Iterator;
|
||||
|
||||
public interface ProfiledDocumentsI<P extends ProfiledDocument> {
|
||||
public interface Projects<P extends Project> {
|
||||
|
||||
public Class<P> getManagedClass();
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package org.gcube.application.geoportal.common.rest;
|
||||
|
||||
import org.bson.Document;
|
||||
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
|
||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
|
||||
|
||||
public interface UseCaseDescriptors {
|
||||
|
||||
public UseCaseDescriptor create(Document toCreate)throws RemoteException;
|
||||
|
||||
public Iterable<UseCaseDescriptor> query(QueryRequest request)throws RemoteException;
|
||||
|
||||
public void deleteById(String id,boolean force)throws RemoteException;
|
||||
|
||||
public UseCaseDescriptor update(String ID, Document toSet)throws RemoteException;
|
||||
|
||||
public UseCaseDescriptor getById(String id)throws RemoteException;
|
||||
}
|
|
@ -42,11 +42,11 @@ public class ISUtils {
|
|||
public static List<AccessPoint> performGetAP(String category,String platform,String flagName,String flagValue) {
|
||||
SimpleQuery query = queryFor(ServiceEndpoint.class);
|
||||
|
||||
query.addCondition("$resource/Profile/Category/text() eq '"+category+"'")
|
||||
.addCondition("$resource/Profile/Platform/Name/text() eq '"+platform+"'")
|
||||
.addCondition("$resource/Profile/AccessPoint//Property[Name/text() eq '"+
|
||||
query.addCondition("$resource/UseCaseDescriptor/Category/text() eq '"+category+"'")
|
||||
.addCondition("$resource/UseCaseDescriptor/Platform/Name/text() eq '"+platform+"'")
|
||||
.addCondition("$resource/UseCaseDescriptor/AccessPoint//Property[Name/text() eq '"+
|
||||
flagName+"'][Value/text() eq '"+flagValue+"']")
|
||||
.setResult("$resource/Profile/AccessPoint");
|
||||
.setResult("$resource/UseCaseDescriptor/AccessPoint");
|
||||
|
||||
DiscoveryClient<AccessPoint> client = clientFor(AccessPoint.class);
|
||||
return client.submit(query);
|
||||
|
|
|
@ -1,20 +1,10 @@
|
|||
package org.gcube.application.geoportal.common.model;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.jayway.jsonpath.Configuration;
|
||||
import com.jayway.jsonpath.JsonPath;
|
||||
import com.jayway.jsonpath.Option;
|
||||
import com.jayway.jsonpath.spi.json.JacksonJsonProvider;
|
||||
import com.jayway.jsonpath.spi.json.JsonProvider;
|
||||
import com.jayway.jsonpath.spi.mapper.JacksonMappingProvider;
|
||||
import com.jayway.jsonpath.spi.mapper.MappingProvider;
|
||||
import org.bson.Document;
|
||||
import org.gcube.application.geoportal.common.JSONSerializationProvider;
|
||||
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
|
||||
import org.gcube.application.geoportal.common.model.document.filesets.Materialization;
|
||||
import org.gcube.application.geoportal.common.model.document.Project;
|
||||
import org.gcube.application.geoportal.common.model.document.filesets.RegisteredFileSet;
|
||||
import org.gcube.application.geoportal.common.model.document.lifecycle.TriggeredEvents;
|
||||
import org.gcube.application.geoportal.common.model.profile.HandlerDeclaration;
|
||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.HandlerDeclaration;
|
||||
import org.gcube.application.geoportal.common.utils.Files;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -38,7 +28,7 @@ public class JSONPathTests {
|
|||
return new JSONPathWrapper(Files.readFileAsString(new File(baseFolder, filename).getAbsolutePath(), Charset.defaultCharset()));
|
||||
}
|
||||
|
||||
private ProfiledDocument getDocument(String filename){
|
||||
private Project getDocument(String filename){
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
package org.gcube.application.geoportal.service.engine.mongo;
|
||||
|
||||
import org.bson.Document;
|
||||
import org.gcube.application.cms.caches.Engine;
|
||||
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
|
||||
import org.gcube.application.geoportal.common.model.profile.Profile;
|
||||
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
public interface ProfileManager {
|
||||
|
||||
public Profile create(Document toCreate);
|
||||
|
||||
public Iterable<Profile> query(QueryRequest request);
|
||||
|
||||
public void deleteById(String id,boolean force);
|
||||
|
||||
public Profile update(String ID, Document toSet);
|
||||
|
||||
public Profile getById(String id);
|
||||
}
|
|
@ -26,9 +26,9 @@ import org.gcube.application.geoportal.common.model.document.filesets.Registered
|
|||
import org.gcube.application.geoportal.common.model.document.filesets.RegisteredFileSet;
|
||||
import org.gcube.application.geoportal.common.model.document.lifecycle.LifecycleInformation;
|
||||
import org.gcube.application.geoportal.common.model.legacy.Concessione;
|
||||
import org.gcube.application.geoportal.common.model.profile.Field;
|
||||
import org.gcube.application.geoportal.common.model.profile.HandlerDeclaration;
|
||||
import org.gcube.application.geoportal.common.model.profile.Profile;
|
||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.Field;
|
||||
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.rest.Configuration;
|
||||
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
|
||||
import org.gcube.application.geoportal.common.model.rest.RegisterFileSetRequest;
|
||||
|
@ -59,33 +59,33 @@ import java.util.function.Consumer;
|
|||
import static org.gcube.application.cms.serialization.Serialization.*;
|
||||
|
||||
@Slf4j
|
||||
public class ProfiledMongoManager extends MongoManager implements MongoManagerI<ProfiledDocument>{
|
||||
public class ProfiledMongoManager extends MongoManager implements MongoManagerI<Project>{
|
||||
|
||||
@Getter
|
||||
Profile profile;
|
||||
UseCaseDescriptor useCaseDescriptor;
|
||||
MongoDatabase db=null;
|
||||
|
||||
|
||||
|
||||
|
||||
public ProfiledMongoManager(String profileId) throws ConfigurationException {
|
||||
// Check Profile ID
|
||||
log.info("Loading profile ID {} ",profileId);
|
||||
if(profileId==null) throw new InvalidParameterException("Profile ID cannot be null");
|
||||
Map<String,Profile> profiles=ImplementationProvider.get().getEngineByClass(ProfileMapCache.ProfileMap.class);
|
||||
// Check UseCaseDescriptor ID
|
||||
log.info("Loading useCaseDescriptor ID {} ",profileId);
|
||||
if(profileId==null) throw new InvalidParameterException("UseCaseDescriptor ID cannot be null");
|
||||
Map<String, UseCaseDescriptor> profiles=ImplementationProvider.get().getEngineByClass(ProfileMapCache.ProfileMap.class);
|
||||
if(!profiles.containsKey(profileId)) {
|
||||
log.debug("Asked profile {} not found. Available ones are {} ",profileId,profiles.keySet());
|
||||
throw new WebApplicationException("Profile " + profileId + " not registered", Response.Status.NOT_FOUND);
|
||||
log.debug("Asked useCaseDescriptor {} not found. Available ones are {} ",profileId,profiles.keySet());
|
||||
throw new WebApplicationException("UseCaseDescriptor " + profileId + " not registered", Response.Status.NOT_FOUND);
|
||||
}
|
||||
profile=profiles.get(profileId);
|
||||
log.debug("Loaded Profile {} ",profile);
|
||||
useCaseDescriptor =profiles.get(profileId);
|
||||
log.debug("Loaded UseCaseDescriptor {} ", useCaseDescriptor);
|
||||
|
||||
|
||||
// Connect to DB
|
||||
String toUseDB=super.client.getConnection().getDatabase();
|
||||
log.info("Connecting to DB {} ",toUseDB);
|
||||
|
||||
// TODO MAP OF DATABASES?
|
||||
|
||||
db=client.getTheClient().getDatabase(toUseDB);
|
||||
}
|
||||
|
||||
|
@ -95,10 +95,10 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
|
|||
private LifecycleManager getLCManager() {
|
||||
try{
|
||||
LifecycleManager toReturn=null;
|
||||
//Getting Lifecycle Manager declaration from Profile
|
||||
List<HandlerDeclaration> handlerDeclarations= profile.getHandlersMapByType().get(PluginDescriptor.BaseTypes.LIFECYCLE_MANAGER);
|
||||
if(handlerDeclarations==null || handlerDeclarations.isEmpty()) throw new ConfigurationException("No Lifecycle Handler defined for profile ID "+profile.getId());
|
||||
if(handlerDeclarations.size()>1) throw new ConfigurationException("Too many Lifecycle Handlers defined ("+handlerDeclarations+") in profile ID "+profile.getId());
|
||||
//Getting Lifecycle Manager declaration from UseCaseDescriptor
|
||||
List<HandlerDeclaration> handlerDeclarations= useCaseDescriptor.getHandlersMapByType().get(PluginDescriptor.BaseTypes.LIFECYCLE_MANAGER);
|
||||
if(handlerDeclarations==null || handlerDeclarations.isEmpty()) throw new ConfigurationException("No Lifecycle Handler defined for useCaseDescriptor ID "+ useCaseDescriptor.getId());
|
||||
if(handlerDeclarations.size()>1) throw new ConfigurationException("Too many Lifecycle Handlers defined ("+handlerDeclarations+") in useCaseDescriptor ID "+ useCaseDescriptor.getId());
|
||||
|
||||
HandlerDeclaration lcHandlerDeclaration=handlerDeclarations.get(0);
|
||||
|
||||
|
@ -116,9 +116,9 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
|
|||
}
|
||||
|
||||
private String getCollectionName(){
|
||||
// TODO Profile can directly specify, use ID only as default
|
||||
// TODO UseCaseDescriptor can directly specify, use ID only as default
|
||||
|
||||
return profile.getId();
|
||||
return useCaseDescriptor.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -127,17 +127,17 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
|
|||
}
|
||||
|
||||
@Override
|
||||
public ProfiledDocument registerNew(Document toRegisterDoc) throws IOException, StepException, EventException {
|
||||
log.info("Registering new document in {} ",profile.getId());
|
||||
public Project registerNew(Document toRegisterDoc) throws IOException, StepException, EventException {
|
||||
log.info("Registering new document in {} ", useCaseDescriptor.getId());
|
||||
log.debug("Going to register {}",toRegisterDoc.toJson());
|
||||
|
||||
ProfiledDocument toRegister = new ProfiledDocument();
|
||||
Project toRegister = new Project();
|
||||
toRegister.setTheDocument(toRegisterDoc);
|
||||
|
||||
PublicationInfo pubInfo=new PublicationInfo();
|
||||
pubInfo.setCreationInfo(UserUtils.getCurrent().asInfo());
|
||||
|
||||
// TODO Set Access From Profile
|
||||
// TODO Set Access From UseCaseDescriptor
|
||||
Access access=new Access();
|
||||
access.setLicense("");
|
||||
access.setPolicy(AccessPolicy.OPEN);
|
||||
|
@ -145,8 +145,8 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
|
|||
|
||||
toRegister.setInfo(pubInfo);
|
||||
|
||||
toRegister.setProfileID(profile.getId());
|
||||
toRegister.setProfileVersion(profile.getVersion());
|
||||
toRegister.setProfileID(useCaseDescriptor.getId());
|
||||
toRegister.setProfileVersion(useCaseDescriptor.getVersion());
|
||||
toRegister.setVersion(new Semver("1.0.0"));
|
||||
|
||||
|
||||
|
@ -169,20 +169,20 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
|
|||
}
|
||||
|
||||
@Override
|
||||
public ProfiledDocument update(String id, Document toSet) throws IOException, EventException {
|
||||
public Project update(String id, Document toSet) throws IOException, EventException {
|
||||
log.trace("Replacing {} ",toSet);
|
||||
ProfiledDocument toUpdate=getByID(id);
|
||||
Project toUpdate=getByID(id);
|
||||
toUpdate.setTheDocument(toSet);
|
||||
toUpdate.getLifecycleInformation().cleanState();
|
||||
|
||||
toUpdate=onUpdate(toUpdate);
|
||||
ProfiledDocument toReturn =convert(replace(asDocumentWithId(toUpdate),new ObjectId(id),getCollectionName()),ProfiledDocument.class);
|
||||
log.debug("Updated ProfiledDocument is {}",toReturn);
|
||||
Project toReturn =convert(replace(asDocumentWithId(toUpdate),new ObjectId(id),getCollectionName()), Project.class);
|
||||
log.debug("Updated Project is {}",toReturn);
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
|
||||
private ProfiledDocument onUpdate(ProfiledDocument toUpdate) throws EventException {
|
||||
private Project onUpdate(Project toUpdate) throws EventException {
|
||||
UserUtils.AuthenticatedUser u = UserUtils.getCurrent();
|
||||
toUpdate.getInfo().setLastEditInfo(u.asInfo());
|
||||
toUpdate.setVersion(toUpdate.getVersion().withIncPatch());
|
||||
|
@ -194,7 +194,7 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
|
|||
public void delete(String id,boolean force) throws DeletionException {
|
||||
log.debug("Deleting by ID {}, force {}",id,force);
|
||||
try{
|
||||
ProfiledDocument doc =getByID(id);
|
||||
Project doc =getByID(id);
|
||||
|
||||
// TODO INVOKE LIFECYCLE
|
||||
|
||||
|
@ -220,10 +220,10 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
|
|||
}
|
||||
|
||||
@Override
|
||||
public ProfiledDocument getByID(String id) throws WebApplicationException{
|
||||
public Project getByID(String id) throws WebApplicationException{
|
||||
Document doc=super.getById(asId(id),getCollectionName());
|
||||
if(doc==null) throw new WebApplicationException("No document with ID "+id);
|
||||
return convert(doc,ProfiledDocument.class);
|
||||
return convert(doc, Project.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -239,7 +239,7 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
|
|||
}
|
||||
|
||||
@Override
|
||||
public Iterable<ProfiledDocument> filter(QueryRequest queryRequest) {
|
||||
public Iterable<Project> filter(QueryRequest queryRequest) {
|
||||
log.info("Searching concessione for filter {} ",queryRequest);
|
||||
LinkedBlockingQueue queue=new LinkedBlockingQueue<Concessione>();
|
||||
query(queryRequest,getCollectionName()).forEach(
|
||||
|
@ -252,13 +252,13 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
|
|||
|
||||
|
||||
@Override
|
||||
public ProfiledDocument performStep(String id, String step, Document options) throws StepException, JsonProcessingException {
|
||||
ProfiledDocument document = getByID(id);
|
||||
public Project performStep(String id, String step, Document options) throws StepException, JsonProcessingException {
|
||||
Project document = getByID(id);
|
||||
try{
|
||||
document.getLifecycleInformation().cleanState();
|
||||
document = step(document, step, options);
|
||||
} catch(Throwable t){
|
||||
log.error("[Profile {} ] ERROR Invoking Step {} on document {}" ,profile.getId(),step,id,t);
|
||||
log.error("[UseCaseDescriptor {} ] ERROR Invoking Step {} on document {}" , useCaseDescriptor.getId(),step,id,t);
|
||||
LifecycleInformation info = new LifecycleInformation();
|
||||
info.setPhase(document.getLifecycleInformation().getPhase());
|
||||
info.setLastOperationStatus(LifecycleInformation.Status.ERROR);
|
||||
|
@ -266,11 +266,11 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
|
|||
info.setLastInvokedStep(step);
|
||||
document.setLifecycleInformation(info);
|
||||
}finally{
|
||||
log.info("Storing {} [Profile {}] After Step {}, Status : {} " ,id,profile.getId(),
|
||||
log.info("Storing {} [UseCaseDescriptor {}] After Step {}, Status : {} " ,id, useCaseDescriptor.getId(),
|
||||
step,document.getLifecycleInformation().getLastOperationStatus());
|
||||
log.debug("LifecycleInformation is {} ",document.getLifecycleInformation());
|
||||
if(log.isTraceEnabled())log.trace("Document is {} ",Serialization.write(document));
|
||||
return convert(replace(asDocumentWithId(document),new ObjectId(id),getCollectionName()),ProfiledDocument.class);
|
||||
return convert(replace(asDocumentWithId(document),new ObjectId(id),getCollectionName()), Project.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -289,12 +289,12 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
|
|||
*
|
||||
*/
|
||||
@Override
|
||||
public ProfiledDocument registerFileSet(String id,RegisterFileSetRequest request) throws ConfigurationException, StorageHubException, StorageException, StepException, JsonProcessingException, DeletionException, EventException {
|
||||
log.info("Registering Fileset for {} [profile ID {}], Request is {} ",id,profile.getId(),request);
|
||||
public Project registerFileSet(String id, RegisterFileSetRequest request) throws ConfigurationException, StorageHubException, StorageException, StepException, JsonProcessingException, DeletionException, EventException {
|
||||
log.info("Registering Fileset for {} [useCaseDescriptor ID {}], Request is {} ",id, useCaseDescriptor.getId(),request);
|
||||
|
||||
List<TempFile> files=request.getStreams();
|
||||
Document attributes =request.getAttributes();
|
||||
ProfiledDocument doc=getByID(id);
|
||||
Project doc=getByID(id);
|
||||
doc.getLifecycleInformation().cleanState();
|
||||
doc.getLifecycleInformation().setLastOperationStatus(LifecycleInformation.Status.OK);
|
||||
|
||||
|
@ -302,8 +302,8 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
|
|||
StorageUtils storage=ImplementationProvider.get().getEngineByClass(StorageUtils.class);
|
||||
|
||||
|
||||
log.debug("Checking field {} definition in {}",request.getFieldDefinitionPath(),profile.getId());
|
||||
Field fieldDefinition=getFieldDefinition(profile,request.getFieldDefinitionPath());
|
||||
log.debug("Checking field {} definition in {}",request.getFieldDefinitionPath(), useCaseDescriptor.getId());
|
||||
Field fieldDefinition=getFieldDefinition(useCaseDescriptor,request.getFieldDefinitionPath());
|
||||
|
||||
JSONPathWrapper docWrapper=new JSONPathWrapper(doc.getTheDocument().toJson());
|
||||
|
||||
|
@ -331,8 +331,8 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
|
|||
if(!(toDelete == null)&&!(toDelete.isEmpty()))
|
||||
deleteFileSetRoutine(toDelete,false,ws);
|
||||
|
||||
RegisteredFileSet fs = prepareRegisteredFileSet(doc.getInfo(),doc.getId(),profile.getId(), request.getAttributes(),files,storage,ws);
|
||||
log.debug("Registered Fileset for [ID {} profile {}] is {} ",fs,doc.getId(),doc.getProfileID());
|
||||
RegisteredFileSet fs = prepareRegisteredFileSet(doc.getInfo(),doc.getId(), useCaseDescriptor.getId(), request.getAttributes(),files,storage,ws);
|
||||
log.debug("Registered Fileset for [ID {} useCaseDescriptor {}] is {} ",fs,doc.getId(),doc.getProfileID());
|
||||
docWrapper.putElement(parentMatchingPath,request.getFieldName(),fs);
|
||||
break;}
|
||||
case MERGE_EXISTING: {
|
||||
|
@ -342,15 +342,15 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
|
|||
// MERGE ATTRIBUTES AND PUT
|
||||
Document toUseAttributes=request.getAttributes();
|
||||
if(original!=null) toUseAttributes.putAll(original);
|
||||
RegisteredFileSet fs = prepareRegisteredFileSet(doc.getInfo(),doc.getId(),profile.getId(), toUseAttributes,files,storage,ws);
|
||||
log.debug("Registered Fileset for [ID {} profile {}] is {} ",fs,doc.getId(),doc.getProfileID());
|
||||
RegisteredFileSet fs = prepareRegisteredFileSet(doc.getInfo(),doc.getId(), useCaseDescriptor.getId(), toUseAttributes,files,storage,ws);
|
||||
log.debug("Registered Fileset for [ID {} useCaseDescriptor {}] is {} ",fs,doc.getId(),doc.getProfileID());
|
||||
docWrapper.putElement(parentMatchingPath,request.getFieldName(),fs);
|
||||
break;}
|
||||
case APPEND: {
|
||||
if(!fieldDefinition.isCollection())
|
||||
throw new WebApplicationException("Cannot add to single field "+request.getFieldDefinitionPath()+".",Response.Status.BAD_REQUEST);
|
||||
RegisteredFileSet fs = prepareRegisteredFileSet(doc.getInfo(),doc.getId(),profile.getId(), request.getAttributes(),files,storage,ws);
|
||||
log.debug("Registered Fileset for [ID {} profile {}] is {} ",fs,doc.getId(),doc.getProfileID());
|
||||
RegisteredFileSet fs = prepareRegisteredFileSet(doc.getInfo(),doc.getId(), useCaseDescriptor.getId(), request.getAttributes(),files,storage,ws);
|
||||
log.debug("Registered Fileset for [ID {} useCaseDescriptor {}] is {} ",fs,doc.getId(),doc.getProfileID());
|
||||
|
||||
docWrapper.addElementToArray(String.format("%1ds['%2$s']",parentMatchingPath,request.getFieldName()),fs);
|
||||
break;}
|
||||
|
@ -363,14 +363,14 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
|
|||
|
||||
doc=onUpdate(doc);
|
||||
|
||||
return convert(replace(asDocumentWithId(doc),new ObjectId(id),getCollectionName()),ProfiledDocument.class);
|
||||
return convert(replace(asDocumentWithId(doc),new ObjectId(id),getCollectionName()), Project.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProfiledDocument deleteFileSet(String id, String path, Boolean force) throws ConfigurationException, StorageHubException, JsonProcessingException, DeletionException, EventException {
|
||||
log.info("Deleting Fileset for {} [profile ID {}], at {} [force {} ]",id,profile.getId(),path,force);
|
||||
public Project deleteFileSet(String id, String path, Boolean force) throws ConfigurationException, StorageHubException, JsonProcessingException, DeletionException, EventException {
|
||||
log.info("Deleting Fileset for {} [useCaseDescriptor ID {}], at {} [force {} ]",id, useCaseDescriptor.getId(),path,force);
|
||||
|
||||
ProfiledDocument doc = getByID(id);
|
||||
Project doc = getByID(id);
|
||||
doc.getLifecycleInformation().cleanState();
|
||||
doc.getLifecycleInformation().cleanState().setLastOperationStatus(LifecycleInformation.Status.OK);
|
||||
|
||||
|
@ -385,25 +385,25 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
|
|||
log.debug("Removing FS from document [ID : ] by path {}",id,path);
|
||||
wrapper.setElement(path,null);
|
||||
doc=onUpdate(doc);
|
||||
return convert(replace(asDocumentWithId(doc),new ObjectId(id),getCollectionName()),ProfiledDocument.class);
|
||||
return convert(replace(asDocumentWithId(doc),new ObjectId(id),getCollectionName()), Project.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Configuration getConfiguration() throws ConfigurationException {
|
||||
log.debug("Asking configuration for {} in {} ",profile.getId(), UserUtils.getCurrent().getContext());
|
||||
log.debug("Asking configuration for {} in {} ", useCaseDescriptor.getId(), UserUtils.getCurrent().getContext());
|
||||
Configuration toReturn= getManager().getCurrentConfiguration();
|
||||
log.debug("Returning current configuration {}",toReturn);
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
|
||||
private ProfiledDocument step(ProfiledDocument theDocument, String step, Document callParameters){
|
||||
private Project step(Project theDocument, String step, Document callParameters){
|
||||
try{
|
||||
log.info("[Profile {}] Invoking Step {} on {}" ,profile.getId(),step,getManager().getDescriptor());
|
||||
log.info("[UseCaseDescriptor {}] Invoking Step {} on {}" , useCaseDescriptor.getId(),step,getManager().getDescriptor());
|
||||
StepExecutionRequest request=new StepExecutionRequest();
|
||||
request.setCallParameters(callParameters);
|
||||
request.setDocument(theDocument);
|
||||
request.setProfile(profile);
|
||||
request.setUseCaseDescriptor(useCaseDescriptor);
|
||||
request.setStep(step);
|
||||
AccountingInfo user= UserUtils.getCurrent().asInfo();
|
||||
request.setUser(user.getUser());
|
||||
|
@ -411,7 +411,7 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
|
|||
|
||||
log.debug("Requesting Step Execution {}",request);
|
||||
StepExecutionReport report= getManager().performStep(request);
|
||||
ProfiledDocument toReturn = report.prepareResult();
|
||||
Project toReturn = report.prepareResult();
|
||||
|
||||
// EVENTS
|
||||
if(report.getToTriggerEvents()!=null) {
|
||||
|
@ -443,12 +443,12 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
|
|||
}
|
||||
}
|
||||
|
||||
private ProfiledDocument triggerEvent(ProfiledDocument theDocument, String event, Document parameters) {
|
||||
private Project triggerEvent(Project theDocument, String event, Document parameters) {
|
||||
try{
|
||||
log.info("[Profile {}] triggering event {} on {}" ,profile.getId(),event,getManager().getDescriptor());
|
||||
log.info("[UseCaseDescriptor {}] triggering event {} on {}" , useCaseDescriptor.getId(),event,getManager().getDescriptor());
|
||||
EventExecutionRequest request= new EventExecutionRequest();
|
||||
request.setEvent(event);
|
||||
request.setProfile(profile);
|
||||
request.setUseCaseDescriptor(useCaseDescriptor);
|
||||
request.setCallParameters(parameters);
|
||||
request.setDocument(theDocument);
|
||||
log.debug("Triggering {}",request);
|
||||
|
@ -479,7 +479,7 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
|
|||
FolderContainer sectionFolder=null;
|
||||
if(folderID==null || folderID.isEmpty()) {
|
||||
FolderContainer base = ws.createFolder(new WorkspaceManager.FolderOptions(
|
||||
docID, "Base Folder for profiled document. Profile " + profileID, null));
|
||||
docID, "Base Folder for profiled document. UseCaseDescriptor " + profileID, null));
|
||||
sectionFolder = ws.createFolder(new WorkspaceManager.FolderOptions(
|
||||
docID + "_" + uuid, "Registered Fileset uuid " + uuid, base));
|
||||
toReturn.put(RegisteredFileSet.FOLDER_ID, sectionFolder.getId());
|
||||
|
@ -531,16 +531,16 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
|
|||
}
|
||||
|
||||
|
||||
private static Field getFieldDefinition(Profile profile,String fieldPath)throws WebApplicationException{
|
||||
JSONPathWrapper schemaWrapper= new JSONPathWrapper(profile.getSchema().toJson());
|
||||
private static Field getFieldDefinition(UseCaseDescriptor useCaseDescriptor, String fieldPath)throws WebApplicationException{
|
||||
JSONPathWrapper schemaWrapper= new JSONPathWrapper(useCaseDescriptor.getSchema().toJson());
|
||||
List<Field> fieldDefinitions=schemaWrapper.getByPath(fieldPath,Field.class);
|
||||
if(fieldDefinitions==null || fieldDefinitions.isEmpty())
|
||||
throw new WebApplicationException("No Field found in schema "+profile.getId()+" at "+fieldPath, Response.Status.BAD_REQUEST);
|
||||
throw new WebApplicationException("No Field found in schema "+ useCaseDescriptor.getId()+" at "+fieldPath, Response.Status.BAD_REQUEST);
|
||||
if(fieldDefinitions.size()>1)
|
||||
throw new WebApplicationException("Multiple field definitions ("+fieldDefinitions.size()+") found in "+profile.getId()+" for "+fieldPath,Response.Status.BAD_REQUEST);
|
||||
throw new WebApplicationException("Multiple field definitions ("+fieldDefinitions.size()+") found in "+ useCaseDescriptor.getId()+" for "+fieldPath,Response.Status.BAD_REQUEST);
|
||||
Field fieldDefinition=Serialization.convert(fieldDefinitions.get(0),Field.class);
|
||||
if(fieldDefinition==null)
|
||||
throw new WebApplicationException("Found field is null ["+profile.getId()+" for "+fieldPath+"]",Response.Status.BAD_REQUEST);
|
||||
throw new WebApplicationException("Found field is null ["+ useCaseDescriptor.getId()+" for "+fieldPath+"]",Response.Status.BAD_REQUEST);
|
||||
log.trace("Field definition is {}",fieldDefinition);
|
||||
return fieldDefinition;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
package org.gcube.application.geoportal.service.engine.mongo;
|
||||
|
||||
import com.mongodb.client.MongoDatabase;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bson.Document;
|
||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
|
||||
import org.gcube.application.geoportal.common.model.rest.ConfigurationException;
|
||||
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
|
||||
import org.gcube.application.geoportal.common.utils.ContextUtils;
|
||||
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Slf4j
|
||||
public class UCDManager extends MongoManager implements UCDManagerI {
|
||||
|
||||
MongoDatabase db=null;
|
||||
|
||||
public UCDManager() throws ConfigurationException {
|
||||
log.info("Init useCaseDescriptor Manager");
|
||||
}
|
||||
|
||||
@Override
|
||||
public MongoDatabase getDatabase(){
|
||||
if(db == null) {
|
||||
log.debug("Getting client for {}",getCollectionName());
|
||||
db = client.getTheClient().getDatabase(getCollectionName());
|
||||
}
|
||||
return db;
|
||||
}
|
||||
|
||||
private String getCollectionName(){
|
||||
return "profiles_"+ContextUtils.getCurrentScope();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UseCaseDescriptor create(Document toCreate) {
|
||||
// Validate
|
||||
// NB Check for existing ID
|
||||
// INSERT
|
||||
// force update cache
|
||||
throw new WebApplicationException("TO BE IMPLEMENTED", Response.Status.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<UseCaseDescriptor> query(QueryRequest queryRequest) {
|
||||
log.info("Querying {} ",queryRequest);
|
||||
LinkedBlockingQueue queue=new LinkedBlockingQueue<UseCaseDescriptor>();
|
||||
query(queryRequest,getCollectionName()).forEach(
|
||||
(Consumer<? super Document>) (Document d)->{try{
|
||||
queue.put(d);
|
||||
}catch(Throwable t){log.warn("Unable to translate "+d);}});
|
||||
log.info("Returned {} elements ",queue.size());
|
||||
return queue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteById(String id, boolean force) {
|
||||
// NB Check for existing ID
|
||||
// Check Force (existing documents)
|
||||
throw new WebApplicationException("TO BE IMPLEMENTED", Response.Status.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UseCaseDescriptor update(String ID, Document toSet) {
|
||||
// NB Check for existing ID
|
||||
// Validate
|
||||
// INSERT
|
||||
// force update cache
|
||||
throw new WebApplicationException("TO BE IMPLEMENTED", Response.Status.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UseCaseDescriptor getById(String id) {
|
||||
// GET from mongo cache
|
||||
// IF void try from ProfileEngine
|
||||
throw new WebApplicationException("TO BE IMPLEMENTED", Response.Status.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package org.gcube.application.geoportal.service.engine.mongo;
|
||||
|
||||
import org.bson.Document;
|
||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
|
||||
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
|
||||
|
||||
public interface UCDManagerI {
|
||||
|
||||
public UseCaseDescriptor create(Document toCreate);
|
||||
|
||||
public Iterable<UseCaseDescriptor> query(QueryRequest request);
|
||||
|
||||
public void deleteById(String id,boolean force);
|
||||
|
||||
public UseCaseDescriptor update(String ID, Document toSet);
|
||||
|
||||
public UseCaseDescriptor getById(String id);
|
||||
}
|
|
@ -1,7 +1,5 @@
|
|||
package org.gcube.application.geoportal.service.engine.providers;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.gcube.application.cms.caches.AbstractScopedMap;
|
||||
import org.gcube.application.cms.plugins.*;
|
||||
|
@ -9,17 +7,10 @@ import org.gcube.application.cms.plugins.faults.InitializationException;
|
|||
import org.gcube.application.cms.plugins.faults.PluginExecutionException;
|
||||
import org.gcube.application.cms.plugins.faults.ShutDownException;
|
||||
import org.gcube.application.cms.plugins.reports.InitializationReport;
|
||||
import org.gcube.application.geoportal.common.model.profile.Profile;
|
||||
import org.gcube.application.geoportal.common.utils.ContextUtils;
|
||||
import org.gcube.application.geoportal.common.model.rest.ConfigurationException;
|
||||
|
||||
import org.reflections.Reflections;
|
||||
import org.reflections.util.ConfigurationBuilder;
|
||||
import org.reflections.util.FilterBuilder;
|
||||
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
public class PluginManager extends AbstractScopedMap<PluginManager.PluginMap> implements PluginManagerInterface {
|
||||
|
|
|
@ -2,10 +2,9 @@ package org.gcube.application.geoportal.service.engine.providers;
|
|||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.gcube.application.cms.caches.AbstractScopedMap;
|
||||
import org.gcube.application.geoportal.common.model.profile.Profile;
|
||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
|
||||
import org.gcube.application.geoportal.common.utils.Files;
|
||||
import org.gcube.application.geoportal.common.model.rest.ConfigurationException;
|
||||
import org.gcube.application.cms.serialization.Serialization;
|
||||
|
@ -13,13 +12,12 @@ import org.gcube.application.cms.serialization.Serialization;
|
|||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
public class ProfileMapCache extends AbstractScopedMap<ProfileMapCache.ProfileMap> {
|
||||
|
||||
@AllArgsConstructor
|
||||
public static class ProfileMap extends HashMap<String,Profile>{
|
||||
public static class ProfileMap extends HashMap<String, UseCaseDescriptor>{
|
||||
}
|
||||
|
||||
public ProfileMapCache() {
|
||||
|
@ -45,8 +43,8 @@ public class ProfileMapCache extends AbstractScopedMap<ProfileMapCache.ProfileMa
|
|||
ProfileMap toReturn=new ProfileMap();
|
||||
|
||||
try {
|
||||
Profile p=Serialization.read(Files.
|
||||
readFileAsString(Files.getFileFromResources("profiles/profiledConcessioni.json").getAbsolutePath(), Charset.defaultCharset()), Profile.class);
|
||||
UseCaseDescriptor p=Serialization.read(Files.
|
||||
readFileAsString(Files.getFileFromResources("profiles/profiledConcessioni.json").getAbsolutePath(), Charset.defaultCharset()), UseCaseDescriptor.class);
|
||||
log.debug("Loaded "+p.getName()+" ID "+p.getId());
|
||||
toReturn.put(p.getId(),p);
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package org.gcube.application.geoportal.service.rest;
|
|||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bson.Document;
|
||||
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
|
||||
import org.gcube.application.geoportal.common.model.document.Project;
|
||||
import org.gcube.application.geoportal.common.model.rest.Configuration;
|
||||
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
|
||||
import org.gcube.application.geoportal.common.rest.InterfaceConstants;
|
||||
|
@ -48,13 +48,13 @@ public class ProfiledDocuments {
|
|||
@POST
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public ProfiledDocument createNew(Document d) {
|
||||
return new GuardedMethod<ProfiledDocument>() {
|
||||
public Project createNew(Document d) {
|
||||
return new GuardedMethod<Project>() {
|
||||
@Override
|
||||
protected ProfiledDocument run() throws Exception, WebApplicationException {
|
||||
log.info("Creating new ProfiledDocument ({})",manager.getProfile().getId());
|
||||
ProfiledDocument toReturn= manager.registerNew(d);
|
||||
log.info("Created new ProfiledDocument ({}, ID {})",manager.getProfile().getId(),toReturn.getId());
|
||||
protected Project run() throws Exception, WebApplicationException {
|
||||
log.info("Creating new Project ({})",manager.getUseCaseDescriptor().getId());
|
||||
Project toReturn= manager.registerNew(d);
|
||||
log.info("Created new Project ({}, ID {})",manager.getUseCaseDescriptor().getId(),toReturn.getId());
|
||||
return toReturn;
|
||||
}
|
||||
}.execute().getResult();
|
||||
|
@ -65,11 +65,11 @@ public class ProfiledDocuments {
|
|||
@Path("{"+InterfaceConstants.Parameters.PROJECT_ID+"}")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public ProfiledDocument update(@PathParam(InterfaceConstants.Parameters.PROJECT_ID) String documentId, Document d) {
|
||||
return new GuardedMethod<ProfiledDocument>() {
|
||||
public Project update(@PathParam(InterfaceConstants.Parameters.PROJECT_ID) String documentId, Document d) {
|
||||
return new GuardedMethod<Project>() {
|
||||
@Override
|
||||
protected ProfiledDocument run() throws Exception, WebApplicationException {
|
||||
log.info("Updating ProfiledDocument ({}, ID {})",manager.getProfile().getId(),documentId);
|
||||
protected Project run() throws Exception, WebApplicationException {
|
||||
log.info("Updating Project ({}, ID {})",manager.getUseCaseDescriptor().getId(),documentId);
|
||||
return manager.update(documentId,d);
|
||||
}
|
||||
}.execute().getResult();
|
||||
|
@ -85,7 +85,7 @@ public class ProfiledDocuments {
|
|||
return new GuardedMethod<Boolean>() {
|
||||
@Override
|
||||
protected Boolean run() throws Exception, WebApplicationException {
|
||||
log.info("Deleting ProfiledDocument ({}, ID {}). Force is {}",manager.getProfile().getId(),id,force);
|
||||
log.info("Deleting Project ({}, ID {}). Force is {}",manager.getUseCaseDescriptor().getId(),id,force);
|
||||
manager.delete(id,force);
|
||||
return true;
|
||||
}
|
||||
|
@ -96,14 +96,14 @@ public class ProfiledDocuments {
|
|||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("/"+InterfaceConstants.Methods.REGISTER_FILES_PATH+"/{"+InterfaceConstants.Parameters.PROJECT_ID+"}")
|
||||
public ProfiledDocument registerFileSet(@PathParam(InterfaceConstants.Parameters.PROJECT_ID) String id,
|
||||
public Project registerFileSet(@PathParam(InterfaceConstants.Parameters.PROJECT_ID) String id,
|
||||
RegisterFileSetRequest request) {
|
||||
return new GuardedMethod<ProfiledDocument>() {
|
||||
return new GuardedMethod<Project>() {
|
||||
@Override
|
||||
protected ProfiledDocument run() throws Exception, WebApplicationException {
|
||||
log.info("Registering {} file(s) for ProfiledDocument ({}, ID {}) with {}",
|
||||
protected Project run() throws Exception, WebApplicationException {
|
||||
log.info("Registering {} file(s) for Project ({}, ID {}) with {}",
|
||||
request.getStreams().size(),
|
||||
manager.getProfile().getId(),
|
||||
manager.getUseCaseDescriptor().getId(),
|
||||
id,request);
|
||||
request.validate();
|
||||
return manager.registerFileSet(id,request);
|
||||
|
@ -115,16 +115,16 @@ public class ProfiledDocuments {
|
|||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("/"+InterfaceConstants.Methods.DELETE_FILES_PATH+"/{"+InterfaceConstants.Parameters.PROJECT_ID+"}")
|
||||
public ProfiledDocument deleteFileSet(
|
||||
public Project deleteFileSet(
|
||||
@PathParam(InterfaceConstants.Parameters.PROJECT_ID) String id,
|
||||
@DefaultValue("false")
|
||||
@QueryParam(InterfaceConstants.Parameters.FORCE) Boolean force,
|
||||
String path) {
|
||||
return new GuardedMethod<ProfiledDocument>() {
|
||||
return new GuardedMethod<Project>() {
|
||||
@Override
|
||||
protected ProfiledDocument run() throws Exception, WebApplicationException {
|
||||
log.info("Deleting FileSet of ProfiledDocument ({}, ID {}) at path {}. Force is {}",
|
||||
manager.getProfile().getId(),
|
||||
protected Project run() throws Exception, WebApplicationException {
|
||||
log.info("Deleting FileSet of Project ({}, ID {}) at path {}. Force is {}",
|
||||
manager.getUseCaseDescriptor().getId(),
|
||||
id,path,force);
|
||||
return manager.deleteFileSet(id,path,force);
|
||||
}
|
||||
|
@ -136,15 +136,15 @@ public class ProfiledDocuments {
|
|||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("/"+InterfaceConstants.Methods.STEP+"/{"+InterfaceConstants.Parameters.PROJECT_ID+"}")
|
||||
public ProfiledDocument performStep(
|
||||
public Project performStep(
|
||||
@PathParam(InterfaceConstants.Parameters.PROJECT_ID) String id,
|
||||
StepExecutionRequest request) {
|
||||
return new GuardedMethod<ProfiledDocument>() {
|
||||
return new GuardedMethod<Project>() {
|
||||
@Override
|
||||
protected ProfiledDocument run() throws Exception, WebApplicationException {
|
||||
log.info("Executing step {} on ProfiledDocument ({},ID,{}) with options {}",
|
||||
protected Project run() throws Exception, WebApplicationException {
|
||||
log.info("Executing step {} on Project ({},ID,{}) with options {}",
|
||||
request.getStepID(),
|
||||
manager.getProfile().getId(),
|
||||
manager.getUseCaseDescriptor().getId(),
|
||||
id,request.getOptions());
|
||||
return manager.performStep(id,request.getStepID(),request.getOptions());
|
||||
}
|
||||
|
@ -167,10 +167,10 @@ public class ProfiledDocuments {
|
|||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("{"+InterfaceConstants.Parameters.PROJECT_ID+"}")
|
||||
public ProfiledDocument getById(@PathParam(InterfaceConstants.Parameters.PROJECT_ID) String id) {
|
||||
return new GuardedMethod<ProfiledDocument>() {
|
||||
public Project getById(@PathParam(InterfaceConstants.Parameters.PROJECT_ID) String id) {
|
||||
return new GuardedMethod<Project>() {
|
||||
@Override
|
||||
protected ProfiledDocument run() throws Exception, WebApplicationException {
|
||||
protected Project run() throws Exception, WebApplicationException {
|
||||
return manager.getByID(id);
|
||||
}
|
||||
}.execute().getResult();
|
||||
|
|
|
@ -3,10 +3,9 @@ package org.gcube.application.geoportal.service.rest;
|
|||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bson.Document;
|
||||
import org.gcube.application.cms.serialization.Serialization;
|
||||
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
|
||||
import org.gcube.application.geoportal.common.model.profile.Profile;
|
||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
|
||||
import org.gcube.application.geoportal.common.rest.InterfaceConstants;
|
||||
import org.gcube.application.geoportal.service.engine.mongo.ProfileManager;
|
||||
import org.gcube.application.geoportal.service.engine.mongo.UCDManagerI;
|
||||
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
@ -15,19 +14,19 @@ import javax.ws.rs.core.MediaType;
|
|||
@Slf4j
|
||||
public class UseCaseDescriptors {
|
||||
|
||||
private ProfileManager profileEngine;
|
||||
private UCDManagerI profileEngine;
|
||||
|
||||
|
||||
@POST
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Profile createNew(Document toCreate) {
|
||||
return new GuardedMethod<Profile>() {
|
||||
public UseCaseDescriptor createNew(Document toCreate) {
|
||||
return new GuardedMethod<UseCaseDescriptor>() {
|
||||
@Override
|
||||
protected Profile run() throws Exception, WebApplicationException {
|
||||
log.info("Creating new Profile ({})",toCreate);
|
||||
Profile toReturn= profileEngine.create(toCreate);
|
||||
log.info("Created new Profile (ID {})",toReturn.getId());
|
||||
protected UseCaseDescriptor run() throws Exception, WebApplicationException {
|
||||
log.info("Creating new UseCaseDescriptor ({})",toCreate);
|
||||
UseCaseDescriptor toReturn= profileEngine.create(toCreate);
|
||||
log.info("Created new UseCaseDescriptor (ID {})",toReturn.getId());
|
||||
return toReturn;
|
||||
}
|
||||
}.execute().getResult();
|
||||
|
@ -37,11 +36,11 @@ public class UseCaseDescriptors {
|
|||
@Path("{"+InterfaceConstants.Parameters.PROFILE_ID+"}")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Profile update(@PathParam(InterfaceConstants.Parameters.PROFILE_ID) String profileId, Document d) {
|
||||
return new GuardedMethod<Profile>() {
|
||||
public UseCaseDescriptor update(@PathParam(InterfaceConstants.Parameters.PROFILE_ID) String profileId, Document d) {
|
||||
return new GuardedMethod<UseCaseDescriptor>() {
|
||||
@Override
|
||||
protected Profile run() throws Exception, WebApplicationException {
|
||||
log.warn("Updating Profile ({})",profileId);
|
||||
protected UseCaseDescriptor run() throws Exception, WebApplicationException {
|
||||
log.warn("Updating UseCaseDescriptor ({})",profileId);
|
||||
return profileEngine.update(profileId,d);
|
||||
}
|
||||
}.execute().getResult();
|
||||
|
@ -57,7 +56,7 @@ public class UseCaseDescriptors {
|
|||
return new GuardedMethod<Boolean>() {
|
||||
@Override
|
||||
protected Boolean run() throws Exception, WebApplicationException {
|
||||
log.warn("Deleting Profile (ID {}). Force is {}",id,force);
|
||||
log.warn("Deleting UseCaseDescriptor (ID {}). Force is {}",id,force);
|
||||
profileEngine.deleteById(id,force);
|
||||
return true;
|
||||
}
|
||||
|
@ -69,10 +68,10 @@ public class UseCaseDescriptors {
|
|||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("{"+InterfaceConstants.Parameters.PROFILE_ID+"}")
|
||||
public Profile getById(@PathParam(InterfaceConstants.Parameters.PROFILE_ID) String id) {
|
||||
return new GuardedMethod<Profile>() {
|
||||
public UseCaseDescriptor getById(@PathParam(InterfaceConstants.Parameters.PROFILE_ID) String id) {
|
||||
return new GuardedMethod<UseCaseDescriptor>() {
|
||||
@Override
|
||||
protected Profile run() throws Exception, WebApplicationException {
|
||||
protected UseCaseDescriptor run() throws Exception, WebApplicationException {
|
||||
return profileEngine.getById(id);
|
||||
}
|
||||
}.execute().getResult();
|
||||
|
|
|
@ -9,7 +9,7 @@ import javax.ws.rs.core.Response;
|
|||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class InexistentProfileTests extends AbstractProfiledDocumentsTests {
|
||||
public class InexistentUseCaseDescriptorTests extends AbstractProfiledDocumentsTests {
|
||||
|
||||
@Override
|
||||
protected WebTarget baseTarget() {
|
||||
|
@ -21,7 +21,7 @@ public class InexistentProfileTests extends AbstractProfiledDocumentsTests {
|
|||
@Test
|
||||
public void testMissingProfile(){
|
||||
Response resp = target(InterfaceConstants.Methods.PROJECTS)
|
||||
.path("non-existent-profile").request().get();
|
||||
.path("non-existent-useCaseDescriptor").request().get();
|
||||
assertEquals(404,resp.getStatus());
|
||||
}
|
||||
}
|
|
@ -60,7 +60,7 @@ public class MongoTests {
|
|||
@Test
|
||||
public void listProfiles() throws JsonProcessingException, IOException, ConfigurationException {
|
||||
// MongoManager manager=new MongoManager();
|
||||
// Profile f=Serialization.mapper.readerFor(Profile.class).readValue(
|
||||
// UseCaseDescriptor f=Serialization.mapper.readerFor(UseCaseDescriptor.class).readValue(
|
||||
// Files.getFileFromResources("fakeProfile.json"));
|
||||
//
|
||||
// manager.iterate(new Document(),f).forEach(printBlock);
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
package org.gcube.application.geoportal.service.profiledDocuments;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.jayway.jsonpath.JsonPath;
|
||||
import org.bson.Document;
|
||||
import org.gcube.application.cms.serialization.Serialization;
|
||||
import org.gcube.application.cms.tests.TokenSetter;
|
||||
import org.gcube.application.cms.tests.model.concessioni.TestConcessioniModel;
|
||||
import org.gcube.application.geoportal.common.model.JSONPathWrapper;
|
||||
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
|
||||
import org.gcube.application.geoportal.common.model.document.filesets.RegisteredFileSet;
|
||||
import org.gcube.application.geoportal.common.model.document.Project;
|
||||
import org.gcube.application.geoportal.common.model.document.lifecycle.LifecycleInformation;
|
||||
import org.gcube.application.geoportal.common.model.rest.Configuration;
|
||||
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
|
||||
|
@ -26,9 +23,7 @@ import org.junit.Test;
|
|||
import javax.ws.rs.client.Entity;
|
||||
import javax.ws.rs.client.WebTarget;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
@ -61,8 +56,8 @@ public abstract class AbstractProfiledDocumentsTests extends BasicServiceTestUni
|
|||
baseTarget().request(MediaType.APPLICATION_JSON).get(List.class).forEach(d ->{
|
||||
|
||||
try {
|
||||
check(baseTarget().path((Serialization.convert(d,ProfiledDocument.class)).getId())
|
||||
.request(MediaType.APPLICATION_JSON).get(),ProfiledDocument.class);
|
||||
check(baseTarget().path((Serialization.convert(d, Project.class)).getId())
|
||||
.request(MediaType.APPLICATION_JSON).get(), Project.class);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace(System.err);
|
||||
Assert.fail(e.getMessage());
|
||||
|
@ -91,15 +86,15 @@ public abstract class AbstractProfiledDocumentsTests extends BasicServiceTestUni
|
|||
|
||||
// @@@@@@@@@@@@@@@ Routines
|
||||
|
||||
protected ProfiledDocument createNew(Document content) throws Exception {
|
||||
ProfiledDocument doc =check(baseTarget().request(MediaType.APPLICATION_JSON).
|
||||
post(Entity.entity(content, MediaType.APPLICATION_JSON)),ProfiledDocument.class);
|
||||
protected Project createNew(Document content) throws Exception {
|
||||
Project doc =check(baseTarget().request(MediaType.APPLICATION_JSON).
|
||||
post(Entity.entity(content, MediaType.APPLICATION_JSON)), Project.class);
|
||||
validate(doc);
|
||||
assertTrue(doc.getLifecycleInformation().getPhase().equals(LifecycleInformation.DRAFT_PHASE));
|
||||
return doc;
|
||||
}
|
||||
|
||||
protected void validate (ProfiledDocument doc){
|
||||
protected void validate (Project doc){
|
||||
assertTrue(doc!=null);
|
||||
assertTrue(doc.getId()!=null);
|
||||
assertTrue(doc.getLifecycleInformation().getPhase()!=null);
|
||||
|
@ -134,14 +129,14 @@ public abstract class AbstractProfiledDocumentsTests extends BasicServiceTestUni
|
|||
}
|
||||
|
||||
|
||||
protected ProfiledDocument update(String id, Document newContent)throws Exception {
|
||||
ProfiledDocument doc = check(baseTarget().path(id).request(MediaType.APPLICATION_JSON).
|
||||
put(Entity.entity(newContent, MediaType.APPLICATION_JSON)),ProfiledDocument.class);
|
||||
protected Project update(String id, Document newContent)throws Exception {
|
||||
Project doc = check(baseTarget().path(id).request(MediaType.APPLICATION_JSON).
|
||||
put(Entity.entity(newContent, MediaType.APPLICATION_JSON)), Project.class);
|
||||
validate(doc);
|
||||
return doc;
|
||||
}
|
||||
|
||||
protected ProfiledDocument upload(StorageUtils storage,
|
||||
protected Project upload(StorageUtils storage,
|
||||
String id,
|
||||
String parentPath,
|
||||
String fieldName,
|
||||
|
@ -156,19 +151,19 @@ public abstract class AbstractProfiledDocumentsTests extends BasicServiceTestUni
|
|||
for(String file:files)
|
||||
builder.add(storage.putOntoStorage(new File(TestConcessioniModel.getBaseFolder(),file),file));
|
||||
|
||||
ProfiledDocument doc = check(baseTarget().path(InterfaceConstants.Methods.REGISTER_FILES_PATH).path(id).request(MediaType.APPLICATION_JSON).
|
||||
Project doc = check(baseTarget().path(InterfaceConstants.Methods.REGISTER_FILES_PATH).path(id).request(MediaType.APPLICATION_JSON).
|
||||
post(Entity.entity(Serialization.write(builder.getTheRequest()),
|
||||
MediaType.APPLICATION_JSON)),ProfiledDocument.class);
|
||||
MediaType.APPLICATION_JSON)), Project.class);
|
||||
validate(doc);
|
||||
return doc;
|
||||
}
|
||||
|
||||
|
||||
protected ProfiledDocument step(String id, StepExecutionRequest request) throws Exception {
|
||||
ProfiledDocument toReturn= check(baseTarget().
|
||||
protected Project step(String id, StepExecutionRequest request) throws Exception {
|
||||
Project toReturn= check(baseTarget().
|
||||
path(InterfaceConstants.Methods.STEP).path(id).request(MediaType.APPLICATION_JSON).
|
||||
post(Entity.entity(Serialization.write(request),
|
||||
MediaType.APPLICATION_JSON)),ProfiledDocument.class);
|
||||
MediaType.APPLICATION_JSON)), Project.class);
|
||||
validate(toReturn);
|
||||
assertTrue(toReturn.getLifecycleInformation().getLastInvokedStep().equals(request.getStepID()));
|
||||
return toReturn;
|
||||
|
|
|
@ -3,14 +3,10 @@ package org.gcube.application.geoportal.service.profiledDocuments;
|
|||
import org.bson.Document;
|
||||
import org.gcube.application.cms.serialization.Serialization;
|
||||
import org.gcube.application.geoportal.common.model.JSONPathWrapper;
|
||||
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
|
||||
import org.gcube.application.geoportal.common.model.document.filesets.GCubeSDILayer;
|
||||
import org.gcube.application.geoportal.common.model.document.filesets.Materialization;
|
||||
import org.gcube.application.geoportal.common.model.document.Project;
|
||||
import org.gcube.application.geoportal.common.model.document.filesets.RegisteredFileSet;
|
||||
import org.gcube.application.geoportal.common.model.document.lifecycle.LifecycleInformation;
|
||||
import org.gcube.application.geoportal.common.model.profile.Field;
|
||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.Field;
|
||||
import org.gcube.application.geoportal.common.model.rest.RegisterFileSetRequest;
|
||||
import org.gcube.application.geoportal.common.model.rest.StepExecutionRequest;
|
||||
import org.gcube.application.geoportal.common.rest.InterfaceConstants;
|
||||
import org.gcube.application.geoportal.common.utils.StorageUtils;
|
||||
import org.gcube.application.geoportal.service.BasicServiceTestUnit;
|
||||
|
@ -20,11 +16,10 @@ import org.junit.Test;
|
|||
import javax.ws.rs.client.Entity;
|
||||
import javax.ws.rs.client.WebTarget;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class DummyProfiledDocumentTest extends AbstractProfiledDocumentsTests{
|
||||
public class DummyProjectTest extends AbstractProfiledDocumentsTests{
|
||||
|
||||
@Override
|
||||
protected WebTarget baseTarget() {
|
||||
|
@ -36,7 +31,7 @@ public class DummyProfiledDocumentTest extends AbstractProfiledDocumentsTests{
|
|||
@Test
|
||||
public void registerNew() throws Exception {
|
||||
|
||||
ProfiledDocument doc = createNew(new Document("field","value"));
|
||||
Project doc = createNew(new Document("field","value"));
|
||||
|
||||
assertTrue(doc.getTheDocument().containsKey("field"));
|
||||
assertTrue(doc.getTheDocument().getString("field").equals("value"));
|
||||
|
@ -45,13 +40,13 @@ public class DummyProfiledDocumentTest extends AbstractProfiledDocumentsTests{
|
|||
|
||||
@Test
|
||||
public void edit() throws Exception {
|
||||
ProfiledDocument doc=createNew(new Document());
|
||||
Project doc=createNew(new Document());
|
||||
String beforeJson=doc.getTheDocument().toJson();
|
||||
doc.getTheDocument().put("someStrangeField","someOtherRandomValue");
|
||||
String edited=doc.getTheDocument().toJson();
|
||||
Assert.assertNotEquals(beforeJson,doc.getTheDocument().toJson());
|
||||
doc= BasicServiceTestUnit.check(baseTarget().path(doc.getId()).request(MediaType.APPLICATION_JSON).
|
||||
put(Entity.entity(doc.getTheDocument(), MediaType.APPLICATION_JSON)),ProfiledDocument.class);
|
||||
put(Entity.entity(doc.getTheDocument(), MediaType.APPLICATION_JSON)), Project.class);
|
||||
Assert.assertEquals(edited,doc.getTheDocument().toJson());
|
||||
}
|
||||
|
||||
|
@ -61,7 +56,7 @@ public class DummyProfiledDocumentTest extends AbstractProfiledDocumentsTests{
|
|||
Document baseDoc=new Document();
|
||||
baseDoc.put("relazioneScavo",new Document("title","My Title"));
|
||||
|
||||
ProfiledDocument doc = createNew(baseDoc);
|
||||
Project doc = createNew(baseDoc);
|
||||
assertTrue(doc.getTheDocument().containsKey("relazioneScavo"));
|
||||
|
||||
|
||||
|
@ -95,7 +90,7 @@ public class DummyProfiledDocumentTest extends AbstractProfiledDocumentsTests{
|
|||
// @Test
|
||||
// public void testSDI() throws Exception {
|
||||
// // Create new
|
||||
// ProfiledDocument doc = createNew(new Document("posizionamentoScavo",new Document("title","Mio pos")));
|
||||
// Project doc = createNew(new Document("posizionamentoScavo",new Document("title","Mio pos")));
|
||||
//
|
||||
// // register filesets
|
||||
// doc = upload(
|
|
@ -2,9 +2,9 @@ package org.gcube.application.geoportal.service.profiledDocuments;
|
|||
|
||||
import org.bson.Document;
|
||||
import org.gcube.application.cms.serialization.Serialization;
|
||||
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
|
||||
import org.gcube.application.geoportal.common.model.document.Project;
|
||||
import org.gcube.application.geoportal.common.model.document.lifecycle.LifecycleInformation;
|
||||
import org.gcube.application.geoportal.common.model.profile.Field;
|
||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.Field;
|
||||
import org.gcube.application.geoportal.common.model.rest.RegisterFileSetRequest;
|
||||
import org.gcube.application.geoportal.common.model.rest.StepExecutionRequest;
|
||||
import org.gcube.application.geoportal.common.rest.InterfaceConstants;
|
||||
|
@ -32,7 +32,7 @@ public class ProfiledConcessioniTests extends AbstractProfiledDocumentsTests{
|
|||
"\"posizionamentoScavo\" :{\n" +
|
||||
"\t\"titolo\" : \"mio titolo\"}}");
|
||||
|
||||
ProfiledDocument doc = createNew(theDoc);
|
||||
Project doc = createNew(theDoc);
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,19 +1,12 @@
|
|||
package org.gcube.application.cms.sdi.engine;
|
||||
|
||||
import it.geosolutions.geoserver.rest.encoder.GSLayerEncoder;
|
||||
import it.geosolutions.geoserver.rest.encoder.feature.GSFeatureTypeEncoder;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bson.Document;
|
||||
import org.gcube.application.cms.sdi.faults.SDIInteractionException;
|
||||
import org.gcube.application.geoportal.common.model.profile.Profile;
|
||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
|
||||
import org.gcube.application.geoportal.common.model.rest.DatabaseConnection;
|
||||
import org.gcube.application.geoportal.common.utils.Files;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
@ -34,30 +27,30 @@ public class PostgisIndexer {
|
|||
@NonNull
|
||||
SDIManagerWrapper manager;
|
||||
@NonNull
|
||||
Profile profile;
|
||||
UseCaseDescriptor useCaseDescriptor;
|
||||
|
||||
@NonNull
|
||||
DatabaseConnection connectionParameters;
|
||||
|
||||
PostgisDBManagerI dbManager=null;
|
||||
|
||||
public PostgisIndexer(SDIManagerWrapper manager, Profile profile,
|
||||
public PostgisIndexer(SDIManagerWrapper manager, UseCaseDescriptor useCaseDescriptor,
|
||||
DatabaseConnection postgisConnection) throws SQLException {
|
||||
log.info("POSTGIS Index for {} Connecting to {} ",profile.getId(),postgisConnection);
|
||||
log.info("POSTGIS Index for {} Connecting to {} ", useCaseDescriptor.getId(),postgisConnection);
|
||||
this.connectionParameters=postgisConnection;
|
||||
dbManager=new PostgisDBManager(DriverManager.
|
||||
getConnection(connectionParameters.getUrl(),
|
||||
connectionParameters.getUser(),
|
||||
connectionParameters.getPwd()));
|
||||
this.manager=manager;
|
||||
this.profile = profile;
|
||||
this.useCaseDescriptor = useCaseDescriptor;
|
||||
|
||||
}
|
||||
|
||||
PostgisTable table = null;
|
||||
|
||||
public void initIndex(String indexName, List<PostgisTable.Field> fields, String workspace,String storeName) throws SQLException, SDIInteractionException {
|
||||
log.info("Check/init index for {} ",profile.getId());
|
||||
log.info("Check/init index for {} ", useCaseDescriptor.getId());
|
||||
table = new PostgisTable(indexName,fields, PostgisTable.GeometryType.POINT);
|
||||
log.trace("Index Postgis Table is {} ",table);
|
||||
log.debug("Create if missing..");
|
||||
|
|
|
@ -39,7 +39,7 @@ public class SDIManagerWrapper extends SDIManager{
|
|||
* - "workspace"
|
||||
* - "layerTitle"
|
||||
* - "documentID"
|
||||
* - "basePersistencePath" (profile specific, e.g. "GNA")
|
||||
* - "basePersistencePath" (useCaseDescriptor specific, e.g. "GNA")
|
||||
*
|
||||
* @param fileSet
|
||||
* @param params
|
||||
|
|
|
@ -19,10 +19,10 @@ import org.gcube.application.cms.sdi.faults.SDIInteractionException;
|
|||
import org.gcube.application.cms.serialization.Serialization;
|
||||
import org.gcube.application.geoportal.common.model.JSONPathWrapper;
|
||||
import org.gcube.application.cms.plugins.model.ComparableVersion;
|
||||
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
|
||||
import org.gcube.application.geoportal.common.model.document.Project;
|
||||
import org.gcube.application.geoportal.common.model.document.filesets.GCubeSDILayer;
|
||||
import org.gcube.application.geoportal.common.model.document.spatial.SpatialReference;
|
||||
import org.gcube.application.geoportal.common.model.profile.Profile;
|
||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -82,8 +82,8 @@ public class SDIIndexerPlugin extends SDIAbstractPlugin implements IndexerPlugin
|
|||
|
||||
log.info("Indexer {} : Performing {} ",this.getDescriptor().getId(),request);
|
||||
|
||||
ProfiledDocument profiledDocument=request.getDocument();
|
||||
Profile profile = request.getProfile();
|
||||
Project project =request.getDocument();
|
||||
UseCaseDescriptor useCaseDescriptor = request.getUseCaseDescriptor();
|
||||
Document requestArguments=request.getCallParameters();
|
||||
|
||||
IndexDocumentReport report= new IndexDocumentReport(request);
|
||||
|
@ -93,19 +93,19 @@ public class SDIIndexerPlugin extends SDIAbstractPlugin implements IndexerPlugin
|
|||
try{
|
||||
// ********* INIT INDEX
|
||||
// TODO CACHE
|
||||
PostgisIndexer indexer = new PostgisIndexer(sdiCache.getObject(),profile,postgisCache.getObject());
|
||||
PostgisIndexer indexer = new PostgisIndexer(sdiCache.getObject(), useCaseDescriptor,postgisCache.getObject());
|
||||
|
||||
Document profileConfiguration =getConfigurationFromProfile(profile).getConfiguration();
|
||||
log.debug("Profile Configuration is {} ",profileConfiguration);
|
||||
Document profileConfiguration =getConfigurationFromProfile(useCaseDescriptor).getConfiguration();
|
||||
log.debug("UseCaseDescriptor Configuration is {} ",profileConfiguration);
|
||||
|
||||
// SCHEMA
|
||||
log.debug("Profile {} : Evaluating Index schema.. ",profile.getId());
|
||||
List<PostgisTable.Field> fields = new ArrayList<>(); // TODO From Profile
|
||||
log.debug("UseCaseDescriptor {} : Evaluating Index schema.. ", useCaseDescriptor.getId());
|
||||
List<PostgisTable.Field> fields = new ArrayList<>(); // TODO From UseCaseDescriptor
|
||||
fields.add(new PostgisTable.Field("geom", PostgisTable.FieldType.GEOMETRY));
|
||||
fields.add(new PostgisTable.Field("projectid", PostgisTable.FieldType.TEXT));
|
||||
List mappingObjs= profileConfiguration.get("explicitFieldMapping",List.class);
|
||||
|
||||
log.trace("Loading mappings from profile.. ");
|
||||
log.trace("Loading mappings from useCaseDescriptor.. ");
|
||||
List<MappingObject> mappingObjects= new ArrayList<>();
|
||||
if(mappingObjs!=null){
|
||||
for (Object mappingObj : mappingObjs) {
|
||||
|
@ -131,31 +131,31 @@ public class SDIIndexerPlugin extends SDIAbstractPlugin implements IndexerPlugin
|
|||
// ************* PREPARE RECORD
|
||||
|
||||
|
||||
JSONPathWrapper documentNavigator=new JSONPathWrapper(Serialization.write(profiledDocument));
|
||||
JSONPathWrapper documentNavigator=new JSONPathWrapper(Serialization.write(project));
|
||||
|
||||
Document centroidDoc = new Document();
|
||||
if(requestArguments.containsKey("centroidRecord"))
|
||||
centroidDoc.putAll(requestArguments.get("centroidRecords",Document.class));
|
||||
// DEFAULT VALUES
|
||||
centroidDoc.put("projectid",profiledDocument.getId());
|
||||
centroidDoc.put("projectid", project.getId());
|
||||
|
||||
// ********************** EVALAUTE POSITION
|
||||
log.debug("indexing Profile {} : Evaluating Centroid... ",profile.getId());
|
||||
if(profiledDocument.getSpatialReference()!=null){
|
||||
log.debug("Using user defined spatial reference "+profiledDocument.getSpatialReference());
|
||||
log.debug("indexing UseCaseDescriptor {} : Evaluating Centroid... ", useCaseDescriptor.getId());
|
||||
if(project.getSpatialReference()!=null){
|
||||
log.debug("Using user defined spatial reference "+ project.getSpatialReference());
|
||||
//TODO USE GEOJSON Position
|
||||
throw new Exception("Not yet implemented");
|
||||
}else {
|
||||
log.debug("Profile {} : Getting evaluation paths from profile.. ",profile.getId());
|
||||
log.debug("UseCaseDescriptor {} : Getting evaluation paths from useCaseDescriptor.. ", useCaseDescriptor.getId());
|
||||
List bboxEvaluationPaths = profileConfiguration.get("bboxEvaluation",List.class);
|
||||
if(bboxEvaluationPaths==null || bboxEvaluationPaths.isEmpty())
|
||||
throw new Exception("Missing configuration bboxEvaluation");
|
||||
|
||||
GCubeSDILayer.BBOX toSet = null;
|
||||
for(Object pathObj : bboxEvaluationPaths){
|
||||
log.debug("Profile {} : Evaluating path {} ",profile.getId(),pathObj);
|
||||
log.debug("UseCaseDescriptor {} : Evaluating path {} ", useCaseDescriptor.getId(),pathObj);
|
||||
List<Object> bboxObjects = documentNavigator.getByPath(pathObj.toString());
|
||||
log.debug("Profile {} : Evaluating path {} .. results {} ",profile.getId(),pathObj,bboxObjects);
|
||||
log.debug("UseCaseDescriptor {} : Evaluating path {} .. results {} ", useCaseDescriptor.getId(),pathObj,bboxObjects);
|
||||
for(Object bboxObject : bboxObjects) {
|
||||
log.info("Matched path {}, value is {} ",pathObj.toString(),bboxObject);
|
||||
GCubeSDILayer.BBOX box = Serialization.convert(bboxObject, GCubeSDILayer.BBOX.class);
|
||||
|
@ -187,7 +187,7 @@ public class SDIIndexerPlugin extends SDIAbstractPlugin implements IndexerPlugin
|
|||
|
||||
|
||||
|
||||
//*********** Additional Values from profile
|
||||
//*********** Additional Values from useCaseDescriptor
|
||||
|
||||
log.info("Setting additional values to centroid from mappings ..");
|
||||
for(MappingObject m : mappingObjects){
|
||||
|
|
|
@ -20,10 +20,10 @@ import org.gcube.application.cms.plugins.requests.MaterializationRequest;
|
|||
import org.gcube.application.cms.serialization.Serialization;
|
||||
import org.gcube.application.geoportal.common.model.JSONPathWrapper;
|
||||
import org.gcube.application.cms.plugins.model.ComparableVersion;
|
||||
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
|
||||
import org.gcube.application.geoportal.common.model.document.Project;
|
||||
import org.gcube.application.geoportal.common.model.document.filesets.RegisteredFileSet;
|
||||
import org.gcube.application.geoportal.common.model.profile.Field;
|
||||
import org.gcube.application.geoportal.common.model.profile.Profile;
|
||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.Field;
|
||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
|
||||
import org.gcube.application.geoportal.common.utils.ContextUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
@ -90,17 +90,17 @@ public class SDIMaterializerPlugin extends AbstractPlugin implements Materializa
|
|||
@Override
|
||||
public MaterializationReport materialize(MaterializationRequest request) throws MaterializationException, InvalidPluginRequestException {
|
||||
log.info("Materializer {} : Performing {} ",this.getDescriptor().getId(),request);
|
||||
ProfiledDocument profiledDocument=request.getDocument();
|
||||
Profile profile = request.getProfile();
|
||||
Project project =request.getDocument();
|
||||
UseCaseDescriptor useCaseDescriptor = request.getUseCaseDescriptor();
|
||||
Document requestArguments=request.getCallParameters();
|
||||
|
||||
MaterializationReport report= new MaterializationReport(request);
|
||||
|
||||
try{
|
||||
Document profileConfiguration =getConfigurationFromProfile(profile).getConfiguration();
|
||||
log.debug("Profile Configuration is {} ",profileConfiguration);
|
||||
JSONPathWrapper documentNavigator=new JSONPathWrapper(profiledDocument.getTheDocument().toJson());
|
||||
JSONPathWrapper schemaNavigator=new JSONPathWrapper(profile.getSchema().toJson());
|
||||
Document profileConfiguration =getConfigurationFromProfile(useCaseDescriptor).getConfiguration();
|
||||
log.debug("UseCaseDescriptor Configuration is {} ",profileConfiguration);
|
||||
JSONPathWrapper documentNavigator=new JSONPathWrapper(project.getTheDocument().toJson());
|
||||
JSONPathWrapper schemaNavigator=new JSONPathWrapper(useCaseDescriptor.getSchema().toJson());
|
||||
|
||||
for(Object fsConfigObj : profileConfiguration.get("registeredFileSetPaths", List.class)){
|
||||
log.debug("Managing {} ",fsConfigObj);
|
||||
|
@ -120,14 +120,14 @@ public class SDIMaterializerPlugin extends AbstractPlugin implements Materializa
|
|||
for(Object fsObject : documentNavigator.getByPath(fsConfig.getDocumentPath())){
|
||||
RegisteredFileSet fs = Serialization.convert(fsObject,RegisteredFileSet.class);
|
||||
log.debug("Found {} ",fs);
|
||||
requestArguments.putIfAbsent("basePersistencePath",profile.getId());
|
||||
requestArguments.putIfAbsent("documentID",profiledDocument.getId());
|
||||
requestArguments.putIfAbsent("basePersistencePath", useCaseDescriptor.getId());
|
||||
requestArguments.putIfAbsent("documentID", project.getId());
|
||||
if(requestArguments.containsKey("titleField"))
|
||||
requestArguments.putIfAbsent("layerTitle",fs.getString(requestArguments.getString("titleField")));
|
||||
else requestArguments.putIfAbsent("layerTitle",fs.getUUID());
|
||||
|
||||
//Add FS uuid at ws_baseName
|
||||
requestArguments.put("workspace",request.getMandatory("workspace")+"_"+ profiledDocument.getId());
|
||||
requestArguments.put("workspace",request.getMandatory("workspace")+"_"+ project.getId());
|
||||
|
||||
// Actually materializing
|
||||
RegisteredFileSet obtained = getSDIManager().materializeLayer(fs,requestArguments);
|
||||
|
|
|
@ -7,13 +7,11 @@ 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.IndexDocumentRequest;
|
||||
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.document.ProfiledDocument;
|
||||
import org.gcube.application.geoportal.common.utils.Files;
|
||||
import org.gcube.application.geoportal.common.model.document.Project;
|
||||
import org.gcube.application.geoportal.common.utils.tests.GCubeTest;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -27,8 +25,8 @@ public class IndexerTest extends BasicPluginTest {
|
|||
assumeTrue(GCubeTest.isTestInfrastructureEnabled());
|
||||
IndexDocumentRequest request=new IndexDocumentRequest();
|
||||
|
||||
ProfiledDocument doc= TestDocuments.documentMap.get("profiledConcessioniExample.json");
|
||||
request.setProfile(TestProfiles.profiles.get(doc.getProfileID()));
|
||||
Project doc= TestDocuments.documentMap.get("profiledConcessioniExample.json");
|
||||
request.setUseCaseDescriptor(TestProfiles.profiles.get(doc.getProfileID()));
|
||||
request.setDocument(doc);
|
||||
Document parameters = new Document();
|
||||
parameters.put("workspace", "testing_workspace");
|
||||
|
|
Loading…
Reference in New Issue