Compare commits

...

15 Commits

15 changed files with 170 additions and 107 deletions

View File

@ -2,6 +2,14 @@ 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

View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.gcube.application</groupId>
<artifactId>geoportal-common</artifactId>
<version>1.0.5</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>
@ -85,12 +85,12 @@
<dependency>
<groupId>org.gcube.contentmanagement</groupId>
<artifactId>storage-manager-core</artifactId>
<version>[2.0.0, 3.0.0)</version>
<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)</version>
<version>[2.0.0, 3.0.0-SNAPSHOT)</version>
</dependency>

View File

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

View File

@ -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;
@ -92,7 +93,7 @@ public class Concessione extends Record{
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);};
@ -113,6 +114,7 @@ public class Concessione extends Record{
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
@ -168,7 +170,11 @@ public class Concessione extends Record{
break;
}
case Paths.POSIZIONAMENTO : {
setRelazioneScavo((RelazioneScavo) toSet);
setPosizionamentoScavo((LayerConcessione) toSet);
break;
}
case Paths.ABSTRACT_RELAZIONE:{
setAbstractRelazione((AbstractRelazione)toSet);
break;
}
case Paths.PIANTE : {
@ -218,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");
@ -228,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) {
@ -297,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) {
@ -344,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());;
@ -409,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;

View File

@ -16,10 +16,7 @@ public class RelazioneScavo extends AssociatedContent {
// private String abstractSection;
private String abstractIta;
private String abstractEng;
private List<String> responsabili;
private List<String> soggetto;
@ -38,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;
}
@ -55,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;
}

View File

@ -15,4 +15,5 @@ public class WorkspaceContent extends PersistedContent{
private String mimetype;
private String storageID;
private String link;
private String name;
}

View File

@ -1,4 +1,4 @@
package org.gcube.application.geoportal.common.rest;
package org.gcube.application.geoportal.common.model.rest;
import java.util.List;
@ -7,6 +7,7 @@ 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

View File

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

View File

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

View File

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

View File

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

View File

@ -20,6 +20,10 @@ public class InterfaceConstants {
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";
}
@ -28,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";
}

View File

@ -1,17 +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 Iterable<Concessione> getList()throws Exception;
public Iterator<Concessione> getList()throws Exception;
public Concessione publish(String id) throws Exception;
public Concessione registerFile(String id, AddSectionToConcessioneRequest request) 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;
}

View File

@ -2,15 +2,18 @@ package org.gcube.application.geoportal.common.rest;
import org.gcube.application.geoportal.common.model.project.Project;
import java.util.Iterator;
public interface ProjectsI {
public Iterable<Project> getAll() throws Exception;
public Iterable<Project> getByProfile(String profileId) throws Exception;
public Iterator<Project> getAll() throws Exception;
public Iterator<Project> getByProfile(String profileId) throws Exception;
public Project getById(String profileId,String id) throws Exception;
public Iterable<Project> getByFilter(String filter)throws Exception;
public Iterable<Project> getByFilter(String filter, String profileId)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;
}

View File

@ -86,6 +86,9 @@ public class TestModel {
relScavo.setAbstractEng("simple abstract section");
relScavo.setResponsabili(concessione.getAuthors());
concessione.setRelazioneScavo(relScavo);
//Immagini rappresentative
ArrayList<UploadedImage> imgs=new ArrayList<>();