From 18d3548c09c28184e622b5aba8acedbd61d2e76b Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 19 Oct 2022 17:51:13 +0200 Subject: [PATCH] in progress --- .../client/GeoportalDataViewer.java | 2 +- .../client/LayerManager.java | 318 +++++++++--------- .../client/events/QueryDataEvent.java | 21 +- .../events/ShowPopupOnCentroiEvent.java | 24 +- .../client/ui/GeonaDataViewMainPanel.java | 3 +- .../GeoportalDataViewerServiceImpl.java | 176 +++++++--- .../server/Geoportal_JSON_Mapper.java | 84 ++++- .../shared/GeoNaSpatialQueryResult.java | 32 +- .../shared/gis/LayerObject.java | 80 ++--- .../GeoportalViewer_Tests.java | 38 ++- 10 files changed, 466 insertions(+), 312 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 41b9579..e6846eb 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 @@ -311,7 +311,7 @@ public class GeoportalDataViewer implements EntryPoint { IndexLayerDV layer = toOpen.getIndexes().get(0); // Open Index Layer - layerManager.addIndexLayer(layer); + layerManager.addIndexLayer(layer, toOpen.getUcd().getProfileID()); } } }); 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 4dd5499..48b9eaa 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 @@ -8,12 +8,12 @@ import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Set; import org.gcube.application.geoportalcommon.shared.geoportal.materialization.GCubeSDIViewerLayerDV; import org.gcube.application.geoportalcommon.shared.geoportal.materialization.IndexLayerDV; +import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.PayloadDV; import org.gcube.application.geoportalcommon.shared.gis.BoundsMap; -import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceContentDV; -import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.LayerType; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MapEventType; @@ -80,16 +80,12 @@ public class LayerManager { /** The ol map. */ private OpenLayerMap olMap; - private Map mapDetailLayerObjects = new HashMap(); - private Map mapBaseLayerObjects = new HashMap(); + private Map mapOtherLayerObjects = new HashMap(); private Map mapIndexLayerObjects = new HashMap(); - private HandlerManager layerManagerBus = new HandlerManager(""); private HandlerManager applicationBus; - private org.gcube.application.geoportalcommon.shared.LayerItem baseLayerFromISProfile; - private OverlayLayerManager overlayLayerManager; /** @@ -117,7 +113,7 @@ public class LayerManager { if (queryEvent.getGeoQuery() != null) { GeoQuery selectDataInfo = queryEvent.getGeoQuery(); - String mongoItemId = queryEvent.getMongoItemId(); + final String productID = queryEvent.getProductID(); GWT.log("(" + selectDataInfo.getX1() + "," + selectDataInfo.getY1() + ")(" + selectDataInfo.getX2() + "," + selectDataInfo.getY2() + ")"); @@ -149,11 +145,11 @@ public class LayerManager { List listLO = new ArrayList(); // for querying base layers - listLO.addAll(mapBaseLayerObjects.values()); + listLO.addAll(mapIndexLayerObjects.values()); // for querying detail layers only in this case if (olMap.getCurrentResolution() < OLMapManager.LAYER_DETAIL_MAX_RESOLUTION) { - Collection collLO = mapDetailLayerObjects.values(); + Collection collLO = mapOtherLayerObjects.values(); listLO.addAll(collLO); ArrayList layerVisibility = new ArrayList(collLO.size()); @@ -221,7 +217,7 @@ public class LayerManager { if (features != null && features.size() > 0) { String theProductId = null; for (FeatureRow fRow : features) { - List productIdLst = fRow.getMapProperties().get("product_id"); + List productIdLst = fRow.getMapProperties().get("projectid"); if (productIdLst != null) { theProductId = productIdLst.get(0); if (theProductId != null) { @@ -245,11 +241,11 @@ public class LayerManager { if (features != null && features.size() > 0) { // I need to show exactly the feature with produc_id == recordId - if (mongoItemId != null) { - GWT.log("MongoItemId is not null: " + mongoItemId); + if (productID != null) { + GWT.log("productID is not null: " + productID); // Searching mongoItemId in the list of product - theFeatures = listUniqueProducts.get(mongoItemId); - GWT.log("Loaded mongoItemId == product_id with id: " + mongoItemId + theFeatures = listUniqueProducts.get(productID); + GWT.log("Loaded productid == product_id with id: " + productID + ", the features are: " + theFeatures); // the recordId/mongoItemId to show has been passed but not found into @@ -261,8 +257,8 @@ public class LayerManager { } // If mongoItemId not passed - if (mongoItemId == null) { - GWT.log("MongoItemId is null"); + if (productID == null) { + GWT.log("productID is null"); // Checking if the features returned belonging to detail layers (not // centroids). if (listUniqueProducts.isEmpty()) { @@ -314,7 +310,8 @@ public class LayerManager { // is > // QUERY_MIN_ZOOM_LEVEL - final String theProfileID = "?????"; + final String theProfileID = geoNaDataObject.getSourceLayerObject() + .getProfileID(); GeoportalDataViewerServiceAsync.Util.getInstance().getLayersForId( theProfileID, theProductID, @@ -412,7 +409,7 @@ public class LayerManager { * Removes the all detail layers. */ public void removeAllDetailLayers() { - mapDetailLayerObjects.clear(); + mapOtherLayerObjects.clear(); olMap.removeAllDetailLayers(); overlayLayerManager.resetLayers(); } @@ -428,7 +425,7 @@ public class LayerManager { if (fRow == null) return null; - List productIds = fRow.getMapProperties().get("product_id"); + List productIds = fRow.getMapProperties().get("projectid"); if (productIds != null && productIds.size() > 0) { String productId = productIds.get(0); String itemName = "Dettagli Prodotto"; @@ -438,8 +435,8 @@ public class LayerManager { } LayerObjectType layerObjectType = layerObject.getType(); - return new ShowDetailsEvent(layerObjectType != null ? layerObjectType.name() : null, layerObject.getUcid(), - productId, itemName, fRow); + return new ShowDetailsEvent(layerObjectType != null ? layerObjectType.name() : null, + layerObject.getProfileID(), productId, itemName, fRow); } return null; @@ -490,18 +487,10 @@ public class LayerManager { */ 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, String profileID, - String projectID) { - -// final LayoutContainer westPanel = (LayoutContainer) layersPanel.getParent(); -// -// if(layersPanel.getLayerItems().size()==0) -// westPanel.mask("Adding..."+layerName, "x-mask-loading"); -// else -// layersPanel.mask("Adding..."+layerName, "x-mask-loading"); + final boolean asDetailLayer, Double minResolution, Double maxResolution, final String profileID, + final String projectID) { final LayerType featureType = isBase ? LayerType.RASTER_BASELAYER : LayerType.FEATURE_TYPE; -// Info.display("Adding Layer", layerName); if (wmsLink == null || wmsLink.isEmpty()) { GeoportalDataViewerConstants.printJs("Skipping add layer for wmsLink as null or empty"); @@ -536,37 +525,61 @@ public class LayerManager { LayerObject lo = new LayerObject(); lo.setLayerItem(layerItem); lo.setType(lot); - lo.setProjectId(projectID); + lo.setProjectID(projectID); + lo.setProfileID(profileID); - switch (lot) { + String layerNameKey = layerItem.getName(); + + LayerObject theLo; + switch (lo.getType()) { case INDEX_LAYER: - + theLo = mapIndexLayerObjects.get(layerNameKey); + if (theLo == null) { + theLo = lo; + mapIndexLayerObjects.put(layerNameKey, theLo); + GWT.log("mapIndexLayerObjects is: " + mapIndexLayerObjects); + olMap.addWMSLayer(layerItem); + } else { + GWT.log("Skipping " + lo.getType() + " layer " + theLo.getLayerItem().getName() + + " already added to Map"); + } break; case PROJECT_LAYER: + theLo = mapOtherLayerObjects.get(layerNameKey); + if (theLo == null) { + theLo = lo; + mapOtherLayerObjects.put(layerNameKey, theLo); + GWT.log("mapOtherLayerObjects is: " + mapIndexLayerObjects); + olMap.addWMSDetailLayer(layerItem); + } else { + GWT.log("Skipping " + lo.getType() + " layer " + theLo.getLayerItem().getName() + + " already added to Map"); + } + break; default: break; } - String key = layerItem.getName(); // should be unique // - // layerObjects.put(key, lo); - - if (!asDetailLayer) { // is a base layer LayerObject blo = - LayerObject blo = mapBaseLayerObjects.get(key); - if (blo == null) { - olMap.addWMSLayer(layerItem); - mapBaseLayerObjects.put(key, lo); - } else { - GWT.log("Skipping base layer " + key + " already added to Map"); - } - } else { - LayerObject dlo = mapDetailLayerObjects.get(key); - if (dlo == null) { - mapDetailLayerObjects.put(key, lo); - olMap.addWMSDetailLayer(layerItem); - overlayLayerManager.addLayerItem(lo); // overlayLayerManager.show(); } else { - GWT.log("Skipping detail layer " + key + " already added to Map"); - } - } +// String key = layerItem.getName(); // should be unique // +// // layerObjects.put(key, lo); +// +// if (!asDetailLayer) { // is a base layer LayerObject blo = +// LayerObject blo = mapIndexLayerObjects.get(key); +// if (blo == null) { +// olMap.addWMSLayer(layerItem); +// mapIndexLayerObjects.put(key, lo); +// } else { +// GWT.log("Skipping base layer " + key + " already added to Map"); +// } +// } else { +// LayerObject dlo = mapOtherLayerObjects.get(key); +// if (dlo == null) { +// mapOtherLayerObjects.put(key, lo); +// olMap.addWMSDetailLayer(layerItem); +// overlayLayerManager.addLayerItem(lo); // overlayLayerManager.show(); } else { +// GWT.log("Skipping detail layer " + key + " already added to Map"); +// } +// } } }); @@ -577,10 +590,12 @@ public class LayerManager { * * @param layer the layer */ - public void addIndexLayer(IndexLayerDV layer) { - - addLayer(LayerObjectType.INDEX_LAYER, null, null, layer.getLayer().getOgcLinks().get("wms"), false, false, null, - false, null, null, null, null); + public void addIndexLayer(IndexLayerDV layer, String profileID) { + 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); } @@ -675,7 +690,8 @@ public class LayerManager { * @param queryClick the query click */ public void showPopupInfoForLayer(List listGeoNaDataObject, ExtentWrapped queryClick) { - + GWT.log("showPopupInfoForLayer called for "+listGeoNaDataObject); + ScrollPanel scrollPanel = new ScrollPanel(); final FlowPanel flowPanel = new FlowPanel(); flowPanel.getElement().getStyle().setProperty("maxHeight", "600px"); @@ -726,7 +742,8 @@ public class LayerManager { String prevConcessioneName = ""; for (GeoNaSpatialQueryResult geoNaSpatialQueryResult : listGeoNaDataObject) { try { - GWT.log("baseLayerFromISProfile.getName() :" + baseLayerFromISProfile.getName()); + + Set indexLayers = mapIndexLayerObjects.keySet(); LayerObject lo = geoNaSpatialQueryResult.getSourceLayerObject(); LayerItem sourceLI = lo.getLayerItem(); @@ -734,7 +751,7 @@ public class LayerManager { // skipping centroid layer if (layerSourceName == null - || layerSourceName.compareToIgnoreCase(baseLayerFromISProfile.getName()) == 0) { + || indexLayers.contains(layerSourceName)) { continue; } @@ -745,80 +762,80 @@ public class LayerManager { } GWT.log("showPopupInfoForLayer must be REVISITED"); - /* - * 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); - * - */ +// +// 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); +// + } catch (Exception e) { GeoportalDataViewerConstants.printJs("Error: " + e.getMessage()); @@ -839,6 +856,8 @@ public class LayerManager { public void showPopupInfoForCentroidLayer(GeoNaSpatialQueryResult geoNaDataObject, FeatureRow feature, Coordinate onFailureCenterTo) { + GWT.log("showPopupInfoForCentroidLayer must be revisited"); + FlexTable flex = new FlexTable(); flex.setCellPadding(1); flex.setCellSpacing(1); @@ -886,13 +905,12 @@ public class LayerManager { if (geoNaDataObject.getMapImages() != null) { for (String key : geoNaDataObject.getMapImages().keySet()) { - List listUI = geoNaDataObject.getMapImages().get(key); + 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 = ""; + PayloadDV img = listUI.get(0); + if (img != null && img.getLink() != null) { + String theImgHTML = ""; GWT.log("theImgHTML: " + theImgHTML); // GeoportalDataViewerConstants.print("The row are: // "+flex.getRowCount()); @@ -1020,24 +1038,6 @@ public class LayerManager { return layerManagerBus; } - /** - * Sets the base layer from is profile. - * - * @param layerItem the new base layer from is profile - */ - public void setBaseLayerFromIsProfile(org.gcube.application.geoportalcommon.shared.LayerItem layerItem) { - this.baseLayerFromISProfile = layerItem; - } - - /** - * Gets the base layer from IS proile. - * - * @return the base layer from IS proile - */ - public org.gcube.application.geoportalcommon.shared.LayerItem getBaseLayerFromISProile() { - return baseLayerFromISProfile; - } - /** * Gets the overlay layer manager. * diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/QueryDataEvent.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/QueryDataEvent.java index fdfca9b..ca7f8aa 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/QueryDataEvent.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/QueryDataEvent.java @@ -17,7 +17,7 @@ public class QueryDataEvent extends GwtEvent { public static Type TYPE = new Type(); private GeoQuery select; private ExtentWrapped queryClickExtent; - private String mongoItemId; + private String productID; private boolean onInit; private MapEventType sourceMapEventType; @@ -26,15 +26,15 @@ public class QueryDataEvent extends GwtEvent { * * @param select the select * @param onFailureCenterTo the on failure center to - * @param mongoItemId the mongo item id + * @param productID the mongo item id * @param onInit the on init * @param mapEventType the map event type */ - public QueryDataEvent(GeoQuery select, ExtentWrapped queryClickExtent, String mongoItemId, boolean onInit, + public QueryDataEvent(GeoQuery select, ExtentWrapped queryClickExtent, String productID, boolean onInit, MapEventType mapEventType) { this.select = select; this.queryClickExtent = queryClickExtent; - this.mongoItemId = mongoItemId; + this.productID = productID; this.onInit = onInit; this.sourceMapEventType = mapEventType; } @@ -49,13 +49,8 @@ public class QueryDataEvent extends GwtEvent { return TYPE; } - /** - * Gets the mongo item id. - * - * @return the mongo item id - */ - public String getMongoItemId() { - return mongoItemId; + public String getProductID() { + return productID; } /** @@ -107,8 +102,8 @@ public class QueryDataEvent extends GwtEvent { builder.append(select); builder.append(", queryClickExtent="); builder.append(queryClickExtent); - builder.append(", mongoItemId="); - builder.append(mongoItemId); + builder.append(", productID="); + builder.append(productID); builder.append(", onInit="); builder.append(onInit); builder.append(", sourceMapEventType="); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/ShowPopupOnCentroiEvent.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/ShowPopupOnCentroiEvent.java index 07c07af..01ed6b5 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/ShowPopupOnCentroiEvent.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/ShowPopupOnCentroiEvent.java @@ -17,18 +17,18 @@ public class ShowPopupOnCentroiEvent extends GwtEvent0) { CheckBox checkbox = (CheckBox) openCollectionPanel.getWidget(0); checkbox.setValue(true, true); String collectionID = checkbox.getId().replace("gcubeCollectionSelector_", ""); 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 74ed4dd..0f2fc2f 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 @@ -40,6 +40,7 @@ import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV; import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV; import org.gcube.application.geoportalcommon.shared.geoportal.materialization.GCubeSDIViewerLayerDV; import org.gcube.application.geoportalcommon.shared.geoportal.materialization.IndexLayerDV; +import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.PayloadDV; import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV; import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_DATA_HANDLER; import org.gcube.application.geoportalcommon.shared.geoportal.ucd.HandlerDeclarationDV; @@ -230,59 +231,6 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme } } - /** - * Gets the data result. - * - * @param layerObjects the layer objects - * @param mapSrsName the map srs name - * @param selectBBOX the select BBOX - * @param maxWFSFeature the max WFS feature - * @param zoomLevel the zoom level - * @return the data result - */ - @Override - public List getDataResult(List layerObjects, String mapSrsName, - BoundsMap selectBBOX, int maxWFSFeature, double zoomLevel) { - LOG.info("getDataResult called"); - - List listDAO = new ArrayList(layerObjects.size()); - - for (LayerObject layerObject : layerObjects) { - GeoNaSpatialQueryResult geoDAO = new GeoNaSpatialQueryResult(); - List features = FeatureParser.getWFSFeatures(layerObject.getLayerItem(), mapSrsName, selectBBOX, - maxWFSFeature); - LOG.debug("For layer name: " + layerObject.getLayerItem().getName() + " got features: " + features); - geoDAO.setFeatures(features); - - // Getting the concessioneId from WFS features - for (FeatureRow fRow : features) { - if (fRow.getMapProperties() != null) { - List concessioneIds = fRow.getMapProperties().get("product_id"); - if (concessioneIds != null && concessioneIds.size() > 0) { - String cId = concessioneIds.get(0); - try { - UploadedImageDV uplImg = sessionloadPreviewImageForConcessione(this.getThreadLocalRequest(), - "Concessione", cId); - // List listUI = getUploadedImagesForId("Concessione", cId, 1); - Map> mapImages = new LinkedHashMap>(); - mapImages.put(cId, Arrays.asList(uplImg)); - // mapImages.put(cId, listUI); - geoDAO.setMapImages(mapImages); - } catch (Exception e) { - LOG.warn("Error on loading uploaded images for concessione: " + cId, e); - } - } - } - } - 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; - } - /** * Gets the uploaded images for id. * @@ -1029,10 +977,11 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme String jsonDocument = theProject.getTheDocument().toJson(); LOG.trace("JSON Project is: " + jsonDocument); - String materializationJSONPath = String.format("%s.%s.%s", Geoportal_JSON_Mapper.JSON_$_POINTER, - Geoportal_JSON_Mapper.FILESET, Geoportal_JSON_Mapper._MATERIALIZATIONS); + String materializationParentJSONPath = String.format("%s..%s", Geoportal_JSON_Mapper.JSON_$_POINTER, + Geoportal_JSON_Mapper.FILESET); - listLayers = Geoportal_JSON_Mapper.readGcubeSDILayersForFileset(materializationJSONPath, jsonDocument); + listLayers = Geoportal_JSON_Mapper.readGcubeSDILayersForFileset(materializationParentJSONPath, + jsonDocument); LOG.info("For projectID " + projectID + ", returning " + listLayers.size() + " layer/s"); return listLayers; @@ -1045,6 +994,48 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme } + protected List getImagesForId(String profileID, String projectID) throws Exception { + LOG.info("getImagesForId [profileID: " + profileID + ", projectID: " + projectID + "] called"); + + if (profileID == null) + throw new Exception("Invalid parameter. The profileID is null"); + + if (projectID == null) + throw new Exception("Invalid parameter. The projectID is null"); + + List listImages = null; + + try { + + SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); + try { + SessionUtil.getCurrentUser(this.getThreadLocalRequest()).getUsername(); + } catch (Exception e) { + LOG.info("User not found in session, the userName for cecking policy will be null"); + } + + LOG.info("Trying to get project for id " + profileID); + + new GeoportalServiceIdentityProxy(this.getThreadLocalRequest()); + 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); + + listImages = Geoportal_JSON_Mapper.readImagesForFileset(filesetJSONPath, jsonDocument); + + LOG.info("For projectID " + projectID + ", returning " + listImages.size() + " image/s"); + return listImages; + + } catch (Exception e) { + String erroMsg = "Images are not available for profileID " + profileID + " with projectID " + projectID; + LOG.error(erroMsg, e); + throw new Exception(erroMsg); + } + + } + /** * Gets the project view for id. * @@ -1097,4 +1088,77 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme } + /** + * Gets the data result. + * + * @param layerObjects the layer objects + * @param mapSrsName the map srs name + * @param selectBBOX the select BBOX + * @param maxWFSFeature the max WFS feature + * @param zoomLevel the zoom level + * @return the data result + */ + @Override + public List getDataResult(List layerObjects, String mapSrsName, + BoundsMap selectBBOX, int maxWFSFeature, double zoomLevel) { + LOG.info("getDataResult called for layerObjects: " + layerObjects); + if (LOG.isDebugEnabled()) { + LOG.info("getDataResult parmeters layerObjects: " + layerObjects, + ", mapSrsName: " + mapSrsName + ", selectBBOX: " + selectBBOX + ", maxWFSFeature: " + maxWFSFeature + + ", zoomLevel: " + zoomLevel); + } + + List listDAO = new ArrayList(layerObjects.size()); + + for (LayerObject layerObject : layerObjects) { + GeoNaSpatialQueryResult geoDAO = new GeoNaSpatialQueryResult(); + List features = FeatureParser.getWFSFeatures(layerObject.getLayerItem(), mapSrsName, selectBBOX, + maxWFSFeature); + 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); + + List 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 project: " + projectID, e); + } + } + } + } + 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/server/Geoportal_JSON_Mapper.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/Geoportal_JSON_Mapper.java index 70b85a1..b9ed375 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/Geoportal_JSON_Mapper.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/Geoportal_JSON_Mapper.java @@ -47,7 +47,7 @@ public class Geoportal_JSON_Mapper { public static final String FILESET = "fileset"; - public static final String _OGC_LINKS_WMS = "_ogcLinks.wms"; + public static final String _OGC_LINKS = "_ogcLinks"; public static final String _BBOX = "_bbox"; @@ -306,6 +306,40 @@ public class Geoportal_JSON_Mapper { } + /** + * Read images for fileset. + * + * @param parentJSONPath the parent JSON path + * @param sectionJSONDocument the section JSON document + * @return the list + */ + public static List readImagesForFileset(String parentJSONPath, String sectionJSONDocument) { + LOG.debug("readImagesForFileset called"); + + List listImages = new ArrayList(); + com.jayway.jsonpath.Configuration config = com.jayway.jsonpath.Configuration.builder() + .jsonProvider(new JsonOrgJsonProvider()).build(); + // Reading Fileset _payloads + String filesetJSONPath = String.format("%s.%s", parentJSONPath, _PAYLOADS); + LOG.info("Reading sectionPath {} into section document {}", filesetJSONPath, sectionJSONDocument); + JsonPath theSectionPolycJsonPath = JsonPath.compile(filesetJSONPath); + Object _filesets = theSectionPolycJsonPath.read(sectionJSONDocument, config); + + List payloads = new ArrayList(); + List listPayloads = recursiveFetchingPayloads(config, _filesets, payloads); + for (Payload payload : listPayloads) { + boolean isImage = ImageDetector.isImage(payload.getMimetype()); + if (isImage) { + PayloadDV payloadDV = ConvertToDataValueObjectModel.toPayloadDV(payload); + listImages.add(payloadDV); + } + } + + LOG.debug("readImagesForFileset returning listOfImages: "+listImages); + return listImages; + + } + public static List readGcubeSDILayersForFileset(String materializationParentJSONPath, String sectionJSONDocument) { LOG.debug("readGcubeSDILayersForFileset called"); @@ -357,6 +391,45 @@ public class Geoportal_JSON_Mapper { return listSDILayers; } + /** + * Read payloads for fileset. + * + * @param filesetJSONPath the fileset JSON path + * @param sectionJSONDocument the section JSON document + * @return the list + */ + public static List recursiveFetchingPayloads(com.jayway.jsonpath.Configuration config, Object objectJSON, + List payloads) { + LOG.debug("recursiveFetchingPayloads called"); + + if (objectJSON == null) + return payloads; + + if (objectJSON instanceof JSONArray) { + JSONArray theJsonArray = (JSONArray) objectJSON; + LOG.trace("jsonArray: " + theJsonArray.toString(3)); + + for (int i = 0; i < theJsonArray.length(); i++) { + recursiveFetchingPayloads(config, theJsonArray.get(i), payloads); + } + } else if (objectJSON instanceof JSONObject) { + JSONObject toStringPayloads = (JSONObject) objectJSON; + LOG.trace("The _payloads is a String {}", toStringPayloads.toString(3)); + Payload payload; + try { + 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()); + } + + } + + return payloads; + + } + // TODO THIS PART SHOULD BE REVISITED/OPTIMIZED private static GCubeSDIViewerLayerDV converLayer(com.jayway.jsonpath.Configuration config, JSONObject thJsonObject) { @@ -381,19 +454,19 @@ public class Geoportal_JSON_Mapper { LOG.warn(jsonPath + " error: ", e); } try { - jsonPath = String.format("%s.%s", JSON_$_POINTER, _OGC_LINKS_WMS); + jsonPath = String.format("%s.%s", JSON_$_POINTER, _OGC_LINKS); String jsonString = JsonPath.using(config).parse(toSerializeJSONOBJ).read(jsonPath).toString(); Gson gson = new Gson(); HashMap map = gson.fromJson(jsonString, HashMap.class); gsdiLayer.setOgcLinks(map); - LOG.debug(_OGC_LINKS_WMS + " are: " + map); + LOG.debug(_OGC_LINKS + " are: " + map); } catch (Exception e) { LOG.warn(jsonPath + " error: ", e); } - + try { String wmsLink = gsdiLayer.getWMSLink(); - if(wmsLink!=null) { + if (wmsLink != null) { String layerName = URLParserUtil.extractValueOfParameterFromURL("layers", wmsLink); gsdiLayer.setLayerName(layerName); } @@ -401,7 +474,6 @@ public class Geoportal_JSON_Mapper { LOG.warn(jsonPath + " error: ", e); } - LOG.debug("converLayer returning: " + gsdiLayer); return gsdiLayer; } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/GeoNaSpatialQueryResult.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/GeoNaSpatialQueryResult.java index d6a315b..211c8c9 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/GeoNaSpatialQueryResult.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/GeoNaSpatialQueryResult.java @@ -4,17 +4,17 @@ import java.io.Serializable; import java.util.List; import java.util.Map; -import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV; +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; - /** * The Class GeoNaSpatialQueryResult. * * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * - * Jul 30, 2021 + * Jul 30, 2021 */ public class GeoNaSpatialQueryResult implements Serializable { @@ -24,8 +24,10 @@ public class GeoNaSpatialQueryResult implements Serializable { private static final long serialVersionUID = 3513120677727206958L; private List features; private LayerObject sourceLayerObject; - // Map with couple (mongoId concessione, list of uploaded GNAImages for the concessione) - private Map> mapImages = null; + // Map with couple (mongoId concessione, list of uploaded GNAImages for the + // concessione) + private Map> mapImages = null; + private ProjectDV projectDV; /** * Instantiates a new geo na data object. @@ -34,6 +36,15 @@ public class GeoNaSpatialQueryResult implements Serializable { } + public void setProjectDV(ProjectDV projectDV) { + this.projectDV = projectDV; + + } + + public ProjectDV getProjectDV() { + return projectDV; + } + /** * Gets the features. * @@ -75,7 +86,7 @@ public class GeoNaSpatialQueryResult implements Serializable { * * @return the map images */ - public Map> getMapImages() { + public Map> getMapImages() { return mapImages; } @@ -84,15 +95,10 @@ public class GeoNaSpatialQueryResult implements Serializable { * * @param mapImages the map images */ - public void setMapImages(Map> mapImages) { + public void setMapImages(Map> mapImages) { this.mapImages = mapImages; } - /** - * To string. - * - * @return the string - */ @Override public String toString() { StringBuilder builder = new StringBuilder(); @@ -102,6 +108,8 @@ 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(); } 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 e270cf3..9c9c226 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 @@ -5,10 +5,9 @@ import java.io.Serializable; import org.gcube.application.geoportalcommon.shared.geoportal.materialization.GCubeSDILayer; import org.gcube.application.geoportalcommon.shared.geoportal.materialization.IndexLayerDV; - /** - * Represents a layer, - * holds the layer item and the related Collection info if existing + * Represents a layer, holds the layer item and the related Collection info if + * existing * * */ @@ -18,14 +17,13 @@ public class LayerObject implements Serializable { * */ private static final long serialVersionUID = -2282478701630148774L; - - + private LayerObjectType type; - - private IndexLayerDV indexLayer; // expected for INDEX_LAYER type - private String ucid; // expected for collection layers - private GCubeSDILayer projectLayer; // expected for PROJECT_LAYER - private String projectId; // expected for PROJECT_LAYER + + private IndexLayerDV indexLayer; // expected for INDEX_LAYER type + private String profileID; // expected for collection layers + private GCubeSDILayer projectLayer; // expected for PROJECT_LAYER + private String projectID; // expected for PROJECT_LAYER private LayerItem layerItem; @@ -33,81 +31,68 @@ public class LayerObject implements Serializable { super(); } - public LayerObject(LayerObjectType type,LayerItem item) { + public LayerObject(LayerObjectType type, LayerItem item) { this.setType(type); this.setLayerItem(item); } - - - public LayerObject(String ucid, IndexLayerDV indexLayer, LayerItem item) { - this(LayerObjectType.INDEX_LAYER,item); - this.ucid=ucid; - this.indexLayer=indexLayer; + + public LayerObject(String profileID, IndexLayerDV indexLayer, LayerItem item) { + this(LayerObjectType.INDEX_LAYER, item); + this.profileID = profileID; + this.indexLayer = indexLayer; } - - public LayerObject(String ucid, String projectId, GCubeSDILayer projectLayer, LayerItem item) { - this(LayerObjectType.PROJECT_LAYER,item); - this.ucid=ucid; - this.projectId=projectId; + + 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; } - public void setType(LayerObjectType type) { this.type = type; } - public IndexLayerDV getIndexLayer() { return indexLayer; } - public void setIndexLayer(IndexLayerDV indexLayer) { this.indexLayer = indexLayer; } - - public String getUcid() { - return ucid; + public String getProfileID() { + return profileID; } - - public void setUcid(String ucid) { - this.ucid = ucid; + public void setProfileID(String profileID) { + this.profileID = profileID; } - public GCubeSDILayer getProjectLayer() { return projectLayer; } - public void setProjectLayer(GCubeSDILayer projectLayer) { this.projectLayer = projectLayer; } - - public String getProjectId() { - return projectId; + public String getProjectID() { + return projectID; } - - public void setProjectId(String projectId) { - this.projectId = projectId; + public void setProjectID(String projectId) { + this.projectID = projectId; } - public LayerItem getLayerItem() { return layerItem; } - public void setLayerItem(LayerItem layerItem) { this.layerItem = layerItem; } @@ -119,17 +104,16 @@ public class LayerObject implements Serializable { builder.append(type); builder.append(", indexLayer="); builder.append(indexLayer); - builder.append(", ucid="); - builder.append(ucid); + builder.append(", profileID="); + builder.append(profileID); builder.append(", projectLayer="); builder.append(projectLayer); - builder.append(", projectId="); - builder.append(projectId); + builder.append(", projectID="); + builder.append(projectID); builder.append(", layerItem="); builder.append(layerItem); builder.append("]"); return builder.toString(); } - - + } \ No newline at end of file diff --git a/src/test/java/org/gcube/portlets/user/geoportaldataviewer/GeoportalViewer_Tests.java b/src/test/java/org/gcube/portlets/user/geoportaldataviewer/GeoportalViewer_Tests.java index e97396e..ca3e6e6 100644 --- a/src/test/java/org/gcube/portlets/user/geoportaldataviewer/GeoportalViewer_Tests.java +++ b/src/test/java/org/gcube/portlets/user/geoportaldataviewer/GeoportalViewer_Tests.java @@ -9,6 +9,8 @@ import org.gcube.application.geoportalcommon.geoportal.GeoportalClientCaller; import org.gcube.application.geoportalcommon.geoportal.ProjectsCaller; import org.gcube.application.geoportalcommon.geoportal.UseCaseDescriptorCaller; import org.gcube.application.geoportalcommon.shared.geoportal.materialization.GCubeSDIViewerLayerDV; +import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.FilesetDV; +import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.PayloadDV; import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV; import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView; import org.gcube.common.authorization.library.provider.SecurityTokenProvider; @@ -37,7 +39,7 @@ public class GeoportalViewer_Tests { private static String TOKEN = "c41a00c0-7897-48d2-a67a-05190d6ce5e6-98187548"; // devVRE private static String PROFILE_ID = "profiledConcessioni"; - private static String PROJECT_ID = "6311d408900dde90e44d9265"; + private static String PROJECT_ID = "634fc41ecd343e6571ed3db0"; private static String USERNAME = "francesco.mangiacrapa"; @@ -55,7 +57,7 @@ public class GeoportalViewer_Tests { clientProjects = GeoportalClientCaller.projects(); } - //@Test + // @Test public void getProjectViewForID() { try { @@ -75,7 +77,7 @@ public class GeoportalViewer_Tests { } } - @Test + // @Test public void getLayersForId() { System.out.println("getLayersForId [profileID: " + PROFILE_ID + ", projectID: " + PROJECT_ID + "] called"); @@ -92,7 +94,8 @@ public class GeoportalViewer_Tests { String materializationParentJSONPath = String.format("%s..%s", Geoportal_JSON_Mapper.JSON_$_POINTER, Geoportal_JSON_Mapper.FILESET); - listLayers = Geoportal_JSON_Mapper.readGcubeSDILayersForFileset(materializationParentJSONPath, jsonDocument); + listLayers = Geoportal_JSON_Mapper.readGcubeSDILayersForFileset(materializationParentJSONPath, + jsonDocument); listLayers.stream().forEach(s -> System.out.println(s)); @@ -104,4 +107,31 @@ public class GeoportalViewer_Tests { } + //@Test + public void getImagesForId() { + System.out.println("getImagesForId [profileID: " + PROFILE_ID + ", projectID: " + PROJECT_ID + "] called"); + + List listImages = null; + + try { + + ScopeProvider.instance.set(CONTEXT); + SecurityTokenProvider.instance.set(TOKEN); + 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); + + listImages.stream().forEach(s -> System.out.println("Image: " + s)); + + } catch (Exception e) { + String erroMsg = "Images are not available for profileID " + PROFILE_ID + " with projectID " + PROJECT_ID; + System.out.println(erroMsg); + e.printStackTrace(); + } + + } + }