#24136 Integrated the temporal dimension on the front-end side
This commit is contained in:
parent
88c6a831d4
commit
08529f2206
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -32,7 +33,8 @@
|
|||
|
||||
|
||||
<wb-module deploy-name="geoportal-data-viewer-app-3.0.0-SNAPSHOT">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -65,7 +67,8 @@
|
|||
|
||||
|
||||
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -98,7 +101,8 @@
|
|||
|
||||
|
||||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -131,7 +135,8 @@
|
|||
|
||||
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -164,7 +169,8 @@
|
|||
|
||||
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -197,7 +203,11 @@
|
|||
|
||||
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||
|
||||
<dependent-module archiveName="geoportal-data-common-2.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-data-common/geoportal-data-common">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -230,7 +240,8 @@
|
|||
|
||||
|
||||
<property name="java-output-path" value="/geoportal-data-viewer-app/target/geoportal-data-viewer-app-0.0.1-SNAPSHOT/WEB-INF/classes"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -263,7 +274,8 @@
|
|||
|
||||
|
||||
<property name="context-root" value="geoportal-data-viewer-app"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -296,7 +308,8 @@
|
|||
|
||||
|
||||
</wb-module>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|||
- [#23954] Passed the 'Details Panel facility' to CMS-UCD model
|
||||
- [#23955] Implemented the Temporal facility to navigate temporal relations among (JSON) Projects
|
||||
- [#24028] Passed the spatial dimension to CMS-Project model
|
||||
- [#24136] Integrated the temporal dimension on the front-end side
|
||||
|
||||
## [v2.4.1-SNAPSHOT] - 2022-09-28
|
||||
|
||||
|
|
|
@ -25,6 +25,8 @@ public class GeoportalDataViewerConstants {
|
|||
public static final String GET_MAX_ZOOM_LEVEL = OpenLayersMapParameters.OL_MAP_PARAM.maxzoomlevel.name();
|
||||
public static final String GET_ZOOM = OpenLayersMapParameters.OL_MAP_PARAM.zoom.name();
|
||||
public static final String GET_CENTER_MAP_TO_LONG_LAT = OpenLayersMapParameters.OL_MAP_PARAM.centermap.name();
|
||||
|
||||
public static final DateTimeFormat DATE_TIME_FORMAT = DateTimeFormat.getFormat("dd MMMM yyyy");
|
||||
|
||||
public static enum MapEventType {
|
||||
MOUSE_CLICK, MAP_ZOOM_END, MOVE_END, ADDED_CENTROID_LAYER_TO_MAP
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.gcube.application.geoportalcommon.shared.geoportal.materialization.GC
|
|||
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.ProjectDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.TemporalReferenceDV;
|
||||
import org.gcube.application.geoportalcommon.shared.gis.BoundsMap;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.LayerType;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION;
|
||||
|
@ -312,9 +313,11 @@ public class LayerManager {
|
|||
// level
|
||||
// is >
|
||||
// QUERY_MIN_ZOOM_LEVEL
|
||||
final String theProfileID = geoNaDataObject.getSourceLayerObject().getProfileID();
|
||||
addLayerToMapForProject(theProfileID, theProductID, geoNaDataObject.getSourceLayerObject()
|
||||
.getProjectDV(), false);
|
||||
final String theProfileID = geoNaDataObject.getSourceLayerObject()
|
||||
.getProfileID();
|
||||
addLayerToMapForProject(theProfileID, theProductID,
|
||||
geoNaDataObject.getSourceLayerObject().getProjectDV(),
|
||||
false);
|
||||
}
|
||||
} else {
|
||||
// removing all WMS detail layers if the ZOOM level is <
|
||||
|
@ -349,20 +352,19 @@ public class LayerManager {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Adds the layer to map for project.
|
||||
*
|
||||
* @param theProfileID the the profile ID
|
||||
* @param theProductID the the product ID
|
||||
* @param theProjectDV the the project DV
|
||||
* @param theProfileID the the profile ID
|
||||
* @param theProductID the the product ID
|
||||
* @param theProjectDV the the project DV
|
||||
* @param notifyLayerAlreadyAdded the notify layer already added
|
||||
*/
|
||||
public void addLayerToMapForProject(String theProfileID, String theProductID, ProjectDV theProjectDV, final boolean notifyLayerAlreadyAdded) {
|
||||
|
||||
GeoportalDataViewerServiceAsync.Util.getInstance().getLayersForId(
|
||||
theProfileID, theProductID,
|
||||
public void addLayerToMapForProject(String theProfileID, String theProductID, ProjectDV theProjectDV,
|
||||
final boolean notifyLayerAlreadyAdded) {
|
||||
|
||||
GeoportalDataViewerServiceAsync.Util.getInstance().getLayersForId(theProfileID, theProductID,
|
||||
new AsyncCallback<List<GCubeSDIViewerLayerDV>>() {
|
||||
|
||||
@Override
|
||||
|
@ -372,26 +374,19 @@ public class LayerManager {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(
|
||||
List<GCubeSDIViewerLayerDV> result) {
|
||||
public void onSuccess(List<GCubeSDIViewerLayerDV> result) {
|
||||
|
||||
for (GCubeSDIViewerLayerDV layer : result) {
|
||||
GWT.log("Adding layer: "
|
||||
+ layer.getLayerName());
|
||||
addLayer(LayerObjectType.PROJECT_LAYER,
|
||||
layer.getLayerName(),
|
||||
layer.getLayerName(),
|
||||
layer.getWMSLink(), false, false, null,
|
||||
true,
|
||||
OLMapManager.LAYER_DETAIL_MIN_RESOLUTION,
|
||||
OLMapManager.LAYER_DETAIL_MAX_RESOLUTION,
|
||||
theProfileID, theProductID,
|
||||
theProjectDV, notifyLayerAlreadyAdded);
|
||||
GWT.log("Adding layer: " + layer.getLayerName());
|
||||
addLayer(LayerObjectType.PROJECT_LAYER, layer.getLayerName(), layer.getLayerName(),
|
||||
layer.getWMSLink(), false, false, null, true,
|
||||
OLMapManager.LAYER_DETAIL_MIN_RESOLUTION, OLMapManager.LAYER_DETAIL_MAX_RESOLUTION,
|
||||
theProfileID, theProductID, theProjectDV, notifyLayerAlreadyAdded);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -496,7 +491,7 @@ public class LayerManager {
|
|||
public void onSuccess(GeoInformationForWMSRequest geoInfoWMS) {
|
||||
|
||||
GWT.log("Parsed WMS Request returned: " + geoInfoWMS);
|
||||
|
||||
|
||||
LayerItem layerItem = toLayerItem(featureType, layerTitle, geoInfoWMS.getLayerName(),
|
||||
geoInfoWMS.getWmsRequest(), geoInfoWMS.getBaseWmsServiceHost(), true, isBase,
|
||||
displayInLayerSwitcher, (ArrayList<String>) geoInfoWMS.getStyles().getGeoStyles(),
|
||||
|
@ -537,11 +532,12 @@ public class LayerManager {
|
|||
} else {
|
||||
GWT.log("Skipping " + lo.getType() + " layer " + theLo.getLayerItem().getName()
|
||||
+ " already added to Map");
|
||||
if(notifyLayerAlreadyAdded) {
|
||||
if (notifyLayerAlreadyAdded) {
|
||||
GeoportalDataViewer.showPopover(RootPanel.get(GeoportalDataViewer.APP_NOTIFIER),
|
||||
"Layers from the selected project are already displayed", "Layers displayed");
|
||||
"Layers from the selected project are already displayed",
|
||||
"Layers displayed");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -743,17 +739,12 @@ public class LayerManager {
|
|||
|
||||
String newProjectID = lo.getProjectID();
|
||||
if (prevProjectId.compareTo(newProjectID) != 0) {
|
||||
// String projectIntro = newProjectID.length() > 100 ? StringUtil.ellipsize(newProjectID, 100)
|
||||
// : newProjectID;
|
||||
//
|
||||
|
||||
ProjectDV projectDV = lo.getProjectDV();
|
||||
String htmlMsg = ProjectUtil.toHMLCode(projectDV.getTheDocument());
|
||||
|
||||
String projectIntro = htmlMsg.length() > 100 ? StringUtil.ellipsize(htmlMsg, 100) : htmlMsg;
|
||||
|
||||
// Heading heading = new Heading(4, lo.getProjectDV().getProfileName());
|
||||
// heading.setTitle("Project ID: "+newProjectID);
|
||||
// heading.getElement().getStyle().setMarginBottom(10, Unit.PX);
|
||||
Label headingProfileName = new Label(lo.getProjectDV().getProfileName());
|
||||
headingProfileName.setType(LabelType.WARNING);
|
||||
headingProfileName.setTitle("Project ID: " + newProjectID);
|
||||
|
@ -762,6 +753,11 @@ public class LayerManager {
|
|||
headingPanel.add(headingProfileName);
|
||||
flowPanel.add(headingPanel);
|
||||
flowPanel.add(new HTML(projectIntro));
|
||||
|
||||
TemporalReferenceDV tempRef = projectDV.getTemporalReference();
|
||||
if (tempRef != null) {
|
||||
flowPanel.add(new HTML(ProjectUtil.toHTMLCode(tempRef)));
|
||||
}
|
||||
|
||||
Button buttOpenProject = new Button("Open Project");
|
||||
final String buttId = "open-details-" + Random.nextInt();
|
||||
|
@ -890,27 +886,37 @@ public class LayerManager {
|
|||
|
||||
ProjectDV projectDV = geoNaDataObject.getSourceLayerObject().getProjectDV();
|
||||
|
||||
if (projectDV != null && projectDV.getTheDocument() != null) {
|
||||
LinkedHashMap<String, Object> map = projectDV.getTheDocument().getDocumentAsMap();
|
||||
// my-html-table
|
||||
if (projectDV != null) {
|
||||
|
||||
FlexTable intFlex = new FlexTable();
|
||||
intFlex.setCellPadding(1);
|
||||
intFlex.setCellSpacing(1);
|
||||
//intFlex.getElement().addClassName("my-html-table");
|
||||
//int i = 0;
|
||||
for (String key : map.keySet()) {
|
||||
try {
|
||||
Object theValue = map.get(key);
|
||||
String toStringValue = theValue + "";
|
||||
//intFlex.setHTML(i, 0, key);
|
||||
intFlex.setHTML(intFlex.getRowCount() + 1, 0, "<span>"+StringUtil.ellipsize(toStringValue, 100)+"</span>");
|
||||
//i++;
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
if (projectDV.getTheDocument() != null) {
|
||||
LinkedHashMap<String, Object> map = projectDV.getTheDocument().getDocumentAsMap();
|
||||
// my-html-table
|
||||
// intFlex.getElement().addClassName("my-html-table");
|
||||
// int i = 0;
|
||||
for (String key : map.keySet()) {
|
||||
try {
|
||||
Object theValue = map.get(key);
|
||||
String toStringValue = theValue + "";
|
||||
// intFlex.setHTML(i, 0, key);
|
||||
intFlex.setHTML(intFlex.getRowCount() + 1, 0,
|
||||
"<span title='"+toStringValue+"'>" + StringUtil.ellipsize(toStringValue, 100) + "</span>");
|
||||
// i++;
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
}
|
||||
}
|
||||
|
||||
flex.setHTML(flex.getRowCount() + 1, 0, intFlex.getElement().getString());
|
||||
}
|
||||
|
||||
flex.setHTML(flex.getRowCount() + 1, 0, intFlex.getElement().getString());
|
||||
TemporalReferenceDV tempRef = projectDV.getTemporalReference();
|
||||
if (tempRef != null) {
|
||||
|
||||
flex.setHTML(flex.getRowCount() + 1, 0, ProjectUtil.toHTMLCode(tempRef));
|
||||
}
|
||||
}
|
||||
|
||||
// Showing properties belonging to centroid layer, ignoring this
|
||||
|
|
|
@ -3,6 +3,8 @@ package org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.project;
|
|||
import java.util.Map.Entry;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.TemporalReferenceDV;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
|
||||
|
||||
public class ProjectUtil {
|
||||
|
||||
|
@ -57,4 +59,28 @@ public class ProjectUtil {
|
|||
return htmlCode;
|
||||
}
|
||||
|
||||
public static String toHTMLCode(TemporalReferenceDV tempRef) {
|
||||
|
||||
String htmlCode = "<span class='display-date'>";
|
||||
|
||||
if (tempRef != null) {
|
||||
|
||||
String dateToString = "";
|
||||
if (tempRef.getStart() != null) {
|
||||
dateToString += GeoportalDataViewerConstants.DATE_TIME_FORMAT.format(tempRef.getStart());
|
||||
|
||||
}
|
||||
dateToString += " / ";
|
||||
if (tempRef.getStart() != null) {
|
||||
dateToString += GeoportalDataViewerConstants.DATE_TIME_FORMAT.format(tempRef.getEnd());
|
||||
|
||||
}
|
||||
|
||||
htmlCode += dateToString;
|
||||
}
|
||||
htmlCode += "</span>";
|
||||
|
||||
return htmlCode;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,11 +2,13 @@ package org.gcube.portlets.user.geoportaldataviewer.client.ui.dandd;
|
|||
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.TemporalReferenceDV;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.events.DoActionOnDetailLayersEvent;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.events.DoActionOnDetailLayersEvent.DO_LAYER_ACTION;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.events.DoActionOnDetailLayersEvent.SwapLayer;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.resources.GNAImages;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.project.ProjectUtil;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.util.StringUtil;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject;
|
||||
|
@ -129,8 +131,14 @@ public class DragDropLayer extends FlowPanel {
|
|||
// labelLayerName.getElement().getStyle().setMarginLeft(10, Unit.PX);
|
||||
ft.setWidget(0, 1, buttonLayerVisibility);
|
||||
ft.setWidget(0, 2, labelProject);
|
||||
ft.setWidget(1, 2, labelLayerName);
|
||||
ft.setWidget(2, 2, new SimplePanel(rs));
|
||||
|
||||
if(layerObject.getProjectDV().getTemporalReference()!=null) {
|
||||
TemporalReferenceDV tempRef = layerObject.getProjectDV().getTemporalReference();
|
||||
ft.setWidget(ft.getRowCount()+1, 2, new HTML(ProjectUtil.toHTMLCode(tempRef)));
|
||||
}
|
||||
|
||||
ft.setWidget(ft.getRowCount()+1, 2, labelLayerName);
|
||||
ft.setWidget(ft.getRowCount()+1, 2, new SimplePanel(rs));
|
||||
add(ft);
|
||||
draggableButton.setIcon(IconType.MOVE);
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ import org.gcube.application.geoportal.common.model.document.identification.Iden
|
|||
import org.gcube.application.geoportal.common.model.document.relationships.Relationship;
|
||||
import org.gcube.application.geoportal.common.model.document.relationships.RelationshipNavigationObject;
|
||||
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
|
||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.HandlerDeclaration;
|
||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
|
||||
import org.gcube.application.geoportal.common.rest.Projects;
|
||||
import org.gcube.application.geoportalcommon.ConvertToDataValueObjectModel;
|
||||
|
@ -46,6 +45,7 @@ import org.gcube.application.geoportalcommon.shared.geoportal.materialization.In
|
|||
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.PayloadDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.IdentificationReferencesTYPE;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.TemporalReferenceDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_DATA_HANDLER;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.HandlerDeclarationDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.UseCaseDescriptorDV;
|
||||
|
@ -81,9 +81,6 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
||||
import com.jayway.jsonpath.DocumentContext;
|
||||
import com.jayway.jsonpath.JsonPath;
|
||||
import com.jayway.jsonpath.Option;
|
||||
|
||||
/**
|
||||
* The server side implementation of the RPC service.
|
||||
|
@ -95,11 +92,13 @@ import com.jayway.jsonpath.Option;
|
|||
@SuppressWarnings("serial")
|
||||
public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet implements GeoportalDataViewerService {
|
||||
|
||||
private static final String TIMELINE_CONFIG_TJT_DOCUMENT = "tjt_document";
|
||||
// private static final String TIMELINE_CONFIG_TJT_DOCUMENT =
|
||||
// UseCaseDescriptorCaller.TIMELINE_CONFIG_TJT_DOCUMENT;
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(GeoportalDataViewerServiceImpl.class);
|
||||
|
||||
private static final String CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE = "MAP_IMAGE_PREVIEW_FOR_CONCESSIONE";
|
||||
// private static final String CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE =
|
||||
// "MAP_IMAGE_PREVIEW_FOR_CONCESSIONE";
|
||||
|
||||
/**
|
||||
* The Enum COMMON_IMAGES_FORMAT.
|
||||
|
@ -848,12 +847,75 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
|||
ProjectDV theProjectDV = ConvertToDataValueObjectModel.toProjectDV(theProject, projectBuilder);
|
||||
theProjectDV.setProfileName(ucd.getName());
|
||||
|
||||
TemporalReferenceDV temporalReference = temporalReferenceForProject(theProject);
|
||||
if (temporalReference == null)
|
||||
temporalReference = new TemporalReferenceDV();
|
||||
theProjectDV.setTemporalReference(temporalReference);
|
||||
|
||||
ProjectView projectView = Geoportal_JSON_Mapper.loadProjectView(theProjectDV, scope, userName);
|
||||
|
||||
if (LOG.isTraceEnabled()) {
|
||||
Geoportal_JSON_Mapper.prettyPrintProjectView(projectView);
|
||||
}
|
||||
|
||||
LOG.info("returning project view for id: " + projectView.getTheProjectDV().getId());
|
||||
return projectView;
|
||||
|
||||
} catch (Exception e) {
|
||||
String erroMsg = "Error occurred on creating projectView for id: " + projectID;
|
||||
LOG.error(erroMsg, e);
|
||||
throw new Exception(erroMsg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the project edit for id.
|
||||
*
|
||||
* @param profileID the profile ID
|
||||
* @param projectID the project ID
|
||||
* @return the project edit for id
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public ProjectView getProjectEditForId(String profileID, String projectID) throws Exception {
|
||||
LOG.info("getProjectEditForId profileID: " + profileID + ", projectID: " + projectID + ", called");
|
||||
|
||||
if (profileID == null || projectID == null)
|
||||
throw new Exception("Invalid parameter. Either profileID or projectID is null");
|
||||
|
||||
try {
|
||||
|
||||
String scope = SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
|
||||
String userName = null;
|
||||
try {
|
||||
userName = SessionUtil.getCurrentUser(this.getThreadLocalRequest()).getUsername();
|
||||
} catch (Exception e) {
|
||||
LOG.info("User not found in session, the userName for cecking policy will be null");
|
||||
}
|
||||
|
||||
LOG.info("Trying to get project for id " + profileID);
|
||||
|
||||
new GeoportalServiceIdentityProxy(this.getThreadLocalRequest());
|
||||
|
||||
UseCaseDescriptor ucd = SessionUtil.getUCDForId(this.getThreadLocalRequest(), profileID);
|
||||
|
||||
if (ucd == null) {
|
||||
ucd = GeoportalClientCaller.useCaseDescriptors().getUCDForId(profileID);
|
||||
SessionUtil.setUCDForId(this.getThreadLocalRequest(), profileID, ucd);
|
||||
}
|
||||
|
||||
Project theProject = GeoportalClientCaller.projects().getProjectByID(profileID, projectID);
|
||||
|
||||
ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(true);
|
||||
projectBuilder.relationships(true);
|
||||
ProjectDV theProjectDV = ConvertToDataValueObjectModel.toProjectDV(theProject, projectBuilder);
|
||||
theProjectDV.setProfileName(ucd.getName());
|
||||
|
||||
ProjectView projectView = Geoportal_JSON_Mapper.loadProjectView(theProjectDV, scope, userName);
|
||||
|
||||
if (LOG.isTraceEnabled()) {
|
||||
Geoportal_JSON_Mapper.prettyPrintProjectView(projectView);
|
||||
}
|
||||
|
||||
LOG.info("returning project view for id: " + projectView.getTheProjectDV().getId());
|
||||
return projectView;
|
||||
|
@ -939,6 +1001,18 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
|||
ProjectDV projectDV = minimalProjectDV(profileID, projectID, true, 2);
|
||||
layerObject.setProjectDV(projectDV);
|
||||
}
|
||||
|
||||
if (layerObject.getProjectDV().getTemporalReference() == null) {
|
||||
Project theProject = GeoportalClientCaller.projects().getProjectByID(profileID,
|
||||
projectID);
|
||||
TemporalReferenceDV temporalReferenceDV = temporalReferenceForProject(theProject);
|
||||
// Empty TemporalReferenceDV
|
||||
if (temporalReferenceDV == null)
|
||||
temporalReferenceDV = new TemporalReferenceDV();
|
||||
|
||||
layerObject.getProjectDV().setTemporalReference(temporalReferenceDV);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -984,6 +1058,17 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
|||
}
|
||||
}
|
||||
|
||||
if (layerObject.getProjectDV().getTemporalReference() == null) {
|
||||
Project theProject = GeoportalClientCaller.projects()
|
||||
.getProjectByID(layerObject.getProfileID(), layerObject.getProjectID());
|
||||
TemporalReferenceDV temporalReferenceDV = temporalReferenceForProject(theProject);
|
||||
// Empty TemporalReferenceDV
|
||||
if (temporalReferenceDV == null)
|
||||
temporalReferenceDV = new TemporalReferenceDV();
|
||||
|
||||
layerObject.getProjectDV().setTemporalReference(temporalReferenceDV);
|
||||
}
|
||||
|
||||
LOG.debug("Case PROJECT_LAYER/GENERIC_LAYER setting layerObject: " + layerObject);
|
||||
geoDAO.setSourceLayerObject(layerObject);
|
||||
LOG.info("For layer name: " + layerObject.getLayerItem().getName() + " got " + features.size()
|
||||
|
@ -1012,8 +1097,10 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
|||
/**
|
||||
* Minimal project DV.
|
||||
*
|
||||
* @param profileID the profile ID
|
||||
* @param projectID the project ID
|
||||
* @param profileID the profile ID
|
||||
* @param projectID the project ID
|
||||
* @param loadDocument the load document
|
||||
* @param limitDocumentEntries the limit document entries
|
||||
* @return the project DV
|
||||
*/
|
||||
private ProjectDV minimalProjectDV(String profileID, String projectID, boolean loadDocument,
|
||||
|
@ -1029,7 +1116,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
|||
|
||||
try {
|
||||
new GeoportalServiceIdentityProxy(this.getThreadLocalRequest());
|
||||
|
||||
|
||||
useCaseDescriptors().build().query(request).forEachRemaining(u -> {
|
||||
try {
|
||||
LOG.debug("UCD for id" + u.getId() + " returend name: " + u.getName());
|
||||
|
@ -1098,9 +1185,9 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
|||
LinkedHashMap<String, Object> documentAsMap = new LinkedHashMap<String, Object>(limit);
|
||||
|
||||
try {
|
||||
|
||||
|
||||
new GeoportalServiceIdentityProxy(this.getThreadLocalRequest());
|
||||
|
||||
|
||||
Project theProject = GeoportalClientCaller.projects().getProjectByID(profileID, projectID);
|
||||
|
||||
try {
|
||||
|
@ -1148,6 +1235,14 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
|||
return documentAsMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the relationships for timeline.
|
||||
*
|
||||
* @param profileID the profile ID
|
||||
* @param projectID the project ID
|
||||
* @return the relationships for timeline
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Override
|
||||
public List<String> getRelationshipsForTimeline(String profileID, String projectID) throws Exception {
|
||||
if (profileID == null || projectID == null)
|
||||
|
@ -1166,17 +1261,11 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
|||
try {
|
||||
|
||||
if (template == null) {
|
||||
|
||||
List<HandlerDeclaration> timelineHandlers = useCaseDescriptors().build().getById(profileID)
|
||||
.getHandlersByType(GEOPORTAL_DATA_HANDLER.geoportal_timeline_json_template.getType());
|
||||
|
||||
if (timelineHandlers != null && timelineHandlers.size() > 0) {
|
||||
HandlerDeclaration handler = timelineHandlers.get(0); // only one expected
|
||||
Document config = handler.getConfiguration();
|
||||
LinkedHashMap<String, Object> tjtDoc = (LinkedHashMap<String, Object>) config
|
||||
.get(TIMELINE_CONFIG_TJT_DOCUMENT);
|
||||
template = new Document(tjtDoc).toJson();
|
||||
LOG.info(TIMELINE_CONFIG_TJT_DOCUMENT + " read is: " + template);
|
||||
Document temporalJsonTemplate = GeoportalClientCaller.useCaseDescriptors()
|
||||
.readTemporalDimensionTemplate(profileID);
|
||||
if (temporalJsonTemplate != null) {
|
||||
template = new Document(temporalJsonTemplate).toJson();
|
||||
LOG.info(UseCaseDescriptorCaller.TIMELINE_CONFIG_TJT_DOCUMENT + " read is: " + template);
|
||||
SessionUtil.setJSONTimelineTemplate(this.getThreadLocalRequest(), profileID, template);
|
||||
}
|
||||
}
|
||||
|
@ -1191,8 +1280,6 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
|||
if (template != null) {
|
||||
|
||||
JSONObject sourceJsonTemplate = new JSONObject(template);
|
||||
com.jayway.jsonpath.Configuration conf = com.jayway.jsonpath.Configuration.defaultConfiguration();
|
||||
com.jayway.jsonpath.Configuration conf2 = conf.addOptions(Option.ALWAYS_RETURN_LIST);
|
||||
|
||||
Project theProject = GeoportalClientCaller.projects().getProjectByID(profileID, projectID);
|
||||
List<Relationship> relationships = theProject.getRelationships();
|
||||
|
@ -1200,11 +1287,8 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
|||
if (relationships == null || relationships.size() == 0)
|
||||
return new ArrayList<String>();
|
||||
|
||||
// Adding the input document
|
||||
DocumentContext targetDoc = JsonPath.using(conf2).parse(theProject.getTheDocument().toJson());
|
||||
|
||||
JSONObject targetJsonObject = toTimelineJSONModel(targetDoc, sourceJsonTemplate, profileID,
|
||||
projectID, null);
|
||||
JSONObject targetJsonObject = toTimelineWithImageJSONModel(theProject, sourceJsonTemplate,
|
||||
profileID, projectID, null);
|
||||
|
||||
targetJsonObject.put("selected", "from here");
|
||||
String theJSONResult = targetJsonObject.toString();
|
||||
|
@ -1217,8 +1301,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
|||
// Adding the first level of the related project
|
||||
theProject = GeoportalClientCaller.projects().getProjectByID(relationship.getTargetUCD(),
|
||||
relationship.getTargetID());
|
||||
targetDoc = JsonPath.using(conf2).parse(theProject.getTheDocument().toJson());
|
||||
targetJsonObject = toTimelineJSONModel(targetDoc, sourceJsonTemplate,
|
||||
targetJsonObject = toTimelineWithImageJSONModel(theProject, sourceJsonTemplate,
|
||||
relationship.getTargetUCD(), relationship.getTargetID(),
|
||||
relationship.getRelationshipName());
|
||||
theJSONResult = targetJsonObject.toString();
|
||||
|
@ -1231,7 +1314,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
|||
// Adding deep > 1
|
||||
while (iterator.hasNext()) {
|
||||
RelationshipNavigationObject nav = (RelationshipNavigationObject) iterator.next();
|
||||
listJSON = visitRelationshipsChain(nav, relationship.getRelationshipName(), listJSON, conf2,
|
||||
listJSON = visitRelationshipsChain(nav, relationship.getRelationshipName(), listJSON,
|
||||
sourceJsonTemplate);
|
||||
}
|
||||
|
||||
|
@ -1247,16 +1330,24 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
|||
LOG.debug("returning list of relantionships having size: " + listJSON.size());
|
||||
return listJSON;
|
||||
} catch (Exception e) {
|
||||
String erroMsg = "Error occurred on reading relatioships for id: " + projectID;
|
||||
String erroMsg = "Error occurred on reading relationships for id: " + projectID;
|
||||
LOG.error(erroMsg, e);
|
||||
throw new Exception(erroMsg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Visit relationships chain.
|
||||
*
|
||||
* @param nav the nav
|
||||
* @param relationshipName the relationship name
|
||||
* @param listJSONTimelineModel the list JSON timeline model
|
||||
* @param sourceJsonTemplate the source json template
|
||||
* @return the list
|
||||
*/
|
||||
// recursive visit of the Relationships
|
||||
public List<String> visitRelationshipsChain(RelationshipNavigationObject nav, String relationshipName,
|
||||
List<String> listJSONTimelineModel, com.jayway.jsonpath.Configuration conf2,
|
||||
JSONObject sourceJsonTemplate) {
|
||||
List<String> listJSONTimelineModel, JSONObject sourceJsonTemplate) {
|
||||
|
||||
if (nav == null)
|
||||
return listJSONTimelineModel;
|
||||
|
@ -1271,8 +1362,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
|||
|
||||
try {
|
||||
Project targetProject = nav.getTarget();
|
||||
DocumentContext targetDoc = JsonPath.using(conf2).parse(targetProject.getTheDocument().toJson());
|
||||
JSONObject targetJsonObject = toTimelineJSONModel(targetDoc, sourceJsonTemplate,
|
||||
JSONObject targetJsonObject = toTimelineWithImageJSONModel(targetProject, sourceJsonTemplate,
|
||||
nav.getTarget().getProfileID(), nav.getTarget().getId(), relationshipName);
|
||||
String theJSONResult = targetJsonObject.toString();
|
||||
listJSONTimelineModel.add(theJSONResult);
|
||||
|
@ -1285,44 +1375,32 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
|||
LOG.debug("visiting children...");
|
||||
for (RelationshipNavigationObject relationship : nav.getChildren()) {
|
||||
listJSONTimelineModel = visitRelationshipsChain(relationship, relationshipName, listJSONTimelineModel,
|
||||
conf2, sourceJsonTemplate);
|
||||
sourceJsonTemplate);
|
||||
}
|
||||
}
|
||||
|
||||
return listJSONTimelineModel;
|
||||
}
|
||||
|
||||
private JSONObject toTimelineJSONModel(DocumentContext targetDoc, JSONObject sourceJsonTemplate, String targetUCD,
|
||||
String targetProjectID, String relationName) {
|
||||
JSONObject targetJsonObject = new JSONObject();
|
||||
/**
|
||||
* To timeline with image JSON model.
|
||||
*
|
||||
* @param theProject the the project
|
||||
* @param sourceJsonTemplate the source json template
|
||||
* @param targetUCD the target UCD
|
||||
* @param targetID the target ID
|
||||
* @param relationName the relation name
|
||||
* @return the JSON object
|
||||
*/
|
||||
private JSONObject toTimelineWithImageJSONModel(Project theProject, JSONObject sourceJsonTemplate, String targetUCD,
|
||||
String targetID, String relationName) {
|
||||
|
||||
targetJsonObject.put("id", targetUCD + "," + targetProjectID);
|
||||
JSONObject targetJsonObject = ConvertToDataValueObjectModel.toTimelineJSONModel(theProject, sourceJsonTemplate,
|
||||
targetUCD, targetID, relationName);
|
||||
|
||||
if (relationName != null)
|
||||
targetJsonObject.put("relationship_name", relationName);
|
||||
|
||||
for (Object key : sourceJsonTemplate.keySet()) {
|
||||
String jsonPath = null;
|
||||
String theKey = null;
|
||||
try {
|
||||
theKey = key + "";
|
||||
LOG.debug("Searching key: " + theKey);
|
||||
jsonPath = sourceJsonTemplate.getString(theKey);
|
||||
LOG.debug("with key: " + theKey + " read JSON path: " + jsonPath);
|
||||
List<String> listValue = targetDoc.read(jsonPath);
|
||||
String result = "";
|
||||
for (int i = 0; i < listValue.size() - 1; i++) {
|
||||
result += listValue.get(i) + ", ";
|
||||
}
|
||||
result += listValue.get(listValue.size() - 1);
|
||||
targetJsonObject.put(theKey, result);
|
||||
} catch (Exception e) {
|
||||
LOG.trace("Error on setting key: {}, path: {}", theKey, jsonPath);
|
||||
}
|
||||
}
|
||||
List<PayloadDV> images = null;
|
||||
try {
|
||||
images = getImagesForId(targetUCD, targetProjectID, true);
|
||||
images = getImagesForId(theProject.getProfileID(), theProject.getId(), true);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
@ -1335,4 +1413,59 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Temporal reference for project.
|
||||
*
|
||||
* @param theProject the the project
|
||||
* @return the temporal reference DV
|
||||
*/
|
||||
private TemporalReferenceDV temporalReferenceForProject(Project theProject) {
|
||||
LOG.trace("temporalReference for profileID: " + theProject.getProfileID() + ", projectID: "
|
||||
+ theProject.getId() + "called");
|
||||
String template = null;
|
||||
try {
|
||||
|
||||
new GeoportalServiceIdentityProxy(this.getThreadLocalRequest());
|
||||
template = SessionUtil.getJSONTimelineTemplate(this.getThreadLocalRequest(), theProject.getProfileID());
|
||||
|
||||
try {
|
||||
|
||||
if (template == null) {
|
||||
|
||||
Document temporalJsonTemplate = GeoportalClientCaller.useCaseDescriptors()
|
||||
.readTemporalDimensionTemplate(theProject.getProfileID());
|
||||
|
||||
if (temporalJsonTemplate != null) {
|
||||
template = new Document(temporalJsonTemplate).toJson();
|
||||
LOG.info(UseCaseDescriptorCaller.TIMELINE_CONFIG_TJT_DOCUMENT + " read is: " + template);
|
||||
SessionUtil.setJSONTimelineTemplate(this.getThreadLocalRequest(), theProject.getProfileID(),
|
||||
template);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
LOG.warn(GEOPORTAL_DATA_HANDLER.geoportal_timeline_json_template.getType()
|
||||
+ " not found!!! Timeline cannot be available");
|
||||
}
|
||||
|
||||
// String template = "{\"content\": \"$.nome\"," + "\"title\": \"$.nome\","
|
||||
// + "\"start\" : \"$.dataInizioProgetto\"," + "\"end\" : \"$.dataFineProgetto\"}";
|
||||
|
||||
if (template != null) {
|
||||
|
||||
JSONObject sourceJsonTemplate = new JSONObject(template);
|
||||
JSONObject targetJsonObject = ConvertToDataValueObjectModel.toTimelineJSONModel(theProject,
|
||||
sourceJsonTemplate, theProject.getProfileID(), theProject.getId(), null);
|
||||
|
||||
return ConvertToDataValueObjectModel.toTemporalReferenceDV(theProject, targetJsonObject);
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
String erroMsg = "Error occurred on reading temporalReference for id: " + theProject.getId();
|
||||
LOG.warn(erroMsg, e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@ import java.util.List;
|
|||
|
||||
import org.bson.Document;
|
||||
import org.gcube.application.geoportal.client.utils.Serialization;
|
||||
import org.gcube.application.geoportal.common.model.document.access.Access;
|
||||
import org.gcube.application.geoportal.common.model.document.access.AccessPolicy;
|
||||
import org.gcube.application.geoportalcommon.ConvertToDataValueObjectModel;
|
||||
import org.gcube.application.geoportalcommon.geoportal.access.GeportalCheckAccessPolicy;
|
||||
import org.gcube.application.geoportalcommon.geoportal.serdes.Payload;
|
||||
|
@ -23,6 +25,8 @@ import org.gcube.application.geoportalcommon.shared.geoportal.view.SectionView;
|
|||
import org.gcube.application.geoportalcommon.shared.geoportal.view.SubDocumentView;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.server.GeoportalDataViewerServiceImpl.ImageDetector;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.server.util.URLParserUtil;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.MetaDataProfileBeanExt;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.ProjectEdit;
|
||||
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean;
|
||||
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetadataFieldWrapper;
|
||||
import org.json.JSONArray;
|
||||
|
@ -64,6 +68,205 @@ public class Geoportal_JSON_Mapper {
|
|||
|
||||
public static final String _THEDOCUMENT = "_theDocument";
|
||||
|
||||
public static ProjectEdit loadProjectEdit(ProjectDV theProjectDV, String scope, String username) throws Exception {
|
||||
|
||||
String theWholeProjectAsJSON = theProjectDV.getTheDocument().getDocumentAsJSON();
|
||||
|
||||
LOG.debug("theProjectDV as JSON: " + theWholeProjectAsJSON);
|
||||
LOG.debug("theProjectDV as MAP: " + theProjectDV.getTheDocument().getDocumentAsMap());
|
||||
|
||||
ProjectEdit projectView = new ProjectEdit();
|
||||
projectView.setTheProjectDV(theProjectDV);
|
||||
|
||||
LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>> linkedMap_UCDId_gCubeProfiles = GcubeProfilesPerUCDIdCache
|
||||
.get(scope);
|
||||
|
||||
// NO UCD defined, applying default
|
||||
if (linkedMap_UCDId_gCubeProfiles.size() == 0) {
|
||||
LOG.warn("No " + GEOPORTAL_CONFIGURATION_TYPE.gcube_profiles + " found in the UCD");
|
||||
LOG.info("Applying default business logic to display the project");
|
||||
SectionView sectionView = new SectionView();
|
||||
sectionView.setSectionTitle("Document");
|
||||
Document sectionDoc = Document.parse(theProjectDV.getTheDocument().getDocumentAsJSON());
|
||||
|
||||
// Creating one Project with one SectionView and SubDocumentView
|
||||
String wholeSectionDoc = sectionDoc.toJson();
|
||||
|
||||
List<FilesetDV> listFiles = new ArrayList<FilesetDV>();
|
||||
|
||||
// Reading Fileset _payloads
|
||||
String filesetJSONPath = String.format("%s.%s", JSON_$_POINTER, FILESET);
|
||||
List<Payload> listPayloads = readPayloadsForFileset(filesetJSONPath, wholeSectionDoc);
|
||||
FilesetDV filesetDV = new FilesetDV();
|
||||
filesetDV.setName(FILESET);
|
||||
for (Payload payload : listPayloads) {
|
||||
PayloadDV payloadDV = ConvertToDataValueObjectModel.toPayloadDV(payload);
|
||||
filesetDV.addPayloadDV(payloadDV);
|
||||
listFiles.add(filesetDV);
|
||||
}
|
||||
}
|
||||
|
||||
List<GcubeProfilesMetadataForUCD> listProfilesBean = linkedMap_UCDId_gCubeProfiles
|
||||
.get(theProjectDV.getProfileID());
|
||||
|
||||
com.jayway.jsonpath.Configuration configuration = com.jayway.jsonpath.Configuration.builder()
|
||||
.jsonProvider(new JsonOrgJsonProvider()).build();
|
||||
|
||||
List<MetaDataProfileBeanExt> listProfileBeansExt = new ArrayList<MetaDataProfileBeanExt>();
|
||||
|
||||
// Reading the Project according to list of Profile defined in the UCD
|
||||
for (GcubeProfilesMetadataForUCD gcubeProfileMetaForUCD : listProfilesBean) {
|
||||
|
||||
GcubeProfileDV gcubeProfileDV = gcubeProfileMetaForUCD.getGcubeProfile();
|
||||
SectionView sectionView = new SectionView();
|
||||
sectionView.setSectionTitle(gcubeProfileDV.getSectionTitle());
|
||||
LOG.debug("\n\nThe profile is: " + gcubeProfileDV);
|
||||
// Building JSON/section full PATH and section name
|
||||
String sectionJSONPath = "";
|
||||
String parentPathFromProfile = gcubeProfileDV.getParentName() == null ? "" : gcubeProfileDV.getParentName();
|
||||
String theSectionName = gcubeProfileDV.getSectionName();
|
||||
|
||||
if (theSectionName.compareTo(JSON_$_POINTER) == 0 || theSectionName.compareTo(JSON_$_POINTER + ".") == 0) {
|
||||
sectionJSONPath = JSON_$_POINTER;
|
||||
theSectionName = "";
|
||||
} else {
|
||||
sectionJSONPath = String.format("%s%s",
|
||||
parentPathFromProfile.endsWith(".") ? parentPathFromProfile : parentPathFromProfile + ".",
|
||||
theSectionName);
|
||||
}
|
||||
|
||||
LOG.debug("The sectionJSONPath is: " + sectionJSONPath);
|
||||
|
||||
JsonPath theSectionJsonPath = null;
|
||||
Object data = null;
|
||||
try {
|
||||
theSectionJsonPath = JsonPath.compile(sectionJSONPath);
|
||||
data = theSectionJsonPath.read(theWholeProjectAsJSON, configuration);
|
||||
} catch (Exception e) {
|
||||
LOG.warn("Error on searching the section " + sectionJSONPath + " in the JSON Project: "
|
||||
+ theWholeProjectAsJSON);
|
||||
continue;
|
||||
}
|
||||
|
||||
LOG.debug("Data is instace of: " + data.getClass());
|
||||
LOG.debug("data to string: " + data.toString());
|
||||
|
||||
// Splitting the General Document in bson.Document according to list of
|
||||
// GcubeProfiles
|
||||
List<Document> listBSONDocument = new ArrayList<Document>();
|
||||
if (data instanceof org.json.JSONObject) {
|
||||
String jsonString = data.toString();
|
||||
LOG.debug("the JSON to string: " + jsonString);
|
||||
Document sectionDoc = Document.parse(jsonString);
|
||||
listBSONDocument.add(sectionDoc);
|
||||
|
||||
} else if (data instanceof org.json.JSONArray) {
|
||||
org.json.JSONArray dataArray = (org.json.JSONArray) data;
|
||||
for (int i = 0; i < dataArray.length(); i++) {
|
||||
String jsonString = dataArray.get(i).toString();
|
||||
LOG.debug("the array " + i + " JSON to string: " + jsonString);
|
||||
Document sectionDoc = Document.parse(jsonString);
|
||||
listBSONDocument.add(sectionDoc);
|
||||
}
|
||||
}
|
||||
|
||||
LOG.debug("Result for " + gcubeProfileDV.getSectionName() + " is: " + listBSONDocument);
|
||||
List<MetaDataProfileBean> theProfileBeans = gcubeProfileMetaForUCD.getListMetadataProfileBean();
|
||||
MetaDataProfileBean theProfileBean = theProfileBeans.get(0);
|
||||
|
||||
//Creating the corresponding MetaDataProfileBeanExt
|
||||
MetaDataProfileBeanExt theProfileBeanExt = new MetaDataProfileBeanExt();
|
||||
theProfileBeanExt.setCategories(theProfileBean.getCategories());
|
||||
theProfileBeanExt.setTitle(theProfileBean.getTitle());
|
||||
theProfileBeanExt.setType(theProfileBean.getType());
|
||||
|
||||
// For each bson.Document filling the MetaDataProfileBean and its file
|
||||
for (int i = 0; i < listBSONDocument.size(); i++) {
|
||||
Document fromSectionDoc = listBSONDocument.get(i);
|
||||
|
||||
|
||||
//Reading policy and license statically
|
||||
//eg. "_access":{"_policy":"OPEN","_license":"CC0-1.0"}}
|
||||
Document docAccess = null;
|
||||
Access access = null;
|
||||
try {
|
||||
docAccess = fromSectionDoc.get("_access", Document.class);
|
||||
System.out.println("docAccess is: "+docAccess);
|
||||
access = new Access();
|
||||
access.setPolicy(AccessPolicy.valueOf(docAccess.getString("_policy")));
|
||||
access.setLicense(docAccess.getString("_license"));
|
||||
// Access. access.get("_policy");
|
||||
// access.get("_license");
|
||||
System.out.println("access is: "+access);
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
// SubDocumentView subDocumentView = new SubDocumentView();
|
||||
// Document toSectionDoc = new Document();
|
||||
// Filling the MetadataFieldWrapper metadata with the
|
||||
// metadataField.getFieldName() as currentValue
|
||||
for (MetadataFieldWrapper metadataField : theProfileBean.getMetadataFields()) {
|
||||
|
||||
String theFieldName = metadataField.getFieldId() != null ? metadataField.getFieldId()
|
||||
: metadataField.getFieldName();
|
||||
LOG.debug("reading theFieldName: " + theFieldName);
|
||||
Object theOBJFieldValue = fromSectionDoc.get(theFieldName);
|
||||
metadataField.setCurrentValue(theOBJFieldValue+"");
|
||||
|
||||
if(access!=null) {
|
||||
if(theFieldName.equalsIgnoreCase("policy")) {
|
||||
metadataField.setCurrentValue(access.getPolicy().name());
|
||||
}else if(theFieldName.equalsIgnoreCase("licenseID")) {
|
||||
metadataField.setCurrentValue(access.getLicense());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
theProfileBeanExt.setMetadataFields(theProfileBean.getMetadataFields());
|
||||
|
||||
// Reading filePaths
|
||||
List<FilePathDV> filePaths = gcubeProfileDV.getFilePaths();
|
||||
|
||||
// READING fileset* field ACCORDING TO filePaths OF THE 'gcubeProfiles' CONFIG
|
||||
if (filePaths != null) {
|
||||
String fromSectionDocJSON = fromSectionDoc.toJson();
|
||||
List<FilesetDV> listFiles = new ArrayList<FilesetDV>();
|
||||
// List<GCubeSDIViewerLayerDV> listLayers = new ArrayList<GCubeSDIViewerLayerDV>();
|
||||
for (FilePathDV filePath : filePaths) {
|
||||
|
||||
// Reading Fileset _payloads
|
||||
String filesetJSONPath = String.format("%s.%s", JSON_$_POINTER, filePath.getFieldName());
|
||||
List<Payload> listPayloads = readPayloadsForFileset(filesetJSONPath, fromSectionDocJSON);
|
||||
FilesetDV filesetDV = new FilesetDV();
|
||||
filesetDV.setName(filePath.getGcubeProfileFieldName());
|
||||
for (Payload payload : listPayloads) {
|
||||
PayloadDV payloadDV = ConvertToDataValueObjectModel.toPayloadDV(payload);
|
||||
filesetDV.addPayloadDV(payloadDV);
|
||||
listFiles.add(filesetDV);
|
||||
}
|
||||
|
||||
// Reading Fileset _materializations
|
||||
// listLayers = readGcubeSDILayersForFileset(filesetJSONPath,
|
||||
// fromSectionDocJSON);
|
||||
|
||||
}
|
||||
|
||||
theProfileBeanExt.setListFileset(listFiles);
|
||||
}
|
||||
|
||||
listProfileBeansExt.add(theProfileBeanExt);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
projectView.setTheProfileBeans(listProfileBeansExt);
|
||||
|
||||
return projectView;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load project view.
|
||||
*
|
||||
|
@ -490,7 +693,8 @@ public class Geoportal_JSON_Mapper {
|
|||
String jsonPath = null;
|
||||
try {
|
||||
jsonPath = String.format("%s.%s", JSON_$_POINTER, _BBOX);
|
||||
HashMap<String, Object> bbox = JsonPath.using(config).parse(toSerializeJSONOBJ).read(jsonPath, HashMap.class);
|
||||
HashMap<String, Object> bbox = JsonPath.using(config).parse(toSerializeJSONOBJ).read(jsonPath,
|
||||
HashMap.class);
|
||||
BBOXDV bboxDV = new BBOXDV(bbox);
|
||||
gsdiLayer.setBbox(bboxDV);
|
||||
LOG.debug(_BBOX + " is: " + bboxDV);
|
||||
|
@ -665,4 +869,31 @@ public class Geoportal_JSON_Mapper {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pretty print project view.
|
||||
*
|
||||
* @param projectView the project view
|
||||
*/
|
||||
public static void prettyPrintProjectEdit(ProjectEdit projectEdit) {
|
||||
|
||||
for (MetaDataProfileBeanExt mpb : projectEdit.getTheProfileBeans()) {
|
||||
System.out.println("\n\n###### Title: " + mpb.getTitle() + " - Type: " + mpb.getType() + " ######");
|
||||
int i = 1;
|
||||
for (MetadataFieldWrapper mfw : mpb.getMetadataFields()) {
|
||||
System.out.println("## " + MetadataFieldWrapper.class.getSimpleName() + " n." + i);
|
||||
System.out.println("***** Metadata");
|
||||
//System.out.println(mfw);
|
||||
System.out.println("\tfieldId: " + mfw.getFieldId() +", fieldName: "+mfw.getFieldName() +", CurrentValue: "+mfw.getCurrentValue());
|
||||
i++;
|
||||
}
|
||||
i = 1;
|
||||
System.out.println("***** Files");
|
||||
for (FilesetDV fileSet : mpb.getListFileset()) {
|
||||
System.out.println("## " + FilesetDV.class.getSimpleName() + " n." + i);
|
||||
System.out.println(fileSet);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.shared;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.FilesetDV;
|
||||
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.CategoryWrapper;
|
||||
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean;
|
||||
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetadataFieldWrapper;
|
||||
|
||||
public class MetaDataProfileBeanExt extends MetaDataProfileBean {
|
||||
|
||||
private List<FilesetDV> listFileset = null;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -7201955007623188104L;
|
||||
|
||||
public MetaDataProfileBeanExt() {
|
||||
super();
|
||||
}
|
||||
|
||||
public MetaDataProfileBeanExt(String type, String title, List<MetadataFieldWrapper> metadataFields,
|
||||
List<CategoryWrapper> categories) {
|
||||
super(type, title, metadataFields, categories);
|
||||
}
|
||||
|
||||
public List<FilesetDV> getListFileset() {
|
||||
if(listFileset==null)
|
||||
listFileset = new ArrayList<FilesetDV>();
|
||||
return listFileset;
|
||||
}
|
||||
|
||||
public void setListFileset(List<FilesetDV> listFileset) {
|
||||
this.listFileset = listFileset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("MetaDataProfileBeanExt [listFileset=");
|
||||
builder.append(listFileset);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
|
||||
|
||||
public class ProjectEdit implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 2885327516680245601L;
|
||||
|
||||
private ProjectDV theProjectDV;
|
||||
|
||||
private List<MetaDataProfileBeanExt> theProfileBeans;
|
||||
|
||||
public ProjectEdit() {
|
||||
|
||||
}
|
||||
|
||||
public ProjectDV getTheProjectDV() {
|
||||
return theProjectDV;
|
||||
}
|
||||
|
||||
public List<MetaDataProfileBeanExt> getTheProfileBeans() {
|
||||
return theProfileBeans;
|
||||
}
|
||||
|
||||
public void setTheProjectDV(ProjectDV theProjectDV) {
|
||||
this.theProjectDV = theProjectDV;
|
||||
}
|
||||
|
||||
public void setTheProfileBeans(List<MetaDataProfileBeanExt> theProfileBeans) {
|
||||
this.theProfileBeans = theProfileBeans;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("ProjectEdit [theProjectDV=");
|
||||
builder.append(theProjectDV);
|
||||
builder.append(", theProfileBeans=");
|
||||
builder.append(theProfileBeans);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -625,6 +625,13 @@ body {
|
|||
text-align: center;
|
||||
}
|
||||
|
||||
.display-date {
|
||||
color: red;
|
||||
background-color: #f7f7f9;
|
||||
padding: 2px;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
|
||||
/*****
|
||||
RESPONSIVE
|
||||
|
|
|
@ -20,11 +20,15 @@ import org.gcube.application.geoportalcommon.shared.geoportal.geojson.GeoJSON;
|
|||
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.GCubeSDIViewerLayerDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.PayloadDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.TemporalReferenceDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.server.Geoportal_JSON_Mapper;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.ProjectEdit;
|
||||
import org.json.JSONObject;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* The Class GeoportalViewer_Tests.
|
||||
|
@ -46,7 +50,7 @@ public class GeoportalViewer_Tests {
|
|||
private static String TOKEN = ""; // devVRE
|
||||
|
||||
private static String PROFILE_ID = "profiledConcessioni";
|
||||
private static String PROJECT_ID = "6356ad1dde985906377eef3f";
|
||||
private static String PROJECT_ID = "6372470aa7b910781daaa8bc";
|
||||
|
||||
private static String USERNAME = "francesco.mangiacrapa";
|
||||
|
||||
|
@ -114,7 +118,7 @@ public class GeoportalViewer_Tests {
|
|||
|
||||
}
|
||||
|
||||
//@Test
|
||||
// @Test
|
||||
public void getSpatialReference() {
|
||||
System.out.println("getSpatialReference [profileID: " + PROFILE_ID + ", projectID: " + PROJECT_ID + "] called");
|
||||
try {
|
||||
|
@ -203,4 +207,56 @@ public class GeoportalViewer_Tests {
|
|||
}
|
||||
}
|
||||
|
||||
// @Test
|
||||
public void testReadProjectEdit() {
|
||||
|
||||
try {
|
||||
ScopeProvider.instance.set(CONTEXT);
|
||||
SecurityTokenProvider.instance.set(TOKEN);
|
||||
Project theProject = clientProjects.getProjectByID(PROFILE_ID, PROJECT_ID);
|
||||
ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(true);
|
||||
projectBuilder.relationships(true);
|
||||
ProjectDV theProjectDV = ConvertToDataValueObjectModel.toProjectDV(theProject, projectBuilder);
|
||||
ProjectEdit projectEdit = Geoportal_JSON_Mapper.loadProjectEdit(theProjectDV, CONTEXT, USERNAME);
|
||||
Geoportal_JSON_Mapper.prettyPrintProjectEdit(projectEdit);
|
||||
|
||||
// ProjectView projectView = Geoportal_JSON_Mapper.loadProjectView(theProjectDV, CONTEXT, USERNAME);
|
||||
// Geoportal_JSON_Mapper.prettyPrintProjectView(projectView);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
//@Test
|
||||
public void testTemporalReference() {
|
||||
try {
|
||||
ScopeProvider.instance.set(CONTEXT);
|
||||
SecurityTokenProvider.instance.set(TOKEN);
|
||||
Project theProject = clientProjects.getProjectByID(PROFILE_ID, PROJECT_ID);
|
||||
Document temporalJsonTemplate = GeoportalClientCaller.useCaseDescriptors()
|
||||
.readTemporalDimensionTemplate(theProject.getProfileID());
|
||||
|
||||
// String template = "{\"content\": \"$.nome\"," + "\"title\": \"$.nome\","
|
||||
// + "\"start\" : \"$.dataInizioProgetto\"," + "\"end\" : \"$.dataFineProgetto\"}";
|
||||
|
||||
if (temporalJsonTemplate != null) {
|
||||
|
||||
JSONObject sourceJsonTemplate = new JSONObject(temporalJsonTemplate);
|
||||
|
||||
JSONObject targetJsonObject = ConvertToDataValueObjectModel.toTimelineJSONModel(theProject,
|
||||
sourceJsonTemplate, theProject.getProfileID(), theProject.getId(), null);
|
||||
|
||||
TemporalReferenceDV temporalDV = ConvertToDataValueObjectModel.toTemporalReferenceDV(theProject,
|
||||
targetJsonObject);
|
||||
System.out.println(temporalDV);
|
||||
// ProjectView projectView = Geoportal_JSON_Mapper.loadProjectView(theProjectDV, CONTEXT, USERNAME);
|
||||
// Geoportal_JSON_Mapper.prettyPrintProjectView(projectView);
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue