Added new handler. Added GeoJSON object
This commit is contained in:
parent
c95d026ecb
commit
abc5466f71
|
@ -34,6 +34,7 @@ import org.gcube.application.geoportalcommon.geoportal.config.FilePath;
|
|||
import org.gcube.application.geoportalcommon.geoportal.config.GcubeProfile;
|
||||
import org.gcube.application.geoportalcommon.geoportal.config.ItemField;
|
||||
import org.gcube.application.geoportalcommon.geoportal.serdes.Payload;
|
||||
import org.gcube.application.geoportalcommon.geoportal.util.GisUtil;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.ConfigurationDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV;
|
||||
|
@ -41,12 +42,15 @@ 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.geojson.Crs;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.geojson.GeoJSON;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.IndexLayerDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.PayloadDV;
|
||||
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;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.IdentificationReferenceDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.IdentificationReferencesTYPE;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.LifecycleInformationDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.PublicationInfoDV;
|
||||
|
@ -56,6 +60,8 @@ import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_DATA
|
|||
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.HandlerDeclarationDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.RelationshipDefinitionDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.UseCaseDescriptorDV;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -91,7 +97,8 @@ public class ConvertToDataValueObjectModel {
|
|||
|
||||
public static final String TIME_FORMAT = "HH" + HOURS_MINUTES_SEPARATOR + "mm";
|
||||
|
||||
public static List<String> KEYSET_POSSIBLE_DATE = Arrays.asList("start", "end", "created", "updated", "inizio", "fine", "creato", "aggiornato");
|
||||
public static List<String> KEYSET_POSSIBLE_DATE = Arrays.asList("start", "end", "created", "updated", "inizio",
|
||||
"fine", "creato", "aggiornato");
|
||||
|
||||
/**
|
||||
* To use case descriptor DV.
|
||||
|
@ -552,10 +559,16 @@ public class ConvertToDataValueObjectModel {
|
|||
theProject.setLifecycleInformationDV(toLifecycleInformationDV(project.getLifecycleInformation()));
|
||||
}
|
||||
|
||||
// if (projectReader.isIncludeSpatialReference()) {
|
||||
// theProject.setSpatialReference(toDocumentDV(project.getSpatialReference(), DocumentDV.class,
|
||||
// projectReader.getListDocumentKeys(), projectReader.isIncludeFullDocumentMap()));
|
||||
// }
|
||||
if (projectReader.isIncludeSpatialReference()) {
|
||||
// theProject.setMapIdentReferenceDV(project.getIdentificationReferences());
|
||||
List<IdentificationReference> ids = project
|
||||
.getIdentificationReferenceByType(IdentificationReferencesTYPE.SPATIAL_REFERENCE.getType());
|
||||
if (ids != null && !ids.isEmpty()) {
|
||||
GeoJSON geoJson = toSpatialReference(ids.get(0).toJson());
|
||||
theProject.setSpatialReference(geoJson);
|
||||
}
|
||||
|
||||
}
|
||||
//
|
||||
// if (projectReader.isIncludeTemporalReference()) {
|
||||
// theProject.setTemporalReference(toTemporalReferenceDV(project.getTemporalReference(),
|
||||
|
@ -577,6 +590,30 @@ public class ConvertToDataValueObjectModel {
|
|||
|
||||
}
|
||||
|
||||
public static GeoJSON toSpatialReference(String geoJSONObject) {
|
||||
LOG.debug("toSpatialReference called");
|
||||
|
||||
if (geoJSONObject == null)
|
||||
return null;
|
||||
|
||||
GeoJSON geoJson = null;
|
||||
try {
|
||||
geoJson = new GeoJSON();
|
||||
JSONObject jsonObject = new JSONObject(geoJSONObject).getJSONObject("geoJSON");
|
||||
geoJson.setType(jsonObject.getString("type"));
|
||||
geoJson.setBbox(GisUtil.fromJSONArray(jsonObject.getJSONArray("bbox")));
|
||||
Crs crs = org.gcube.application.geoportal.client.utils.Serialization
|
||||
.read(jsonObject.getJSONObject("crs").toString(), Crs.class);
|
||||
geoJson.setCrs(crs);
|
||||
geoJson.setGeoJSON(jsonObject.toString());
|
||||
} catch (JSONException | IOException e) {
|
||||
LOG.warn("Error on converting " + GeoJSON.class.getSimpleName() + " from : " + geoJSONObject, e);
|
||||
}
|
||||
|
||||
return geoJson;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* To result document DV.
|
||||
*
|
||||
|
@ -1146,41 +1183,19 @@ public class ConvertToDataValueObjectModel {
|
|||
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"
|
||||
}
|
||||
* { "_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 IndexLayerDV convert(Index toConvert) throws InvalidObjectException {
|
||||
|
||||
if (toConvert == null || toConvert.getType() == null)
|
||||
|
@ -1190,7 +1205,8 @@ public class ConvertToDataValueObjectModel {
|
|||
switch (toConvert.getType()) {
|
||||
case "GIS-CENTROIDS": {
|
||||
toReturn = Serialization.convert(toConvert, IndexLayerDV.class);
|
||||
// toReturn.setLayer(Serialization.read(toConvert.get("layer"), GCubeSDILayer.class));
|
||||
// toReturn.setLayer(Serialization.read(toConvert.get("layer"),
|
||||
// GCubeSDILayer.class));
|
||||
// toReturn.setFlag(toConvert.getString("flag"));
|
||||
// toReturn.setIndexName(toConvert.getString());
|
||||
break;
|
||||
|
|
|
@ -12,7 +12,7 @@ import java.util.List;
|
|||
public class ProjectDVBuilder {
|
||||
|
||||
private boolean lifecycleInformation;
|
||||
private boolean spatialReference;
|
||||
private boolean spatialReference = true; //default
|
||||
private boolean temporalReference;
|
||||
private boolean relationships;
|
||||
private List<String> listDocumentKeys;
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
package org.gcube.application.geoportalcommon.geoportal.util;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.BBOXDV;
|
||||
import org.json.JSONArray;
|
||||
|
||||
public class GisUtil {
|
||||
|
||||
public static BBOXDV fromJSONArray(JSONArray outerArray) {
|
||||
|
||||
try {
|
||||
if (outerArray == null)
|
||||
return new BBOXDV();
|
||||
|
||||
double[] coords = new double[outerArray.length()];
|
||||
|
||||
for (int i = 0; i < outerArray.length(); i++) {
|
||||
coords[i] = outerArray.getDouble(i);
|
||||
}
|
||||
|
||||
return BBOXDV.fromGeoJSON(coords);
|
||||
} catch (Exception e) {
|
||||
return new BBOXDV();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.geojson;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class Crs implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -8848168371106854638L;
|
||||
|
||||
public Crs(){
|
||||
|
||||
}
|
||||
|
||||
@JsonProperty
|
||||
private String type;
|
||||
@JsonProperty
|
||||
private Map<String, Object> properties = new HashMap<String, Object>();
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public Map<String, Object> getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
public void setProperties(Map<String, Object> properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof Crs)) {
|
||||
return false;
|
||||
}
|
||||
Crs crs = (Crs) o;
|
||||
if (properties != null ? !properties.equals(crs.properties) : crs.properties != null) {
|
||||
return false;
|
||||
}
|
||||
return !(type != null ? !type.equals(crs.type) : crs.type != null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = type != null ? type.hashCode() : 0;
|
||||
result = 31 * result + (properties != null ? properties.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Crs{" + "type='" + type + '\'' + ", properties=" + properties + '}';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.geojson;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.BBOXDV;
|
||||
|
||||
public class GeoJSON implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -7798331554142534921L;
|
||||
|
||||
private String type;
|
||||
private Crs crs;
|
||||
private BBOXDV bbox;
|
||||
private String geoJSON;
|
||||
|
||||
public GeoJSON() {
|
||||
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public Crs getCrs() {
|
||||
return crs;
|
||||
}
|
||||
|
||||
public BBOXDV getBbox() {
|
||||
return bbox;
|
||||
}
|
||||
|
||||
public String getGeoJSON() {
|
||||
return geoJSON;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public void setCrs(Crs crs) {
|
||||
this.crs = crs;
|
||||
}
|
||||
|
||||
public void setBbox(BBOXDV bbox) {
|
||||
this.bbox = bbox;
|
||||
}
|
||||
|
||||
public void setGeoJSON(String geoJSON) {
|
||||
this.geoJSON = geoJSON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("GeoJSON [type=");
|
||||
builder.append(type);
|
||||
builder.append(", crs=");
|
||||
builder.append(crs);
|
||||
builder.append(", bbox=");
|
||||
builder.append(bbox);
|
||||
builder.append(", geoJSON=");
|
||||
builder.append(geoJSON);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -26,6 +26,14 @@ public class IdentificationReferenceDV extends DocumentDV implements Serializabl
|
|||
return type;
|
||||
}
|
||||
|
||||
public IdentificationReferencesTYPE asIdentificationReferencesTYPE() {
|
||||
try {
|
||||
return IdentificationReferencesTYPE.valueOf(type);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
package org.gcube.application.geoportalcommon.shared.geoportal.project;
|
||||
|
||||
|
||||
/**
|
||||
* The Enum IdentificationReferencesTYPE.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Oct 26, 2022
|
||||
*/
|
||||
public enum IdentificationReferencesTYPE {
|
||||
|
||||
SPATIAL_REFERENCE("SPATIAL REFERENCE");
|
||||
|
||||
String type;
|
||||
|
||||
/**
|
||||
* Instantiates a new identification references TYPE.
|
||||
*
|
||||
* @param type the type
|
||||
*/
|
||||
IdentificationReferencesTYPE(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type.
|
||||
*
|
||||
* @return the type
|
||||
*/
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
}
|
|
@ -5,9 +5,9 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.geojson.GeoJSON;
|
||||
|
||||
public class ProjectDV implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -25,6 +25,9 @@ public class ProjectDV implements Serializable {
|
|||
private Map<String, IdentificationReferenceDV> mapIdentReferenceDV;
|
||||
private LifecycleInformationDV lifecycleInformationDV;
|
||||
|
||||
// Shortcut to "SPATIAL REFERENCE" containted into IdentificationReferenceDV
|
||||
private GeoJSON spatialReference;
|
||||
|
||||
public ProjectDV() {
|
||||
|
||||
}
|
||||
|
@ -101,6 +104,14 @@ public class ProjectDV implements Serializable {
|
|||
this.lifecycleInformationDV = lifecycleInformationDV;
|
||||
}
|
||||
|
||||
public GeoJSON getSpatialReference() {
|
||||
return spatialReference;
|
||||
}
|
||||
|
||||
public void setSpatialReference(GeoJSON spatialReference) {
|
||||
this.spatialReference = spatialReference;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
@ -122,6 +133,8 @@ public class ProjectDV implements Serializable {
|
|||
builder.append(mapIdentReferenceDV);
|
||||
builder.append(", lifecycleInformationDV=");
|
||||
builder.append(lifecycleInformationDV);
|
||||
builder.append(", spatialReference=");
|
||||
builder.append(spatialReference);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.gcube.application.geoportalcommon.shared.geoportal.ucd;
|
|||
public enum GEOPORTAL_DATA_HANDLER {
|
||||
|
||||
geoportal_data_list("org.gcube.portlets.user.geoportal-data-list", "DATA_LIST_GUI"),
|
||||
geoportal_basic_data_list("org.gcube.portlets.user.geoportal-basic-data-list", "BASIC_DATA_LIST_GUI"),
|
||||
geoportal_data_entry("org.gcube.portlets.user.geoportal-data-entry-app", "DATA_ENTRY_GUI"),
|
||||
geoportal_workflow_action_list("org.gcube.portlets.user.geoportal-workflow-action-list","WORKFLOW_ACTION_LIST_GUI"),
|
||||
gna_concessioni_lc("GNA-CONCESSIONI-LC", "LifecycleManagement");
|
||||
|
|
|
@ -16,9 +16,6 @@ public class ProjectView implements Serializable {
|
|||
// The DocumentDV (contained in the ProjectDV) is listed in SectionView
|
||||
private List<SectionView> listSections = new ArrayList<SectionView>();
|
||||
|
||||
private Double centroidLong;
|
||||
private Double centroidLat;
|
||||
|
||||
public ProjectView() {
|
||||
|
||||
}
|
||||
|
@ -35,14 +32,6 @@ public class ProjectView implements Serializable {
|
|||
return listSections;
|
||||
}
|
||||
|
||||
public Double getCentroidLong() {
|
||||
return centroidLong;
|
||||
}
|
||||
|
||||
public Double getCentroidLat() {
|
||||
return centroidLat;
|
||||
}
|
||||
|
||||
public void setTheProjectDV(ProjectDV theProjectDV) {
|
||||
this.theProjectDV = theProjectDV;
|
||||
}
|
||||
|
@ -51,14 +40,6 @@ public class ProjectView implements Serializable {
|
|||
this.listSections = listSections;
|
||||
}
|
||||
|
||||
public void setCentroidLong(Double centroidLong) {
|
||||
this.centroidLong = centroidLong;
|
||||
}
|
||||
|
||||
public void setCentroidLat(Double centroidLat) {
|
||||
this.centroidLat = centroidLat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
@ -66,10 +47,6 @@ public class ProjectView implements Serializable {
|
|||
builder.append(theProjectDV);
|
||||
builder.append(", listSections=");
|
||||
builder.append(listSections);
|
||||
builder.append(", centroidLong=");
|
||||
builder.append(centroidLong);
|
||||
builder.append(", centroidLat=");
|
||||
builder.append(centroidLat);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue