UCD and project models
This commit is contained in:
parent
43ddf88ba8
commit
1e84ca40a7
49
pom.xml
49
pom.xml
|
@ -100,55 +100,62 @@
|
|||
</dependency>
|
||||
<!-- END FORCING -->
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.9.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.gwtbootstrap</groupId>
|
||||
<artifactId>gwt-bootstrap</artifactId>
|
||||
<version>2.3.2.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.tdesjardins</groupId>
|
||||
<artifactId>gwt-ol3</artifactId>
|
||||
<!-- <version>8.1.0-gwt2_9</version> -->
|
||||
<!-- <version>8.1.0-gwt2_9</version> -->
|
||||
<version>8.2.0-gwt2_8</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.spatial.data</groupId>
|
||||
<artifactId>geo-utility</artifactId>
|
||||
<version>[1.0.0,2.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>gcube-url-shortener</artifactId>
|
||||
<version>[1.0.0,2.0.0-SNAPSHOT)</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>keycloak-client</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- <dependency> -->
|
||||
<!-- <groupId>org.projectlombok</groupId> -->
|
||||
<!-- <artifactId>lombok</artifactId> -->
|
||||
<!-- <version>1.14.8</version> -->
|
||||
<!-- </dependency> -->
|
||||
<!-- <dependency> -->
|
||||
<!-- <groupId>org.projectlombok</groupId> -->
|
||||
<!-- <artifactId>lombok</artifactId> -->
|
||||
<!-- <version>1.14.8</version> -->
|
||||
<!-- </dependency> -->
|
||||
|
||||
<!-- PROVIDED in GATEWAY -->
|
||||
<!-- PROVIDED in GATEWAY -->
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<scope>provided</scope>
|
||||
<!-- <scope>system</scope> -->
|
||||
<!-- <systemPath>/Users/fabioisti/.m2/repository/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar</systemPath> -->
|
||||
<!-- <scope>system</scope> -->
|
||||
<!-- <systemPath>/Users/fabioisti/.m2/repository/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar</systemPath> -->
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
@ -186,7 +193,7 @@
|
|||
<artifactId>oidc-library</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.resources.discovery</groupId>
|
||||
<artifactId>ic-client</artifactId>
|
||||
|
@ -207,8 +214,8 @@
|
|||
<artifactId>usermanagement-core</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.liferay.portal</groupId>
|
||||
<artifactId>portal-service</artifactId>
|
||||
|
@ -229,11 +236,11 @@
|
|||
<artifactId>slf4j-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- TEST -->
|
||||
|
||||
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
|
|
|
@ -165,6 +165,22 @@ public class GeoportalDataViewer implements EntryPoint {
|
|||
|
||||
});
|
||||
|
||||
GeoportalDataViewerServiceAsync.Util.getInstance().getAvailableCollections(new AsyncCallback<List<GCubeCollection>>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
GWT.log("Failure on loading available collections ", caught);
|
||||
Window.alert("Sorry, an error occurred while gathering collections. Please, contact the support");
|
||||
}
|
||||
|
||||
public void onSuccess(java.util.List<GCubeCollection> result) {
|
||||
GWT.log("Loaded Collections");
|
||||
result.forEach(g ->GWT.log(g.getUcd().getName()));
|
||||
|
||||
};
|
||||
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import org.gcube.application.geoportalcommon.shared.gis.BoundsMap;
|
|||
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.GCubeCollection;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject;
|
||||
|
@ -151,4 +152,9 @@ public interface GeoportalDataViewerService extends RemoteService {
|
|||
ResultSetPaginatedData getListConcessioni(Integer start, Integer limit, SearchingFilter filter,
|
||||
boolean reloadFromService) throws Exception;
|
||||
|
||||
|
||||
// Collections
|
||||
|
||||
List<GCubeCollection> getAvailableCollections() throws Exception;
|
||||
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import org.gcube.application.geoportalcommon.shared.gis.BoundsMap;
|
|||
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.GCubeCollection;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject;
|
||||
|
@ -68,4 +69,11 @@ public interface GeoportalDataViewerServiceAsync {
|
|||
void getListConcessioni(Integer start, Integer limit, SearchingFilter filter, boolean reloadFromService,
|
||||
AsyncCallback<ResultSetPaginatedData> callback);
|
||||
|
||||
|
||||
|
||||
|
||||
// Collections
|
||||
|
||||
void getAvailableCollections(AsyncCallback<List<GCubeCollection>> callback);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.server;
|
||||
|
||||
import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin.useCaseDescriptors;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
@ -10,9 +12,12 @@ import java.util.Map;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.gcube.application.geoportal.client.utils.Serialization;
|
||||
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.UploadedImage;
|
||||
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
|
||||
import org.gcube.application.geoportal.common.rest.UseCaseDescriptorsI;
|
||||
import org.gcube.application.geoportalcommon.ConvertToDataViewModel;
|
||||
import org.gcube.application.geoportalcommon.GeoportalCommon;
|
||||
import org.gcube.application.geoportalcommon.MongoServiceCommon;
|
||||
|
@ -36,7 +41,9 @@ import org.gcube.portlets.user.geoportaldataviewer.server.gis.WMSUrlValidator;
|
|||
import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.ConcessioniMongoServiceIdentityProxy;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accesspolicy.GeoNACheckAccessPolicy;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.server.util.SessionUtil;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.GCubeCollection;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.cl.ucd.UCD;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.FeatureRow;
|
||||
|
@ -765,5 +772,25 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ************************************** COLLECTIONS
|
||||
|
||||
@Override
|
||||
public List<GCubeCollection> getAvailableCollections() throws Exception {
|
||||
ArrayList<GCubeCollection> toReturn= new ArrayList<GCubeCollection>();
|
||||
|
||||
UseCaseDescriptorsI client = useCaseDescriptors().build();
|
||||
client.query(new QueryRequest()).forEachRemaining(u->{
|
||||
UCD ucd = Serialization.convert(u, UCD.class);
|
||||
|
||||
GCubeCollection coll=new GCubeCollection();
|
||||
coll.setUcd(ucd);
|
||||
|
||||
toReturn.add(coll);
|
||||
});
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,16 +5,17 @@ import java.io.Serializable;
|
|||
import java.util.List;
|
||||
|
||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.cl.ucd.UCD;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.IndexLayer;
|
||||
|
||||
|
||||
public class GCubeCollection implements Serializable {
|
||||
|
||||
private UseCaseDescriptor ucd;
|
||||
private UCD ucd;
|
||||
private List<IndexLayer> indexes;
|
||||
|
||||
|
||||
public UseCaseDescriptor getUcd() {
|
||||
public UCD getUcd() {
|
||||
return ucd;
|
||||
}
|
||||
|
||||
|
@ -22,4 +23,12 @@ public class GCubeCollection implements Serializable {
|
|||
return indexes;
|
||||
}
|
||||
|
||||
|
||||
public void setUcd(UCD ucd) {
|
||||
this.ucd = ucd;
|
||||
}
|
||||
|
||||
public void setIndexes(List<IndexLayer> indexes) {
|
||||
this.indexes = indexes;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.shared.cl.document;
|
||||
|
||||
|
||||
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.cl.document.accouting.AccountingInfo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
public class Lock {
|
||||
|
||||
public static final String ID="_id";
|
||||
public static final String INFO="_info";
|
||||
public static final String OPERATION="_operation";
|
||||
|
||||
@JsonProperty(INFO)
|
||||
private AccountingInfo info;
|
||||
@JsonProperty(ID)
|
||||
private String id;
|
||||
@JsonProperty(OPERATION)
|
||||
private String operation;
|
||||
public AccountingInfo getInfo() {
|
||||
return info;
|
||||
}
|
||||
public void setInfo(AccountingInfo info) {
|
||||
this.info = info;
|
||||
}
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
public String getOperation() {
|
||||
return operation;
|
||||
}
|
||||
public void setOperation(String operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,203 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.shared.cl.document;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.cl.document.accouting.PublicationInfo;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.cl.document.identification.IdentificationReference;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.cl.document.lifecycle.LifecycleInformation;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.cl.document.relationships.Relationship;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
|
||||
public class Project {
|
||||
|
||||
public static final String ID="_id";
|
||||
public static final String VERSION="_version";
|
||||
public static final String INFO="_info";
|
||||
public static final String PROFILE_ID="_profileID";
|
||||
public static final String PROFILE_VERSION="_profileVersion";
|
||||
public static final String LIFECYCLE_INFORMATION="_lifecycleInformation";
|
||||
public static final String RELATIONSHIPS="_relationships";
|
||||
public static final String IDENTIFICATION_REFERENCES="_identificationReferences";
|
||||
public static final String THE_DOCUMENT="_theDocument";
|
||||
public static final String LOCK="_lock";
|
||||
|
||||
// CORE METADATA
|
||||
|
||||
@JsonProperty(ID)
|
||||
private String id;
|
||||
@JsonProperty(VERSION)
|
||||
private String version;
|
||||
|
||||
// Publication Info
|
||||
@JsonProperty(INFO)
|
||||
private PublicationInfo info;
|
||||
|
||||
// UseCaseDescriptor reference
|
||||
@JsonProperty(PROFILE_ID)
|
||||
private String profileID;
|
||||
@JsonProperty(PROFILE_VERSION)
|
||||
private String profileVersion;
|
||||
|
||||
@JsonProperty(LIFECYCLE_INFORMATION)
|
||||
private LifecycleInformation lifecycleInformation;
|
||||
|
||||
@JsonProperty(RELATIONSHIPS)
|
||||
private List<Relationship> relationships;
|
||||
|
||||
@JsonProperty(IDENTIFICATION_REFERENCES)
|
||||
private List<IdentificationReference> identificationReferences;
|
||||
|
||||
@JsonProperty(THE_DOCUMENT)
|
||||
private Object theDocument;
|
||||
|
||||
@JsonProperty(LOCK)
|
||||
private Lock lock;
|
||||
|
||||
|
||||
/**
|
||||
* Similar to equals but without checking following fields
|
||||
*
|
||||
* lock
|
||||
* @param o
|
||||
* @return
|
||||
*/
|
||||
public boolean isEquivalent(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof Project)) return false;
|
||||
Project project = (Project) o;
|
||||
return Objects.equals(getId(), project.getId()) && Objects.equals(getVersion(), project.getVersion()) && Objects.equals(getInfo(), project.getInfo()) && Objects.equals(getProfileID(), project.getProfileID()) && Objects.equals(getProfileVersion(), project.getProfileVersion()) && Objects.equals(getLifecycleInformation(), project.getLifecycleInformation()) && Objects.equals(getIdentificationReferences(), project.getIdentificationReferences()) && Objects.equals(getRelationships(), project.getRelationships()) && Objects.equals(getTheDocument(), project.getTheDocument());
|
||||
}
|
||||
|
||||
|
||||
@JsonIgnore
|
||||
public List<IdentificationReference> getIdentificationReferenceByType(String type){
|
||||
if(identificationReferences==null) return Collections.emptyList();
|
||||
else return identificationReferences.stream()
|
||||
.filter(item -> item.getType().equals(type)).collect(Collectors.toList());
|
||||
};
|
||||
|
||||
@JsonIgnore
|
||||
public List<Relationship> getRelationshipsByName(String relation){
|
||||
if(relationships==null)return Collections.emptyList();
|
||||
else return relationships.stream().filter(relationship -> relationship.
|
||||
getRelationshipName().equals(relation)).collect(Collectors.toList());
|
||||
};
|
||||
|
||||
|
||||
@JsonIgnore
|
||||
public Project addRelation(Relationship rel){
|
||||
if(relationships==null) relationships = new ArrayList<>();
|
||||
relationships.add(rel);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
|
||||
public PublicationInfo getInfo() {
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
public void setInfo(PublicationInfo info) {
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
|
||||
public String getProfileID() {
|
||||
return profileID;
|
||||
}
|
||||
|
||||
|
||||
public void setProfileID(String profileID) {
|
||||
this.profileID = profileID;
|
||||
}
|
||||
|
||||
|
||||
public String getProfileVersion() {
|
||||
return profileVersion;
|
||||
}
|
||||
|
||||
|
||||
public void setProfileVersion(String profileVersion) {
|
||||
this.profileVersion = profileVersion;
|
||||
}
|
||||
|
||||
|
||||
public LifecycleInformation getLifecycleInformation() {
|
||||
return lifecycleInformation;
|
||||
}
|
||||
|
||||
|
||||
public void setLifecycleInformation(LifecycleInformation lifecycleInformation) {
|
||||
this.lifecycleInformation = lifecycleInformation;
|
||||
}
|
||||
|
||||
|
||||
public List<Relationship> getRelationships() {
|
||||
return relationships;
|
||||
}
|
||||
|
||||
|
||||
public void setRelationships(List<Relationship> relationships) {
|
||||
this.relationships = relationships;
|
||||
}
|
||||
|
||||
|
||||
public List<IdentificationReference> getIdentificationReferences() {
|
||||
return identificationReferences;
|
||||
}
|
||||
|
||||
|
||||
public void setIdentificationReferences(List<IdentificationReference> identificationReferences) {
|
||||
this.identificationReferences = identificationReferences;
|
||||
}
|
||||
|
||||
|
||||
public Object getTheDocument() {
|
||||
return theDocument;
|
||||
}
|
||||
|
||||
|
||||
public void setTheDocument(Object theDocument) {
|
||||
this.theDocument = theDocument;
|
||||
}
|
||||
|
||||
|
||||
public Lock getLock() {
|
||||
return lock;
|
||||
}
|
||||
|
||||
|
||||
public void setLock(Lock lock) {
|
||||
this.lock = lock;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.shared.cl.document.access;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
public class Access {
|
||||
|
||||
public static final String POLICY="_policy";
|
||||
public static final String LICENSE="_license";
|
||||
|
||||
@JsonProperty(POLICY)
|
||||
private AccessPolicy policy;
|
||||
@JsonProperty(LICENSE)
|
||||
private String license;
|
||||
public AccessPolicy getPolicy() {
|
||||
return policy;
|
||||
}
|
||||
public void setPolicy(AccessPolicy policy) {
|
||||
this.policy = policy;
|
||||
}
|
||||
public String getLicense() {
|
||||
return license;
|
||||
}
|
||||
public void setLicense(String license) {
|
||||
this.license = license;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.shared.cl.document.access;
|
||||
|
||||
public enum AccessPolicy {
|
||||
|
||||
OPEN,RESTRICTED,EMBARGOED;
|
||||
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.shared.cl.document.accouting;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
|
||||
public class AccountingInfo {
|
||||
|
||||
public static final String USER="_user";
|
||||
public static final String CONTEXT="_context";
|
||||
public static final String INSTANT="_instant";
|
||||
|
||||
@JsonProperty(USER)
|
||||
private User user;
|
||||
@JsonProperty(CONTEXT)
|
||||
private Context context;
|
||||
@JsonProperty(INSTANT)
|
||||
private String instant;
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
public Context getContext() {
|
||||
return context;
|
||||
}
|
||||
public void setContext(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
public String getInstant() {
|
||||
return instant;
|
||||
}
|
||||
public void setInstant(String instant) {
|
||||
this.instant = instant;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.shared.cl.document.accouting;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
public class Context {
|
||||
public static final String ID="_id";
|
||||
public static final String NAME = "_name";
|
||||
|
||||
@JsonProperty(ID)
|
||||
private String id;
|
||||
@JsonProperty(NAME)
|
||||
private String name;
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.shared.cl.document.accouting;
|
||||
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.cl.document.access.Access;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
public class PublicationInfo {
|
||||
|
||||
public static final String CREATION_INFO="_creationInfo";
|
||||
public static final String LAST_EDIT_INFO="_lastEditInfo";
|
||||
public static final String ACCESS = "_access";
|
||||
|
||||
@JsonProperty(CREATION_INFO)
|
||||
private AccountingInfo creationInfo;
|
||||
@JsonProperty(LAST_EDIT_INFO)
|
||||
private AccountingInfo lastEditInfo;
|
||||
@JsonProperty(ACCESS)
|
||||
private Access access;
|
||||
public AccountingInfo getCreationInfo() {
|
||||
return creationInfo;
|
||||
}
|
||||
public void setCreationInfo(AccountingInfo creationInfo) {
|
||||
this.creationInfo = creationInfo;
|
||||
}
|
||||
public AccountingInfo getLastEditInfo() {
|
||||
return lastEditInfo;
|
||||
}
|
||||
public void setLastEditInfo(AccountingInfo lastEditInfo) {
|
||||
this.lastEditInfo = lastEditInfo;
|
||||
}
|
||||
public Access getAccess() {
|
||||
return access;
|
||||
}
|
||||
public void setAccess(Access access) {
|
||||
this.access = access;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.shared.cl.document.accouting;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
public class User {
|
||||
|
||||
public static final String USERNAME="_username";
|
||||
|
||||
@JsonProperty(USERNAME)
|
||||
private String username;
|
||||
|
||||
@JsonIgnore
|
||||
private Set<String> roles;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof User)) return false;
|
||||
User user = (User) o;
|
||||
return Objects.equals(getUsername(), user.getUsername());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(getUsername());
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public Set<String> getRoles() {
|
||||
return roles;
|
||||
}
|
||||
|
||||
public void setRoles(Set<String> roles) {
|
||||
this.roles = roles;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.shared.cl.document.identification;
|
||||
|
||||
public class CentroidRecordReference extends IdentificationReference{
|
||||
|
||||
public static final String CENTROID_RECORD_REFERENCE="CENTROID_RECORD_TYPE";
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.shared.cl.document.identification;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.google.gwt.json.client.JSONObject;
|
||||
import com.google.gwt.json.client.JSONString;
|
||||
|
||||
|
||||
public class IdentificationReference extends JSONObject {
|
||||
|
||||
public static final String TYPE="_type";
|
||||
|
||||
public IdentificationReference(String type) {
|
||||
setType(type);
|
||||
}
|
||||
|
||||
public IdentificationReference() {}
|
||||
|
||||
@JsonIgnore
|
||||
public String getType(){return super.get(TYPE).toString();}
|
||||
@JsonIgnore
|
||||
public void setType(String type){super.put(TYPE, new JSONString(type));}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.shared.cl.document.identification;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
|
||||
public class SpatialReference extends IdentificationReference{
|
||||
|
||||
public static final String SPATIAL_REFERENCE_TYPE="SPATIAL REFERENCE";
|
||||
public static final String GEO_JSON="geoJSON";
|
||||
|
||||
|
||||
public SpatialReference(Object geoJSON) {
|
||||
// setGeoJson(geoJSON);
|
||||
setType(SPATIAL_REFERENCE_TYPE);
|
||||
}
|
||||
|
||||
public SpatialReference() {}
|
||||
|
||||
|
||||
@JsonIgnore
|
||||
public Object getGeoJson(){return super.get(GEO_JSON);}
|
||||
// @JsonIgnore
|
||||
// public Object setGeoJson(Object geoJSON){return super.put(GEO_JSON,JSONObject.geoJSON);}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.shared.cl.document.identification;
|
||||
|
||||
public class TemporalReference extends IdentificationReference {
|
||||
|
||||
public static final String TEMPORAL_REFERENCE_TYPE="TEMPORAL_REFERENCE_TYPE";
|
||||
}
|
|
@ -0,0 +1,139 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.shared.cl.document.lifecycle;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class LifecycleInformation {
|
||||
|
||||
public static final class CommonPhases{
|
||||
public static final String DRAFT_PHASE="DRAFT";
|
||||
}
|
||||
|
||||
//COMMON PHASES
|
||||
|
||||
|
||||
public static final String PHASE="_phase";
|
||||
public static final String LAST_INVOKED_STEP="_lastInvokedStep";
|
||||
public static final String LAST_OPERATION_STATUS="_lastOperationStatus";
|
||||
public static final String ERROR_MESSAGES="_errorMessages";
|
||||
public static final String WARNING_MESSAGES="_warningMessages";
|
||||
public static final String TRIGGERED_EVENTS="_triggeredEvents";
|
||||
public static final String NOTES="_notes";
|
||||
|
||||
public static enum Status{
|
||||
OK,ERROR,WARNING
|
||||
}
|
||||
|
||||
@JsonProperty(PHASE)
|
||||
private String phase;
|
||||
@JsonProperty(LAST_INVOKED_STEP)
|
||||
private String lastInvokedStep;
|
||||
@JsonProperty(LAST_OPERATION_STATUS)
|
||||
private Status lastOperationStatus;
|
||||
@JsonProperty(ERROR_MESSAGES)
|
||||
private List<String> errorMessages;
|
||||
@JsonProperty(WARNING_MESSAGES)
|
||||
private List<String> warningMessages;
|
||||
@JsonProperty(TRIGGERED_EVENTS)
|
||||
private List<TriggeredEvents> triggeredEvents;
|
||||
@JsonProperty(NOTES)
|
||||
private String notes;
|
||||
|
||||
|
||||
@JsonIgnore
|
||||
public TriggeredEvents getLastEvent(){
|
||||
if(triggeredEvents==null || triggeredEvents.isEmpty()) return null;
|
||||
return triggeredEvents.get(triggeredEvents.size()-1);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public LifecycleInformation addErrorMessage(String msg){
|
||||
if(errorMessages==null)
|
||||
errorMessages=new ArrayList<>();
|
||||
errorMessages.add(msg);
|
||||
return this;
|
||||
}
|
||||
@JsonIgnore
|
||||
public LifecycleInformation addWarningMessage(String msg){
|
||||
if(warningMessages==null)
|
||||
warningMessages=new ArrayList<>();
|
||||
warningMessages.add(msg);
|
||||
return this;
|
||||
}
|
||||
@JsonIgnore
|
||||
public LifecycleInformation addEventReport(TriggeredEvents info){
|
||||
if(triggeredEvents==null) triggeredEvents=new ArrayList<>();
|
||||
triggeredEvents.add(info);
|
||||
return this;
|
||||
}
|
||||
@JsonIgnore
|
||||
public LifecycleInformation cleanState(){
|
||||
setLastOperationStatus(null);
|
||||
setLastInvokedStep(null);
|
||||
setTriggeredEvents(new ArrayList<>());
|
||||
setErrorMessages(new ArrayList<>());
|
||||
setWarningMessages(new ArrayList<>());
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPhase() {
|
||||
return phase;
|
||||
}
|
||||
|
||||
public void setPhase(String phase) {
|
||||
this.phase = phase;
|
||||
}
|
||||
|
||||
public String getLastInvokedStep() {
|
||||
return lastInvokedStep;
|
||||
}
|
||||
|
||||
public void setLastInvokedStep(String lastInvokedStep) {
|
||||
this.lastInvokedStep = lastInvokedStep;
|
||||
}
|
||||
|
||||
public Status getLastOperationStatus() {
|
||||
return lastOperationStatus;
|
||||
}
|
||||
|
||||
public void setLastOperationStatus(Status lastOperationStatus) {
|
||||
this.lastOperationStatus = lastOperationStatus;
|
||||
}
|
||||
|
||||
public List<String> getErrorMessages() {
|
||||
return errorMessages;
|
||||
}
|
||||
|
||||
public void setErrorMessages(List<String> errorMessages) {
|
||||
this.errorMessages = errorMessages;
|
||||
}
|
||||
|
||||
public List<String> getWarningMessages() {
|
||||
return warningMessages;
|
||||
}
|
||||
|
||||
public void setWarningMessages(List<String> warningMessages) {
|
||||
this.warningMessages = warningMessages;
|
||||
}
|
||||
|
||||
public List<TriggeredEvents> getTriggeredEvents() {
|
||||
return triggeredEvents;
|
||||
}
|
||||
|
||||
public void setTriggeredEvents(List<TriggeredEvents> triggeredEvents) {
|
||||
this.triggeredEvents = triggeredEvents;
|
||||
}
|
||||
|
||||
public String getNotes() {
|
||||
return notes;
|
||||
}
|
||||
|
||||
public void setNotes(String notes) {
|
||||
this.notes = notes;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.shared.cl.document.lifecycle;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TriggeredEvents {
|
||||
|
||||
public static final String PHASE="_phase";
|
||||
public static final String LAST_INVOKED_STEP="_lastInvokedStep";
|
||||
public static final String LAST_OPERATION_STATUS="_lastOperationStatus";
|
||||
public static final String ERROR_MESSAGES="_errorMessages";
|
||||
public static final String WARNING_MESSAGES="_warningMessages";
|
||||
public static final String TRIGGERED_EVENTS="_triggeredEvents";
|
||||
|
||||
private String event;
|
||||
private LifecycleInformation.Status lastOperationStatus;
|
||||
private List<String> errorMessages;
|
||||
private List<String> warningMessages;
|
||||
|
||||
public void addErrorMessage(String msg){
|
||||
if(errorMessages==null)
|
||||
errorMessages=new ArrayList<>();
|
||||
errorMessages.add(msg);
|
||||
}
|
||||
public void addWarningMessage(String msg){
|
||||
if(warningMessages==null)
|
||||
warningMessages=new ArrayList<>();
|
||||
warningMessages.add(msg);
|
||||
}
|
||||
public String getEvent() {
|
||||
return event;
|
||||
}
|
||||
public void setEvent(String event) {
|
||||
this.event = event;
|
||||
}
|
||||
public LifecycleInformation.Status getLastOperationStatus() {
|
||||
return lastOperationStatus;
|
||||
}
|
||||
public void setLastOperationStatus(LifecycleInformation.Status lastOperationStatus) {
|
||||
this.lastOperationStatus = lastOperationStatus;
|
||||
}
|
||||
public List<String> getErrorMessages() {
|
||||
return errorMessages;
|
||||
}
|
||||
public void setErrorMessages(List<String> errorMessages) {
|
||||
this.errorMessages = errorMessages;
|
||||
}
|
||||
public List<String> getWarningMessages() {
|
||||
return warningMessages;
|
||||
}
|
||||
public void setWarningMessages(List<String> warningMessages) {
|
||||
this.warningMessages = warningMessages;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.shared.cl.document.relationships;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
public class Relationship {
|
||||
|
||||
public static final String RELATIONSHIP_NAME="_relationshipName";
|
||||
public static final String TARGET_ID="_targetID";
|
||||
public static final String TARGET_UCD="_targetUCD";
|
||||
|
||||
@JsonProperty(RELATIONSHIP_NAME)
|
||||
private String relationshipName;
|
||||
@JsonProperty(TARGET_ID)
|
||||
private String targetID;
|
||||
@JsonProperty(TARGET_UCD)
|
||||
private String targetUCD;
|
||||
public String getRelationshipName() {
|
||||
return relationshipName;
|
||||
}
|
||||
public void setRelationshipName(String relationshipName) {
|
||||
this.relationshipName = relationshipName;
|
||||
}
|
||||
public String getTargetID() {
|
||||
return targetID;
|
||||
}
|
||||
public void setTargetID(String targetID) {
|
||||
this.targetID = targetID;
|
||||
}
|
||||
public String getTargetUCD() {
|
||||
return targetUCD;
|
||||
}
|
||||
public void setTargetUCD(String targetUCD) {
|
||||
this.targetUCD = targetUCD;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.shared.cl.document.relationships;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.application.geoportal.common.model.document.Project;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import lombok.NonNull;
|
||||
|
||||
|
||||
public class RelationshipNavigationObject {
|
||||
public static final String CHILDREN="_children";
|
||||
public static final String TARGET="_target";
|
||||
|
||||
@JsonProperty(CHILDREN)
|
||||
List<RelationshipNavigationObject> children;
|
||||
|
||||
@NonNull
|
||||
@JsonProperty(TARGET)
|
||||
Project target;
|
||||
|
||||
public List<RelationshipNavigationObject> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<RelationshipNavigationObject> children) {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
public Project getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
public void setTarget(Project target) {
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.shared.cl.ucd;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.cl.document.Project;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.cl.document.accouting.User;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
public class DataAccessPolicy {
|
||||
|
||||
public static final String POLICY = "_policy";
|
||||
public static final String ROLES = "_roles";
|
||||
public static final String ENFORCER = "_enforcer";
|
||||
|
||||
public static class PolicyEnforcer {
|
||||
public static final String FILTER="_filter";
|
||||
@JsonProperty(FILTER)
|
||||
private String filter;
|
||||
|
||||
@JsonIgnore
|
||||
public Object getFilterDocument(){
|
||||
if(filter!=null) return filter;
|
||||
else return new Object();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@JsonProperty(POLICY)
|
||||
private Policy policy;
|
||||
@JsonProperty(ROLES)
|
||||
private List<String> roles;
|
||||
@JsonProperty(ENFORCER)
|
||||
private PolicyEnforcer enforcer;
|
||||
|
||||
@JsonIgnore
|
||||
public boolean canRead(Project p, User u){
|
||||
switch(getPolicy().getRead()){
|
||||
case own: return p.getInfo().getCreationInfo().getUser().equals(u);
|
||||
case any: return true;
|
||||
case none:
|
||||
default : return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@JsonIgnore
|
||||
public boolean canWrite(Project p, User u){
|
||||
switch(getPolicy().getWrite()){
|
||||
case own: return p.getInfo().getCreationInfo().getUser().equals(u);
|
||||
case any: return true;
|
||||
case none:
|
||||
default : return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Policy getPolicy() {
|
||||
return policy;
|
||||
}
|
||||
|
||||
|
||||
public void setPolicy(Policy policy) {
|
||||
this.policy = policy;
|
||||
}
|
||||
|
||||
|
||||
public List<String> getRoles() {
|
||||
return roles;
|
||||
}
|
||||
|
||||
|
||||
public void setRoles(List<String> roles) {
|
||||
this.roles = roles;
|
||||
}
|
||||
|
||||
|
||||
public PolicyEnforcer getEnforcer() {
|
||||
return enforcer;
|
||||
}
|
||||
|
||||
|
||||
public void setEnforcer(PolicyEnforcer enforcer) {
|
||||
this.enforcer = enforcer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.shared.cl.ucd;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.google.gwt.json.client.JSONArray;
|
||||
import com.google.gwt.json.client.JSONObject;
|
||||
|
||||
public class Field extends JSONObject {
|
||||
|
||||
public static final String TYPE="_type";
|
||||
public static final String CHILDREN="_children";
|
||||
public static final String MAX_CARDINALITY="_max";
|
||||
public static final String MIN_CARDINALITY="_min";
|
||||
public static final String LABEL="_label";
|
||||
|
||||
@JsonIgnore
|
||||
public String getLabel(){
|
||||
return this.get(LABEL).toString();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public String getType(){
|
||||
return this.get(TYPE).toString();
|
||||
};
|
||||
|
||||
@JsonIgnore
|
||||
public Boolean isLeaf(){
|
||||
JSONArray children = getChildren();
|
||||
return children == null || children.size()==0 || children.get(0)==null;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public JSONArray getChildren(){
|
||||
return (JSONArray)this.get(CHILDREN);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public Boolean isCollection() {
|
||||
Integer maxCard=this.getMaxCardinality();
|
||||
return (maxCard>1||maxCard<0); // Negative values for unbounded
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public Integer getMaxCardinality(){
|
||||
if(this.containsKey(MAX_CARDINALITY))
|
||||
return Integer.parseInt(get(MAX_CARDINALITY).toString());
|
||||
else return 1;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public Integer getMinCardinality(){
|
||||
if(this.containsKey(MIN_CARDINALITY))
|
||||
return Integer.parseInt(get(MIN_CARDINALITY).toString());
|
||||
else return 0;
|
||||
}
|
||||
@JsonIgnore
|
||||
public Boolean isMandatory(){
|
||||
return getMinCardinality()==0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.shared.cl.ucd;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
class FieldMap extends ArrayList<FieldMap.MapElement> {
|
||||
|
||||
public static class MapElement extends HashMap<String,Field>{
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.shared.cl.ucd;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.google.gwt.json.client.JSONObject;
|
||||
|
||||
|
||||
public class HandlerDeclaration {
|
||||
|
||||
public static final String ID="_id";
|
||||
public static final String TYPE="_type";
|
||||
public static final String CONFIGURATION="_configuration";
|
||||
|
||||
@JsonProperty(ID)
|
||||
private String id;
|
||||
@JsonProperty(TYPE)
|
||||
private String type;
|
||||
@JsonProperty(CONFIGURATION)
|
||||
private JSONObject configuration;
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
public JSONObject getConfiguration() {
|
||||
return configuration;
|
||||
}
|
||||
public void setConfiguration(JSONObject configuration) {
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.shared.cl.ucd;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
public class Policy {
|
||||
public static final String WRITE="_write";
|
||||
public static final String READ="_read";
|
||||
|
||||
public static enum Type{
|
||||
own, none, any
|
||||
}
|
||||
|
||||
@JsonProperty(WRITE)
|
||||
private Policy.Type write;
|
||||
@JsonProperty(READ)
|
||||
private Policy.Type read;
|
||||
|
||||
|
||||
public Policy.Type getWrite() {
|
||||
return write;
|
||||
}
|
||||
public void setWrite(Policy.Type write) {
|
||||
this.write = write;
|
||||
}
|
||||
public Policy.Type getRead() {
|
||||
return read;
|
||||
}
|
||||
public void setRead(Policy.Type read) {
|
||||
this.read = read;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,142 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.shared.cl.ucd;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.cl.document.accouting.AccountingInfo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class UCD implements Serializable {
|
||||
|
||||
public static final String MONGO_ID="_mongoId";
|
||||
public static final String ID="_id";
|
||||
public static final String VERSION="_version";
|
||||
public static final String NAME="_name";
|
||||
public static final String DESCRIPTION="_description";
|
||||
public static final String CREATION_INFO="_creationInfo";
|
||||
public static final String SCHEMA="_schema";
|
||||
public static final String HANDLERS="_handlers";
|
||||
public static final String DATA_ACCESS_POLICIES="_dataAccessPolicies";
|
||||
|
||||
|
||||
@JsonProperty(MONGO_ID)
|
||||
private String mongoId;
|
||||
|
||||
@JsonProperty(ID)
|
||||
private String id;
|
||||
@JsonProperty(VERSION)
|
||||
private String version;
|
||||
|
||||
@JsonProperty(NAME)
|
||||
private String name;
|
||||
@JsonProperty(DESCRIPTION)
|
||||
private String description;
|
||||
@JsonProperty(CREATION_INFO)
|
||||
private AccountingInfo creationInfo;
|
||||
|
||||
@JsonProperty(SCHEMA)
|
||||
private Field schema;
|
||||
|
||||
@JsonProperty(HANDLERS)
|
||||
private List<HandlerDeclaration> handlers;
|
||||
|
||||
|
||||
@JsonProperty(DATA_ACCESS_POLICIES)
|
||||
private List<DataAccessPolicy> dataAccessPolicies;
|
||||
|
||||
|
||||
public String getMongoId() {
|
||||
return mongoId;
|
||||
}
|
||||
|
||||
|
||||
public void setMongoId(String mongoId) {
|
||||
this.mongoId = mongoId;
|
||||
}
|
||||
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
|
||||
public AccountingInfo getCreationInfo() {
|
||||
return creationInfo;
|
||||
}
|
||||
|
||||
|
||||
public void setCreationInfo(AccountingInfo creationInfo) {
|
||||
this.creationInfo = creationInfo;
|
||||
}
|
||||
|
||||
|
||||
public Field getSchema() {
|
||||
return schema;
|
||||
}
|
||||
|
||||
|
||||
public void setSchema(Field schema) {
|
||||
this.schema = schema;
|
||||
}
|
||||
|
||||
|
||||
public List<HandlerDeclaration> getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
|
||||
public void setHandlers(List<HandlerDeclaration> handlers) {
|
||||
this.handlers = handlers;
|
||||
}
|
||||
|
||||
|
||||
public List<DataAccessPolicy> getDataAccessPolicies() {
|
||||
return dataAccessPolicies;
|
||||
}
|
||||
|
||||
|
||||
public void setDataAccessPolicies(List<DataAccessPolicy> dataAccessPolicies) {
|
||||
this.dataAccessPolicies = dataAccessPolicies;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer;
|
||||
|
||||
import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin.useCaseDescriptors;
|
||||
|
||||
import org.gcube.application.geoportal.client.utils.Serialization;
|
||||
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
|
||||
import org.gcube.application.geoportal.common.rest.UseCaseDescriptorsI;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.cl.ucd.UCD;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ModelConversionTests {
|
||||
|
||||
@Test
|
||||
public void testGetUCD() throws Exception {
|
||||
TokenSetter.set("/gcube/devsec/devVRE");
|
||||
UseCaseDescriptorsI client = useCaseDescriptors().build();
|
||||
client.query(new QueryRequest()).forEachRemaining(u->{
|
||||
|
||||
System.out.println(u.getName());
|
||||
|
||||
UCD ucd = Serialization.convert(u, UCD.class);
|
||||
System.out.println(ucd.getName());
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
|
||||
public class TokenSetter {
|
||||
|
||||
|
||||
private static Properties props=new Properties();
|
||||
|
||||
static{
|
||||
try {
|
||||
props.load(TokenSetter.class.getResourceAsStream("/tokens.properties"));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("YOU NEED TO SET TOKEN FILE IN CONFIGURATION");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void set(String scope){
|
||||
try{
|
||||
if(!props.containsKey(scope)) throw new RuntimeException("No token found for scope : "+scope);
|
||||
SecurityTokenProvider.instance.set(props.getProperty(scope));
|
||||
}catch(Throwable e){
|
||||
System.err.println("Unable to set token for scope "+scope);
|
||||
e.printStackTrace(System.err);
|
||||
}
|
||||
ScopeProvider.instance.set(scope);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue