diff --git a/concessioni-lifecycle/src/main/java/org/gcube/application/cms/concessioni/plugins/ConcessioniLifeCycleManager.java b/concessioni-lifecycle/src/main/java/org/gcube/application/cms/concessioni/plugins/ConcessioniLifeCycleManager.java index ec41021..a28a221 100644 --- a/concessioni-lifecycle/src/main/java/org/gcube/application/cms/concessioni/plugins/ConcessioniLifeCycleManager.java +++ b/concessioni-lifecycle/src/main/java/org/gcube/application/cms/concessioni/plugins/ConcessioniLifeCycleManager.java @@ -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: { diff --git a/concessioni-lifecycle/src/main/java/org/gcube/application/cms/concessioni/plugins/SDIMaterializerPlugin.java b/concessioni-lifecycle/src/main/java/org/gcube/application/cms/concessioni/plugins/SDIMaterializerPlugin.java index 21e6368..764a573 100644 --- a/concessioni-lifecycle/src/main/java/org/gcube/application/cms/concessioni/plugins/SDIMaterializerPlugin.java +++ b/concessioni-lifecycle/src/main/java/org/gcube/application/cms/concessioni/plugins/SDIMaterializerPlugin.java @@ -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){ diff --git a/geoportal-service/src/main/java/org/gcube/application/geoportal/service/engine/mongo/ProfiledMongoManager.java b/geoportal-service/src/main/java/org/gcube/application/geoportal/service/engine/mongo/ProfiledMongoManager.java index e4f1086..a45177d 100644 --- a/geoportal-service/src/main/java/org/gcube/application/geoportal/service/engine/mongo/ProfiledMongoManager.java +++ b/geoportal-service/src/main/java/org/gcube/application/geoportal/service/engine/mongo/ProfiledMongoManager.java @@ -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 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 matchingPaths = docWrapper.getMatchingPaths(request.getDestinationPath()); + if(matchingPaths.size()>1&&!request.getClashOption().equals(RegisterFileSetRequest.ClashOptions.APPEND)) + System.out.println(); + + + List 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; } } diff --git a/geoportal-service/src/test/java/org/gcube/application/geoportal/service/ProfiledConcessioniTests.java b/geoportal-service/src/test/java/org/gcube/application/geoportal/service/ProfiledConcessioniTests.java index 6b82175..0684291 100644 --- a/geoportal-service/src/test/java/org/gcube/application/geoportal/service/ProfiledConcessioniTests.java +++ b/geoportal-service/src/test/java/org/gcube/application/geoportal/service/ProfiledConcessioniTests.java @@ -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");