Compare commits
35 Commits
Author | SHA1 | Date |
---|---|---|
Fabio Sinibaldi | 7233768700 | |
Fabio Sinibaldi | 0494aa7039 | |
Fabio Sinibaldi | 9e1c46b95b | |
Fabio Sinibaldi | e6f826d841 | |
Fabio Sinibaldi | f33ccd3e91 | |
Fabio Sinibaldi | fe4110213d | |
Fabio Sinibaldi | f14c243a67 | |
Fabio Sinibaldi | 8fb4b7625f | |
Fabio Sinibaldi | bcb5ae8c15 | |
Fabio Sinibaldi | f46b0ba34c | |
Fabio Sinibaldi | cff85e396f | |
Fabio Sinibaldi | 069e8420c7 | |
Fabio Sinibaldi | 3408e3e9a4 | |
Fabio Sinibaldi | ebd1b2c5c1 | |
Fabio Sinibaldi | 464a86ac51 | |
Fabio Sinibaldi | 74ccb666bc | |
Fabio Sinibaldi | 31db0d70df | |
Fabio Sinibaldi | 7e083800fd | |
Fabio Sinibaldi | bdb3b6c2cc | |
Fabio Sinibaldi | f770bdbcee | |
Fabio Sinibaldi | 01371e8750 | |
Fabio Sinibaldi | dacaa5ef06 | |
Fabio Sinibaldi | f30c662e35 | |
Fabio Sinibaldi | f68290afa5 | |
Fabio Sinibaldi | 0630ca9a48 | |
Fabio Sinibaldi | 8bf718d3a9 | |
Fabio Sinibaldi | e7f2b59844 | |
Fabio Sinibaldi | f6756413d6 | |
Fabio Sinibaldi | 888c14ad69 | |
Fabio Sinibaldi | 0e9f28909c | |
Fabio Sinibaldi | 204d4608a0 | |
Fabio Sinibaldi | 08462b863e | |
Fabio Sinibaldi | 8b36eb5a8d | |
Fabio Sinibaldi | a06a92ab72 | |
Fabio Sinibaldi | cdbe3bae12 |
27
CHANGELOG.md
27
CHANGELOG.md
|
@ -2,6 +2,33 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|||
|
||||
# Changelog for org.gcube.application.geoportal-common
|
||||
|
||||
# [v1.0.6-SNAPSHOT] - 2021-08-3
|
||||
Forced Deletion
|
||||
Search & query
|
||||
Clean Fileset
|
||||
Interfaces return iterator instead of iterable
|
||||
Name in WorkspaceContent (https://support.d4science.org/issues/22032)
|
||||
|
||||
|
||||
# [v1.0.5] - 2020-12-9
|
||||
Mongo Id in record
|
||||
Mongo Concessioni interface
|
||||
Added Files.fixFileNAme
|
||||
ValidationReport as field
|
||||
Updated Model (#20357)
|
||||
|
||||
|
||||
# [v1.0.4-SNAPSHOT] - 2020-12-9
|
||||
Projects Rest Interface
|
||||
TempFile support
|
||||
|
||||
# [v1.0.3] - 2020-12-4
|
||||
Project model update
|
||||
|
||||
|
||||
# [v1.0.2-SNAPSHOT] - 2020-12-4
|
||||
Model update
|
||||
|
||||
## [v1.0.1] - 2020-11-11
|
||||
|
||||
Model update
|
||||
|
|
35
pom.xml
35
pom.xml
|
@ -4,7 +4,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.gcube.application</groupId>
|
||||
<artifactId>geoportal-common</artifactId>
|
||||
<version>1.0.1</version>
|
||||
<version>1.0.6-SNAPSHOT</version>
|
||||
<name>Geoportal Common</name>
|
||||
|
||||
|
||||
|
@ -36,7 +36,7 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.distribution</groupId>
|
||||
<artifactId>gcube-bom</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<version>2.0.1</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
@ -51,9 +51,12 @@
|
|||
<version>1.14.8</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>authorization-client</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- TEST -->
|
||||
<dependency>
|
||||
|
@ -62,22 +65,34 @@
|
|||
<scope>test</scope>
|
||||
<version>4.11</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- read JSON -->
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.media</groupId>
|
||||
<artifactId>jersey-media-json-jackson</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- jackson java time -->
|
||||
|
||||
<!-- jackson java time -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
<version>2.8.8</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- STORAGE -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.contentmanagement</groupId>
|
||||
<artifactId>storage-manager-core</artifactId>
|
||||
<version>[2.0.0, 3.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.contentmanagement</groupId>
|
||||
<artifactId>storage-manager-wrapper</artifactId>
|
||||
<version>[2.0.0, 3.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package org.gcube.application.geoportal.common.model.legacy;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString(callSuper=true)
|
||||
public class AbstractRelazione extends AssociatedContent{
|
||||
|
||||
private String abstractIta;
|
||||
private String abstractEng;
|
||||
|
||||
|
||||
}
|
|
@ -19,7 +19,7 @@ import lombok.Setter;
|
|||
|
||||
public abstract class AssociatedContent {
|
||||
|
||||
|
||||
private String mongo_id;
|
||||
private long id;
|
||||
|
||||
private AccessPolicy policy;
|
||||
|
|
|
@ -71,7 +71,8 @@ public class Concessione extends Record{
|
|||
private Double centroidLong;
|
||||
|
||||
private RelazioneScavo relazioneScavo;
|
||||
|
||||
private AssociatedContent abstractRelazione;
|
||||
|
||||
private List<UploadedImage> immaginiRappresentative=new ArrayList<UploadedImage>();
|
||||
|
||||
private LayerConcessione posizionamentoScavo;
|
||||
|
@ -87,6 +88,112 @@ public class Concessione extends Record{
|
|||
}
|
||||
|
||||
|
||||
public static class Paths{
|
||||
public final static String RELAZIONE="relazione";
|
||||
public final static String POSIZIONAMENTO="posizionamentoScavo";
|
||||
public final static String PIANTE="piante";
|
||||
public final static String IMMAGINI="immagini";
|
||||
public final static String ABSTRACT_RELAZIONE="abstract_relazione";
|
||||
public static final String MONGO_ID="mongo_id";
|
||||
|
||||
public final static String piantaByIndex(int index) {return makeByIndex(PIANTE,index);};
|
||||
public final static String imgByIndex(int index) {return makeByIndex(IMMAGINI,index);};
|
||||
|
||||
public final static String piantaById(String id) {return makeByStringField(PIANTE, MONGO_ID, id);};
|
||||
public final static String imgById(String id) {return makeByStringField(IMMAGINI, MONGO_ID, id);};
|
||||
|
||||
|
||||
|
||||
private static String makeByIndex(String base,int value) {return String.format("%1$s[%2$d]",base,value);}
|
||||
private static String makeByStringField(String base,String field,String value)
|
||||
{return String.format("%1$s.%2$s:\"%3$s\"",base,field,value);}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AssociatedContent getContentByPath(String path) {
|
||||
switch(path) {
|
||||
case Paths.RELAZIONE : return getRelazioneScavo();
|
||||
case Paths.POSIZIONAMENTO : return getPosizionamentoScavo();
|
||||
case Paths.ABSTRACT_RELAZIONE: return getAbstractRelazione();
|
||||
}
|
||||
if(path.matches("\\w+\\[\\d+\\]")) {
|
||||
// Array section
|
||||
String field=path.substring(0,path.lastIndexOf("["));
|
||||
Integer index=Integer.parseInt(path.substring(path.lastIndexOf("[")+1,path.lastIndexOf("]")));
|
||||
List<? extends AssociatedContent> list=null;
|
||||
switch (field) {
|
||||
case Paths.IMMAGINI : list = immaginiRappresentative; break;
|
||||
case Paths.PIANTE : list = pianteFineScavo; break;
|
||||
}
|
||||
return getByIndex(list,index);
|
||||
|
||||
}
|
||||
if(path.matches("\\w+\\.\\w+\\s*\\:\\s*\\\"\\w+\\\"")) {
|
||||
// Map section
|
||||
String field=path.substring(0,path.lastIndexOf("."));
|
||||
String subField=path.substring(path.indexOf(".")+1,path.lastIndexOf(":")).trim();
|
||||
String value=path.substring(path.indexOf("\"")+1,path.lastIndexOf("\""));
|
||||
List<? extends AssociatedContent> list=null;
|
||||
switch (field) {
|
||||
case Paths.IMMAGINI : list = immaginiRappresentative; break;
|
||||
case Paths.PIANTE : list = pianteFineScavo; break;
|
||||
}
|
||||
return getByFieldValue(list, subField, value);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static AssociatedContent getByIndex(List<? extends AssociatedContent> list, int index) {
|
||||
if(list == null )return null;
|
||||
return list.get(index);
|
||||
}
|
||||
|
||||
// NB only mongo_id is supported in this impl.
|
||||
private static AssociatedContent getByFieldValue(List<? extends AssociatedContent> list, String field, Object value) {
|
||||
for(AssociatedContent c: list) {
|
||||
switch(field) {
|
||||
case Paths.MONGO_ID : {
|
||||
if(c.getMongo_id()!=null&&c.getMongo_id().equals(value))
|
||||
return c;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setAtPath(AssociatedContent toSet, String path) {
|
||||
switch(path) {
|
||||
case Paths.RELAZIONE : {
|
||||
setRelazioneScavo((RelazioneScavo) toSet);
|
||||
break;
|
||||
}
|
||||
case Paths.POSIZIONAMENTO : {
|
||||
setPosizionamentoScavo((LayerConcessione) toSet);
|
||||
break;
|
||||
}
|
||||
case Paths.ABSTRACT_RELAZIONE:{
|
||||
setAbstractRelazione((AbstractRelazione)toSet);
|
||||
break;
|
||||
}
|
||||
case Paths.PIANTE : {
|
||||
if(pianteFineScavo==null)pianteFineScavo=new ArrayList<LayerConcessione>();
|
||||
pianteFineScavo.add((LayerConcessione) toSet);
|
||||
break;
|
||||
}
|
||||
case Paths.IMMAGINI: {
|
||||
if(immaginiRappresentative==null)immaginiRappresentative=new ArrayList<UploadedImage>();
|
||||
pianteFineScavo.add((LayerConcessione) toSet);
|
||||
break;
|
||||
}
|
||||
|
||||
//TODO MATCH if()case Paths.PIANTa : return
|
||||
//TODO MATCH if()case Paths.Img : return
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValidationReport validate() {
|
||||
ValidationReport validator= super.validate();
|
||||
|
@ -117,8 +224,7 @@ public class Concessione extends Record{
|
|||
validator.checkMandatory(paroleChiaveLibere, "Parole chiave libere");
|
||||
|
||||
validator.checkMandatory(responsabile,"Responsabile");
|
||||
|
||||
|
||||
|
||||
|
||||
validator.checkMandatory(titolareCopyright, "Titolare Copyright");
|
||||
validator.checkMandatory(titolareLicenza,"Titolare licenza");
|
||||
|
@ -127,12 +233,13 @@ public class Concessione extends Record{
|
|||
|
||||
|
||||
if(validator.checkMandatory(relazioneScavo, "Relazione scavo")) {
|
||||
|
||||
|
||||
|
||||
validator.addChild(relazioneScavo.validateForInsertion());
|
||||
}
|
||||
|
||||
if(validator.checkMandatory(abstractRelazione,"Abstract Relazione")){
|
||||
validator.addChild(abstractRelazione.validateForInsertion());
|
||||
}
|
||||
|
||||
// if(immaginiRappresentative!=null)
|
||||
//
|
||||
// for(UploadedImage img : immaginiRappresentative) {
|
||||
|
@ -196,6 +303,13 @@ public class Concessione extends Record{
|
|||
relazioneScavo.setPolicy(getPolicy());
|
||||
}
|
||||
|
||||
if(abstractRelazione!=null) {
|
||||
abstractRelazione.setTitolo(ConstraintCheck.defaultFor(abstractRelazione.getTitolo(),getNome()+" abstract relazione di scavo").evaluate());
|
||||
abstractRelazione.setCreationTime(ConstraintCheck.defaultFor(abstractRelazione.getCreationTime(),getCreationTime()).evaluate());
|
||||
abstractRelazione.setLicenseID(ConstraintCheck.defaultFor(getLicenzaID(), "CC-BY-4.0").evaluate());
|
||||
abstractRelazione.setPolicy(getPolicy());
|
||||
}
|
||||
|
||||
|
||||
if(immaginiRappresentative!=null)
|
||||
for(UploadedImage img : immaginiRappresentative) {
|
||||
|
@ -243,7 +357,7 @@ public class Concessione extends Record{
|
|||
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());;
|
||||
|
@ -308,70 +422,17 @@ public class Concessione extends Record{
|
|||
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;
|
||||
|
@ -448,5 +509,4 @@ public class Concessione extends Record{
|
|||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ public class LayerConcessione extends SDILayerDescriptor{
|
|||
//layer
|
||||
private String layerName;
|
||||
private String wmsLink;
|
||||
|
||||
private String workspace;
|
||||
|
||||
|
||||
//1.Identificazione
|
||||
|
|
|
@ -17,6 +17,7 @@ import lombok.ToString;
|
|||
|
||||
public abstract class Record {
|
||||
|
||||
private String mongo_id;
|
||||
|
||||
//Generic Info
|
||||
private long id;
|
||||
|
@ -41,7 +42,7 @@ public abstract class Record {
|
|||
|
||||
|
||||
|
||||
|
||||
private ValidationReport report;
|
||||
|
||||
public ValidationReport validate() {
|
||||
|
||||
|
@ -50,8 +51,9 @@ public abstract class Record {
|
|||
validator.checkMandatory(getRecordType(), "Record Type");
|
||||
|
||||
validator.checkMandatory(getNome(), "Nome");
|
||||
|
||||
return validator;
|
||||
setReport(validator);
|
||||
|
||||
return getReport();
|
||||
}
|
||||
|
||||
public void setDefaults() {
|
||||
|
@ -65,6 +67,8 @@ public abstract class Record {
|
|||
setLicenzaID(ConstraintCheck.defaultFor(getLicenzaID(),"CC-BY").evaluate());
|
||||
}
|
||||
|
||||
|
||||
|
||||
public abstract AssociatedContent getContentByPath(String path);
|
||||
public abstract void setAtPath(AssociatedContent toSet,String path);
|
||||
|
||||
}
|
||||
|
|
|
@ -16,8 +16,7 @@ public class RelazioneScavo extends AssociatedContent {
|
|||
|
||||
|
||||
|
||||
private String abstractSection;
|
||||
|
||||
|
||||
private List<String> responsabili;
|
||||
private List<String> soggetto;
|
||||
|
||||
|
@ -36,10 +35,7 @@ public class RelazioneScavo extends AssociatedContent {
|
|||
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;
|
||||
}
|
||||
|
@ -53,27 +49,11 @@ public class RelazioneScavo extends AssociatedContent {
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,5 +18,8 @@ public abstract class SDILayerDescriptor extends AssociatedContent{
|
|||
public abstract String getWmsLink();
|
||||
public abstract void setWmsLink(String wmsLink);
|
||||
|
||||
|
||||
public abstract void setWorkspace(String workspace);
|
||||
public abstract String getWorkspace();
|
||||
public abstract BBOX getBbox();
|
||||
public abstract void setBbox(BBOX toSet);
|
||||
}
|
||||
|
|
|
@ -15,4 +15,5 @@ public class WorkspaceContent extends PersistedContent{
|
|||
private String mimetype;
|
||||
private String storageID;
|
||||
private String link;
|
||||
private String name;
|
||||
}
|
||||
|
|
|
@ -5,11 +5,19 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class ValidationReport implements Serializable{
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -3629142756787381094L;
|
||||
|
||||
|
||||
public static enum ValidationStatus{
|
||||
PASSED, ERROR, WARNING
|
||||
}
|
||||
|
|
|
@ -31,17 +31,13 @@ public class Project {
|
|||
|
||||
*
|
||||
*/
|
||||
|
||||
public static enum Status{
|
||||
VALID,INVALID,PUBLISHED
|
||||
}
|
||||
|
||||
private String _id;
|
||||
private String profile_id;
|
||||
private PublicationDetails publication;
|
||||
private Status status;
|
||||
private BasicJSONObject document;
|
||||
private Object document;
|
||||
private Centroid centroid;
|
||||
private PublicationDetails publication;
|
||||
|
||||
|
||||
private String json;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package org.gcube.application.geoportal.common.model.project;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Status {
|
||||
|
||||
|
||||
private StatusPhase phase;
|
||||
private List<String> messages;
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package org.gcube.application.geoportal.common.model.project;
|
||||
|
||||
public enum StatusPhase {
|
||||
|
||||
DRAFT,
|
||||
UNDER_VALIDATION,
|
||||
INVALID,
|
||||
VALID,
|
||||
UNDER_PUBLICATION,
|
||||
PUBLICATION_ERROR,
|
||||
PUBLISHED
|
||||
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
package org.gcube.application.geoportal.common.model.project;
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package org.gcube.application.geoportal.common.model.rest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.gcube.application.geoportal.common.rest.TempFile;
|
||||
|
||||
@XmlRootElement
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class AddSectionToConcessioneRequest {
|
||||
|
||||
private String destinationPath;
|
||||
private List<TempFile> streams;
|
||||
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package org.gcube.application.geoportal.common.model.rest;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Configuration {
|
||||
|
||||
// Index (postgis + layer) Configuration
|
||||
public PostgisIndexDescriptor index;
|
||||
|
||||
|
||||
|
||||
// Mongo DB Configuration
|
||||
// TBD
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package org.gcube.application.geoportal.common.model.rest;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class DatabaseConnection {
|
||||
|
||||
private String user;
|
||||
private String pwd;
|
||||
private String url;
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package org.gcube.application.geoportal.common.model.rest;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class PostgisIndexDescriptor {
|
||||
|
||||
public DatabaseConnection postgisDBIndex;
|
||||
public String wmsLink;
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package org.gcube.application.geoportal.common.model.rest;
|
||||
|
||||
import lombok.Data;
|
||||
import org.bson.Document;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class QueryRequest {
|
||||
|
||||
@Data
|
||||
public static class PagedRequest{
|
||||
private int offset;
|
||||
private int Limit;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class OrderedRequest {
|
||||
public static enum Direction {ASCENDING,DESCENDING}
|
||||
private Direction direction;
|
||||
private String json;
|
||||
private List<String> fields;
|
||||
}
|
||||
private Document filter;
|
||||
private Document projection;
|
||||
private OrderedRequest ordering;
|
||||
private PagedRequest paging;
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
package org.gcube.application.geoportal.common.rest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import org.gcube.application.geoportal.common.model.legacy.AssociatedContent;
|
||||
import org.gcube.application.geoportal.common.model.legacy.InputStreamDescriptor;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@XmlRootElement
|
||||
@Data
|
||||
public class AddSectionToConcessioneRequest {
|
||||
|
||||
private AssociatedContent toRegister;
|
||||
private List<InputStreamDescriptor> streams;
|
||||
|
||||
}
|
|
@ -15,6 +15,16 @@ public class InterfaceConstants {
|
|||
public static final String PROJECTS="projects";
|
||||
|
||||
public static final String CONCESSIONI="concessioni";
|
||||
public static final String MONGO_CONCESSIONI="mongo-concessioni";
|
||||
|
||||
|
||||
public static final String PUBLISH_PATH="publish";
|
||||
public static final String REGISTER_FILES_PATH="registerFiles";
|
||||
public static final String DELETE_FILES_PATH="deleteFiles";
|
||||
public static final String CONFIGURATION_PATH="configuration";
|
||||
public static final String SEARCH_PATH="search";
|
||||
public static final String QUERY_PATH="query";
|
||||
|
||||
}
|
||||
|
||||
public static final class Parameters{
|
||||
|
@ -22,10 +32,12 @@ public class InterfaceConstants {
|
|||
public static final String SECTION_ID="section_id";
|
||||
public static final String PROFILE_ID="profile_id";
|
||||
|
||||
//INVESTIGATE CAPABILITIES
|
||||
public static final String ORDER_BY="order_by";
|
||||
public static final String LIMIT="limit";
|
||||
public static final String OFFSET="offset";
|
||||
// //INVESTIGATE CAPABILITIES
|
||||
// public static final String ORDER_BY="order_by";
|
||||
// public static final String LIMIT="limit";
|
||||
// public static final String OFFSET="offset";
|
||||
public static final String FORCE="force";
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
package org.gcube.application.geoportal.common.rest;
|
||||
|
||||
import org.gcube.application.geoportal.common.model.legacy.Concessione;
|
||||
import org.gcube.application.geoportal.common.model.rest.AddSectionToConcessioneRequest;
|
||||
import org.gcube.application.geoportal.common.model.rest.Configuration;
|
||||
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
public interface MongoConcessioni {
|
||||
|
||||
public Concessione createNew(Concessione c) throws Exception;
|
||||
public void deleteById(String id) throws Exception;
|
||||
public void deleteById(String id,Boolean force) throws Exception;
|
||||
public Concessione getById(String id) throws Exception;
|
||||
public Iterator<Concessione> getList()throws Exception;
|
||||
public Concessione publish(String id) throws Exception;
|
||||
public Concessione registerFileSet(String id, AddSectionToConcessioneRequest request) throws Exception;
|
||||
public Concessione cleanFileSet(String id, String path) throws Exception;
|
||||
public Concessione update(String id, String jsonUpdate) throws Exception;
|
||||
public Concessione replace(Concessione replacement) throws Exception;
|
||||
|
||||
public void unPublish(String id)throws Exception;
|
||||
|
||||
|
||||
public Configuration getCurrentConfiguration()throws Exception;
|
||||
public Iterator<Concessione> search(String filter)throws Exception;
|
||||
public Iterator<Concessione> query(QueryRequest request) throws Exception;
|
||||
public String queryForJSON(QueryRequest request) throws Exception;
|
||||
|
||||
public <T> Iterator<T> queryForType(QueryRequest request,Class<T> clazz) throws Exception;
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package org.gcube.application.geoportal.common.rest;
|
||||
|
||||
import org.gcube.application.geoportal.common.model.project.Project;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
public interface ProjectsI {
|
||||
|
||||
|
||||
public Iterator<Project> getAll() throws Exception;
|
||||
public Iterator<Project> getByProfile(String profileId) throws Exception;
|
||||
public Project getById(String profileId,String id) throws Exception;
|
||||
public Iterator<Project> getByFilter(String filter)throws Exception;
|
||||
public Iterator<Project> getByFilter(String filter, String profileId)throws Exception;
|
||||
public Project registrNew(String profileId, String jsonDocument)throws Exception;
|
||||
public Project update(String profileId, String projectId,String jsonDocument) throws Exception;
|
||||
public void deleteById(String profileId, String projectId)throws Exception;
|
||||
public void deleteById(String profileId, String projectId, Boolean force)throws Exception;
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package org.gcube.application.geoportal.common.rest;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class TempFile {
|
||||
|
||||
private String id;
|
||||
private String filename;
|
||||
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package org.gcube.application.geoportal.common.utils;
|
||||
|
||||
import static org.gcube.common.authorization.client.Constants.authorizationService;
|
||||
|
||||
import org.gcube.common.authorization.library.AuthorizationEntry;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class ContextUtils {
|
||||
|
||||
|
||||
public static String getCurrentScope(){
|
||||
try{
|
||||
String token=SecurityTokenProvider.instance.get();
|
||||
log.debug("Token is : "+token);
|
||||
if(token==null) throw new Exception("Security Token is null");
|
||||
AuthorizationEntry entry = authorizationService().get(token);
|
||||
return entry.getContext();
|
||||
}catch(Exception e ){
|
||||
log.debug("Unable to resolve token, checking scope provider..",e);
|
||||
return ScopeProvider.instance.get();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static String getCurrentCaller(){
|
||||
try{
|
||||
String token=SecurityTokenProvider.instance.get();
|
||||
log.debug("Token is : "+token);
|
||||
if(token==null) throw new Exception("Security Token is null");
|
||||
AuthorizationEntry entry = authorizationService().get(token);
|
||||
return entry.getClientInfo().getId();
|
||||
}catch(Exception e ){
|
||||
log.debug("Unable to resolve token, checking scope provider..",e);
|
||||
return "Unidentified data-transfer user";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -37,5 +37,12 @@ public class Files {
|
|||
|
||||
}
|
||||
|
||||
|
||||
public static String fixFilename(String toFix) {
|
||||
if(toFix.contains(".")) {
|
||||
String prefix=toFix.substring(toFix.lastIndexOf("."));
|
||||
toFix=toFix.substring(0,toFix.lastIndexOf("."));
|
||||
return toFix.toLowerCase().replaceAll("[\\*\\+\\/\\\\ \\[\\]\\(\\)\\.\\\"\\:\\;\\|]","_")+prefix;
|
||||
}
|
||||
return toFix.toLowerCase().replaceAll("[\\*\\+\\/\\\\ \\[\\]\\(\\)\\.\\\"\\:\\;\\|]","_");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
package org.gcube.application.geoportal.common.utils;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStream;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.application.geoportal.common.rest.InterfaceConstants;
|
||||
import org.gcube.application.geoportal.common.rest.TempFile;
|
||||
import org.gcube.contentmanagement.blobstorage.service.IClient;
|
||||
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.AccessType;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.MemoryType;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.StorageClient;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class StorageUtils {
|
||||
|
||||
public static final IClient getClient(){
|
||||
return new StorageClient(InterfaceConstants.SERVICE_CLASS, InterfaceConstants.SERVICE_NAME, ContextUtils.getCurrentCaller(), AccessType.SHARED, MemoryType.VOLATILE).getClient();
|
||||
}
|
||||
|
||||
private IClient client;
|
||||
public StorageUtils() {
|
||||
client=getClient();
|
||||
}
|
||||
|
||||
//return Id
|
||||
public TempFile putOntoStorage(InputStream source,String filename) throws RemoteBackendException, FileNotFoundException{
|
||||
log.debug("Uploading source "+filename);
|
||||
String id=client.put(true).LFile(source).RFile(getUniqueString());
|
||||
return new TempFile(id,filename);
|
||||
}
|
||||
|
||||
public static final boolean checkStorageId(String id){
|
||||
return getClient().getHttpUrl().RFile(id)!=null;
|
||||
}
|
||||
|
||||
public static final String getUrlById(String id){
|
||||
IClient client=getClient();
|
||||
log.debug("Id is "+id);
|
||||
return client.getHttpUrl().RFile(id);
|
||||
}
|
||||
|
||||
public static final void removeById(String id){
|
||||
IClient client=getClient();
|
||||
client.remove().RFile(id);
|
||||
}
|
||||
|
||||
|
||||
public static final String getUniqueString(){
|
||||
return UUID.randomUUID().toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package org.gcube.application.geoportal.common.model;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.application.geoportal.common.model.legacy.Concessione;
|
||||
import org.gcube.application.geoportal.common.model.legacy.Concessione.Paths;
|
||||
import org.gcube.application.geoportal.common.model.legacy.LayerConcessione;
|
||||
import org.gcube.application.geoportal.common.model.legacy.RelazioneScavo;
|
||||
import org.gcube.application.geoportal.common.model.legacy.UploadedImage;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
public class PathsTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void embeddedPaths() {
|
||||
Concessione c=TestModel.prepareConcessione();
|
||||
c=TestModel.setIds(c);
|
||||
|
||||
|
||||
|
||||
LayerConcessione p=(LayerConcessione) c.getContentByPath(Paths.POSIZIONAMENTO);
|
||||
assertEquals(c.getPosizionamentoScavo(), p);
|
||||
|
||||
RelazioneScavo rel=(RelazioneScavo) c.getContentByPath(Paths.RELAZIONE);
|
||||
assertEquals(c.getRelazioneScavo(), rel);
|
||||
|
||||
for(int i=0;i<c.getPianteFineScavo().size();i++) {
|
||||
LayerConcessione l=(LayerConcessione) c.getContentByPath(Paths.piantaByIndex(i));
|
||||
assertEquals(c.getPianteFineScavo().get(i),l);
|
||||
}
|
||||
|
||||
for(int i=0;i<c.getImmaginiRappresentative().size();i++) {
|
||||
UploadedImage l=(UploadedImage) c.getContentByPath(Paths.imgByIndex(i));
|
||||
assertEquals(c.getImmaginiRappresentative().get(i),l);
|
||||
}
|
||||
|
||||
|
||||
for(int i=0;i<c.getPianteFineScavo().size();i++) {
|
||||
LayerConcessione layer=c.getPianteFineScavo().get(i);
|
||||
LayerConcessione l=(LayerConcessione) c.getContentByPath(Paths.piantaById(layer.getMongo_id()));
|
||||
assertEquals(layer,l);
|
||||
}
|
||||
|
||||
|
||||
|
||||
for(int i=0;i<c.getImmaginiRappresentative().size();i++) {
|
||||
UploadedImage layer=c.getImmaginiRappresentative().get(i);
|
||||
UploadedImage l=(UploadedImage) c.getContentByPath(Paths.imgById(layer.getMongo_id()));
|
||||
assertEquals(layer,l);
|
||||
}
|
||||
|
||||
|
||||
System.out.println();
|
||||
System.out.println();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -48,4 +48,18 @@ public class SerializationTest {
|
|||
System.out.println("Concessione is "+concessione.toString());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void generic() throws JsonProcessingException, IOException {
|
||||
Concessione conc=TestModel.prepareConcessione();
|
||||
conc.validate();
|
||||
full(conc);
|
||||
}
|
||||
|
||||
|
||||
public void full(Object obj) throws JsonProcessingException, IOException {
|
||||
String asString=mapper.writeValueAsString(obj);
|
||||
Object other=mapper.readerFor(obj.getClass()).readValue(asString);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,130 @@
|
|||
package org.gcube.application.geoportal.common.model;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.application.geoportal.common.model.legacy.AccessPolicy;
|
||||
import org.gcube.application.geoportal.common.model.legacy.Concessione;
|
||||
import org.gcube.application.geoportal.common.model.legacy.LayerConcessione;
|
||||
import org.gcube.application.geoportal.common.model.legacy.RelazioneScavo;
|
||||
import org.gcube.application.geoportal.common.model.legacy.UploadedImage;
|
||||
|
||||
public class TestModel {
|
||||
|
||||
private static final String rnd() {
|
||||
return UUID.randomUUID().toString().replace("-", "_");
|
||||
}
|
||||
|
||||
|
||||
public static final Concessione setIds(Concessione c) {
|
||||
c.setMongo_id(rnd());
|
||||
c.getRelazioneScavo().setMongo_id(rnd());
|
||||
c.getPosizionamentoScavo().setMongo_id(rnd());
|
||||
c.getPianteFineScavo().forEach((LayerConcessione l)->{l.setMongo_id(rnd());});
|
||||
c.getImmaginiRappresentative().forEach((UploadedImage i)->{i.setMongo_id(rnd());});
|
||||
return c;
|
||||
}
|
||||
|
||||
public static Concessione prepareEmptyConcessione() {
|
||||
Concessione concessione=new Concessione();
|
||||
|
||||
// Generic fields
|
||||
|
||||
// Concessione fields
|
||||
|
||||
|
||||
|
||||
|
||||
concessione.setNome("MONGO Italia, forse, ma su ");
|
||||
concessione.setIntroduzione("This is my MONGO 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.setFontiFinanziamento(Arrays.asList(new String[] {"Big pharma","Pentagon"}));
|
||||
|
||||
|
||||
concessione.setSoggetto(Arrays.asList(new String[] {"Research Excavation","Archeology"}));
|
||||
|
||||
|
||||
concessione.setDataInizioProgetto(LocalDateTime.now());
|
||||
concessione.setDataFineProgetto(LocalDateTime.now());
|
||||
|
||||
concessione.setLicenzaID("CC-BY");
|
||||
|
||||
concessione.setTitolareLicenza(Arrays.asList(new String[] {"Qualcun altro"}));
|
||||
concessione.setTitolareCopyright(Arrays.asList(new String[] {"Chiedilo in giro"}));
|
||||
|
||||
concessione.setParoleChiaveLibere(Arrays.asList(new String[] {"Robba","Stuff"}));
|
||||
concessione.setParoleChiaveICCD(Arrays.asList(new String[] {"vattelapesca","somthing something"}));
|
||||
|
||||
|
||||
concessione.setCentroidLat(43.0); //N-S
|
||||
concessione.setCentroidLong(9.0); //E-W
|
||||
|
||||
return concessione;
|
||||
}
|
||||
|
||||
public static Concessione prepareConcessione() {
|
||||
|
||||
Concessione concessione=prepareEmptyConcessione();
|
||||
|
||||
|
||||
|
||||
// Attachments
|
||||
|
||||
// Relazione scavo
|
||||
RelazioneScavo relScavo=new RelazioneScavo();
|
||||
|
||||
relScavo.setAbstractEng("simple abstract section");
|
||||
relScavo.setResponsabili(concessione.getAuthors());
|
||||
|
||||
|
||||
|
||||
|
||||
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.setCreationTime(LocalDateTime.now());
|
||||
img.setResponsabili(concessione.getAuthors());
|
||||
imgs.add(img);
|
||||
|
||||
}
|
||||
concessione.setImmaginiRappresentative(imgs);
|
||||
//Posizionamento
|
||||
LayerConcessione posizionamento=new LayerConcessione();
|
||||
posizionamento.setValutazioneQualita("Secondo me si");
|
||||
posizionamento.setMetodoRaccoltaDati("Fattobbene");
|
||||
posizionamento.setScalaAcquisizione("1:10000");
|
||||
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.setValutazioneQualita("Secondo me si");
|
||||
pianta.setMetodoRaccoltaDati("Fattobbene");
|
||||
pianta.setScalaAcquisizione("1:10000");
|
||||
pianta.setAuthors(concessione.getAuthors());
|
||||
pianta.setPolicy(AccessPolicy.RESTRICTED);
|
||||
piante.add(pianta);
|
||||
}
|
||||
concessione.setPianteFineScavo(piante);
|
||||
|
||||
return concessione;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue