This commit is contained in:
Fabio Sinibaldi 2022-10-18 18:00:44 +02:00
parent 888ff97c50
commit f7101e98a4
4 changed files with 497 additions and 244 deletions

View File

@ -34,17 +34,24 @@ public abstract class GenericUseCases extends BasicVreTests{
@Test @Test
public void createNew () throws RemoteException, FileNotFoundException, JsonProcessingException, InvalidRequestException { public void createNew () throws RemoteException, FileNotFoundException, JsonProcessingException, InvalidRequestException {
String profileID=getUCID(); Projects<Project> client = getClient();
Document myDocument= new Document();
myDocument.put("section",new Document("title","myTitle"));
Projects<Project> client = getClient(profileID);
// Create project // Create project
Project project = client.createNew(myDocument); Project project = client.createNew(getNewDocument());
project = prepareWithFileSet(project);
System.out.println("Resulting Project : "+project);
System.out.println("JSON Reprepsentation : "+ Serialization.write(project));
}
protected Document getNewDocument(){
Document myDocument= new Document();
myDocument.put("section",new Document("title","myTitle"));
return myDocument;
}
protected Project prepareWithFileSet(Project project) throws FileNotFoundException, InvalidRequestException, RemoteException {
String parentPath = "$.section"; String parentPath = "$.section";
String fieldName = "fileset"; String fieldName = "fileset";
String fieldDefinition = "$.section._children[?(@.fileset)]"; String fieldDefinition = "$.section._children[?(@.fileset)]";
@ -55,10 +62,6 @@ public abstract class GenericUseCases extends BasicVreTests{
parentPath,fieldName,fieldDefinition, new File(Tests.FOLDER_CONCESSIONI,"pos.shp")); parentPath,fieldName,fieldDefinition, new File(Tests.FOLDER_CONCESSIONI,"pos.shp"));
project = client.registerFileSet(project.getId(),fsRequest); return getClient().registerFileSet(project.getId(),fsRequest);
System.out.println("Resulting Project : "+project);
System.out.println("JSON Reprepsentation : "+ Serialization.write(project));
} }
} }

View File

@ -3,13 +3,26 @@ package org.gcube.application.geoportal.clients;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import lombok.Data; import lombok.Data;
import org.bson.Document; import org.bson.Document;
import org.gcube.application.cms.tests.TestDocuments;
import org.gcube.application.cms.tests.Tests;
import org.gcube.application.geoportal.client.utils.Serialization; import org.gcube.application.geoportal.client.utils.Serialization;
import org.gcube.application.geoportal.common.faults.InvalidRequestException;
import org.gcube.application.geoportal.common.model.document.Project; import org.gcube.application.geoportal.common.model.document.Project;
import org.gcube.application.geoportal.common.model.rest.RegisterFileSetRequest;
import org.gcube.application.geoportal.common.model.rest.StepExecutionRequest; import org.gcube.application.geoportal.common.model.rest.StepExecutionRequest;
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.HandlerDeclaration;
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor; import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
import org.gcube.application.geoportal.common.rest.Projects;
import org.gcube.application.geoportal.common.utils.FileSets;
import org.gcube.application.geoportal.common.utils.Files;
import org.gcube.application.geoportal.common.utils.StorageUtils;
import org.junit.Test; import org.junit.Test;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.charset.Charset;
import java.rmi.RemoteException; import java.rmi.RemoteException;
public class ProfiledConcessioniTest extends ProfiledDocumentsTest{ public class ProfiledConcessioniTest extends ProfiledDocumentsTest{
@ -36,12 +49,81 @@ public class ProfiledConcessioniTest extends ProfiledDocumentsTest{
} }
@Test @Test
public void performSubmit() throws RemoteException, JsonProcessingException { public void performSubmit() throws RemoteException, JsonProcessingException, FileNotFoundException, InvalidRequestException {
String id="630f912755e2947b0278c1be";
Project p = getClient().performStep(id,new StepExecutionRequest("SUBMIT-FOR-REVIEW",new Document())); Projects<Project> client = getClient();
Project p=client.createNew(getNewDocument());
p=prepareWithFileSet(p);
p = getClient().performStep(p.getId(), new StepExecutionRequest("SUBMIT-FOR-REVIEW",new Document()));
System.out.println("Result is "+Serialization.write(p)); System.out.println("Result is "+Serialization.write(p));
} }
@Override
protected Document getNewDocument() {
try {
String json = Files.readFileAsString(TestDocuments.BASE_FOLDER + "/basicConcessioneDocument.json", Charset.defaultCharset());
return Document.parse(json);
}catch (Throwable t){
throw new RuntimeException(t);
}
}
@Override
protected Project prepareWithFileSet(Project project) throws FileNotFoundException, InvalidRequestException, RemoteException {
Projects<Project> client = getClient();
// Set relazione
client.registerFileSet(project.getId(), FileSets.
prepareRequest(new StorageUtils(),
"$.relazioneScavo","fileset",
"$.relazioneScavo."+Field.CHILDREN+"[?(@.fileset)]",
new File(Tests.FOLDER_CONCESSIONI,"relazione.pdf")));
// Set Abstract
client.registerFileSet(project.getId(), FileSets.
prepareRequest(new StorageUtils(),
"$.abstractRelazione","filesetIta",
"$.abstractRelazione."+Field.CHILDREN+"[?(@.filesetIta)]",
new File(Tests.FOLDER_CONCESSIONI,"relazione.pdf")));
// Set pos
client.registerFileSet(project.getId(), FileSets.
prepareRequest(new StorageUtils(),
"$.posizionamentoScavo","fileset",
"$.posizionamentoScavo."+Field.CHILDREN+"[?(@.fileset)]",
new File(Tests.FOLDER_CONCESSIONI,"pos.shp"),
new File(Tests.FOLDER_CONCESSIONI,"pos.shx")));
// Add 2 imgs
for(int i=0;i<2;i++){
client.registerFileSet(project.getId(), FileSets.
prepareRequest(new StorageUtils(),
"$.immaginiRappresentative["+i+"]","fileset",
"$.immaginiRappresentative."+Field.CHILDREN+"[?(@.fileset)]",
new File(Tests.FOLDER_CONCESSIONI,"immagine"+(i+1)+".png")));
}
// Add 2 piante
for(int i=0;i<2;i++){
client.registerFileSet(project.getId(), FileSets.
prepareRequest(new StorageUtils(),
"$.pianteFineScavo["+i+"]","fileset",
"$.pianteFineScavo."+Field.CHILDREN+"[?(@.fileset)]",
new File(Tests.FOLDER_CONCESSIONI,"pianta.shp"),
new File(Tests.FOLDER_CONCESSIONI,"pianta.shx")));
}
return client.getById(project.getId());
}
} }

