Layer management

This commit is contained in:
Fabio Sinibaldi 2022-02-15 19:02:44 +01:00
parent cc9f592f2c
commit 10eab28b84
4 changed files with 18 additions and 10 deletions

View File

@ -68,7 +68,7 @@ public class ConcessioniLifeCycleManager implements LifecycleManager {
case "SUBMIT-FOR-REVIEW" :{
//TODO Checks
if(!request.getDocument().getLifecycleInformation().getPhase().equals("Draft"))
if(!request.getDocument().getLifecycleInformation().getPhase().equals(LifecycleInformation.DRAFT_PHASE))
throw new StepException("Document is not in Draft phase");
//Materialize layers
MaterializationRequest matReq = new MaterializationRequest();
@ -133,7 +133,8 @@ public class ConcessioniLifeCycleManager implements LifecycleManager {
// Set Defaults as for on update
case EventExecutionRequest.Events.ON_UPDATE_DOCUMENT: {
log.debug("Setting default values..");
report.setResult(setDefaults(request.getDocument()));
// TODO implement defaults for concessione
// report.setResult(setDefaults(request.getDocument()));
break;
}
case EventExecutionRequest.Events.ON_DELETE_DOCUMENT: {

View File

@ -1,6 +1,5 @@
package org.gcube.application.cms.concessioni.plugins;
import com.mongodb.util.JSON;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.bson.Document;
@ -17,8 +16,6 @@ import org.gcube.application.cms.plugins.reports.Report;
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.geoportal.common.model.document.filesets.Materialization;
import org.gcube.application.geoportal.common.model.document.lifecycle.LifecycleInformation;
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.profile.Field;
@ -103,7 +100,7 @@ public class SDIMaterializerPlugin implements MaterializationPlugin {
}
}
profiledDocument.setTheDocument(Document.parse(documentNavigator.getCtx().json()));
profiledDocument.setTheDocument(Document.parse(documentNavigator.getValueCTX().json()));
report.setResultDocument(profiledDocument);
report.setStatus(Report.Status.OK);
}catch (SDIInteractionException e){

View File

@ -152,7 +152,7 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
LifecycleInformation draftInfo=new LifecycleInformation();
draftInfo.setPhase("DRAFT");
draftInfo.setPhase(LifecycleInformation.DRAFT_PHASE);
toRegister.setLifecycleInformation(draftInfo);
// Apply Lifecycle
@ -277,7 +277,7 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
* artifact
* images
* images[1]
* layers[?(@.name = 'myName')]
* layers[?(@.name = 'myName')].fileset
*
*
*
@ -297,6 +297,7 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
log.debug("Checking {}  path against profile {}",request.getFieldPath(),profile.getId());
JSONPathWrapper schemaWrapper= new JSONPathWrapper(profile.getSchema().toJson());
List<Field> fieldDefinitions=schemaWrapper.getByPath(request.getFieldPath(),Field.class);
if(fieldDefinitions==null || fieldDefinitions.isEmpty())
throw new WebApplicationException("No Field found in schema "+profile.getId()+" at "+request.getFieldPath(), Response.Status.BAD_REQUEST);
@ -309,6 +310,12 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
log.debug("Field definition is {}",fieldDefinition);
JSONPathWrapper docWrapper=new JSONPathWrapper(doc.getTheDocument().toJson());
List<Object> matchingPaths = docWrapper.getMatchingPaths(request.getDestinationPath());
if(matchingPaths.size()>1&&!request.getClashOption().equals(RegisterFileSetRequest.ClashOptions.APPEND))
System.out.println();
List<RegisteredFileSet> found=docWrapper.getByPath(request.getDestinationPath(),RegisteredFileSet.class);
@ -353,7 +360,7 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
docWrapper.set(request.getDestinationPath(),toSet);
log.debug("Setting result on profiled document");
doc.setTheDocument(Document.parse(docWrapper.getCtx().jsonString()));
doc.setTheDocument(Document.parse(docWrapper.getValueCTX().jsonString()));
doc=onUpdate(doc);
@ -463,7 +470,7 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
log.debug("Document ID {} : deleting ws folder {}",doc.get_id(),toDelete.getFolderId());
if(toDelete.getPayloads()!=null)
ws.deleteItem(toDelete.getFolderId());
doc.setTheDocument(Document.parse(wrapper.set(fileSetPath,null).getCtx().jsonString()));
doc.setTheDocument(Document.parse(wrapper.set(fileSetPath,null).getValueCTX().jsonString()));
return doc;
}
}

View File

@ -1,6 +1,7 @@
package org.gcube.application.geoportal.service;
import org.bson.Document;
import org.gcube.application.cms.serialization.Serialization;
import org.gcube.application.cms.tests.model.concessioni.TestConcessioniModel;
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
import org.gcube.application.geoportal.common.model.document.lifecycle.LifecycleInformation;
@ -39,6 +40,8 @@ public class ProfiledConcessioniTests extends ProfiledDocumentsTests{
RegisterFileSetRequest.ClashOptions.MERGE_EXISTING,
"pos.shp");
System.out.println("Registered posizionamento, result is "+ Serialization.write(doc));
// invoke step SUBMIT-FOR-REVIEW
StepExecutionRequest req=new StepExecutionRequest();
req.setStepID("SUBMIT-FOR-REVIEW");