From 8a572aad8f3df1646628ccb9832b9f78d0120b97 Mon Sep 17 00:00:00 2001 From: Fabio Sinibaldi Date: Fri, 2 Oct 2020 17:56:54 +0200 Subject: [PATCH] Model and refactoring --- CHANGELOG.md | 6 +- .../geoportal/AbstractRecordManager.java | 1 - .../geoportal/ArchiveManagerImpl.java | 5 +- .../geoportal/ConcessioneManager.java | 16 +- .../geoportal/PostgisDBManager.java | 8 +- .../geoportal/PostgisDBManagerI.java | 5 +- .../geoportal/PostgisTableFactory.java | 4 +- .../gcube/application/geoportal/Uploader.java | 8 +- .../geoportal/model/AccessPolicy.java | 7 + .../geoportal/model/ArchiveDescriptor.java | 27 +- .../geoportal/model/AssociatedContent.java | 31 --- .../application/geoportal/model/Record.java | 176 +++--------- .../model/concessioni/Concessione.java | 261 ++++++++++++++---- .../model/concessioni/LayerConcessione.java | 132 +++++++++ .../model/concessioni/RelazioneScavo.java | 75 +++++ .../model/content/AssociatedContent.java | 102 +++++++ .../model/content/GeoServerContent.java | 28 ++ .../geoportal/model/content/OtherContent.java | 20 ++ .../model/content/PersistedContent.java | 31 +++ .../model/content/UploadedImage.java | 79 ++++++ .../model/content/WorkspaceContent.java | 23 ++ .../geoportal/model/db/PostgisTable.java | 53 +--- .../{ => fault}/DataParsingException.java | 2 +- .../GeoPackageInteractionException.java | 2 +- .../{ => fault}/InvalidRecordException.java | 2 +- .../model/{ => fault}/PublishException.java | 2 +- .../application/geoportal/model/gis/BBOX.java | 38 +++ .../geoportal/model/gis/LayerDescriptor.java | 18 -- .../model/gis/SDILayerDescriptor.java | 28 ++ .../model/gis/ShapeFileLayerDescriptor.java | 12 + .../application/geoportal/utils/CSV.java | 2 +- .../geoportal/utils/CollectionsUtils.java | 14 + .../application/geoportal/utils/DBUtils.java | 45 +++ .../geoportal/utils/GpkgUtils.java | 2 +- .../application/geoportal/utils/Layers.java | 4 +- .../application/geoportal/CSVToPostgis.java | 2 +- .../geoportal/GeopackageTests.java | 4 +- .../application/geoportal/PostgisMockup.java | 4 +- .../geoportal/SerializationTests.java | 143 +++++++--- .../geoportal/UploadGpkgTable.java | 4 +- .../geoportal/db/ParsingTests.java | 6 +- src/test/resources/META-INF/persistence.xml | 8 +- 42 files changed, 1046 insertions(+), 394 deletions(-) create mode 100644 src/main/java/org/gcube/application/geoportal/model/AccessPolicy.java delete mode 100644 src/main/java/org/gcube/application/geoportal/model/AssociatedContent.java create mode 100644 src/main/java/org/gcube/application/geoportal/model/concessioni/LayerConcessione.java create mode 100644 src/main/java/org/gcube/application/geoportal/model/concessioni/RelazioneScavo.java create mode 100644 src/main/java/org/gcube/application/geoportal/model/content/AssociatedContent.java create mode 100644 src/main/java/org/gcube/application/geoportal/model/content/GeoServerContent.java create mode 100644 src/main/java/org/gcube/application/geoportal/model/content/OtherContent.java create mode 100644 src/main/java/org/gcube/application/geoportal/model/content/PersistedContent.java create mode 100644 src/main/java/org/gcube/application/geoportal/model/content/UploadedImage.java create mode 100644 src/main/java/org/gcube/application/geoportal/model/content/WorkspaceContent.java rename src/main/java/org/gcube/application/geoportal/model/{ => fault}/DataParsingException.java (93%) rename src/main/java/org/gcube/application/geoportal/model/{gis => fault}/GeoPackageInteractionException.java (93%) rename src/main/java/org/gcube/application/geoportal/model/{ => fault}/InvalidRecordException.java (93%) rename src/main/java/org/gcube/application/geoportal/model/{ => fault}/PublishException.java (94%) create mode 100644 src/main/java/org/gcube/application/geoportal/model/gis/BBOX.java create mode 100644 src/main/java/org/gcube/application/geoportal/model/gis/SDILayerDescriptor.java create mode 100644 src/main/java/org/gcube/application/geoportal/model/gis/ShapeFileLayerDescriptor.java create mode 100644 src/main/java/org/gcube/application/geoportal/utils/DBUtils.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a2713e..66f43de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -# Changelog for "geoportal-logic" +# Changelog for org.gcube.application.geoportal-logic + +## [1.0.0-SNAPSHOT] - 2020-09-25 + +First release diff --git a/src/main/java/org/gcube/application/geoportal/AbstractRecordManager.java b/src/main/java/org/gcube/application/geoportal/AbstractRecordManager.java index 7e73ee4..bd3a6a3 100644 --- a/src/main/java/org/gcube/application/geoportal/AbstractRecordManager.java +++ b/src/main/java/org/gcube/application/geoportal/AbstractRecordManager.java @@ -13,5 +13,4 @@ public abstract class AbstractRecordManager { }; - } diff --git a/src/main/java/org/gcube/application/geoportal/ArchiveManagerImpl.java b/src/main/java/org/gcube/application/geoportal/ArchiveManagerImpl.java index 0e3af78..dc1e9f7 100644 --- a/src/main/java/org/gcube/application/geoportal/ArchiveManagerImpl.java +++ b/src/main/java/org/gcube/application/geoportal/ArchiveManagerImpl.java @@ -86,8 +86,9 @@ public class ArchiveManagerImpl implements ArchiveManager { @Override public ArchiveDescriptor getByLayerId(long layerId) { EntityManager em=emf.createEntityManager(); - try{ - return em.find(LayerDescriptor.class, layerId).getArchive(); + try{ + return null; +// return em.find(LayerDescriptor.class, layerId).getArchive(); }finally { em.close(); } diff --git a/src/main/java/org/gcube/application/geoportal/ConcessioneManager.java b/src/main/java/org/gcube/application/geoportal/ConcessioneManager.java index a21bb88..de0c024 100644 --- a/src/main/java/org/gcube/application/geoportal/ConcessioneManager.java +++ b/src/main/java/org/gcube/application/geoportal/ConcessioneManager.java @@ -1,23 +1,13 @@ package org.gcube.application.geoportal; -import org.gcube.application.geoportal.model.Record; import org.gcube.application.geoportal.model.concessioni.Concessione; -public class ConcessioneManager extends AbstractRecordManager { - - public ConcessioneManager() { - // TODO Auto-generated constructor stub - } - +public class ConcessioneManager extends AbstractRecordManager { + @Override - public Record updateInfo(Record updatedInfoRecord) { + public Concessione updateInfo(Concessione updatedInfoRecord) { // TODO Auto-generated method stub return null; } - - @Override - public Concessione getRecord() { - return (Concessione) super.getRecord(); - } } diff --git a/src/main/java/org/gcube/application/geoportal/PostgisDBManager.java b/src/main/java/org/gcube/application/geoportal/PostgisDBManager.java index 1105105..054f352 100644 --- a/src/main/java/org/gcube/application/geoportal/PostgisDBManager.java +++ b/src/main/java/org/gcube/application/geoportal/PostgisDBManager.java @@ -7,10 +7,12 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -import org.gcube.application.geoportal.model.DataParsingException; import org.gcube.application.geoportal.model.MOSI; import org.gcube.application.geoportal.model.db.DatabaseConnection; import org.gcube.application.geoportal.model.db.PostgisTable; +import org.gcube.application.geoportal.model.fault.DataParsingException; +import org.gcube.application.geoportal.model.gis.BBOX; +import org.gcube.application.geoportal.utils.DBUtils; import lombok.extern.slf4j.Slf4j; @@ -86,10 +88,10 @@ public class PostgisDBManager implements PostgisDBManagerI { * @see org.gcube.application.geoportal.PostgisDBManagerI#evaluateBoundingBox(org.gcube.application.geoportal.model.PostgisTable) */ @Override - public PostgisTable.BBOX evaluateBoundingBox(PostgisTable table) throws SQLException, DataParsingException { + public BBOX evaluateBoundingBox(PostgisTable table) throws SQLException, DataParsingException { ResultSet rs=conn.createStatement().executeQuery("Select ST_Extent("+table.getGeometryColumn()+") as extent from "+table.getTablename()); if(rs.next()) - return PostgisTable.BBOX.parseST_Extent(rs.getString("extent")); + return DBUtils.parseST_Extent(rs.getString("extent")); else throw new SQLException("No extent returned"); } diff --git a/src/main/java/org/gcube/application/geoportal/PostgisDBManagerI.java b/src/main/java/org/gcube/application/geoportal/PostgisDBManagerI.java index 83986d1..26b113b 100644 --- a/src/main/java/org/gcube/application/geoportal/PostgisDBManagerI.java +++ b/src/main/java/org/gcube/application/geoportal/PostgisDBManagerI.java @@ -4,9 +4,10 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -import org.gcube.application.geoportal.model.DataParsingException; import org.gcube.application.geoportal.model.db.PostgisTable; import org.gcube.application.geoportal.model.db.PostgisTable.POINT; +import org.gcube.application.geoportal.model.fault.DataParsingException; +import org.gcube.application.geoportal.model.gis.BBOX; public interface PostgisDBManagerI { @@ -16,7 +17,7 @@ public interface PostgisDBManagerI { // int deleteCentroid(String uuid) throws SQLException; - PostgisTable.BBOX evaluateBoundingBox(PostgisTable table) throws SQLException, DataParsingException; + BBOX evaluateBoundingBox(PostgisTable table) throws SQLException, DataParsingException; PreparedStatement prepareInsertStatement(PostgisTable target, boolean createTable, boolean geometryAsText) throws SQLException; diff --git a/src/main/java/org/gcube/application/geoportal/PostgisTableFactory.java b/src/main/java/org/gcube/application/geoportal/PostgisTableFactory.java index dfab4fb..b5a7f46 100644 --- a/src/main/java/org/gcube/application/geoportal/PostgisTableFactory.java +++ b/src/main/java/org/gcube/application/geoportal/PostgisTableFactory.java @@ -11,14 +11,14 @@ import java.util.UUID; import org.apache.commons.csv.CSVParser; import org.apache.commons.csv.CSVRecord; -import org.gcube.application.geoportal.model.DataParsingException; import org.gcube.application.geoportal.model.db.DBConstants; import org.gcube.application.geoportal.model.db.DBInteractionException; import org.gcube.application.geoportal.model.db.PostgisTable; import org.gcube.application.geoportal.model.db.PostgisTable.Field; import org.gcube.application.geoportal.model.db.PostgisTable.FieldType; import org.gcube.application.geoportal.model.db.PostgisTable.GeometryType; -import org.gcube.application.geoportal.model.gis.GeoPackageInteractionException; +import org.gcube.application.geoportal.model.fault.DataParsingException; +import org.gcube.application.geoportal.model.fault.GeoPackageInteractionException; import org.gcube.application.geoportal.utils.CSV; import org.gcube.application.geoportal.utils.GpkgUtils; diff --git a/src/main/java/org/gcube/application/geoportal/Uploader.java b/src/main/java/org/gcube/application/geoportal/Uploader.java index 16b1cdf..3e25598 100644 --- a/src/main/java/org/gcube/application/geoportal/Uploader.java +++ b/src/main/java/org/gcube/application/geoportal/Uploader.java @@ -19,11 +19,11 @@ import org.gcube.application.geoportal.model.ArchiveDescriptor.ArchiveType; import org.gcube.application.geoportal.model.db.DBConstants; import org.gcube.application.geoportal.model.db.DBInteractionException; import org.gcube.application.geoportal.model.db.PostgisTable; -import org.gcube.application.geoportal.model.gis.GeoPackageInteractionException; +import org.gcube.application.geoportal.model.fault.DataParsingException; +import org.gcube.application.geoportal.model.fault.GeoPackageInteractionException; +import org.gcube.application.geoportal.model.fault.InvalidRecordException; import org.gcube.application.geoportal.model.gis.LayerDescriptor; import org.gcube.application.geoportal.model.Configuration; -import org.gcube.application.geoportal.model.DataParsingException; -import org.gcube.application.geoportal.model.InvalidRecordException; import org.gcube.application.geoportal.utils.GpkgUtils; import org.gcube.application.geoportal.utils.Layers; import org.gcube.spatial.data.geonetwork.GeoNetworkPublisher; @@ -178,7 +178,7 @@ public class Uploader { //Fill archive details toRegister.setVersion("1.0.0"); for(LayerDescriptor layer:layers) - toRegister.addLayer(layer); +// toRegister.addLayer(layer); //store archive info into app DB archiveManager.store(toRegister); diff --git a/src/main/java/org/gcube/application/geoportal/model/AccessPolicy.java b/src/main/java/org/gcube/application/geoportal/model/AccessPolicy.java new file mode 100644 index 0000000..0328a62 --- /dev/null +++ b/src/main/java/org/gcube/application/geoportal/model/AccessPolicy.java @@ -0,0 +1,7 @@ +package org.gcube.application.geoportal.model; + +public enum AccessPolicy { + + OPEN,RESTRICTED,EMBARGOED; + +} diff --git a/src/main/java/org/gcube/application/geoportal/model/ArchiveDescriptor.java b/src/main/java/org/gcube/application/geoportal/model/ArchiveDescriptor.java index 5f3b4ef..aab0299 100644 --- a/src/main/java/org/gcube/application/geoportal/model/ArchiveDescriptor.java +++ b/src/main/java/org/gcube/application/geoportal/model/ArchiveDescriptor.java @@ -13,6 +13,7 @@ import javax.persistence.Id; import javax.persistence.OneToMany; import javax.persistence.Table; +import org.gcube.application.geoportal.model.content.AssociatedContent; import org.gcube.application.geoportal.model.db.DBConstants; import org.gcube.application.geoportal.model.gis.LayerDescriptor; @@ -53,13 +54,13 @@ public class ArchiveDescriptor { private String archiveLocation; - @OneToMany(cascade=CascadeType.ALL, mappedBy="archive", fetch=FetchType.EAGER) +// @OneToMany(cascade=CascadeType.ALL, mappedBy="archive", fetch=FetchType.EAGER) private List attachments; // meta private String metadataID; - @OneToMany(mappedBy="archive", cascade=CascadeType.ALL, fetch=FetchType.EAGER) +// @OneToMany(mappedBy="archive", cascade=CascadeType.ALL, fetch=FetchType.EAGER) private List layers; @@ -70,17 +71,17 @@ public class ArchiveDescriptor { } - public void addLayer(LayerDescriptor layer) { - if(layers==null) layers=new ArrayList(); - - if(!getLayers().contains(layer)) { - getLayers().add(layer); - if(layer.getArchive()!=null) { - layer.getArchive().getLayers().remove(layer); - } - } - layer.setArchive(this); - } +// public void addLayer(LayerDescriptor layer) { +// if(layers==null) layers=new ArrayList(); +// +// if(!getLayers().contains(layer)) { +// getLayers().add(layer); +// if(layer.getArchive()!=null) { +// layer.getArchive().getLayers().remove(layer); +// } +// } +// layer.setArchive(this); +// } } diff --git a/src/main/java/org/gcube/application/geoportal/model/AssociatedContent.java b/src/main/java/org/gcube/application/geoportal/model/AssociatedContent.java deleted file mode 100644 index 1023dc5..0000000 --- a/src/main/java/org/gcube/application/geoportal/model/AssociatedContent.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.gcube.application.geoportal.model; - -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; - -import lombok.ToString; - -@Entity -@ToString -public class AssociatedContent { - - public static enum ContentType{ - METADATA_EXCEL,ATTACHMENT - } - - @Id - @GeneratedValue - private long id; - - private String name; - private ContentType type; - private String itemID; - private String link; - - @ManyToOne - @JoinColumn(name="archive_uuid", nullable=false) - private ArchiveDescriptor archive; -} diff --git a/src/main/java/org/gcube/application/geoportal/model/Record.java b/src/main/java/org/gcube/application/geoportal/model/Record.java index 6956db1..114ce3a 100644 --- a/src/main/java/org/gcube/application/geoportal/model/Record.java +++ b/src/main/java/org/gcube/application/geoportal/model/Record.java @@ -1,12 +1,20 @@ package org.gcube.application.geoportal.model; -import java.util.List; +import java.util.Date; -import org.apache.commons.collections4.CollectionUtils; -import org.gcube.application.geoportal.model.gis.LayerDescriptor; -import org.gcube.application.geoportal.utils.CollectionsUtils; +import javax.persistence.DiscriminatorColumn; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +import javax.persistence.Table; + +import org.gcube.application.geoportal.utils.Serialization; + +import com.fasterxml.jackson.core.JsonProcessingException; -import jersey.repackaged.com.google.common.collect.Lists; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; @@ -15,153 +23,33 @@ import lombok.ToString; @Getter @Setter @ToString -public class Record { +@Entity +@Table(name = "RECORD") +@Inheritance(strategy = InheritanceType.SINGLE_TABLE) +@DiscriminatorColumn(name = "RECORD_TYPE") +@EqualsAndHashCode +public abstract class Record { + //Generic Info + @Id @GeneratedValue(strategy=GenerationType.IDENTITY) + private long id; + - protected String id; protected RecordType recordType; + protected String version="1.0.0"; + + //Storage Info protected String folderId; - protected String lastUpdateTime; + + //Accounting + protected Date lastUpdateTime; protected String lastUpdateUser; - protected String creationTime; + protected Date creationTime; protected String creationUser; - protected String version; - protected String license; - protected String titolareLicenza; - protected String dirittiAccessoDati; - //one to many - protected List attachments; - - //one to many - protected List layers; - - - protected Double centroidLat; - protected Double centroidLong; - @Override - public int hashCode() { - final int prime = 31; - int result = 1; -// result = prime * result + ((attachments == null) ? 0 : attachments.hashCode()); - if(attachments!=null || attachments.isEmpty()) - result = prime * result +0; - else { - for(AssociatedContent c:attachments) - result = prime * result + c.hashCode(); - } - -// result = prime * result + ((layers == null) ? 0 : layers.hashCode()); - if(layers!=null || layers.isEmpty()) - result = prime * result +0; - else { - for(LayerDescriptor l:layers) - result = prime * result + l.hashCode(); - } - - - - result = prime * result + ((centroidLat == null) ? 0 : centroidLat.hashCode()); - result = prime * result + ((centroidLong == null) ? 0 : centroidLong.hashCode()); - result = prime * result + ((creationTime == null) ? 0 : creationTime.hashCode()); - result = prime * result + ((creationUser == null) ? 0 : creationUser.hashCode()); - result = prime * result + ((dirittiAccessoDati == null) ? 0 : dirittiAccessoDati.hashCode()); - result = prime * result + ((folderId == null) ? 0 : folderId.hashCode()); - result = prime * result + ((id == null) ? 0 : id.hashCode()); - result = prime * result + ((lastUpdateTime == null) ? 0 : lastUpdateTime.hashCode()); - result = prime * result + ((lastUpdateUser == null) ? 0 : lastUpdateUser.hashCode()); - result = prime * result + ((license == null) ? 0 : license.hashCode()); - result = prime * result + ((recordType == null) ? 0 : recordType.hashCode()); - result = prime * result + ((titolareLicenza == null) ? 0 : titolareLicenza.hashCode()); - result = prime * result + ((version == null) ? 0 : version.hashCode()); - return result; + public String asJson() throws JsonProcessingException { + return Serialization.asJSON(this); } - - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Record other = (Record) obj; - - if(!CollectionsUtils.equalsCollections(attachments, other.attachments)) - return false; - - if(!CollectionsUtils.equalsCollections(layers, other.layers)) - return false; - - - if (centroidLat == null) { - if (other.centroidLat != null) - return false; - } else if (!centroidLat.equals(other.centroidLat)) - return false; - if (centroidLong == null) { - if (other.centroidLong != null) - return false; - } else if (!centroidLong.equals(other.centroidLong)) - return false; - if (creationTime == null) { - if (other.creationTime != null) - return false; - } else if (!creationTime.equals(other.creationTime)) - return false; - if (creationUser == null) { - if (other.creationUser != null) - return false; - } else if (!creationUser.equals(other.creationUser)) - return false; - if (dirittiAccessoDati == null) { - if (other.dirittiAccessoDati != null) - return false; - } else if (!dirittiAccessoDati.equals(other.dirittiAccessoDati)) - return false; - if (folderId == null) { - if (other.folderId != null) - return false; - } else if (!folderId.equals(other.folderId)) - return false; - if (id == null) { - if (other.id != null) - return false; - } else if (!id.equals(other.id)) - return false; - if (lastUpdateTime == null) { - if (other.lastUpdateTime != null) - return false; - } else if (!lastUpdateTime.equals(other.lastUpdateTime)) - return false; - if (lastUpdateUser == null) { - if (other.lastUpdateUser != null) - return false; - } else if (!lastUpdateUser.equals(other.lastUpdateUser)) - return false; - - if (license == null) { - if (other.license != null) - return false; - } else if (!license.equals(other.license)) - return false; - if (recordType != other.recordType) - return false; - if (titolareLicenza == null) { - if (other.titolareLicenza != null) - return false; - } else if (!titolareLicenza.equals(other.titolareLicenza)) - return false; - if (version == null) { - if (other.version != null) - return false; - } else if (!version.equals(other.version)) - return false; - return true; - } - - } diff --git a/src/main/java/org/gcube/application/geoportal/model/concessioni/Concessione.java b/src/main/java/org/gcube/application/geoportal/model/concessioni/Concessione.java index 52f5204..2fc3a89 100644 --- a/src/main/java/org/gcube/application/geoportal/model/concessioni/Concessione.java +++ b/src/main/java/org/gcube/application/geoportal/model/concessioni/Concessione.java @@ -1,8 +1,15 @@ package org.gcube.application.geoportal.model.concessioni; +import java.util.Date; import java.util.List; +import javax.persistence.DiscriminatorValue; +import javax.persistence.Entity; + import org.gcube.application.geoportal.model.Record; +import org.gcube.application.geoportal.model.RecordType; +import org.gcube.application.geoportal.model.content.OtherContent; +import org.gcube.application.geoportal.model.content.UploadedImage; import org.gcube.application.geoportal.utils.CollectionsUtils; import lombok.Getter; @@ -12,126 +19,268 @@ import lombok.ToString; @Getter @Setter @ToString(callSuper=true) + +@Entity +@DiscriminatorValue("CONCESSIONE") public class Concessione extends Record{ - + //Nome del progetto private String nome; - private String descrizione; + + //Introduzione (descrizione del progetto) + private String introduzione; + + //Descrizione del contenuto + private String descrizioneContenuto; + + //Autori private List authors; + + //Soggetto che materialmente invia i dati. private String contributore; - private String titolare; + + //Indicare il nome del titolare/i dei dati contenuti nel dataset e/o per sue specifiche parti. + private List titolari; + private String responsabile; private String editore; - private List keywords; - private String fonti; - private String soggetto; - private List dateScavo; + private List fontiFinanaziamento; + + //Research Excavation; Archaeology (valori di default) + private List soggetto; + + + //Referenze bibliografiche, DOI (se esistenti) di risorse correlate all’indagine in oggetto + private List risorseCorrelate; + + + private Date dataInizioScavo; + private Date dataFineScavo; + + private String titolareLicenza; + private String titolareCopyright; + + + private List paroleChiaveLibere; + private List paroleChiaveICCD; + + + private Double centroidLat; + private Double centroidLong; + + + + private RelazioneScavo relazioneScavo; + private List immaginiRappresentative; + private LayerConcessione posizionamentoScavo; + private List pianteFineScavo; + private List genericContent; + + + public Concessione() { + setRecordType(RecordType.CONCESSIONE); + } + @Override public int hashCode() { final int prime = 31; - int result = super.hashCode(); + int result = 1; // result = prime * result + ((authors == null) ? 0 : authors.hashCode()); - if(authors!=null || authors.isEmpty()) - result = prime * result +0; - else { - for(String c:authors) - result = prime * result + c.hashCode(); - } - -// result = prime * result + ((dateScavo == null) ? 0 : dateScavo.hashCode()); - if(dateScavo!=null || dateScavo.isEmpty()) - result = prime * result +0; - else { - for(String c:dateScavo) - result = prime * result + c.hashCode(); - } - -// result = prime * result + ((keywords == null) ? 0 : keywords.hashCode()); - if(keywords!=null || keywords.isEmpty()) - result = prime * result +0; - else { - for(String c:keywords) - result = prime * result + c.hashCode(); - } - - + result = prime * result + CollectionsUtils.hashCode(authors); +// result = prime * result + ((fontiFinanaziamento == null) ? 0 : fontiFinanaziamento.hashCode()); + result = prime * result + CollectionsUtils.hashCode(fontiFinanaziamento); +// result = prime * result + ((immaginiRappresentative == null) ? 0 : immaginiRappresentative.hashCode()); + result = prime * result + CollectionsUtils.hashCode(immaginiRappresentative); +// result = prime * result + ((paroleChiaveICCD == null) ? 0 : paroleChiaveICCD.hashCode()); + result = prime * result + CollectionsUtils.hashCode(paroleChiaveICCD); +// result = prime * result + ((paroleChiaveLibere == null) ? 0 : paroleChiaveLibere.hashCode()); + result = prime * result + CollectionsUtils.hashCode(paroleChiaveLibere); +// result = prime * result + ((pianteFineScavo == null) ? 0 : pianteFineScavo.hashCode()); + result = prime * result + CollectionsUtils.hashCode(pianteFineScavo); +// result = prime * result + ((risorseCorrelate == null) ? 0 : risorseCorrelate.hashCode()); + result = prime * result + CollectionsUtils.hashCode(risorseCorrelate); +// result = prime * result + ((soggetto == null) ? 0 : soggetto.hashCode()); + result = prime * result + CollectionsUtils.hashCode(soggetto); +// result = prime * result + ((titolari == null) ? 0 : titolari.hashCode()); + result = prime * result + CollectionsUtils.hashCode(titolari); + result = prime * result + ((centroidLat == null) ? 0 : centroidLat.hashCode()); + result = prime * result + ((centroidLong == null) ? 0 : centroidLong.hashCode()); result = prime * result + ((contributore == null) ? 0 : contributore.hashCode()); - result = prime * result + ((descrizione == null) ? 0 : descrizione.hashCode()); + result = prime * result + ((dataFineScavo == null) ? 0 : dataFineScavo.hashCode()); + result = prime * result + ((dataInizioScavo == null) ? 0 : dataInizioScavo.hashCode()); + result = prime * result + ((descrizioneContenuto == null) ? 0 : descrizioneContenuto.hashCode()); result = prime * result + ((editore == null) ? 0 : editore.hashCode()); - result = prime * result + ((fonti == null) ? 0 : fonti.hashCode()); + result = prime * result + ((genericContent == null) ? 0 : genericContent.hashCode()); + result = prime * result + ((introduzione == null) ? 0 : introduzione.hashCode()); result = prime * result + ((nome == null) ? 0 : nome.hashCode()); + + result = prime * result + ((posizionamentoScavo == null) ? 0 : posizionamentoScavo.hashCode()); + result = prime * result + ((relazioneScavo == null) ? 0 : relazioneScavo.hashCode()); result = prime * result + ((responsabile == null) ? 0 : responsabile.hashCode()); - result = prime * result + ((soggetto == null) ? 0 : soggetto.hashCode()); - result = prime * result + ((titolare == null) ? 0 : titolare.hashCode()); + result = prime * result + ((titolareCopyright == null) ? 0 : titolareCopyright.hashCode()); + result = prime * result + ((titolareLicenza == null) ? 0 : titolareLicenza.hashCode()); return result; } + @Override public boolean equals(Object obj) { if (this == obj) return true; - if (!super.equals(obj)) + if (obj == null) return false; if (getClass() != obj.getClass()) return false; Concessione other = (Concessione) obj; +// if (authors == null) { +// if (other.authors != null) +// return false; +// } else if (!authors.equals(other.authors)) +// return false; + if(!CollectionsUtils.equalsCollections(authors, other.authors)) return false; - if(!CollectionsUtils.equalsCollections(authors, other.authors)) - return false; +// if (fontiFinanaziamento == null) { +// if (other.fontiFinanaziamento != null) +// return false; +// } else if (!fontiFinanaziamento.equals(other.fontiFinanaziamento)) +// return false; + if (!CollectionsUtils.equalsCollections(fontiFinanaziamento, other.fontiFinanaziamento)) return false; + +// if (immaginiRappresentative == null) { +// if (other.immaginiRappresentative != null) +// return false; +// } else if (!immaginiRappresentative.equals(other.immaginiRappresentative)) +// return false; + if (!CollectionsUtils.equalsCollections(immaginiRappresentative, other.immaginiRappresentative)) return false; + +// if (paroleChiaveICCD == null) { +// if (other.paroleChiaveICCD != null) +// return false; +// } else if (!paroleChiaveICCD.equals(other.paroleChiaveICCD)) +// return false; + if (!CollectionsUtils.equalsCollections(paroleChiaveICCD, other.paroleChiaveICCD)) return false; + +// if (paroleChiaveLibere == null) { +// if (other.paroleChiaveLibere != null) +// return false; +// } else if (!paroleChiaveLibere.equals(other.paroleChiaveLibere)) +// return false; + if (!CollectionsUtils.equalsCollections(paroleChiaveLibere, other.paroleChiaveLibere)) return false; + +// if (piantaFineScavo == null) { +// if (other.piantaFineScavo != null) +// return false; +// } else if (!piantaFineScavo.equals(other.piantaFineScavo)) +// return false; + if (!CollectionsUtils.equalsCollections(pianteFineScavo, other.pianteFineScavo)) return false; + +// if (risorseCorrelate == null) { +// if (other.risorseCorrelate != null) +// return false; +// } else if (!risorseCorrelate.equals(other.risorseCorrelate)) +// return false; + if (!CollectionsUtils.equalsCollections(risorseCorrelate, other.risorseCorrelate)) return false; + +// if (soggetto == null) { +// if (other.soggetto != null) +// return false; +// } else if (!soggetto.equals(other.soggetto)) +// return false; + if (!CollectionsUtils.equalsCollections(soggetto, other.soggetto)) return false; + +// if (titolari == null) { +// if (other.titolari != null) +// return false; +// } else if (!titolari.equals(other.titolari)) +// return false; + if (!CollectionsUtils.equalsCollections(titolari, other.titolari)) return false; - if(!CollectionsUtils.equalsCollections(dateScavo, other.dateScavo)) - return false; - if(!CollectionsUtils.equalsCollections(keywords, other.keywords)) + if (centroidLat == null) { + if (other.centroidLat != null) + return false; + } else if (!centroidLat.equals(other.centroidLat)) + return false; + if (centroidLong == null) { + if (other.centroidLong != null) + return false; + } else if (!centroidLong.equals(other.centroidLong)) return false; - if (contributore == null) { if (other.contributore != null) return false; } else if (!contributore.equals(other.contributore)) return false; - if (descrizione == null) { - if (other.descrizione != null) + if (dataFineScavo == null) { + if (other.dataFineScavo != null) return false; - } else if (!descrizione.equals(other.descrizione)) + } else if (!dataFineScavo.equals(other.dataFineScavo)) + return false; + if (dataInizioScavo == null) { + if (other.dataInizioScavo != null) + return false; + } else if (!dataInizioScavo.equals(other.dataInizioScavo)) + return false; + if (descrizioneContenuto == null) { + if (other.descrizioneContenuto != null) + return false; + } else if (!descrizioneContenuto.equals(other.descrizioneContenuto)) return false; if (editore == null) { if (other.editore != null) return false; } else if (!editore.equals(other.editore)) return false; - if (fonti == null) { - if (other.fonti != null) + if (genericContent == null) { + if (other.genericContent != null) return false; - } else if (!fonti.equals(other.fonti)) + } else if (!genericContent.equals(other.genericContent)) + return false; + if (introduzione == null) { + if (other.introduzione != null) + return false; + } else if (!introduzione.equals(other.introduzione)) return false; if (nome == null) { if (other.nome != null) return false; } else if (!nome.equals(other.nome)) return false; + + + if (posizionamentoScavo == null) { + if (other.posizionamentoScavo != null) + return false; + } else if (!posizionamentoScavo.equals(other.posizionamentoScavo)) + return false; + if (relazioneScavo == null) { + if (other.relazioneScavo != null) + return false; + } else if (!relazioneScavo.equals(other.relazioneScavo)) + return false; if (responsabile == null) { if (other.responsabile != null) return false; } else if (!responsabile.equals(other.responsabile)) return false; - if (soggetto == null) { - if (other.soggetto != null) + if (titolareCopyright == null) { + if (other.titolareCopyright != null) return false; - } else if (!soggetto.equals(other.soggetto)) + } else if (!titolareCopyright.equals(other.titolareCopyright)) return false; - if (titolare == null) { - if (other.titolare != null) + if (titolareLicenza == null) { + if (other.titolareLicenza != null) return false; - } else if (!titolare.equals(other.titolare)) + } else if (!titolareLicenza.equals(other.titolareLicenza)) return false; + return true; } - + } diff --git a/src/main/java/org/gcube/application/geoportal/model/concessioni/LayerConcessione.java b/src/main/java/org/gcube/application/geoportal/model/concessioni/LayerConcessione.java new file mode 100644 index 0000000..0f3482a --- /dev/null +++ b/src/main/java/org/gcube/application/geoportal/model/concessioni/LayerConcessione.java @@ -0,0 +1,132 @@ +package org.gcube.application.geoportal.model.concessioni; + +import java.util.List; + +import javax.persistence.DiscriminatorValue; +import javax.persistence.Entity; + +import org.gcube.application.geoportal.model.gis.BBOX; +import org.gcube.application.geoportal.model.gis.SDILayerDescriptor; +import org.gcube.application.geoportal.utils.CollectionsUtils; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + + +@Getter +@Setter +@ToString(callSuper=true) + +@Entity +@DiscriminatorValue("LAYER_CONCESSIONE") +public class LayerConcessione extends SDILayerDescriptor{ + + //1.Identificazione + private String titolo; + private String abstractSection; + + //2.Classificazione + private String topicCategory; + + //3.Keyword + private String subTopic; + + //4. Delimitazione geographica + private BBOX bbox; + + //5. Temporal + + + //6. Quality + private String valutazioneQualita; + + private String metodoRaccoltaDati; + + private String scalaAcquisizione; + + //8. Responsabili + private List authors; + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((abstractSection == null) ? 0 : abstractSection.hashCode()); +// result = prime * result + ((authors == null) ? 0 : authors.hashCode()); + result = prime * result + CollectionsUtils.hashCode(authors); + + + result = prime * result + ((bbox == null) ? 0 : bbox.hashCode()); + result = prime * result + ((metodoRaccoltaDati == null) ? 0 : metodoRaccoltaDati.hashCode()); + result = prime * result + ((scalaAcquisizione == null) ? 0 : scalaAcquisizione.hashCode()); + result = prime * result + ((subTopic == null) ? 0 : subTopic.hashCode()); + result = prime * result + ((titolo == null) ? 0 : titolo.hashCode()); + result = prime * result + ((topicCategory == null) ? 0 : topicCategory.hashCode()); + result = prime * result + ((valutazioneQualita == null) ? 0 : valutazioneQualita.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + LayerConcessione other = (LayerConcessione) obj; + if (abstractSection == null) { + if (other.abstractSection != null) + return false; + } else if (!abstractSection.equals(other.abstractSection)) + return false; +// if (authors == null) { +// if (other.authors != null) +// return false; +// } else if (!authors.equals(other.authors)) +// return false; + if(!CollectionsUtils.equalsCollections(authors, other.authors)) return false; + + + if (bbox == null) { + if (other.bbox != null) + return false; + } else if (!bbox.equals(other.bbox)) + return false; + if (metodoRaccoltaDati == null) { + if (other.metodoRaccoltaDati != null) + return false; + } else if (!metodoRaccoltaDati.equals(other.metodoRaccoltaDati)) + return false; + if (scalaAcquisizione == null) { + if (other.scalaAcquisizione != null) + return false; + } else if (!scalaAcquisizione.equals(other.scalaAcquisizione)) + return false; + if (subTopic == null) { + if (other.subTopic != null) + return false; + } else if (!subTopic.equals(other.subTopic)) + return false; + if (titolo == null) { + if (other.titolo != null) + return false; + } else if (!titolo.equals(other.titolo)) + return false; + if (topicCategory == null) { + if (other.topicCategory != null) + return false; + } else if (!topicCategory.equals(other.topicCategory)) + return false; + if (valutazioneQualita == null) { + if (other.valutazioneQualita != null) + return false; + } else if (!valutazioneQualita.equals(other.valutazioneQualita)) + return false; + return true; + } + + + +} diff --git a/src/main/java/org/gcube/application/geoportal/model/concessioni/RelazioneScavo.java b/src/main/java/org/gcube/application/geoportal/model/concessioni/RelazioneScavo.java new file mode 100644 index 0000000..4d83542 --- /dev/null +++ b/src/main/java/org/gcube/application/geoportal/model/concessioni/RelazioneScavo.java @@ -0,0 +1,75 @@ +package org.gcube.application.geoportal.model.concessioni; + +import java.util.List; + +import javax.persistence.DiscriminatorValue; +import javax.persistence.Entity; + +import org.gcube.application.geoportal.model.content.AssociatedContent; +import org.gcube.application.geoportal.utils.CollectionsUtils; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString(callSuper=true) + +@Entity +@DiscriminatorValue("RELAZIONE") +public class RelazioneScavo extends AssociatedContent { + + + + private String abstractSection; + private List responsabili; + + private List soggetto; + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((abstractSection == null) ? 0 : abstractSection.hashCode()); +// result = prime * result + ((responsabili == null) ? 0 : responsabili.hashCode()); + result = prime * result + CollectionsUtils.hashCode(responsabili); +// result = prime * result + ((soggetto == null) ? 0 : soggetto.hashCode()); + result = prime * result + CollectionsUtils.hashCode(soggetto); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + RelazioneScavo other = (RelazioneScavo) obj; + if (abstractSection == null) { + if (other.abstractSection != null) + return false; + } else if (!abstractSection.equals(other.abstractSection)) + return false; +// if (responsabili == null) { +// if (other.responsabili != null) +// return false; +// } else if (!responsabili.equals(other.responsabili)) +// return false; + if(!CollectionsUtils.equalsCollections(responsabili, other.responsabili)) return false; + + +// if (soggetto == null) { +// if (other.soggetto != null) +// return false; +// } else if (!soggetto.equals(other.soggetto)) +// return false; + if(!CollectionsUtils.equalsCollections(soggetto, other.soggetto)) return false; + + + return true; + } + +} diff --git a/src/main/java/org/gcube/application/geoportal/model/content/AssociatedContent.java b/src/main/java/org/gcube/application/geoportal/model/content/AssociatedContent.java new file mode 100644 index 0000000..7bbe66b --- /dev/null +++ b/src/main/java/org/gcube/application/geoportal/model/content/AssociatedContent.java @@ -0,0 +1,102 @@ +package org.gcube.application.geoportal.model.content; + +import java.util.Date; +import java.util.List; + +import javax.persistence.DiscriminatorColumn; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +import javax.persistence.Table; + +import org.gcube.application.geoportal.model.AccessPolicy; +import org.gcube.application.geoportal.utils.CollectionsUtils; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@ToString +@Getter +@Setter +@Entity +@Table(name = "CONTENT") +@Inheritance(strategy = InheritanceType.SINGLE_TABLE) +@DiscriminatorColumn(name = "CONTENT_TYPE") +public abstract class AssociatedContent { + + @Id + @GeneratedValue(strategy=GenerationType.IDENTITY) + private long id; + + private AccessPolicy policy; + private String licenseID; + private String titolo; + private Date creationTime; + + + + private List actualContent; + + + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; +// result = prime * result + ((actualContent == null) ? 0 : actualContent.hashCode()); + result = prime * result + CollectionsUtils.hashCode(actualContent); + + result = prime * result + ((creationTime == null) ? 0 : creationTime.hashCode()); + result = prime * result + (int) (id ^ (id >>> 32)); + result = prime * result + ((licenseID == null) ? 0 : licenseID.hashCode()); + result = prime * result + ((policy == null) ? 0 : policy.hashCode()); + result = prime * result + ((titolo == null) ? 0 : titolo.hashCode()); + return result; + } + + + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + AssociatedContent other = (AssociatedContent) obj; +// if (actualContent == null) { +// if (other.actualContent != null) +// return false; +// } else if (!actualContent.equals(other.actualContent)) +// return false; + if(!CollectionsUtils.equalsCollections(actualContent, other.actualContent)) return false; + + if (creationTime == null) { + if (other.creationTime != null) + return false; + } else if (!creationTime.equals(other.creationTime)) + return false; + if (id != other.id) + return false; + if (licenseID == null) { + if (other.licenseID != null) + return false; + } else if (!licenseID.equals(other.licenseID)) + return false; + if (policy != other.policy) + return false; + if (titolo == null) { + if (other.titolo != null) + return false; + } else if (!titolo.equals(other.titolo)) + return false; + return true; + } + + +} diff --git a/src/main/java/org/gcube/application/geoportal/model/content/GeoServerContent.java b/src/main/java/org/gcube/application/geoportal/model/content/GeoServerContent.java new file mode 100644 index 0000000..dead468 --- /dev/null +++ b/src/main/java/org/gcube/application/geoportal/model/content/GeoServerContent.java @@ -0,0 +1,28 @@ +package org.gcube.application.geoportal.model.content; + +import javax.persistence.DiscriminatorValue; +import javax.persistence.Entity; + +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString(callSuper=true) + +@Entity +@DiscriminatorValue("GEOSERVER") +@EqualsAndHashCode(callSuper=true) +public class GeoServerContent extends PersistedContent{ + + //GeoServer Details + private String geoserverHostName; + + private String geoserverPath; + + private String filename; + + +} diff --git a/src/main/java/org/gcube/application/geoportal/model/content/OtherContent.java b/src/main/java/org/gcube/application/geoportal/model/content/OtherContent.java new file mode 100644 index 0000000..2e7606c --- /dev/null +++ b/src/main/java/org/gcube/application/geoportal/model/content/OtherContent.java @@ -0,0 +1,20 @@ +package org.gcube.application.geoportal.model.content; + +import javax.persistence.DiscriminatorValue; +import javax.persistence.Entity; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString(callSuper=true) + +@Entity +@DiscriminatorValue("OTHER") +public class OtherContent extends AssociatedContent { + + + +} diff --git a/src/main/java/org/gcube/application/geoportal/model/content/PersistedContent.java b/src/main/java/org/gcube/application/geoportal/model/content/PersistedContent.java new file mode 100644 index 0000000..fd46254 --- /dev/null +++ b/src/main/java/org/gcube/application/geoportal/model/content/PersistedContent.java @@ -0,0 +1,31 @@ +package org.gcube.application.geoportal.model.content; + +import javax.persistence.DiscriminatorColumn; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +import javax.persistence.Table; + +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@ToString +@Getter +@Setter +@Entity +@Table(name = "PERSISTED_CONTENT") +@Inheritance(strategy = InheritanceType.SINGLE_TABLE) +@DiscriminatorColumn(name = "CONTENT_TYPE") +@EqualsAndHashCode +public abstract class PersistedContent { + + @Id + @GeneratedValue(strategy=GenerationType.IDENTITY) + private long id; + +} diff --git a/src/main/java/org/gcube/application/geoportal/model/content/UploadedImage.java b/src/main/java/org/gcube/application/geoportal/model/content/UploadedImage.java new file mode 100644 index 0000000..ed2f9da --- /dev/null +++ b/src/main/java/org/gcube/application/geoportal/model/content/UploadedImage.java @@ -0,0 +1,79 @@ +package org.gcube.application.geoportal.model.content; + +import java.util.List; + +import javax.persistence.DiscriminatorValue; +import javax.persistence.Entity; + +import org.gcube.application.geoportal.utils.CollectionsUtils; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString(callSuper=true) + +@Entity +@DiscriminatorValue("IMAGE") +public class UploadedImage extends AssociatedContent { + + + private String didascalia; + private String format; + + private List responsabili; + + private List soggetto; + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((didascalia == null) ? 0 : didascalia.hashCode()); + result = prime * result + ((format == null) ? 0 : format.hashCode()); +// result = prime * result + ((responsabili == null) ? 0 : responsabili.hashCode()); + result = prime * result + CollectionsUtils.hashCode(responsabili); +// result = prime * result + ((soggetto == null) ? 0 : soggetto.hashCode()); + result = prime * result + CollectionsUtils.hashCode(soggetto); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + UploadedImage other = (UploadedImage) obj; + if (didascalia == null) { + if (other.didascalia != null) + return false; + } else if (!didascalia.equals(other.didascalia)) + return false; + if (format == null) { + if (other.format != null) + return false; + } else if (!format.equals(other.format)) + return false; +// if (responsabili == null) { +// if (other.responsabili != null) +// return false; +// } else if (!responsabili.equals(other.responsabili)) +// return false; + if(!CollectionsUtils.equalsCollections(responsabili, other.responsabili)) return false; + +// if (soggetto == null) { +// if (other.soggetto != null) +// return false; +// } else if (!soggetto.equals(other.soggetto)) +// return false; + if(!CollectionsUtils.equalsCollections(soggetto, other.soggetto)) return false; + + return true; + } + +} diff --git a/src/main/java/org/gcube/application/geoportal/model/content/WorkspaceContent.java b/src/main/java/org/gcube/application/geoportal/model/content/WorkspaceContent.java new file mode 100644 index 0000000..9427502 --- /dev/null +++ b/src/main/java/org/gcube/application/geoportal/model/content/WorkspaceContent.java @@ -0,0 +1,23 @@ +package org.gcube.application.geoportal.model.content; + +import javax.persistence.DiscriminatorValue; +import javax.persistence.Entity; + +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString(callSuper=true) + +@Entity +@DiscriminatorValue("WORKSPACE") +@EqualsAndHashCode(callSuper=true) +public class WorkspaceContent extends PersistedContent{ + + private String mimetype; + private String storageID; + private String link; +} diff --git a/src/main/java/org/gcube/application/geoportal/model/db/PostgisTable.java b/src/main/java/org/gcube/application/geoportal/model/db/PostgisTable.java index 22538f1..d999111 100644 --- a/src/main/java/org/gcube/application/geoportal/model/db/PostgisTable.java +++ b/src/main/java/org/gcube/application/geoportal/model/db/PostgisTable.java @@ -12,7 +12,8 @@ import java.util.Map.Entry; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.gcube.application.geoportal.model.DataParsingException; +import org.gcube.application.geoportal.model.fault.DataParsingException; +import org.gcube.application.geoportal.model.gis.BBOX; import lombok.AllArgsConstructor; import lombok.Getter; @@ -70,56 +71,6 @@ public class PostgisTable { } - @RequiredArgsConstructor - @Getter - @ToString - public static class BBOX{ - - public static BBOX WORLD_EXTENT=new BBOX(90d,180d,-90d,-180d); - - - private static Pattern pattern = Pattern.compile("(?!=\\d\\.\\d\\.)([\\d.]+)"); - - public static BBOX parseST_Extent(String extent) throws DataParsingException { - //BOX(11.9122574810083 44.2514144864263,11.9761128271586 44.2912342569845) - try { - log.debug("Parsing BBOX "+extent); - Matcher m=pattern.matcher(extent); - - // Scanner sc = new Scanner(extent); - // double minLong = sc.nextDouble(), - // minLat = sc.nextDouble(), - // maxLong = sc.nextDouble(), - // maxLat= sc.nextDouble(); - - if(!m.find()) throw new DataParsingException("Unable to get minLong "); - Double minLong=Double.parseDouble(m.group(1)); - - if(!m.find()) throw new DataParsingException("Unable to get minLat "); - Double minLat=Double.parseDouble(m.group(1)); - - if(!m.find()) throw new DataParsingException("Unable to get maxLong "); - Double maxLong=Double.parseDouble(m.group(1)); - - if(!m.find()) throw new DataParsingException("Unable to get maxLat "); - Double maxLat=Double.parseDouble(m.group(1)); - return new BBOX(maxLat, maxLong, minLat, minLong); - }catch(Throwable t) { - throw new DataParsingException("Invalid BBOX "+extent,t); - } - } - - @NonNull - private Double maxLat; - @NonNull - private Double maxLong; - @NonNull - private Double minLat; - @NonNull - private Double minLong; - } - - @RequiredArgsConstructor @Getter @ToString diff --git a/src/main/java/org/gcube/application/geoportal/model/DataParsingException.java b/src/main/java/org/gcube/application/geoportal/model/fault/DataParsingException.java similarity index 93% rename from src/main/java/org/gcube/application/geoportal/model/DataParsingException.java rename to src/main/java/org/gcube/application/geoportal/model/fault/DataParsingException.java index 1178630..ec17ec7 100644 --- a/src/main/java/org/gcube/application/geoportal/model/DataParsingException.java +++ b/src/main/java/org/gcube/application/geoportal/model/fault/DataParsingException.java @@ -1,4 +1,4 @@ -package org.gcube.application.geoportal.model; +package org.gcube.application.geoportal.model.fault; public class DataParsingException extends Exception { diff --git a/src/main/java/org/gcube/application/geoportal/model/gis/GeoPackageInteractionException.java b/src/main/java/org/gcube/application/geoportal/model/fault/GeoPackageInteractionException.java similarity index 93% rename from src/main/java/org/gcube/application/geoportal/model/gis/GeoPackageInteractionException.java rename to src/main/java/org/gcube/application/geoportal/model/fault/GeoPackageInteractionException.java index 53a9c7a..c5c6fb7 100644 --- a/src/main/java/org/gcube/application/geoportal/model/gis/GeoPackageInteractionException.java +++ b/src/main/java/org/gcube/application/geoportal/model/fault/GeoPackageInteractionException.java @@ -1,4 +1,4 @@ -package org.gcube.application.geoportal.model.gis; +package org.gcube.application.geoportal.model.fault; public class GeoPackageInteractionException extends Exception { diff --git a/src/main/java/org/gcube/application/geoportal/model/InvalidRecordException.java b/src/main/java/org/gcube/application/geoportal/model/fault/InvalidRecordException.java similarity index 93% rename from src/main/java/org/gcube/application/geoportal/model/InvalidRecordException.java rename to src/main/java/org/gcube/application/geoportal/model/fault/InvalidRecordException.java index bb6907b..cc0bc13 100644 --- a/src/main/java/org/gcube/application/geoportal/model/InvalidRecordException.java +++ b/src/main/java/org/gcube/application/geoportal/model/fault/InvalidRecordException.java @@ -1,4 +1,4 @@ -package org.gcube.application.geoportal.model; +package org.gcube.application.geoportal.model.fault; public class InvalidRecordException extends Exception { diff --git a/src/main/java/org/gcube/application/geoportal/model/PublishException.java b/src/main/java/org/gcube/application/geoportal/model/fault/PublishException.java similarity index 94% rename from src/main/java/org/gcube/application/geoportal/model/PublishException.java rename to src/main/java/org/gcube/application/geoportal/model/fault/PublishException.java index 15736f6..5d270c8 100644 --- a/src/main/java/org/gcube/application/geoportal/model/PublishException.java +++ b/src/main/java/org/gcube/application/geoportal/model/fault/PublishException.java @@ -1,4 +1,4 @@ -package org.gcube.application.geoportal.model; +package org.gcube.application.geoportal.model.fault; import org.gcube.spatial.data.gis.model.report.PublishResponse; diff --git a/src/main/java/org/gcube/application/geoportal/model/gis/BBOX.java b/src/main/java/org/gcube/application/geoportal/model/gis/BBOX.java new file mode 100644 index 0000000..8d8bdc0 --- /dev/null +++ b/src/main/java/org/gcube/application/geoportal/model/gis/BBOX.java @@ -0,0 +1,38 @@ +package org.gcube.application.geoportal.model.gis; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.eclipse.persistence.annotations.HashPartitioning; +import org.gcube.application.geoportal.model.fault.DataParsingException; + +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; +import lombok.ToString; +import lombok.extern.slf4j.Slf4j; + +@RequiredArgsConstructor +@Getter +@ToString +@Slf4j +@NoArgsConstructor +@EqualsAndHashCode +public class BBOX{ + + public static BBOX WORLD_EXTENT=new BBOX(90d,180d,-90d,-180d); + + + + + @NonNull + private Double maxLat; + @NonNull + private Double maxLong; + @NonNull + private Double minLat; + @NonNull + private Double minLong; +} \ No newline at end of file diff --git a/src/main/java/org/gcube/application/geoportal/model/gis/LayerDescriptor.java b/src/main/java/org/gcube/application/geoportal/model/gis/LayerDescriptor.java index 2c5a6a6..b0221e4 100644 --- a/src/main/java/org/gcube/application/geoportal/model/gis/LayerDescriptor.java +++ b/src/main/java/org/gcube/application/geoportal/model/gis/LayerDescriptor.java @@ -15,17 +15,12 @@ import lombok.NonNull; import lombok.RequiredArgsConstructor; import lombok.Setter; -@Entity @Getter @Setter @RequiredArgsConstructor @NoArgsConstructor public class LayerDescriptor { - @Id @GeneratedValue(strategy=GenerationType.IDENTITY) - private long id; - - @NonNull private String metaUUID; @NonNull @@ -37,17 +32,4 @@ public class LayerDescriptor { @NonNull private String tableName; - - - @ManyToOne - @JoinColumn(name="archive") - private ArchiveDescriptor archive; - - @Override - public String toString() { - return "LayerDescriptor [id=" + id + ", metaUUID=" + metaUUID + ", metaID=" + metaID + ", layerName=" - + layerName + ", geoserverWorkspace=" + geoserverWorkspace + ", tableName=" + tableName + "]"; - } - - } diff --git a/src/main/java/org/gcube/application/geoportal/model/gis/SDILayerDescriptor.java b/src/main/java/org/gcube/application/geoportal/model/gis/SDILayerDescriptor.java new file mode 100644 index 0000000..d086e66 --- /dev/null +++ b/src/main/java/org/gcube/application/geoportal/model/gis/SDILayerDescriptor.java @@ -0,0 +1,28 @@ +package org.gcube.application.geoportal.model.gis; + +import org.gcube.application.geoportal.model.content.AssociatedContent; + +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + + +@Getter +@Setter +@ToString(callSuper=true) +@EqualsAndHashCode(callSuper=true) +public abstract class SDILayerDescriptor extends AssociatedContent{ + + //meta + private String layerUUID; + private Long layerID; + + //layer + private String layerName; + private String wmsLink; + + + + +} diff --git a/src/main/java/org/gcube/application/geoportal/model/gis/ShapeFileLayerDescriptor.java b/src/main/java/org/gcube/application/geoportal/model/gis/ShapeFileLayerDescriptor.java new file mode 100644 index 0000000..d29fffa --- /dev/null +++ b/src/main/java/org/gcube/application/geoportal/model/gis/ShapeFileLayerDescriptor.java @@ -0,0 +1,12 @@ +package org.gcube.application.geoportal.model.gis; + +import java.util.List; + +import javax.persistence.Entity; + +@Entity +public class ShapeFileLayerDescriptor extends SDILayerDescriptor{ + + + +} diff --git a/src/main/java/org/gcube/application/geoportal/utils/CSV.java b/src/main/java/org/gcube/application/geoportal/utils/CSV.java index 015dd37..869ce0d 100644 --- a/src/main/java/org/gcube/application/geoportal/utils/CSV.java +++ b/src/main/java/org/gcube/application/geoportal/utils/CSV.java @@ -11,10 +11,10 @@ import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVParser; import org.apache.commons.csv.CSVRecord; import org.gcube.application.geoportal.PostgisDBManager; -import org.gcube.application.geoportal.model.DataParsingException; import org.gcube.application.geoportal.model.db.DBInteractionException; import org.gcube.application.geoportal.model.db.PostgisTable; import org.gcube.application.geoportal.model.db.PostgisTable.GeometryType; +import org.gcube.application.geoportal.model.fault.DataParsingException; import lombok.extern.slf4j.Slf4j; diff --git a/src/main/java/org/gcube/application/geoportal/utils/CollectionsUtils.java b/src/main/java/org/gcube/application/geoportal/utils/CollectionsUtils.java index c07c220..bdd4729 100644 --- a/src/main/java/org/gcube/application/geoportal/utils/CollectionsUtils.java +++ b/src/main/java/org/gcube/application/geoportal/utils/CollectionsUtils.java @@ -1,6 +1,7 @@ package org.gcube.application.geoportal.utils; import java.util.Collection; +import java.util.Iterator; import org.apache.commons.collections4.CollectionUtils; @@ -16,4 +17,17 @@ public class CollectionsUtils { return CollectionUtils.isEqualCollection(a,b); } + public static int hashCode(Collection a) { + if(a==null || a.isEmpty()) + return 0; + + final int prime = 31; + int result = 1; + + Iterator it=a.iterator(); + while(it.hasNext()) + result=prime*result+it.next().hashCode(); + return result; + } + } diff --git a/src/main/java/org/gcube/application/geoportal/utils/DBUtils.java b/src/main/java/org/gcube/application/geoportal/utils/DBUtils.java new file mode 100644 index 0000000..a5cb547 --- /dev/null +++ b/src/main/java/org/gcube/application/geoportal/utils/DBUtils.java @@ -0,0 +1,45 @@ +package org.gcube.application.geoportal.utils; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.gcube.application.geoportal.model.fault.DataParsingException; +import org.gcube.application.geoportal.model.gis.BBOX; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public class DBUtils { + + + private static Pattern pattern = Pattern.compile("(?!=\\d\\.\\d\\.)([\\d.]+)"); + + public static BBOX parseST_Extent(String extent) throws DataParsingException { + //BOX(11.9122574810083 44.2514144864263,11.9761128271586 44.2912342569845) + try { + log.debug("Parsing BBOX "+extent); + Matcher m=pattern.matcher(extent); + + // Scanner sc = new Scanner(extent); + // double minLong = sc.nextDouble(), + // minLat = sc.nextDouble(), + // maxLong = sc.nextDouble(), + // maxLat= sc.nextDouble(); + + if(!m.find()) throw new DataParsingException("Unable to get minLong "); + Double minLong=Double.parseDouble(m.group(1)); + + if(!m.find()) throw new DataParsingException("Unable to get minLat "); + Double minLat=Double.parseDouble(m.group(1)); + + if(!m.find()) throw new DataParsingException("Unable to get maxLong "); + Double maxLong=Double.parseDouble(m.group(1)); + + if(!m.find()) throw new DataParsingException("Unable to get maxLat "); + Double maxLat=Double.parseDouble(m.group(1)); + return new BBOX(maxLat, maxLong, minLat, minLong); + }catch(Throwable t) { + throw new DataParsingException("Invalid BBOX "+extent,t); + } + } +} diff --git a/src/main/java/org/gcube/application/geoportal/utils/GpkgUtils.java b/src/main/java/org/gcube/application/geoportal/utils/GpkgUtils.java index 2b92ba8..9b8cd49 100644 --- a/src/main/java/org/gcube/application/geoportal/utils/GpkgUtils.java +++ b/src/main/java/org/gcube/application/geoportal/utils/GpkgUtils.java @@ -5,9 +5,9 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.gcube.application.geoportal.model.InvalidRecordException; import org.gcube.application.geoportal.model.MOSI; import org.gcube.application.geoportal.model.db.PostgisTable.Field; +import org.gcube.application.geoportal.model.fault.InvalidRecordException; import lombok.extern.slf4j.Slf4j; import mil.nga.geopackage.GeoPackage; diff --git a/src/main/java/org/gcube/application/geoportal/utils/Layers.java b/src/main/java/org/gcube/application/geoportal/utils/Layers.java index 742ef74..a46365a 100644 --- a/src/main/java/org/gcube/application/geoportal/utils/Layers.java +++ b/src/main/java/org/gcube/application/geoportal/utils/Layers.java @@ -9,9 +9,9 @@ import org.gcube.application.geoportal.PostgisDBManagerI; import org.gcube.application.geoportal.model.MOSI; import org.gcube.application.geoportal.model.MOSI.Extent_Type; import org.gcube.application.geoportal.model.db.PostgisTable; -import org.gcube.application.geoportal.model.db.PostgisTable.BBOX; +import org.gcube.application.geoportal.model.fault.PublishException; +import org.gcube.application.geoportal.model.gis.BBOX; import org.gcube.application.geoportal.model.gis.LayerDescriptor; -import org.gcube.application.geoportal.model.PublishException; import org.gcube.spatial.data.geonetwork.GeoNetworkPublisher; import org.gcube.spatial.data.geonetwork.LoginLevel; import org.gcube.spatial.data.geonetwork.iso.tpl.ISOMetadataByTemplate; diff --git a/src/test/java/org/gcube/application/geoportal/CSVToPostgis.java b/src/test/java/org/gcube/application/geoportal/CSVToPostgis.java index 3a8a750..f0f7ee2 100644 --- a/src/test/java/org/gcube/application/geoportal/CSVToPostgis.java +++ b/src/test/java/org/gcube/application/geoportal/CSVToPostgis.java @@ -4,8 +4,8 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.sql.SQLException; -import org.gcube.application.geoportal.model.DataParsingException; import org.gcube.application.geoportal.model.db.DBInteractionException; +import org.gcube.application.geoportal.model.fault.DataParsingException; public class CSVToPostgis { diff --git a/src/test/java/org/gcube/application/geoportal/GeopackageTests.java b/src/test/java/org/gcube/application/geoportal/GeopackageTests.java index 7a1edf3..db065ba 100644 --- a/src/test/java/org/gcube/application/geoportal/GeopackageTests.java +++ b/src/test/java/org/gcube/application/geoportal/GeopackageTests.java @@ -7,7 +7,6 @@ import java.sql.SQLException; import java.util.HashMap; import java.util.HashSet; -import org.gcube.application.geoportal.model.DataParsingException; import org.gcube.application.geoportal.model.MOSI; import org.gcube.application.geoportal.model.MOSI.CD_Type; import org.gcube.application.geoportal.model.MOSI.CD_Type.ACC_Type; @@ -32,7 +31,8 @@ import org.gcube.application.geoportal.model.MOSI.TU_Type.NVC_Type; import org.gcube.application.geoportal.model.MOSI.TU_Type.STU_Type; import org.gcube.application.geoportal.model.db.DBInteractionException; import org.gcube.application.geoportal.model.db.PostgisTable; -import org.gcube.application.geoportal.model.gis.GeoPackageInteractionException; +import org.gcube.application.geoportal.model.fault.DataParsingException; +import org.gcube.application.geoportal.model.fault.GeoPackageInteractionException; import org.gcube.application.geoportal.model.MOSI.VR_Type; import org.gcube.application.geoportal.utils.Files; import org.gcube.application.geoportal.utils.GpkgUtils; diff --git a/src/test/java/org/gcube/application/geoportal/PostgisMockup.java b/src/test/java/org/gcube/application/geoportal/PostgisMockup.java index 199d5c7..29f784e 100644 --- a/src/test/java/org/gcube/application/geoportal/PostgisMockup.java +++ b/src/test/java/org/gcube/application/geoportal/PostgisMockup.java @@ -4,10 +4,10 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -import org.gcube.application.geoportal.model.DataParsingException; import org.gcube.application.geoportal.model.db.PostgisTable; -import org.gcube.application.geoportal.model.db.PostgisTable.BBOX; import org.gcube.application.geoportal.model.db.PostgisTable.POINT; +import org.gcube.application.geoportal.model.fault.DataParsingException; +import org.gcube.application.geoportal.model.gis.BBOX; public class PostgisMockup implements PostgisDBManagerI { diff --git a/src/test/java/org/gcube/application/geoportal/SerializationTests.java b/src/test/java/org/gcube/application/geoportal/SerializationTests.java index ac562a4..e25ce67 100644 --- a/src/test/java/org/gcube/application/geoportal/SerializationTests.java +++ b/src/test/java/org/gcube/application/geoportal/SerializationTests.java @@ -1,13 +1,18 @@ package org.gcube.application.geoportal; -import static org.junit.Assert.assertSame; - import java.io.IOException; +import java.time.Instant; +import java.util.ArrayList; import java.util.Arrays; +import java.util.Date; +import org.gcube.application.geoportal.model.AccessPolicy; import org.gcube.application.geoportal.model.Record; -import org.gcube.application.geoportal.model.RecordType; import org.gcube.application.geoportal.model.concessioni.Concessione; +import org.gcube.application.geoportal.model.concessioni.LayerConcessione; +import org.gcube.application.geoportal.model.concessioni.RelazioneScavo; +import org.gcube.application.geoportal.model.content.UploadedImage; +import org.gcube.application.geoportal.model.gis.BBOX; import org.gcube.application.geoportal.utils.Serialization; import org.junit.Assert; import org.junit.Before; @@ -19,42 +24,116 @@ import com.fasterxml.jackson.databind.JsonMappingException; public class SerializationTests { private Concessione concessione=null; - + @Before public void init() { concessione=new Concessione(); - concessione.setAttachments(null); - + + + // Generic fields + concessione.setCreationTime(Date.from(Instant.now())); + concessione.setCreationUser("my author"); + concessione.setLastUpdateTime(concessione.getCreationTime()); + concessione.setVersion("1.0.0"); + + + + // Concessione fields + + concessione.setNome("My test thing"); + concessione.setIntroduzione("This is my project"); + concessione.setDescrizioneContenuto("It contains this and that"); + concessione.setAuthors(Arrays.asList(new String[] {"Some one","Some, oneelse"})); + + concessione.setContributore("Contrib 1"); + concessione.setTitolari(Arrays.asList(new String[] {"Some one","Some, oneelse"})); + concessione.setResponsabile("Someone"); + concessione.setEditore("Editore"); + + concessione.setFontiFinanaziamento(Arrays.asList(new String[] {"Big pharma","Pentagon"})); + + + concessione.setSoggetto(Arrays.asList(new String[] {"Research Excavation","Archeology"})); + + + + concessione.setDataInizioScavo(Date.from(Instant.now())); + concessione.setDataFineScavo(Date.from(Instant.now())); + + concessione.setTitolareLicenza("Qualcun altro"); + concessione.setTitolareCopyright("Chiedilo in giro"); + + concessione.setParoleChiaveLibere(Arrays.asList(new String[] {"Robba","Stuff"})); + concessione.setParoleChiaveICCD(Arrays.asList(new String[] {"vattelapesca","somthing something"})); + + concessione.setCentroidLat(180.0); concessione.setCentroidLong(90.0); - concessione.setContributore("Contrib 1"); - concessione.setCreationTime("1880"); - concessione.setCreationUser("my author"); - concessione.setDateScavo(Arrays.asList(new String[] {"Febbraio","1980"})); - concessione.setDescrizione("Concessione esempio"); - concessione.setDirittiAccessoDati("Nessun diritto"); - concessione.setEditore("Editore"); - concessione.setFolderId("9845"); - concessione.setFonti("Wikipedia"); - concessione.setId("AKSDJFODéDAAFDJ"); - concessione.setKeywords(Arrays.asList(new String[] {"cose non interessanti","stupidaggini"})); - concessione.setLastUpdateTime("ieri"); - concessione.setLastUpdateUser("io"); - concessione.setLayers(null); - - - concessione.setLicense("cccp"); - concessione.setNome("My test thing"); - concessione.setRecordType(RecordType.CONCESSIONE); - concessione.setResponsabile("Qualcuno lo sarà"); - concessione.setSoggetto("Subj"); - concessione.setTitolare("Titolarone"); - concessione.setTitolareLicenza("Qualcun altro"); - concessione.setVersion("1.0.0b"); + + + // Attachments + + // Relazione scavo + RelazioneScavo relScavo=new RelazioneScavo(); + + relScavo.setTitolo(concessione.getNome()+" relazione scavo"); + relScavo.setAbstractSection("simple abstract section"); + relScavo.setSoggetto(concessione.getSoggetto()); + relScavo.setCreationTime(concessione.getCreationTime()); + relScavo.setResponsabili(concessione.getAuthors()); + relScavo.setPolicy(AccessPolicy.OPEN); + relScavo.setLicenseID("CC-BY"); + + concessione.setRelazioneScavo(relScavo); + //Immagini rappresentative + ArrayList imgs=new ArrayList<>(); + for(int i=0;i<5;i++) { + UploadedImage img=new UploadedImage(); + img.setTitolo("My image number "+i); + img.setDidascalia("You can see my image number "+i); + img.setFormat("TIFF"); + img.setSoggetto(concessione.getSoggetto()); + img.setCreationTime(Date.from(Instant.now())); + img.setResponsabili(concessione.getAuthors()); + img.setLicenseID("CC-BY"); + imgs.add(img); + } + concessione.setImmaginiRappresentative(imgs); + //Posizionamento + LayerConcessione posizionamento=new LayerConcessione(); + posizionamento.setTitolo(concessione.getNome()+" posizionamento area scavo"); + posizionamento.setAbstractSection("My abstract"); + posizionamento.setTopicCategory("Society"); + posizionamento.setSubTopic("Archeology"); + posizionamento.setBbox(BBOX.WORLD_EXTENT); + posizionamento.setValutazioneQualita("Secondo me si"); + posizionamento.setMetodoRaccoltaDati("Fattobbene"); + posizionamento.setScalaAcquisizione("1:10000"); + posizionamento.setLicenseID("CC-BY"); + posizionamento.setAuthors(concessione.getAuthors()); + concessione.setPosizionamentoScavo(posizionamento); + + // Piante fine scavo + ArrayList piante=new ArrayList(); + for(int i=0;i<4;i++) { + LayerConcessione pianta=new LayerConcessione(); + pianta.setTitolo(concessione.getNome()+" pianta area scavo"); + pianta.setAbstractSection("My abstract"); + pianta.setTopicCategory("Society"); + pianta.setSubTopic("Archeology"); + pianta.setBbox(BBOX.WORLD_EXTENT); + pianta.setValutazioneQualita("Secondo me si"); + pianta.setMetodoRaccoltaDati("Fattobbene"); + pianta.setScalaAcquisizione("1:10000"); + pianta.setLicenseID("CC-BY"); + pianta.setAuthors(concessione.getAuthors()); + piante.add(pianta); + } + concessione.setPianteFineScavo(piante); } - - + + @Test public void serilalization() throws JsonParseException, JsonMappingException, IOException { System.out.println(cycle(concessione)); diff --git a/src/test/java/org/gcube/application/geoportal/UploadGpkgTable.java b/src/test/java/org/gcube/application/geoportal/UploadGpkgTable.java index 8ed3336..b9122f5 100644 --- a/src/test/java/org/gcube/application/geoportal/UploadGpkgTable.java +++ b/src/test/java/org/gcube/application/geoportal/UploadGpkgTable.java @@ -5,10 +5,10 @@ import java.io.IOException; import java.sql.SQLException; import java.util.Map; -import org.gcube.application.geoportal.model.DataParsingException; import org.gcube.application.geoportal.model.db.DBInteractionException; import org.gcube.application.geoportal.model.db.DatabaseConnection; -import org.gcube.application.geoportal.model.gis.GeoPackageInteractionException; +import org.gcube.application.geoportal.model.fault.DataParsingException; +import org.gcube.application.geoportal.model.fault.GeoPackageInteractionException; import org.gcube.application.geoportal.utils.GpkgUtils; import org.gcube.application.geoportal.utils.MainUtils; diff --git a/src/test/java/org/gcube/application/geoportal/db/ParsingTests.java b/src/test/java/org/gcube/application/geoportal/db/ParsingTests.java index 2d1ba5c..cd188f9 100644 --- a/src/test/java/org/gcube/application/geoportal/db/ParsingTests.java +++ b/src/test/java/org/gcube/application/geoportal/db/ParsingTests.java @@ -1,7 +1,7 @@ package org.gcube.application.geoportal.db; -import org.gcube.application.geoportal.model.DataParsingException; -import org.gcube.application.geoportal.model.db.PostgisTable; +import org.gcube.application.geoportal.model.fault.DataParsingException; +import org.gcube.application.geoportal.model.gis.BBOX; import org.junit.Test; public class ParsingTests { @@ -9,6 +9,6 @@ public class ParsingTests { @Test public void parseExtent() throws DataParsingException { String toparse="BBOX POLYGON((8.476 39.179,8.476 45.772,17.391 45.772,17.391 39.179,8.476 39.179))"; - System.out.println(PostgisTable.BBOX.parseST_Extent(toparse)); + System.out.println(BBOX.parseST_Extent(toparse)); } } diff --git a/src/test/resources/META-INF/persistence.xml b/src/test/resources/META-INF/persistence.xml index bf1628b..4a0bd42 100644 --- a/src/test/resources/META-INF/persistence.xml +++ b/src/test/resources/META-INF/persistence.xml @@ -3,9 +3,11 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"> - org.gcube.application.geoportal.model.ArchiveDescriptor - org.gcube.application.geoportal.model.AssociatedContent - org.gcube.application.geoportal.model.gis.LayerDescriptor + + org.gcube.application.geoportal.model.content.AssociatedContent + org.gcube.application.geoportal.model.concessioni.Concessione + org.gcube.application.geoportal.model.concessioni.PiantaScavo + org.gcube.application.geoportal.model.concessioni.RelazioneScavo