Model and refactoring

This commit is contained in:
Fabio Sinibaldi 2020-10-02 17:56:54 +02:00
parent cab3146363
commit 8a572aad8f
42 changed files with 1046 additions and 394 deletions

View File

@ -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

View File

@ -13,5 +13,4 @@ public abstract class AbstractRecordManager<T extends Record> {
};
}

View File

@ -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();
}

View File

@ -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<Concessione> {
@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();
}
}

View File

@ -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");
}

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -0,0 +1,7 @@
package org.gcube.application.geoportal.model;
public enum AccessPolicy {
OPEN,RESTRICTED,EMBARGOED;
}

View File

@ -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<AssociatedContent> 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<LayerDescriptor> layers;
@ -70,17 +71,17 @@ public class ArchiveDescriptor {
}
public void addLayer(LayerDescriptor layer) {
if(layers==null) layers=new ArrayList<LayerDescriptor>();
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<LayerDescriptor>();
//
// if(!getLayers().contains(layer)) {
// getLayers().add(layer);
// if(layer.getArchive()!=null) {
// layer.getArchive().getLayers().remove(layer);
// }
// }
// layer.setArchive(this);
// }
}

View File

@ -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;
}

View File

@ -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<AssociatedContent> attachments;
//one to many
protected List<LayerDescriptor> 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;
}
}

View File

@ -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<String> 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<String> titolari;
private String responsabile;
private String editore;
private List<String> keywords;
private String fonti;
private String soggetto;
private List<String> dateScavo;
private List<String> fontiFinanaziamento;
//Research Excavation; Archaeology (valori di default)
private List<String> soggetto;
//Referenze bibliografiche, DOI (se esistenti) di risorse correlate allindagine in oggetto
private List<String> risorseCorrelate;
private Date dataInizioScavo;
private Date dataFineScavo;
private String titolareLicenza;
private String titolareCopyright;
private List<String> paroleChiaveLibere;
private List<String> paroleChiaveICCD;
private Double centroidLat;
private Double centroidLong;
private RelazioneScavo relazioneScavo;
private List<UploadedImage> immaginiRappresentative;
private LayerConcessione posizionamentoScavo;
private List<LayerConcessione> pianteFineScavo;
private List<OtherContent> 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;
}
}

View File

@ -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<String> 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;
}
}

View File

@ -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<String> responsabili;
private List<String> 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;
}
}

View File

@ -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<PersistedContent> 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;
}
}

View File

@ -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;
}

View File

@ -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 {
}

View File

@ -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;
}

View File

@ -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<String> responsabili;
private List<String> 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;
}
}

View File

@ -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;
}

View File

@ -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

View File

@ -1,4 +1,4 @@
package org.gcube.application.geoportal.model;
package org.gcube.application.geoportal.model.fault;
public class DataParsingException extends Exception {

View File

@ -1,4 +1,4 @@
package org.gcube.application.geoportal.model.gis;
package org.gcube.application.geoportal.model.fault;
public class GeoPackageInteractionException extends Exception {

View File

@ -1,4 +1,4 @@
package org.gcube.application.geoportal.model;
package org.gcube.application.geoportal.model.fault;
public class InvalidRecordException extends Exception {

View File

@ -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;

View File

@ -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;
}

View File

@ -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 + "]";
}
}

View File

@ -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;
}

View File

@ -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{
}

View File

@ -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;

View File

@ -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;
}
}

View File

@ -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);
}
}
}

View File

@ -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;

View File

@ -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;

View File

@ -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 {

View File

@ -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;

View File

@ -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 {

View File

@ -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<UploadedImage> 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<LayerConcessione> piante=new ArrayList<LayerConcessione>();
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));

View File

@ -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;

View File

@ -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));
}
}

View File

@ -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">
<persistence-unit name="archiveDB" transaction-type="RESOURCE_LOCAL">
<class>org.gcube.application.geoportal.model.ArchiveDescriptor</class>
<class>org.gcube.application.geoportal.model.AssociatedContent</class>
<class>org.gcube.application.geoportal.model.gis.LayerDescriptor</class>
<class>org.gcube.application.geoportal.model.content.AssociatedContent</class>
<class>org.gcube.application.geoportal.model.concessioni.Concessione</class>
<class>org.gcube.application.geoportal.model.concessioni.PiantaScavo</class>
<class>org.gcube.application.geoportal.model.concessioni.RelazioneScavo</class>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:derby:memory:unit-testing-geona;create=true"/>
<!-- <property name="javax.persistence.jdbc.user" value="user"/>