diff --git a/.classpath b/.classpath deleted file mode 100644 index 5e8a55f..0000000 --- a/.classpath +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index e9441bb..0000000 --- a/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,3 +0,0 @@ -eclipse.preferences.version=1 -encoding//src/main/java=UTF-8 -encoding/=UTF-8 diff --git a/pom.xml b/pom.xml index 195fb46..51d87c6 100644 --- a/pom.xml +++ b/pom.xml @@ -57,6 +57,8 @@ 1.1 + + @@ -71,8 +73,25 @@ org.glassfish javax.json 1.1 + test + + + org.glassfish.jersey.media + jersey-media-json-jackson + test + + + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + 2.8.8 + test + + + ch.qos.logback logback-classic diff --git a/src/test/java/org/gcube/application/geoportal/common/model/SerializationTest.java b/src/test/java/org/gcube/application/geoportal/common/model/SerializationTest.java index 506b1f3..9c009d2 100644 --- a/src/test/java/org/gcube/application/geoportal/common/model/SerializationTest.java +++ b/src/test/java/org/gcube/application/geoportal/common/model/SerializationTest.java @@ -2,19 +2,37 @@ package org.gcube.application.geoportal.common.model; import java.io.FileInputStream; import java.io.FileNotFoundException; +import java.io.IOException; import javax.json.Json; import javax.json.JsonObject; import org.gcube.application.geoportal.common.faults.JsonParseException; +import org.gcube.application.geoportal.common.model.legacy.Concessione; import org.gcube.application.geoportal.common.model.profile.Profile; import org.gcube.application.geoportal.common.utils.Files; import org.junit.Assert; import org.junit.Test; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; + public class SerializationTest { + private static ObjectMapper mapper = new ObjectMapper(); + + static { + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,false); + mapper.configure(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS, false); + mapper.setSerializationInclusion(Include.NON_NULL); + // mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); + } + + @Test public void readProfile() throws FileNotFoundException, JsonParseException { JsonObject object=Json.createReader(new FileInputStream(Files.getFileFromResources("ProfileConcessioni.json"))).readObject(); @@ -28,4 +46,11 @@ public class SerializationTest { } + @Test + public void readConcessione() throws JsonProcessingException, IOException { + Concessione concessione=mapper.readerFor(Concessione.class).readValue( + Files.getFileFromResources("Concessione.json")); + System.out.println("Concessione is "+concessione.toString()); + + } } diff --git a/src/test/resources/Concessione.json b/src/test/resources/Concessione.json new file mode 100644 index 0000000..595f22e --- /dev/null +++ b/src/test/resources/Concessione.json @@ -0,0 +1,200 @@ +{ + "id": 1, + "recordType": "CONCESSIONE", + "version": "1.0.0", + "licenzaID": "CC-BY", + "policy": "OPEN", + "nome": "Italia, forse", + "folderId": "2f1bcd4b-fc3d-48c5-aa3b-064c68ba94c9", + "lastUpdateTime": [ + 2020, + 11, + 17, + 12, + 19, + 58, + 418000000 + ], + "lastUpdateUser": "NO NAME", + "creationTime": [ + 2020, + 11, + 17, + 12, + 19, + 58, + 418000000 + ], + "creationUser": "NO NAME", + "introduzione": "This is my project", + "descrizioneContenuto": "It contains this and that", + "authors": [ + "Some one", + "Some, oneelse" + ], + "contributore": "Contrib 1", + "titolari": [ + "Some one", + "Some, oneelse" + ], + "responsabile": "Someone", + "editore": "Editore", + "fontiFinanziamento": [ + "Big pharma", + "Pentagon" + ], + "soggetto": [ + "Research Excavation", + "Archeology" + ], + "risorseCorrelate": [], + "dataInizioProgetto": [ + 2020, + 11, + 17, + 12, + 19, + 40, + 741000000 + ], + "dataFineProgetto": [ + 2020, + 11, + 17, + 12, + 19, + 40, + 752000000 + ], + "titolareLicenza": "Qualcun altro", + "titolareCopyright": "Chiedilo in giro", + "paroleChiaveLibere": [ + "Robba", + "Stuff" + ], + "paroleChiaveICCD": [ + "vattelapesca", + "somthing something" + ], + "centroidLat": 43.0, + "centroidLong": 9.0, + "relazioneScavo": { + "id": 11, + "policy": "OPEN", + "licenseID": "CC-BY", + "titolo": "Italia, forse relazione di scavo", + "creationTime": [ + 2020, + 11, + 17, + 12, + 19, + 58, + 418000000 + ], + "record": null, + "actualContent": [ + { + "id": 16, + "associated": null, + "mimetype": "application/pdf", + "storageID": "78ec815e-cc0e-4a61-8248-8eebe8c7c6be", + "link": "https://data.dev.d4science.org/shub/E_K0lSY05ja0s2N2hkVkxzWTVRSGN0MWZ4UFFOQnFTZHgraytOK05lcHZ2d002aGQ1Z2grZkE5d1ZmTUc5V3diLw==" + } + ], + "abstractSection": "simple abstract section", + "responsabili": [ + "Some one", + "Some, oneelse" + ], + "soggetto": [ + "Research Excavation", + "Archeology" + ] + }, + "immaginiRappresentative": [], + "posizionamentoScavo": { + "id": 10, + "policy": "OPEN", + "licenseID": "CC-BY", + "titolo": "Italia, forse posizionamento scavo", + "creationTime": [ + 2020, + 11, + 17, + 12, + 19, + 58, + 418000000 + ], + "record": null, + "actualContent": [ + { + "id": 11, + "associated": null, + "mimetype": "application/x-dbf", + "storageID": "6c6ab4c4-5691-4652-9010-485ec8f1fc3d", + "link": "https://data.dev.d4science.org/shub/E_OThaZC9lRkk5cVprcjBwZlBFS1NyZEtvcjNTekFJYjVoZUdXalQweGI2emJzZ3cxNTFoUUJNbUs1YXRKLzA0bg==" + }, + { + "id": 12, + "associated": null, + "mimetype": "text/plain", + "storageID": "10b8fbce-89a1-4a76-9e91-17c08c45c8ca", + "link": "https://data.dev.d4science.org/shub/E_eEo2NEV5WHl6RDhVSUMvWm1NTndwOW5FTjZaSkdPVjR0MFBiclNWWTBCbUJXUjA1ZmNVbU00N3FXeU5JQVdnLw==" + }, + { + "id": 13, + "associated": null, + "mimetype": "text/plain", + "storageID": "435380a5-812d-4bef-b0f1-f0e89cd93730", + "link": "https://data.dev.d4science.org/shub/E_YTMyTDU5cVBxSWRkZEFuYi9hTVQ2ZUxtbnNyYU9KcUNydFl6dk5jbkhYWHk2ODAwUDZuemE5M2xVT2RPZDA5MA==" + }, + { + "id": 14, + "associated": null, + "mimetype": "application/x-shapefile", + "storageID": "04a284fe-c6f2-4dd6-8c9c-06cc1ebbefb8", + "link": "https://data.dev.d4science.org/shub/E_UXRlN0F0OUdWazdCNElORExJUlppL0JEMjdkcHIvNWNDNGdtejNBQkxQTFlySERlWnQySUVDSkVTWHJHblRtdg==" + }, + { + "id": 15, + "associated": null, + "mimetype": "application/x-shapefile", + "storageID": "285882cd-7922-4755-b7f2-95fe72960425", + "link": "https://data.dev.d4science.org/shub/E_aFlKbkhhREE3VlQ3TzZRMzlNK2YrODYxamFsclRmOWZKL1FYS1BzbjIvYWNBMjNnK2pyQzZTZUVKODUrRjBlTQ==" + } + ], + "layerUUID": null, + "layerID": null, + "layerName": null, + "wmsLink": null, + "abstractSection": "Posizionamento topografico georeferenziato dell’area interessata dalle indagini", + "topicCategory": "Society", + "subTopic": "Archeology", + "bbox": { + "maxLat": 90.0, + "maxLong": 180.0, + "minLat": -90.0, + "minLong": -180.0 + }, + "paroleChiaveLibere": [ + "Robba", + "Stuff" + ], + "paroleChiaveICCD": [ + "vattelapesca", + "somthing something" + ], + "valutazioneQualita": "Secondo me si", + "metodoRaccoltaDati": "Fattobbene", + "scalaAcquisizione": "1:10000", + "authors": [ + "Some one", + "Some, oneelse" + ], + "responsabile": "Someone" + }, + "pianteFineScavo": [], + "genericContent": [] +} \ No newline at end of file