diff --git a/src/main/java/org/gcube/application/geoportal/common/model/legacy/AccessPolicy.java b/src/main/java/org/gcube/application/geoportal/common/model/legacy/AccessPolicy.java new file mode 100644 index 0000000..f17f659 --- /dev/null +++ b/src/main/java/org/gcube/application/geoportal/common/model/legacy/AccessPolicy.java @@ -0,0 +1,7 @@ +package org.gcube.application.geoportal.common.model.legacy; + +public enum AccessPolicy { + + OPEN,RESTRICTED,EMBARGOED; + +} diff --git a/src/main/java/org/gcube/application/geoportal/common/model/legacy/AssociatedContent.java b/src/main/java/org/gcube/application/geoportal/common/model/legacy/AssociatedContent.java new file mode 100644 index 0000000..bee2128 --- /dev/null +++ b/src/main/java/org/gcube/application/geoportal/common/model/legacy/AssociatedContent.java @@ -0,0 +1,126 @@ +package org.gcube.application.geoportal.common.model.legacy; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; + +import org.gcube.application.geoportal.common.model.legacy.report.ValidationReport; +import org.gcube.application.geoportal.common.utils.CollectionsUtils; + +import lombok.Getter; +import lombok.Setter; + + +@Getter +@Setter + +public abstract class AssociatedContent { + + + private long id; + + private AccessPolicy policy; + private String licenseID; + private String titolo; + private LocalDateTime creationTime; + + + public ValidationReport validateForInsertion() { + ValidationReport toReturn=new ValidationReport("Associated Content"); + toReturn.checkMandatory(policy, "Politica di accesso"); + toReturn.checkMandatory(licenseID, "Licenza"); + toReturn.checkMandatory(titolo,"Titolo"); + toReturn.checkMandatory(creationTime, "Creation time"); + return toReturn; + } + + + + + + private List actualContent=new ArrayList<>(); + + + + @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; + } + + + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("AssociatedContent [id="); + builder.append(id); + builder.append(", policy="); + builder.append(policy); + builder.append(", licenseID="); + builder.append(licenseID); + builder.append(", titolo="); + builder.append(titolo); + builder.append(", creationTime="); + builder.append(creationTime); + + builder.append(", actualContent="); + builder.append(actualContent); + builder.append("]"); + return builder.toString(); + } + + + + + +} diff --git a/src/main/java/org/gcube/application/geoportal/common/model/legacy/BBOX.java b/src/main/java/org/gcube/application/geoportal/common/model/legacy/BBOX.java new file mode 100644 index 0000000..aa88773 --- /dev/null +++ b/src/main/java/org/gcube/application/geoportal/common/model/legacy/BBOX.java @@ -0,0 +1,36 @@ +package org.gcube.application.geoportal.common.model.legacy; + +import java.io.Serializable; + +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; +import lombok.ToString; + +@RequiredArgsConstructor +@Getter +@NoArgsConstructor +@EqualsAndHashCode +@ToString +public class BBOX implements Serializable{ + + /** + * + */ + private static final long serialVersionUID = -159414992596542946L; + + 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/common/model/legacy/Concessione.java b/src/main/java/org/gcube/application/geoportal/common/model/legacy/Concessione.java new file mode 100644 index 0000000..ae5d6d4 --- /dev/null +++ b/src/main/java/org/gcube/application/geoportal/common/model/legacy/Concessione.java @@ -0,0 +1,438 @@ +package org.gcube.application.geoportal.common.model.legacy; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.gcube.application.geoportal.common.model.legacy.report.Check; +import org.gcube.application.geoportal.common.model.legacy.report.ConstraintCheck; +import org.gcube.application.geoportal.common.model.legacy.report.ValidationReport; +import org.gcube.application.geoportal.common.model.legacy.report.ValidationReport.ValidationStatus; +import org.gcube.application.geoportal.common.utils.CollectionsUtils; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString(callSuper=true) + +public class Concessione extends Record{ + + + //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; + + //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 fontiFinanziamento; + + //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 LocalDateTime dataInizioProgetto; + private LocalDateTime dataFineProgetto; + + private String titolareLicenza; + private String titolareCopyright; + + private List paroleChiaveLibere; + + private List paroleChiaveICCD; + + + private Double centroidLat; + private Double centroidLong; + + private RelazioneScavo relazioneScavo; + + private List immaginiRappresentative=new ArrayList(); + + private LayerConcessione posizionamentoScavo; + + private List pianteFineScavo=new ArrayList<>(); + + private List genericContent=new ArrayList<>(); + + + public Concessione() { + super(); + setRecordType(RecordType.CONCESSIONE); + } + + + @Override + public ValidationReport validate() { + ValidationReport validator= super.validate(); + + validator.setObjectName("Concessione"); + + setPolicy(AccessPolicy.OPEN); + + + + validator.checkMandatory(authors, "Lista Autori"); + if(validator.checkMandatory(centroidLat, "Latitudine")) + if(centroidLat>90||centroidLat<-90) validator.addMessage(ValidationStatus.ERROR, "Latitudine non valida : "+centroidLat); + + if(validator.checkMandatory(centroidLong, "Longitudine")) + if(centroidLong>180||centroidLong<-180) validator.addMessage(ValidationStatus.ERROR, "Longitudine non valida : "+centroidLong); + + validator.checkMandatory(contributore, "Contributore"); + if(validator.checkMandatory(dataFineProgetto, "Data Fine Progetto") && + validator.checkMandatory(dataInizioProgetto, "Data Inizio Progetto")) + if(dataFineProgetto.isBefore(dataInizioProgetto)) validator.addMessage(ValidationStatus.ERROR, "Data Fine Progetto non può esser prima di Data Inizio Progetto."); + + validator.checkMandatory(descrizioneContenuto, "Descrizione contenuto"); + validator.checkMandatory(editore, "Editore"); + validator.checkMandatory(fontiFinanziamento, "Fonti Finanaziamento"); + validator.checkMandatory(introduzione, "Introduzione"); + validator.checkMandatory(paroleChiaveICCD, "Parole chiave ICCD"); + validator.checkMandatory(paroleChiaveLibere, "Parole chiave libere"); + + validator.checkMandatory(responsabile,"Responsabile"); + + + + validator.checkMandatory(titolareCopyright, "Titolare Copyright"); + validator.checkMandatory(titolareLicenza,"Titolare licenza"); + validator.checkMandatory(titolari, "Titolari"); + + + + if(validator.checkMandatory(relazioneScavo, "Relazione scavo")) { + + + + validator.addChild(relazioneScavo.validateForInsertion()); + } + +// if(immaginiRappresentative!=null) +// +// for(UploadedImage img : immaginiRappresentative) { +// validator.setDefault(img.getSoggetto(),getSoggetto()); +// validator.setDefault(img.getCreationTime(),getCreationTime()); +// validator.setDefault(img.getPolicy(), getPolicy()); +// validator.setDefault(img.getLicenzaID(), getLicenzaID()); +// +// validator.addChild(img.validateForInsertion()); +// } +// + + if(validator.checkMandatory(posizionamentoScavo, "Posizionamento scavo")) { + + ValidationReport posReport=posizionamentoScavo.validateForInsertion(); + posReport.setObjectName("Posizionamento scavo"); + validator.addChild(posReport); + } + + + if(genericContent!=null) + for(OtherContent content:genericContent) + validator.addChild(content.validateForInsertion()); + + if(validator.checkMandatory(pianteFineScavo,"Piante fine scavo")) + for(LayerConcessione l:pianteFineScavo) { + validator.addChild(l.validateForInsertion()); + } + + + + + + return validator; + } + + + @Override + public void setDefaults() { + super.setDefaults(); + setSoggetto(ConstraintCheck.defaultFor(soggetto, Arrays.asList(new String[] {"Research Excavation","Archaeology"})) + .addChecks(Check.collectionSizeMin(2)).evaluate()); + + + + if(relazioneScavo!=null) { + relazioneScavo.setTitolo(ConstraintCheck.defaultFor(relazioneScavo.getTitolo(),getNome()+" relazione di scavo").evaluate()); + relazioneScavo.setSoggetto(ConstraintCheck.defaultFor(relazioneScavo.getSoggetto(),getSoggetto()).evaluate()); + relazioneScavo.setCreationTime(ConstraintCheck.defaultFor(relazioneScavo.getCreationTime(),getCreationTime()).evaluate()); + relazioneScavo.setLicenseID(getLicenzaID()); + relazioneScavo.setPolicy(getPolicy()); + } + + + if(immaginiRappresentative!=null) + for(UploadedImage img : immaginiRappresentative) { + img.setSoggetto(ConstraintCheck.defaultFor(img.getSoggetto(),getSoggetto()).evaluate()); + img.setCreationTime(ConstraintCheck.defaultFor(img.getCreationTime(),getCreationTime()).evaluate()); + img.setPolicy(ConstraintCheck.defaultFor(img.getPolicy(),getPolicy()).evaluate()); + img.setLicenseID(ConstraintCheck.defaultFor(img.getLicenseID(),getLicenzaID()).evaluate()); + } + + + if(posizionamentoScavo!=null) { + posizionamentoScavo.setTitolo(ConstraintCheck.defaultFor(posizionamentoScavo.getTitolo(), getNome()+" posizionamento scavo").evaluate()); + posizionamentoScavo.setAbstractSection( + ConstraintCheck.defaultFor(posizionamentoScavo.getAbstractSection(),"Posizionamento topografico georeferenziato dell’area interessata dalle indagini").evaluate()); + + posizionamentoScavo.setTopicCategory(ConstraintCheck.defaultFor(posizionamentoScavo.getTopicCategory(), "Society").evaluate()); + posizionamentoScavo.setSubTopic(ConstraintCheck.defaultFor(posizionamentoScavo.getSubTopic(), "Archeology").evaluate()); + + posizionamentoScavo.setParoleChiaveLibere(ConstraintCheck.defaultFor(posizionamentoScavo.getParoleChiaveLibere(),getParoleChiaveLibere()).evaluate()); + posizionamentoScavo.setParoleChiaveICCD(ConstraintCheck.defaultFor(posizionamentoScavo.getParoleChiaveICCD(),getParoleChiaveICCD()).evaluate()); + + //TODO Evaluate + posizionamentoScavo.setBbox(ConstraintCheck.defaultFor(posizionamentoScavo.getBbox(), BBOX.WORLD_EXTENT).evaluate()); + + posizionamentoScavo.setPolicy(ConstraintCheck.defaultFor(posizionamentoScavo.getPolicy(),getPolicy()).evaluate());; + posizionamentoScavo.setLicenseID("CC-BY"); + posizionamentoScavo.setResponsabile(getResponsabile()); + posizionamentoScavo.setCreationTime(ConstraintCheck.defaultFor(posizionamentoScavo.getCreationTime(), getCreationTime()).evaluate()); + + + } + + + + if(pianteFineScavo!=null) + for(LayerConcessione l:pianteFineScavo) { + + l.setTitolo(ConstraintCheck.defaultFor(l.getTitolo(), getNome()+" pianta fine scavo").evaluate()); + l.setAbstractSection( + ConstraintCheck.defaultFor(l.getAbstractSection(),"Planimetria georeferenziata dell'area indagata al termine delle attività").evaluate()); + + l.setTopicCategory(ConstraintCheck.defaultFor(l.getTopicCategory(), "Society").evaluate()); + l.setSubTopic(ConstraintCheck.defaultFor(l.getSubTopic(), "Archeology").evaluate()); + + l.setParoleChiaveLibere(ConstraintCheck.defaultFor(l.getParoleChiaveLibere(),getParoleChiaveLibere()).evaluate()); + l.setParoleChiaveICCD(ConstraintCheck.defaultFor(l.getParoleChiaveICCD(),getParoleChiaveICCD()).evaluate()); + + //TODO Evaluate + l.setBbox(ConstraintCheck.defaultFor(l.getBbox(), BBOX.WORLD_EXTENT).evaluate()); + + l.setPolicy(ConstraintCheck.defaultFor(l.getPolicy(),getPolicy()).evaluate());; + l.setLicenseID(ConstraintCheck.defaultFor(l.getLicenseID(), "CC-BY").evaluate()); + l.setResponsabile(getResponsabile()); + l.setCreationTime(ConstraintCheck.defaultFor(l.getCreationTime(), getCreationTime()).evaluate()); + } + + + + + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; +// result = prime * result + ((authors == null) ? 0 : authors.hashCode()); + result = prime * result + CollectionsUtils.hashCode(authors); +// result = prime * result + ((fontiFinanaziamento == null) ? 0 : fontiFinanaziamento.hashCode()); + result = prime * result + CollectionsUtils.hashCode(fontiFinanziamento); +// 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 + ((dataFineProgetto == null) ? 0 : dataFineProgetto.hashCode()); + result = prime * result + ((dataInizioProgetto == null) ? 0 : dataInizioProgetto.hashCode()); + result = prime * result + ((descrizioneContenuto == null) ? 0 : descrizioneContenuto.hashCode()); + result = prime * result + ((editore == null) ? 0 : editore.hashCode()); + result = prime * result + ((genericContent == null) ? 0 : genericContent.hashCode()); + result = prime * result + ((introduzione == null) ? 0 : introduzione.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 + ((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 (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 (fontiFinanaziamento == null) { +// if (other.fontiFinanaziamento != null) +// return false; +// } else if (!fontiFinanaziamento.equals(other.fontiFinanaziamento)) +// return false; + if (!CollectionsUtils.equalsCollections(fontiFinanziamento, other.fontiFinanziamento)) 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 (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 (dataFineProgetto == null) { + if (other.dataFineProgetto != null) + return false; + } else if (!dataFineProgetto.equals(other.dataFineProgetto)) + return false; + if (dataInizioProgetto == null) { + if (other.dataInizioProgetto != null) + return false; + } else if (!dataInizioProgetto.equals(other.dataInizioProgetto)) + 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 (genericContent == null) { + if (other.genericContent != null) + return false; + } 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 (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 (titolareCopyright == null) { + if (other.titolareCopyright != null) + return false; + } else if (!titolareCopyright.equals(other.titolareCopyright)) + return false; + if (titolareLicenza == null) { + if (other.titolareLicenza != null) + return false; + } else if (!titolareLicenza.equals(other.titolareLicenza)) + return false; + + return true; + } + + + +} diff --git a/src/main/java/org/gcube/application/geoportal/common/model/legacy/GeoServerContent.java b/src/main/java/org/gcube/application/geoportal/common/model/legacy/GeoServerContent.java new file mode 100644 index 0000000..88fd57a --- /dev/null +++ b/src/main/java/org/gcube/application/geoportal/common/model/legacy/GeoServerContent.java @@ -0,0 +1,28 @@ +package org.gcube.application.geoportal.common.model.legacy; + +import java.util.ArrayList; +import java.util.List; + +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString(callSuper=true) + +@EqualsAndHashCode(callSuper=true) +public class GeoServerContent extends PersistedContent{ + + //GeoServer Details + private String geoserverHostName; + private String geoserverPath; + + private List fileNames=new ArrayList(); + + + private String workspace; + private String store; + private String featureType; +} diff --git a/src/main/java/org/gcube/application/geoportal/common/model/legacy/LayerConcessione.java b/src/main/java/org/gcube/application/geoportal/common/model/legacy/LayerConcessione.java new file mode 100644 index 0000000..784d9ce --- /dev/null +++ b/src/main/java/org/gcube/application/geoportal/common/model/legacy/LayerConcessione.java @@ -0,0 +1,141 @@ +package org.gcube.application.geoportal.common.model.legacy; + +import java.util.List; + +import org.gcube.application.geoportal.common.model.legacy.report.ValidationReport; +import org.gcube.application.geoportal.common.utils.CollectionsUtils; + +import lombok.Getter; +import lombok.Setter; + + +@Getter +@Setter + +public class LayerConcessione extends SDILayerDescriptor{ + + //1.Identificazione + private String abstractSection; + + //2.Classificazione + private String topicCategory; + + //3.Keyword + private String subTopic; + + //4. Delimitazione geographica + private BBOX bbox; + + //5. Temporal + + private List paroleChiaveLibere; + + private List paroleChiaveICCD; + + //6. Quality + private String valutazioneQualita; + + private String metodoRaccoltaDati; + + private String scalaAcquisizione; + + //8. Responsabili + private List authors; + + private String responsabile; + + + + + @Override + public ValidationReport validateForInsertion() { + ValidationReport toReturn=super.validateForInsertion(); + toReturn.setObjectName("Layer Concessione"); + toReturn.checkMandatory(abstractSection, "Abstract"); + toReturn.checkMandatory(subTopic, "Categoria (Topic)"); + //TODO +// toReturn.checkMandatory(bbox, "Bounding Box"); + + toReturn.checkMandatory(valutazioneQualita, "Valutazione della qualita"); + toReturn.checkMandatory(metodoRaccoltaDati, "Metodo raccolta dati"); + toReturn.checkMandatory(scalaAcquisizione, "Scala acquisizione"); + toReturn.checkMandatory(authors, "Autori"); + return toReturn; + } + + @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 + ((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 (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/common/model/legacy/OtherContent.java b/src/main/java/org/gcube/application/geoportal/common/model/legacy/OtherContent.java new file mode 100644 index 0000000..7aeda2f --- /dev/null +++ b/src/main/java/org/gcube/application/geoportal/common/model/legacy/OtherContent.java @@ -0,0 +1,15 @@ +package org.gcube.application.geoportal.common.model.legacy; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString(callSuper=true) + +public class OtherContent extends AssociatedContent { + + + +} diff --git a/src/main/java/org/gcube/application/geoportal/common/model/legacy/PersistedContent.java b/src/main/java/org/gcube/application/geoportal/common/model/legacy/PersistedContent.java new file mode 100644 index 0000000..fd51e8e --- /dev/null +++ b/src/main/java/org/gcube/application/geoportal/common/model/legacy/PersistedContent.java @@ -0,0 +1,35 @@ +package org.gcube.application.geoportal.common.model.legacy; + +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +@EqualsAndHashCode +public abstract class PersistedContent { + + //Generic Info + private long id; + + private AssociatedContent associated; + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("PersistedContent [id="); + builder.append(id); + if(associated==null) { + builder.append(", associated="); + builder.append(associated); + }else { + builder.append(", OWNER-associated-id="); + builder.append(associated.getId()); + } + builder.append("]"); + return builder.toString(); + } + + + +} diff --git a/src/main/java/org/gcube/application/geoportal/common/model/legacy/Record.java b/src/main/java/org/gcube/application/geoportal/common/model/legacy/Record.java new file mode 100644 index 0000000..1930b46 --- /dev/null +++ b/src/main/java/org/gcube/application/geoportal/common/model/legacy/Record.java @@ -0,0 +1,69 @@ +package org.gcube.application.geoportal.common.model.legacy; + +import java.time.LocalDateTime; + +import org.gcube.application.geoportal.common.model.legacy.report.ConstraintCheck; +import org.gcube.application.geoportal.common.model.legacy.report.ValidationReport; + +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString +@EqualsAndHashCode +public abstract class Record { + + + //Generic Info + private long id; + + private RecordType recordType; + private String version; + private String licenzaID; + + private AccessPolicy policy; + //Nome del progetto + private String nome; + + + //Storage Info + private String folderId; + + //Accounting + private LocalDateTime lastUpdateTime; + private String lastUpdateUser; + private LocalDateTime creationTime; + private String creationUser; + + + + + + public ValidationReport validate() { + + setDefaults(); + ValidationReport validator=new ValidationReport("Core metadata"); + validator.checkMandatory(getRecordType(), "Record Type"); + + validator.checkMandatory(getNome(), "Nome"); + + return validator; + } + + public void setDefaults() { + LocalDateTime now=LocalDateTime.now(); + + setVersion(ConstraintCheck.defaultFor(getVersion(),"1.0.0").evaluate()); + setPolicy(ConstraintCheck.defaultFor(getPolicy(), AccessPolicy.OPEN).evaluate()); + + setLastUpdateTime(ConstraintCheck.defaultFor(getLastUpdateTime(),now).evaluate()); + setCreationTime(ConstraintCheck.defaultFor(getCreationTime(),now).evaluate()); + setLicenzaID(ConstraintCheck.defaultFor(getLicenzaID(),"CC-BY").evaluate()); + } + + + +} diff --git a/src/main/java/org/gcube/application/geoportal/common/model/legacy/RecordType.java b/src/main/java/org/gcube/application/geoportal/common/model/legacy/RecordType.java new file mode 100644 index 0000000..267cc3f --- /dev/null +++ b/src/main/java/org/gcube/application/geoportal/common/model/legacy/RecordType.java @@ -0,0 +1,6 @@ +package org.gcube.application.geoportal.common.model.legacy; + +public enum RecordType { + + CONCESSIONE,MOSI,MOPR +} diff --git a/src/main/java/org/gcube/application/geoportal/common/model/legacy/RelazioneScavo.java b/src/main/java/org/gcube/application/geoportal/common/model/legacy/RelazioneScavo.java new file mode 100644 index 0000000..e9d4034 --- /dev/null +++ b/src/main/java/org/gcube/application/geoportal/common/model/legacy/RelazioneScavo.java @@ -0,0 +1,80 @@ +package org.gcube.application.geoportal.common.model.legacy; + +import java.util.List; + +import org.gcube.application.geoportal.common.model.legacy.report.ValidationReport; +import org.gcube.application.geoportal.common.utils.CollectionsUtils; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString(callSuper=true) +public class RelazioneScavo extends AssociatedContent { + + + + private String abstractSection; + + private List responsabili; + private List soggetto; + + + @Override + public ValidationReport validateForInsertion() { + + ValidationReport toReturn=super.validateForInsertion(); + toReturn.setObjectName("Relazione Scavo"); + toReturn.checkMandatory(responsabili, "Responsabili"); + toReturn.checkMandatory(soggetto, "Soggetto"); + return toReturn; + } + + @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/common/model/legacy/SDILayerDescriptor.java b/src/main/java/org/gcube/application/geoportal/common/model/legacy/SDILayerDescriptor.java new file mode 100644 index 0000000..7ed8f03 --- /dev/null +++ b/src/main/java/org/gcube/application/geoportal/common/model/legacy/SDILayerDescriptor.java @@ -0,0 +1,23 @@ +package org.gcube.application.geoportal.common.model.legacy; + +import lombok.Getter; +import lombok.Setter; + + +@Getter +@Setter +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/common/model/legacy/UploadedImage.java b/src/main/java/org/gcube/application/geoportal/common/model/legacy/UploadedImage.java new file mode 100644 index 0000000..3b5b413 --- /dev/null +++ b/src/main/java/org/gcube/application/geoportal/common/model/legacy/UploadedImage.java @@ -0,0 +1,73 @@ +package org.gcube.application.geoportal.common.model.legacy; + +import java.util.List; + +import org.gcube.application.geoportal.common.utils.CollectionsUtils; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString(callSuper=true) + +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/common/model/legacy/WorkspaceContent.java b/src/main/java/org/gcube/application/geoportal/common/model/legacy/WorkspaceContent.java new file mode 100644 index 0000000..7085c55 --- /dev/null +++ b/src/main/java/org/gcube/application/geoportal/common/model/legacy/WorkspaceContent.java @@ -0,0 +1,18 @@ +package org.gcube.application.geoportal.common.model.legacy; + +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +@Getter +@Setter +@ToString(callSuper=true) + +@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/common/model/legacy/report/Check.java b/src/main/java/org/gcube/application/geoportal/common/model/legacy/report/Check.java new file mode 100644 index 0000000..d5e2e27 --- /dev/null +++ b/src/main/java/org/gcube/application/geoportal/common/model/legacy/report/Check.java @@ -0,0 +1,56 @@ +package org.gcube.application.geoportal.common.model.legacy.report; + +import java.util.Collection; + +public interface Check{ + + public static Check collectionSizeMax(final int upperBound) { + return new Check() { + int size=0; + @Override + public boolean isOk(Object toCheck) { + int size=((Collection)toCheck).size(); + return size<=upperBound; + } + @Override + public String getMessage() { + return "Numero elementi : "+size+" [max : "+upperBound+"]"; + } + }; + } + + public static Check collectionSizeMin(final int lowerBound) { + return new Check() { + int size=0; + @Override + public boolean isOk(Object toCheck) { + int size=((Collection)toCheck).size(); + return size>=lowerBound; + } + @Override + public String getMessage() { + return "Numero elementi : "+size+" [min : "+lowerBound+"]"; + } + }; + } + + public static Check collectionSize(final int lowerBound, final int upperBound) { + return new Check() { + int size=0; + + @Override + public boolean isOk(Object toCheck) { + size=((Collection)toCheck).size(); + return size<=upperBound&&size>=lowerBound; + } + + @Override + public String getMessage() { + return "Numero elementi : "+size+" [min : "+lowerBound+" max : "+upperBound+"]"; + } + }; + } + + public boolean isOk(Object toCheck); + public String getMessage(); +} \ No newline at end of file diff --git a/src/main/java/org/gcube/application/geoportal/common/model/legacy/report/Checks.java b/src/main/java/org/gcube/application/geoportal/common/model/legacy/report/Checks.java new file mode 100644 index 0000000..e5d57ae --- /dev/null +++ b/src/main/java/org/gcube/application/geoportal/common/model/legacy/report/Checks.java @@ -0,0 +1,7 @@ +package org.gcube.application.geoportal.common.model.legacy.report; + +public class Checks { + +// public static final Check + +} diff --git a/src/main/java/org/gcube/application/geoportal/common/model/legacy/report/ConstraintCheck.java b/src/main/java/org/gcube/application/geoportal/common/model/legacy/report/ConstraintCheck.java new file mode 100644 index 0000000..558d108 --- /dev/null +++ b/src/main/java/org/gcube/application/geoportal/common/model/legacy/report/ConstraintCheck.java @@ -0,0 +1,103 @@ +package org.gcube.application.geoportal.common.model.legacy.report; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class ConstraintCheck { + + public static ConstraintCheck defaultFor(T toCheck,T defaultValue){ + return new ConstraintCheck(toCheck).withDefault(defaultValue); + } + + + private T theObject; + private String fieldLabel; + private String message; + private boolean error=false; + private boolean mandatory; + private T theDefault; + + private List additionalChecks=new ArrayList(); + + public ConstraintCheck(T theObject,Check...checks){ + this.theObject=theObject; + for(Check c:checks) + additionalChecks.add(c); + check(); + + } + public ConstraintCheck withDefault(T theDefault){ + this.theDefault=theDefault; + return this; + } + public ConstraintCheck addChecks(Check...checks){ + for(Check c:checks) + additionalChecks.add(c); + return this; + } + public ConstraintCheck(T theObject,String fieldLabel,Check...checks){ + this.theObject=theObject; + this.fieldLabel=fieldLabel; + for(Check c:checks) + additionalChecks.add(c); + check(); + } + + public T evaluate() { + check(); + T result=theObject; + if(isError()) { + result=theDefault; + if(theDefault!=null && theDefault instanceof Collection) { + Collection defaultCollection=(Collection) theDefault; + ArrayList target=new ArrayList(defaultCollection); + result=(T) target; + } + } + return result; + + } + + private void check() { + if(theObject==null) { + this.setMessage(fieldLabel+" è un campo obbligatorio."); + this.setError(true); + }else + if((theObject instanceof String) && ((String) theObject).isEmpty()) { + this.setMessage(fieldLabel+" non può essere vuoto."); + this.setError(true); + }else + if((theObject instanceof Collection)) { + Collection toCheckCollection=(Collection) theObject; + if(toCheckCollection.isEmpty()) { + this.setMessage("La lista "+fieldLabel+" non può essere vuota."); + this.setError(true); + } + + + Boolean containsError=false; + Object[] array=toCheckCollection.toArray(new Object[toCheckCollection.size()]); + for(int i=0;i errorMessages=new ArrayList(); + private List warningMessages=new ArrayList(); + private List children=new ArrayList(); + + + public ValidationStatus getStatus() { + if(!errorMessages.isEmpty()) return ValidationStatus.ERROR; + + boolean isWarning=(!warningMessages.isEmpty()); + for(ValidationReport obj : children) { + ValidationStatus status=obj.getStatus(); + if(status.equals(ValidationStatus.ERROR)) return ValidationStatus.ERROR; + if(status.equals(ValidationStatus.WARNING)) isWarning=true; + } + if(isWarning) return ValidationStatus.WARNING; + return ValidationStatus.PASSED; + } + + public void addChild(ValidationReport obj) { + children.add(obj); + } + + public void addMessage(ValidationStatus status,String message) { + switch (status) { + case ERROR: + errorMessages.add(message); + break; + case WARNING : + warningMessages.add(message); + default: + break; + } + } + + + + + public boolean checkMandatory(T toCheck,String name,Check...checks) { + ConstraintCheck check=new ConstraintCheck(toCheck,name,checks); + if(check.isError()) + this.addMessage(ValidationStatus.ERROR, check.getMessage()); + return !check.isError(); + } + + + public ValidationReport(String objectName) { + super(); + this.objectName = objectName; + } + + +} diff --git a/src/main/java/org/gcube/application/geoportal/common/model/project/Project.java b/src/main/java/org/gcube/application/geoportal/common/model/project/Project.java index 5813d54..9e1d6cd 100644 --- a/src/main/java/org/gcube/application/geoportal/common/model/project/Project.java +++ b/src/main/java/org/gcube/application/geoportal/common/model/project/Project.java @@ -22,7 +22,7 @@ public class Project extends BasicJSONObject{ last_update_user: version : license : - policy : } + policy : status : VALID, PUBLISHED,INVALID document : {.....} diff --git a/src/main/java/org/gcube/application/geoportal/common/rest/ConcessioniI.java b/src/main/java/org/gcube/application/geoportal/common/rest/ConcessioniI.java new file mode 100644 index 0000000..b93346f --- /dev/null +++ b/src/main/java/org/gcube/application/geoportal/common/rest/ConcessioniI.java @@ -0,0 +1,9 @@ +package org.gcube.application.geoportal.common.rest; + +public interface ConcessioniI { + + + public String create(String toCreate); + public String readById(String readById); + +} diff --git a/src/main/java/org/gcube/application/geoportal/common/utils/CollectionsUtils.java b/src/main/java/org/gcube/application/geoportal/common/utils/CollectionsUtils.java new file mode 100644 index 0000000..a4071a4 --- /dev/null +++ b/src/main/java/org/gcube/application/geoportal/common/utils/CollectionsUtils.java @@ -0,0 +1,44 @@ +package org.gcube.application.geoportal.common.utils; + +import java.util.Collection; +import java.util.Iterator; + +public class CollectionsUtils { + + public static boolean equalsCollections(Collection a, Collection b) { + + if(a==null&&b!=null) + return false; + if(a!=null&&b==null) + return false; + + if(a==null&&b==null) + return true; + + if(a.size()!=b.size()) + return false; + + Iterator itA=a.iterator(); + Iterator itB=a.iterator(); + while(itA.hasNext()) { + if(!itA.next().equals(itB.next())) + return false; + } + + return true; + } + + 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; + } + +}