in progress

This commit is contained in:
Francesco Mangiacrapa 2022-10-25 11:35:03 +02:00
parent 0a5cd91c55
commit 0900cd46c5
17 changed files with 403 additions and 107 deletions

View File

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
@ -23,7 +25,9 @@
<wb-module deploy-name="geoportal-data-viewer-app-3.0.0-SNAPSHOT">
@ -47,7 +51,9 @@
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
@ -71,7 +77,9 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
@ -95,7 +103,9 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
@ -119,7 +129,9 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
@ -146,7 +158,9 @@
<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>
@ -170,7 +184,9 @@
<property name="java-output-path" value="/geoportal-data-viewer-app/target/geoportal-data-viewer-app-0.0.1-SNAPSHOT/WEB-INF/classes"/>
@ -194,7 +210,9 @@
<property name="context-root" value="geoportal-data-viewer-app"/>
@ -218,7 +236,9 @@
</wb-module>

View File

@ -8,10 +8,7 @@ import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences;
import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.IndexLayerDV;
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
import org.gcube.application.geoportalcommon.shared.products.model.RecordDV;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MapEventType;
import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEvent;
@ -304,7 +301,7 @@ public class GeoportalDataViewer implements EntryPoint {
IndexLayerDV layer = toOpen.getIndexes().get(0);
// Open Index Layer
layerManager.addIndexLayer(layer, toOpen.getUcd().getProfileID());
layerManager.addIndexLayer(layer, toOpen.getUcd().getProfileID(), null);
}
}
});
@ -406,7 +403,8 @@ public class GeoportalDataViewer implements EntryPoint {
if (record != null) {
this.cancel();
GWT.log("cancelled timer");
performWFSQueryOnCentroid(record);
performWFSQueryOnCentroid(record.getTheProjectDV().getId(),
record.getCentroidLong(), record.getCentroidLat());
}
if (attempt > MAX_RETRY) {
@ -540,16 +538,17 @@ public class GeoportalDataViewer implements EntryPoint {
}
});
// applicationBus.addHandler(ShowPopupOnCentroiEvent.TYPE, new ShowPopupOnCentroiEventHandler() {
//
// @Override
// public void onShowPopup(ShowPopupOnCentroiEvent showPopupOnCentroiEvent) {
//
// if (showPopupOnCentroiEvent.getRecord() != null)
// performWFSQueryOnCentroid(showPopupOnCentroiEvent.getRecord());
//
// }
// });
applicationBus.addHandler(ShowPopupOnCentroiEvent.TYPE, new ShowPopupOnCentroiEventHandler() {
@Override
public void onShowPopup(ShowPopupOnCentroiEvent showPopupOnCentroiEvent) {
if (showPopupOnCentroiEvent.getDocument() != null)
performWFSQueryOnCentroid(showPopupOnCentroiEvent.getDocument().getProjectID(),
showPopupOnCentroiEvent.getCentroidLong(), showPopupOnCentroiEvent.getCentroidLat());
}
});
applicationBus.addHandler(SearchPerformedEvent.TYPE, new SearchPerformedEventHandler() {
@ -602,10 +601,11 @@ public class GeoportalDataViewer implements EntryPoint {
//
// }-*/;
private void performWFSQueryOnCentroid(ProjectView project) {
if (project != null) {
Double x = project.getCentroidLong();
Double y = project.getCentroidLat();
private void performWFSQueryOnCentroid(String projectID, Double centroidLong, Double centroidLat) {
GWT.log("Perform performWFSQueryOnCentroid: "+projectID+ " long: "+centroidLong + ", lat: "+centroidLat);
if (projectID != null) {
Double x = centroidLong;
Double y = centroidLat;
GWT.log("X: " + x + ", Y:" + y);
if (x != null && y != null) {
Coordinate transfCoord = MapUtils.transformCoordiante(new Coordinate(x, y),
@ -615,8 +615,8 @@ public class GeoportalDataViewer implements EntryPoint {
// GeoportalDataViewerConstants.print("fireEvent QueryDataEvent");
ExtentWrapped toExt = new ExtentWrapped(transfCoord.getX(), transfCoord.getY(), transfCoord.getX(),
transfCoord.getY());
layerManager.getLayerManagerBus().fireEvent(new QueryDataEvent(select, toExt,
project.getTheProjectDV().getId(), true, MapEventType.ADDED_CENTROID_LAYER_TO_MAP));
layerManager.getLayerManagerBus().fireEvent(
new QueryDataEvent(select, toExt, projectID, true, MapEventType.ADDED_CENTROID_LAYER_TO_MAP));
} else {
GeoportalDataViewerConstants
.printJs("I cannot select the point one or both coordiantes are null. X: " + x + ", Y:" + y);

View File

@ -210,7 +210,7 @@ public class LayerManager {
MapEventType sourceEvent = queryEvent.getSourceMapEventType();
// TODO SWTCH FOR EARCH ITEM TYPE
for (GeoNaSpatialQueryResult geoNaDataObject : listGeonaDataObjects) {
for (final GeoNaSpatialQueryResult geoNaDataObject : listGeonaDataObjects) {
GWT.log("GeoNaDataObject: " + geoNaDataObject);
List<FeatureRow> features = geoNaDataObject.getFeatures();
LayerItem layerItem = geoNaDataObject.getSourceLayerObject().getLayerItem();
@ -344,7 +344,7 @@ public class LayerManager {
true,
OLMapManager.LAYER_DETAIL_MIN_RESOLUTION,
OLMapManager.LAYER_DETAIL_MAX_RESOLUTION,
theProfileID, theProductID);
theProfileID, theProductID, geoNaDataObject.getSourceLayerObject().getProjectDV());
}
}
@ -464,11 +464,12 @@ public class LayerManager {
* @param maxResolution the max resolution
* @param profileID the profile ID
* @param projectID the project ID
* @param projectDV the project DV
*/
public void addLayer(final LayerObjectType lot, final String layerTitle, final String layerName,
final String wmsLink, final boolean isBase, final boolean displayInLayerSwitcher, final String UUID,
final boolean asDetailLayer, Double minResolution, Double maxResolution, final String profileID,
final String projectID) {
final String projectID, final ProjectDV projectDV) {
final LayerType featureType = isBase ? LayerType.RASTER_BASELAYER : LayerType.FEATURE_TYPE;
@ -507,6 +508,7 @@ public class LayerManager {
lo.setType(lot);
lo.setProjectID(projectID);
lo.setProfileID(profileID);
lo.setProjectDV(projectDV);
String layerNameKey = layerItem.getName();
@ -531,6 +533,7 @@ public class LayerManager {
mapOtherLayerObjects.put(layerNameKey, theLo);
GWT.log("mapOtherLayerObjects is: " + mapIndexLayerObjects);
olMap.addWMSDetailLayer(layerItem);
overlayLayerManager.addLayerItem(theLo);
} else {
GWT.log("Skipping " + lo.getType() + " layer " + theLo.getLayerItem().getName()
+ " already added to Map");
@ -565,17 +568,20 @@ public class LayerManager {
});
}
/**
* Adds the index layer.
*
* @param layer the layer
* @param profileID the profile ID
* @param projectDV the project DV
*/
public void addIndexLayer(IndexLayerDV layer, String profileID) {
public void addIndexLayer(IndexLayerDV layer, String profileID, ProjectDV projectDV) {
GWT.log("Adding index layer: " + layer);
String wmsLink = layer.getLayer().getOgcLinks().get("wms");
GWT.log("index layer wmsLink: " + wmsLink);
addLayer(LayerObjectType.INDEX_LAYER, null, null, wmsLink, false, false, null, false, null, null, profileID,
null);
null, projectDV);
}

View File

@ -1,17 +1,25 @@
package org.gcube.portlets.user.geoportaldataviewer.client;
import java.util.ArrayList;
import java.util.HashMap;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.dandd.DragDropLayer;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject;
import com.github.gwtbootstrap.client.ui.Label;
import com.github.gwtbootstrap.client.ui.constants.LabelType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.ui.FlowPanel;
public class OverlayLayerManager {
private ArrayList<LayerObject> layers = new ArrayList<LayerObject>();
private FlowPanel fp = new FlowPanel();
// private ArrayList<LayerObject> layers = new ArrayList<LayerObject>();
// private FlowPanel fp = new FlowPanel();
private FlowPanel clusterCollectionsMainPanel = new FlowPanel();
private HashMap<String, ArrayList<DragDropLayer>> mapCollectionsPerProfileID = new HashMap<String, ArrayList<DragDropLayer>>();
private HashMap<String, FlowPanel> mapCollectionsContainersPerProfileID = new HashMap<String, FlowPanel>();
private HandlerManager applicationBus;
public OverlayLayerManager(HandlerManager applicationBus) {
@ -19,18 +27,43 @@ public class OverlayLayerManager {
}
void addLayerItem(LayerObject lo) {
GWT.log("Adding LayerObject having project: "+lo.getProjectDV());
ArrayList<DragDropLayer> listDDLayers = mapCollectionsPerProfileID.get(lo.getProfileID());
if (listDDLayers == null) {
String collectionName = lo.getProjectDV() != null && lo.getProjectDV().getProfileName() != null
? lo.getProjectDV().getProfileName()
: lo.getProfileID();
Label labelCollectionName = new Label(collectionName);
labelCollectionName.setType(LabelType.WARNING);
clusterCollectionsMainPanel.add(labelCollectionName);
listDDLayers = new ArrayList<DragDropLayer>();
}
FlowPanel fp = new FlowPanel();
fp.getElement().getStyle().setMarginLeft(10, Unit.PX);
DragDropLayer dandd = new DragDropLayer(applicationBus, lo, true, true);
layers.add(lo);
listDDLayers.add(dandd);
fp.add(dandd);
mapCollectionsContainersPerProfileID.put(lo.getProfileID(), fp);
mapCollectionsPerProfileID.put(lo.getProfileID(), listDDLayers);
clusterCollectionsMainPanel.add(fp);
}
public void resetLayers() {
layers.clear();
fp.clear();
clusterCollectionsMainPanel.clear();
mapCollectionsContainersPerProfileID.clear();
mapCollectionsPerProfileID.clear();
}
public FlowPanel getPanel() {
return fp;
return clusterCollectionsMainPanel;
}
}

View File

@ -14,6 +14,8 @@ import com.google.gwt.event.shared.GwtEvent;
public class ShowPopupOnCentroiEvent extends GwtEvent<ShowPopupOnCentroiEventHandler> {
public static Type<ShowPopupOnCentroiEventHandler> TYPE = new Type<ShowPopupOnCentroiEventHandler>();
private DocumentDV document;
private Double centroidLong;
private Double centroidLat;
/**
* Instantiates a new show details event.
@ -23,8 +25,10 @@ public class ShowPopupOnCentroiEvent extends GwtEvent<ShowPopupOnCentroiEventHan
* @param itemName the item name
* @param featureRow the feature row
*/
public ShowPopupOnCentroiEvent(DocumentDV document) {
public ShowPopupOnCentroiEvent(DocumentDV document, Double centroidLong, Double centroidLat) {
this.document = document;
this.centroidLong = centroidLong;
this.centroidLat = centroidLat;
}
@ -52,5 +56,13 @@ public class ShowPopupOnCentroiEvent extends GwtEvent<ShowPopupOnCentroiEventHan
public DocumentDV getDocument() {
return document;
}
public Double getCentroidLat() {
return centroidLat;
}
public Double getCentroidLong() {
return centroidLong;
}
}

View File

@ -8,7 +8,7 @@
}
.to-align-right{
position: absolute;
top: 40px;
top: 50px;
right: 10px;
}
</ui:style>

View File

@ -0,0 +1,24 @@
package org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.project;
import java.util.Map.Entry;
import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV;
public class ProjectUtil {
public static <T extends DocumentDV> String toHMLCode(T document, String projectID) {
String htmlCode = "";
Entry<String, Object> firstEntrySet = document.getFirstEntryOfMap();
if (firstEntrySet != null) {
htmlCode += firstEntrySet.getKey() + ": <b>" + firstEntrySet.getValue() + "</b>";
}
if (projectID != null) {
htmlCode += "(id: " + projectID + ")";
}
return htmlCode;
}
}

View File

@ -19,7 +19,6 @@ import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.MapView;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.util.CustomFlexTable;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.PageHeader;
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.google.gwt.core.client.GWT;

View File

@ -21,8 +21,7 @@
.the-title {
background-color: rgba(0,60,136,.7);
color: white;
font-style: italic;
padding: 5px 10px;
padding: 10px 10px;
font-size: 14px;
}

View File

@ -0,0 +1,50 @@
package org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.project.relation;
import java.util.List;
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.project.ProjectUtil;
import com.github.gwtbootstrap.client.ui.Column;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Widget;
public class RelationshipPanel extends Composite {
private static ViewRelationshipPanelUiBinder uiBinder = GWT.create(ViewRelationshipPanelUiBinder.class);
interface ViewRelationshipPanelUiBinder extends UiBinder<Widget, RelationshipPanel> {
}
@UiField
HTMLPanel rootRow;
@UiField
Column leftChildColumn;
@UiField
Column rightChildColumn;
private HandlerManager appManagerBus;
public RelationshipPanel(HandlerManager appManagerBus, ProjectDV fromProject, List<ProjectDV> relationships) {
initWidget(uiBinder.createAndBindUi(this));
this.appManagerBus = appManagerBus;
String html = ProjectUtil.toHMLCode(fromProject.getTheDocument(), fromProject.getId());
rootRow.add(new HTML(html));
showRelationsOf(fromProject);
}
public void showRelationsOf(ProjectDV project) {
}
}

View File

@ -0,0 +1,23 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
<ui:style>
</ui:style>
<g:HTMLPanel>
<b:Row ui:field="rootRow">
<b:FlowPanel ui:field="rootPanel"></b:FlowPanel>
</b:Row>
<b:Row>
<b:Column size="4">
<b:FlowPanel ui:field="leftChildPanel"></b:FlowPanel>
</b:Column>
<b:Column size="4">
<b:FlowPanel ui:field="rightChildPanel"></b:FlowPanel>
</b:Column>
</b:Row>
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -13,6 +13,7 @@ import org.gcube.application.geoportalcommon.shared.SearchingFilter.LOGICAL_OP;
import org.gcube.application.geoportalcommon.shared.SearchingFilter.ORDER;
import org.gcube.application.geoportalcommon.shared.WhereClause;
import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV;
import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync;
import org.gcube.portlets.user.geoportaldataviewer.client.events.SearchPerformedEvent;
@ -38,10 +39,8 @@ import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyPressEvent;
import com.google.gwt.event.dom.client.KeyPressHandler;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.cellview.client.TextColumn;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite;
@ -308,9 +307,11 @@ public class SearchFacilityUI extends Composite {
i = 1;
for (DocumentDV documentDV : result.getData()) {
ResultDocumentDV resultDoc = (ResultDocumentDV) documentDV;
NavLink locateOnMap = new NavLink("Show");
locateOnMap.setTitle("Locate on the Map and show details");
locateOnMap.setTitle("Open this project and show details");
locateOnMap.setIcon(IconType.MAP_MARKER);
locateOnMap.addClickHandler(new ClickHandler() {
@ -320,7 +321,7 @@ public class SearchFacilityUI extends Composite {
GeoportalItemReferences gir = new GeoportalItemReferences(documentDV.getProjectID(),
profileID);
appManagerBus.fireEvent(new ShowDetailsEvent(gir, null, null));
appManagerBus.fireEvent(new ShowPopupOnCentroiEvent(documentDV));
appManagerBus.fireEvent(new ShowPopupOnCentroiEvent(documentDV, resultDoc.getCentroidLong(), resultDoc.getCentroidLat()));
}
});

View File

@ -995,8 +995,10 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
}
protected List<PayloadDV> getImagesForId(String profileID, String projectID) throws Exception {
LOG.info("getImagesForId [profileID: " + profileID + ", projectID: " + projectID + "] called");
protected List<PayloadDV> getImagesForId(String profileID, String projectID, boolean limitToFirstOneFound)
throws Exception {
LOG.info("getImagesForId [profileID: " + profileID + ", projectID: " + projectID + ", limitToFirstOneFound: "
+ limitToFirstOneFound + "] called");
if (profileID == null)
throw new Exception("Invalid parameter. The profileID is null");
@ -1025,7 +1027,8 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
String filesetJSONPath = String.format("%s..%s", Geoportal_JSON_Mapper.JSON_$_POINTER,
Geoportal_JSON_Mapper.FILESET);
listImages = Geoportal_JSON_Mapper.readImagesForFileset(filesetJSONPath, jsonDocument);
listImages = Geoportal_JSON_Mapper.readImagesForFileset(filesetJSONPath, jsonDocument,
limitToFirstOneFound);
LOG.info("For projectID " + projectID + ", returning " + listImages.size() + " image/s");
return listImages;
@ -1068,7 +1071,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
new GeoportalServiceIdentityProxy(this.getThreadLocalRequest());
UseCaseDescriptor ucd = GeoportalClientCaller.useCaseDescriptors().getUCDForId(profileID);
Project theProject = GeoportalClientCaller.projects().getProjectByID(profileID, projectID);
ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(true);
projectBuilder.relationships(true);
ProjectDV theProjectDV = ConvertToDataValueObjectModel.toProjectDV(theProject, projectBuilder);
@ -1137,10 +1140,11 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
String projectID = productIDs.get(0);
layerObject.setProjectID(projectID);
String profileID = layerObject.getProfileID();
List<PayloadDV> images;
// Loading images for profileID and projectID
try {
images = getImagesForId(profileID, projectID);
images = getImagesForId(profileID, projectID, true);
Map<String, List<PayloadDV>> mapImages = new LinkedHashMap<String, List<PayloadDV>>();
mapImages.put(projectID, images);
@ -1150,6 +1154,32 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
LOG.warn("Error on loading images for projectID: " + projectID + " profileID: "
+ profileID);
}
// Sets only profileID and profileName into ProjectDV
if (layerObject.getProjectDV() == null) {
QueryRequest request = new QueryRequest();
request.setFilter(Document.parse(
"{\"" + UseCaseDescriptor.ID + "\" : " + "{\"$eq\" : \"" + profileID + "\"}}"));
request.setProjection(Document.parse("{\"" + UseCaseDescriptor.NAME + "\" : " + "1}"));
try {
useCaseDescriptors().build().query(request).forEachRemaining(u -> {
try {
LOG.debug("UCD for id" + u.getId() + " returend name: " + u.getName());
ProjectDV projectDV = new ProjectDV();
projectDV.setId(projectID);
projectDV.setProfileName(u.getName());
projectDV.setProfileID(u.getId());
layerObject.setProjectDV(projectDV);
} catch (Exception e) {
LOG.warn("Invalid UCD, UCID : " + u.getId());
}
});
} catch (Exception e) {
// silent
}
}
}
}
@ -1160,35 +1190,56 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
break;
}
case PROJECT_LAYER:
case GENERIC_LAYER: {
LOG.debug("The LayerObject is a of kind: "+layerObject.getType());
// Getting the projectid from WFS features, but limiting to the first one
for (FeatureRow fRow : features) {
if (fRow.getMapProperties() != null) {
List<String> productIDs = fRow.getMapProperties().get("projectid");
if (productIDs != null && productIDs.size() > 0) {
String projectID = productIDs.get(0);
layerObject.setProjectID(projectID);
String profileID = layerObject.getProfileID();
try {
Project theProject = GeoportalClientCaller.projects().getProjectByID(profileID,
projectID);
ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder()
.fullDocumentMap(false);
ProjectDV projectDV = ConvertToDataValueObjectModel.toProjectDV(theProject,
projectBuilder);
geoDAO.setProjectDV(projectDV);
layerObject.setProjectDV(projectDV);
// Limiting to 1 feature of Layers
continue;
} catch (Exception e) {
LOG.warn("Error on loading the Project for projectID: " + projectID + " profileID: "
+ profileID);
}
}
LOG.debug("The LayerObject is a of kind: " + layerObject.getType());
// TODO CHECK THIS
// Getting the projectid from WFS features, but limiting to the first one, Do we
// have more than one centroid in the same position??
if (layerObject.getProjectDV() == null) {
Project theProject;
try {
theProject = GeoportalClientCaller.projects().getProjectByID(layerObject.getProfileID(),
layerObject.getProjectID());
ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(false);
ProjectDV projectDV = ConvertToDataValueObjectModel.toProjectDV(theProject, projectBuilder);
layerObject.setProjectDV(projectDV);
} catch (Exception e) {
String erroMsg = "Error occurred on loading project for profileID "+layerObject.getProfileID()+" and projectID "+layerObject.getProjectID();
LOG.warn(erroMsg, e);
}
}
// for (FeatureRow fRow : features) {
// if (fRow.getMapProperties() != null) {
// List<String> productIDs = fRow.getMapProperties().get("projectid");
// if (productIDs != null && productIDs.size() > 0) {
// String projectID = productIDs.get(0);
// layerObject.setProjectID(projectID);
// String profileID = layerObject.getProfileID();
// try {
// Project theProject = GeoportalClientCaller.projects().getProjectByID(profileID,
// projectID);
// ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder()
// .fullDocumentMap(false);
// ProjectDV projectDV = ConvertToDataValueObjectModel.toProjectDV(theProject,
// projectBuilder);
// // geoDAO.setProjectDV(projectDV);
// layerObject.setProjectDV(projectDV);
// // Limiting to 1 feature of Layers
// continue;
// } catch (Exception e) {
// LOG.warn("Error on loading the Project for projectID: " + projectID + " profileID: "
// + profileID);
// }
// }
// }
// }
geoDAO.setSourceLayerObject(layerObject);
LOG.info("For layer name: " + layerObject.getLayerItem().getName() + " got " + features.size()
+ " feature/s");

View File

@ -37,6 +37,13 @@ import com.google.gson.JsonParser;
import com.jayway.jsonpath.JsonPath;
import com.jayway.jsonpath.spi.json.JsonOrgJsonProvider;
/**
* The Class Geoportal_JSON_Mapper.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Oct 24, 2022
*/
public class Geoportal_JSON_Mapper {
public static final String _PAYLOADS = "_payloads";
@ -57,6 +64,15 @@ public class Geoportal_JSON_Mapper {
public static final String _THEDOCUMENT = "_theDocument";
/**
* Load project view.
*
* @param theProjectDV the the project DV
* @param scope the scope
* @param username the username
* @return the project view
* @throws Exception the exception
*/
public static ProjectView loadProjectView(ProjectDV theProjectDV, String scope, String username) throws Exception {
String theWholeProjectAsJSON = theProjectDV.getTheDocument().getDocumentAsJSON();
@ -309,11 +325,13 @@ public class Geoportal_JSON_Mapper {
/**
* Read images for fileset.
*
* @param parentJSONPath the parent JSON path
* @param sectionJSONDocument the section JSON document
* @param parentJSONPath the parent JSON path
* @param sectionJSONDocument the section JSON document
* @param limitToFirstOneFound the limit to first one found
* @return the list
*/
public static List<PayloadDV> readImagesForFileset(String parentJSONPath, String sectionJSONDocument) {
public static List<PayloadDV> readImagesForFileset(String parentJSONPath, String sectionJSONDocument,
boolean limitToFirstOneFound) {
LOG.debug("readImagesForFileset called");
List<PayloadDV> listImages = new ArrayList<PayloadDV>();
@ -332,14 +350,23 @@ public class Geoportal_JSON_Mapper {
if (isImage) {
PayloadDV payloadDV = ConvertToDataValueObjectModel.toPayloadDV(payload);
listImages.add(payloadDV);
if (limitToFirstOneFound && listImages.size() == 1)
return listImages;
}
}
LOG.debug("readImagesForFileset returning listOfImages: "+listImages);
LOG.debug("readImagesForFileset returning listOfImages: " + listImages);
return listImages;
}
/**
* Read gcube SDI layers for fileset.
*
* @param materializationParentJSONPath the materialization parent JSON path
* @param sectionJSONDocument the section JSON document
* @return the list
*/
public static List<GCubeSDIViewerLayerDV> readGcubeSDILayersForFileset(String materializationParentJSONPath,
String sectionJSONDocument) {
LOG.debug("readGcubeSDILayersForFileset called");
@ -368,6 +395,14 @@ public class Geoportal_JSON_Mapper {
}
/**
* Recursive fetching layers.
*
* @param config the config
* @param objectJSON the object JSON
* @param listSDILayers the list SDI layers
* @return the list
*/
private static List<GCubeSDIViewerLayerDV> recursiveFetchingLayers(com.jayway.jsonpath.Configuration config,
Object objectJSON, List<GCubeSDIViewerLayerDV> listSDILayers) {
@ -392,10 +427,11 @@ public class Geoportal_JSON_Mapper {
}
/**
* Read payloads for fileset.
* Recursive fetching payloads.
*
* @param filesetJSONPath the fileset JSON path
* @param sectionJSONDocument the section JSON document
* @param config the config
* @param objectJSON the object JSON
* @param payloads the payloads
* @return the list
*/
public static List<Payload> recursiveFetchingPayloads(com.jayway.jsonpath.Configuration config, Object objectJSON,
@ -410,7 +446,7 @@ public class Geoportal_JSON_Mapper {
LOG.trace("jsonArray: " + theJsonArray.toString(3));
for (int i = 0; i < theJsonArray.length(); i++) {
recursiveFetchingPayloads(config, theJsonArray.get(i), payloads);
payloads = recursiveFetchingPayloads(config, theJsonArray.get(i), payloads);
}
} else if (objectJSON instanceof JSONObject) {
JSONObject toStringPayloads = (JSONObject) objectJSON;
@ -420,8 +456,8 @@ public class Geoportal_JSON_Mapper {
payload = Serialization.read(toStringPayloads.toString(), Payload.class);
payloads.add(payload);
} catch (Exception e) {
LOG.warn("Error on converting the JSON Boject " + toStringPayloads + "as " + Payload.class.getSimpleName()
+ e.getMessage());
LOG.warn("Error on converting the JSON Boject " + toStringPayloads + "as "
+ Payload.class.getSimpleName() + e.getMessage());
}
}
@ -430,6 +466,13 @@ public class Geoportal_JSON_Mapper {
}
/**
* Conver layer.
*
* @param config the config
* @param thJsonObject the th json object
* @return the g cube SDI viewer layer DV
*/
// TODO THIS PART SHOULD BE REVISITED/OPTIMIZED
private static GCubeSDIViewerLayerDV converLayer(com.jayway.jsonpath.Configuration config,
JSONObject thJsonObject) {
@ -576,6 +619,11 @@ public class Geoportal_JSON_Mapper {
return gson.toJson(jsonObject);
}
/**
* Pretty print project view.
*
* @param projectView the project view
*/
public static void prettyPrintProjectView(ProjectView projectView) {
for (SectionView section : projectView.getListSections()) {

View File

@ -5,7 +5,6 @@ import java.util.List;
import java.util.Map;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.PayloadDV;
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.FeatureRow;
@ -27,7 +26,7 @@ public class GeoNaSpatialQueryResult implements Serializable {
// Map with couple (mongoId concessione, list of uploaded GNAImages for the
// concessione)
private Map<String, List<PayloadDV>> mapImages = null;
private ProjectDV projectDV;
// private ProjectDV projectDV;
/**
* Instantiates a new geo na data object.
@ -36,14 +35,14 @@ public class GeoNaSpatialQueryResult implements Serializable {
}
public void setProjectDV(ProjectDV projectDV) {
this.projectDV = projectDV;
}
public ProjectDV getProjectDV() {
return projectDV;
}
// public void setProjectDV(ProjectDV projectDV) {
// this.projectDV = projectDV;
//
// }
//
// public ProjectDV getProjectDV() {
// return projectDV;
// }
/**
* Gets the features.
@ -108,8 +107,6 @@ public class GeoNaSpatialQueryResult implements Serializable {
builder.append(sourceLayerObject);
builder.append(", mapImages=");
builder.append(mapImages);
builder.append(", projectDV=");
builder.append(projectDV);
builder.append("]");
return builder.toString();
}

View File

@ -454,8 +454,9 @@ body {
/*******************************************/
.search-facility {
width: 600px;
width: 750px;
max-height: 700px;
max-width: 850px;
}
.search-textbox {

View File

@ -1,8 +1,13 @@
package org.gcube.portlets.user.geoportaldataviewer;
import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin.useCaseDescriptors;
import java.util.List;
import org.bson.Document;
import org.gcube.application.geoportal.common.model.document.Project;
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
import org.gcube.application.geoportalcommon.ConvertToDataValueObjectModel;
import org.gcube.application.geoportalcommon.ProjectDVBuilder;
import org.gcube.application.geoportalcommon.geoportal.GeoportalClientCaller;
@ -120,9 +125,10 @@ public class GeoportalViewer_Tests {
Project project = clientProjects.getProjectByID(PROFILE_ID, PROJECT_ID);
String jsonDocument = project.getTheDocument().toJson();
System.out.println("JSON Project is: " + jsonDocument);
String filesetJSONPath = String.format("%s..%s", Geoportal_JSON_Mapper.JSON_$_POINTER, Geoportal_JSON_Mapper.FILESET);
listImages = Geoportal_JSON_Mapper.readImagesForFileset(filesetJSONPath, jsonDocument);
String filesetJSONPath = String.format("%s..%s", Geoportal_JSON_Mapper.JSON_$_POINTER,
Geoportal_JSON_Mapper.FILESET);
listImages = Geoportal_JSON_Mapper.readImagesForFileset(filesetJSONPath, jsonDocument, true);
listImages.stream().forEach(s -> System.out.println("Image: " + s));
@ -133,5 +139,31 @@ public class GeoportalViewer_Tests {
}
}
//@Test
public void testUCDQuery() {
QueryRequest request = new QueryRequest();
request.setFilter(
Document.parse("{\"" + UseCaseDescriptor.ID + "\" : " + "{\"$eq\" : \"" + PROFILE_ID + "\"}}"));
request.setProjection(Document.parse("{\"" + UseCaseDescriptor.NAME + "\" : " + "1}"));
try {
useCaseDescriptors().build().query(request).forEachRemaining(u -> {
try {
System.out.println("UCD for id" + u.getId() + " returend name: " + u.getName());
ProjectDV projectDV = new ProjectDV();
projectDV.setId(PROJECT_ID);
projectDV.setProfileName(u.getName());
projectDV.setProfileID(u.getId());
System.out.println(projectDV);
} catch (Exception e) {
System.out.println("Invalid UCD, UCID : " + u.getId());
e.printStackTrace();
}
});
} catch (Exception e) {
// silent
}
}
}