View File

@ -0,0 +1,65 @@
{
"nome": "TEST Castello di Ceparano",
"introduzione": "Scavi archeologici nel castello di Ceparano, situato su una collina posta ai margini della vallata del Marzeno, nel territorio del comune di Brisighella, conosciuto dalla metà del X secolo e abbandonato nel XVI secolo. Il progetto ha lobiettivo di definire se si tratti di un sito di nuova fondazione o se si tratta di un sito rurale altomedievale, trasformato in villaggio fortificato in un periodo successivo. Si intende inoltre chiarire la sua reale di estensione e funzione nel corso del tempo e verificare la presenza di strutture/insediamenti età precedente. ",
"descrizioneContenuto": "Relazione di fine scavo e relativo abstract; selezione di immagini rappresentative; posizionamento topografico dell'area indagata, pianta di fine scavo.",
"authors": [
"Enrico Cirelli (Disci, Alma Mater Studiorum - Università di Bologna)"
],
"contributore": "Enrico Cirelli",
"titolari": [
"Enrico Cirelli"
],
"responsabile": "Enrico Cirelli",
"editore": "Enrico Cirelli",
"fontiFinanziamento": [
"Alma Mater Studiorum - Università di Bologna"
],
"soggetto": [
"Research Excavation"
],
"risorseCorrelate": [
"E. Cirelli, Scavi archeologici nel castello di Ceparano, in 'Cristalli', 1-2019, pp. 20-29. https://www.academia.edu/36107675/SCAVI_NEL_CASTELLO_DI_CEPARANO"
],
"dataInizioProgetto": "2019-07-29T00:00:00",
"dataFineProgetto": "2019-08-30T00:00:00",
"titolareLicenza": [
"Enrico Cirelli"
],
"titolareCopyright": [
"Enrico Cirelli"
],
"paroleChiaveLibere": [
"Castello",
"Chiesa castrale",
"Pieve",
"Ossario",
"Sepolture"
],
"paroleChiaveICCD": [
"VI-VII",
"X-XVI"
],
"relazioneScavo": {
"titolo": "Castello di Ceparano relazione di scavo",
"responsabili": [
"Enrico Cirelli"
],
"soggetto": [
"Research Excavation"
]
},
"abstractRelazione": {
"titolo": "Castello di Ceparano abstract relazione di scavo"
},
"posizionamentoScavo": {
"titolo": "Posizionamento scavo"
},
"pianteFineScavo": [
{"titolo": "Pianta 1"},
{"titolo": "Pianta 2"}
],
"immaginiRappresentative": [
{"titolo": "Img 1"},
{"titolo": "Img 2"}
]
}

