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

@ -1,100 +1,207 @@
{ {
"_id" : "profiledConcessioni", "_id": "profiledConcessioni",
"_version" : "1.0.0", "_version": "1.0.0",
"_name" : "Concessione", "_name": "Concessione",
"_schema": {
"_schema" : { "abstractRelazione": {
"abstractRelazione" : { "_min" : 1, "_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": {
"_children" : [ "_max": 1,
{"fileset" :{"_type" : "RegisteredFileSet", "_min": 1}}, "_min": 1,
{"title" : {"_min" : 1}} "_children": [
{
"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": {
"_children" : [ "_max": 1,
{"fileset" :{"_type" : "RegisteredFileSet","_min": 1}}, "_min": 1,
{"title" : {"_min" : 1}} "_children": [
{
"fileset": {
"_type": "RegisteredFileSet",
"_min": 1
}
},
{
"title": {
"_min": 1
}
}
] ]
}, },
"pianteFineScavo" : { "_max" : -1, "pianteFineScavo": {
"_children" : [ "_max": -1,
{"fileset" :{"_type" : "RegisteredFileSet","_min": 1}}, "_children": [
{"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": {
{"_policy" : {"_read" : "any", "_write" : "none"}, "_roles":["Guest"], "_read": "any",
"_enforcer": {"_filter" : "{\"_lifecycleInformation._phase\" : {\"$eq\" : \"Published\"}}"}}, "_write": "any"
{"_policy" : {"_read" : "any", "_write" : "none"}, "_roles":["Admin"]}, },
{"_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": [
"explicitFieldMapping" : [ "$..posizionamentoScavo.._bbox"
{"name" : "titolo", "path" : "$._theDocument.title", "type" : "TEXT"}
], ],
"jslt" : {}, "explicitFieldMapping": [
"additionalLayers" : [ {
{"source" : {"url" : "..."},"toSetTitle":""} "name": "titolo",
"path": "$._theDocument.title",
"type": "TEXT"
}
],
"jslt": {},
"additionalLayers": [
{
"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,168 +297,164 @@
"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", "_configuration": {
"_configuration": { "itemFields": [
"itemFields": [ {
{ "label": "Name",
"label": "Name", "paths": [
"paths": [ "_theDocument.nome"
"_theDocument.nome" ],
], "operator": "$and",
"operator": "$and", "searchable": true,
"searchable": true, "sortable": true,
"sortable": true, "asResult": true
"asResult": true },
}, {
{ "label": "Introduction",
"label": "Introduction", "paths": [
"paths": [ "_theDocument.introduzione"
"_theDocument.introduzione" ],
], "operator": "$and",
"operator": "$and", "searchable": true,
"searchable": true, "sortable": false,
"sortable": false, "asResult": true
"asResult": true },
}, {
{ "label": "Author/s",
"label": "Author/s", "paths": [
"paths": [ "_theDocument.authors"
"_theDocument.authors" ],
], "operator": "$and",
"operator": "$and", "searchable": false,
"searchable": false, "sortable": true,
"sortable": true, "asResult": true
"asResult": true },
}, {
{ "label": "Project Start",
"label": "Project Start", "paths": [
"paths": [ "_theDocument.dataInizioProgetto"
"_theDocument.dataInizioProgetto" ],
], "operator": "$and",
"operator": "$and", "searchable": false,
"searchable": false, "sortable": true,
"sortable": true, "asResult": true
"asResult": true },
}, {
{ "label": "Director/Staff",
"label": "Director/Staff", "paths": [
"paths": [ "_theDocument.authors",
"_theDocument.authors", "_theDocument.contributore",
"_theDocument.contributore", "_theDocument.titolari",
"_theDocument.titolari", "_theDocument.editore",
"_theDocument.editore", "_theDocument.responsabile"
"_theDocument.responsabile" ],
], "operator": "$or",
"operator": "$or", "searchable": true,
"searchable": true, "sortable": false,
"sortable": false, "asResult": true
"asResult": true },
}, {
{ "label": "Keywords",
"label": "Keywords", "paths": [
"paths": [ "_theDocument.paroleChiaveLibere",
"_theDocument.paroleChiaveLibere", "_theDocument.paroleChiaveICCD"
"_theDocument.paroleChiaveICCD" ],
], "operator": "$or",
"operator": "$or", "searchable": true,
"searchable": true, "sortable": false,
"sortable": false, "asResult": true
"asResult": true },
}, {
{ "label": "Creator",
"label": "Creator", "paths": [
"paths": [ "_info._creationInfo._user._username"
"_info._creationInfo._user._username" ],
], "operator": "$or",
"operator": "$or", "searchable": true,
"searchable": true, "sortable": false,
"sortable": false, "asResult": false
"asResult": false },
}, {
{ "label": "Phase",
"label": "Phase", "paths": [
"paths": [ "_lifecycleInformation._phase"
"_lifecycleInformation._phase" ],
], "operator": "$or",
"operator": "$or", "searchable": true,
"searchable": true, "sortable": true,
"sortable": true, "asResult": false
"asResult": false },
}, {
{ "label": "Status",
"label": "Status", "paths": [
"paths": [ "_lifecycleInformation._lastOperationStatus"
"_lifecycleInformation._lastOperationStatus" ],
], "operator": "$or",
"operator": "$or", "searchable": true,
"searchable": true, "sortable": true,
"sortable": true, "asResult": false
"asResult": false }
}
],
"actionsDefinition": [
{
"id": "submit_for_review",
"title": "Submit for Review",
"call_STEPS": [
"SUBMIT-FOR-REVIEW"
],
"description": "Submit the Project (for review)",
"display_on_phase": [
"REJECTED",
"DRAFT"
]
},
{
"id": "reject",
"title": "Reject",
"call_STEPS": [
"REJECT-DRAFT"
],
"description": "Reject the Project",
"display_on_phase": [
"DRAFT"
]
},
{
"id": "approve",
"title": "Approve",
"call_STEPS": [
"APPROVE-SUBMITTED"
],
"description": "Approve the Project",
"display_on_phase": [
"DRAFT"
]
},
{
"id": "publish",
"title": "Publish",
"call_STEPS": [
"PUBLISH"
],
"description": "Publish the Project",
"display_on_phase": [
"DRAFT",
"APPROVED"
]
},
{
"id": "unpublish",
"title": "Unpublish",
"call_STEPS": [
"UNPUBLISH"
],
"description": "Unpublish the Project",
"display_on_phase": [
"PUBLISHED"
] ]
} }
] },
} {
} "_id": "org.gcube.portlets.user.geoportal-workflow-action-list",
"_type": "WORKFLOW_ACTION_LIST_GUI",
"_configuration": {
"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",
"title": "Submit for Review",
"call_STEPS": [
"SUBMIT-FOR-REVIEW"
],
"description": "Submit the Project (for review)",
"display_on_phase": [
"DRAFT"
]
},
{
"id": "reject",
"title": "Reject",
"call_STEPS": [
"REJECT-DRAFT"
],
"description": "Reject the Project",
"display_on_phase": [
"Pending Approval"
]
},
{
"id": "approve",
"title": "Approve",
"call_STEPS": [
"APPROVE-SUBMITTED"
],
"description": "Approve the Project",
"display_on_phase": [
"Pending Approval"
]
}
]
}
}
],
"_relationshipDefinitions" : [
{"_id": "precedes", "_label" : "Precede",
"_reverseRelationId" : "follows"},
{"_id": "follows", "_label" : "Segue",
"_reverseRelationId" : "precedes"}
] ]
} }