merged with beans contained in the branch cms-projects-support
This commit is contained in:
parent
c5a3d8faee
commit
f007654210
|
@ -1,6 +1,7 @@
|
|||
package org.gcube.application.geoportalcommon;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InvalidObjectException;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
@ -16,6 +17,7 @@ import java.util.Set;
|
|||
|
||||
import org.bson.Document;
|
||||
import org.gcube.application.geoportal.client.utils.Serialization;
|
||||
import org.gcube.application.geoportal.common.model.configuration.Index;
|
||||
import org.gcube.application.geoportal.common.model.document.Project;
|
||||
import org.gcube.application.geoportal.common.model.document.access.Access;
|
||||
import org.gcube.application.geoportal.common.model.document.accounting.AccountingInfo;
|
||||
|
@ -39,6 +41,7 @@ import org.gcube.application.geoportalcommon.shared.geoportal.config.ActionDefin
|
|||
import org.gcube.application.geoportalcommon.shared.geoportal.config.FilePathDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.config.GcubeProfileDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.IndexLayer;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.AccessDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.AccountingInfoDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.BasicLifecycleInformationDV;
|
||||
|
@ -1146,5 +1149,63 @@ public class ConvertToDataValueObjectModel {
|
|||
p.setStorageID(p.getStorageID());
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* {
|
||||
"_type": "GIS-CENTROIDS",
|
||||
"layer": {
|
||||
"_type": "gcube-sdi-layer",
|
||||
"_platformInfo": [
|
||||
{
|
||||
"_type": "Geoserver",
|
||||
"workspace": "profiledconcessioni_devvre",
|
||||
"storeName": "profiledconcessioni_devvre_centroids",
|
||||
"_host": "geoserver-218.dev.d4science.org"
|
||||
}
|
||||
],
|
||||
"_bbox": {
|
||||
"_maxX": 180.0,
|
||||
"_minX": -180.0,
|
||||
"_maxY": 90.0,
|
||||
"_minY": -90.0
|
||||
},
|
||||
"_ogcLinks": {
|
||||
"wms": {
|
||||
"wms": "https://geoserver-218.dev.d4science.org/geoserver/profiledconcessioni_devvre/wms?service=WMS&version=1.1.0&request=GetMap&layers=profiledconcessioni_devvre:null&styles=&bbox=-180.000000,-90.000000,180.000000,90.000000&srs=EPSG:4326&format=application/openlayers&width=400&height=400"
|
||||
}
|
||||
}
|
||||
},
|
||||
"indexName": "profiledconcessioni_devvre_centroids",
|
||||
"records": 4,
|
||||
"crossReferencedLayers": {},
|
||||
"flag": "public"
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
public static IndexLayer convert(Index toConvert) throws InvalidObjectException {
|
||||
|
||||
if(toConvert==null || toConvert.getType()==null)
|
||||
throw new InvalidObjectException("Unable to convert Index. Unknown type: "+toConvert);
|
||||
|
||||
IndexLayer toReturn = null;
|
||||
switch(toConvert.getType()) {
|
||||
case "GIS-CENTROIDS" : {
|
||||
toReturn = Serialization.convert(toConvert,IndexLayer.class);
|
||||
// toReturn.setLayer(Serialization.read(toConvert.get("layer"), GCubeSDILayer.class));
|
||||
// toReturn.setFlag(toConvert.getString("flag"));
|
||||
// toReturn.setIndexName(toConvert.getString());
|
||||
break;
|
||||
|
||||
}
|
||||
default:{
|
||||
throw new InvalidObjectException("Unable to convert Index. Unknown type : "+toConvert.getType());
|
||||
}
|
||||
}
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,109 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.materialization;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class BBOXDV extends HashMap<String,Double>{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -160255589938251081L;
|
||||
|
||||
public BBOXDV() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public final String asGeoJSONBBox(){
|
||||
StringBuilder builder = new StringBuilder("[");
|
||||
builder.append(getMaxX()+","); // W
|
||||
builder.append(getMinY()+","); // S
|
||||
if(is3d()) builder.append(getMinZ()+","); // Z
|
||||
|
||||
builder.append(getMinX()+","); // E
|
||||
builder.append(getMaxY()+","); // N
|
||||
if(is3d()) builder.append(getMaxZ()+","); // Z
|
||||
|
||||
|
||||
builder.deleteCharAt(builder.length());
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
public double[] asGeoJSONArray(){
|
||||
if(is3d()){
|
||||
return new double[]{getMaxX(),getMinY(),getMinZ(),getMinX(),getMaxY(),getMaxZ()};
|
||||
}else return new double[]{getMaxX(),getMinY(),getMinX(),getMaxY()};
|
||||
}
|
||||
|
||||
public static final BBOXDV fromGeoJSON(double[] coords){
|
||||
BBOXDV toReturn = new BBOXDV();
|
||||
toReturn.setMaxX(coords[0]);
|
||||
toReturn.setMinY(coords[1]);
|
||||
|
||||
if(coords.length == 6){
|
||||
// 3D
|
||||
toReturn.setMinZ(coords[2]);
|
||||
toReturn.setMinX(coords[3]);
|
||||
toReturn.setMaxY(coords[4]);
|
||||
toReturn.setMaxZ(coords[5]);
|
||||
}else {
|
||||
toReturn.setMinX(coords[2]);
|
||||
toReturn.setMaxY(coords[3]);
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public static final BBOXDV WORLD=new BBOXDV(180d,-180d,90d,-90d);
|
||||
|
||||
public static final BBOXDV WORLD_3D=new BBOXDV(180d,-180d,90d,-90d);
|
||||
|
||||
public static final String MAX_X="_maxX";
|
||||
public static final String MAX_Y="_maxY";
|
||||
public static final String MAX_Z="_maxZ";
|
||||
public static final String MIN_X="_minX";
|
||||
public static final String MIN_Y="_minY";
|
||||
public static final String MIN_Z="_minZ";
|
||||
|
||||
|
||||
public BBOXDV(Double maxX,Double minX,Double maxY,Double minY,Double maxZ,Double minZ){
|
||||
this(maxX,minX,maxY,minY);
|
||||
setMaxZ(maxZ);
|
||||
setMinZ(minZ);
|
||||
}
|
||||
public BBOXDV(Double maxX,Double minX,Double maxY,Double minY){
|
||||
setMaxX(maxX);
|
||||
setMinX(minX);
|
||||
setMaxY(maxY);
|
||||
setMinY(minY);
|
||||
}
|
||||
|
||||
|
||||
public BBOXDV setMaxX(Double d){this.put(MAX_X,d);return this;}
|
||||
|
||||
public BBOXDV setMaxY(Double d){this.put(MAX_Y,d);return this;}
|
||||
|
||||
public BBOXDV setMaxZ(Double d){this.put(MAX_Z,d);return this;}
|
||||
|
||||
public BBOXDV setMinX(Double d){this.put(MIN_X,d);return this;}
|
||||
|
||||
public BBOXDV setMinY(Double d){this.put(MIN_Y,d);return this;}
|
||||
|
||||
public BBOXDV setMinZ(Double d){this.put(MIN_Z,d);return this;}
|
||||
|
||||
public Double getMinY(){return (Double) this.getOrDefault(MIN_Y,-90d);}
|
||||
|
||||
public Double getMaxY(){return (Double) this.getOrDefault(MAX_Y,90d);}
|
||||
|
||||
public Double getMinX(){return (Double) this.getOrDefault(MIN_X,-180d);}
|
||||
|
||||
public Double getMaxX(){return (Double) this.getOrDefault(MAX_X,180d);}
|
||||
|
||||
public Double getMinZ(){return (Double) this.getOrDefault(MIN_Z,null);}
|
||||
|
||||
public Double getMaxZ(){return (Double) this.getOrDefault(MAX_Z,null);}
|
||||
|
||||
|
||||
public Boolean is3d(){
|
||||
return getMinZ()!=null && getMaxZ() !=null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.materialization;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class GCubeSDILayerDV implements Serializable {
|
||||
|
||||
// TODO manage heterogeneus collection
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 5317964084778336268L;
|
||||
@JsonProperty(value = "_type")
|
||||
private String type;
|
||||
@JsonProperty(value = "_platformInfo")
|
||||
private List<GeoServerPlatformInfoDV> platformInfos;
|
||||
@JsonProperty(value = "_bbox")
|
||||
private BBOXDV bbox;
|
||||
@JsonProperty(value = "_ogcLinks")
|
||||
private HashMap<String, String> ogcLinks;
|
||||
|
||||
public GCubeSDILayerDV() {
|
||||
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public List<GeoServerPlatformInfoDV> getPlatformInfos() {
|
||||
return platformInfos;
|
||||
}
|
||||
|
||||
public BBOXDV getBbox() {
|
||||
return bbox;
|
||||
}
|
||||
|
||||
public HashMap<String, String> getOgcLinks() {
|
||||
return ogcLinks;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public void setPlatformInfos(List<GeoServerPlatformInfoDV> platformInfos) {
|
||||
this.platformInfos = platformInfos;
|
||||
}
|
||||
|
||||
public void setBbox(BBOXDV bbox) {
|
||||
this.bbox = bbox;
|
||||
}
|
||||
|
||||
public void setOgcLinks(HashMap<String, String> ogcLinks) {
|
||||
this.ogcLinks = ogcLinks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("GCubeSDILayerDV [type=");
|
||||
builder.append(type);
|
||||
builder.append(", platformInfos=");
|
||||
builder.append(platformInfos);
|
||||
builder.append(", bbox=");
|
||||
builder.append(bbox);
|
||||
builder.append(", ogcLinks=");
|
||||
builder.append(ogcLinks);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.materialization;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class GeoServerPlatformInfoDV implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -2630467451758269625L;
|
||||
|
||||
@JsonProperty(value = "_type")
|
||||
private String type;
|
||||
private String workspace;
|
||||
private String storeName;
|
||||
|
||||
public GeoServerPlatformInfoDV() {
|
||||
}
|
||||
|
||||
@JsonProperty(value = "_host")
|
||||
private String host;
|
||||
|
||||
private Map<String, String> ogcLinks;
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getWorkspace() {
|
||||
return workspace;
|
||||
}
|
||||
|
||||
public void setWorkspace(String workspace) {
|
||||
this.workspace = workspace;
|
||||
}
|
||||
|
||||
public String getStoreName() {
|
||||
return storeName;
|
||||
}
|
||||
|
||||
public void setStoreName(String storeName) {
|
||||
this.storeName = storeName;
|
||||
}
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public Map<String, String> getOgcLinks() {
|
||||
return ogcLinks;
|
||||
}
|
||||
|
||||
public void setOgcLinks(Map<String, String> ogcLinks) {
|
||||
this.ogcLinks = ogcLinks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("GeoServerPlatformInfoDV [type=");
|
||||
builder.append(type);
|
||||
builder.append(", workspace=");
|
||||
builder.append(workspace);
|
||||
builder.append(", storeName=");
|
||||
builder.append(storeName);
|
||||
builder.append(", host=");
|
||||
builder.append(host);
|
||||
builder.append(", ogcLinks=");
|
||||
builder.append(ogcLinks);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.materialization;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class IndexLayer implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 5352754312327975329L;
|
||||
|
||||
@JsonProperty(value = "_type")
|
||||
private String type;
|
||||
private GCubeSDILayerDV layer;
|
||||
private String indexName;
|
||||
private int records;
|
||||
private String flag;
|
||||
|
||||
public IndexLayer() {
|
||||
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public GCubeSDILayerDV getLayer() {
|
||||
return layer;
|
||||
}
|
||||
|
||||
public void setLayer(GCubeSDILayerDV layer) {
|
||||
this.layer = layer;
|
||||
}
|
||||
|
||||
public String getIndexName() {
|
||||
return indexName;
|
||||
}
|
||||
|
||||
public void setIndexName(String indexName) {
|
||||
this.indexName = indexName;
|
||||
}
|
||||
|
||||
public int getRecords() {
|
||||
return records;
|
||||
}
|
||||
|
||||
public void setRecords(int records) {
|
||||
this.records = records;
|
||||
}
|
||||
|
||||
public String getFlag() {
|
||||
return flag;
|
||||
}
|
||||
|
||||
public void setFlag(String flag) {
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("IndexLayer [type=");
|
||||
builder.append(type);
|
||||
builder.append(", layer=");
|
||||
builder.append(layer);
|
||||
builder.append(", indexName=");
|
||||
builder.append(indexName);
|
||||
builder.append(", records=");
|
||||
builder.append(records);
|
||||
builder.append(", flag=");
|
||||
builder.append(flag);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.materialization;
|
||||
|
||||
public enum LayerObjectType {
|
||||
BASE_LAYER, PROJECT_LAYER, INDEX_LAYER, GENERIC_LAYER
|
||||
}
|
Loading…
Reference in New Issue