View File

@ -2,99 +2,206 @@
"_id": "profiledConcessioni", "_id": "profiledConcessioni",
"_version": "1.0.0", "_version": "1.0.0",
"_name": "Concessione", "_name": "Concessione",
"_schema": { "_schema": {
"abstractRelazione" : { "_min" : 1, "abstractRelazione": {
"_min": 1,
"_children": [ "_children": [
{"filesetIta" :{"_type" : "RegisteredFileSet", "_min": 1}}, {
{"filesetEng" :{"_type" : "RegisteredFileSet"}}, "filesetIta": {
{"title" : {"_min" : 1}} "_type": "RegisteredFileSet",
"_min": 1
}
},
{
"filesetEng": {
"_type": "RegisteredFileSet"
}
},
{
"title": {
"_min": 1
}
}
] ]
}, },
"relazioneScavo" : { "_max" : 1, "_min" : 1, "relazioneScavo": {
"_max": 1,
"_min": 1,
"_children": [ "_children": [
{"fileset" :{"_type" : "RegisteredFileSet", "_min": 1}}, {
{"title" : {"_min" : 1}} "fileset": {
"_type": "RegisteredFileSet",
"_min": 1
}
},
{
"title": {
"_min": 1
}
}
] ]
}, },
"immaginiRappresentative": { "immaginiRappresentative": {
"_max": 8, "_max": 8,
"_children": [ "_children": [
{"fileset" :{"_type" : "RegisteredFileSet","_min": 1}}, {
{"title" : {"_min" : 1}} "fileset": {
"_type": "RegisteredFileSet",
"_min": 1
}
},
{
"title": {
"_min": 1
}
}
] ]
}, },
"posizionamentoScavo" : { "_max" : 1, "_min" : 1, "posizionamentoScavo": {
"_max": 1,
"_min": 1,
"_children": [ "_children": [
{"fileset" :{"_type" : "RegisteredFileSet","_min": 1}}, {
{"title" : {"_min" : 1}} "fileset": {
"_type": "RegisteredFileSet",
"_min": 1
}
},
{
"title": {
"_min": 1
}
}
] ]
}, },
"pianteFineScavo" : { "_max" : -1, "pianteFineScavo": {
"_max": -1,
"_children": [ "_children": [
{"fileset" :{"_type" : "RegisteredFileSet","_min": 1}}, {
{"title" : {"_min" : 1}} "fileset": {
"_type": "RegisteredFileSet",
"_min": 1
}
},
{
"title": {
"_min": 1
}
}
] ]
} }
}, },
"_description": "Embedded profile for concessioni [mibac] management", "_description": "Embedded profile for concessioni [mibac] management",
"_creationInfo": { "_creationInfo": {
"_user": { "_user": {
"_username": "fabio.sinibaldi" "_username": "fabio.sinibaldi"
} }
}, },
"_dataAccessPolicies": [ "_dataAccessPolicies": [
{"_policy" : {"_read" : "any", "_write" : "any"}, "_roles":[]}, {
{"_policy" : {"_read" : "any", "_write" : "none"}, "_roles":["Guest"], "_policy": {
"_enforcer": {"_filter" : "{\"_lifecycleInformation._phase\" : {\"$eq\" : \"Published\"}}"}}, "_read": "any",
{"_policy" : {"_read" : "any", "_write" : "none"}, "_roles":["Admin"]}, "_write": "any"
{"_policy" : {"_read" : "any", "_write" : "any"}, "_roles":["Data-Manager"]} },
"_roles": []
},
{
"_policy": {
"_read": "any",
"_write": "none"
},
"_roles": [
"Guest"
],
"_enforcer": {
"_filter": "{\"_lifecycleInformation._phase\" : {\"$eq\" : \"Published\"}}"
}
},
{
"_policy": {
"_read": "any",
"_write": "none"
},
"_roles": [
"Admin"
]
},
{
"_policy": {
"_read": "any",
"_write": "any"
},
"_roles": [
"Data-Manager"
]
}
], ],
"_handlers": [ "_handlers": [
{ {
"_id": "GNA-CONCESSIONI-LC", "_id": "GNA-CONCESSIONI-LC",
"_type": "LifecycleManagement", "_type": "LifecycleManagement",
"_configuration": { "_configuration": {
"step_access": [ "step_access": [
{"STEP" : "SUBMIT-FOR-REVIEW", "roles" :[]}, {
{"STEP" : "REJECT-DRAFT", "roles" :["Data-Manager"]}, "STEP": "SUBMIT-FOR-REVIEW",
{"STEP" : "APPROVE-SUBMITTED", "roles" :["Data-Manager"]} "roles": []
},
{
"STEP": "REJECT-DRAFT",
"roles": [
"Data-Manager"
]
},
{
"STEP": "APPROVE-SUBMITTED",
"roles": [
"Data-Manager"
]
}
] ]
} }
}, },
{ {
"_id": "SDI-Default-Materializer", "_id": "SDI-Default-Materializer",
"_type": "Materializer", "_type": "Materializer",
"_configuration": { "_configuration": {
"registeredFileSetPaths": [ "registeredFileSetPaths": [
{"schemaField" : "pianteFineScavo","documentPath" : "pianteFineScavo[*].fileset"}, {
{"schemaField" : "posizionamentoScavo","documentPath" : "posizionamentoScavo.fileset"} "schemaField": "pianteFineScavo",
"documentPath": "pianteFineScavo[*].fileset"
},
{
"schemaField": "posizionamentoScavo",
"documentPath": "posizionamentoScavo.fileset"
}
] ]
} }
}, },
{ {
"_id": "SDI-Indexer-Plugin", "_id": "SDI-Indexer-Plugin",
"_type": "Indexer", "_type": "Indexer",
"_configuration": { "_configuration": {
"bboxEvaluation" : ["$..posizionamentoScavo.._bbox"], "bboxEvaluation": [
"$..posizionamentoScavo.._bbox"
],
"explicitFieldMapping": [ "explicitFieldMapping": [
{"name" : "titolo", "path" : "$._theDocument.title", "type" : "TEXT"} {
"name": "titolo",
"path": "$._theDocument.title",
"type": "TEXT"
}
], ],
"jslt": {}, "jslt": {},
"additionalLayers": [ "additionalLayers": [
{"source" : {"url" : "..."},"toSetTitle":""} {
"source": {
"url": "..."
},
"toSetTitle": ""
}
] ]
} }
}, },
{ {
"_id": "org.gcube.portlets.user.geoportal-data-entry-app", "_id": "org.gcube.portlets.user.geoportal-data-entry-app",
"_type": "DATA_ENTRY_GUI", "_type": "DATA_ENTRY_GUI",
@ -190,7 +297,6 @@
"saveStep": "SUBMIT-FOR-REVIEW" "saveStep": "SUBMIT-FOR-REVIEW"
} }
}, },
{ {
"_id": "org.gcube.portlets.user.geoportal-data-list", "_id": "org.gcube.portlets.user.geoportal-data-list",
"_type": "DATA_LIST_GUI", "_type": "DATA_LIST_GUI",
@ -291,8 +397,23 @@
"sortable": true, "sortable": true,
"asResult": false "asResult": false
} }
], ]
}
},
{
"_id": "org.gcube.portlets.user.geoportal-workflow-action-list",
"_type": "WORKFLOW_ACTION_LIST_GUI",
"_configuration": {
"actionsDefinition": [ "actionsDefinition": [
{
"id": "post_creation_action",
"title": "Post Creation Action",
"call_STEPS": [
"SUBMIT-FOR-REVIEW"
],
"description": "Action fired after the Project creation",
"display_on_phase": []
},
{ {
"id": "submit_for_review", "id": "submit_for_review",
"title": "Submit for Review", "title": "Submit for Review",
@ -301,7 +422,6 @@
], ],
"description": "Submit the Project (for review)", "description": "Submit the Project (for review)",
"display_on_phase": [ "display_on_phase": [
"REJECTED",
"DRAFT" "DRAFT"
] ]
}, },
@ -313,7 +433,7 @@
], ],
"description": "Reject the Project", "description": "Reject the Project",
"display_on_phase": [ "display_on_phase": [
"DRAFT" "Pending Approval"
] ]
}, },
{ {
@ -324,34 +444,17 @@
], ],
"description": "Approve the Project", "description": "Approve the Project",
"display_on_phase": [ "display_on_phase": [
"DRAFT" "Pending Approval"
] ]
}, }
{ ]
"id": "publish", }
"title": "Publish", }
"call_STEPS": [
"PUBLISH"
], ],
"description": "Publish the Project", "_relationshipDefinitions" : [
"display_on_phase": [ {"_id": "precedes", "_label" : "Precede",
"DRAFT", "_reverseRelationId" : "follows"},
"APPROVED" {"_id": "follows", "_label" : "Segue",
] "_reverseRelationId" : "precedes"}
},
{
"id": "unpublish",
"title": "Unpublish",
"call_STEPS": [
"UNPUBLISH"
],
"description": "Unpublish the Project",
"display_on_phase": [
"PUBLISHED"
]
}
]
}
}
] ]
} }