diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 1f1af12..883b08d 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,5 +1,6 @@ - + + @@ -21,7 +22,8 @@ - + + @@ -43,7 +45,8 @@ - + + @@ -65,7 +68,8 @@ - + + @@ -87,7 +91,8 @@ - + + @@ -109,7 +114,8 @@ - + + @@ -134,7 +140,8 @@ uses - + + @@ -156,7 +163,8 @@ - + + @@ -178,7 +186,8 @@ - + + @@ -200,7 +209,8 @@ - + + diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/LayerManager.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/LayerManager.java index 48b9eaa..bd81bfb 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/LayerManager.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/LayerManager.java @@ -40,11 +40,15 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformation import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.ZAxis; import com.github.gwtbootstrap.client.ui.Button; +import com.github.gwtbootstrap.client.ui.Heading; +import com.github.gwtbootstrap.client.ui.Label; import com.github.gwtbootstrap.client.ui.constants.ButtonType; import com.github.gwtbootstrap.client.ui.constants.IconType; +import com.github.gwtbootstrap.client.ui.constants.LabelType; import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; +import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.shared.HandlerManager; @@ -54,6 +58,7 @@ import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.EventListener; +import com.google.gwt.user.client.Random; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.FlexTable; @@ -690,8 +695,8 @@ public class LayerManager { * @param queryClick the query click */ public void showPopupInfoForLayer(List listGeoNaDataObject, ExtentWrapped queryClick) { - GWT.log("showPopupInfoForLayer called for "+listGeoNaDataObject); - + GWT.log("showPopupInfoForLayer called for " + listGeoNaDataObject); + ScrollPanel scrollPanel = new ScrollPanel(); final FlowPanel flowPanel = new FlowPanel(); flowPanel.getElement().getStyle().setProperty("maxHeight", "600px"); @@ -739,10 +744,10 @@ public class LayerManager { } }); - String prevConcessioneName = ""; + String prevProjectId = ""; for (GeoNaSpatialQueryResult geoNaSpatialQueryResult : listGeoNaDataObject) { try { - + Set indexLayers = mapIndexLayerObjects.keySet(); LayerObject lo = geoNaSpatialQueryResult.getSourceLayerObject(); LayerItem sourceLI = lo.getLayerItem(); @@ -750,8 +755,8 @@ public class LayerManager { String layerSourceName = sourceLI.getName(); // skipping centroid layer - if (layerSourceName == null - || indexLayers.contains(layerSourceName)) { + if (layerSourceName == null || indexLayers.contains(layerSourceName) + || lo.getType().equals(LayerObjectType.INDEX_LAYER)) { continue; } @@ -762,81 +767,107 @@ public class LayerManager { } GWT.log("showPopupInfoForLayer must be REVISITED"); -// -// String nomeConcessione = lo.getProjectLayer().getNome(); if -// (prevConcessioneName.compareTo(nomeConcessione) != 0) { String -// concessioneIntro = nomeConcessione.length() > 100 ? -// StringUtil.ellipsize(nomeConcessione, 100) : nomeConcessione; Heading heading -// = new Heading(4, concessioneIntro); heading.setTitle(nomeConcessione); -// heading.getElement().getStyle().setMarginBottom(10, Unit.PX); -// flowPanel.add(heading); -// -// Button buttOpenProject = new Button("Open Project"); final String buttId = -// "open-details-" + Random.nextInt(); Element bEl = -// buttOpenProject.getElement(); bEl.setId(buttId); -// bEl.getStyle().setPaddingLeft(0, Unit.PX); -// buttOpenProject.setType(ButtonType.LINK); -// -// if (buttOpenProject != null) { flowPanel.add(buttOpenProject); -// buttOpenProject.setType(ButtonType.LINK); -// Scheduler.get().scheduleDeferred(new ScheduledCommand() { -// -// @Override public void execute() { Element buttonElement = -// DOM.getElementById(buttId); Event.sinkEvents(buttonElement, Event.ONCLICK); -// Event.setEventListener(buttonElement, new EventListener() { -// -// @Override public void onBrowserEvent(Event event) { if (Event.ONCLICK == -// event.getTypeInt()) { applicationBus.fireEvent(new -// ShowDetailsEvent("concessione", lo.getSourceConcessione().getItemId(), -// nomeConcessione, null)); -// -// } } }); } }); } listOpenProject.add(buttOpenProject); -// -// HTML subText = new HTML( -// "

Layers and Properties

" -// ); flowPanel.add(subText); } -// -// prevConcessioneName = nomeConcessione; -// -// Label layerLabel = new Label(); layerLabel.setType(LabelType.INFO); -// -// String layerName = StringUtil.fullNameToLayerName(layerSourceName, ":"); -// layerLabel.setText(layerName); layerLabel.setTitle(layerSourceName); -// layerLabel.getElement().getStyle().setMarginTop(10, Unit.PX); -// layerLabel.getElement().getStyle().setMarginBottom(5, Unit.PX); -// flowPanel.add(layerLabel); -// -// GWT.log("Displaying " + features.size() + " features"); FlexTable intFlex = -// new FlexTable(); intFlex.setCellPadding(1); intFlex.setCellSpacing(1); -// intFlex.getElement().addClassName("table-feature"); intFlex.setHTML(0, 0, new -// HTML("Feature Id").toString()); -// -// int i = 0; for (FeatureRow feature : features) { -// -// intFlex.setHTML(i + 1, 0, new HTML(feature.getId()).toString()); -// -// // Showing properties belonging to concessioni layer Map> entries = feature.getMapProperties(); -// -// if (entries.size() == 0) { // Adding this row to show "no property" for -// feature // intFlex.setHTML(i + 1, 1, new -// HTML("No property").toString()); } int j = 0; for (String key : -// entries.keySet()) { List theValues = entries.get(key); String -// valueToDisplay = ""; for (String value : theValues) { valueToDisplay += value -// + ", "; -// -// } valueToDisplay = valueToDisplay.substring(0, valueToDisplay.length() - 2); -// -// // adding the keys only of first feature row. They are equal for all features -// // (beloning to same layer). if (i == 0) intFlex.setHTML(0, j + 1, new -// HTML(key).toString()); -// -// intFlex.setHTML(i + 1, j + 1, new HTML(valueToDisplay).toString()); j++; -// -// } i++; } flowPanel.add(intFlex); -// - + String newProjectID = lo.getProjectID(); + if (prevProjectId.compareTo(newProjectID) != 0) { + String concessioneIntro = newProjectID.length() > 100 + ? StringUtil.ellipsize(newProjectID, 100) + : newProjectID; + Heading heading = new Heading(4, concessioneIntro); + heading.setTitle(newProjectID); + heading.getElement().getStyle().setMarginBottom(10, Unit.PX); + flowPanel.add(heading); + + Button buttOpenProject = new Button("Open Project"); + final String buttId = "open-details-" + Random.nextInt(); + Element bEl = buttOpenProject.getElement(); + bEl.setId(buttId); + bEl.getStyle().setPaddingLeft(0, Unit.PX); + buttOpenProject.setType(ButtonType.LINK); + + if (buttOpenProject != null) { + flowPanel.add(buttOpenProject); + buttOpenProject.setType(ButtonType.LINK); + Scheduler.get().scheduleDeferred(new ScheduledCommand() { + + @Override + public void execute() { + Element buttonElement = DOM.getElementById(buttId); + Event.sinkEvents(buttonElement, Event.ONCLICK); + Event.setEventListener(buttonElement, new EventListener() { + + @Override + public void onBrowserEvent(Event event) { + if (Event.ONCLICK == event.getTypeInt()) { + applicationBus.fireEvent(new ShowDetailsEvent(lo.getType().name(), + lo.getProfileID(), newProjectID, null, null)); + + } + } + }); + } + }); + } + listOpenProject.add(buttOpenProject); + + HTML subText = new HTML( + "

Layers and Properties

"); + flowPanel.add(subText); + } + + prevProjectId = newProjectID; + + Label layerLabel = new Label(); + layerLabel.setType(LabelType.INFO); + + String layerName = StringUtil.fullNameToLayerName(layerSourceName, ":"); + layerLabel.setText(layerName); + layerLabel.setTitle(layerSourceName); + layerLabel.getElement().getStyle().setMarginTop(10, Unit.PX); + layerLabel.getElement().getStyle().setMarginBottom(5, Unit.PX); + flowPanel.add(layerLabel); + + GWT.log("Displaying " + features.size() + " features"); + FlexTable intFlex = new FlexTable(); + intFlex.setCellPadding(1); + intFlex.setCellSpacing(1); + intFlex.getElement().addClassName("table-feature"); + intFlex.setHTML(0, 0, new HTML("Feature Id").toString()); + + int i = 0; + for (FeatureRow feature : features) { + + intFlex.setHTML(i + 1, 0, new HTML(feature.getId()).toString()); + + // Showing properties belonging to concessioni layer + Map> entries = feature.getMapProperties(); + + if (entries.size() == 0) { + // Adding this row to show "no property" for feature + // intFlex.setHTML(i + 1, 1, new HTML("No property").toString()); + } + int j = 0; + for (String key : entries.keySet()) { + List theValues = entries.get(key); + String valueToDisplay = ""; + for (String value : theValues) { + valueToDisplay += value + ", "; + + } + valueToDisplay = valueToDisplay.substring(0, valueToDisplay.length() - 2); + + // adding the keys only of first feature row. They are equal for all features + // (beloning to same layer). + if (i == 0) + intFlex.setHTML(0, j + 1, new HTML(key).toString()); + + intFlex.setHTML(i + 1, j + 1, new HTML(valueToDisplay).toString()); + j++; + + } + i++; + } + flowPanel.add(intFlex); } catch (Exception e) { GeoportalDataViewerConstants.printJs("Error: " + e.getMessage()); } @@ -910,7 +941,7 @@ public class LayerManager { if (listUI != null && listUI.size() > 0) { PayloadDV img = listUI.get(0); if (img != null && img.getLink() != null) { - String theImgHTML = ""; + String theImgHTML = ""; GWT.log("theImgHTML: " + theImgHTML); // GeoportalDataViewerConstants.print("The row are: // "+flex.getRowCount()); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java index 0f2fc2f..6ef3530 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java @@ -63,6 +63,7 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.ViewerConfiguration; import org.gcube.portlets.user.geoportaldataviewer.shared.faults.ControlledError; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject; +import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObjectType; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.FeatureRow; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformationForWMSRequest; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.Styles; @@ -1020,8 +1021,9 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme Project theProject = GeoportalClientCaller.projects().getProjectByID(profileID, projectID); String jsonDocument = theProject.getTheDocument().toJson(); LOG.trace("JSON Project is: " + jsonDocument); - - String filesetJSONPath = String.format("%s..%s", Geoportal_JSON_Mapper.JSON_$_POINTER, Geoportal_JSON_Mapper.FILESET); + + String filesetJSONPath = String.format("%s..%s", Geoportal_JSON_Mapper.JSON_$_POINTER, + Geoportal_JSON_Mapper.FILESET); listImages = Geoportal_JSON_Mapper.readImagesForFileset(filesetJSONPath, jsonDocument); @@ -1117,45 +1119,87 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme LOG.debug("For layer name: " + layerObject.getLayerItem().getName() + " got features: " + features); geoDAO.setFeatures(features); - // Getting the projectid from WFS features - for (FeatureRow fRow : features) { - if (fRow.getMapProperties() != null) { - List productIDs = fRow.getMapProperties().get("projectid"); - if (productIDs != null && productIDs.size() > 0) { - String projectID = productIDs.get(0); - try { - LOG.debug("Found the projectID : " + projectID + " into properties of feature id: " - + fRow.getId()); - String profileID = layerObject.getProfileID(); - LOG.debug("Read the profileID from layerObject : " + profileID); - if (profileID != null) { - Project theProject = GeoportalClientCaller.projects().getProjectByID(profileID, - projectID); - ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(false); - ProjectDV projectDV = ConvertToDataValueObjectModel.toProjectDV(theProject, - projectBuilder); - geoDAO.setProjectDV(projectDV); + if (features != null && features.size() > 0) { - List images = getImagesForId(profileID, projectID); + LayerObjectType loType = layerObject.getType(); + if (loType == null) + loType = LayerObjectType.GENERIC_LAYER; + + switch (layerObject.getType()) { + case INDEX_LAYER: { + + // Expected 1 feature + FeatureRow fRow = features.get(0); + if (fRow.getMapProperties() != null) { + List productIDs = fRow.getMapProperties().get("projectid"); + if (productIDs != null && productIDs.size() > 0) { + String projectID = productIDs.get(0); + layerObject.setProjectID(projectID); + String profileID = layerObject.getProfileID(); + List images; + // Loading images for profileID and projectID + try { + images = getImagesForId(profileID, projectID); Map> mapImages = new LinkedHashMap>(); mapImages.put(projectID, images); // mapImages.put(cId, listUI); geoDAO.setMapImages(mapImages); - - } else { - LOG.warn("ProfileID is null for: " + layerObject); + } catch (Exception e) { + LOG.warn("Error on loading images for projectID: " + projectID + " profileID: " + + profileID); } - } catch (Exception e) { - LOG.warn("Error on loading images for project: " + projectID, e); } } + + geoDAO.setSourceLayerObject(layerObject); + LOG.info("For layer name: " + layerObject.getLayerItem().getName() + " got " + features.size() + + " feature/s"); + listDAO.add(geoDAO); + + break; } + case PROJECT_LAYER: + case GENERIC_LAYER: { + + // Getting the projectid from WFS features, but limiting to the first one + for (FeatureRow fRow : features) { + if (fRow.getMapProperties() != null) { + List 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"); + listDAO.add(geoDAO); + + } + + default: + break; + } + } - geoDAO.setSourceLayerObject(layerObject); - LOG.info("For layer name: " + layerObject.getLayerItem().getName() + " got " + features.size() - + " feature/s"); - listDAO.add(geoDAO); } LOG.info("returning " + listDAO + " geona data objects"); return listDAO; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/LayerObject.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/LayerObject.java index 9c9c226..ce74757 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/LayerObject.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/LayerObject.java @@ -2,8 +2,7 @@ package org.gcube.portlets.user.geoportaldataviewer.shared.gis; import java.io.Serializable; -import org.gcube.application.geoportalcommon.shared.geoportal.materialization.GCubeSDILayer; -import org.gcube.application.geoportalcommon.shared.geoportal.materialization.IndexLayerDV; +import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV; /** * Represents a layer, holds the layer item and the related Collection info if @@ -20,13 +19,15 @@ public class LayerObject implements Serializable { private LayerObjectType type; - private IndexLayerDV indexLayer; // expected for INDEX_LAYER type + // private IndexLayerDV indexLayer; // expected for INDEX_LAYER type private String profileID; // expected for collection layers - private GCubeSDILayer projectLayer; // expected for PROJECT_LAYER + // private GCubeSDILayer projectLayer; // expected for PROJECT_LAYER private String projectID; // expected for PROJECT_LAYER private LayerItem layerItem; + private ProjectDV projectDV; + public LayerObject() { super(); } @@ -36,19 +37,6 @@ public class LayerObject implements Serializable { this.setLayerItem(item); } - public LayerObject(String profileID, IndexLayerDV indexLayer, LayerItem item) { - this(LayerObjectType.INDEX_LAYER, item); - this.profileID = profileID; - this.indexLayer = indexLayer; - } - - public LayerObject(String profileID, String projectID, GCubeSDILayer projectLayer, LayerItem item) { - this(LayerObjectType.PROJECT_LAYER, item); - this.profileID = profileID; - this.projectID = projectID; - this.projectLayer = projectLayer; - } - public LayerObjectType getType() { return type; } @@ -57,14 +45,6 @@ public class LayerObject implements Serializable { this.type = type; } - public IndexLayerDV getIndexLayer() { - return indexLayer; - } - - public void setIndexLayer(IndexLayerDV indexLayer) { - this.indexLayer = indexLayer; - } - public String getProfileID() { return profileID; } @@ -73,14 +53,6 @@ public class LayerObject implements Serializable { this.profileID = profileID; } - public GCubeSDILayer getProjectLayer() { - return projectLayer; - } - - public void setProjectLayer(GCubeSDILayer projectLayer) { - this.projectLayer = projectLayer; - } - public String getProjectID() { return projectID; } @@ -97,21 +69,27 @@ public class LayerObject implements Serializable { this.layerItem = layerItem; } + public ProjectDV getProjectDV() { + return projectDV; + } + + public void setProjectDV(ProjectDV projectDV) { + this.projectDV = projectDV; + } + @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append("LayerObject [type="); builder.append(type); - builder.append(", indexLayer="); - builder.append(indexLayer); builder.append(", profileID="); builder.append(profileID); - builder.append(", projectLayer="); - builder.append(projectLayer); builder.append(", projectID="); builder.append(projectID); builder.append(", layerItem="); builder.append(layerItem); + builder.append(", projectDV="); + builder.append(projectDV); builder.append("]"); return builder.toString(); }