From b15dbf8a81a903fa0f024fa9414e5e4ddd4527fb Mon Sep 17 00:00:00 2001 From: Fabio Sinibaldi Date: Tue, 18 Oct 2022 12:30:28 +0200 Subject: [PATCH] Collections support --- .../client/GeoportalDataViewer.java | 14 +- .../client/LayerManager.java | 1019 +++++++++-------- .../client/ViewerStatus.java | 2 +- .../collections/OpenCollectionEvent.java | 4 +- .../client/gis/LightOpenLayerMap.java | 2 +- .../client/gis/OpenLayerMap.java | 19 +- .../client/ui/dandd/DragDropLayer.java | 8 +- .../client/ui/map/MapView.java | 4 +- .../GeoportalDataViewerServiceImpl.java | 4 +- .../shared/ViewerConfiguration.java | 4 +- .../materialization/GCubeSDILayerDV.java | 29 + .../GeoServerPlatformInfoDV.java | 20 +- .../shared/gis/IndexLayer.java | 5 + .../shared/gis/LayerItem.java | 90 +- .../ModelConversionTests.java | 26 +- 15 files changed, 684 insertions(+), 566 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java index c2f0c8e..cc0e06b 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java @@ -30,6 +30,8 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.GCubeCollection; import org.gcube.portlets.user.geoportaldataviewer.shared.ViewerConfiguration; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.IndexLayer; +import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem; +import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.GWT; @@ -272,6 +274,8 @@ public class GeoportalDataViewer implements EntryPoint { GWT.log("!! Collection "+collId+" is not available"); Window.alert("Collection "+collId+" is not found."); }else { + try { + GCubeCollection toOpen = GeoportalDataViewer.getStatus().getConfig().getAvailableCollections().get(collId); // Check if indexes is empty @@ -284,9 +288,15 @@ public class GeoportalDataViewer implements EntryPoint { IndexLayer layer = toOpen.getIndexes().get(0); // Open Index Layer - layerManager.addIndexLayer(layer); + GWT.log("Opening index "+layer); + LayerObject toAdd = new LayerObject(toOpen.getUcd().getId(), layer, LayerItem.fromIndex(layer)); + layerManager.addLayer(toAdd); + }catch(Throwable t) { + GWT.log("Unable to open collection.",t); + Window.alert("Unable to open collection. Please contact administrators."); + } } }); @@ -299,7 +309,7 @@ public class GeoportalDataViewer implements EntryPoint { // ??? // Open details popup (if called on startup) - // Opens layer manager panel + try { 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 5d66a37..704e841 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 @@ -110,217 +110,220 @@ public class LayerManager { */ private void bindEvents() { - layerManagerBus.addHandler(QueryDataEvent.TYPE, new QueryDataEventHandler() { - - @Override - public void onQueryInteraction(final QueryDataEvent queryEvent) { - // GeoportalDataViewerConstants.print("fired QueryDataEvent: - // "+queryEvent.toString()); - - if (queryEvent.getGeoQuery() != null) { - GeoQuery selectDataInfo = queryEvent.getGeoQuery(); - String mongoItemId = queryEvent.getMongoItemId(); - - GWT.log("(" + selectDataInfo.getX1() + "," + selectDataInfo.getY1() + ")(" + selectDataInfo.getX2() - + "," + selectDataInfo.getY2() + ")"); - - BoundsMap mapBBOX = new BoundsMap(); - double minX = queryEvent.getGeoQuery().getX1(); - double minY = queryEvent.getGeoQuery().getY1(); - Coordinate centerCoordinate = new Coordinate(minX, minY); - centerCoordinate = olMap.transform(centerCoordinate, MAP_PROJECTION.EPSG_3857.getName(), - MAP_PROJECTION.EPSG_4326.getName()); - mapBBOX.setLowerLeftX(centerCoordinate.getX()); - mapBBOX.setLowerLeftY(centerCoordinate.getY()); - -// double maxX = olMap.getExtent().getUpperRightX(); -// double maxY = olMap.getExtent().getUpperRightY(); - double maxX = queryEvent.getGeoQuery().getX2(); - double maxY = queryEvent.getGeoQuery().getY2(); - centerCoordinate = new Coordinate(maxX, maxY); - centerCoordinate = olMap.transform(centerCoordinate, MAP_PROJECTION.EPSG_3857.getName(), - MAP_PROJECTION.EPSG_4326.getName()); - mapBBOX.setUpperRightX(centerCoordinate.getX()); - mapBBOX.setUpperRightY(centerCoordinate.getY()); - - mapBBOX.setCrs(MAP_PROJECTION.EPSG_4326.getName()); - - GWT.log("Bounds is: " + mapBBOX); - GWT.log("MAX_WFS_FEATURES is: " + GeoportalDataViewerConstants.MAX_WFS_FEATURES); - // GeoportalDataViewerConstants.print("calling getDataResult"); - - List listLO = new ArrayList(); - // for querying base layers - listLO.addAll(mapBaseLayerObjects.values()); - - // for querying detail layers only in this case - if (olMap.getCurrentResolution() < OLMapManager.LAYER_DETAIL_MAX_RESOLUTION) { - Collection collLO = mapDetailLayerObjects.values(); - listLO.addAll(collLO); - - ArrayList layerVisibility = new ArrayList(collLO.size()); - layerVisibility.addAll(collLO); - //Managing layer visibility. If a layer is not visible has to be not queryable - for (LayerObject layerObject : layerVisibility) { - String layerName = layerObject.getLayerItem().getName(); - boolean isLayerVisible = olMap.isLayerVisible(layerName); - if(!isLayerVisible) { - GWT.log("From querying removing layername: "+layerName + ", it is not visible"); - listLO.remove(layerObject); - } -// else { -// ExtentWrapped layerExtent = olMap.getSourceExtentForLayer(layerName); -// if(layerExtent!=null) { -// ExtentWrapped centerQueryPoint = new ExtentWrapped(minX, minY, maxX,maxY); -// -// boolean contains = layerExtent.containsExtent(centerQueryPoint); -// GWT.log("layer: "+layerName + " contains the queried BBOX: "+contains); -// } + + // TODO Manage QueryDataEvent + +// layerManagerBus.addHandler(QueryDataEvent.TYPE, new QueryDataEventHandler() { +// +// @Override +// public void onQueryInteraction(final QueryDataEvent queryEvent) { +// // GeoportalDataViewerConstants.print("fired QueryDataEvent: +// // "+queryEvent.toString()); +// +// if (queryEvent.getGeoQuery() != null) { +// GeoQuery selectDataInfo = queryEvent.getGeoQuery(); +// String mongoItemId = queryEvent.getMongoItemId(); +// +// GWT.log("(" + selectDataInfo.getX1() + "," + selectDataInfo.getY1() + ")(" + selectDataInfo.getX2() +// + "," + selectDataInfo.getY2() + ")"); +// +// BoundsMap mapBBOX = new BoundsMap(); +// double minX = queryEvent.getGeoQuery().getX1(); +// double minY = queryEvent.getGeoQuery().getY1(); +// Coordinate centerCoordinate = new Coordinate(minX, minY); +// centerCoordinate = olMap.transform(centerCoordinate, MAP_PROJECTION.EPSG_3857.getName(), +// MAP_PROJECTION.EPSG_4326.getName()); +// mapBBOX.setLowerLeftX(centerCoordinate.getX()); +// mapBBOX.setLowerLeftY(centerCoordinate.getY()); +// +//// double maxX = olMap.getExtent().getUpperRightX(); +//// double maxY = olMap.getExtent().getUpperRightY(); +// double maxX = queryEvent.getGeoQuery().getX2(); +// double maxY = queryEvent.getGeoQuery().getY2(); +// centerCoordinate = new Coordinate(maxX, maxY); +// centerCoordinate = olMap.transform(centerCoordinate, MAP_PROJECTION.EPSG_3857.getName(), +// MAP_PROJECTION.EPSG_4326.getName()); +// mapBBOX.setUpperRightX(centerCoordinate.getX()); +// mapBBOX.setUpperRightY(centerCoordinate.getY()); +// +// mapBBOX.setCrs(MAP_PROJECTION.EPSG_4326.getName()); +// +// GWT.log("Bounds is: " + mapBBOX); +// GWT.log("MAX_WFS_FEATURES is: " + GeoportalDataViewerConstants.MAX_WFS_FEATURES); +// // GeoportalDataViewerConstants.print("calling getDataResult"); +// +// List listLO = new ArrayList(); +// // for querying base layers +// listLO.addAll(mapBaseLayerObjects.values()); +// +// // for querying detail layers only in this case +// if (olMap.getCurrentResolution() < OLMapManager.LAYER_DETAIL_MAX_RESOLUTION) { +// Collection collLO = mapDetailLayerObjects.values(); +// listLO.addAll(collLO); +// +// ArrayList layerVisibility = new ArrayList(collLO.size()); +// layerVisibility.addAll(collLO); +// //Managing layer visibility. If a layer is not visible has to be not queryable +// for (LayerObject layerObject : layerVisibility) { +// String layerName = layerObject.getLayerItem().getName(); +// boolean isLayerVisible = olMap.isLayerVisible(layerName); +// if(!isLayerVisible) { +// GWT.log("From querying removing layername: "+layerName + ", it is not visible"); +// listLO.remove(layerObject); // } -// - } - } - - GeoportalDataViewerServiceAsync.Util.getInstance().getDataResult(listLO, olMap.getProjectionCode(), - mapBBOX, GeoportalDataViewerConstants.MAX_WFS_FEATURES, olMap.getCurrentZoomLevel(), - new AsyncCallback>() { - - @Override - public void onFailure(Throwable caught) { - // GeoportalDataViewerConstants.print("on Failure DataResult: - // "+caught.getMessage()); - } - - @Override - public void onSuccess(List listGeonaDataObjects) { - - GWT.log("GeoNaDataObject's is/are " + listGeonaDataObjects.size()); - // GWT.log("GeoNaDataObject's: " + listGeonaDataObjects); - // GeoportalDataViewerConstants.print("GeoNaDataObject's: - // "+listGeonaDataObjects); - - if (listGeonaDataObjects == null || listGeonaDataObjects.isEmpty()) - return; - - FeatureRow feature = null; - - MapEventType sourceEvent = queryEvent.getSourceMapEventType(); - - // TODO SWTCH FOR EARCH ITEM TYPE - for (GeoNaSpatialQueryResult geoNaDataObject : listGeonaDataObjects) { - List features = geoNaDataObject.getFeatures(); - - GWT.log("GeoNaDataObject Source layer item name: " - + geoNaDataObject.getSourceLayerObject().getLayerItem().getName()); - - // USING ONLY THE FIRST FEATURE IN THE LIST - if (features != null && features.size() > 0) { - String theProductId = null; - // I need to show exactly the feature with produc_id == recordId - if (mongoItemId != null) { - for (FeatureRow fRow : features) { - List productIdLst = fRow.getMapProperties() - .get("product_id"); - theProductId = productIdLst.get(0); - try { - // long productId = Long.parseLong(thePID); - if (theProductId == mongoItemId) { - feature = fRow; - GWT.log("Found recorId == product_id with id: " - + theProductId); - break; - } - } catch (Exception e) { - // TODO: handle exception - } - } - } - - // If mongoItemId not passed, I'm using the first feature returned - if (mongoItemId == null) { - feature = features.get(0); - List productIdLst = feature.getMapProperties() - .get("product_id"); - if (productIdLst == null) { - // in this case the feature/s returned is/are a (detail) layer/s - // belonging - // to a record/concessione (not centroid layer), - // so calling show popuup info on detail layers if the - // following events are true. - if (sourceEvent.equals(MapEventType.MOUSE_CLICK) && olMap - .getCurrentZoomLevel() > OLMapManager.QUERY_MIN_ZOOM_LEVEL) { - - // Here I need to pass only the visible layers - showPopupInfoForLayer(listGeonaDataObjects, - queryEvent.getQueryClickExtent()); - } - return; - } - theProductId = productIdLst.get(0); - } else { - // the recordId to show has been passed but not found into list of - // FeatureRow - if (feature == null) { - return; - } - } - - GWT.log("the product id is: " + theProductId); - // Displaying popup info for centroid layer - if (sourceEvent.equals(MapEventType.MOUSE_CLICK) - || sourceEvent.equals(MapEventType.ADDED_CENTROID_LAYER_TO_MAP)) { - showPopupInfoForCentroidLayer(geoNaDataObject, feature, - queryEvent.getQueryClickExtent().getCenter()); - } - - - //TODO LOAD LAYERS FOM BBOX - GWT.log("TODO LAOD LAYERS" ); - - - -// // retrieving and showing WMS layers of a concessione if the ZOOM level is > -// // QUERY_MIN_ZOOM_LEVEL -// if (olMap.getCurrentZoomLevel() > OLMapManager.QUERY_MIN_ZOOM_LEVEL) { -// GeoportalDataViewerServiceAsync.Util.getInstance().getLayersForId( -// "concessione", theProductId, -// new AsyncCallback>() { +//// else { +//// ExtentWrapped layerExtent = olMap.getSourceExtentForLayer(layerName); +//// if(layerExtent!=null) { +//// ExtentWrapped centerQueryPoint = new ExtentWrapped(minX, minY, maxX,maxY); +//// +//// boolean contains = layerExtent.containsExtent(centerQueryPoint); +//// GWT.log("layer: "+layerName + " contains the queried BBOX: "+contains); +//// } +//// } +//// +// } +// } // -// @Override -// public void onFailure(Throwable caught) { -// // TODO Auto-generated method stub +// GeoportalDataViewerServiceAsync.Util.getInstance().getDataResult(listLO, olMap.getProjectionCode(), +// mapBBOX, GeoportalDataViewerConstants.MAX_WFS_FEATURES, olMap.getCurrentZoomLevel(), +// new AsyncCallback>() { // -// } +// @Override +// public void onFailure(Throwable caught) { +// // GeoportalDataViewerConstants.print("on Failure DataResult: +// // "+caught.getMessage()); +// } // -// @Override -// public void onSuccess(List result) { -// -// for (LayerConcessioneDV layer : result) { -// GWT.log("Adding layer: " + layer.getLayerName()); -// addLayer("concessione", layer.getLayerName(), -// layer.getLayerName(), layer.getWmsLink(), -// false, false, layer.getLayerUUID(), true, -// OLMapManager.LAYER_DETAIL_MIN_RESOLUTION, -// OLMapManager.LAYER_DETAIL_MAX_RESOLUTION, -// layer.getRefersTo()); -// } +// @Override +// public void onSuccess(List listGeonaDataObjects) { // -// } -// }); -// } else { -// // removing all WMS detail layers if the ZOOM level is < -// // QUERY_MIN_ZOOM_LEVEL -// removeAllDetailLayers(); +// GWT.log("GeoNaDataObject's is/are " + listGeonaDataObjects.size()); +// // GWT.log("GeoNaDataObject's: " + listGeonaDataObjects); +// // GeoportalDataViewerConstants.print("GeoNaDataObject's: +// // "+listGeonaDataObjects); +// +// if (listGeonaDataObjects == null || listGeonaDataObjects.isEmpty()) +// return; +// +// FeatureRow feature = null; +// +// MapEventType sourceEvent = queryEvent.getSourceMapEventType(); +// +// // TODO SWTCH FOR EARCH ITEM TYPE +// for (GeoNaSpatialQueryResult geoNaDataObject : listGeonaDataObjects) { +// List features = geoNaDataObject.getFeatures(); +// +// GWT.log("GeoNaDataObject Source layer item name: " +// + geoNaDataObject.getSourceLayerObject().getLayerItem().getName()); +// +// // USING ONLY THE FIRST FEATURE IN THE LIST +// if (features != null && features.size() > 0) { +// String theProductId = null; +// // I need to show exactly the feature with produc_id == recordId +// if (mongoItemId != null) { +// for (FeatureRow fRow : features) { +// List productIdLst = fRow.getMapProperties() +// .get("product_id"); +// theProductId = productIdLst.get(0); +// try { +// // long productId = Long.parseLong(thePID); +// if (theProductId == mongoItemId) { +// feature = fRow; +// GWT.log("Found recorId == product_id with id: " +// + theProductId); +// break; +// } +// } catch (Exception e) { +// // TODO: handle exception +// } +// } // } - - - } - } - } - }); - } - } - }); +// +// // If mongoItemId not passed, I'm using the first feature returned +// if (mongoItemId == null) { +// feature = features.get(0); +// List productIdLst = feature.getMapProperties() +// .get("product_id"); +// if (productIdLst == null) { +// // in this case the feature/s returned is/are a (detail) layer/s +// // belonging +// // to a record/concessione (not centroid layer), +// // so calling show popuup info on detail layers if the +// // following events are true. +// if (sourceEvent.equals(MapEventType.MOUSE_CLICK) && olMap +// .getCurrentZoomLevel() > OLMapManager.QUERY_MIN_ZOOM_LEVEL) { +// +// // Here I need to pass only the visible layers +// showPopupInfoForLayer(listGeonaDataObjects, +// queryEvent.getQueryClickExtent()); +// } +// return; +// } +// theProductId = productIdLst.get(0); +// } else { +// // the recordId to show has been passed but not found into list of +// // FeatureRow +// if (feature == null) { +// return; +// } +// } +// +// GWT.log("the product id is: " + theProductId); +// // Displaying popup info for centroid layer +// if (sourceEvent.equals(MapEventType.MOUSE_CLICK) +// || sourceEvent.equals(MapEventType.ADDED_CENTROID_LAYER_TO_MAP)) { +// showPopupInfoForCentroidLayer(geoNaDataObject, feature, +// queryEvent.getQueryClickExtent().getCenter()); +// } +// +// +// //TODO LOAD LAYERS FOM BBOX +// GWT.log("TODO LAOD LAYERS" ); +// +// +// +//// // retrieving and showing WMS layers of a concessione if the ZOOM level is > +//// // QUERY_MIN_ZOOM_LEVEL +//// if (olMap.getCurrentZoomLevel() > OLMapManager.QUERY_MIN_ZOOM_LEVEL) { +//// GeoportalDataViewerServiceAsync.Util.getInstance().getLayersForId( +//// "concessione", theProductId, +//// new AsyncCallback>() { +//// +//// @Override +//// public void onFailure(Throwable caught) { +//// // TODO Auto-generated method stub +//// +//// } +//// +//// @Override +//// public void onSuccess(List result) { +//// +//// for (LayerConcessioneDV layer : result) { +//// GWT.log("Adding layer: " + layer.getLayerName()); +//// addLayer("concessione", layer.getLayerName(), +//// layer.getLayerName(), layer.getWmsLink(), +//// false, false, layer.getLayerUUID(), true, +//// OLMapManager.LAYER_DETAIL_MIN_RESOLUTION, +//// OLMapManager.LAYER_DETAIL_MAX_RESOLUTION, +//// layer.getRefersTo()); +//// } +//// +//// } +//// }); +//// } else { +//// // removing all WMS detail layers if the ZOOM level is < +//// // QUERY_MIN_ZOOM_LEVEL +//// removeAllDetailLayers(); +//// } +// +// +// } +// } +// } +// }); +// } +// } +// }); layerManagerBus.addHandler(AddedLayerToMapEvent.TYPE, new AddedLayerToMapEventHandler() { @@ -346,9 +349,20 @@ public class LayerManager { * Removes the all detail layers. */ public void removeAllDetailLayers() { - mapDetailLayerObjects.clear(); - olMap.removeAllDetailLayers(); - overlayLayerManager.resetLayers(); + // TODO + + GWT.log("TODO : Implenent clear layers"); + + // REMOVE FROM MAP +// olMap.removeAllDetailLayers(); +// +// // REMOVE FROM MANAGER +// overlayLayerManager.resetLayers(); +// +// // REMOVE FROM STATUS +// mapDetailLayerObjects.clear(); + + } /** @@ -396,18 +410,35 @@ public class LayerManager { } case PROJECT_LAYER : { - map + // Add TO MAP + olMap.addWMSDetailLayer(object.getLayerItem()); + // ADD TO MAP MANAGER PANEL + getOverlayLayerManager().addLayerItem(object); + + // ADD TO STATUS + GeoportalDataViewer.getStatus().addOpenedProjectLayer(object.getUcid(), object.getProjectId(), object); break; } case INDEX_LAYER :{ + // Add TO MAP + olMap.addWMSDetailLayer(object.getLayerItem()); + + // ADD TO MAP MANAGER PANEL + getOverlayLayerManager().addLayerItem(object); + + // ADD TO STATUS + GeoportalDataViewer.getStatus().addOpenedIndex(object.getUcid(), object); break; } } } + + + // /** // * Adds the layer. // * @@ -556,128 +587,131 @@ public class LayerManager { } }); - String prevConcessioneName = ""; - for (GeoNaSpatialQueryResult geoNaSpatialQueryResult : listGeoNaDataObject) { - try { - GWT.log("baseLayerFromISProfile.getName() :" + baseLayerFromISProfile.getName()); - LayerObject lo = geoNaSpatialQueryResult.getSourceLayerObject(); - LayerItem sourceLI = lo.getLayerItem(); - - String layerSourceName = sourceLI.getName(); - - // skipping centroid layer - if (layerSourceName == null - || layerSourceName.compareToIgnoreCase(baseLayerFromISProfile.getName()) == 0) { - continue; - } - - List features = geoNaSpatialQueryResult.getFeatures(); - - if (features == null || features.isEmpty()) { - continue; - } - - String nomeConcessione = lo.getSourceConcessione().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); - } catch (Exception e) { - GeoportalDataViewerConstants.printJs("Error: " + e.getMessage()); - } - } + + // TODO Adapt for generic collections + +// String prevConcessioneName = ""; +// for (GeoNaSpatialQueryResult geoNaSpatialQueryResult : listGeoNaDataObject) { +// try { +// GWT.log("baseLayerFromISProfile.getName() :" + baseLayerFromISProfile.getName()); +// LayerObject lo = geoNaSpatialQueryResult.getSourceLayerObject(); +// LayerItem sourceLI = lo.getLayerItem(); +// +// String layerSourceName = sourceLI.getName(); +// +// // skipping centroid layer +// if (layerSourceName == null +// || layerSourceName.compareToIgnoreCase(baseLayerFromISProfile.getName()) == 0) { +// continue; +// } +// +// List features = geoNaSpatialQueryResult.getFeatures(); +// +// if (features == null || features.isEmpty()) { +// continue; +// } +// +// String nomeConcessione = lo.getSourceConcessione().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); +// } catch (Exception e) { +// GeoportalDataViewerConstants.printJs("Error: " + e.getMessage()); +// } +// } olMap.showPopup(scrollPanel.toString(), queryClick.getCenter()); @@ -694,166 +728,169 @@ public class LayerManager { public void showPopupInfoForCentroidLayer(GeoNaSpatialQueryResult geoNaDataObject, FeatureRow feature, Coordinate onFailureCenterTo) { - FlexTable flex = new FlexTable(); - flex.setCellPadding(1); - flex.setCellSpacing(1); - flex.getElement().addClassName("popup-table"); - VerticalPanel vpPanel = new VerticalPanel(); - vpPanel.add(flex); - - if (feature == null) { - flex.setHTML(0, 0, new HTML("No data available").toString()); - olMap.showPopup(vpPanel.toString(), onFailureCenterTo); - return; - } - - // Showing properties belonging to concessioni centroid layer - Map> entries = feature.getMapProperties(); - - String nome = ""; - String descrizione = ""; - String date = ""; - - for (String key : entries.keySet()) { - String theValue = entries.get(key).get(0); - if (key.equalsIgnoreCase("nome")) { - nome = theValue != null ? theValue : ""; - } else if (key.equalsIgnoreCase("descrizione")) { - descrizione = theValue != null ? theValue : ""; - } else if (key.equalsIgnoreCase("date_scavo")) { - date = theValue != null ? theValue : ""; - } - } - - // GeoportalDataViewerConstants.print("0: "+nome); - flex.setHTML(0, 0, new HTML(nome).toString()); - try { - descrizione = StringUtil.ellipsize(descrizione, 100); - GWT.log("reduced: " + descrizione); - } catch (Exception e) { - GWT.log("error: " + e.getMessage()); - } - // GeoportalDataViewerConstants.print("1: "+descrizione); - flex.setText(1, 0, descrizione); - // GeoportalDataViewerConstants.print("2: "+date); - date = StringUtil.formatDate(date); - flex.setHTML(2, 0, new HTML("" + date + "").toString()); - - if (geoNaDataObject.getMapImages() != null) { - for (String key : geoNaDataObject.getMapImages().keySet()) { - List listUI = geoNaDataObject.getMapImages().get(key); - GWT.log("Adding images: " + listUI); - if (listUI != null && listUI.size() > 0) { - UploadedImageDV img = listUI.get(0); - if (img!= null && img.getListWsContent() != null) { - WorkspaceContentDV wsContent = img.getListWsContent().get(img.getListWsContent().size() - 1); - String theImgHTML = ""; - GWT.log("theImgHTML: " + theImgHTML); - // GeoportalDataViewerConstants.print("The row are: - // "+flex.getRowCount()); - flex.setHTML(flex.getRowCount() + 1, 0, theImgHTML); - } - } - } - } - - GWT.log("The selected Feature is: " + feature); - // GeoportalDataViewerConstants.print("The selected Feature is: "+feature); - FeatureRow theFeature = feature; - Button button = new Button("Open Details"); - button.getElement().setId("open-details"); - button.setType(ButtonType.LINK); - - if (button != null) { - vpPanel.add(button); - button.setType(ButtonType.LINK); - button.addClickHandler(new ClickHandler() { - - @Override - public void onClick(ClickEvent event) { - ShowDetailsEvent toEvent = parseGeonaReferences( - geoNaDataObject.getSourceLayerObject().getItemType(), theFeature); - applicationBus.fireEvent(toEvent); - - } - }); - } - - Coordinate centerTo = null; - GWT.log("geometry is: " + feature.getGeometry()); - if (feature.getGeometry() != null) { - GWT.log("trasforming geometry: " + feature.getGeometry().getToJSONObject()); - - Geometry geom = new GeoJson().readGeometry(feature.getGeometry().getToJSONObject(), null); - - // POINT - if (geom.getType().equalsIgnoreCase("Point")) { - GWT.log("geometry: is a point"); - String coordinateJSON = feature.getGeometry().getCoordinatesJSON(); - JSONArray centerJSON = (JSONArray) JSONParser.parseStrict(coordinateJSON); -// Coordinate center = OLFactory.createCoordinate( -// new Double(centerJSON.get(0).toString()), -// new Double(centerJSON.get(1).toString())); - - Coordinate center = new Coordinate(new Double(centerJSON.get(0).toString()), - new Double(centerJSON.get(1).toString())); - - if (feature.getCrsName() != null && feature.getCrsName().endsWith(MAP_PROJECTION.EPSG_4326.getId())) { - - center = MapUtils.transformCoordiante(center, MAP_PROJECTION.EPSG_4326.getName(), - MAP_PROJECTION.EPSG_3857.getName()); - } - centerTo = center; - } else { - - Extent geomExtent = geom.getExtent(); - - Coordinate lower = OLFactory.createCoordinate(geomExtent.getLowerLeftX(), geomExtent.getLowerLeftY()); - Coordinate upper = OLFactory.createCoordinate(geomExtent.getUpperRightX(), geomExtent.getUpperRightY()); - Coordinate lowerCoord = lower; - Coordinate upperCoord = upper; - if (feature.getCrsName() != null && feature.getCrsName().endsWith(MAP_PROJECTION.EPSG_4326.getId())) { - - lowerCoord = MapUtils.transformCoordiante(lower, MAP_PROJECTION.EPSG_4326.getName(), - MAP_PROJECTION.EPSG_3857.getName()); - upperCoord = MapUtils.transformCoordiante(upper, MAP_PROJECTION.EPSG_4326.getName(), - MAP_PROJECTION.EPSG_3857.getName()); - } - - ExtentWrapped ew = new ExtentWrapped(lowerCoord.getX(), lowerCoord.getY(), upperCoord.getX(), - upperCoord.getY()); - - centerTo = new Coordinate(ew.getCenter().getX(), ew.getCenter().getY()); - - } - GWT.log("center is: " + centerTo); - } - - // fallback - if (centerTo == null) - centerTo = onFailureCenterTo; - - olMap.showPopup(vpPanel.toString(), centerTo); - - Scheduler.get().scheduleDeferred(new ScheduledCommand() { - - @Override - public void execute() { - Element buttonElement = DOM.getElementById("open-details"); - Event.sinkEvents(buttonElement, Event.ONCLICK); - Event.setEventListener(buttonElement, new EventListener() { - - @Override - public void onBrowserEvent(Event event) { - if (Event.ONCLICK == event.getTypeInt()) { - ShowDetailsEvent toEvent = parseGeonaReferences( - geoNaDataObject.getSourceLayerObject().getItemType(), theFeature); - applicationBus.fireEvent(toEvent); - } - } - }); - } - }); + GWT.log("TODO : SHOW POPUP METHOD "); + + +// FlexTable flex = new FlexTable(); +// flex.setCellPadding(1); +// flex.setCellSpacing(1); +// flex.getElement().addClassName("popup-table"); +// VerticalPanel vpPanel = new VerticalPanel(); +// vpPanel.add(flex); +// +// if (feature == null) { +// flex.setHTML(0, 0, new HTML("No data available").toString()); +// olMap.showPopup(vpPanel.toString(), onFailureCenterTo); +// return; +// } +// +// // Showing properties belonging to concessioni centroid layer +// Map> entries = feature.getMapProperties(); +// +// String nome = ""; +// String descrizione = ""; +// String date = ""; +// +// for (String key : entries.keySet()) { +// String theValue = entries.get(key).get(0); +// if (key.equalsIgnoreCase("nome")) { +// nome = theValue != null ? theValue : ""; +// } else if (key.equalsIgnoreCase("descrizione")) { +// descrizione = theValue != null ? theValue : ""; +// } else if (key.equalsIgnoreCase("date_scavo")) { +// date = theValue != null ? theValue : ""; +// } +// } +// +// // GeoportalDataViewerConstants.print("0: "+nome); +// flex.setHTML(0, 0, new HTML(nome).toString()); +// try { +// descrizione = StringUtil.ellipsize(descrizione, 100); +// GWT.log("reduced: " + descrizione); +// } catch (Exception e) { +// GWT.log("error: " + e.getMessage()); +// } +// // GeoportalDataViewerConstants.print("1: "+descrizione); +// flex.setText(1, 0, descrizione); +// // GeoportalDataViewerConstants.print("2: "+date); +// date = StringUtil.formatDate(date); +// flex.setHTML(2, 0, new HTML("" + date + "").toString()); +// +// if (geoNaDataObject.getMapImages() != null) { +// for (String key : geoNaDataObject.getMapImages().keySet()) { +// List listUI = geoNaDataObject.getMapImages().get(key); +// GWT.log("Adding images: " + listUI); +// if (listUI != null && listUI.size() > 0) { +// UploadedImageDV img = listUI.get(0); +// if (img!= null && img.getListWsContent() != null) { +// WorkspaceContentDV wsContent = img.getListWsContent().get(img.getListWsContent().size() - 1); +// String theImgHTML = ""; +// GWT.log("theImgHTML: " + theImgHTML); +// // GeoportalDataViewerConstants.print("The row are: +// // "+flex.getRowCount()); +// flex.setHTML(flex.getRowCount() + 1, 0, theImgHTML); +// } +// } +// } +// } +// +// GWT.log("The selected Feature is: " + feature); +// // GeoportalDataViewerConstants.print("The selected Feature is: "+feature); +// FeatureRow theFeature = feature; +// Button button = new Button("Open Details"); +// button.getElement().setId("open-details"); +// button.setType(ButtonType.LINK); +// +// if (button != null) { +// vpPanel.add(button); +// button.setType(ButtonType.LINK); +// button.addClickHandler(new ClickHandler() { +// +// @Override +// public void onClick(ClickEvent event) { +// ShowDetailsEvent toEvent = parseGeonaReferences( +// geoNaDataObject.getSourceLayerObject().getItemType(), theFeature); +// applicationBus.fireEvent(toEvent); +// +// } +// }); +// } +// +// Coordinate centerTo = null; +// GWT.log("geometry is: " + feature.getGeometry()); +// if (feature.getGeometry() != null) { +// GWT.log("trasforming geometry: " + feature.getGeometry().getToJSONObject()); +// +// Geometry geom = new GeoJson().readGeometry(feature.getGeometry().getToJSONObject(), null); +// +// // POINT +// if (geom.getType().equalsIgnoreCase("Point")) { +// GWT.log("geometry: is a point"); +// String coordinateJSON = feature.getGeometry().getCoordinatesJSON(); +// JSONArray centerJSON = (JSONArray) JSONParser.parseStrict(coordinateJSON); +//// Coordinate center = OLFactory.createCoordinate( +//// new Double(centerJSON.get(0).toString()), +//// new Double(centerJSON.get(1).toString())); +// +// Coordinate center = new Coordinate(new Double(centerJSON.get(0).toString()), +// new Double(centerJSON.get(1).toString())); +// +// if (feature.getCrsName() != null && feature.getCrsName().endsWith(MAP_PROJECTION.EPSG_4326.getId())) { +// +// center = MapUtils.transformCoordiante(center, MAP_PROJECTION.EPSG_4326.getName(), +// MAP_PROJECTION.EPSG_3857.getName()); +// } +// centerTo = center; +// } else { +// +// Extent geomExtent = geom.getExtent(); +// +// Coordinate lower = OLFactory.createCoordinate(geomExtent.getLowerLeftX(), geomExtent.getLowerLeftY()); +// Coordinate upper = OLFactory.createCoordinate(geomExtent.getUpperRightX(), geomExtent.getUpperRightY()); +// Coordinate lowerCoord = lower; +// Coordinate upperCoord = upper; +// if (feature.getCrsName() != null && feature.getCrsName().endsWith(MAP_PROJECTION.EPSG_4326.getId())) { +// +// lowerCoord = MapUtils.transformCoordiante(lower, MAP_PROJECTION.EPSG_4326.getName(), +// MAP_PROJECTION.EPSG_3857.getName()); +// upperCoord = MapUtils.transformCoordiante(upper, MAP_PROJECTION.EPSG_4326.getName(), +// MAP_PROJECTION.EPSG_3857.getName()); +// } +// +// ExtentWrapped ew = new ExtentWrapped(lowerCoord.getX(), lowerCoord.getY(), upperCoord.getX(), +// upperCoord.getY()); +// +// centerTo = new Coordinate(ew.getCenter().getX(), ew.getCenter().getY()); +// +// } +// GWT.log("center is: " + centerTo); +// } +// +// // fallback +// if (centerTo == null) +// centerTo = onFailureCenterTo; +// +// olMap.showPopup(vpPanel.toString(), centerTo); +// +// Scheduler.get().scheduleDeferred(new ScheduledCommand() { +// +// @Override +// public void execute() { +// Element buttonElement = DOM.getElementById("open-details"); +// Event.sinkEvents(buttonElement, Event.ONCLICK); +// Event.setEventListener(buttonElement, new EventListener() { +// +// @Override +// public void onBrowserEvent(Event event) { +// if (Event.ONCLICK == event.getTypeInt()) { +// ShowDetailsEvent toEvent = parseGeonaReferences( +// geoNaDataObject.getSourceLayerObject().getItemType(), theFeature); +// applicationBus.fireEvent(toEvent); +// } +// } +// }); +// } +// }); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ViewerStatus.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ViewerStatus.java index 0af002b..64df96c 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ViewerStatus.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ViewerStatus.java @@ -55,7 +55,7 @@ public class ViewerStatus { openedIndexes.get(ucid).add(indexId); } - public void addOpenedProject(String ucid, String projectId, LayerObject projectLayer) { + public void addOpenedProjectLayer(String ucid, String projectId, LayerObject projectLayer) { if(openedProjects==null) openedProjects=new HashMap>>(); if(!openedProjects.containsKey(ucid)) openedProjects.put(ucid, new HashMap>()); Map> map=openedProjects.get(ucid); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/collections/OpenCollectionEvent.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/collections/OpenCollectionEvent.java index ae98b34..addde8d 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/collections/OpenCollectionEvent.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/collections/OpenCollectionEvent.java @@ -11,12 +11,12 @@ public class OpenCollectionEvent extends GwtEvent { @Override public Type getAssociatedType() { - return null; + return TYPE; } @Override protected void dispatch(OpenCollectionEventHandler h) { - + h.onOpenCollection(this); } public OpenCollectionEvent(String collectionId) { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerMap.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerMap.java index 9d8be3b..0b501bb 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerMap.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerMap.java @@ -166,7 +166,7 @@ public class LightOpenLayerMap { map.addInteraction(new KeyboardPan()); map.addInteraction(new KeyboardZoom()); - List listBaseMapLayers = GeoportalDataViewer.getListBaseMapLayers(); + List listBaseMapLayers = GeoportalDataViewer.getStatus().getConfig().getBaseLayers(); BaseMapLayer bml = null; if(listBaseMapLayers!=null) bml = listBaseMapLayers.get(0); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerMap.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerMap.java index 39bf8b2..d7e59fc 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerMap.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerMap.java @@ -59,6 +59,7 @@ import ol.source.ImageWmsParams; import ol.source.Osm; import ol.source.Source; import ol.source.Vector; +import ol.source.WmsServerType; import ol.source.Xyz; import ol.source.XyzOptions; @@ -435,14 +436,7 @@ public abstract class OpenLayerMap { - public void openLayer(LayerItem toOpen) { - - // Check type - switch() { - case INDEX_LAYER - } - - } + @@ -453,6 +447,8 @@ public abstract class OpenLayerMap { */ public synchronized void addWMSDetailLayer(LayerItem layerItem) { + GWT.log("Adding WMS Detail Layer on map "+layerItem); + if (wmsDetailsLayerMap == null) wmsDetailsLayerMap = new LinkedHashMap(); @@ -464,9 +460,14 @@ public abstract class OpenLayerMap { GWT.log("The detail layer with key: " + key + " does not exist, creating and adding it to map"); ImageWmsParams imageWMSParams = OLFactory.createOptions(); imageWMSParams.setLayers(layerItem.getName()); - + + ImageWmsOptions imageWMSOptions = OLFactory.createOptions(); imageWMSOptions.setUrl(layerItem.getMapServerHost()); + + imageWMSOptions.setServerType(WmsServerType.GEOSERVER); + imageWMSOptions.setUrl(layerItem.getWmsLink().substring(0, layerItem.getWmsLink().lastIndexOf("?"))); + imageWMSOptions.setParams(imageWMSParams); // imageWMSOptions.setRatio(1.5f); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/dandd/DragDropLayer.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/dandd/DragDropLayer.java index ebc645d..2f35ca1 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/dandd/DragDropLayer.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/dandd/DragDropLayer.java @@ -60,10 +60,12 @@ public class DragDropLayer extends FlowPanel { this.labelLayerName.setTitle(layerItem.getName()); this.labelLayerName.setType(LabelType.INFO); - BaseConcessioneDV refConcessione = layerObject.getSourceConcessione(); - String nameConcessione = StringUtil.ellipsize(refConcessione.getNome(), 40); + // TODO Manage Collection + +// BaseConcessioneDV refConcessione = layerObject.getSourceConcessione(); + String nameConcessione = StringUtil.ellipsize("TODO : UCD", 40); com.google.gwt.user.client.ui.Label labelConcessione = new com.google.gwt.user.client.ui.Label(nameConcessione); - labelConcessione.setTitle(refConcessione.getNome()); + labelConcessione.setTitle("TODO : PROJECT"); getElement().getStyle().setMarginTop(5, Unit.PX); getElement().getStyle().setMarginBottom(10, Unit.PX); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/MapView.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/MapView.java index 26059cf..3c05377 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/MapView.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/MapView.java @@ -105,7 +105,9 @@ public class MapView extends Composite { } protected void setBaseLayers() { - List listBaseLayers = GeoportalDataViewer.getListBaseMapLayers(); + + // TODO pass layers as parameters? + List listBaseLayers = GeoportalDataViewer.getStatus().getConfig().getBaseLayers(); if(listBaseLayers==null) return; 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 fd829d9..2e7eefd 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 @@ -790,7 +790,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme // ************** LOAD AVAILABLE COLLECTIONS LOG.debug("Loading available collections.. "); - config.setAvailableCollections(new ArrayList()); + config.setAvailableCollections(new HashMap()); // TODO filter by // configured ? @@ -844,7 +844,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme // Return only if gis indexed if(coll.getIndexes().isEmpty()) LOG.info("No available GIS Index for collection "+coll.getUcd().getName()); - else config.getAvailableCollections().add(coll); + else config.getAvailableCollections().put(coll.getUcd().getId(),coll); }catch(Throwable t) { LOG.warn("Invalid UCD, can't translate to DV. UCID : "+u.getId(),t); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/ViewerConfiguration.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/ViewerConfiguration.java index 5cd8c61..83d797b 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/ViewerConfiguration.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/ViewerConfiguration.java @@ -11,10 +11,10 @@ public class ViewerConfiguration implements IsSerializable{ //TODO BaseLayers - public List baseLayers; + private List baseLayers; - public Map availableCollections; + private Map availableCollections; public List getBaseLayers() { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/cl/document/materialization/GCubeSDILayerDV.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/cl/document/materialization/GCubeSDILayerDV.java index 586549a..3650bff 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/cl/document/materialization/GCubeSDILayerDV.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/cl/document/materialization/GCubeSDILayerDV.java @@ -20,6 +20,35 @@ public class GCubeSDILayerDV implements IsSerializable{ private BBOXDV bbox; @JsonProperty(value = "_ogcLinks") private HashMap ogcLinks; + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + public List getPlatformInfos() { + return platformInfos; + } + public void setPlatformInfos(List platformInfos) { + this.platformInfos = platformInfos; + } + public BBOXDV getBbox() { + return bbox; + } + public void setBbox(BBOXDV bbox) { + this.bbox = bbox; + } + public HashMap getOgcLinks() { + return ogcLinks; + } + public void setOgcLinks(HashMap ogcLinks) { + this.ogcLinks = ogcLinks; + } + @Override + public String toString() { + return "GCubeSDILayerDV [type=" + type + ", platformInfos=" + platformInfos + ", bbox=" + bbox + ", ogcLinks=" + + ogcLinks + "]"; + } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/cl/document/materialization/GeoServerPlatformInfoDV.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/cl/document/materialization/GeoServerPlatformInfoDV.java index 6ef466c..3fa5856 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/cl/document/materialization/GeoServerPlatformInfoDV.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/cl/document/materialization/GeoServerPlatformInfoDV.java @@ -11,11 +11,13 @@ public class GeoServerPlatformInfoDV implements IsSerializable{ private String type; private String workspace; private String storeName; + private String layerName; + + @JsonProperty(value = "_host") private String host; - private Map ogcLinks; public String getType() { return type; @@ -49,13 +51,21 @@ public class GeoServerPlatformInfoDV implements IsSerializable{ this.host = host; } - public Map getOgcLinks() { - return ogcLinks; + + public String getLayerName() { + return layerName; + } + + public void setLayerName(String layerName) { + this.layerName = layerName; } - public void setOgcLinks(Map ogcLinks) { - this.ogcLinks = ogcLinks; + @Override + public String toString() { + return "GeoServerPlatformInfoDV [type=" + type + ", workspace=" + workspace + ", storeName=" + storeName + + ", layerName=" + layerName + ", host=" + host + "]"; } + diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/IndexLayer.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/IndexLayer.java index d4de230..93a37d8 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/IndexLayer.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/IndexLayer.java @@ -46,6 +46,11 @@ public class IndexLayer implements IsSerializable{ public void setFlag(String flag) { this.flag = flag; } + @Override + public String toString() { + return "IndexLayer [type=" + type + ", layer=" + layer + ", indexName=" + indexName + ", records=" + records + + ", flag=" + flag + "]"; + } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/LayerItem.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/LayerItem.java index 2b05b81..3c296bc 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/LayerItem.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/LayerItem.java @@ -9,6 +9,7 @@ import java.util.Map; import org.gcube.application.geoportalcommon.shared.gis.BoundsMap; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.LayerType; import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil; +import org.gcube.portlets.user.geoportaldataviewer.shared.cl.document.materialization.GeoServerPlatformInfoDV; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.Property; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.ZAxis; @@ -969,6 +970,33 @@ public class LayerItem implements Serializable, Cloneable { } + public static LayerItem fromIndex(IndexLayer layer) { + + // Assuming only GS platform + GeoServerPlatformInfoDV gsInfo = layer.getLayer().getPlatformInfos().get(0); + + + GWT.log("PlatformInfo is "+gsInfo); + + return new LayerItem(LayerType.FEATURE_TYPE, + layer.getIndexName(), + gsInfo.getWorkspace()+":"+gsInfo.getLayerName(), + layer.getLayer().getOgcLinks().get("wms"), // ?? + gsInfo.getHost(), + false, + false, + true, + null, + layer.getLayer().getOgcLinks().get("wms"), + true, + null, + false, + null, + null, // TODO ZAXIS + null, // NO restrictions on resolution + null); + } + /** * To layer item. * @@ -992,30 +1020,28 @@ public class LayerItem implements Serializable, Cloneable { * @return the layer item */ - - // TODO Constructor from IndexLayer, GCUBESDILAeryDV or direct info - private LayerItem toLayerItem(LayerType layerType, String layerTitle, String layerName, String layerURL, + private LayerItem(LayerType layerType, String layerTitle, String layerName, String layerURL, String mapServerHost, boolean isExternal, boolean isBase, boolean displayInLayerSwitcher, ArrayList styles, String wmsLink, boolean onTop, HashMap wmsNotStandardParams, boolean isNcWms, String UUID, ZAxis zAxis, Double minResolution, Double maxResolution) { // GWT.log("Add addLayerByWms 1"); - LayerItem layerItem = new LayerItem(); - layerItem.setBaseLayer(isBase); - layerItem.setTitle(layerTitle); - layerItem.setName(layerName); - layerItem.setUrl(layerURL); - layerItem.setMapServerHost(mapServerHost); + + this.setBaseLayer(isBase); + this.setTitle(layerTitle); + this.setName(layerName); + this.setUrl(layerURL); + this.setMapServerHost(mapServerHost); // l.setExternal(isExternal); - layerItem.setOpacity(1d); - layerItem.setBuffer(2); - layerItem.setWmsLink(wmsLink); - layerItem.setWmsNotStandardParams(wmsNotStandardParams); - layerItem.setNcWms(isNcWms); - layerItem.setUUID(UUID); - layerItem.setZAxis(zAxis); - layerItem.setMinResolution(minResolution); - layerItem.setMaxResolution(maxResolution); + this.setOpacity(1d); + this.setBuffer(2); + this.setWmsLink(wmsLink); + this.setWmsNotStandardParams(wmsNotStandardParams); + this.setNcWms(isNcWms); + this.setUUID(UUID); + this.setZAxis(zAxis); + this.setMinResolution(minResolution); + this.setMaxResolution(maxResolution); switch (layerType) { @@ -1023,17 +1049,17 @@ public class LayerItem implements Serializable, Cloneable { case RASTER_BASELAYER: // l.setHasLegend(false); - layerItem.setBaseLayer(true); - layerItem.setTrasparent(false); - layerItem.setClickData(false); + this.setBaseLayer(true); + this.setTrasparent(false); + this.setClickData(false); break; case FEATURE_TYPE: // CASE FEATURE TYPE - layerItem.setBaseLayer(false); - layerItem.setClickData(true); - layerItem.setTrasparent(true); + this.setBaseLayer(false); + this.setClickData(true); + this.setTrasparent(true); break; } @@ -1041,19 +1067,21 @@ public class LayerItem implements Serializable, Cloneable { GWT.log("styles " + styles); if (styles != null && styles.size() > 0) { - layerItem.setHasLegend(true); - layerItem.setDefaultStyle(styles.get(0)); - layerItem.setStyle(styles.get(0)); - layerItem.setStyles(styles); + this.setHasLegend(true); + this.setDefaultStyle(styles.get(0)); + this.setStyle(styles.get(0)); + this.setStyles(styles); } else { String style = URLUtil.getValueOfParameter("styles", wmsLink); if (style != null) { // CASE OF STYLE =""; // TENTATIVE TO GET LEGEND - layerItem.setHasLegend(true); + this.setHasLegend(true); } } - GWT.log("Built layer: " + layerItem); - return layerItem; + GWT.log("Built layer: " + this); } + + + } diff --git a/src/test/java/org/gcube/portlets/user/geoportaldataviewer/ModelConversionTests.java b/src/test/java/org/gcube/portlets/user/geoportaldataviewer/ModelConversionTests.java index aa79b3e..6546c4d 100644 --- a/src/test/java/org/gcube/portlets/user/geoportaldataviewer/ModelConversionTests.java +++ b/src/test/java/org/gcube/portlets/user/geoportaldataviewer/ModelConversionTests.java @@ -1,27 +1,21 @@ package org.gcube.portlets.user.geoportaldataviewer; -import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin.useCaseDescriptors; - -import org.gcube.application.geoportal.client.utils.Serialization; -import org.gcube.application.geoportal.common.model.rest.QueryRequest; -import org.gcube.application.geoportal.common.rest.UseCaseDescriptorsI; -import org.gcube.portlets.user.geoportaldataviewer.shared.cl.ucd.UCD; import org.junit.Test; public class ModelConversionTests { @Test public void testGetUCD() throws Exception { - TokenSetter.set("/gcube/devsec/devVRE"); - UseCaseDescriptorsI client = useCaseDescriptors().build(); - client.query(new QueryRequest()).forEachRemaining(u->{ - - System.out.println(u.getName()); - - UCD ucd = Serialization.convert(u, UCD.class); - System.out.println(ucd.getName()); - - }); +// TokenSetter.set("/gcube/devsec/devVRE"); +// UseCaseDescriptorsI client = useCaseDescriptors().build(); +// client.query(new QueryRequest()).forEachRemaining(u->{ +// +// System.out.println(u.getName()); +// +// UCD ucd = Serialization.convert(u, UCD.class); +// System.out.println(ucd.getName()); +// +// }); }