From 44134a4860d6dc0f351e1d156f278b28d02f9946 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 30 Jul 2021 14:57:08 +0200 Subject: [PATCH 01/38] Moved to MongoConcessione-Client and mongoID --- .classpath | 6 +- .../com.gwtplugins.gdt.eclipse.core.prefs | 2 +- .settings/org.eclipse.wst.common.component | 32 +- CHANGELOG.md | 6 + pom.xml | 2 +- .../client/GeoportalDataViewer.java | 30 +- .../client/GeoportalDataViewerService.java | 22 +- .../GeoportalDataViewerServiceAsync.java | 4 +- .../client/LayerManager.java | 611 +++++++++--------- .../client/events/QueryDataEvent.java | 42 +- .../client/events/ShowDetailsEvent.java | 24 +- .../server/ConvertToDataViewModel.java | 2 +- .../GeoportalDataViewerServiceImpl.java | 288 +++++---- .../server/util/SessionUtil.java | 63 +- .../shared/GeoNaSpatialQueryResult.java | 18 +- .../shared/products/model/RecordDV.java | 27 +- 16 files changed, 627 insertions(+), 552 deletions(-) diff --git a/.classpath b/.classpath index 285ac7e..7118c71 100644 --- a/.classpath +++ b/.classpath @@ -1,12 +1,12 @@ - + - + @@ -36,5 +36,5 @@ - + diff --git a/.settings/com.gwtplugins.gdt.eclipse.core.prefs b/.settings/com.gwtplugins.gdt.eclipse.core.prefs index afbfdeb..18cc930 100644 --- a/.settings/com.gwtplugins.gdt.eclipse.core.prefs +++ b/.settings/com.gwtplugins.gdt.eclipse.core.prefs @@ -1,4 +1,4 @@ eclipse.preferences.version=1 -lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-viewer-app/target/geoportal-data-viewer-app-1.2.0-SNAPSHOT +lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-viewer-app/target/geoportal-data-viewer-app-1.3.0-SNAPSHOT warSrcDir=src/main/webapp warSrcDirIsOutput=false diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 0d454c2..9ec4a78 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,13 +1,15 @@ - + - - + + + + @@ -15,7 +17,8 @@ - + + @@ -23,7 +26,8 @@ - + + @@ -31,15 +35,18 @@ - + + - + + - + + @@ -47,13 +54,15 @@ - + + - + + @@ -61,7 +70,8 @@ - + + diff --git a/CHANGELOG.md b/CHANGELOG.md index ab37615..e535cd1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [v1.3.0-SNAPSHOT] - 2021-07-30 + +#### Enhancements + +[#21890] Porting to ConcessioniManagerI and pass to mongoID ## [v1.2.0-SNAPSHOT] - 2021-07-19 @@ -12,6 +17,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm [#21847] Integrated with an Image and LighBox gallery for images Moved to maven-portal-bom 3.6.3 + ## [v1.1.0] - 2020-12-21 #### Enhancements diff --git a/pom.xml b/pom.xml index 433770e..bea5067 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.gcube.portlets.user geoportal-data-viewer-app war - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT GeoPortal Data Viewer App The GeoPortal Data Viewer App is an application to access, discovery and navigate the GeoNa products by a Web-Map Interface 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 e844663..44d4936 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 @@ -124,14 +124,14 @@ public class GeoportalDataViewer implements EntryPoint { GWT.log(GeoportalDataViewerConstants.GET_LAYER_TITLE + " = " + paramLayerTitle); // VALIDATING THE LONG FORMAT FOR GID - try { - if (paramGeonaItemID != null) - Long.parseLong(paramGeonaItemID); - } catch (Exception e) { - Window.alert("Bad format for parameter " + GeoportalDataViewerConstants.GET_GEONA_ITEM_ID - + ". It must be a Long"); - paramGeonaItemID = null; - } +// try { +// if (paramGeonaItemID != null) +// Long.parseLong(paramGeonaItemID); +// } catch (Exception e) { +// Window.alert("Bad format for parameter " + GeoportalDataViewerConstants.GET_GEONA_ITEM_ID +// + ". It must be a Long"); +// paramGeonaItemID = null; +// } Scheduler.get().scheduleDeferred(new ScheduledCommand() { @@ -177,7 +177,7 @@ public class GeoportalDataViewer implements EntryPoint { + paramGeonaItemID); return; } - GeoNaItemRef gir = new GeoNaItemRef(new Long(paramGeonaItemID), paramGeonaItemType); + GeoNaItemRef gir = new GeoNaItemRef(paramGeonaItemID, paramGeonaItemType); applicationBus.fireEvent(new ShowDetailsEvent(gir, null, null)); } @@ -222,22 +222,22 @@ public class GeoportalDataViewer implements EntryPoint { public void onShowDetails(ShowDetailsEvent showDetailsEvent) { GWT.log("Fired event: "+showDetailsEvent); - Long id = showDetailsEvent.getGeonaID(); + String geonaMongoId = showDetailsEvent.getGeonaMongoID(); - if(id==null) { + if(geonaMongoId==null) { Window.alert("Item Id not found"); return; } //TODO boolean found = false; - GWT.log("Product with id: "+id+" found? "+found); + GWT.log("Product with id: "+geonaMongoId+" found? "+found); if(!found) { if(showDetailsEvent.getGeonaItemType().equalsIgnoreCase("Concessione")) { - GeoportalDataViewerServiceAsync.Util.getInstance().getConcessioneForId(id, new AsyncCallback() { + GeoportalDataViewerServiceAsync.Util.getInstance().getConcessioneForId(geonaMongoId, new AsyncCallback() { @Override public void onFailure(Throwable caught) { @@ -325,7 +325,7 @@ public class GeoportalDataViewer implements EntryPoint { private void performWFSQueryOnCentroid(RecordDV record) { if(record!=null) { - GWT.log("record instanceof ConcessioneDV: " +(record instanceof ConcessioneDV)); + GWT.log("record instanceof ConcessioneDV: " +(record instanceof ConcessioneDV) +" with mongo item id: "+record.getItemId()); //GeoportalDataViewerConstants.print("record instanceof ConcessioneDV: " +(record instanceof ConcessioneDV)); if(record instanceof ConcessioneDV) { ConcessioneDV concessioneDV = (ConcessioneDV) record; @@ -337,7 +337,7 @@ public class GeoportalDataViewer implements EntryPoint { GeoQuery select = olMapMng.toDataPointQuery(transfCoord); GWT.log("GeoQuery: "+select); //GeoportalDataViewerConstants.print("fireEvent QueryDataEvent"); - layerManager.getLayerManagerBus().fireEvent(new QueryDataEvent(select, transfCoord, record.getId(), true)); + layerManager.getLayerManagerBus().fireEvent(new QueryDataEvent(select, transfCoord, record.getItemId(), true)); }else { GeoportalDataViewerConstants.printJs("I cannot select the point one or both coordiantes are null. X: "+x +", Y:"+y); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java index 87b956b..9b11de7 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java @@ -19,7 +19,7 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * - * Nov 17, 2020 + * Nov 17, 2020 */ @RemoteServiceRelativePath("geoportaldataviewerservice") public interface GeoportalDataViewerService extends RemoteService { @@ -28,7 +28,7 @@ public interface GeoportalDataViewerService extends RemoteService { * Parses the wms request. * * @param wmsRequest the wms request - * @param layerName the layer name + * @param layerName the layer name * @return the geo information for WMS request * @throws Exception the exception */ @@ -37,11 +37,11 @@ public interface GeoportalDataViewerService extends RemoteService { /** * Gets the data result. * - * @param layerObjects the layer objects - * @param mapSrsName the map srs name - * @param mapBBOX the map BBOX + * @param layerObjects the layer objects + * @param mapSrsName the map srs name + * @param mapBBOX the map BBOX * @param maxWFSFeature the max WFS feature - * @param zoomLevel the zoom level + * @param zoomLevel the zoom level * @return the data result */ List getDataResult(List layerObjects, String mapSrsName, BoundsMap mapBBOX, @@ -50,11 +50,11 @@ public interface GeoportalDataViewerService extends RemoteService { /** * Gets the concessione for id. * - * @param id the id + * @param mongoId the mongo id * @return the concessione for id * @throws Exception the exception */ - ConcessioneDV getConcessioneForId(Long id) throws Exception; + ConcessioneDV getConcessioneForId(String mongoId) throws Exception; /** * Gets the my login. @@ -84,12 +84,12 @@ public interface GeoportalDataViewerService extends RemoteService { * Gets the uploaded images for id. * * @param itemType the item type - * @param id the id + * @param itemId the item id * @param maxImages the max images * @return the uploaded images for id - * @throws Exception the exception + * @throws Exception */ - List getUploadedImagesForId(String itemType, Long id, int maxImages) throws Exception; + List getUploadedImagesForId(String itemType, String itemId, int maxImages) throws Exception; /** * Gets the public links for. diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java index 048ee65..fb9b817 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java @@ -38,7 +38,7 @@ public interface GeoportalDataViewerServiceAsync { void getDataResult(List layerObjects, String mapSrsName, BoundsMap mapBBOX, int maxWFSFeature, double zoomLevel, AsyncCallback> callback); - void getConcessioneForId(Long id, AsyncCallback callback); + void getConcessioneForId(String mongoId, AsyncCallback callback); void getMyLogin(AsyncCallback callback); @@ -46,7 +46,7 @@ public interface GeoportalDataViewerServiceAsync { void getGeoNaDataViewProfile(AsyncCallback callback); - void getUploadedImagesForId(String itemType, Long id, int maxImages, AsyncCallback> callback); + void getUploadedImagesForId(String itemType, String itemId, int maxImages, AsyncCallback> callback); void getPublicLinksFor(GeoNaItemRef item, AsyncCallback asyncCallback); 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 2ad56da..89bd471 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 @@ -51,23 +51,20 @@ import com.google.gwt.user.client.ui.VerticalPanel; import ol.Coordinate; - /** * The Class LayerManager. * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * - * Oct 27, 2020 + * Oct 27, 2020 */ public class LayerManager { - - /** The ol map. */ private OpenLayerOSM olMap; private List layerObjects = new ArrayList(); - + private HandlerManager layerManagerBus = new HandlerManager(""); private HandlerManager applicationBus; @@ -81,312 +78,333 @@ public class LayerManager { this.applicationBus = applicationBus; bindEvents(); } - - + /** * Bind events. */ 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) { + // GeoportalDataViewerConstants.print("fired QueryDataEvent: + // "+queryEvent.toString()); + + if (queryEvent.getGeoQuery() != null) { GeoQuery selectDataInfo = queryEvent.getGeoQuery(); - Long recordId = queryEvent.getRecordId(); - - GWT.log("("+selectDataInfo.getX1()+","+selectDataInfo.getY1()+")("+selectDataInfo.getX2()+","+selectDataInfo.getY2()+")"); - - for (LayerObject layerObj : layerObjects){ - //TODO + String mongoItemId = queryEvent.getMongoItemId(); + + GWT.log("(" + selectDataInfo.getX1() + "," + selectDataInfo.getY1() + ")(" + selectDataInfo.getX2() + + "," + selectDataInfo.getY2() + ")"); + + for (LayerObject layerObj : layerObjects) { + // TODO isLayerVisible(layerObj.getLayerItem()); - + } - + BoundsMap mapBBOX = new BoundsMap(); - //THIS IS SHOULD BE CORRET, THE BOUND AND CRS ARE READ FROM MAP - /*mapBBOX.setCrs(olMap.getProjectionCode()); - mapBBOX.setLowerLeftX(olMap.getExtent().getLowerLeftX()); - mapBBOX.setLowerLeftY(olMap.getExtent().getLowerLeftY()); - mapBBOX.setUpperRightX(olMap.getExtent().getUpperRightX()); - mapBBOX.setUpperRightY(olMap.getExtent().getUpperRightY()); - */ - - //THE FOLLOWING SHOULD BE NOT NEEDED BUT THE GETFEATURE WITH EPSG_3857 SEEMS NOT WORK IN OUR GEOSERVER + // THIS IS SHOULD BE CORRET, THE BOUND AND CRS ARE READ FROM MAP + /* + * mapBBOX.setCrs(olMap.getProjectionCode()); + * mapBBOX.setLowerLeftX(olMap.getExtent().getLowerLeftX()); + * mapBBOX.setLowerLeftY(olMap.getExtent().getLowerLeftY()); + * mapBBOX.setUpperRightX(olMap.getExtent().getUpperRightX()); + * mapBBOX.setUpperRightY(olMap.getExtent().getUpperRightY()); + */ + + // THE FOLLOWING SHOULD BE NOT NEEDED BUT THE GETFEATURE WITH EPSG_3857 SEEMS + // NOT WORK IN OUR GEOSERVER // double minX = olMap.getExtent().getLowerLeftX(); // double minY = olMap.getExtent().getLowerLeftY(); double minX = queryEvent.getGeoQuery().getX1(); double minY = queryEvent.getGeoQuery().getY1(); Coordinate centerCoordinate = new Coordinate(minX, minY); - centerCoordinate = olMap.transform(centerCoordinate, GeoportalDataViewerConstants.EPSG_3857, GeoportalDataViewerConstants.EPSG_4326); + centerCoordinate = olMap.transform(centerCoordinate, GeoportalDataViewerConstants.EPSG_3857, + GeoportalDataViewerConstants.EPSG_4326); 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, GeoportalDataViewerConstants.EPSG_3857, GeoportalDataViewerConstants.EPSG_4326); + centerCoordinate = new Coordinate(maxX, maxY); + centerCoordinate = olMap.transform(centerCoordinate, GeoportalDataViewerConstants.EPSG_3857, + GeoportalDataViewerConstants.EPSG_4326); mapBBOX.setUpperRightX(centerCoordinate.getX()); mapBBOX.setUpperRightY(centerCoordinate.getY()); - + mapBBOX.setCrs(GeoportalDataViewerConstants.EPSG_4326); - - GWT.log("Bounds is: "+mapBBOX); - GWT.log("MAX_WFS_FEATURES is: "+GeoportalDataViewerConstants.MAX_WFS_FEATURES); - //GeoportalDataViewerConstants.print("calling getDataResult"); - - GeoportalDataViewerServiceAsync.Util.getInstance().getDataResult(layerObjects, olMap.getProjectionCode(), mapBBOX, GeoportalDataViewerConstants.MAX_WFS_FEATURES, olMap.getCurrentZoomLevel(), new AsyncCallback>() { - @Override - public void onFailure(Throwable caught) { - //GeoportalDataViewerConstants.print("on Failure DataResult: "+caught.getMessage()); - } + GWT.log("Bounds is: " + mapBBOX); + GWT.log("MAX_WFS_FEATURES is: " + GeoportalDataViewerConstants.MAX_WFS_FEATURES); + // GeoportalDataViewerConstants.print("calling getDataResult"); - @Override - public void onSuccess(List listGeonaDataObjects) { - - GWT.log("GeoNaDataObject's: "+listGeonaDataObjects); - //GeoportalDataViewerConstants.print("GeoNaDataObject's: "+listGeonaDataObjects); - - if(listGeonaDataObjects==null || listGeonaDataObjects.isEmpty()) - return; + GeoportalDataViewerServiceAsync.Util.getInstance().getDataResult(layerObjects, + olMap.getProjectionCode(), mapBBOX, GeoportalDataViewerConstants.MAX_WFS_FEATURES, + olMap.getCurrentZoomLevel(), new AsyncCallback>() { - FlexTable flex = new FlexTable(); - flex.setCellPadding(1); - flex.setCellSpacing(1); - flex.getElement().addClassName("popup-table"); - boolean featureFound = false; - FeatureRow feature = null; - - //TODO SWTCH FOR EARCH ITEM TYPE - for (GeoNaSpatialQueryResult geoNaDataObject : listGeonaDataObjects) { - List features = geoNaDataObject.getFeatures(); + @Override + public void onFailure(Throwable caught) { + // GeoportalDataViewerConstants.print("on Failure DataResult: + // "+caught.getMessage()); + } - //USING ONLY THE FIRST FEATURE IN THE LIST - if(features!=null && features.size()>0) { - - //I need to show exaclty the feature with produc_id == recordId - if(recordId!=null) { - for (FeatureRow fRow : features) { - List productIdLst = fRow.getMapProperties().get("product_id"); - String thePID = productIdLst.get(0); + @Override + public void onSuccess(List listGeonaDataObjects) { + + GWT.log("GeoNaDataObject's: " + listGeonaDataObjects); + // GeoportalDataViewerConstants.print("GeoNaDataObject's: + // "+listGeonaDataObjects); + + if (listGeonaDataObjects == null || listGeonaDataObjects.isEmpty()) + return; + + FlexTable flex = new FlexTable(); + flex.setCellPadding(1); + flex.setCellSpacing(1); + flex.getElement().addClassName("popup-table"); + boolean featureFound = false; + FeatureRow feature = null; + + // TODO SWTCH FOR EARCH ITEM TYPE + for (GeoNaSpatialQueryResult geoNaDataObject : listGeonaDataObjects) { + List features = geoNaDataObject.getFeatures(); + + // USING ONLY THE FIRST FEATURE IN THE LIST + if (features != null && features.size() > 0) { + + // I need to show exaclty the feature with produc_id == recordId + if (mongoItemId != null) { + for (FeatureRow fRow : features) { + List productIdLst = fRow.getMapProperties() + .get("product_id"); + String 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 recordId not passed, I'm using the first feature returned + if (mongoItemId == null) { + feature = features.get(0); + } else { + // the recordId to show has been passed but not found into list of + // FeatureRow + if (feature == null) { + return; + } + } + + 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 { - long productId = Long.parseLong(thePID); - if(productId==recordId) { - feature = fRow; - GWT.log("Found recorId == product_id with id: "+productId); - break; - } - }catch (Exception e) { - // TODO: handle exception + 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.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); + } + } + } + } + + featureFound = true; + // break; //Only the first one } - } - - //If recordId not passed, I'm using the first feature returned - if(recordId==null) { - feature = features.get(0); - }else { - //the recordId to show has been passed but not found into list of FeatureRow - if(feature==null) { + + if (feature == null) return; - } - } - - 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:""; + GWT.log("The selected Feature is: " + feature); + // GeoportalDataViewerConstants.print("The selected Feature is: "+feature); + FeatureRow theFeature = feature; + Button button = null; + if (!featureFound) { + flex.setHTML(0, 0, new HTML("No data available").toString()); + } else { + button = new Button("Open Details"); + button.getElement().setId("open-details"); + button.setType(ButtonType.LINK); } - 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 (Long 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.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); + + VerticalPanel vpPanel = new VerticalPanel(); + vpPanel.add(flex); + + 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; + + if (feature.getGeometry() != null) { + + PointsPath path = feature.getGeometry().getPath(); + GWT.log("Points Path: " + path); + if (path != null && path.getCoordinates() != null + && path.getCoordinates().length > 0) { + org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.Coordinate center = path + .getCoordinates()[0]; + centerTo = new Coordinate(center.getX(), center.getY()); } } - } - - featureFound = true; - //break; //Only the first one - } - - if(feature==null) - return; - - GWT.log("The selected Feature is: "+feature); - //GeoportalDataViewerConstants.print("The selected Feature is: "+feature); - FeatureRow theFeature = feature; - Button button = null; - if(!featureFound) { - flex.setHTML(0, 0, new HTML("No data available").toString()); - }else { - button = new Button("Open Details"); - button.getElement().setId("open-details"); - button.setType(ButtonType.LINK); - } - - VerticalPanel vpPanel = new VerticalPanel(); - vpPanel.add(flex); - - 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; - - if(feature.getGeometry()!=null) { - - PointsPath path = feature.getGeometry().getPath(); - GWT.log("Points Path: "+path); - if(path!=null && path.getCoordinates()!=null && path.getCoordinates().length>0) { - org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.Coordinate center = path.getCoordinates()[0]; - centerTo = new Coordinate(center.getX(), center.getY()); + + // fallback + if (centerTo == null) + centerTo = queryEvent.getOnFailureCenterTo(); + + 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); + } + } + }); + } + }); } } - - //fallback - if(centerTo==null) - centerTo = queryEvent.getOnFailureCenterTo(); - - 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); - } - } - }); - } - }); - } - } - }); + }); } } }); - + layerManagerBus.addHandler(AddedLayerToMapEvent.TYPE, new AddedLayerToMapEventHandler() { - + @Override public void onLayerRendered(AddedLayerToMapEvent addedLayerToMapEvent) { - GWT.log("Fired into layerManagerBus "+addedLayerToMapEvent); + GWT.log("Fired into layerManagerBus " + addedLayerToMapEvent); applicationBus.fireEvent(addedLayerToMapEvent); } }); - - + layerManagerBus.addHandler(ZoomOutOverMinimumEvent.TYPE, new ZoomOutOverMinimumEventHandler() { - + @Override public void onZoomOut(ZoomOutOverMinimumEvent zoomOutEvent) { - GWT.log("Fired into layerManagerBus "+zoomOutEvent); + GWT.log("Fired into layerManagerBus " + zoomOutEvent); applicationBus.fireEvent(zoomOutEvent); } }); } - - + /** * Parses the geona references. * * @param itemType the item type - * @param fRow the f row + * @param fRow the f row * @return the show details event */ private ShowDetailsEvent parseGeonaReferences(String itemType, FeatureRow fRow) { - if(fRow==null) + if (fRow == null) return null; - + List productIds = fRow.getMapProperties().get("product_id"); - if(productIds!=null && productIds.size()>0) { - long id = Long.parseLong(productIds.get(0)); + if (productIds != null && productIds.size() > 0) { + String productId = productIds.get(0); String itemName = "Dettagli Prodotto"; List listName = fRow.getMapProperties().get("nome"); - if(listName!=null && listName.size()>0) { + if (listName != null && listName.size() > 0) { itemName = listName.get(0); } - - return new ShowDetailsEvent(itemType, id, itemName, fRow); + + return new ShowDetailsEvent(itemType, productId, itemName, fRow); } - + return null; } - /** * Adds the layer. * - * @param geonaItemType the geona item type - * @param layerTitle the layer title - * @param layerName the layer name - * @param wmsLink the wms link - * @param isBase the is base + * @param geonaItemType the geona item type + * @param layerTitle the layer title + * @param layerName the layer name + * @param wmsLink the wms link + * @param isBase the is base * @param displayInLayerSwitcher the display in layer switcher - * @param UUID the uuid - * @param onTop the on top + * @param UUID the uuid + * @param onTop the on top */ - public void addLayer(final String geonaItemType, final String layerTitle, final String layerName, final String wmsLink, final boolean isBase,final boolean displayInLayerSwitcher, final String UUID, final boolean onTop) { + public void addLayer(final String geonaItemType, final String layerTitle, final String layerName, + final String wmsLink, final boolean isBase, final boolean displayInLayerSwitcher, final String UUID, + final boolean onTop) { // final LayoutContainer westPanel = (LayoutContainer) layersPanel.getParent(); // @@ -395,54 +413,65 @@ public class LayerManager { // else // layersPanel.mask("Adding..."+layerName, "x-mask-loading"); - final LayerType featureType = isBase?LayerType.RASTER_BASELAYER:LayerType.FEATURE_TYPE; + final LayerType featureType = isBase ? LayerType.RASTER_BASELAYER : LayerType.FEATURE_TYPE; // Info.display("Adding Layer", layerName); - GeoportalDataViewerServiceAsync.Util.getInstance().parseWmsRequest(wmsLink, layerName, new AsyncCallback() { + GeoportalDataViewerServiceAsync.Util.getInstance().parseWmsRequest(wmsLink, layerName, + new AsyncCallback() { - @Override - public void onFailure(Throwable caught) { + @Override + public void onFailure(Throwable caught) { - Window.alert(caught.getMessage()); - } + Window.alert(caught.getMessage()); + } - @Override - public void onSuccess(GeoInformationForWMSRequest geoInfoWMS) { - - GWT.log("Parsed WMS Request returned: "+geoInfoWMS); - //ddLayerByWms(featureType, layerTitle, result.getLayerName(), result.getWmsRequest(), result.getBaseWmsServiceHost(), true, isBase, displayInLayerSwitcher, (ArrayList) result.getStyles().getGeoStyles(), result.getWmsRequest(), false, result.getMapWMSNoStandard(), result.isNcWMS(), UUID, result.getZAxis()); - - LayerItem layerItem = toLayerItem(featureType, layerTitle, geoInfoWMS.getLayerName(), geoInfoWMS.getWmsRequest(), geoInfoWMS.getBaseWmsServiceHost(), true, isBase, displayInLayerSwitcher, (ArrayList) geoInfoWMS.getStyles().getGeoStyles(), geoInfoWMS.getWmsRequest(), false, geoInfoWMS.getMapWMSNoStandard(), geoInfoWMS.isNcWMS(), UUID, geoInfoWMS.getZAxis()); - LayerObject lo = new LayerObject(); - lo.setLayerItem(layerItem); - lo.setItemType(geonaItemType); - layerObjects.add(lo); - olMap.addWMSLayer(layerItem); - } - }); + @Override + public void onSuccess(GeoInformationForWMSRequest geoInfoWMS) { + + GWT.log("Parsed WMS Request returned: " + geoInfoWMS); + // ddLayerByWms(featureType, layerTitle, result.getLayerName(), + // result.getWmsRequest(), result.getBaseWmsServiceHost(), true, isBase, + // displayInLayerSwitcher, (ArrayList) + // result.getStyles().getGeoStyles(), result.getWmsRequest(), false, + // result.getMapWMSNoStandard(), result.isNcWMS(), UUID, result.getZAxis()); + + LayerItem layerItem = toLayerItem(featureType, layerTitle, geoInfoWMS.getLayerName(), + geoInfoWMS.getWmsRequest(), geoInfoWMS.getBaseWmsServiceHost(), true, isBase, + displayInLayerSwitcher, (ArrayList) geoInfoWMS.getStyles().getGeoStyles(), + geoInfoWMS.getWmsRequest(), false, geoInfoWMS.getMapWMSNoStandard(), + geoInfoWMS.isNcWMS(), UUID, geoInfoWMS.getZAxis()); + LayerObject lo = new LayerObject(); + lo.setLayerItem(layerItem); + lo.setItemType(geonaItemType); + layerObjects.add(lo); + olMap.addWMSLayer(layerItem); + } + }); } - /** * To layer item. * - * @param layerType the layer type - * @param layerTitle the layer title - * @param layerName the layer name - * @param layerURL the layer URL - * @param mapServerHost the map server host - * @param isExternal the is external - * @param isBase the is base + * @param layerType the layer type + * @param layerTitle the layer title + * @param layerName the layer name + * @param layerURL the layer URL + * @param mapServerHost the map server host + * @param isExternal the is external + * @param isBase the is base * @param displayInLayerSwitcher the display in layer switcher - * @param styles the styles - * @param wmsLink the wms link - * @param onTop the on top - * @param wmsNotStandardParams the wms not standard params - * @param isNcWms the is nc wms - * @param UUID the uuid - * @param zAxis the z axis + * @param styles the styles + * @param wmsLink the wms link + * @param onTop the on top + * @param wmsNotStandardParams the wms not standard params + * @param isNcWms the is nc wms + * @param UUID the uuid + * @param zAxis the z axis * @return the layer item */ - private LayerItem toLayerItem(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) { + private LayerItem toLayerItem(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) { // GWT.log("Add addLayerByWms 1"); LayerItem layerItem = new LayerItem(); @@ -451,7 +480,7 @@ public class LayerManager { layerItem.setName(layerName); layerItem.setUrl(layerURL); layerItem.setMapServerHost(mapServerHost); - //l.setExternal(isExternal); + // l.setExternal(isExternal); layerItem.setOpacity(1d); layerItem.setBuffer(2); layerItem.setWmsLink(wmsLink); @@ -462,53 +491,53 @@ public class LayerManager { switch (layerType) { - //TODO IMPLEMENT THIS CASE - case RASTER_BASELAYER: + // TODO IMPLEMENT THIS CASE + case RASTER_BASELAYER: // l.setHasLegend(false); - layerItem.setBaseLayer(true); - layerItem.setTrasparent(false); - layerItem.setClickData(false); - break; + layerItem.setBaseLayer(true); + layerItem.setTrasparent(false); + layerItem.setClickData(false); + break; - case FEATURE_TYPE: + case FEATURE_TYPE: - //CASE FEATURE TYPE - layerItem.setBaseLayer(false); - layerItem.setClickData(true); - layerItem.setTrasparent(true); - break; + // CASE FEATURE TYPE + layerItem.setBaseLayer(false); + layerItem.setClickData(true); + layerItem.setTrasparent(true); + break; } - GWT.log("styles "+styles); + GWT.log("styles " + styles); - if(styles!=null && styles.size()>0){ + if (styles != null && styles.size() > 0) { layerItem.setHasLegend(true); layerItem.setDefaultStyle(styles.get(0)); layerItem.setStyle(styles.get(0)); layerItem.setStyles(styles); - }else{ + } else { String style = URLUtil.getValueOfParameter("styles", wmsLink); - if(style!=null){ //CASE OF STYLE =""; - //TENTATIVE TO GET LEGEND + if (style != null) { // CASE OF STYLE =""; + // TENTATIVE TO GET LEGEND layerItem.setHasLegend(true); } } - GWT.log("Built layer: "+layerItem); + GWT.log("Built layer: " + layerItem); return layerItem; } - + /** * Checks if is layer visible. * * @param layerItem the layer item * @return true, if is layer visible */ - public boolean isLayerVisible(LayerItem layerItem){ + public boolean isLayerVisible(LayerItem layerItem) { return olMap.isLayerVisible(layerItem.getName()); } - + /** * Sets the ol map. * 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 38caafb..4b8cf9f 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 @@ -11,28 +11,27 @@ import ol.Coordinate; * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * - * Oct 29, 2020 + * Oct 29, 2020 */ public class QueryDataEvent extends GwtEvent { public static Type TYPE = new Type(); private GeoQuery select; private Coordinate onFailureCenterTo; - private Long recordId; + private String mongoItemId; private boolean onInit; - /** * Instantiates a new query data event. * - * @param select the select + * @param select the select * @param onFailureCenterTo the on failure center to - * @param recordId the record id - * @param onInit the on init + * @param mongoItemId the mongo item id + * @param onInit the on init */ - public QueryDataEvent(GeoQuery select, Coordinate onFailureCenterTo, Long recordId, boolean onInit) { + public QueryDataEvent(GeoQuery select, Coordinate onFailureCenterTo, String mongoItemId, boolean onInit) { this.select = select; this.onFailureCenterTo = onFailureCenterTo; - this.recordId = recordId; + this.mongoItemId = mongoItemId; this.onInit = onInit; } @@ -45,15 +44,9 @@ public class QueryDataEvent extends GwtEvent { public Type getAssociatedType() { return TYPE; } - - - /** - * Gets the record id. - * - * @return the record id - */ - public Long getRecordId() { - return recordId; + + public String getMongoItemId() { + return mongoItemId; } /** @@ -64,6 +57,7 @@ public class QueryDataEvent extends GwtEvent { public boolean isOnInit() { return onInit; } + /** * Dispatch. * @@ -74,7 +68,7 @@ public class QueryDataEvent extends GwtEvent { handler.onQueryInteraction(this); } - + /** * Gets the geo query. * @@ -83,8 +77,7 @@ public class QueryDataEvent extends GwtEvent { public GeoQuery getGeoQuery() { return select; } - - + public Coordinate getOnFailureCenterTo() { return onFailureCenterTo; } @@ -96,17 +89,12 @@ public class QueryDataEvent extends GwtEvent { builder.append(select); builder.append(", onFailureCenterTo="); builder.append(onFailureCenterTo); - builder.append(", recordId="); - builder.append(recordId); + builder.append(", mongoItemId="); + builder.append(mongoItemId); builder.append(", onInit="); builder.append(onInit); builder.append("]"); return builder.toString(); } - - - - - } \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/ShowDetailsEvent.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/ShowDetailsEvent.java index 9358360..2e61b8e 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/ShowDetailsEvent.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/ShowDetailsEvent.java @@ -9,15 +9,15 @@ import com.google.gwt.event.shared.GwtEvent; /** * The Class ShowDetailsEvent. * - * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * - * Nov 13, 2020 + * Jul 30, 2021 */ public class ShowDetailsEvent extends GwtEvent { public static Type TYPE = new Type(); private String geonaItemType; private FeatureRow featureRow; - private Long geonaID; + private String geonaMongoID; private String itemName; @@ -25,13 +25,13 @@ public class ShowDetailsEvent extends GwtEvent { * Instantiates a new show details event. * * @param geonaItemType the geona item type - * @param geonaID the geona ID + * @param geonaMongoID the geona mongo ID * @param itemName the item name * @param featureRow the feature row */ - public ShowDetailsEvent(String geonaItemType, Long geonaID, String itemName, FeatureRow featureRow) { + public ShowDetailsEvent(String geonaItemType, String geonaMongoID, String itemName, FeatureRow featureRow) { this.geonaItemType = geonaItemType; - this.geonaID = geonaID; + this.geonaMongoID = geonaMongoID; this.itemName = itemName; this.featureRow = featureRow; @@ -47,7 +47,7 @@ public class ShowDetailsEvent extends GwtEvent { */ public ShowDetailsEvent(GeoNaItemRef gir, String itemName, FeatureRow featureRow) { this.geonaItemType = gir.getItemType(); - this.geonaID = gir.getItemId(); + this.geonaMongoID = gir.getItemId(); this.itemName = itemName; this.featureRow = featureRow; } @@ -92,12 +92,12 @@ public class ShowDetailsEvent extends GwtEvent { } /** - * Gets the geona ID. + * Gets the geona mongo ID. * - * @return the geona ID + * @return the geona mongo ID */ - public Long getGeonaID() { - return geonaID; + public String getGeonaMongoID() { + return geonaMongoID; } /** @@ -125,7 +125,7 @@ public class ShowDetailsEvent extends GwtEvent { * @return the geona item ref */ public GeoNaItemRef getGeonaItemRef() { - return new GeoNaItemRef(geonaID, geonaItemType); + return new GeoNaItemRef(geonaMongoID, geonaItemType); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConvertToDataViewModel.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConvertToDataViewModel.java index 3513355..3b72b83 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConvertToDataViewModel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConvertToDataViewModel.java @@ -75,7 +75,7 @@ public class ConvertToDataViewModel { theConcessione.setDescrizioneContenuto(concessione.getDescrizioneContenuto()); theConcessione.setEditore(concessione.getEditore()); theConcessione.setFontiFinanziamento(concessione.getFontiFinanziamento()); - theConcessione.setId(concessione.getId()); + theConcessione.setItemId(concessione.getMongo_id()); theConcessione.setNome(concessione.getNome()); theConcessione.setIntroduzione(concessione.getIntroduzione()); 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 8205e99..9894c98 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 @@ -1,12 +1,14 @@ package org.gcube.portlets.user.geoportaldataviewer.server; +import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.statefulMongoConcessioni; + import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import org.gcube.application.geoportal.client.legacy.ConcessioniManager; +import org.gcube.application.geoportal.client.legacy.ConcessioniManagerI; import org.gcube.application.geoportal.common.model.legacy.Concessione; import org.gcube.application.geoportal.common.model.legacy.UploadedImage; import org.gcube.application.geoportalcommon.GeoNaDataViewerProfileReader; @@ -14,6 +16,9 @@ import org.gcube.application.geoportalcommon.GeoportalCommon; import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.LayerItem; +import org.gcube.common.authorization.library.provider.SecurityTokenProvider; +import org.gcube.common.portal.PortalContext; +import org.gcube.common.scope.api.ScopeProvider; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerService; import org.gcube.portlets.user.geoportaldataviewer.server.gis.FeatureParser; import org.gcube.portlets.user.geoportaldataviewer.server.gis.WMSUrlValidator; @@ -43,12 +48,11 @@ import com.google.gwt.user.server.rpc.RemoteServiceServlet; * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * - * Nov 12, 2020 + * Nov 12, 2020 */ @SuppressWarnings("serial") -public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet implements - GeoportalDataViewerService { - +public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet implements GeoportalDataViewerService { + public static final String PRODUCT_ID = "product_id"; /** The Constant LOG. */ private static final Logger LOG = LoggerFactory.getLogger(GeoportalDataViewerServiceImpl.class); @@ -57,7 +61,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme * Parses the wms request. * * @param wmsRequest the wms request - * @param layerName the layer name + * @param layerName the layer name * @return the geo information for WMS request * @throws Exception the exception */ @@ -65,17 +69,17 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme public GeoInformationForWMSRequest parseWmsRequest(String wmsRequest, String layerName) throws Exception { return loadGeoInfoForWmsRequest(wmsRequest, layerName); } - /** * Load geo info for wms request. * - * @param wmsLink the wms link + * @param wmsLink the wms link * @param layerName the layer name * @return the geo information for WMS request * @throws Exception the exception */ - public static GeoInformationForWMSRequest loadGeoInfoForWmsRequest(String wmsLink, String layerName) throws Exception{ + public static GeoInformationForWMSRequest loadGeoInfoForWmsRequest(String wmsLink, String layerName) + throws Exception { try { WMSUrlValidator validator = new WMSUrlValidator(wmsLink, layerName); String wmsServiceHost = validator.getWmsServiceHost(); @@ -83,30 +87,33 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme layerName = validator.getLayerName(); String versionWms = validator.getValueOfParsedWMSParameter(WmsParameters.VERSION); String crs = validator.getValueOfParsedWMSParameter(WmsParameters.CRS); - // + // HashMap mapWmsNotStandard = new HashMap(); - if(validator.getMapWmsNoStandardParams()!=null){ + if (validator.getMapWmsNoStandardParams() != null) { mapWmsNotStandard.putAll(validator.getMapWmsNoStandardParams()); } - // + // GeoNcWMSMetadataUtility geoGS = new GeoNcWMSMetadataUtility(validWMSRequest, 4000); - //STYLES - LayerStyles layerStyle = geoGS.loadStyles(); - Map mapNcWmsStyles = layerStyle.getMapNcWmsStyles()==null?new HashMap(1):layerStyle.getMapNcWmsStyles(); + // STYLES + LayerStyles layerStyle = geoGS.loadStyles(); + Map mapNcWmsStyles = layerStyle.getMapNcWmsStyles() == null ? new HashMap(1) + : layerStyle.getMapNcWmsStyles(); mapWmsNotStandard.putAll(mapNcWmsStyles); - //MAP STYLES INTO GWT-SERIALIZABLE OBJECT + // MAP STYLES INTO GWT-SERIALIZABLE OBJECT Styles styles = new Styles(layerStyle.getGeoStyles(), layerStyle.getMapNcWmsStyles(), layerStyle.isNcWms()); - //ZAxis + // ZAxis LayerZAxis layerZAxis = geoGS.loadZAxis(); - //MAP ZAXIS INTO GWT-SERIALIZABLE OBJECT - ZAxis zAxis = layerZAxis!=null?new ZAxis(layerZAxis.getUnits(), layerZAxis.isPositive(), layerZAxis.getValues()):null; + // MAP ZAXIS INTO GWT-SERIALIZABLE OBJECT + ZAxis zAxis = layerZAxis != null + ? new ZAxis(layerZAxis.getUnits(), layerZAxis.isPositive(), layerZAxis.getValues()) + : null; - return new GeoInformationForWMSRequest(wmsServiceHost, validWMSRequest, layerName, versionWms, crs, mapWmsNotStandard, styles, styles.isNcWms(), zAxis); - } - catch (Exception e) { - String msg = "An error occurred during wms request validation for layer: "+layerName; - LOG.error(msg,e); + return new GeoInformationForWMSRequest(wmsServiceHost, validWMSRequest, layerName, versionWms, crs, + mapWmsNotStandard, styles, styles.isNcWms(), zAxis); + } catch (Exception e) { + String msg = "An error occurred during wms request validation for layer: " + layerName; + LOG.error(msg, e); throw new Exception(msg); } } @@ -114,83 +121,88 @@ 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 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 + * @param zoomLevel the zoom level * @return the data result */ @Override - public List getDataResult(List layerObjects, String mapSrsName, BoundsMap selectBBOX, - int maxWFSFeature, double zoomLevel) { + 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); + List features = FeatureParser.getWFSFeatures(layerObject.getLayerItem(), mapSrsName, selectBBOX, + maxWFSFeature); + LOG.debug("For layer name: " + layerObject.getLayerItem().getName() + " got features: " + features); geoDAO.setFeatures(features); for (FeatureRow fRow : features) { - if(fRow.getMapProperties()!=null) { + if (fRow.getMapProperties() != null) { List concessioneIds = fRow.getMapProperties().get("product_id"); - if(concessioneIds!=null && concessioneIds.size()>0) { + if (concessioneIds != null && concessioneIds.size() > 0) { String cId = concessioneIds.get(0); try { - long theConcessionID = Long.parseLong(cId); - List listUI = getUploadedImagesForId("Concessione", theConcessionID, 1); - Map> mapImages = new LinkedHashMap>(); - mapImages.put(theConcessionID, listUI); + List listUI = getUploadedImagesForId("Concessione", cId, 1); + Map> mapImages = new LinkedHashMap>(); + mapImages.put(cId, listUI); geoDAO.setMapImages(mapImages); - }catch (Exception e) { - LOG.warn("Error on loading uploaded images for concessione: "+cId, e); + } 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"); + LOG.info("For layer name: " + layerObject.getLayerItem().getName() + " got " + features.size() + + " feature/s"); listDAO.add(geoDAO); } - LOG.info("returning "+listDAO+" geona data objects"); + LOG.info("returning " + listDAO + " geona data objects"); return listDAO; } - /** * Gets the uploaded images for id. * - * @param id the id + * @param itemType the item type + * @param itemId the item id. It is the mongoId + * @param maxImages the max images * @return the uploaded images for id * @throws Exception the exception */ @Override - public List getUploadedImagesForId(String itemType, Long id, int maxImages) throws Exception{ - LOG.info("getUploadedImagesForId [id: "+id+", itemType: "+itemType+"] called"); - - if(itemType==null) + public List getUploadedImagesForId(String itemType, String itemId, int maxImages) + throws Exception { + LOG.info("getUploadedImagesForId [itemId: " + itemId + ", itemType: " + itemType + "] called"); + + if (itemType == null) throw new Exception("Invalid parameter. The itemType is null"); - - if(id==null) - throw new Exception("Invalid parameter. The Id is null"); - + + if (itemId == null) + throw new Exception("Invalid parameter. The itemId is null"); + List listUI = null; - + try { - + SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); - - if(itemType.equalsIgnoreCase("concessione")) { - - LOG.info("Trying to get concessione for id "+id); - ConcessioniManager concessioniManager = new ConcessioniManager(); - Concessione concessione = concessioniManager.getById(id+""); + + if (itemType.equalsIgnoreCase("concessione")) { + + LOG.info("Trying to get concessione for id " + itemId); + SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); + SessionUtil.getCurrentToken(this.getThreadLocalRequest(), true); + ConcessioniManagerI concessioniManager = statefulMongoConcessioni().build(); + Concessione concessione = concessioniManager.getById(itemId); if (concessione != null) { - LOG.info("For id "+id+", got concessione "+concessione.getNome() +" from service"); + LOG.info("For id " + itemId + ", got concessione " + concessione.getNome() + " from service"); List images = concessione.getImmaginiRappresentative(); - + if (images != null) { listUI = new ArrayList(); int max = maxImages < images.size() ? maxImages : images.size(); @@ -198,70 +210,73 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme UploadedImageDV ui = ConvertToDataViewModel.toUploadedImage(images.get(i)); listUI.add(ui); } - LOG.info("For id "+id+", got "+listUI.size() +" image/s"); + LOG.info("For id " + itemId + ", got " + listUI.size() + " image/s"); } - }else - throw new Exception("Concessione with id: "+id +" not available"); + } else + throw new Exception("Concessione with id '" + itemId + "' not available"); } - + return listUI; - - }catch (Exception e) { - String erroMsg = UploadedImage.class.getSimpleName() +" not available for "+Concessione.class.getSimpleName() +" with id "+id; - LOG.error(erroMsg,e); + + } catch (Exception e) { + String erroMsg = UploadedImage.class.getSimpleName() + " not available for " + + Concessione.class.getSimpleName() + " with id " + itemId; + LOG.error(erroMsg, e); throw new Exception(erroMsg); } - + } - + /** * Gets the concessione for id. * - * @param id the id + * @param mongoId the mongo id * @return the concessione for id * @throws Exception the exception */ @Override - public ConcessioneDV getConcessioneForId(Long id) throws Exception{ - LOG.info("getConcessioneForId "+id+ " called"); - + public ConcessioneDV getConcessioneForId(String mongoId) throws Exception { + LOG.info("getConcessioneForId " + mongoId + " called"); + ConcessioneDV concessionDV = null; - - if(id==null) - throw new Exception("Invalid parameter. The Id is null"); - + + if (mongoId == null) + throw new Exception("Invalid parameter. The itemId is null"); + try { - LOG.info("Trying to get record for id "+id); + LOG.info("Trying to get record for id " + mongoId); SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); - Concessione concessione = new ConcessioniManager().getById(id+""); - LOG.info("Got concessione for id "+id); - if(concessione !=null) { + SessionUtil.getCurrentToken(this.getThreadLocalRequest(), true); + // Obtain the client + ConcessioniManagerI manager = statefulMongoConcessioni().build(); + Concessione concessione = manager.getById(mongoId); + LOG.info("Got concessione for mongoId " + mongoId); + if (concessione != null) { concessionDV = ConvertToDataViewModel.toConcessione(concessione); } - - if(concessionDV==null) - throw new Exception("Concessione with id: "+id +" not available"); - - LOG.debug("For id "+id+" returning "+ConcessioneDV.class.getSimpleName()+": "+concessionDV); + + if (concessionDV == null) + throw new Exception("Concessione with id '" + mongoId + "' not available"); + + LOG.debug("For id " + mongoId + " returning " + ConcessioneDV.class.getSimpleName() + ": " + concessionDV); return concessionDV; - - }catch (Exception e) { - String erroMsg = Concessione.class.getSimpleName() +" with id "+id+" not available"; - LOG.error(erroMsg,e); + + } catch (Exception e) { + String erroMsg = Concessione.class.getSimpleName() + " with id '" + mongoId + "' not available"; + LOG.error(erroMsg, e); throw new Exception(erroMsg); } - + } - - + /** * Gets the parameters from URL. * - * @param theURL the the URL + * @param theURL the the URL * @param parameters the parameters * @return a map with couple (paramKey, paramValue) */ - + public Map getParametersFromURL(String theURL, List parameters) { if (theURL == null) @@ -275,30 +290,29 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme String paramValue = URLParserUtil.extractValueOfParameterFromURL(paramKey, theURL); hashParameters.put(paramKey, paramValue); } - + return hashParameters; } - - + /** * Gets the my login. * * @return the my login */ @Override - public String getMyLogin(){ + public String getMyLogin() { try { GCubeUser user = SessionUtil.getCurrentUser(this.getThreadLocalRequest()); - if(user==null) + if (user == null) return null; return user.getUsername(); - }catch (Exception e) { + } catch (Exception e) { LOG.warn("Error on getting the login, am I out of portal? Returning null"); return null; } } - + /** * Gets the layer for type. * @@ -307,31 +321,31 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme * @throws Exception the exception */ @Override - public GeoInformationForWMSRequest getLayerForType(String layerType) throws Exception{ - LOG.info("Called getLayerForType for:"+layerType); - - if(layerType==null || layerType.isEmpty()) + public GeoInformationForWMSRequest getLayerForType(String layerType) throws Exception { + LOG.info("Called getLayerForType for:" + layerType); + + if (layerType == null || layerType.isEmpty()) throw new Exception("The input parameter layerType is null or empty"); - + SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); GeoNaDataViewerProfileReader gdvp = new GeoNaDataViewerProfileReader("geoportal-data-viewer-app"); GeoNaDataViewerProfile profile = gdvp.readProfileFromInfrastrucure(); - LOG.info("Read profile: "+profile); - + LOG.info("Read profile: " + profile); + String lowerLayerType = layerType.toLowerCase(); - LOG.info("Reading map layers for type:"+lowerLayerType); + LOG.info("Reading map layers for type:" + lowerLayerType); LayerItem layer = profile.getMapLayers().get(lowerLayerType); - - if(layer==null || layer.getWmsLink()==null) - throw new Exception("The layer type "+lowerLayerType+" has not been found. Please check your input parameter"); - - if(layer.getWmsLink()==null) - throw new Exception("The layer type "+lowerLayerType+" has not a WMS Link associated. Please check your input parameter"); - - + + if (layer == null || layer.getWmsLink() == null) + throw new Exception( + "The layer type " + lowerLayerType + " has not been found. Please check your input parameter"); + + if (layer.getWmsLink() == null) + throw new Exception("The layer type " + lowerLayerType + + " has not a WMS Link associated. Please check your input parameter"); + return parseWmsRequest(layer.getWmsLink(), null); } - /** * Gets the geo na data view profile. @@ -340,17 +354,16 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme * @throws Exception the exception */ @Override - public GeoNaDataViewerProfile getGeoNaDataViewProfile() throws Exception{ + public GeoNaDataViewerProfile getGeoNaDataViewProfile() throws Exception { LOG.info("getGeoNaDataViewProfile called"); - + SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); GeoportalCommon gc = new GeoportalCommon(); org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile profile = gc.getGeoNaDataViewProfile(null); - LOG.info("Returning profile: "+profile); + LOG.info("Returning profile: " + profile); return profile; } - @Override public GeoNaItemRef getPublicLinksFor(GeoNaItemRef item) throws Exception { LOG.info("getPublicLinksFor called for: " + item); @@ -359,25 +372,26 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme if (item == null) throw new Exception("Bad request, the item is null"); - - if(item.getItemId()==null) + + if (item.getItemId() == null) throw new Exception("Bad request, the item id is null"); - - if(item.getItemType()==null) + + if (item.getItemType() == null) throw new Exception("Bad request, the item type is null"); - + SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); GeoportalCommon gc = new GeoportalCommon(); return gc.getPublicLinksFor(item); - + } catch (Exception e) { LOG.error("Error on getPublicLinksFor for: " + item, e); - throw new Exception("Share link not available for this item. Try later or contact the support. Error: "+e.getMessage()); + throw new Exception("Share link not available for this item. Try later or contact the support. Error: " + + e.getMessage()); } } - + public boolean isSessionExpired() throws Exception { return SessionUtil.isSessionExpired(this.getThreadLocalRequest()); } - + } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/SessionUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/SessionUtil.java index b5d8638..d7c552f 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/SessionUtil.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/SessionUtil.java @@ -6,6 +6,7 @@ package org.gcube.portlets.user.geoportaldataviewer.server.util; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; +import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.common.portal.PortalContext; import org.gcube.common.scope.api.ScopeProvider; import org.gcube.portlets.user.urlshortener.UrlShortener; @@ -20,19 +21,18 @@ import org.slf4j.LoggerFactory; import com.liferay.portal.service.UserLocalServiceUtil; - /** * The Class SessionUtil. * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * - * Oct 20, 2020 + * Oct 20, 2020 */ public class SessionUtil { /** The log. */ private static Logger LOG = LoggerFactory.getLogger(SessionUtil.class); - + public static final String URL_SHORTENER_SERVICE = "URL_SHORTENER_SERVICE"; /** @@ -44,20 +44,18 @@ public class SessionUtil { try { UserLocalServiceUtil.getService(); return true; - }catch (Exception ex) { + } catch (Exception ex) { LOG.warn("Development Mode ON"); return false; } } - + /** * Checks if is session expired. * - * @param httpServletRequest - * the http servlet request + * @param httpServletRequest the http servlet request * @return true, if is session expired - * @throws Exception - * the exception + * @throws Exception the exception */ public static boolean isSessionExpired(HttpServletRequest httpServletRequest) throws Exception { LOG.trace("workspace session validating..."); @@ -70,9 +68,9 @@ public class SessionUtil { * @param request the request * @return a GcubeUser object */ - public static GCubeUser getCurrentUser(HttpServletRequest request){ + public static GCubeUser getCurrentUser(HttpServletRequest request) { - if(request == null) + if (request == null) throw new IllegalArgumentException("HttpServletRequest is null!"); PortalContext pContext = PortalContext.getConfiguration(); @@ -84,36 +82,60 @@ public class SessionUtil { /** * Retrieve the current scope by using the portal manager. * - * @param request the request + * @param request the request * @param setInThread the set in thread * @return a GcubeUser object */ - public static String getCurrentContext(HttpServletRequest request, boolean setInThread){ + public static String getCurrentContext(HttpServletRequest request, boolean setInThread) { - if(request == null) + if (request == null) throw new IllegalArgumentException("HttpServletRequest is null!"); PortalContext pContext = PortalContext.getConfiguration(); String context = pContext.getCurrentScope(request); - LOG.debug("Returning context " + context); - if(context != null && setInThread) + if (context != null && setInThread) ScopeProvider.instance.set(context); + LOG.debug("Returning context " + context); return context; } + /** + * Retrieve the current scope by using the portal manager. + * + * @param request the request + * @param setInThread the set in thread + * @return a GcubeUser object + */ + public static String getCurrentToken(HttpServletRequest request, boolean setInThread) { + + if (request == null) + throw new IllegalArgumentException("HttpServletRequest is null!"); + + PortalContext pContext = PortalContext.getConfiguration(); + String scope = pContext.getCurrentScope(request); + GCubeUser user = pContext.getCurrentUser(request); + String token = PortalContext.getConfiguration().getCurrentUserToken(scope, user.getUsername()); + + if (token != null && setInThread) + SecurityTokenProvider.instance.set(token); + + LOG.debug("Returning token " + token.substring(1, 10) + "MASKED_TOKEN"); + return token; + } + /** * Retrieve the group given the scope. * * @param scope the scope * @return the group from scope * @throws UserManagementSystemException the user management system exception - * @throws GroupRetrievalFault the group retrieval fault + * @throws GroupRetrievalFault the group retrieval fault */ - public static GCubeGroup getGroupFromScope(String scope) throws UserManagementSystemException, GroupRetrievalFault{ + public static GCubeGroup getGroupFromScope(String scope) throws UserManagementSystemException, GroupRetrievalFault { - if(scope == null || scope.isEmpty()) + if (scope == null || scope.isEmpty()) throw new IllegalArgumentException("Scope is missing here!!"); GroupManager gm = new LiferayGroupManager(); @@ -122,7 +144,6 @@ public class SessionUtil { } - /** * Gets the url shortener. * @@ -142,7 +163,7 @@ public class SessionUtil { } } catch (Exception e) { - LOG.warn("Error occurred when instancing the "+UrlShortener.class.getSimpleName(), e); + LOG.warn("Error occurred when instancing the " + UrlShortener.class.getSimpleName(), e); } return shortener; 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 37d1827..e4f4271 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 @@ -8,12 +8,13 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.FeatureRow; import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.UploadedImageDV; + /** * The Class GeoNaSpatialQueryResult. * - * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * - * Nov 17, 2020 + * Jul 30, 2021 */ public class GeoNaSpatialQueryResult implements Serializable { @@ -23,8 +24,8 @@ public class GeoNaSpatialQueryResult implements Serializable { private static final long serialVersionUID = 3513120677727206958L; private List features; private LayerObject sourceLayerObject; - // Map with couple (id concessione, list of uplaoded Images for the concessione) - private Map> mapImages = null; + // Map with couple (mongoId concessione, list of uplaoded Images for the concessione) + private Map> mapImages = null; /** * Instantiates a new geo na data object. @@ -74,7 +75,7 @@ public class GeoNaSpatialQueryResult implements Serializable { * * @return the map images */ - public Map> getMapImages() { + public Map> getMapImages() { return mapImages; } @@ -83,10 +84,15 @@ 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(); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/model/RecordDV.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/model/RecordDV.java index aac4991..a3c9d39 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/model/RecordDV.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/model/RecordDV.java @@ -13,14 +13,13 @@ import com.google.gwt.user.client.rpc.IsSerializable; */ public abstract class RecordDV implements Serializable, IsSerializable { - /** * */ private static final long serialVersionUID = 2913726613820175679L; - /** The id. */ - private Long id; + /** The mongo id **/ + private String itemId; /** The record type. */ private String recordType; @@ -62,21 +61,21 @@ public abstract class RecordDV implements Serializable, IsSerializable { } /** - * Gets the id. + * Gets the item id. * - * @return the id + * @return the item id */ - public Long getId() { - return id; + public String getItemId() { + return itemId; } /** - * Sets the id. + * Sets the item id. * - * @param id the new id + * @param itemId the new item id */ - public void setId(Long id) { - this.id = id; + public void setItemId(String itemId) { + this.itemId = itemId; } /** @@ -262,8 +261,8 @@ public abstract class RecordDV implements Serializable, IsSerializable { @Override public String toString() { StringBuilder builder = new StringBuilder(); - builder.append("RecordDV [id="); - builder.append(id); + builder.append("RecordDV [itemId="); + builder.append(itemId); builder.append(", recordType="); builder.append(recordType); builder.append(", version="); @@ -288,4 +287,6 @@ public abstract class RecordDV implements Serializable, IsSerializable { return builder.toString(); } + + } -- 2.17.1 From c7683e12456d02ea0761d86c48ec863bbb244d0d Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 30 Jul 2021 15:08:03 +0200 Subject: [PATCH 02/38] fixed css --- .../client/ui/gallery/ImagesGallery.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/gallery/ImagesGallery.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/gallery/ImagesGallery.java index fd14c8a..d3effb0 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/gallery/ImagesGallery.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/gallery/ImagesGallery.java @@ -80,11 +80,11 @@ public class ImagesGallery { // GALLERY THEME galleryTheme : { thumbnail : { - borderRadius : '2px', - background : '#fff', - titleShadow : 'none', - titleColor : '#696969', - labelBackground : '#f3f3f3' + borderRadius : '2px !important', + background : '#ffffff !important', + titleShadow : 'none !important', + titleColor : '#696969 !important', + labelBackground : '#f3f3f3 !important' }, thumbnailIcon : { color : '#000', -- 2.17.1 From 1c3184fd0b438d74f26efbc0730c4465a2c91480 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 30 Jul 2021 15:57:25 +0200 Subject: [PATCH 03/38] added a method --- .../client/GeoportalDataViewerService.java | 11 +++ .../GeoportalDataViewerServiceAsync.java | 4 + .../client/LayerManager.java | 40 +++++++++- .../GeoportalDataViewerServiceImpl.java | 80 ++++++++++++++++++- 4 files changed, 128 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java index 9b11de7..365edd1 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java @@ -9,6 +9,7 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformationForWMSRequest; import org.gcube.portlets.user.geoportaldataviewer.shared.products.ConcessioneDV; +import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.LayerConcessioneDV; import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.UploadedImageDV; import com.google.gwt.user.client.rpc.RemoteService; @@ -100,4 +101,14 @@ public interface GeoportalDataViewerService extends RemoteService { */ GeoNaItemRef getPublicLinksFor(GeoNaItemRef item) throws Exception; + /** + * Gets the layers for id. + * + * @param itemType the item type + * @param itemId the item id + * @return the layers for id + * @throws Exception the exception + */ + List getLayersForId(String itemType, String itemId) throws Exception; + } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java index fb9b817..3ae9425 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java @@ -9,6 +9,7 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformationForWMSRequest; import org.gcube.portlets.user.geoportaldataviewer.shared.products.ConcessioneDV; +import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.LayerConcessioneDV; import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.UploadedImageDV; import com.google.gwt.core.client.GWT; @@ -50,4 +51,7 @@ public interface GeoportalDataViewerServiceAsync { void getPublicLinksFor(GeoNaItemRef item, AsyncCallback asyncCallback); + void getLayersForId(String itemType, String itemId, + AsyncCallback> asyncCallback); + } 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 89bd471..449ae55 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 @@ -168,20 +168,20 @@ public class LayerManager { flex.getElement().addClassName("popup-table"); boolean featureFound = false; FeatureRow feature = null; - + // TODO SWTCH FOR EARCH ITEM TYPE for (GeoNaSpatialQueryResult geoNaDataObject : listGeonaDataObjects) { List features = geoNaDataObject.getFeatures(); // USING ONLY THE FIRST FEATURE IN THE LIST if (features != null && features.size() > 0) { - + String theProductId = null; // I need to show exaclty the feature with produc_id == recordId if (mongoItemId != null) { for (FeatureRow fRow : features) { List productIdLst = fRow.getMapProperties() .get("product_id"); - String theProductId = productIdLst.get(0); + theProductId = productIdLst.get(0); try { //long productId = Long.parseLong(thePID); if (theProductId == mongoItemId) { @@ -196,9 +196,12 @@ public class LayerManager { } } - // If recordId not passed, I'm using the first feature returned + // 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"); + theProductId = productIdLst.get(0); } else { // the recordId to show has been passed but not found into list of // FeatureRow @@ -206,6 +209,35 @@ public class LayerManager { return; } } + + GWT.log("the product id is: "+theProductId); + + /*if(olMap.getCurrentZoomLevel()>10) { + 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) { + GWT.log("Adding layers: "+result); + for (LayerConcessioneDV layer : result) { + addLayer("concessione", layer.getLayerName(), layer.getLayerName(), layer.getWmsLink(), false, false, layer.getLayerUUID(), true); +// LayerItem li = new LayerItem(); +// li.setBaseLayer(false); +// li.setWmsLink(layer.getWmsLink()); +// li.setTitle(layer.getLayerName()); +// olMap.addWMSLayer(li); + } + + } + }); + return; + }*/ + Map> entries = feature.getMapProperties(); 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 9894c98..e3191b3 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 @@ -10,15 +10,13 @@ import java.util.Map; import org.gcube.application.geoportal.client.legacy.ConcessioniManagerI; import org.gcube.application.geoportal.common.model.legacy.Concessione; +import org.gcube.application.geoportal.common.model.legacy.LayerConcessione; import org.gcube.application.geoportal.common.model.legacy.UploadedImage; import org.gcube.application.geoportalcommon.GeoNaDataViewerProfileReader; import org.gcube.application.geoportalcommon.GeoportalCommon; import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.LayerItem; -import org.gcube.common.authorization.library.provider.SecurityTokenProvider; -import org.gcube.common.portal.PortalContext; -import org.gcube.common.scope.api.ScopeProvider; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerService; import org.gcube.portlets.user.geoportaldataviewer.server.gis.FeatureParser; import org.gcube.portlets.user.geoportaldataviewer.server.gis.WMSUrlValidator; @@ -32,6 +30,7 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformation import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.Styles; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.ZAxis; import org.gcube.portlets.user.geoportaldataviewer.shared.products.ConcessioneDV; +import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.LayerConcessioneDV; import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.UploadedImageDV; import org.gcube.spatial.data.geoutility.GeoNcWMSMetadataUtility; import org.gcube.spatial.data.geoutility.bean.LayerStyles; @@ -227,6 +226,68 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme } + /** + * Gets the layers for id. + * + * @param itemType the item type + * @param itemId the item id + * @return the layers for id + * @throws Exception the exception + */ + @Override + public List getLayersForId(String itemType, String itemId) throws Exception { + LOG.info("getLayersForId [itemId: " + itemId + ", itemType: " + itemType + "] called"); + + if (itemType == null) + throw new Exception("Invalid parameter. The itemType is null"); + + if (itemId == null) + throw new Exception("Invalid parameter. The itemId is null"); + + List listLayers = null; + + try { + + SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); + + if (itemType.equalsIgnoreCase("concessione")) { + + LOG.info("Trying to get concessione for id " + itemId); + SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); + SessionUtil.getCurrentToken(this.getThreadLocalRequest(), true); + ConcessioniManagerI concessioniManager = statefulMongoConcessioni().build(); + Concessione concessione = concessioniManager.getById(itemId); + if (concessione != null) { + LOG.info("For id " + itemId + ", got concessione " + concessione.getNome() + " from service"); + listLayers = new ArrayList(); + if (concessione.getPianteFineScavo() != null) { + + for (LayerConcessione lc : concessione.getPianteFineScavo()) { + listLayers.add(ConvertToDataViewModel.toLayerConcessione(lc)); + } + } + + if (concessione.getPosizionamentoScavo() != null) { + LayerConcessioneDV thePosizScavo = ConvertToDataViewModel + .toLayerConcessione(concessione.getPosizionamentoScavo()); + if (thePosizScavo != null) + listLayers.add(thePosizScavo); + } + + } else + throw new Exception("Concessione with id '" + itemId + "' not available"); + } + LOG.info("For id " + itemId + ", returning " + listLayers.size() + " layer/s"); + return listLayers; + + } catch (Exception e) { + String erroMsg = "Layers are not available for " + Concessione.class.getSimpleName() + " with id " + itemId; + LOG.error(erroMsg, e); + throw new Exception(erroMsg); + } + + } + /** * Gets the concessione for id. * @@ -364,6 +425,13 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme return profile; } + /** + * Gets the public links for. + * + * @param item the item + * @return the public links for + * @throws Exception the exception + */ @Override public GeoNaItemRef getPublicLinksFor(GeoNaItemRef item) throws Exception { LOG.info("getPublicLinksFor called for: " + item); @@ -390,6 +458,12 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme } } + /** + * Checks if is session expired. + * + * @return true, if is session expired + * @throws Exception the exception + */ public boolean isSessionExpired() throws Exception { return SessionUtil.isSessionExpired(this.getThreadLocalRequest()); } -- 2.17.1 From 4b1071226cb26cd1c880faced01ce25f883008c2 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 2 Aug 2021 11:31:59 +0200 Subject: [PATCH 04/38] fixed css for image gallery --- src/main/webapp/GeoportalDataViewer.css | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/webapp/GeoportalDataViewer.css b/src/main/webapp/GeoportalDataViewer.css index 99a7645..dba823e 100644 --- a/src/main/webapp/GeoportalDataViewer.css +++ b/src/main/webapp/GeoportalDataViewer.css @@ -254,3 +254,14 @@ body { font-size: .9em !important; margin-bottom: 5px !important } + +.nGY2 .nGY2GThumbnailIcon { + Text-Shadow: none !important; + color: #696969 !important; +} + +.nGY2 .nGY2GThumbnailAlbumTitle, .nGY2 .nGY2GThumbnailImageTitle { + Text-Shadow: none !important; + color: #696969 !important; + font-family: arial !important; +} -- 2.17.1 From 9158437b2f5f49e4b7eb8e28daf4bbf412fb8661 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 2 Aug 2021 15:20:01 +0200 Subject: [PATCH 05/38] #20595 Porting and using the model view provided by geoportal-common --- .../com.gwtplugins.gwt.eclipse.core.prefs | 2 + .settings/org.eclipse.wst.common.component | 53 +- CHANGELOG.md | 1 + .../client/GeoportalDataViewer.java | 4 +- .../client/GeoportalDataViewerService.java | 8 +- .../GeoportalDataViewerServiceAsync.java | 8 +- .../client/LayerManager.java | 6 +- .../client/gis/LightOpenLayerOSM.java | 2 +- .../client/ui/DetailsPanel.java | 4 +- .../client/ui/GeonaDataViewMainPanel.java | 4 +- .../client/ui/gallery/ImagesGallery.java | 4 +- .../client/ui/images/ImageView.java | 4 +- .../client/ui/images/ThumbnailImageView.java | 2 +- .../client/ui/map/MapView.java | 2 +- .../client/ui/products/RecordView.java | 2 +- .../products/concessioni/ConcessioneView.java | 8 +- .../concessioni/LayerConcessioneView.java | 2 +- .../concessioni/RelazioneScavoView.java | 6 +- .../server/ConvertToDataViewModel.java | 988 +++++++++--------- .../GeoportalDataViewerServiceImpl.java | 11 +- .../server/gis/FeatureParser.java | 4 +- .../server/gis/GisMakers.java | 4 +- .../shared/GeoNaSpatialQueryResult.java | 2 +- .../shared/gis/BoundsMap.java | 170 --- .../shared/gis/LayerItem.java | 1 + .../shared/products/ConcessioneDV.java | 597 ----------- .../products/content/AssociatedContentDV.java | 202 ---- .../products/content/OtherContentDV.java | 41 - .../products/content/WorkspaceContentDV.java | 85 -- .../model/AbstractRelazioneScavoDV.java | 152 --- .../products/model/LayerConcessioneDV.java | 135 --- .../shared/products/model/RecordDV.java | 292 ------ .../products/model/RelazioneScavoDV.java | 125 --- .../products/model/SDILayerDescriptorDV.java | 143 --- .../products/model/UploadedImageDV.java | 141 --- .../geoportaldataviewer/GetConcessione.java | 4 +- 36 files changed, 587 insertions(+), 2632 deletions(-) create mode 100644 .settings/com.gwtplugins.gwt.eclipse.core.prefs delete mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/BoundsMap.java delete mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/ConcessioneDV.java delete mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/content/AssociatedContentDV.java delete mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/content/OtherContentDV.java delete mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/content/WorkspaceContentDV.java delete mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/model/AbstractRelazioneScavoDV.java delete mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/model/LayerConcessioneDV.java delete mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/model/RecordDV.java delete mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/model/RelazioneScavoDV.java delete mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/model/SDILayerDescriptorDV.java delete mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/model/UploadedImageDV.java diff --git a/.settings/com.gwtplugins.gwt.eclipse.core.prefs b/.settings/com.gwtplugins.gwt.eclipse.core.prefs new file mode 100644 index 0000000..65cc113 --- /dev/null +++ b/.settings/com.gwtplugins.gwt.eclipse.core.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +gwtSyncCodeServer=true diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 9ec4a78..de22390 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,5 +1,8 @@ - + + + + @@ -8,7 +11,10 @@ - + + + + @@ -17,7 +23,10 @@ - + + + + @@ -26,7 +35,10 @@ - + + + + @@ -35,17 +47,29 @@ - + + + + - + + + + - + + uses + + + + + @@ -54,14 +78,20 @@ - + + + + - + + + + @@ -70,7 +100,10 @@ - + + + + diff --git a/CHANGELOG.md b/CHANGELOG.md index e535cd1..f1d3320 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm #### Enhancements [#21890] Porting to ConcessioniManagerI and pass to mongoID +[#20595] Porting and using the model view provided by geoportal-common ## [v1.2.0-SNAPSHOT] - 2021-07-19 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 44d4936..566e5d0 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 @@ -5,6 +5,8 @@ import java.util.Iterator; import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.LayerItem; +import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; +import org.gcube.application.geoportalcommon.shared.products.model.RecordDV; import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEventHandler; import org.gcube.portlets.user.geoportaldataviewer.client.events.ClosedViewDetailsEvent; @@ -17,8 +19,6 @@ import org.gcube.portlets.user.geoportaldataviewer.client.events.ZoomOutOverMini import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils; import org.gcube.portlets.user.geoportaldataviewer.client.ui.GeonaDataViewMainPanel; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.ConcessioneDV; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.RecordDV; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.GWT; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java index 365edd1..6ed194f 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java @@ -4,13 +4,13 @@ import java.util.List; import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; +import org.gcube.application.geoportalcommon.shared.gis.BoundsMap; +import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; +import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV; +import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV; import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult; -import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformationForWMSRequest; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.ConcessioneDV; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.LayerConcessioneDV; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.UploadedImageDV; import com.google.gwt.user.client.rpc.RemoteService; import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java index 3ae9425..3e76450 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java @@ -4,13 +4,13 @@ import java.util.List; import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; +import org.gcube.application.geoportalcommon.shared.gis.BoundsMap; +import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; +import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV; +import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV; import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult; -import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformationForWMSRequest; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.ConcessioneDV; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.LayerConcessioneDV; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.UploadedImageDV; import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.rpc.AsyncCallback; 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 449ae55..ec4903a 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,6 +8,9 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +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.events.AddedLayerToMapEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEventHandler; @@ -20,7 +23,6 @@ import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerOSM; import org.gcube.portlets.user.geoportaldataviewer.client.util.StringUtil; import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil; import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult; -import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject; @@ -28,8 +30,6 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.FeatureRow; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.PointsPath; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformationForWMSRequest; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.ZAxis; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.content.WorkspaceContentDV; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.UploadedImageDV; import com.github.gwtbootstrap.client.ui.Button; import com.github.gwtbootstrap.client.ui.constants.ButtonType; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerOSM.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerOSM.java index b1803a4..4d62cb6 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerOSM.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerOSM.java @@ -1,8 +1,8 @@ package org.gcube.portlets.user.geoportaldataviewer.client.gis; +import org.gcube.application.geoportalcommon.shared.gis.BoundsMap; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants; import org.gcube.portlets.user.geoportaldataviewer.client.resources.Images; -import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery.TYPE; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/DetailsPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/DetailsPanel.java index 3b0f9d6..94b16cb 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/DetailsPanel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/DetailsPanel.java @@ -1,10 +1,10 @@ package org.gcube.portlets.user.geoportaldataviewer.client.ui; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; +import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; +import org.gcube.application.geoportalcommon.shared.products.model.RecordDV; import org.gcube.portlets.user.geoportaldataviewer.client.events.ClosedViewDetailsEvent; import org.gcube.portlets.user.geoportaldataviewer.client.ui.products.concessioni.ConcessioneView; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.ConcessioneDV; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.RecordDV; import com.github.gwtbootstrap.client.ui.Button; import com.github.gwtbootstrap.client.ui.constants.ButtonType; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java index 913d5ae..213420c 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java @@ -1,9 +1,9 @@ package org.gcube.portlets.user.geoportaldataviewer.client.ui; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; +import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; +import org.gcube.application.geoportalcommon.shared.products.model.RecordDV; import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerOSM; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.ConcessioneDV; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.RecordDV; import com.github.gwtbootstrap.client.ui.Button; import com.github.gwtbootstrap.client.ui.NavLink; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/gallery/ImagesGallery.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/gallery/ImagesGallery.java index d3effb0..414fb96 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/gallery/ImagesGallery.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/gallery/ImagesGallery.java @@ -2,8 +2,8 @@ package org.gcube.portlets.user.geoportaldataviewer.client.ui.gallery; import java.util.List; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.content.WorkspaceContentDV; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.UploadedImageDV; +import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceContentDV; +import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV; import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.json.client.JSONArray; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/images/ImageView.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/images/ImageView.java index bccd700..237fbea 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/images/ImageView.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/images/ImageView.java @@ -1,10 +1,10 @@ package org.gcube.portlets.user.geoportaldataviewer.client.ui.images; +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.ui.ModalWindow; import org.gcube.portlets.user.geoportaldataviewer.client.util.NewBrowserWindow; import org.gcube.portlets.user.geoportaldataviewer.client.util.StringUtil; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.content.WorkspaceContentDV; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.UploadedImageDV; import com.github.gwtbootstrap.client.ui.Button; import com.github.gwtbootstrap.client.ui.Heading; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/images/ThumbnailImageView.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/images/ThumbnailImageView.java index 9f45b7d..1ccd877 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/images/ThumbnailImageView.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/images/ThumbnailImageView.java @@ -1,7 +1,7 @@ package org.gcube.portlets.user.geoportaldataviewer.client.ui.images; +import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV; import org.gcube.portlets.user.geoportaldataviewer.client.util.StringUtil; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.UploadedImageDV; import com.google.gwt.core.client.GWT; import com.google.gwt.uibinder.client.UiBinder; 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 98580ff..0928059 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 @@ -1,10 +1,10 @@ package org.gcube.portlets.user.geoportaldataviewer.client.ui.map; +import org.gcube.application.geoportalcommon.shared.gis.BoundsMap; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants; import org.gcube.portlets.user.geoportaldataviewer.client.gis.ExtentWrapped; import org.gcube.portlets.user.geoportaldataviewer.client.gis.LightOpenLayerOSM; import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils; -import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap; import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.Scheduler; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/RecordView.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/RecordView.java index dd3f796..9d542c1 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/RecordView.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/RecordView.java @@ -1,7 +1,7 @@ package org.gcube.portlets.user.geoportaldataviewer.client.ui.products; +import org.gcube.application.geoportalcommon.shared.products.model.RecordDV; import org.gcube.portlets.user.geoportaldataviewer.client.ui.util.CustomFlexTable; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.RecordDV; import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.Style.Unit; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java index 40a115e..dfdb8b1 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java @@ -4,6 +4,10 @@ import java.util.ArrayList; import java.util.List; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; +import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; +import org.gcube.application.geoportalcommon.shared.products.model.AbstractRelazioneScavoDV; +import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV; +import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync; import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils; @@ -12,10 +16,6 @@ import org.gcube.portlets.user.geoportaldataviewer.client.ui.dialogs.DialogShare import org.gcube.portlets.user.geoportaldataviewer.client.ui.gallery.ImagesGallery; import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.MapView; import org.gcube.portlets.user.geoportaldataviewer.client.ui.util.CustomFlexTable; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.ConcessioneDV; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.AbstractRelazioneScavoDV; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.LayerConcessioneDV; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.UploadedImageDV; import com.github.gwtbootstrap.client.ui.Button; import com.github.gwtbootstrap.client.ui.PageHeader; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/LayerConcessioneView.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/LayerConcessioneView.java index 1ec2934..b36aeaa 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/LayerConcessioneView.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/LayerConcessioneView.java @@ -1,10 +1,10 @@ package org.gcube.portlets.user.geoportaldataviewer.client.ui.products.concessioni; +import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants; import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils; import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.MapView; import org.gcube.portlets.user.geoportaldataviewer.client.ui.util.CustomFlexTable; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.LayerConcessioneDV; import com.google.gwt.core.client.GWT; import com.google.gwt.uibinder.client.UiBinder; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/RelazioneScavoView.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/RelazioneScavoView.java index 1f59b35..efa1707 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/RelazioneScavoView.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/RelazioneScavoView.java @@ -2,11 +2,11 @@ package org.gcube.portlets.user.geoportaldataviewer.client.ui.products.concessio import java.util.List; +import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceContentDV; +import org.gcube.application.geoportalcommon.shared.products.model.AbstractRelazioneScavoDV; +import org.gcube.application.geoportalcommon.shared.products.model.RelazioneScavoDV; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants; import org.gcube.portlets.user.geoportaldataviewer.client.ui.util.CustomFlexTable; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.content.WorkspaceContentDV; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.AbstractRelazioneScavoDV; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.RelazioneScavoDV; import com.github.gwtbootstrap.client.ui.Button; import com.github.gwtbootstrap.client.ui.Paragraph; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConvertToDataViewModel.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConvertToDataViewModel.java index 3b72b83..12b8e65 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConvertToDataViewModel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConvertToDataViewModel.java @@ -1,499 +1,499 @@ -package org.gcube.portlets.user.geoportaldataviewer.server; - -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.ArrayList; -import java.util.List; - -import org.gcube.application.geoportal.common.model.legacy.AccessPolicy; -import org.gcube.application.geoportal.common.model.legacy.BBOX; -import org.gcube.application.geoportal.common.model.legacy.Concessione; -import org.gcube.application.geoportal.common.model.legacy.LayerConcessione; -import org.gcube.application.geoportal.common.model.legacy.OtherContent; -import org.gcube.application.geoportal.common.model.legacy.PersistedContent; -import org.gcube.application.geoportal.common.model.legacy.RelazioneScavo; -import org.gcube.application.geoportal.common.model.legacy.UploadedImage; -import org.gcube.application.geoportal.common.model.legacy.WorkspaceContent; -import org.gcube.portlets.user.geoportaldataviewer.server.util.URLParserUtil; -import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.ConcessioneDV; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.content.OtherContentDV; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.content.WorkspaceContentDV; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.AbstractRelazioneScavoDV; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.LayerConcessioneDV; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.RelazioneScavoDV; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.UploadedImageDV; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * The Class ConvertToGUIModel. - * - * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) - * - * Nov 2, 2020 - */ -public class ConvertToDataViewModel { - - private static final String NO_TIME = "T00:00"; - - /** The Constant LOG. */ - private static final Logger LOG = LoggerFactory.getLogger(ConvertToDataViewModel.class); - - public static final String DATE_FORMAT = "dd-MM-yyyy"; - - public static final String HOURS_MINUTES_SEPARATOR = ":"; - - public static final String TIME_FORMAT = "HH" + HOURS_MINUTES_SEPARATOR + "mm"; - - - /** - * To concessione. - * - * @param concessione the concessione - * @return the concessione - * @throws Exception the exception - */ - public static ConcessioneDV toConcessione(Concessione concessione) throws Exception { - LOG.debug("called toConcessione for: "+concessione); - - if (concessione == null) - return null; - - try { - - ConcessioneDV theConcessione = new ConcessioneDV(); - theConcessione.setPolicy(toPolicy(concessione.getPolicy())); - //theConcessione.setAuthors(concessione.getAuthors()); - theConcessione.setCentroidLat(concessione.getCentroidLat()); - theConcessione.setCentroidLong(concessione.getCentroidLong()); - theConcessione.setContributore(concessione.getContributore()); - theConcessione.setCreationTime(toDateFormatString(concessione.getCreationTime())); - theConcessione.setCreationUser(toUser(concessione.getCreationUser())); - theConcessione.setDataFineProgetto(toDateFormatString(concessione.getDataFineProgetto())); - theConcessione.setDataInizioProgetto(toDateFormatString(concessione.getDataInizioProgetto())); - theConcessione.setDescrizioneContenuto(concessione.getDescrizioneContenuto()); - theConcessione.setEditore(concessione.getEditore()); - theConcessione.setFontiFinanziamento(concessione.getFontiFinanziamento()); - theConcessione.setItemId(concessione.getMongo_id()); - theConcessione.setNome(concessione.getNome()); - - theConcessione.setIntroduzione(concessione.getIntroduzione()); - theConcessione.setLastUpdateTime(toDateFormatString(concessione.getLastUpdateTime())); - theConcessione.setLastUpdateUser(toUser(concessione.getLastUpdateUser())); - theConcessione.setLicenzaID(concessione.getLicenzaID()); - theConcessione.setNome(concessione.getNome()); - theConcessione.setParoleChiaveICCD(concessione.getParoleChiaveICCD()); - theConcessione.setParoleChiaveLibere(concessione.getParoleChiaveLibere()); - - theConcessione.setResponsabile(concessione.getResponsabile()); - theConcessione.setRisorseCorrelate(concessione.getRisorseCorrelate()); - theConcessione.setSoggetto(concessione.getSoggetto()); - theConcessione.setTitolariCopyright(concessione.getTitolareCopyright()); - theConcessione.setTitolariLicenza(concessione.getTitolareLicenza()); - theConcessione.setTitolari(concessione.getTitolari()); - theConcessione.setVersion(concessione.getVersion()); - - theConcessione.setRecordType(concessione.getRecordType().name()); - - theConcessione.setAbstractRelazioneScavo(toAbstractRelazioneScavo(concessione.getRelazioneScavo())); - theConcessione.setRelazioneScavo(toRelazioneScavo(concessione.getRelazioneScavo())); - - - if (concessione.getImmaginiRappresentative() != null) { - List uploadedImagesDV = new ArrayList( - concessione.getImmaginiRappresentative().size()); - for (UploadedImage ui : concessione.getImmaginiRappresentative()) { - uploadedImagesDV.add(toUploadedImage(ui)); - } - theConcessione.setImmaginiRappresentative(uploadedImagesDV); - } - - - if (concessione.getGenericContent() != null) { - List otherContentsDV = new ArrayList( - concessione.getGenericContent().size()); - for (OtherContent gc : concessione.getGenericContent()) { - otherContentsDV.add(toOtherContentDV(gc)); - } - theConcessione.setGenericContent(otherContentsDV); - } - - - if (concessione.getPianteFineScavo() != null) { - List piantaScavoDV = new ArrayList( - concessione.getPianteFineScavo().size()); - for (LayerConcessione lc : concessione.getPianteFineScavo()) { - piantaScavoDV.add(toLayerConcessione(lc)); - } - theConcessione.setPianteFineScavo(piantaScavoDV); - } - - if (concessione.getPosizionamentoScavo() != null) { - LayerConcessioneDV thePosizScavo = toLayerConcessione(concessione.getPosizionamentoScavo()); - theConcessione.setPosizionamentoScavo(thePosizScavo); - } - - - LOG.debug("Returning concessione: " + theConcessione); - return theConcessione; - }catch (Exception e) { - LOG.error("Error on converting concessione: "+concessione, e); - return null; - } - - } - - //TO AVOID SERIALIZATION ISSUE AGAINST GWT -// public static List toListString(List orginList){ -// if(orginList==null) +//package org.gcube.portlets.user.geoportaldataviewer.server; +// +//import java.time.LocalDateTime; +//import java.time.format.DateTimeFormatter; +//import java.util.ArrayList; +//import java.util.List; +// +//import org.gcube.application.geoportal.common.model.legacy.AccessPolicy; +//import org.gcube.application.geoportal.common.model.legacy.BBOX; +//import org.gcube.application.geoportal.common.model.legacy.Concessione; +//import org.gcube.application.geoportal.common.model.legacy.LayerConcessione; +//import org.gcube.application.geoportal.common.model.legacy.OtherContent; +//import org.gcube.application.geoportal.common.model.legacy.PersistedContent; +//import org.gcube.application.geoportal.common.model.legacy.RelazioneScavo; +//import org.gcube.application.geoportal.common.model.legacy.UploadedImage; +//import org.gcube.application.geoportal.common.model.legacy.WorkspaceContent; +//import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; +//import org.gcube.application.geoportalcommon.shared.products.content.OtherContentDV; +//import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceContentDV; +//import org.gcube.application.geoportalcommon.shared.products.model.AbstractRelazioneScavoDV; +//import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV; +//import org.gcube.application.geoportalcommon.shared.products.model.RelazioneScavoDV; +//import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV; +//import org.gcube.portlets.user.geoportaldataviewer.server.util.URLParserUtil; +//import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap; +//import org.slf4j.Logger; +//import org.slf4j.LoggerFactory; +// +///** +// * The Class ConvertToGUIModel. +// * +// * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) +// * +// * Nov 2, 2020 +// */ +//public class ConvertToDataViewModel { +// +// private static final String NO_TIME = "T00:00"; +// +// /** The Constant LOG. */ +// private static final Logger LOG = LoggerFactory.getLogger(ConvertToDataViewModel.class); +// +// public static final String DATE_FORMAT = "dd-MM-yyyy"; +// +// public static final String HOURS_MINUTES_SEPARATOR = ":"; +// +// public static final String TIME_FORMAT = "HH" + HOURS_MINUTES_SEPARATOR + "mm"; +// +// +// /** +// * To concessione. +// * +// * @param concessione the concessione +// * @return the concessione +// * @throws Exception the exception +// */ +// public static ConcessioneDV toConcessione(Concessione concessione) throws Exception { +// LOG.debug("called toConcessione for: "+concessione); +// +// if (concessione == null) // return null; // -// List destList = new ArrayList(orginList.size()); -// for (String orgValue : orginList) { -// destList.add(orgValue); +// try { +// +// ConcessioneDV theConcessione = new ConcessioneDV(); +// theConcessione.setPolicy(toPolicy(concessione.getPolicy())); +// //theConcessione.setAuthors(concessione.getAuthors()); +// theConcessione.setCentroidLat(concessione.getCentroidLat()); +// theConcessione.setCentroidLong(concessione.getCentroidLong()); +// theConcessione.setContributore(concessione.getContributore()); +// theConcessione.setCreationTime(toDateFormatString(concessione.getCreationTime())); +// theConcessione.setCreationUser(toUser(concessione.getCreationUser())); +// theConcessione.setDataFineProgetto(toDateFormatString(concessione.getDataFineProgetto())); +// theConcessione.setDataInizioProgetto(toDateFormatString(concessione.getDataInizioProgetto())); +// theConcessione.setDescrizioneContenuto(concessione.getDescrizioneContenuto()); +// theConcessione.setEditore(concessione.getEditore()); +// theConcessione.setFontiFinanziamento(concessione.getFontiFinanziamento()); +// theConcessione.setItemId(concessione.getMongo_id()); +// theConcessione.setNome(concessione.getNome()); +// +// theConcessione.setIntroduzione(concessione.getIntroduzione()); +// theConcessione.setLastUpdateTime(toDateFormatString(concessione.getLastUpdateTime())); +// theConcessione.setLastUpdateUser(toUser(concessione.getLastUpdateUser())); +// theConcessione.setLicenzaID(concessione.getLicenzaID()); +// theConcessione.setNome(concessione.getNome()); +// theConcessione.setParoleChiaveICCD(concessione.getParoleChiaveICCD()); +// theConcessione.setParoleChiaveLibere(concessione.getParoleChiaveLibere()); +// +// theConcessione.setResponsabile(concessione.getResponsabile()); +// theConcessione.setRisorseCorrelate(concessione.getRisorseCorrelate()); +// theConcessione.setSoggetto(concessione.getSoggetto()); +// theConcessione.setTitolariCopyright(concessione.getTitolareCopyright()); +// theConcessione.setTitolariLicenza(concessione.getTitolareLicenza()); +// theConcessione.setTitolari(concessione.getTitolari()); +// theConcessione.setVersion(concessione.getVersion()); +// +// theConcessione.setRecordType(concessione.getRecordType().name()); +// +// theConcessione.setAbstractRelazioneScavo(toAbstractRelazioneScavo(concessione.getRelazioneScavo())); +// theConcessione.setRelazioneScavo(toRelazioneScavo(concessione.getRelazioneScavo())); +// +// +// if (concessione.getImmaginiRappresentative() != null) { +// List uploadedImagesDV = new ArrayList( +// concessione.getImmaginiRappresentative().size()); +// for (UploadedImage ui : concessione.getImmaginiRappresentative()) { +// uploadedImagesDV.add(toUploadedImage(ui)); +// } +// theConcessione.setImmaginiRappresentative(uploadedImagesDV); +// } +// +// +// if (concessione.getGenericContent() != null) { +// List otherContentsDV = new ArrayList( +// concessione.getGenericContent().size()); +// for (OtherContent gc : concessione.getGenericContent()) { +// otherContentsDV.add(toOtherContentDV(gc)); +// } +// theConcessione.setGenericContent(otherContentsDV); +// } +// +// +// if (concessione.getPianteFineScavo() != null) { +// List piantaScavoDV = new ArrayList( +// concessione.getPianteFineScavo().size()); +// for (LayerConcessione lc : concessione.getPianteFineScavo()) { +// piantaScavoDV.add(toLayerConcessione(lc)); +// } +// theConcessione.setPianteFineScavo(piantaScavoDV); +// } +// +// if (concessione.getPosizionamentoScavo() != null) { +// LayerConcessioneDV thePosizScavo = toLayerConcessione(concessione.getPosizionamentoScavo()); +// theConcessione.setPosizionamentoScavo(thePosizScavo); +// } +// +// +// LOG.debug("Returning concessione: " + theConcessione); +// return theConcessione; +// }catch (Exception e) { +// LOG.error("Error on converting concessione: "+concessione, e); +// return null; +// } +// +// } +// +// //TO AVOID SERIALIZATION ISSUE AGAINST GWT +//// public static List toListString(List orginList){ +//// if(orginList==null) +//// return null; +//// +//// List destList = new ArrayList(orginList.size()); +//// for (String orgValue : orginList) { +//// destList.add(orgValue); +//// } +//// +//// return destList; +//// } +// +// /** +// * To user. +// * +// * @param username the username +// * @return the string +// */ +// public static String toUser(String username) { +// +// if(username==null) +// return null; +// +// return username; +// +// } +// +// /** +// * To policy. +// * +// * @param policy the policy +// * @return the string +// */ +// public static String toPolicy(AccessPolicy policy) { +// +// if(policy==null) +// return null; +// +// return policy.name(); +// +// } +// +// /** +// * To date format string. +// * +// * @param dateTime the date time +// * @return the string +// */ +// public static String toDateFormatString(LocalDateTime dateTime) { +// +// if(dateTime==null) +// return null; +// +// String time = dateTime.toString(); +// DateTimeFormatter formatter = null; +// try { +// if(!time.endsWith(NO_TIME)) { +// formatter = DateTimeFormatter.ofPattern(DATE_FORMAT + " " + TIME_FORMAT); +// }else { +// time = time.replace(NO_TIME, ""); +// formatter = DateTimeFormatter.ofPattern(DATE_FORMAT); +// } +// }catch (Exception e) { +// LOG.warn("Parsing error: ",e); // } // -// return destList; +// try { +// if(formatter!=null) +// return dateTime.format(formatter); +// }catch (Exception e) { +// LOG.warn("Date format error: ",e); +// } +// +// return dateTime.toString(); // } - - /** - * To user. - * - * @param username the username - * @return the string - */ - public static String toUser(String username) { - - if(username==null) - return null; - - return username; - - } - - /** - * To policy. - * - * @param policy the policy - * @return the string - */ - public static String toPolicy(AccessPolicy policy) { - - if(policy==null) - return null; - - return policy.name(); - - } - - /** - * To date format string. - * - * @param dateTime the date time - * @return the string - */ - public static String toDateFormatString(LocalDateTime dateTime) { - - if(dateTime==null) - return null; - - String time = dateTime.toString(); - DateTimeFormatter formatter = null; - try { - if(!time.endsWith(NO_TIME)) { - formatter = DateTimeFormatter.ofPattern(DATE_FORMAT + " " + TIME_FORMAT); - }else { - time = time.replace(NO_TIME, ""); - formatter = DateTimeFormatter.ofPattern(DATE_FORMAT); - } - }catch (Exception e) { - LOG.warn("Parsing error: ",e); - } - - try { - if(formatter!=null) - return dateTime.format(formatter); - }catch (Exception e) { - LOG.warn("Date format error: ",e); - } - - return dateTime.toString(); - } - - /** - * To abstract relazione scavo. - * - * @param relazioneScavo the relazione scavo - * @return the abstract relazione scavo DV - */ - public static AbstractRelazioneScavoDV toAbstractRelazioneScavo(RelazioneScavo relazioneScavo) { - - if (relazioneScavo == null) - return null; - - AbstractRelazioneScavoDV theRelazioneDiScavo = new AbstractRelazioneScavoDV(); - theRelazioneDiScavo.setAbstractSectionIta(relazioneScavo.getAbstractIta()); - theRelazioneDiScavo.setAbstractSectionEng(relazioneScavo.getAbstractEng()); - - theRelazioneDiScavo.setCreationTime(toDateFormatString(relazioneScavo.getCreationTime())); - theRelazioneDiScavo.setId(relazioneScavo.getId()); - theRelazioneDiScavo.setLicenseID(relazioneScavo.getLicenseID()); - theRelazioneDiScavo.setPolicy(toPolicy(relazioneScavo.getPolicy())); - //theRelazioneDiScavo.setRecord(recordDV); - theRelazioneDiScavo.setResponsabili(relazioneScavo.getResponsabili()); - theRelazioneDiScavo.setSoggetto(relazioneScavo.getSoggetto()); - theRelazioneDiScavo.setTitolo(relazioneScavo.getTitolo()); - - LOG.debug("Returning: " + theRelazioneDiScavo); - return theRelazioneDiScavo; - } - - /** - * To relazione scavo. - * - * @param relazioneScavo the relazione scavo - * @return the relazione scavo data view - */ - public static RelazioneScavoDV toRelazioneScavo(RelazioneScavo relazioneScavo) { - - if (relazioneScavo == null) - return null; - - RelazioneScavoDV theRelazioneDiScavo = new RelazioneScavoDV(); - theRelazioneDiScavo.setCreationTime(toDateFormatString(relazioneScavo.getCreationTime())); - theRelazioneDiScavo.setId(relazioneScavo.getId()); - theRelazioneDiScavo.setLicenseID(relazioneScavo.getLicenseID()); - theRelazioneDiScavo.setPolicy(toPolicy(relazioneScavo.getPolicy())); - //theRelazioneDiScavo.setRecord(recordDV); - theRelazioneDiScavo.setResponsabili(relazioneScavo.getResponsabili()); - theRelazioneDiScavo.setSoggetto(relazioneScavo.getSoggetto()); - theRelazioneDiScavo.setTitolo(relazioneScavo.getTitolo()); - - List actContent = relazioneScavo.getActualContent(); - if(actContent!=null && actContent.size()>0) { - List listWsContent = new ArrayList(); - - for (PersistedContent content : actContent) { - if(content!=null && content instanceof WorkspaceContent) { - listWsContent.add(toWorkspaceContent((WorkspaceContent)content)); - } - } - theRelazioneDiScavo.setListWsContent(listWsContent); - } - - LOG.debug("Returning: " + theRelazioneDiScavo); - return theRelazioneDiScavo; - } - - /** - * To uploaded image. - * - * @param uploadedImage the uploaded image - * @return the uploaded image data-view - */ - public static UploadedImageDV toUploadedImage(UploadedImage uploadedImage) { - - if (uploadedImage == null) - return null; - - UploadedImageDV theUploadedImageDV = new UploadedImageDV(); - theUploadedImageDV.setCreationTime(toDateFormatString(uploadedImage.getCreationTime())); - theUploadedImageDV.setDidascalia(uploadedImage.getDidascalia()); - theUploadedImageDV.setFormat(uploadedImage.getFormat()); - theUploadedImageDV.setId(uploadedImage.getId()); - theUploadedImageDV.setLicenseID(uploadedImage.getLicenseID()); - theUploadedImageDV.setPolicy(toPolicy(uploadedImage.getPolicy())); - //theUploadedImageDV.setRecord(recordDV); - theUploadedImageDV.setResponsabili(uploadedImage.getResponsabili()); - theUploadedImageDV.setSoggetto(uploadedImage.getSoggetto()); - theUploadedImageDV.setTitolo(uploadedImage.getTitolo()); - - List actContent = uploadedImage.getActualContent(); - if(actContent!=null && actContent.size()>0) { - List listWsContent = new ArrayList(); - - for (PersistedContent content : actContent) { - if(content!=null && content instanceof WorkspaceContent) { - listWsContent.add(toWorkspaceContent((WorkspaceContent)content)); - } - } - theUploadedImageDV.setListWsContent(listWsContent); - } - - LOG.debug("Returning: " + theUploadedImageDV); - return theUploadedImageDV; - } - - - /** - * To workspace content. - * - * @param wContent the w content - * @return the workspace content DV - */ - public static WorkspaceContentDV toWorkspaceContent(WorkspaceContent wContent){ - if (wContent == null) - return null; - - WorkspaceContentDV theWSDV = new WorkspaceContentDV(); - theWSDV.setLink(wContent.getLink()); - theWSDV.setMimetype(wContent.getMimetype()); - theWSDV.setStorageID(wContent.getStorageID()); - theWSDV.setId(wContent.getId()); - - return theWSDV; - } - - /** - * To layer concessione. - * - * @param layerConcessione the layer concessione - * @return the layer concessione data view - */ - public static LayerConcessioneDV toLayerConcessione(LayerConcessione layerConcessione) { - - if (layerConcessione == null) - return null; - - LOG.debug("Converting: "+layerConcessione); - LayerConcessioneDV theLayerConessione = new LayerConcessioneDV(); - theLayerConessione.setAbstractSection(layerConcessione.getAbstractSection()); - - String wmsLink = layerConcessione.getWmsLink(); - String layerName = null; - BoundsMap bounds = null; - - //reading layer name from wmsLink - //string bbox - if(wmsLink!=null) { - layerName = URLParserUtil.extractValueOfParameterFromURL("layers", wmsLink); - String bbox = URLParserUtil.extractValueOfParameterFromURL("bbox", wmsLink); - String wmsVersion = URLParserUtil.extractValueOfParameterFromURL("version", wmsLink); - bounds = toBoundMap(wmsVersion, bbox, ","); - LOG.debug("Built bounds from wmsLInk: "+bounds); - } - - if(layerName!=null) - theLayerConessione.setLayerName(layerName); - else - theLayerConessione.setLayerName(layerConcessione.getLayerName()); - - - theLayerConessione.setWmsLink(wmsLink); - theLayerConessione.setLayerID(layerConcessione.getLayerID()); - theLayerConessione.setLayerUUID(layerConcessione.getLayerUUID()); - theLayerConessione.setAuthors(layerConcessione.getAuthors()); - - if(bounds==null) - bounds = toBoundMap(layerConcessione.getBbox()); - - theLayerConessione.setBbox(bounds); - theLayerConessione.setCreationTime(toDateFormatString(layerConcessione.getCreationTime())); - theLayerConessione.setId(layerConcessione.getId()); - theLayerConessione.setLicenseID(layerConcessione.getLicenseID()); - theLayerConessione.setMetodoRaccoltaDati(layerConcessione.getMetodoRaccoltaDati()); - theLayerConessione.setPolicy(toPolicy(layerConcessione.getPolicy())); - //theLayerConessione.setRecord(recordDV); - theLayerConessione.setScalaAcquisizione(layerConcessione.getScalaAcquisizione()); - theLayerConessione.setSubTopic(layerConcessione.getSubTopic()); - theLayerConessione.setTitolo(layerConcessione.getTitolo()); - theLayerConessione.setTopicCategory(layerConcessione.getTopicCategory()); - theLayerConessione.setValutazioneQualita(layerConcessione.getValutazioneQualita()); - - - LOG.debug("Returning: " + theLayerConessione); - return theLayerConessione; - - } - - /** - * To other content DV. - * - * @param otherContent the other content - * @return the other content DV - */ - public static OtherContentDV toOtherContentDV(OtherContent otherContent) { - - if (otherContent == null) - return null; - - OtherContentDV theOtherContent = new OtherContentDV(); - theOtherContent.setCreationTime(toDateFormatString(otherContent.getCreationTime())); - theOtherContent.setId(otherContent.getId()); - theOtherContent.setLicenseID(otherContent.getLicenseID()); - theOtherContent.setPolicy(toPolicy(otherContent.getPolicy())); - //theOtherContent.setRecord(recordDV); - theOtherContent.setTitolo(otherContent.getTitolo()); - - return theOtherContent; - } - - /** - * To bound map. - * - * @param bbox the bbox - * @return the bounds map - */ - public static BoundsMap toBoundMap(BBOX bbox) { - - if (bbox == null) - return null; - - return new BoundsMap(bbox.getMinLong(), bbox.getMinLat(), bbox.getMaxLong(), bbox.getMaxLat(), null); - } - - - /** - * To bound map. - * - * @param wmsVersion the wms version - * @param bbox the bbox - * @param separator the separator - * @return the bounds map - */ - public static BoundsMap toBoundMap(String wmsVersion, String bbox, String separator) { - - if (bbox == null) - return null; - - if(wmsVersion==null) - return null; - - if(separator==null) - separator = ","; - - try { - - String[] bboxArr = bbox.split(separator); - - if(wmsVersion.startsWith("1.3")) { - //is 1.3.x - return new BoundsMap(toDouble(bboxArr[1]), toDouble(bboxArr[0]), toDouble(bboxArr[3]), toDouble(bboxArr[2]), wmsVersion); - }else { - //should be 1.1.X - return new BoundsMap(toDouble(bboxArr[0]), toDouble(bboxArr[1]), toDouble(bboxArr[2]), toDouble(bboxArr[3]), wmsVersion); - } - }catch (Exception e) { - LOG.warn("Error on creating Bounds for wmsVersion "+wmsVersion+" and bbox "+bbox+" : ",e); - return null; - } - } - - /** - * To double. - * - * @param value the value - * @return the double - */ - public static Double toDouble(String value) { - try { - return Double.parseDouble(value); - }catch (Exception e) { - LOG.warn("Error on parsing "+value+" as double: ",e); - return null; - } - } - - -} +// +// /** +// * To abstract relazione scavo. +// * +// * @param relazioneScavo the relazione scavo +// * @return the abstract relazione scavo DV +// */ +// public static AbstractRelazioneScavoDV toAbstractRelazioneScavo(RelazioneScavo relazioneScavo) { +// +// if (relazioneScavo == null) +// return null; +// +// AbstractRelazioneScavoDV theRelazioneDiScavo = new AbstractRelazioneScavoDV(); +// theRelazioneDiScavo.setAbstractSectionIta(relazioneScavo.getAbstractIta()); +// theRelazioneDiScavo.setAbstractSectionEng(relazioneScavo.getAbstractEng()); +// +// theRelazioneDiScavo.setCreationTime(toDateFormatString(relazioneScavo.getCreationTime())); +// theRelazioneDiScavo.setId(relazioneScavo.getId()); +// theRelazioneDiScavo.setLicenseID(relazioneScavo.getLicenseID()); +// theRelazioneDiScavo.setPolicy(toPolicy(relazioneScavo.getPolicy())); +// //theRelazioneDiScavo.setRecord(recordDV); +// theRelazioneDiScavo.setResponsabili(relazioneScavo.getResponsabili()); +// theRelazioneDiScavo.setSoggetto(relazioneScavo.getSoggetto()); +// theRelazioneDiScavo.setTitolo(relazioneScavo.getTitolo()); +// +// LOG.debug("Returning: " + theRelazioneDiScavo); +// return theRelazioneDiScavo; +// } +// +// /** +// * To relazione scavo. +// * +// * @param relazioneScavo the relazione scavo +// * @return the relazione scavo data view +// */ +// public static RelazioneScavoDV toRelazioneScavo(RelazioneScavo relazioneScavo) { +// +// if (relazioneScavo == null) +// return null; +// +// RelazioneScavoDV theRelazioneDiScavo = new RelazioneScavoDV(); +// theRelazioneDiScavo.setCreationTime(toDateFormatString(relazioneScavo.getCreationTime())); +// theRelazioneDiScavo.setId(relazioneScavo.getId()); +// theRelazioneDiScavo.setLicenseID(relazioneScavo.getLicenseID()); +// theRelazioneDiScavo.setPolicy(toPolicy(relazioneScavo.getPolicy())); +// //theRelazioneDiScavo.setRecord(recordDV); +// theRelazioneDiScavo.setResponsabili(relazioneScavo.getResponsabili()); +// theRelazioneDiScavo.setSoggetto(relazioneScavo.getSoggetto()); +// theRelazioneDiScavo.setTitolo(relazioneScavo.getTitolo()); +// +// List actContent = relazioneScavo.getActualContent(); +// if(actContent!=null && actContent.size()>0) { +// List listWsContent = new ArrayList(); +// +// for (PersistedContent content : actContent) { +// if(content!=null && content instanceof WorkspaceContent) { +// listWsContent.add(toWorkspaceContent((WorkspaceContent)content)); +// } +// } +// theRelazioneDiScavo.setListWsContent(listWsContent); +// } +// +// LOG.debug("Returning: " + theRelazioneDiScavo); +// return theRelazioneDiScavo; +// } +// +// /** +// * To uploaded image. +// * +// * @param uploadedImage the uploaded image +// * @return the uploaded image data-view +// */ +// public static UploadedImageDV toUploadedImage(UploadedImage uploadedImage) { +// +// if (uploadedImage == null) +// return null; +// +// UploadedImageDV theUploadedImageDV = new UploadedImageDV(); +// theUploadedImageDV.setCreationTime(toDateFormatString(uploadedImage.getCreationTime())); +// theUploadedImageDV.setDidascalia(uploadedImage.getDidascalia()); +// theUploadedImageDV.setFormat(uploadedImage.getFormat()); +// theUploadedImageDV.setId(uploadedImage.getId()); +// theUploadedImageDV.setLicenseID(uploadedImage.getLicenseID()); +// theUploadedImageDV.setPolicy(toPolicy(uploadedImage.getPolicy())); +// //theUploadedImageDV.setRecord(recordDV); +// theUploadedImageDV.setResponsabili(uploadedImage.getResponsabili()); +// theUploadedImageDV.setSoggetto(uploadedImage.getSoggetto()); +// theUploadedImageDV.setTitolo(uploadedImage.getTitolo()); +// +// List actContent = uploadedImage.getActualContent(); +// if(actContent!=null && actContent.size()>0) { +// List listWsContent = new ArrayList(); +// +// for (PersistedContent content : actContent) { +// if(content!=null && content instanceof WorkspaceContent) { +// listWsContent.add(toWorkspaceContent((WorkspaceContent)content)); +// } +// } +// theUploadedImageDV.setListWsContent(listWsContent); +// } +// +// LOG.debug("Returning: " + theUploadedImageDV); +// return theUploadedImageDV; +// } +// +// +// /** +// * To workspace content. +// * +// * @param wContent the w content +// * @return the workspace content DV +// */ +// public static WorkspaceContentDV toWorkspaceContent(WorkspaceContent wContent){ +// if (wContent == null) +// return null; +// +// WorkspaceContentDV theWSDV = new WorkspaceContentDV(); +// theWSDV.setLink(wContent.getLink()); +// theWSDV.setMimetype(wContent.getMimetype()); +// theWSDV.setStorageID(wContent.getStorageID()); +// theWSDV.setId(wContent.getId()); +// +// return theWSDV; +// } +// +// /** +// * To layer concessione. +// * +// * @param layerConcessione the layer concessione +// * @return the layer concessione data view +// */ +// public static LayerConcessioneDV toLayerConcessione(LayerConcessione layerConcessione) { +// +// if (layerConcessione == null) +// return null; +// +// LOG.debug("Converting: "+layerConcessione); +// LayerConcessioneDV theLayerConessione = new LayerConcessioneDV(); +// theLayerConessione.setAbstractSection(layerConcessione.getAbstractSection()); +// +// String wmsLink = layerConcessione.getWmsLink(); +// String layerName = null; +// BoundsMap bounds = null; +// +// //reading layer name from wmsLink +// //string bbox +// if(wmsLink!=null) { +// layerName = URLParserUtil.extractValueOfParameterFromURL("layers", wmsLink); +// String bbox = URLParserUtil.extractValueOfParameterFromURL("bbox", wmsLink); +// String wmsVersion = URLParserUtil.extractValueOfParameterFromURL("version", wmsLink); +// bounds = toBoundMap(wmsVersion, bbox, ","); +// LOG.debug("Built bounds from wmsLInk: "+bounds); +// } +// +// if(layerName!=null) +// theLayerConessione.setLayerName(layerName); +// else +// theLayerConessione.setLayerName(layerConcessione.getLayerName()); +// +// +// theLayerConessione.setWmsLink(wmsLink); +// theLayerConessione.setLayerID(layerConcessione.getLayerID()); +// theLayerConessione.setLayerUUID(layerConcessione.getLayerUUID()); +// theLayerConessione.setAuthors(layerConcessione.getAuthors()); +// +// if(bounds==null) +// bounds = toBoundMap(layerConcessione.getBbox()); +// +// theLayerConessione.setBbox(bounds); +// theLayerConessione.setCreationTime(toDateFormatString(layerConcessione.getCreationTime())); +// theLayerConessione.setId(layerConcessione.getId()); +// theLayerConessione.setLicenseID(layerConcessione.getLicenseID()); +// theLayerConessione.setMetodoRaccoltaDati(layerConcessione.getMetodoRaccoltaDati()); +// theLayerConessione.setPolicy(toPolicy(layerConcessione.getPolicy())); +// //theLayerConessione.setRecord(recordDV); +// theLayerConessione.setScalaAcquisizione(layerConcessione.getScalaAcquisizione()); +// theLayerConessione.setSubTopic(layerConcessione.getSubTopic()); +// theLayerConessione.setTitolo(layerConcessione.getTitolo()); +// theLayerConessione.setTopicCategory(layerConcessione.getTopicCategory()); +// theLayerConessione.setValutazioneQualita(layerConcessione.getValutazioneQualita()); +// +// +// LOG.debug("Returning: " + theLayerConessione); +// return theLayerConessione; +// +// } +// +// /** +// * To other content DV. +// * +// * @param otherContent the other content +// * @return the other content DV +// */ +// public static OtherContentDV toOtherContentDV(OtherContent otherContent) { +// +// if (otherContent == null) +// return null; +// +// OtherContentDV theOtherContent = new OtherContentDV(); +// theOtherContent.setCreationTime(toDateFormatString(otherContent.getCreationTime())); +// theOtherContent.setId(otherContent.getId()); +// theOtherContent.setLicenseID(otherContent.getLicenseID()); +// theOtherContent.setPolicy(toPolicy(otherContent.getPolicy())); +// //theOtherContent.setRecord(recordDV); +// theOtherContent.setTitolo(otherContent.getTitolo()); +// +// return theOtherContent; +// } +// +// /** +// * To bound map. +// * +// * @param bbox the bbox +// * @return the bounds map +// */ +// public static BoundsMap toBoundMap(BBOX bbox) { +// +// if (bbox == null) +// return null; +// +// return new BoundsMap(bbox.getMinLong(), bbox.getMinLat(), bbox.getMaxLong(), bbox.getMaxLat(), null); +// } +// +// +// /** +// * To bound map. +// * +// * @param wmsVersion the wms version +// * @param bbox the bbox +// * @param separator the separator +// * @return the bounds map +// */ +// public static BoundsMap toBoundMap(String wmsVersion, String bbox, String separator) { +// +// if (bbox == null) +// return null; +// +// if(wmsVersion==null) +// return null; +// +// if(separator==null) +// separator = ","; +// +// try { +// +// String[] bboxArr = bbox.split(separator); +// +// if(wmsVersion.startsWith("1.3")) { +// //is 1.3.x +// return new BoundsMap(toDouble(bboxArr[1]), toDouble(bboxArr[0]), toDouble(bboxArr[3]), toDouble(bboxArr[2]), wmsVersion); +// }else { +// //should be 1.1.X +// return new BoundsMap(toDouble(bboxArr[0]), toDouble(bboxArr[1]), toDouble(bboxArr[2]), toDouble(bboxArr[3]), wmsVersion); +// } +// }catch (Exception e) { +// LOG.warn("Error on creating Bounds for wmsVersion "+wmsVersion+" and bbox "+bbox+" : ",e); +// return null; +// } +// } +// +// /** +// * To double. +// * +// * @param value the value +// * @return the double +// */ +// public static Double toDouble(String value) { +// try { +// return Double.parseDouble(value); +// }catch (Exception e) { +// LOG.warn("Error on parsing "+value+" as double: ",e); +// return null; +// } +// } +// +// +//} 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 e3191b3..aad93aa 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 @@ -12,26 +12,27 @@ import org.gcube.application.geoportal.client.legacy.ConcessioniManagerI; import org.gcube.application.geoportal.common.model.legacy.Concessione; import org.gcube.application.geoportal.common.model.legacy.LayerConcessione; import org.gcube.application.geoportal.common.model.legacy.UploadedImage; +import org.gcube.application.geoportalcommon.ConvertToDataViewModel; import org.gcube.application.geoportalcommon.GeoNaDataViewerProfileReader; import org.gcube.application.geoportalcommon.GeoportalCommon; import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.LayerItem; +import org.gcube.application.geoportalcommon.shared.gis.BoundsMap; +import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; +import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV; +import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV; +import org.gcube.application.geoportalcommon.util.URLParserUtil; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerService; import org.gcube.portlets.user.geoportaldataviewer.server.gis.FeatureParser; import org.gcube.portlets.user.geoportaldataviewer.server.gis.WMSUrlValidator; import org.gcube.portlets.user.geoportaldataviewer.server.util.SessionUtil; -import org.gcube.portlets.user.geoportaldataviewer.server.util.URLParserUtil; import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult; -import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.FeatureRow; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformationForWMSRequest; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.Styles; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.ZAxis; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.ConcessioneDV; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.LayerConcessioneDV; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.UploadedImageDV; import org.gcube.spatial.data.geoutility.GeoNcWMSMetadataUtility; import org.gcube.spatial.data.geoutility.bean.LayerStyles; import org.gcube.spatial.data.geoutility.bean.LayerZAxis; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/gis/FeatureParser.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/gis/FeatureParser.java index a50cf28..fa3362b 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/gis/FeatureParser.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/gis/FeatureParser.java @@ -15,9 +15,9 @@ import java.util.List; import java.util.Map; import org.apache.commons.io.IOUtils; +import org.gcube.application.geoportalcommon.shared.gis.BoundsMap; +import org.gcube.application.geoportalcommon.util.URLParserUtil; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants; -import org.gcube.portlets.user.geoportaldataviewer.server.util.URLParserUtil; -import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.Coordinate; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.FeatureGeometry; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/gis/GisMakers.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/gis/GisMakers.java index ef156f6..24469bf 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/gis/GisMakers.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/gis/GisMakers.java @@ -1,8 +1,8 @@ package org.gcube.portlets.user.geoportaldataviewer.server.gis; +import org.gcube.application.geoportalcommon.shared.gis.BoundsMap; +import org.gcube.application.geoportalcommon.util.URLParserUtil; import org.gcube.portlets.user.geoportaldataviewer.server.gis.MapServerRecognize.SERVERTYPE; -import org.gcube.portlets.user.geoportaldataviewer.server.util.URLParserUtil; -import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem; import org.slf4j.Logger; import org.slf4j.LoggerFactory; 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 e4f4271..6decadf 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,9 +4,9 @@ import java.io.Serializable; import java.util.List; import java.util.Map; +import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.FeatureRow; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.UploadedImageDV; /** diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/BoundsMap.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/BoundsMap.java deleted file mode 100644 index ddc284a..0000000 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/BoundsMap.java +++ /dev/null @@ -1,170 +0,0 @@ -package org.gcube.portlets.user.geoportaldataviewer.shared.gis; - -import java.io.Serializable; - -/** - * The Class BoundsMap. - * - * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) - * - * Oct 27, 2020 - */ -public class BoundsMap implements Serializable{ - - - /** - * - */ - private static final long serialVersionUID = 69005924452960006L; - - /** The lower left X. */ - private double lowerLeftX = 0.0; - - /** The lower left Y. */ - private double lowerLeftY = 0.0; - - /** The upper right X. */ - private double upperRightX = 0.0; - - /** The upper right Y. */ - private double upperRightY = 0.0; - - /** The crs. */ - private String crs = ""; - - - - /** - * Instantiates a new bounds map. - */ - public BoundsMap() { - } - - /** - * Instantiates a new bounds map. - * - * @param lowerLeftX the lower left X - * @param lowerLeftY the lower left Y - * @param upperRightX the upper right X - * @param upperRightY the upper right Y - * @param crs the crs - */ - public BoundsMap(double lowerLeftX, double lowerLeftY, double upperRightX, - double upperRightY, String crs) { - super(); - this.lowerLeftX = lowerLeftX; - this.lowerLeftY = lowerLeftY; - this.upperRightX = upperRightX; - this.upperRightY = upperRightY; - this.crs = crs; - } - - /** - * Gets the lower left X. - * - * @return the lower left X - */ - public double getLowerLeftX() { - return lowerLeftX; - } - - /** - * Sets the lower left X. - * - * @param lowerLeftX the new lower left X - */ - public void setLowerLeftX(double lowerLeftX) { - this.lowerLeftX = lowerLeftX; - } - - /** - * Gets the lower left Y. - * - * @return the lower left Y - */ - public double getLowerLeftY() { - return lowerLeftY; - } - - /** - * Sets the lower left Y. - * - * @param lowerLeftY the new lower left Y - */ - public void setLowerLeftY(double lowerLeftY) { - this.lowerLeftY = lowerLeftY; - } - - /** - * Gets the upper right X. - * - * @return the upper right X - */ - public double getUpperRightX() { - return upperRightX; - } - - /** - * Sets the upper right X. - * - * @param upperRightX the new upper right X - */ - public void setUpperRightX(double upperRightX) { - this.upperRightX = upperRightX; - } - - /** - * Gets the upper right Y. - * - * @return the upper right Y - */ - public double getUpperRightY() { - return upperRightY; - } - - /** - * Sets the upper right Y. - * - * @param upperRightY the new upper right Y - */ - public void setUpperRightY(double upperRightY) { - this.upperRightY = upperRightY; - } - - /** - * Gets the crs. - * - * @return the crs - */ - public String getCrs() { - return crs; - } - - /** - * Sets the crs. - * - * @param crs the new crs - */ - public void setCrs(String crs) { - this.crs = crs; - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("BoundsMap [lowerLeftX="); - builder.append(lowerLeftX); - builder.append(", lowerLeftY="); - builder.append(lowerLeftY); - builder.append(", upperRightX="); - builder.append(upperRightX); - builder.append(", upperRightY="); - builder.append(upperRightY); - builder.append(", crs="); - builder.append(crs); - builder.append("]"); - return builder.toString(); - } - - -} 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 c2cbd5e..c4feff4 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 @@ -5,6 +5,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import org.gcube.application.geoportalcommon.shared.gis.BoundsMap; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.Property; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.ZAxis; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/ConcessioneDV.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/ConcessioneDV.java deleted file mode 100644 index 18a172d..0000000 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/ConcessioneDV.java +++ /dev/null @@ -1,597 +0,0 @@ -package org.gcube.portlets.user.geoportaldataviewer.shared.products; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -import org.gcube.portlets.user.geoportaldataviewer.shared.products.content.OtherContentDV; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.AbstractRelazioneScavoDV; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.LayerConcessioneDV; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.RecordDV; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.RelazioneScavoDV; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.UploadedImageDV; - -import com.google.gwt.user.client.rpc.IsSerializable; - -/** - * The Class ConcessioneDV. - * - * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) - * - * Nov 4, 2020 - */ -public class ConcessioneDV extends RecordDV implements Serializable, IsSerializable { - - /** - * - */ - private static final long serialVersionUID = 1387327199157005059L; - - /** The introduzione. */ - private String introduzione; - - /** The descrizione contenuto. */ - private String descrizioneContenuto; - - /** The authors. */ - private List authors; - - /** The contributore. */ - private String contributore; - - /** The titolari. */ - private List titolari; - - /** The responsabile. */ - private String responsabile; - - /** The editore. */ - private String editore; - - /** The fonti finanziamento. */ - private List fontiFinanziamento; - - /** The soggetto. */ - private List soggetto; - - /** The risorse correlate. */ - private List risorseCorrelate; - - /** The data inizio progetto. */ - private String dataInizioProgetto; - - /** The data fine progetto. */ - private String dataFineProgetto; - - /** The titolare licenza. */ - private List titolariLicenza; - - /** The titolare copyright. */ - private List titolariCopyright; - - /** The parole chiave libere. */ - private List paroleChiaveLibere; - - /** The parole chiave ICCD. */ - private List paroleChiaveICCD; - - /** The centroid lat. */ - private Double centroidLat; - - /** The centroid long. */ - private Double centroidLong; - - /** The relazione scavo. */ - private AbstractRelazioneScavoDV abstractRelazioneScavo; - - /** The relazione scavo. */ - private RelazioneScavoDV relazioneScavo; - - /** The immagini rappresentative. */ - private List immaginiRappresentative = new ArrayList(); - - /** The posizionamento scavo. */ - private LayerConcessioneDV posizionamentoScavo; - - /** The piante fine scavo. */ - private List pianteFineScavo = new ArrayList(); - - /** The generic content. */ - private List genericContent = new ArrayList(); - - /** - * Instantiates a new concessione. - */ - public ConcessioneDV() { - - } - - /** - * Gets the introduzione. - * - * @return the introduzione - */ - public String getIntroduzione() { - return introduzione; - } - - /** - * Sets the introduzione. - * - * @param introduzione the new introduzione - */ - public void setIntroduzione(String introduzione) { - this.introduzione = introduzione; - } - - /** - * Gets the descrizione contenuto. - * - * @return the descrizione contenuto - */ - public String getDescrizioneContenuto() { - return descrizioneContenuto; - } - - /** - * Sets the descrizione contenuto. - * - * @param descrizioneContenuto the new descrizione contenuto - */ - public void setDescrizioneContenuto(String descrizioneContenuto) { - this.descrizioneContenuto = descrizioneContenuto; - } - - /** - * Gets the authors. - * - * @return the authors - */ - public List getAuthors() { - return authors; - } - - /** - * Sets the authors. - * - * @param authors the new authors - */ - public void setAuthors(List authors) { - this.authors = authors; - } - - /** - * Gets the contributore. - * - * @return the contributore - */ - public String getContributore() { - return contributore; - } - - /** - * Sets the contributore. - * - * @param contributore the new contributore - */ - public void setContributore(String contributore) { - this.contributore = contributore; - } - - /** - * Gets the titolari. - * - * @return the titolari - */ - public List getTitolari() { - return titolari; - } - - /** - * Sets the titolari. - * - * @param titolari the new titolari - */ - public void setTitolari(List titolari) { - this.titolari = titolari; - } - - /** - * Gets the responsabile. - * - * @return the responsabile - */ - public String getResponsabile() { - return responsabile; - } - - /** - * Sets the responsabile. - * - * @param responsabile the new responsabile - */ - public void setResponsabile(String responsabile) { - this.responsabile = responsabile; - } - - /** - * Gets the editore. - * - * @return the editore - */ - public String getEditore() { - return editore; - } - - /** - * Sets the editore. - * - * @param editore the new editore - */ - public void setEditore(String editore) { - this.editore = editore; - } - - /** - * Gets the fonti finanziamento. - * - * @return the fonti finanziamento - */ - public List getFontiFinanziamento() { - return fontiFinanziamento; - } - - /** - * Sets the fonti finanziamento. - * - * @param fontiFinanziamento the new fonti finanziamento - */ - public void setFontiFinanziamento(List fontiFinanziamento) { - this.fontiFinanziamento = fontiFinanziamento; - } - - /** - * Gets the soggetto. - * - * @return the soggetto - */ - public List getSoggetto() { - return soggetto; - } - - /** - * Sets the soggetto. - * - * @param soggetto the new soggetto - */ - public void setSoggetto(List soggetto) { - this.soggetto = soggetto; - } - - /** - * Gets the risorse correlate. - * - * @return the risorse correlate - */ - public List getRisorseCorrelate() { - return risorseCorrelate; - } - - /** - * Sets the risorse correlate. - * - * @param risorseCorrelate the new risorse correlate - */ - public void setRisorseCorrelate(List risorseCorrelate) { - this.risorseCorrelate = risorseCorrelate; - } - - /** - * Gets the data inizio progetto. - * - * @return the data inizio progetto - */ - public String getDataInizioProgetto() { - return dataInizioProgetto; - } - - /** - * Sets the data inizio progetto. - * - * @param dataInizioProgetto the new data inizio progetto - */ - public void setDataInizioProgetto(String dataInizioProgetto) { - this.dataInizioProgetto = dataInizioProgetto; - } - - /** - * Gets the data fine progetto. - * - * @return the data fine progetto - */ - public String getDataFineProgetto() { - return dataFineProgetto; - } - - /** - * Sets the data fine progetto. - * - * @param dataFineProgetto the new data fine progetto - */ - public void setDataFineProgetto(String dataFineProgetto) { - this.dataFineProgetto = dataFineProgetto; - } - - /** - * Gets the titolari licenza. - * - * @return the titolari licenza - */ - public List getTitolariLicenza() { - return titolariLicenza; - } - - /** - * Sets the titolari licenza. - * - * @param titolariLicenza the new titolari licenza - */ - public void setTitolariLicenza(List titolariLicenza) { - this.titolariLicenza = titolariLicenza; - } - - /** - * Gets the titolari copyright. - * - * @return the titolari copyright - */ - public List getTitolariCopyright() { - return titolariCopyright; - } - - /** - * Sets the titolari copyright. - * - * @param titolariCopyright the new titolari copyright - */ - public void setTitolariCopyright(List titolariCopyright) { - this.titolariCopyright = titolariCopyright; - } - - /** - * Gets the parole chiave libere. - * - * @return the parole chiave libere - */ - public List getParoleChiaveLibere() { - return paroleChiaveLibere; - } - - /** - * Sets the parole chiave libere. - * - * @param paroleChiaveLibere the new parole chiave libere - */ - public void setParoleChiaveLibere(List paroleChiaveLibere) { - this.paroleChiaveLibere = paroleChiaveLibere; - } - - /** - * Gets the parole chiave ICCD. - * - * @return the parole chiave ICCD - */ - public List getParoleChiaveICCD() { - return paroleChiaveICCD; - } - - /** - * Sets the parole chiave ICCD. - * - * @param paroleChiaveICCD the new parole chiave ICCD - */ - public void setParoleChiaveICCD(List paroleChiaveICCD) { - this.paroleChiaveICCD = paroleChiaveICCD; - } - - /** - * Gets the centroid lat. - * - * @return the centroid lat - */ - public Double getCentroidLat() { - return centroidLat; - } - - /** - * Sets the centroid lat. - * - * @param centroidLat the new centroid lat - */ - public void setCentroidLat(Double centroidLat) { - this.centroidLat = centroidLat; - } - - /** - * Gets the centroid long. - * - * @return the centroid long - */ - public Double getCentroidLong() { - return centroidLong; - } - - /** - * Sets the centroid long. - * - * @param centroidLong the new centroid long - */ - public void setCentroidLong(Double centroidLong) { - this.centroidLong = centroidLong; - } - - /** - * Gets the relazione scavo. - * - * @return the relazione scavo - */ - public RelazioneScavoDV getRelazioneScavo() { - return relazioneScavo; - } - - /** - * Sets the relazione scavo. - * - * @param relazioneScavo the new relazione scavo - */ - public void setRelazioneScavo(RelazioneScavoDV relazioneScavo) { - this.relazioneScavo = relazioneScavo; - } - - /** - * Gets the immagini rappresentative. - * - * @return the immagini rappresentative - */ - public List getImmaginiRappresentative() { - return immaginiRappresentative; - } - - /** - * Sets the immagini rappresentative. - * - * @param immaginiRappresentative the new immagini rappresentative - */ - public void setImmaginiRappresentative(List immaginiRappresentative) { - this.immaginiRappresentative = immaginiRappresentative; - } - - /** - * Gets the posizionamento scavo. - * - * @return the posizionamento scavo - */ - public LayerConcessioneDV getPosizionamentoScavo() { - return posizionamentoScavo; - } - - /** - * Sets the posizionamento scavo. - * - * @param posizionamentoScavo the new posizionamento scavo - */ - public void setPosizionamentoScavo(LayerConcessioneDV posizionamentoScavo) { - this.posizionamentoScavo = posizionamentoScavo; - } - - /** - * Gets the piante fine scavo. - * - * @return the piante fine scavo - */ - public List getPianteFineScavo() { - return pianteFineScavo; - } - - /** - * Sets the piante fine scavo. - * - * @param pianteFineScavo the new piante fine scavo - */ - public void setPianteFineScavo(List pianteFineScavo) { - this.pianteFineScavo = pianteFineScavo; - } - - /** - * Gets the generic content. - * - * @return the generic content - */ - public List getGenericContent() { - return genericContent; - } - - /** - * Sets the generic content. - * - * @param genericContent the new generic content - */ - public void setGenericContent(List genericContent) { - this.genericContent = genericContent; - } - - - /** - * Gets the abstract relazione scavo. - * - * @return the abstract relazione scavo - */ - public AbstractRelazioneScavoDV getAbstractRelazioneScavo() { - return abstractRelazioneScavo; - } - - /** - * Sets the abstract relazione scavo. - * - * @param abstractRelazioneScavo the new abstract relazione scavo - */ - public void setAbstractRelazioneScavo(AbstractRelazioneScavoDV abstractRelazioneScavo) { - this.abstractRelazioneScavo = abstractRelazioneScavo; - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("ConcessioneDV [introduzione="); - builder.append(introduzione); - builder.append(", descrizioneContenuto="); - builder.append(descrizioneContenuto); - builder.append(", authors="); - builder.append(authors); - builder.append(", contributore="); - builder.append(contributore); - builder.append(", titolari="); - builder.append(titolari); - builder.append(", responsabile="); - builder.append(responsabile); - builder.append(", editore="); - builder.append(editore); - builder.append(", fontiFinanziamento="); - builder.append(fontiFinanziamento); - builder.append(", soggetto="); - builder.append(soggetto); - builder.append(", risorseCorrelate="); - builder.append(risorseCorrelate); - builder.append(", dataInizioProgetto="); - builder.append(dataInizioProgetto); - builder.append(", dataFineProgetto="); - builder.append(dataFineProgetto); - builder.append(", titolariLicenza="); - builder.append(titolariLicenza); - builder.append(", titolariCopyright="); - builder.append(titolariCopyright); - builder.append(", paroleChiaveLibere="); - builder.append(paroleChiaveLibere); - builder.append(", paroleChiaveICCD="); - builder.append(paroleChiaveICCD); - builder.append(", centroidLat="); - builder.append(centroidLat); - builder.append(", centroidLong="); - builder.append(centroidLong); - builder.append(", abstractRelazioneScavo="); - builder.append(abstractRelazioneScavo); - builder.append(", relazioneScavo="); - builder.append(relazioneScavo); - builder.append(", immaginiRappresentative="); - builder.append(immaginiRappresentative); - builder.append(", posizionamentoScavo="); - builder.append(posizionamentoScavo); - builder.append(", pianteFineScavo="); - builder.append(pianteFineScavo); - builder.append(", genericContent="); - builder.append(genericContent); - builder.append("]"); - return builder.toString(); - } - -} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/content/AssociatedContentDV.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/content/AssociatedContentDV.java deleted file mode 100644 index efd4c7f..0000000 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/content/AssociatedContentDV.java +++ /dev/null @@ -1,202 +0,0 @@ -package org.gcube.portlets.user.geoportaldataviewer.shared.products.content; - -import java.io.Serializable; - -import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.RecordDV; - -import com.google.gwt.user.client.rpc.IsSerializable; - -/** - * The Class AssociatedContent. - * - * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) - * - * Nov 2, 2020 - */ -public abstract class AssociatedContentDV implements IsSerializable, Serializable{ - - - /** - * - */ - private static final long serialVersionUID = -3666420861504055117L; - - /** The id. */ - private long id; - - /** The policy. */ - private String policy; - - /** The license ID. */ - private String licenseID; - - /** The titolo. */ - private String titolo; - - /** The creation time. */ - private String creationTime; - - /** The record. */ - private RecordDV record; - - - /** - * Instantiates a new associated content. - */ - public AssociatedContentDV() { - } - - /** - * Instantiates a new associated content. - * - * @param id the id - * @param policy the policy - * @param licenseID the license ID - * @param titolo the titolo - * @param creationTime the creation time - * @param record the record - */ - public AssociatedContentDV(long id, String policy, String licenseID, String titolo, String creationTime, - RecordDV record) { - super(); - this.id = id; - this.policy = policy; - this.licenseID = licenseID; - this.titolo = titolo; - this.creationTime = creationTime; - this.record = record; - } - - /** - * Gets the id. - * - * @return the id - */ - public long getId() { - return id; - } - - /** - * Sets the id. - * - * @param id the new id - */ - public void setId(long id) { - this.id = id; - } - - /** - * Gets the policy. - * - * @return the policy - */ - public String getPolicy() { - return policy; - } - - /** - * Sets the policy. - * - * @param policy the new policy - */ - public void setPolicy(String policy) { - this.policy = policy; - } - - /** - * Gets the license ID. - * - * @return the license ID - */ - public String getLicenseID() { - return licenseID; - } - - /** - * Sets the license ID. - * - * @param licenseID the new license ID - */ - public void setLicenseID(String licenseID) { - this.licenseID = licenseID; - } - - /** - * Gets the titolo. - * - * @return the titolo - */ - public String getTitolo() { - return titolo; - } - - /** - * Sets the titolo. - * - * @param titolo the new titolo - */ - public void setTitolo(String titolo) { - this.titolo = titolo; - } - - /** - * Gets the creation time. - * - * @return the creation time - */ - public String getCreationTime() { - return creationTime; - } - - /** - * Sets the creation time. - * - * @param creationTime the new creation time - */ - public void setCreationTime(String creationTime) { - this.creationTime = creationTime; - } - - /** - * Gets the record. - * - * @return the record - */ - public RecordDV getRecord() { - return record; - } - - /** - * Sets the record. - * - * @param record the new record - */ - public void setRecord(RecordDV record) { - this.record = record; - } - - /** - * To string. - * - * @return the string - */ - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("AssociatedContent [id="); - builder.append(id); - builder.append(", policy="); - builder.append(policy); - builder.append(", licenseID="); - builder.append(licenseID); - builder.append(", titolo="); - builder.append(titolo); - builder.append(", creationTime="); - builder.append(creationTime); - builder.append(", record="); - builder.append(record); - builder.append("]"); - return builder.toString(); - } - -} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/content/OtherContentDV.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/content/OtherContentDV.java deleted file mode 100644 index 6f8bfff..0000000 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/content/OtherContentDV.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.gcube.portlets.user.geoportaldataviewer.shared.products.content; - -import java.io.Serializable; - -/** - * The Class OtherContent. - * - * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) - * - * Nov 2, 2020 - */ -public class OtherContentDV extends AssociatedContentDV implements Serializable{ - - - /** - * - */ - private static final long serialVersionUID = -2550361768550673836L; - - /** - * Instantiates a new other content. - */ - public OtherContentDV() { - - } - - /** - * To string. - * - * @return the string - */ - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("OtherContent [toString()="); - builder.append(super.toString()); - builder.append("]"); - return builder.toString(); - } - -} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/content/WorkspaceContentDV.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/content/WorkspaceContentDV.java deleted file mode 100644 index 7872626..0000000 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/content/WorkspaceContentDV.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.gcube.portlets.user.geoportaldataviewer.shared.products.content; - -import java.io.Serializable; - -import com.google.gwt.user.client.rpc.IsSerializable; - -/** - * The Class WorkspaceContentDV. - * - * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) - * - * Nov 5, 2020 - */ -public class WorkspaceContentDV implements IsSerializable, Serializable { - - /** - * - */ - private static final long serialVersionUID = -3919923007831416696L; - - /** The mimetype. */ - private String mimetype; - - /** The storage ID. */ - private String storageID; - - /** The link. */ - private String link; - - private Long id; - - public WorkspaceContentDV() { - - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getMimetype() { - return mimetype; - } - - public void setMimetype(String mimetype) { - this.mimetype = mimetype; - } - - public String getStorageID() { - return storageID; - } - - public void setStorageID(String storageID) { - this.storageID = storageID; - } - - public String getLink() { - return link; - } - - public void setLink(String link) { - this.link = link; - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("WorkspaceContentDV [mimetype="); - builder.append(mimetype); - builder.append(", storageID="); - builder.append(storageID); - builder.append(", link="); - builder.append(link); - builder.append(", id="); - builder.append(id); - builder.append("]"); - return builder.toString(); - } - - - -} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/model/AbstractRelazioneScavoDV.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/model/AbstractRelazioneScavoDV.java deleted file mode 100644 index 48923f3..0000000 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/model/AbstractRelazioneScavoDV.java +++ /dev/null @@ -1,152 +0,0 @@ -package org.gcube.portlets.user.geoportaldataviewer.shared.products.model; - -import java.io.Serializable; -import java.util.List; - -import org.gcube.portlets.user.geoportaldataviewer.shared.products.content.AssociatedContentDV; - - -/** - * The Class AbstractRelazioneScavoDV. - * - * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) - * - * Dec 21, 2020 - */ -public class AbstractRelazioneScavoDV extends AssociatedContentDV implements Serializable { - - - /** - * - */ - private static final long serialVersionUID = 8768745863185590509L; - - /** The abstract section. */ - private String abstractSectionIta; - - private String abstractSectionEng; - - /** The responsabili. */ - private List responsabili; - - /** The soggetto. */ - private List soggetto; - - /** - * Instantiates a new abstract relazione scavo. - */ - public AbstractRelazioneScavoDV() { - - } - - /** - * Instantiates a new abstract relazione scavo. - * - * @param abstractSectionIta the abstract section ita - * @param abstractSectionEng the abstract section eng - * @param responsabili the responsabili - * @param soggetto the soggetto - */ - public AbstractRelazioneScavoDV(String abstractSectionIta, String abstractSectionEng, List responsabili, List soggetto) { - super(); - this.abstractSectionIta = abstractSectionIta; - this.abstractSectionEng = abstractSectionEng; - this.responsabili = responsabili; - this.soggetto = soggetto; - } - - /** - * Gets the abstract section ita. - * - * @return the abstract section ita - */ - public String getAbstractSectionIta() { - return abstractSectionIta; - } - - /** - * Sets the abstract section ita. - * - * @param abstractSectionIta the new abstract section ita - */ - public void setAbstractSectionIta(String abstractSectionIta) { - this.abstractSectionIta = abstractSectionIta; - } - - /** - * Gets the abstract section eng. - * - * @return the abstract section eng - */ - public String getAbstractSectionEng() { - return abstractSectionEng; - } - - /** - * Sets the abstract section eng. - * - * @param abstractSectionEng the new abstract section eng - */ - public void setAbstractSectionEng(String abstractSectionEng) { - this.abstractSectionEng = abstractSectionEng; - } - - /** - * Gets the responsabili. - * - * @return the responsabili - */ - public List getResponsabili() { - return responsabili; - } - - /** - * Sets the responsabili. - * - * @param responsabili the new responsabili - */ - public void setResponsabili(List responsabili) { - this.responsabili = responsabili; - } - - /** - * Gets the soggetto. - * - * @return the soggetto - */ - public List getSoggetto() { - return soggetto; - } - - /** - * Sets the soggetto. - * - * @param soggetto the new soggetto - */ - public void setSoggetto(List soggetto) { - this.soggetto = soggetto; - } - - /** - * To string. - * - * @return the string - */ - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("RelazioneScavoDV [abstractSectionIta="); - builder.append(abstractSectionIta); - builder.append(", abstractSectionEng="); - builder.append(abstractSectionEng); - builder.append(", responsabili="); - builder.append(responsabili); - builder.append(", soggetto="); - builder.append(soggetto); - builder.append("]"); - return builder.toString(); - } - - - -} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/model/LayerConcessioneDV.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/model/LayerConcessioneDV.java deleted file mode 100644 index 543c035..0000000 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/model/LayerConcessioneDV.java +++ /dev/null @@ -1,135 +0,0 @@ -package org.gcube.portlets.user.geoportaldataviewer.shared.products.model; - -import java.io.Serializable; -import java.util.List; - -import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap; - -import com.google.gwt.user.client.rpc.IsSerializable; - -public class LayerConcessioneDV extends SDILayerDescriptorDV implements IsSerializable, Serializable{ - - /** - * - */ - private static final long serialVersionUID = 2633250621043744245L; - - // 1.Identificazione - private String abstractSection; - - // 2.Classificazione - private String topicCategory; - - // 3.Keyword - private String subTopic; - - // 4. Delimitazione geographica - private BoundsMap bbox; - - // 5. Temporal - - // 6. Quality - private String valutazioneQualita; - - private String metodoRaccoltaDati; - - private String scalaAcquisizione; - - private List authors; - - public LayerConcessioneDV() { - - } - - public String getAbstractSection() { - return abstractSection; - } - - public void setAbstractSection(String abstractSection) { - this.abstractSection = abstractSection; - } - - public String getTopicCategory() { - return topicCategory; - } - - public void setTopicCategory(String topicCategory) { - this.topicCategory = topicCategory; - } - - public String getSubTopic() { - return subTopic; - } - - public void setSubTopic(String subTopic) { - this.subTopic = subTopic; - } - - public BoundsMap getBbox() { - return bbox; - } - - public void setBbox(BoundsMap bbox) { - this.bbox = bbox; - } - - public String getValutazioneQualita() { - return valutazioneQualita; - } - - public void setValutazioneQualita(String valutazioneQualita) { - this.valutazioneQualita = valutazioneQualita; - } - - public String getMetodoRaccoltaDati() { - return metodoRaccoltaDati; - } - - public void setMetodoRaccoltaDati(String metodoRaccoltaDati) { - this.metodoRaccoltaDati = metodoRaccoltaDati; - } - - public String getScalaAcquisizione() { - return scalaAcquisizione; - } - - public void setScalaAcquisizione(String scalaAcquisizione) { - this.scalaAcquisizione = scalaAcquisizione; - } - - public List getAuthors() { - return authors; - } - - public void setAuthors(List authors) { - this.authors = authors; - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("LayerConcessione [abstractSection="); - builder.append(abstractSection); - builder.append(", topicCategory="); - builder.append(topicCategory); - builder.append(", subTopic="); - builder.append(subTopic); - builder.append(", bbox="); - builder.append(bbox); - builder.append(", valutazioneQualita="); - builder.append(valutazioneQualita); - builder.append(", metodoRaccoltaDati="); - builder.append(metodoRaccoltaDati); - builder.append(", scalaAcquisizione="); - builder.append(scalaAcquisizione); - builder.append(", authors="); - builder.append(authors); - builder.append(", wmsLink="); - builder.append(super.getWmsLink()); - builder.append(", layerName="); - builder.append(super.getLayerName()); - builder.append("]"); - return builder.toString(); - } - -} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/model/RecordDV.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/model/RecordDV.java deleted file mode 100644 index a3c9d39..0000000 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/model/RecordDV.java +++ /dev/null @@ -1,292 +0,0 @@ -package org.gcube.portlets.user.geoportaldataviewer.shared.products.model; - -import java.io.Serializable; - -import com.google.gwt.user.client.rpc.IsSerializable; - -/** - * The Class Record. - * - * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) - * - * Nov 2, 2020 - */ -public abstract class RecordDV implements Serializable, IsSerializable { - - /** - * - */ - private static final long serialVersionUID = 2913726613820175679L; - - /** The mongo id **/ - private String itemId; - - /** The record type. */ - private String recordType; - - /** The version. */ - private String version = "1.0.0"; - - /** The licenza ID. */ - private String licenzaID; - - private String policy; - - /** The nome. */ - // Nome del progetto - private String nome; - - /** The folder id. */ - // Storage Info - private String folderId; - - /** The last update time. */ - // Accounting - private String lastUpdateTime; - - /** The last update user. */ - private String lastUpdateUser; - - /** The creation time. */ - private String creationTime; - - /** The creation user. */ - private String creationUser; - - /** - * Instantiates a new record. - */ - public RecordDV() { - - } - - /** - * Gets the item id. - * - * @return the item id - */ - public String getItemId() { - return itemId; - } - - /** - * Sets the item id. - * - * @param itemId the new item id - */ - public void setItemId(String itemId) { - this.itemId = itemId; - } - - /** - * Gets the record type. - * - * @return the record type - */ - public String getRecordType() { - return recordType; - } - - /** - * Sets the record type. - * - * @param recordType the new record type - */ - public void setRecordType(String recordType) { - this.recordType = recordType; - } - - /** - * Gets the version. - * - * @return the version - */ - public String getVersion() { - return version; - } - - /** - * Sets the version. - * - * @param version the new version - */ - public void setVersion(String version) { - this.version = version; - } - - /** - * Gets the licenza ID. - * - * @return the licenza ID - */ - public String getLicenzaID() { - return licenzaID; - } - - /** - * Sets the licenza ID. - * - * @param licenzaID the new licenza ID - */ - public void setLicenzaID(String licenzaID) { - this.licenzaID = licenzaID; - } - - /** - * Gets the accesso. - * - * @return the accesso - */ - public String getPolicy() { - return policy; - } - - /** - * Sets the accesso. - * - * @param policy the new policy - */ - public void setPolicy(String policy) { - this.policy = policy; - } - - /** - * Gets the nome. - * - * @return the nome - */ - public String getNome() { - return nome; - } - - /** - * Sets the nome. - * - * @param nome the new nome - */ - public void setNome(String nome) { - this.nome = nome; - } - - /** - * Gets the folder id. - * - * @return the folder id - */ - public String getFolderId() { - return folderId; - } - - /** - * Sets the folder id. - * - * @param folderId the new folder id - */ - public void setFolderId(String folderId) { - this.folderId = folderId; - } - - /** - * Gets the last update time. - * - * @return the last update time - */ - public String getLastUpdateTime() { - return lastUpdateTime; - } - - /** - * Sets the last update time. - * - * @param lastUpdateTime the new last update time - */ - public void setLastUpdateTime(String lastUpdateTime) { - this.lastUpdateTime = lastUpdateTime; - } - - /** - * Gets the last update user. - * - * @return the last update user - */ - public String getLastUpdateUser() { - return lastUpdateUser; - } - - /** - * Sets the last update user. - * - * @param lastUpdateUser the new last update user - */ - public void setLastUpdateUser(String lastUpdateUser) { - this.lastUpdateUser = lastUpdateUser; - } - - /** - * Gets the creation time. - * - * @return the creation time - */ - public String getCreationTime() { - return creationTime; - } - - /** - * Sets the creation time. - * - * @param creationTime the new creation time - */ - public void setCreationTime(String creationTime) { - this.creationTime = creationTime; - } - - /** - * Gets the creation user. - * - * @return the creation user - */ - public String getCreationUser() { - return creationUser; - } - - /** - * Sets the creation user. - * - * @param creationUser the new creation user - */ - public void setCreationUser(String creationUser) { - this.creationUser = creationUser; - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("RecordDV [itemId="); - builder.append(itemId); - builder.append(", recordType="); - builder.append(recordType); - builder.append(", version="); - builder.append(version); - builder.append(", licenzaID="); - builder.append(licenzaID); - builder.append(", policy="); - builder.append(policy); - builder.append(", nome="); - builder.append(nome); - builder.append(", folderId="); - builder.append(folderId); - builder.append(", lastUpdateTime="); - builder.append(lastUpdateTime); - builder.append(", lastUpdateUser="); - builder.append(lastUpdateUser); - builder.append(", creationTime="); - builder.append(creationTime); - builder.append(", creationUser="); - builder.append(creationUser); - builder.append("]"); - return builder.toString(); - } - - - -} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/model/RelazioneScavoDV.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/model/RelazioneScavoDV.java deleted file mode 100644 index 232a1ad..0000000 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/model/RelazioneScavoDV.java +++ /dev/null @@ -1,125 +0,0 @@ -package org.gcube.portlets.user.geoportaldataviewer.shared.products.model; - -import java.io.Serializable; -import java.util.List; - -import org.gcube.portlets.user.geoportaldataviewer.shared.products.content.AssociatedContentDV; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.content.WorkspaceContentDV; - - -/** - * The Class RelazioneScavoDV. - * - * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) - * - * Dec 21, 2020 - */ -public class RelazioneScavoDV extends AssociatedContentDV implements Serializable { - - /** - * - */ - private static final long serialVersionUID = 2456950567302197554L; - - /** The responsabili. */ - private List responsabili; - - /** The soggetto. */ - private List soggetto; - - private List listWsContent; - - /** - * Instantiates a new relazione scavo DV. - */ - public RelazioneScavoDV() { - - } - - /** - * Instantiates a new relazione scavo DV. - * - * @param responsabili the responsabili - * @param soggetto the soggetto - */ - public RelazioneScavoDV(List responsabili, List soggetto) { - super(); - this.responsabili = responsabili; - this.soggetto = soggetto; - } - - /** - * Gets the responsabili. - * - * @return the responsabili - */ - public List getResponsabili() { - return responsabili; - } - - /** - * Sets the responsabili. - * - * @param responsabili the new responsabili - */ - public void setResponsabili(List responsabili) { - this.responsabili = responsabili; - } - - /** - * Gets the soggetto. - * - * @return the soggetto - */ - public List getSoggetto() { - return soggetto; - } - - /** - * Sets the soggetto. - * - * @param soggetto the new soggetto - */ - public void setSoggetto(List soggetto) { - this.soggetto = soggetto; - } - - /** - * Gets the list ws content. - * - * @return the list ws content - */ - public List getListWsContent() { - return listWsContent; - } - - /** - * Sets the list ws content. - * - * @param listWsContent the new list ws content - */ - public void setListWsContent(List listWsContent) { - this.listWsContent = listWsContent; - } - - /** - * To string. - * - * @return the string - */ - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("RelazioneScavoDV [responsabili="); - builder.append(responsabili); - builder.append(", soggetto="); - builder.append(soggetto); - builder.append(", listWsContent="); - builder.append(listWsContent); - builder.append("]"); - return builder.toString(); - } - - - -} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/model/SDILayerDescriptorDV.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/model/SDILayerDescriptorDV.java deleted file mode 100644 index 0be6a9f..0000000 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/model/SDILayerDescriptorDV.java +++ /dev/null @@ -1,143 +0,0 @@ -package org.gcube.portlets.user.geoportaldataviewer.shared.products.model; - -import java.io.Serializable; - -import org.gcube.portlets.user.geoportaldataviewer.shared.products.content.AssociatedContentDV; - -import com.google.gwt.user.client.rpc.IsSerializable; - - -/** - * The Class SDILayerDescriptorDV. - * - * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) - * - * Nov 4, 2020 - */ -public class SDILayerDescriptorDV extends AssociatedContentDV implements IsSerializable, Serializable { - - /** - * - */ - private static final long serialVersionUID = 6137246723753812015L; - // meta - private String layerUUID; - private Long layerID; - - // layer - private String layerName; - private String wmsLink; - - /** - * Instantiates a new SDI layer descriptor DV. - */ - public SDILayerDescriptorDV() { - } - - /** - * Instantiates a new SDI layer descriptor DV. - * - * @param layerUUID the layer UUID - * @param layerID the layer ID - * @param layerName the layer name - * @param wmsLink the wms link - */ - public SDILayerDescriptorDV(String layerUUID, Long layerID, String layerName, String wmsLink) { - super(); - this.layerUUID = layerUUID; - this.layerID = layerID; - this.layerName = layerName; - this.wmsLink = wmsLink; - } - - /** - * Gets the layer UUID. - * - * @return the layer UUID - */ - public String getLayerUUID() { - return layerUUID; - } - - /** - * Sets the layer UUID. - * - * @param layerUUID the new layer UUID - */ - public void setLayerUUID(String layerUUID) { - this.layerUUID = layerUUID; - } - - /** - * Gets the layer ID. - * - * @return the layer ID - */ - public Long getLayerID() { - return layerID; - } - - /** - * Sets the layer ID. - * - * @param layerID the new layer ID - */ - public void setLayerID(Long layerID) { - this.layerID = layerID; - } - - /** - * Gets the layer name. - * - * @return the layer name - */ - public String getLayerName() { - return layerName; - } - - /** - * Sets the layer name. - * - * @param layerName the new layer name - */ - public void setLayerName(String layerName) { - this.layerName = layerName; - } - - /** - * Gets the wms link. - * - * @return the wms link - */ - public String getWmsLink() { - return wmsLink; - } - - /** - * Sets the wms link. - * - * @param wmsLink the new wms link - */ - public void setWmsLink(String wmsLink) { - this.wmsLink = wmsLink; - } - - /* (non-Javadoc) - * @see org.gcube.portlets.user.geoportaldataviewer.shared.products.content.AssociatedContentDV#toString() - */ - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("SDILayerDescriptor [layerUUID="); - builder.append(layerUUID); - builder.append(", layerID="); - builder.append(layerID); - builder.append(", layerName="); - builder.append(layerName); - builder.append(", wmsLink="); - builder.append(wmsLink); - builder.append("]"); - return builder.toString(); - } - -} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/model/UploadedImageDV.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/model/UploadedImageDV.java deleted file mode 100644 index d9689f0..0000000 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/model/UploadedImageDV.java +++ /dev/null @@ -1,141 +0,0 @@ -package org.gcube.portlets.user.geoportaldataviewer.shared.products.model; - -import java.io.Serializable; -import java.util.List; - -import org.gcube.portlets.user.geoportaldataviewer.shared.products.content.AssociatedContentDV; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.content.WorkspaceContentDV; - -import com.google.gwt.user.client.rpc.IsSerializable; - -/** - * The Class UploadedImage. - * - * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) - * - * Nov 2, 2020 - */ -public class UploadedImageDV extends AssociatedContentDV implements IsSerializable, Serializable { - - /** The Constant serialVersionUID. */ - private static final long serialVersionUID = 809167060189883015L; - - /** The didascalia. */ - private String didascalia; - - /** The format. */ - private String format; - - /** The responsabili. */ - private List responsabili; - - /** The soggetto. */ - private List soggetto; - - private List listWsContent; - - /** - * Instantiates a new uploaded image. - */ - public UploadedImageDV() { - - } - - /** - * Gets the didascalia. - * - * @return the didascalia - */ - public String getDidascalia() { - return didascalia; - } - - /** - * Sets the didascalia. - * - * @param didascalia the new didascalia - */ - public void setDidascalia(String didascalia) { - this.didascalia = didascalia; - } - - /** - * Gets the format. - * - * @return the format - */ - public String getFormat() { - return format; - } - - /** - * Sets the format. - * - * @param format the new format - */ - public void setFormat(String format) { - this.format = format; - } - - /** - * Gets the responsabili. - * - * @return the responsabili - */ - public List getResponsabili() { - return responsabili; - } - - /** - * Sets the responsabili. - * - * @param responsabili the new responsabili - */ - public void setResponsabili(List responsabili) { - this.responsabili = responsabili; - } - - /** - * Gets the soggetto. - * - * @return the soggetto - */ - public List getSoggetto() { - return soggetto; - } - - /** - * Sets the soggetto. - * - * @param soggetto the new soggetto - */ - public void setSoggetto(List soggetto) { - this.soggetto = soggetto; - } - - public List getListWsContent() { - return listWsContent; - } - - public void setListWsContent(List listWsContent) { - this.listWsContent = listWsContent; - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("UploadedImageDV [didascalia="); - builder.append(didascalia); - builder.append(", format="); - builder.append(format); - builder.append(", responsabili="); - builder.append(responsabili); - builder.append(", soggetto="); - builder.append(soggetto); - builder.append(", listWsContent="); - builder.append(listWsContent); - builder.append("]"); - return builder.toString(); - } - -} diff --git a/src/test/java/org/gcube/portlets/user/geoportaldataviewer/GetConcessione.java b/src/test/java/org/gcube/portlets/user/geoportaldataviewer/GetConcessione.java index e8915ed..5bf0b80 100644 --- a/src/test/java/org/gcube/portlets/user/geoportaldataviewer/GetConcessione.java +++ b/src/test/java/org/gcube/portlets/user/geoportaldataviewer/GetConcessione.java @@ -2,10 +2,10 @@ package org.gcube.portlets.user.geoportaldataviewer; import org.gcube.application.geoportal.client.legacy.ConcessioniManager; import org.gcube.application.geoportal.common.model.legacy.Concessione; +import org.gcube.application.geoportalcommon.ConvertToDataViewModel; +import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.common.scope.api.ScopeProvider; -import org.gcube.portlets.user.geoportaldataviewer.server.ConvertToDataViewModel; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.ConcessioneDV; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -- 2.17.1 From a2131b7bf163f7184c2a39f1de7085c47e8869f4 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 2 Aug 2021 16:45:05 +0200 Subject: [PATCH 06/38] bug fixing data point selection --- .settings/org.eclipse.wst.common.component | 3 --- .../client/GeoportalDataViewer.java | 2 +- .../client/LayerManager.java | 1 + .../client/OLMapManager.java | 16 +++++++++++--- .../geoportaldataviewer/GetConcessione.java | 21 +++++++++++-------- 5 files changed, 27 insertions(+), 16 deletions(-) diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index de22390..b3fd7d1 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -63,9 +63,6 @@ - - uses - 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 566e5d0..1a24ba3 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 @@ -334,7 +334,7 @@ public class GeoportalDataViewer implements EntryPoint { GWT.log("X: "+x +", Y:"+y); if(x!=null && y!=null) { Coordinate transfCoord = MapUtils.transformCoordiante(new Coordinate(x, y), GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857); - GeoQuery select = olMapMng.toDataPointQuery(transfCoord); + GeoQuery select = olMapMng.toDataPointQuery(transfCoord,false); GWT.log("GeoQuery: "+select); //GeoportalDataViewerConstants.print("fireEvent QueryDataEvent"); layerManager.getLayerManagerBus().fireEvent(new QueryDataEvent(select, transfCoord, record.getItemId(), true)); 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 ec4903a..38feb24 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 @@ -155,6 +155,7 @@ public class LayerManager { @Override public void onSuccess(List listGeonaDataObjects) { + GWT.log("GeoNaDataObject's is/are " + listGeonaDataObjects.size()); GWT.log("GeoNaDataObject's: " + listGeonaDataObjects); // GeoportalDataViewerConstants.print("GeoNaDataObject's: // "+listGeonaDataObjects); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java index 24fb887..41e13da 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java @@ -65,7 +65,7 @@ public class OLMapManager { // // } - GeoQuery select = toDataPointQuery(coordinate); + GeoQuery select = toDataPointQuery(coordinate,true); layerManagerBus.fireEvent(new QueryDataEvent(select, coordinate, null, true)); } @@ -136,7 +136,7 @@ public class OLMapManager { * @param coordinate the coordinate * @return the geo query */ - public GeoQuery toDataPointQuery(Coordinate coordinate) { + public GeoQuery toDataPointQuery(Coordinate coordinate, boolean manualClick) { double lon = coordinate.getX(); double lat = coordinate.getY(); @@ -149,7 +149,17 @@ public class OLMapManager { // ratio - mapPixelWeight : bboxWeight = 20px : geoRectangleWidth // where 10px is the pixel diameter dimension of the clicked point double bboxWidth = Math.abs(olMap.getExtent().getLowerLeftX() - olMap.getExtent().getUpperRightX()); - double geoWidth = (bboxWidth / w) * (20 / 2); + double geoWidth = 0; + //adding a tolerance in case of manual click + if(manualClick) { + //adding a tolerance for clicking + geoWidth = (bboxWidth / w) * (14 / 2); + } + else { + //data point selection for coordinate loaded from concessione + geoWidth = (bboxWidth / w) * (2); + } + double x1 = Math.min(lon + geoWidth, lon - geoWidth); double x2 = Math.max(lon + geoWidth, lon - geoWidth); double y1 = Math.min(lat + geoWidth, lat - geoWidth); diff --git a/src/test/java/org/gcube/portlets/user/geoportaldataviewer/GetConcessione.java b/src/test/java/org/gcube/portlets/user/geoportaldataviewer/GetConcessione.java index 5bf0b80..58b3a59 100644 --- a/src/test/java/org/gcube/portlets/user/geoportaldataviewer/GetConcessione.java +++ b/src/test/java/org/gcube/portlets/user/geoportaldataviewer/GetConcessione.java @@ -1,6 +1,8 @@ package org.gcube.portlets.user.geoportaldataviewer; -import org.gcube.application.geoportal.client.legacy.ConcessioniManager; +import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.statefulMongoConcessioni; + +import org.gcube.application.geoportal.client.legacy.ConcessioniManagerI; import org.gcube.application.geoportal.common.model.legacy.Concessione; import org.gcube.application.geoportalcommon.ConvertToDataViewModel; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; @@ -16,20 +18,21 @@ public class GetConcessione { private static final String YOUR_TOKEN = ""; public static String SCOPE = "/gcube/devsec/devVRE"; - public static long concessioneId = 8; + public static String concessioneId = "6102c07002ad3d05b5f81ddc"; - public static ConcessioneDV getConcessioneForId(Long id) throws Exception{ - LOG.info("getConcessioneForId "+id+ "called"); + public static ConcessioneDV getConcessioneForId(String mongoID) throws Exception{ + LOG.info("getConcessioneForId "+mongoID+ "called"); ConcessioneDV concessionDV = null; - if(id==null) + if(mongoID==null) throw new Exception("Invalid parameter. The Id is null"); try { - LOG.info("Trying to get record for id "+id); - Concessione concessione = new ConcessioniManager().getById(id+""); - LOG.info("For id "+id+", got concessione "+concessione); + LOG.info("Trying to get record for id "+mongoID); + ConcessioniManagerI concessioniManager = statefulMongoConcessioni().build(); + Concessione concessione = concessioniManager.getById(mongoID); + LOG.info("For id "+mongoID+", got concessione "+concessione); LOG.info("Immagini Rappresentative are: "+concessione.getImmaginiRappresentative()); LOG.info("Relazione scavo: "+concessione.getRelazioneScavo()); LOG.info("Pianta Fine scavo: "+concessione.getPianteFineScavo()); @@ -45,7 +48,7 @@ public class GetConcessione { return concessionDV; }catch (Exception e) { - String erroMsg = Concessione.class.getSimpleName() +" with id "+id+" not available"; + String erroMsg = Concessione.class.getSimpleName() +" with id "+mongoID+" not available"; LOG.error(erroMsg,e); throw new Exception(erroMsg); } -- 2.17.1 From fea98c837d88e3f747ffd436b4013236672ad812 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 2 Aug 2021 17:05:01 +0200 Subject: [PATCH 07/38] added loading icon --- .../ui/dialogs/DialogShareableLink.java | 226 ++++++++++-------- .../ui/dialogs/DialogShareableLink.ui.xml | 3 +- 2 files changed, 122 insertions(+), 107 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/dialogs/DialogShareableLink.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/dialogs/DialogShareableLink.java index 8da0679..90a56e7 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/dialogs/DialogShareableLink.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/dialogs/DialogShareableLink.java @@ -1,9 +1,9 @@ package org.gcube.portlets.user.geoportaldataviewer.client.ui.dialogs; - import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.PublicLink; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync; +import org.gcube.portlets.user.geoportaldataviewer.client.util.LoaderIcon; import com.github.gwtbootstrap.client.ui.Alert; import com.github.gwtbootstrap.client.ui.Button; @@ -16,6 +16,7 @@ import com.github.gwtbootstrap.client.ui.Tooltip; import com.github.gwtbootstrap.client.ui.constants.VisibilityChange; import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.Element; +import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.MouseOverEvent; @@ -26,6 +27,7 @@ import com.google.gwt.user.client.Random; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Composite; +import com.google.gwt.user.client.ui.HTMLPanel; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.VerticalPanel; import com.google.gwt.user.client.ui.Widget; @@ -35,7 +37,7 @@ import com.google.gwt.user.client.ui.Widget; * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * - * Sep 19, 2019 + * Sep 19, 2019 */ public class DialogShareableLink extends Composite { @@ -45,10 +47,10 @@ public class DialogShareableLink extends Composite { @UiField ControlGroup cgPublicLink; - + @UiField ControlGroup cgPrivateLongLink; - + @UiField ControlGroup cgPublicLongLink; @@ -57,58 +59,61 @@ public class DialogShareableLink extends Composite { @UiField TextBox textPrivateLink; - + @UiField TextBox textPrivateLongLink; - + @UiField TextBox textPublicLongLink; - + @UiField Alert errorAlert; - + @UiField Alert actionAlert; - + // @UiField // Well alertFilePublicLink; - + @UiField Fieldset fieldSetPrivate; - + @UiField Fieldset fieldSetPublic; - + @UiField VerticalPanel fieldPrivateSharing; // @UiField // VerticalPanel filedEnableDisableSharing; - + @UiField Label labelLinkSharing; - + @UiField Button privateLinkCopyButton; - + @UiField Button privateLongLinkCopyButton; - + @UiField Button publicLinkCopyButton; - + @UiField Button publicLongLinkCopyButton; // // @UiField // Well wellPrivateLinkDescription; - + @UiField Button showPrivateLongLinkButton; - + @UiField Button showPublicLongLinkButton; - + + @UiField + HTMLPanel info_panel; + // @UiField // HTMLPanel panelFieldsContainer; @@ -117,22 +122,23 @@ public class DialogShareableLink extends Composite { private String fileVersion; private boolean itemIsPublicStatus; - + private PublicLink openPublicLink; - + private PublicLink restrictedPublicLink; - + private final String privateShareToFileDescription = "By sharing the following Private Link " + "with your coworkers, you will enact the users of the group the folder is shared with, " + "to access the file and the shared folder content. Login required"; - + + private LoaderIcon loadingIcon = new LoaderIcon("loading..."); /** * The Interface DialogShareableLinkUiBinder. * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * - * Sep 19, 2019 + * Sep 19, 2019 */ interface DialogShareableLinkUiBinder extends UiBinder { } @@ -140,80 +146,81 @@ public class DialogShareableLink extends Composite { /** * Instantiates a new dialog shareable link. * - * @param item the item + * @param item the item * @param version the version */ public DialogShareableLink(GeoNaItemRef item, String version) { initWidget(uiBinder.createAndBindUi(this)); - + this.geonItemRef = item; this.fileVersion = version; this.actionAlert.setAnimation(true); - - //cgRemovePublicLink.setVisible(false); + + // cgRemovePublicLink.setVisible(false); // fieldSetPrivate.setVisible(false); // fieldPrivateSharing.setVisible(false); cgPublicLink.setVisible(true); fieldPrivateSharing.setVisible(false); fieldSetPrivate.setVisible(false); - + GeoportalDataViewerServiceAsync.Util.getInstance().getMyLogin(new AsyncCallback() { @Override public void onFailure(Throwable caught) { // TODO Auto-generated method stub - + } @Override public void onSuccess(String result) { - if(result!=null) { + if (result != null) { fieldPrivateSharing.setVisible(true); fieldSetPrivate.setVisible(true); } } }); - showMessage("", false); + loadingIcon.getElement().getStyle().setMarginBottom(20,Unit.PX); + showLoadingIcon(true); - //alertFilePublicLink.setVisible(true); + // alertFilePublicLink.setVisible(true); loadAndShowPublicLinksForItem(item); - //getElement().setClassName("gwt-DialogBoxNew"); + // getElement().setClassName("gwt-DialogBoxNew"); modalBox.setTitle("Share Link..."); ModalFooter modalFooter = new ModalFooter(); final Button buttClose = new Button("Close"); modalFooter.add(buttClose); - + buttClose.addClickHandler(new ClickHandler() { - + @Override public void onClick(ClickEvent event) { modalBox.hide(); } }); - + addEvents(); - textPrivateLink.setId(Random.nextInt()+Random.nextInt()+""); - textPrivateLongLink.setId(Random.nextInt()+Random.nextInt()+""); - textPublicLink.setId(Random.nextInt()+Random.nextInt()+""); - textPublicLongLink.setId(Random.nextInt()+Random.nextInt()+""); - + textPrivateLink.setId(Random.nextInt() + Random.nextInt() + ""); + textPrivateLongLink.setId(Random.nextInt() + Random.nextInt() + ""); + textPublicLink.setId(Random.nextInt() + Random.nextInt() + ""); + textPublicLongLink.setId(Random.nextInt() + Random.nextInt() + ""); + modalBox.add(this); modalBox.add(modalFooter); modalBox.show(); } - + /** * Adds the events. */ private void addEvents() { - + showPrivateLongLinkButton.addClickHandler(new ClickHandler() { - + @Override public void onClick(ClickEvent event) { showPrivateLongLinkButton.setVisible(false); @@ -221,16 +228,16 @@ public class DialogShareableLink extends Composite { textPrivateLongLink.setText(restrictedPublicLink.getCompleteURL()); } }); - + showPublicLongLinkButton.addClickHandler(new ClickHandler() { - + @Override public void onClick(ClickEvent event) { - if(openPublicLink!=null && openPublicLink.getCompleteURL()!=null) { + if (openPublicLink != null && openPublicLink.getCompleteURL() != null) { showPublicLongLinkButton.setVisible(false); cgPublicLongLink.setVisible(true); textPublicLongLink.setText(openPublicLink.getCompleteURL()); - }else { + } else { textPublicLongLink.setText("Not available"); showPublicLongLinkButton.setText("Not available"); showPublicLongLinkButton.addStyleName("href-disabled"); @@ -240,149 +247,147 @@ public class DialogShareableLink extends Composite { } } }); - + privateLinkCopyButton.addClickHandler(new ClickHandler() { - + @Override public void onClick(ClickEvent event) { - + final Element elem = event.getRelativeElement(); elem.setTitle("Copied to clipboard"); Tooltip.changeVisibility(elem, VisibilityChange.TOGGLE.get()); Timer timer = new Timer() { - + @Override public void run() { Tooltip.changeVisibility(elem, VisibilityChange.HIDE.get()); } }; - + timer.schedule(1000); copyToClipboard(textPrivateLink.getId()); } }); - + privateLinkCopyButton.addMouseOverHandler(new MouseOverHandler() { - + @Override public void onMouseOver(MouseOverEvent event) { final Element elem = event.getRelativeElement(); elem.setTitle("Copy"); } }); - - + privateLongLinkCopyButton.addClickHandler(new ClickHandler() { - + @Override public void onClick(ClickEvent event) { final Element elem = event.getRelativeElement(); Tooltip.changeVisibility(elem, VisibilityChange.TOGGLE.get()); Timer timer = new Timer() { - + @Override public void run() { Tooltip.changeVisibility(elem, VisibilityChange.HIDE.get()); } }; - + timer.schedule(1000); copyToClipboard(textPrivateLongLink.getId()); } }); - + privateLongLinkCopyButton.addMouseOverHandler(new MouseOverHandler() { - + @Override public void onMouseOver(MouseOverEvent event) { final Element elem = event.getRelativeElement(); elem.setTitle("Copy"); } }); - + publicLinkCopyButton.addClickHandler(new ClickHandler() { - + @Override public void onClick(ClickEvent event) { final Element elem = event.getRelativeElement(); Tooltip.changeVisibility(elem, VisibilityChange.TOGGLE.get()); Timer timer = new Timer() { - + @Override public void run() { Tooltip.changeVisibility(elem, VisibilityChange.HIDE.get()); } }; - + timer.schedule(1000); copyToClipboard(textPublicLink.getId()); } }); - + publicLinkCopyButton.addMouseOverHandler(new MouseOverHandler() { - + @Override public void onMouseOver(MouseOverEvent event) { final Element elem = event.getRelativeElement(); elem.setTitle("Copy"); } }); - + publicLongLinkCopyButton.addClickHandler(new ClickHandler() { - + @Override public void onClick(ClickEvent event) { final Element elem = event.getRelativeElement(); Tooltip.changeVisibility(elem, VisibilityChange.TOGGLE.get()); Timer timer = new Timer() { - + @Override public void run() { Tooltip.changeVisibility(elem, VisibilityChange.HIDE.get()); } }; - + timer.schedule(1000); copyToClipboard(textPublicLongLink.getId()); } }); - + publicLongLinkCopyButton.addMouseOverHandler(new MouseOverHandler() { - + @Override public void onMouseOver(MouseOverEvent event) { final Element elem = event.getRelativeElement(); elem.setTitle("Copy"); } }); - + textPrivateLink.addClickHandler(new ClickHandler() { - + @Override public void onClick(ClickEvent event) { textPrivateLink.selectAll(); } }); - + textPrivateLongLink.addClickHandler(new ClickHandler() { - + @Override public void onClick(ClickEvent event) { textPrivateLongLink.selectAll(); } }); - + textPublicLongLink.addClickHandler(new ClickHandler() { - + @Override public void onClick(ClickEvent event) { textPublicLongLink.selectAll(); } }); - + } - - + /** * Copy to clipboard. * @@ -390,15 +395,14 @@ public class DialogShareableLink extends Composite { */ private native void copyToClipboard(String myDivId) /*-{ - var copyText = $doc.getElementById(myDivId); - console.log("text copied is :"+copyText.value); - copyText.select(); - //For mobile devices - copyText.setSelectionRange(0, 99999); - $doc.execCommand("copy"); - //alert("Copied the text: " + copyText.value); + var copyText = $doc.getElementById(myDivId); + console.log("text copied is :" + copyText.value); + copyText.select(); + //For mobile devices + copyText.setSelectionRange(0, 99999); + $doc.execCommand("copy"); + //alert("Copied the text: " + copyText.value); }-*/; - /** * Load and show public links for item. @@ -407,30 +411,31 @@ public class DialogShareableLink extends Composite { */ private void loadAndShowPublicLinksForItem(GeoNaItemRef item) { - GeoportalDataViewerServiceAsync.Util.getInstance().getPublicLinksFor(item, - new AsyncCallback() { + GeoportalDataViewerServiceAsync.Util.getInstance().getPublicLinksFor(item, new AsyncCallback() { @Override public void onSuccess(GeoNaItemRef itemReferences) { + showLoadingIcon(false); openPublicLink = itemReferences.getOpenLink(); restrictedPublicLink = itemReferences.getRestrictedLink(); String toPublicURL = openPublicLink.getShortURL() != null && !openPublicLink.getShortURL().isEmpty() ? openPublicLink.getShortURL() : openPublicLink.getCompleteURL(); - + textPublicLink.setValue(toPublicURL); textPublicLongLink.setValue(openPublicLink.getCompleteURL()); - - String toPrivateURL = restrictedPublicLink.getShortURL() != null && !restrictedPublicLink.getShortURL().isEmpty() - ? restrictedPublicLink.getShortURL() - : restrictedPublicLink.getCompleteURL(); - + + String toPrivateURL = restrictedPublicLink.getShortURL() != null + && !restrictedPublicLink.getShortURL().isEmpty() ? restrictedPublicLink.getShortURL() + : restrictedPublicLink.getCompleteURL(); + textPrivateLink.setValue(toPrivateURL); textPrivateLongLink.setValue(restrictedPublicLink.getCompleteURL()); } @Override public void onFailure(Throwable caught) { + showLoadingIcon(false); openPublicLink = null; disableTextBox(textPublicLink); disableTextBox(textPrivateLink); @@ -439,6 +444,17 @@ public class DialogShareableLink extends Composite { }); } + public void showLoadingIcon(boolean show) { + try { + if(show) + info_panel.add(loadingIcon); + else + info_panel.remove(loadingIcon); + }catch (Exception e) { + + } + } + /** * Disable text box. * @@ -448,7 +464,7 @@ public class DialogShareableLink extends Composite { textBox.setEnabled(false); textBox.getElement().getStyle().setOpacity(0.3); } - + /** * Show error. * @@ -458,16 +474,16 @@ public class DialogShareableLink extends Composite { errorAlert.setVisible(true); errorAlert.setText(msg); } - + /** * Show message. * - * @param msg the msg + * @param msg the msg * @param visible the visible */ private void showMessage(String msg, boolean visible) { actionAlert.setVisible(visible); - actionAlert.setText(msg==null?"":msg); + actionAlert.setText(msg == null ? "" : msg); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/dialogs/DialogShareableLink.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/dialogs/DialogShareableLink.ui.xml index fac703c..a4d1dc7 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/dialogs/DialogShareableLink.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/dialogs/DialogShareableLink.ui.xml @@ -44,12 +44,11 @@ } + - - -- 2.17.1 From 97db5d2c1200fd2a3c9b2c06fe87ce139436189f Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 4 Aug 2021 16:10:11 +0200 Subject: [PATCH 08/38] using java.util.Date --- .settings/org.eclipse.wst.common.component | 33 +- .../client/GeoportalDataViewerConstants.java | 5 + .../client/ui/products/RecordView.java | 5 +- .../products/concessioni/ConcessioneView.java | 6 +- .../server/ConvertToDataViewModel.java | 499 ------------------ 5 files changed, 33 insertions(+), 515 deletions(-) delete mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConvertToDataViewModel.java diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index b3fd7d1..70f376c 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,5 +1,6 @@ - + + @@ -11,7 +12,8 @@ - + + @@ -23,7 +25,8 @@ - + + @@ -35,7 +38,8 @@ - + + @@ -47,7 +51,8 @@ - + + @@ -55,7 +60,8 @@ - + + @@ -63,7 +69,11 @@ - + + uses + + + @@ -75,7 +85,8 @@ - + + @@ -85,7 +96,8 @@ - + + @@ -97,7 +109,8 @@ - + + diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java index 9e83645..f1c3bc9 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java @@ -1,7 +1,10 @@ package org.gcube.portlets.user.geoportaldataviewer.client; +import org.gcube.application.geoportalcommon.ConvertToDataViewModel; import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayersMapParameters; +import com.google.gwt.i18n.client.DateTimeFormat; + /** * The Class GeoportalDataViewerConstants. * @@ -46,6 +49,8 @@ public class GeoportalDataViewerConstants { public static final int MAP_ITALY_FIT_ZOOM_ON = 6; + public static DateTimeFormat DT_FORMAT = DateTimeFormat.getFormat(ConvertToDataViewModel.DATE_FORMAT); + /** * Prints the. diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/RecordView.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/RecordView.java index 9d542c1..92765fe 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/RecordView.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/RecordView.java @@ -1,6 +1,7 @@ package org.gcube.portlets.user.geoportaldataviewer.client.ui.products; import org.gcube.application.geoportalcommon.shared.products.model.RecordDV; +import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants; import org.gcube.portlets.user.geoportaldataviewer.client.ui.util.CustomFlexTable; import com.google.gwt.core.client.GWT; @@ -31,8 +32,8 @@ public class RecordView extends Composite { public RecordView(RecordDV record) { initWidget(uiBinder.createAndBindUi(this)); - customTable.addNextKeyValue("Created", record.getCreationTime()); - customTable.addNextKeyValue("Last Updated", record.getLastUpdateTime()); + customTable.addNextKeyValue("Created", GeoportalDataViewerConstants.DT_FORMAT.format(record.getCreationTime())); + customTable.addNextKeyValue("Last Updated", GeoportalDataViewerConstants.DT_FORMAT.format(record.getLastUpdateTime())); customTable.addNextKeyValue("Updated by", record.getLastUpdateUser()); recordDVPanel.add(customTable); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java index dfdb8b1..830ff95 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java @@ -38,9 +38,7 @@ import ol.Coordinate; import ol.OLFactory; public class ConcessioneView extends Composite { - - private static ConcessioneViewUiBinder uiBinder = GWT.create(ConcessioneViewUiBinder.class); interface ConcessioneViewUiBinder extends UiBinder { @@ -117,11 +115,11 @@ public class ConcessioneView extends Composite { introduzione.setText(concessioneDV.getIntroduzione()); if (concessioneDV.getDataInizioProgetto() != null) { - customTable.addNextKeyValue("Data Inizio Progetto", concessioneDV.getDataInizioProgetto()); + customTable.addNextKeyValue("Data Inizio Progetto", GeoportalDataViewerConstants.DT_FORMAT.format(concessioneDV.getDataInizioProgetto())); } if (concessioneDV.getDataFineProgetto() != null) { - customTable.addNextKeyValue("Data Fine Progetto", concessioneDV.getDataFineProgetto()); + customTable.addNextKeyValue("Data Fine Progetto", GeoportalDataViewerConstants.DT_FORMAT.format(concessioneDV.getDataFineProgetto())); } if (concessioneDV.getParoleChiaveLibere() != null) { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConvertToDataViewModel.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConvertToDataViewModel.java deleted file mode 100644 index 12b8e65..0000000 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConvertToDataViewModel.java +++ /dev/null @@ -1,499 +0,0 @@ -//package org.gcube.portlets.user.geoportaldataviewer.server; -// -//import java.time.LocalDateTime; -//import java.time.format.DateTimeFormatter; -//import java.util.ArrayList; -//import java.util.List; -// -//import org.gcube.application.geoportal.common.model.legacy.AccessPolicy; -//import org.gcube.application.geoportal.common.model.legacy.BBOX; -//import org.gcube.application.geoportal.common.model.legacy.Concessione; -//import org.gcube.application.geoportal.common.model.legacy.LayerConcessione; -//import org.gcube.application.geoportal.common.model.legacy.OtherContent; -//import org.gcube.application.geoportal.common.model.legacy.PersistedContent; -//import org.gcube.application.geoportal.common.model.legacy.RelazioneScavo; -//import org.gcube.application.geoportal.common.model.legacy.UploadedImage; -//import org.gcube.application.geoportal.common.model.legacy.WorkspaceContent; -//import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; -//import org.gcube.application.geoportalcommon.shared.products.content.OtherContentDV; -//import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceContentDV; -//import org.gcube.application.geoportalcommon.shared.products.model.AbstractRelazioneScavoDV; -//import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV; -//import org.gcube.application.geoportalcommon.shared.products.model.RelazioneScavoDV; -//import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV; -//import org.gcube.portlets.user.geoportaldataviewer.server.util.URLParserUtil; -//import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap; -//import org.slf4j.Logger; -//import org.slf4j.LoggerFactory; -// -///** -// * The Class ConvertToGUIModel. -// * -// * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) -// * -// * Nov 2, 2020 -// */ -//public class ConvertToDataViewModel { -// -// private static final String NO_TIME = "T00:00"; -// -// /** The Constant LOG. */ -// private static final Logger LOG = LoggerFactory.getLogger(ConvertToDataViewModel.class); -// -// public static final String DATE_FORMAT = "dd-MM-yyyy"; -// -// public static final String HOURS_MINUTES_SEPARATOR = ":"; -// -// public static final String TIME_FORMAT = "HH" + HOURS_MINUTES_SEPARATOR + "mm"; -// -// -// /** -// * To concessione. -// * -// * @param concessione the concessione -// * @return the concessione -// * @throws Exception the exception -// */ -// public static ConcessioneDV toConcessione(Concessione concessione) throws Exception { -// LOG.debug("called toConcessione for: "+concessione); -// -// if (concessione == null) -// return null; -// -// try { -// -// ConcessioneDV theConcessione = new ConcessioneDV(); -// theConcessione.setPolicy(toPolicy(concessione.getPolicy())); -// //theConcessione.setAuthors(concessione.getAuthors()); -// theConcessione.setCentroidLat(concessione.getCentroidLat()); -// theConcessione.setCentroidLong(concessione.getCentroidLong()); -// theConcessione.setContributore(concessione.getContributore()); -// theConcessione.setCreationTime(toDateFormatString(concessione.getCreationTime())); -// theConcessione.setCreationUser(toUser(concessione.getCreationUser())); -// theConcessione.setDataFineProgetto(toDateFormatString(concessione.getDataFineProgetto())); -// theConcessione.setDataInizioProgetto(toDateFormatString(concessione.getDataInizioProgetto())); -// theConcessione.setDescrizioneContenuto(concessione.getDescrizioneContenuto()); -// theConcessione.setEditore(concessione.getEditore()); -// theConcessione.setFontiFinanziamento(concessione.getFontiFinanziamento()); -// theConcessione.setItemId(concessione.getMongo_id()); -// theConcessione.setNome(concessione.getNome()); -// -// theConcessione.setIntroduzione(concessione.getIntroduzione()); -// theConcessione.setLastUpdateTime(toDateFormatString(concessione.getLastUpdateTime())); -// theConcessione.setLastUpdateUser(toUser(concessione.getLastUpdateUser())); -// theConcessione.setLicenzaID(concessione.getLicenzaID()); -// theConcessione.setNome(concessione.getNome()); -// theConcessione.setParoleChiaveICCD(concessione.getParoleChiaveICCD()); -// theConcessione.setParoleChiaveLibere(concessione.getParoleChiaveLibere()); -// -// theConcessione.setResponsabile(concessione.getResponsabile()); -// theConcessione.setRisorseCorrelate(concessione.getRisorseCorrelate()); -// theConcessione.setSoggetto(concessione.getSoggetto()); -// theConcessione.setTitolariCopyright(concessione.getTitolareCopyright()); -// theConcessione.setTitolariLicenza(concessione.getTitolareLicenza()); -// theConcessione.setTitolari(concessione.getTitolari()); -// theConcessione.setVersion(concessione.getVersion()); -// -// theConcessione.setRecordType(concessione.getRecordType().name()); -// -// theConcessione.setAbstractRelazioneScavo(toAbstractRelazioneScavo(concessione.getRelazioneScavo())); -// theConcessione.setRelazioneScavo(toRelazioneScavo(concessione.getRelazioneScavo())); -// -// -// if (concessione.getImmaginiRappresentative() != null) { -// List uploadedImagesDV = new ArrayList( -// concessione.getImmaginiRappresentative().size()); -// for (UploadedImage ui : concessione.getImmaginiRappresentative()) { -// uploadedImagesDV.add(toUploadedImage(ui)); -// } -// theConcessione.setImmaginiRappresentative(uploadedImagesDV); -// } -// -// -// if (concessione.getGenericContent() != null) { -// List otherContentsDV = new ArrayList( -// concessione.getGenericContent().size()); -// for (OtherContent gc : concessione.getGenericContent()) { -// otherContentsDV.add(toOtherContentDV(gc)); -// } -// theConcessione.setGenericContent(otherContentsDV); -// } -// -// -// if (concessione.getPianteFineScavo() != null) { -// List piantaScavoDV = new ArrayList( -// concessione.getPianteFineScavo().size()); -// for (LayerConcessione lc : concessione.getPianteFineScavo()) { -// piantaScavoDV.add(toLayerConcessione(lc)); -// } -// theConcessione.setPianteFineScavo(piantaScavoDV); -// } -// -// if (concessione.getPosizionamentoScavo() != null) { -// LayerConcessioneDV thePosizScavo = toLayerConcessione(concessione.getPosizionamentoScavo()); -// theConcessione.setPosizionamentoScavo(thePosizScavo); -// } -// -// -// LOG.debug("Returning concessione: " + theConcessione); -// return theConcessione; -// }catch (Exception e) { -// LOG.error("Error on converting concessione: "+concessione, e); -// return null; -// } -// -// } -// -// //TO AVOID SERIALIZATION ISSUE AGAINST GWT -//// public static List toListString(List orginList){ -//// if(orginList==null) -//// return null; -//// -//// List destList = new ArrayList(orginList.size()); -//// for (String orgValue : orginList) { -//// destList.add(orgValue); -//// } -//// -//// return destList; -//// } -// -// /** -// * To user. -// * -// * @param username the username -// * @return the string -// */ -// public static String toUser(String username) { -// -// if(username==null) -// return null; -// -// return username; -// -// } -// -// /** -// * To policy. -// * -// * @param policy the policy -// * @return the string -// */ -// public static String toPolicy(AccessPolicy policy) { -// -// if(policy==null) -// return null; -// -// return policy.name(); -// -// } -// -// /** -// * To date format string. -// * -// * @param dateTime the date time -// * @return the string -// */ -// public static String toDateFormatString(LocalDateTime dateTime) { -// -// if(dateTime==null) -// return null; -// -// String time = dateTime.toString(); -// DateTimeFormatter formatter = null; -// try { -// if(!time.endsWith(NO_TIME)) { -// formatter = DateTimeFormatter.ofPattern(DATE_FORMAT + " " + TIME_FORMAT); -// }else { -// time = time.replace(NO_TIME, ""); -// formatter = DateTimeFormatter.ofPattern(DATE_FORMAT); -// } -// }catch (Exception e) { -// LOG.warn("Parsing error: ",e); -// } -// -// try { -// if(formatter!=null) -// return dateTime.format(formatter); -// }catch (Exception e) { -// LOG.warn("Date format error: ",e); -// } -// -// return dateTime.toString(); -// } -// -// /** -// * To abstract relazione scavo. -// * -// * @param relazioneScavo the relazione scavo -// * @return the abstract relazione scavo DV -// */ -// public static AbstractRelazioneScavoDV toAbstractRelazioneScavo(RelazioneScavo relazioneScavo) { -// -// if (relazioneScavo == null) -// return null; -// -// AbstractRelazioneScavoDV theRelazioneDiScavo = new AbstractRelazioneScavoDV(); -// theRelazioneDiScavo.setAbstractSectionIta(relazioneScavo.getAbstractIta()); -// theRelazioneDiScavo.setAbstractSectionEng(relazioneScavo.getAbstractEng()); -// -// theRelazioneDiScavo.setCreationTime(toDateFormatString(relazioneScavo.getCreationTime())); -// theRelazioneDiScavo.setId(relazioneScavo.getId()); -// theRelazioneDiScavo.setLicenseID(relazioneScavo.getLicenseID()); -// theRelazioneDiScavo.setPolicy(toPolicy(relazioneScavo.getPolicy())); -// //theRelazioneDiScavo.setRecord(recordDV); -// theRelazioneDiScavo.setResponsabili(relazioneScavo.getResponsabili()); -// theRelazioneDiScavo.setSoggetto(relazioneScavo.getSoggetto()); -// theRelazioneDiScavo.setTitolo(relazioneScavo.getTitolo()); -// -// LOG.debug("Returning: " + theRelazioneDiScavo); -// return theRelazioneDiScavo; -// } -// -// /** -// * To relazione scavo. -// * -// * @param relazioneScavo the relazione scavo -// * @return the relazione scavo data view -// */ -// public static RelazioneScavoDV toRelazioneScavo(RelazioneScavo relazioneScavo) { -// -// if (relazioneScavo == null) -// return null; -// -// RelazioneScavoDV theRelazioneDiScavo = new RelazioneScavoDV(); -// theRelazioneDiScavo.setCreationTime(toDateFormatString(relazioneScavo.getCreationTime())); -// theRelazioneDiScavo.setId(relazioneScavo.getId()); -// theRelazioneDiScavo.setLicenseID(relazioneScavo.getLicenseID()); -// theRelazioneDiScavo.setPolicy(toPolicy(relazioneScavo.getPolicy())); -// //theRelazioneDiScavo.setRecord(recordDV); -// theRelazioneDiScavo.setResponsabili(relazioneScavo.getResponsabili()); -// theRelazioneDiScavo.setSoggetto(relazioneScavo.getSoggetto()); -// theRelazioneDiScavo.setTitolo(relazioneScavo.getTitolo()); -// -// List actContent = relazioneScavo.getActualContent(); -// if(actContent!=null && actContent.size()>0) { -// List listWsContent = new ArrayList(); -// -// for (PersistedContent content : actContent) { -// if(content!=null && content instanceof WorkspaceContent) { -// listWsContent.add(toWorkspaceContent((WorkspaceContent)content)); -// } -// } -// theRelazioneDiScavo.setListWsContent(listWsContent); -// } -// -// LOG.debug("Returning: " + theRelazioneDiScavo); -// return theRelazioneDiScavo; -// } -// -// /** -// * To uploaded image. -// * -// * @param uploadedImage the uploaded image -// * @return the uploaded image data-view -// */ -// public static UploadedImageDV toUploadedImage(UploadedImage uploadedImage) { -// -// if (uploadedImage == null) -// return null; -// -// UploadedImageDV theUploadedImageDV = new UploadedImageDV(); -// theUploadedImageDV.setCreationTime(toDateFormatString(uploadedImage.getCreationTime())); -// theUploadedImageDV.setDidascalia(uploadedImage.getDidascalia()); -// theUploadedImageDV.setFormat(uploadedImage.getFormat()); -// theUploadedImageDV.setId(uploadedImage.getId()); -// theUploadedImageDV.setLicenseID(uploadedImage.getLicenseID()); -// theUploadedImageDV.setPolicy(toPolicy(uploadedImage.getPolicy())); -// //theUploadedImageDV.setRecord(recordDV); -// theUploadedImageDV.setResponsabili(uploadedImage.getResponsabili()); -// theUploadedImageDV.setSoggetto(uploadedImage.getSoggetto()); -// theUploadedImageDV.setTitolo(uploadedImage.getTitolo()); -// -// List actContent = uploadedImage.getActualContent(); -// if(actContent!=null && actContent.size()>0) { -// List listWsContent = new ArrayList(); -// -// for (PersistedContent content : actContent) { -// if(content!=null && content instanceof WorkspaceContent) { -// listWsContent.add(toWorkspaceContent((WorkspaceContent)content)); -// } -// } -// theUploadedImageDV.setListWsContent(listWsContent); -// } -// -// LOG.debug("Returning: " + theUploadedImageDV); -// return theUploadedImageDV; -// } -// -// -// /** -// * To workspace content. -// * -// * @param wContent the w content -// * @return the workspace content DV -// */ -// public static WorkspaceContentDV toWorkspaceContent(WorkspaceContent wContent){ -// if (wContent == null) -// return null; -// -// WorkspaceContentDV theWSDV = new WorkspaceContentDV(); -// theWSDV.setLink(wContent.getLink()); -// theWSDV.setMimetype(wContent.getMimetype()); -// theWSDV.setStorageID(wContent.getStorageID()); -// theWSDV.setId(wContent.getId()); -// -// return theWSDV; -// } -// -// /** -// * To layer concessione. -// * -// * @param layerConcessione the layer concessione -// * @return the layer concessione data view -// */ -// public static LayerConcessioneDV toLayerConcessione(LayerConcessione layerConcessione) { -// -// if (layerConcessione == null) -// return null; -// -// LOG.debug("Converting: "+layerConcessione); -// LayerConcessioneDV theLayerConessione = new LayerConcessioneDV(); -// theLayerConessione.setAbstractSection(layerConcessione.getAbstractSection()); -// -// String wmsLink = layerConcessione.getWmsLink(); -// String layerName = null; -// BoundsMap bounds = null; -// -// //reading layer name from wmsLink -// //string bbox -// if(wmsLink!=null) { -// layerName = URLParserUtil.extractValueOfParameterFromURL("layers", wmsLink); -// String bbox = URLParserUtil.extractValueOfParameterFromURL("bbox", wmsLink); -// String wmsVersion = URLParserUtil.extractValueOfParameterFromURL("version", wmsLink); -// bounds = toBoundMap(wmsVersion, bbox, ","); -// LOG.debug("Built bounds from wmsLInk: "+bounds); -// } -// -// if(layerName!=null) -// theLayerConessione.setLayerName(layerName); -// else -// theLayerConessione.setLayerName(layerConcessione.getLayerName()); -// -// -// theLayerConessione.setWmsLink(wmsLink); -// theLayerConessione.setLayerID(layerConcessione.getLayerID()); -// theLayerConessione.setLayerUUID(layerConcessione.getLayerUUID()); -// theLayerConessione.setAuthors(layerConcessione.getAuthors()); -// -// if(bounds==null) -// bounds = toBoundMap(layerConcessione.getBbox()); -// -// theLayerConessione.setBbox(bounds); -// theLayerConessione.setCreationTime(toDateFormatString(layerConcessione.getCreationTime())); -// theLayerConessione.setId(layerConcessione.getId()); -// theLayerConessione.setLicenseID(layerConcessione.getLicenseID()); -// theLayerConessione.setMetodoRaccoltaDati(layerConcessione.getMetodoRaccoltaDati()); -// theLayerConessione.setPolicy(toPolicy(layerConcessione.getPolicy())); -// //theLayerConessione.setRecord(recordDV); -// theLayerConessione.setScalaAcquisizione(layerConcessione.getScalaAcquisizione()); -// theLayerConessione.setSubTopic(layerConcessione.getSubTopic()); -// theLayerConessione.setTitolo(layerConcessione.getTitolo()); -// theLayerConessione.setTopicCategory(layerConcessione.getTopicCategory()); -// theLayerConessione.setValutazioneQualita(layerConcessione.getValutazioneQualita()); -// -// -// LOG.debug("Returning: " + theLayerConessione); -// return theLayerConessione; -// -// } -// -// /** -// * To other content DV. -// * -// * @param otherContent the other content -// * @return the other content DV -// */ -// public static OtherContentDV toOtherContentDV(OtherContent otherContent) { -// -// if (otherContent == null) -// return null; -// -// OtherContentDV theOtherContent = new OtherContentDV(); -// theOtherContent.setCreationTime(toDateFormatString(otherContent.getCreationTime())); -// theOtherContent.setId(otherContent.getId()); -// theOtherContent.setLicenseID(otherContent.getLicenseID()); -// theOtherContent.setPolicy(toPolicy(otherContent.getPolicy())); -// //theOtherContent.setRecord(recordDV); -// theOtherContent.setTitolo(otherContent.getTitolo()); -// -// return theOtherContent; -// } -// -// /** -// * To bound map. -// * -// * @param bbox the bbox -// * @return the bounds map -// */ -// public static BoundsMap toBoundMap(BBOX bbox) { -// -// if (bbox == null) -// return null; -// -// return new BoundsMap(bbox.getMinLong(), bbox.getMinLat(), bbox.getMaxLong(), bbox.getMaxLat(), null); -// } -// -// -// /** -// * To bound map. -// * -// * @param wmsVersion the wms version -// * @param bbox the bbox -// * @param separator the separator -// * @return the bounds map -// */ -// public static BoundsMap toBoundMap(String wmsVersion, String bbox, String separator) { -// -// if (bbox == null) -// return null; -// -// if(wmsVersion==null) -// return null; -// -// if(separator==null) -// separator = ","; -// -// try { -// -// String[] bboxArr = bbox.split(separator); -// -// if(wmsVersion.startsWith("1.3")) { -// //is 1.3.x -// return new BoundsMap(toDouble(bboxArr[1]), toDouble(bboxArr[0]), toDouble(bboxArr[3]), toDouble(bboxArr[2]), wmsVersion); -// }else { -// //should be 1.1.X -// return new BoundsMap(toDouble(bboxArr[0]), toDouble(bboxArr[1]), toDouble(bboxArr[2]), toDouble(bboxArr[3]), wmsVersion); -// } -// }catch (Exception e) { -// LOG.warn("Error on creating Bounds for wmsVersion "+wmsVersion+" and bbox "+bbox+" : ",e); -// return null; -// } -// } -// -// /** -// * To double. -// * -// * @param value the value -// * @return the double -// */ -// public static Double toDouble(String value) { -// try { -// return Double.parseDouble(value); -// }catch (Exception e) { -// LOG.warn("Error on parsing "+value+" as double: ",e); -// return null; -// } -// } -// -// -//} -- 2.17.1 From b2e6830bbe7bc7744c394183841766113713b3de Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Tue, 31 Aug 2021 18:21:17 +0200 Subject: [PATCH 09/38] implementing task #21946 --- CHANGELOG.md | 1 + README.md | 5 + .../client/GeoportalDataViewer.java | 6 +- .../client/GeoportalDataViewerConstants.java | 2 + .../client/GeoportalDataViewerService.java | 13 + .../GeoportalDataViewerServiceAsync.java | 3 + .../client/LayerManager.java | 105 +++-- .../client/OLMapManager.java | 99 +++-- .../client/events/QueryDataEvent.java | 37 +- .../client/gis/OpenLayerOSM.java | 419 +++++++++++++----- .../client/ui/gallery/ImagesGallery.java | 32 +- .../GeoportalDataViewerServiceImpl.java | 36 +- 12 files changed, 534 insertions(+), 224 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1d3320..4c5f138 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm [#21890] Porting to ConcessioniManagerI and pass to mongoID [#20595] Porting and using the model view provided by geoportal-common +[#21946] Show layers of a concessione automatically on map according to zoom level ## [v1.2.0-SNAPSHOT] - 2021-07-19 diff --git a/README.md b/README.md index 76b58a0..847a6d1 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,11 @@ The GeoPortal Data Viewer App is an application to access, discovery and navigat * [OpenJDK](https://openjdk.java.net/) - The JDK used * [Maven](https://maven.apache.org/) - Dependency Management +** Uses ** + +* [GWT-OL3](https://github.com/TDesjardins/gwt-ol) GWT-OpenLayers 3+ v.8.0.0-gwt2_9 +* [OpenLayers](https://openlayers.org/) OpenLayers v.6.X + ## Documentation N/A 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 1a24ba3..71936ed 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 @@ -7,6 +7,7 @@ import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.LayerItem; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.model.RecordDV; +import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MapEventType; import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEventHandler; import org.gcube.portlets.user.geoportaldataviewer.client.events.ClosedViewDetailsEvent; @@ -167,7 +168,7 @@ public class GeoportalDataViewer implements EntryPoint { GWT.log("The layerItem is: " + layerItem); layerManager.addLayer(theItemType, null, null, layerItem.getWmsLink(), false, false, - null, true); + null, false); if (paramGeonaItemID != null) { if (paramGeonaItemType == null) { @@ -308,6 +309,7 @@ public class GeoportalDataViewer implements EntryPoint { if(mainPanel.getDisplyedRecord()==null && !olMapMng.isQueryPointActive()) { olMapMng.hidePopInfo(); + olMapMng.removeDetailLayers(); } } @@ -337,7 +339,7 @@ public class GeoportalDataViewer implements EntryPoint { GeoQuery select = olMapMng.toDataPointQuery(transfCoord,false); GWT.log("GeoQuery: "+select); //GeoportalDataViewerConstants.print("fireEvent QueryDataEvent"); - layerManager.getLayerManagerBus().fireEvent(new QueryDataEvent(select, transfCoord, record.getItemId(), true)); + layerManager.getLayerManagerBus().fireEvent(new QueryDataEvent(select, transfCoord, record.getItemId(), true, MapEventType.ADDED_LAYER_TO_MAP)); }else { GeoportalDataViewerConstants.printJs("I cannot select the point one or both coordiantes are null. X: "+x +", Y:"+y); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java index f1c3bc9..caccf86 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java @@ -28,6 +28,8 @@ public class GeoportalDataViewerConstants { public static final String GET_ZOOM = OpenLayersMapParameters.OL_MAP_PARAM.zoom.name(); public static final String GET_CENTER_MAP_TO_LONG_LAT = OpenLayersMapParameters.OL_MAP_PARAM.centermap.name(); + public static enum MapEventType {INIT, MAP_ZOOM_END, MOVE_END, ADDED_LAYER_TO_MAP} + /** * The Enum LayerType. * diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java index 6ed194f..0167a55 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java @@ -111,4 +111,17 @@ public interface GeoportalDataViewerService extends RemoteService { */ List getLayersForId(String itemType, String itemId) throws Exception; + /** + * Gets the WFS features. + * + * @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 WFS features + */ + List getWFSFeatures(List layerObjects, String mapSrsName, + BoundsMap selectBBOX, int maxWFSFeature, double zoomLevel); + } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java index 3e76450..564b6dd 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java @@ -54,4 +54,7 @@ public interface GeoportalDataViewerServiceAsync { void getLayersForId(String itemType, String itemId, AsyncCallback> asyncCallback); + void getWFSFeatures(List layerObjects, String mapSrsName, BoundsMap selectBBOX, int maxWFSFeature, + double zoomLevel, AsyncCallback> callback); + } 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 38feb24..35a000c 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 @@ -10,8 +10,10 @@ import java.util.Map; 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.LayerConcessioneDV; 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.MapEventType; import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEventHandler; import org.gcube.portlets.user.geoportaldataviewer.client.events.QueryDataEvent; @@ -63,7 +65,7 @@ public class LayerManager { /** The ol map. */ private OpenLayerOSM olMap; - private List layerObjects = new ArrayList(); + private Map layerObjects = new HashMap(); private HandlerManager layerManagerBus = new HandlerManager(""); @@ -98,7 +100,7 @@ public class LayerManager { GWT.log("(" + selectDataInfo.getX1() + "," + selectDataInfo.getY1() + ")(" + selectDataInfo.getX2() + "," + selectDataInfo.getY2() + ")"); - for (LayerObject layerObj : layerObjects) { + for (LayerObject layerObj : layerObjects.values()) { // TODO isLayerVisible(layerObj.getLayerItem()); @@ -141,10 +143,10 @@ public class LayerManager { GWT.log("Bounds is: " + mapBBOX); GWT.log("MAX_WFS_FEATURES is: " + GeoportalDataViewerConstants.MAX_WFS_FEATURES); // GeoportalDataViewerConstants.print("calling getDataResult"); - - GeoportalDataViewerServiceAsync.Util.getInstance().getDataResult(layerObjects, - olMap.getProjectionCode(), mapBBOX, GeoportalDataViewerConstants.MAX_WFS_FEATURES, - olMap.getCurrentZoomLevel(), new AsyncCallback>() { + List listLO = new ArrayList(layerObjects.values()); + GeoportalDataViewerServiceAsync.Util.getInstance().getDataResult(listLO, olMap.getProjectionCode(), + mapBBOX, GeoportalDataViewerConstants.MAX_WFS_FEATURES, olMap.getCurrentZoomLevel(), + new AsyncCallback>() { @Override public void onFailure(Throwable caught) { @@ -169,7 +171,7 @@ public class LayerManager { flex.getElement().addClassName("popup-table"); boolean featureFound = false; FeatureRow feature = null; - + // TODO SWTCH FOR EARCH ITEM TYPE for (GeoNaSpatialQueryResult geoNaDataObject : listGeonaDataObjects) { List features = geoNaDataObject.getFeatures(); @@ -184,7 +186,7 @@ public class LayerManager { .get("product_id"); theProductId = productIdLst.get(0); try { - //long productId = Long.parseLong(thePID); + // long productId = Long.parseLong(thePID); if (theProductId == mongoItemId) { feature = fRow; GWT.log("Found recorId == product_id with id: " @@ -202,6 +204,12 @@ public class LayerManager { feature = features.get(0); List productIdLst = feature.getMapProperties() .get("product_id"); + if (productIdLst == null) { + // in this case the feature returned is a (detail) layer belonging + // to a record/concessione (not centroid layer), + // so returning + return; + } theProductId = productIdLst.get(0); } else { // the recordId to show has been passed but not found into list of @@ -210,36 +218,48 @@ public class LayerManager { return; } } - - GWT.log("the product id is: "+theProductId); - - /*if(olMap.getCurrentZoomLevel()>10) { - GeoportalDataViewerServiceAsync.Util.getInstance().getLayersForId("concessione", theProductId, new AsyncCallback>() { - @Override - public void onFailure(Throwable caught) { - // TODO Auto-generated method stub - - } + GWT.log("the product id is: " + theProductId); - @Override - public void onSuccess(List result) { - GWT.log("Adding layers: "+result); - for (LayerConcessioneDV layer : result) { - addLayer("concessione", layer.getLayerName(), layer.getLayerName(), layer.getWmsLink(), false, false, layer.getLayerUUID(), true); + // 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) { + GWT.log("Adding layers: " + result); + for (LayerConcessioneDV layer : result) { + addLayer("concessione", layer.getLayerName(), + layer.getLayerName(), layer.getWmsLink(), + false, false, layer.getLayerUUID(), true); // LayerItem li = new LayerItem(); // li.setBaseLayer(false); // li.setWmsLink(layer.getWmsLink()); // li.setTitle(layer.getLayerName()); // olMap.addWMSLayer(li); - } - - } - }); - return; - }*/ - + } + } + }); + } else { + // removing all WMS detail layers if the ZOOM level is < QUERY_MIN_ZOOM_LEVEL + olMap.removeAllDetailLayers(); + } + + if(queryEvent.getSourceMapEventType() != null && queryEvent.getSourceMapEventType().equals(MapEventType.MAP_ZOOM_END)) { + GWT.log("EVENT IS "+MapEventType.MAP_ZOOM_END +" retuning"); + return; + } + + //Showing properties belonging to concessioni centroid layer Map> entries = feature.getMapProperties(); String nome = ""; @@ -433,11 +453,11 @@ public class LayerManager { * @param isBase the is base * @param displayInLayerSwitcher the display in layer switcher * @param UUID the uuid - * @param onTop the on top + * @param asDetailLayer the as detail layer */ public void addLayer(final String geonaItemType, final String layerTitle, final String layerName, final String wmsLink, final boolean isBase, final boolean displayInLayerSwitcher, final String UUID, - final boolean onTop) { + final boolean asDetailLayer) { // final LayoutContainer westPanel = (LayoutContainer) layersPanel.getParent(); // @@ -448,6 +468,12 @@ public class LayerManager { 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"); + return; + } + GeoportalDataViewerServiceAsync.Util.getInstance().parseWmsRequest(wmsLink, layerName, new AsyncCallback() { @@ -475,8 +501,19 @@ public class LayerManager { LayerObject lo = new LayerObject(); lo.setLayerItem(layerItem); lo.setItemType(geonaItemType); - layerObjects.add(lo); - olMap.addWMSLayer(layerItem); + + String key = layerItem.getMapServerHost() + "/layer/" + layerItem.getName(); + +// //if a detail layer checking if it is already added to map +// if (asDetailLayer && layerObjects.containsKey(key)) { +// GWT.log("Skipping layer already added to Map"); +// } else { + layerObjects.put(key, lo); + if (!asDetailLayer) + olMap.addWMSLayer(layerItem); + else + olMap.addWMSDetailLayer(layerItem); +// } } }); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java index 41e13da..d5aa4e8 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java @@ -1,5 +1,6 @@ package org.gcube.portlets.user.geoportaldataviewer.client; +import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MapEventType; import org.gcube.portlets.user.geoportaldataviewer.client.events.QueryDataEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.ZoomOutOverMinimumEvent; import org.gcube.portlets.user.geoportaldataviewer.client.gis.ExtentWrapped; @@ -21,7 +22,7 @@ import ol.OLFactory; * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * - * Nov 19, 2020 + * Nov 19, 2020 */ public class OLMapManager { @@ -32,12 +33,12 @@ public class OLMapManager { private Double zoomStart = null; private Double zoomEnd = null; private ol.Extent dragEndExtent = null; - private static final int QUERY_MIN_ZOOM_LEVEL = 13; + public static final int QUERY_MIN_ZOOM_LEVEL = 13; /** * Instantiates a new OL map manager. * - * @param targetId the target id + * @param targetId the target id * @param layerManagerBus the layer manager bus */ public OLMapManager(String targetId, HandlerManager layerManagerBus) { @@ -56,64 +57,64 @@ public class OLMapManager { @Override public void clickListener(MapBrowserEvent event) { Coordinate coordinate = event.getCoordinate(); - if(!olMap.mapInstancied()) + if (!olMap.mapInstancied()) return; - + // if (olMap.isQueryPointActive()) { // GeoQuery select = toDataPointQuery(coordinate); // layerManagerBus.fireEvent(new QueryDataEvent(select, coordinate)); // // } - - GeoQuery select = toDataPointQuery(coordinate,true); - layerManagerBus.fireEvent(new QueryDataEvent(select, coordinate, null, true)); + + GeoQuery select = toDataPointQuery(coordinate, true); + layerManagerBus.fireEvent(new QueryDataEvent(select, coordinate, null, true, MapEventType.INIT)); } @Override public void moveEndListener(MapEvent event) { - //onInit - if(!olMap.mapInstancied()) + // onInit + if (!olMap.mapInstancied()) return; - - checkSelectQuery(); + + checkSelectQuery(MapEventType.MOVE_END); } @Override public void moveStartListener(MapEvent event) { - - //onInit - if(!olMap.mapInstancied()) + + // onInit + if (!olMap.mapInstancied()) return; setDragStart(); - + } @Override public void mapZoomListener(MapEvent event) { - - //onInit - if(!olMap.mapInstancied()) + + // onInit + if (!olMap.mapInstancied()) return; - + setDragStart(); zoomStart = olMap.getCurrentZoomLevel(); - GWT.log("zoomStart: "+zoomStart); + GWT.log("zoomStart: " + zoomStart); } @Override public void mapZoomEndListener(MapEvent event) { - //onInit - if(!olMap.mapInstancied()) + // onInit + if (!olMap.mapInstancied()) return; - + setDragStart(); zoomEnd = olMap.getCurrentZoomLevel(); - GWT.log("zoomEnd: "+zoomEnd); - checkSelectQuery(); + GWT.log("zoomEnd: " + zoomEnd); + checkSelectQuery(MapEventType.MAP_ZOOM_END); } @@ -140,7 +141,7 @@ public class OLMapManager { double lon = coordinate.getX(); double lat = coordinate.getY(); - GWT.log("To quey DP: "+coordinate); + GWT.log("To quey DP: " + coordinate); int w = (int) olMap.getSize().getWidth(); int h = (int) olMap.getSize().getHeight(); @@ -150,16 +151,15 @@ public class OLMapManager { // where 10px is the pixel diameter dimension of the clicked point double bboxWidth = Math.abs(olMap.getExtent().getLowerLeftX() - olMap.getExtent().getUpperRightX()); double geoWidth = 0; - //adding a tolerance in case of manual click - if(manualClick) { - //adding a tolerance for clicking + // adding a tolerance in case of manual click + if (manualClick) { + // adding a tolerance for clicking geoWidth = (bboxWidth / w) * (14 / 2); - } - else { - //data point selection for coordinate loaded from concessione + } else { + // data point selection for coordinate loaded from concessione geoWidth = (bboxWidth / w) * (2); } - + double x1 = Math.min(lon + geoWidth, lon - geoWidth); double x2 = Math.max(lon + geoWidth, lon - geoWidth); double y1 = Math.min(lat + geoWidth, lat - geoWidth); @@ -182,8 +182,8 @@ public class OLMapManager { /** * Check select query. */ - private void checkSelectQuery() { - + private void checkSelectQuery(MapEventType mapEventType) { + GWT.log("Zoom is:" + olMap.getCurrentZoomLevel()); if (dragStartExtent != null && olMap.getCurrentZoomLevel() > QUERY_MIN_ZOOM_LEVEL) { @@ -199,12 +199,11 @@ public class OLMapManager { GWT.log("the distance is: " + dist); if (dist > 5000 || startExt.containsExtent(endExt)) { GeoQuery select = toDataBoxQuery(dragEndExtent); - layerManagerBus.fireEvent(new QueryDataEvent(select, endExt.getCenter(), null, false)); + layerManagerBus.fireEvent(new QueryDataEvent(select, endExt.getCenter(), null, false, mapEventType)); } - } - else if(zoomStart!=null && zoomEnd!=null) { - - if(zoomEnd { public static Type TYPE = new Type(); @@ -19,6 +20,7 @@ public class QueryDataEvent extends GwtEvent { private Coordinate onFailureCenterTo; private String mongoItemId; private boolean onInit; + private MapEventType sourceMapEventType; /** * Instantiates a new query data event. @@ -27,12 +29,15 @@ public class QueryDataEvent extends GwtEvent { * @param onFailureCenterTo the on failure center to * @param mongoItemId the mongo item id * @param onInit the on init + * @param mapEventType the map event type */ - public QueryDataEvent(GeoQuery select, Coordinate onFailureCenterTo, String mongoItemId, boolean onInit) { + public QueryDataEvent(GeoQuery select, Coordinate onFailureCenterTo, String mongoItemId, boolean onInit, + MapEventType mapEventType) { this.select = select; this.onFailureCenterTo = onFailureCenterTo; this.mongoItemId = mongoItemId; this.onInit = onInit; + this.sourceMapEventType = mapEventType; } /** @@ -45,6 +50,11 @@ public class QueryDataEvent extends GwtEvent { return TYPE; } + /** + * Gets the mongo item id. + * + * @return the mongo item id + */ public String getMongoItemId() { return mongoItemId; } @@ -78,10 +88,29 @@ public class QueryDataEvent extends GwtEvent { return select; } + /** + * Gets the on failure center to. + * + * @return the on failure center to + */ public Coordinate getOnFailureCenterTo() { return onFailureCenterTo; } + /** + * Gets the source map event type. + * + * @return the source map event type + */ + public MapEventType getSourceMapEventType() { + return sourceMapEventType; + } + + /** + * To string. + * + * @return the string + */ @Override public String toString() { StringBuilder builder = new StringBuilder(); @@ -93,6 +122,8 @@ public class QueryDataEvent extends GwtEvent { builder.append(mongoItemId); builder.append(", onInit="); builder.append(onInit); + builder.append(", sourceMapEventType="); + builder.append(sourceMapEventType); builder.append("]"); return builder.toString(); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java index 6bb974a..2c254e6 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java @@ -1,5 +1,7 @@ package org.gcube.portlets.user.geoportaldataviewer.client.gis; +import java.util.HashMap; + import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants; import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEvent; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem; @@ -13,6 +15,8 @@ import com.google.gwt.user.client.Event; import ol.Collection; import ol.Coordinate; +import ol.Feature; +import ol.FeatureOptions; import ol.Map; import ol.MapBrowserEvent; import ol.MapEvent; @@ -25,6 +29,7 @@ import ol.View; import ol.ViewOptions; import ol.control.Attribution; import ol.event.EventListener; +import ol.geom.Geometry; import ol.interaction.Draw; import ol.interaction.DrawOptions; import ol.interaction.Extent; @@ -36,6 +41,7 @@ import ol.layer.Base; import ol.layer.Image; import ol.layer.LayerOptions; import ol.layer.Tile; +import ol.layer.VectorLayerOptions; import ol.proj.Projection; import ol.proj.ProjectionOptions; import ol.source.ImageWms; @@ -45,74 +51,101 @@ import ol.source.Osm; import ol.source.Vector; import ol.source.XyzOptions; - // TODO: Auto-generated Javadoc /** * The Class OpenLayerOSM. * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * - * Oct 27, 2020 + * Oct 27, 2020 */ public abstract class OpenLayerOSM { - + + /** + * Click listener. + * + * @param event the event + */ public abstract void clickListener(MapBrowserEvent event); - + + /** + * Move end listener. + * + * @param event the event + */ public abstract void moveEndListener(MapEvent event); - + + /** + * Move start listener. + * + * @param event the event + */ public abstract void moveStartListener(MapEvent event); - + + /** + * Map zoom listener. + * + * @param event the event + */ public abstract void mapZoomListener(MapEvent event); - + + /** + * Map zoom end listener. + * + * @param event the event + */ public abstract void mapZoomEndListener(MapEvent event); /** The map. */ private Map map; - + /** The view. */ private View view; - + /** The view options. */ private ViewOptions viewOptions = OLFactory.createOptions(); - + /** The projection options. */ private ProjectionOptions projectionOptions = OLFactory.createOptions(); - + /** The point draw. */ private Draw queryPoint; - + private Extent queryBox; - + /** The popup overlay. */ private Overlay popupOverlay; private HandlerManager eventBus; - - private boolean isQueryBoxActive; - - private boolean isQueryPointActive; - - /** - * Instantiates a new open layer OSM. - * - * @param divTargetId the div target id - * @param eventBus the event bus - */ - /* (non-Javadoc) - * @see de.desjardins.ol3.demo.client.example.Example#show() - */ + private boolean isQueryBoxActive; + + private boolean isQueryPointActive; + + private java.util.Map wmsDetailsLayerMap; + + /** + * Instantiates a new open layer OSM. + * + * @param divTargetId the div target id + * @param eventBus the event bus + */ + /* + * (non-Javadoc) + * + * @see de.desjardins.ol3.demo.client.example.Example#show() + */ public OpenLayerOSM(String divTargetId, HandlerManager eventBus) { this.eventBus = eventBus; - // create a OSM-layer - XyzOptions osmSourceOptions = OLFactory.createOptions(); + // create a OSM-layer + XyzOptions osmSourceOptions = OLFactory.createOptions(); - Osm osmSource = new Osm(osmSourceOptions); - LayerOptions osmLayerOptions = OLFactory.createOptions(); - osmLayerOptions.setSource(osmSource); + Osm osmSource = new Osm(osmSourceOptions); + LayerOptions osmLayerOptions = OLFactory.createOptions(); + osmLayerOptions.setSource(osmSource); - Tile osmLayer = new Tile(osmLayerOptions); + Tile osmLayer = new Tile(osmLayerOptions); // create a projection projectionOptions.setCode(GeoportalDataViewerConstants.EPSG_3857); projectionOptions.setUnits("m"); @@ -120,39 +153,41 @@ public abstract class OpenLayerOSM { Projection projection = new Projection(projectionOptions); viewOptions.setProjection(projection); viewOptions.setMaxZoom(19); - - // create a view - view = new View(viewOptions); - - // create the map - MapOptions mapOptions = OLFactory.createOptions(); - mapOptions.setTarget(divTargetId); - mapOptions.setView(view); + // create a view + view = new View(viewOptions); - map = new Map(mapOptions); + // create the map + MapOptions mapOptions = OLFactory.createOptions(); + mapOptions.setTarget(divTargetId); + mapOptions.setView(view); - map.addLayer(osmLayer); - //map.addLayer(tileDebugLayer); + map = new Map(mapOptions); - // add some controls - map.addControl(OLFactory.createScaleLine()); - MapUtils.addDefaultControls(map.getControls()); + map.addLayer(osmLayer); + // map.addLayer(tileDebugLayer); - Attribution attribution = new Attribution(); - attribution.setCollapsed(true); - map.addControl(attribution); - - // add some interactions - map.addInteraction(new KeyboardPan()); - map.addInteraction(new KeyboardZoom()); - - bindEvents(); + // add some controls + map.addControl(OLFactory.createScaleLine()); + MapUtils.addDefaultControls(map.getControls()); - } - + Attribution attribution = new Attribution(); + attribution.setCollapsed(true); + map.addControl(attribution); + + // add some interactions + map.addInteraction(new KeyboardPan()); + map.addInteraction(new KeyboardZoom()); + + bindEvents(); + + } + + /** + * Bind events. + */ private void bindEvents() { - + map.addClickListener(new EventListener() { @Override @@ -168,7 +203,7 @@ public abstract class OpenLayerOSM { moveEndListener(event); } }); - + map.addMoveStartListener(new EventListener() { @Override @@ -176,7 +211,7 @@ public abstract class OpenLayerOSM { moveStartListener(event); } }); - + map.addMapZoomListener(new EventListener() { @Override @@ -184,7 +219,7 @@ public abstract class OpenLayerOSM { mapZoomListener(event); } }); - + map.addMapZoomEndListener(new EventListener() { @Override @@ -193,32 +228,37 @@ public abstract class OpenLayerOSM { } }); } - + /** * Sets the center. * * @param centerCoordinate the new center */ public void setCenter(Coordinate centerCoordinate) { - view.setCenter(centerCoordinate); + view.setCenter(centerCoordinate); } - + /** * Sets the center. * - * @param centerCoordinate the new center + * @param zoom the new zoom */ public void setZoom(int zoom) { - view.setZoom(zoom); + view.setZoom(zoom); } - + /** + * Show popup. + * + * @param html the html + * @param coordinate the coordinate + */ public void showPopup(String html, Coordinate coordinate) { - GWT.log("Showing popup on: "+coordinate); - //GeoportalDataViewerConstants.print("Showing popup on: "+coordinate); + GWT.log("Showing popup on: " + coordinate); + // GeoportalDataViewerConstants.print("Showing popup on: "+coordinate); Element elPopup = DOM.getElementById("popup"); elPopup.getStyle().setVisibility(Visibility.VISIBLE); - if(popupOverlay==null) { + if (popupOverlay == null) { popupOverlay = addOverlay(elPopup); addPopupCloserHandelr(popupOverlay); } @@ -226,14 +266,17 @@ public abstract class OpenLayerOSM { popContent.setInnerHTML(html); popupOverlay.setPosition(coordinate); } - + + /** + * Hide popup. + */ public void hidePopup() { - if(popupOverlay!=null) { + if (popupOverlay != null) { Element elPopup = DOM.getElementById("popup"); elPopup.getStyle().setVisibility(Visibility.HIDDEN); } } - + /** * Adds the popup closer handelr. * @@ -253,11 +296,11 @@ public abstract class OpenLayerOSM { } }); } - + /** * Handler popu closer. * - * @param divId the div id + * @param divId the div id * @param overlayId the overlay id */ public static native void handlerPopuCloser(String divId, String overlayId) /*-{ @@ -271,21 +314,20 @@ public abstract class OpenLayerOSM { }-*/; - /** * Adds the WMS layer. * * @param layerItem the layer item */ public void addWMSLayer(LayerItem layerItem) { - + ImageWmsParams imageWMSParams = OLFactory.createOptions(); imageWMSParams.setLayers(layerItem.getName()); ImageWmsOptions imageWMSOptions = OLFactory.createOptions(); imageWMSOptions.setUrl(layerItem.getMapServerHost()); imageWMSOptions.setParams(imageWMSParams); - //imageWMSOptions.setRatio(1.5f); + // imageWMSOptions.setRatio(1.5f); ImageWms imageWMSSource = new ImageWms(imageWMSOptions); @@ -293,29 +335,142 @@ public abstract class OpenLayerOSM { layerOptions.setSource(imageWMSSource); Image wmsLayer = new Image(layerOptions); - - //visibleLayerItems - + + // visibleLayerItems + map.addLayer(wmsLayer); GWT.log("Fired the event Added Layer"); eventBus.fireEvent(new AddedLayerToMapEvent(layerItem)); - + } - + + /** + * Adds the WMS detail layer. + * + * @param layerItem the layer item + */ + public void addWMSDetailLayer(LayerItem layerItem) { + + if (wmsDetailsLayerMap == null) + wmsDetailsLayerMap = new HashMap(); + + String key = layerItem.getMapServerHost() + "/layer/" + layerItem.getName(); + + Image layer = wmsDetailsLayerMap.get(key); + + if (layer == null) { + 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.setParams(imageWMSParams); + // imageWMSOptions.setRatio(1.5f); + + ImageWms imageWMSSource = new ImageWms(imageWMSOptions); + + LayerOptions layerOptions = OLFactory.createOptions(); + layerOptions.setSource(imageWMSSource); + + Image wmsLayer = new Image(layerOptions); + + // visibleLayerItems + + map.addLayer(wmsLayer); + wmsDetailsLayerMap.put(key, wmsLayer); + + GWT.log("Fired the event Added Layer"); + eventBus.fireEvent(new AddedLayerToMapEvent(layerItem)); + } else { + GWT.log("The detail layer with key: " + key + " already exists, skipping"); + } + + } + + public void removeAllDetailLayers() { + if (wmsDetailsLayerMap == null) + return; + + for (String key : wmsDetailsLayerMap.keySet()) { + Image layer = wmsDetailsLayerMap.get(key); + map.removeLayer(layer); + } + + wmsDetailsLayerMap.clear(); + + } + +// public void addGeometry(Geometry theGeom) { +// +// if(theGeom==null) +// return; +// +// if(geometryLayer==null) { +// geometryLayer = new Vector("Feature selected"); +// geometryLayer.setDisplayInLayerSwitcher(false); +// map.addLayer(geometryLayer); +// }else { +// geometryLayer.removeAllFeatures(); +// } +// Style style = new Style(); +// style.setFillColor("#00FF00"); +// style.setGraphicName("circle"); +// style.setPointRadius(10); +// VectorFeature vf = new VectorFeature(theGeom, style); +// geometryLayer.addFeature(vf); +// } +// +// +// protected void removeGeometries() { +// if(geometryLayer!=null) +// geometryLayer.removeAllFeatures(); +// } + + /** + * Adds the vector. + * + * @param geometry the geometry + */ + public void addVector(Geometry geometry) { + + VectorLayerOptions vectorLayerOptions = new VectorLayerOptions(); + vectorLayerOptions.setMap(map); + +// Style style = new Style(); +// FillOptions fillOptions = new FillOptions(); +// Color color = new Color(0, 0, 255, 1.0); +// fillOptions.setColor(color); +// Fill fill = new Fill(fillOptions); +// style.setFill(fill); + + FeatureOptions featureOptions = new FeatureOptions(); + featureOptions.setGeometry(geometry); + Feature feature = OLFactory.createFeature(featureOptions); + + Vector vectorSource = OLFactory.createVectorSource(); + vectorSource.addFeature(feature); + vectorLayerOptions.setSource(vectorSource); + + ol.layer.Vector vector = OLFactory.createVector(vectorLayerOptions); + + map.addLayer(vector); + } + /** * Adds the point vector source. * * @return the draw */ public Draw addPointVectorSource() { - if(queryPoint==null) + if (queryPoint == null) initPointInteraction(); - + map.addInteraction(queryPoint); isQueryPointActive = true; return queryPoint; } - + /** * Inits the point interaction. */ @@ -328,39 +483,39 @@ public abstract class OpenLayerOSM { drawOptions.setMinPoints(1); drawOptions.setWrapX(false); queryPoint = new Draw(drawOptions); - + queryPoint.addChangeListener(new EventListener() { @Override public void onEvent(ol.events.Event event) { GWT.log(event.getType()); - + } }); } - + /** * Removes the interaction. * * @param interaction the interaction */ public void removeInteraction(Interaction interaction) { - map.removeInteraction(interaction); + map.removeInteraction(interaction); } - + /** * Removes the interactions. */ public void removeQueryInteractions() { Collection interactions = map.getInteractions(); - if(interactions!=null) { + if (interactions != null) { map.removeInteraction(queryBox); map.removeInteraction(queryPoint); isQueryBoxActive = false; isQueryPointActive = false; } } - + /** * Adds the extent interaction. * @@ -369,17 +524,16 @@ public abstract class OpenLayerOSM { public Extent addExtentInteraction() { ExtentOptions extentOptions = new ExtentOptions(); extentOptions.setWrapX(false); - //StyleOptions styleOptions = new StyleOptions(); - //styleOptions.setStroke(stroke); - //styleOptions.set - //extentOptions.setBoxStyle(new ol.style.Style(styleOptions)); + // StyleOptions styleOptions = new StyleOptions(); + // styleOptions.setStroke(stroke); + // styleOptions.set + // extentOptions.setBoxStyle(new ol.style.Style(styleOptions)); queryBox = new Extent(extentOptions); map.addInteraction(queryBox); isQueryBoxActive = true; return queryBox; } - - + /** * Adds the overlay. * @@ -405,23 +559,22 @@ public abstract class OpenLayerOSM { * @return true, if is layer visible */ public boolean isLayerVisible(String layerName) { - + Collection layers = map.getLayers(); - - if(layers!=null) { + + if (layers != null) { Base[] layersArr = layers.getArray(); for (int i = 0; i < layersArr.length; i++) { Base layer = layersArr[i]; String theLayerName = (String) layer.get("name"); - GWT.log("The Layer name is: "+layerName); - if(theLayerName!=null && theLayerName.equals(layerName)) + GWT.log("The Layer name is: " + layerName); + if (theLayerName != null && theLayerName.equals(layerName)) return true; } } - + return false; } - /** * Gets the projection code. @@ -431,7 +584,6 @@ public abstract class OpenLayerOSM { public String getProjectionCode() { return map.getView().getProjection().getCode(); } - /** * Gets the current zoom level. @@ -441,9 +593,7 @@ public abstract class OpenLayerOSM { public double getCurrentZoomLevel() { return map.getView().getZoom(); } - - - + /** * Gets the bbox. * @@ -452,7 +602,7 @@ public abstract class OpenLayerOSM { public ol.Extent getBBOX() { return getExtent(); } - + /** * Gets the extent. * @@ -461,26 +611,53 @@ public abstract class OpenLayerOSM { public ol.Extent getExtent() { return this.map.getView().calculateExtent(map.getSize()); } - - public Coordinate transform (Coordinate centerCoordinate, String source, String target){ - return Projection.transform(centerCoordinate, source, target); + + /** + * Transform. + * + * @param centerCoordinate the center coordinate + * @param source the source + * @param target the target + * @return the coordinate + */ + public Coordinate transform(Coordinate centerCoordinate, String source, String target) { + return Projection.transform(centerCoordinate, source, target); } - + + /** + * Checks if is query box active. + * + * @return true, if is query box active + */ public boolean isQueryBoxActive() { return isQueryBoxActive; } - + + /** + * Checks if is query point active. + * + * @return true, if is query point active + */ public boolean isQueryPointActive() { return isQueryPointActive; } - + + /** + * Gets the size. + * + * @return the size + */ public Size getSize() { return map.getSize(); } + /** + * Map instancied. + * + * @return true, if successful + */ public boolean mapInstancied() { - return this.map!=null; - } + return this.map != null; + } } - diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/gallery/ImagesGallery.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/gallery/ImagesGallery.java index 414fb96..b226ec3 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/gallery/ImagesGallery.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/gallery/ImagesGallery.java @@ -140,22 +140,24 @@ public class ImagesGallery { JSONArray jsonArray = new JSONArray(); int index = 0; for (UploadedImageDV image : listImages) { - for (WorkspaceContentDV imageContent : image.getListWsContent()) { - JSONObject json = new JSONObject(); - json.put("src", new JSONString(imageContent.getLink())); - json.put("srct", new JSONString(imageContent.getLink())); - List listAuthors = image.getResponsabili(); - String txtAuthors = listAuthors.size()>1 ? "Authors: ": "Author: "; - for (String author : listAuthors) { - txtAuthors+= " "+author +","; + if(image.getListWsContent()!=null) { + for (WorkspaceContentDV imageContent : image.getListWsContent()) { + JSONObject json = new JSONObject(); + json.put("src", new JSONString(imageContent.getLink())); + json.put("srct", new JSONString(imageContent.getLink())); + List listAuthors = image.getResponsabili(); + String txtAuthors = listAuthors.size()>1 ? "Authors: ": "Author: "; + for (String author : listAuthors) { + txtAuthors+= " "+author +","; + } + txtAuthors = txtAuthors.substring(0,txtAuthors.length()-2); + String description = txtAuthors + ". ID Licenza: "+image.getLicenseID(); + json.put("title", new JSONString(image.getDidascalia())); + json.put("description", new JSONString(description)); + json.put("downloadURL", new JSONString(imageContent.getLink())); + jsonArray.set(index, json); + index++; } - txtAuthors = txtAuthors.substring(0,txtAuthors.length()-2); - String description = txtAuthors + ". ID Licenza: "+image.getLicenseID(); - json.put("title", new JSONString(image.getDidascalia())); - json.put("description", new JSONString(description)); - json.put("downloadURL", new JSONString(imageContent.getLink())); - jsonArray.set(index, json); - index++; } } 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 aad93aa..83b63de 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 @@ -230,8 +230,8 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme /** * Gets the layers for id. * - * @param itemType the item type - * @param itemId the item id + * @param itemType the item type + * @param itemId the item id * @return the layers for id * @throws Exception the exception */ @@ -469,4 +469,36 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme return SessionUtil.isSessionExpired(this.getThreadLocalRequest()); } + /** + * Gets the WFS features. + * + * @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 WFS features + */ + @Override + public List getWFSFeatures(List layerObjects, String mapSrsName, + BoundsMap selectBBOX, int maxWFSFeature, double zoomLevel) { + LOG.info("getWFSFeatures 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); + 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; + } + } -- 2.17.1 From b337955f714a4ad9b3d1ec265843d44b7b45106e Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 1 Sep 2021 12:51:06 +0200 Subject: [PATCH 10/38] added MAP_PROJECTION object --- .../client/GeoportalDataViewer.java | 3 +- .../client/GeoportalDataViewerConstants.java | 68 ++++--- .../client/LayerManager.java | 21 +- .../client/OLMapManager.java | 19 +- .../client/events/MapExtentToEvent.java | 52 +++++ .../events/MapExtentToEventHandler.java | 20 ++ .../client/gis/LightOpenLayerOSM.java | 190 +++++++++--------- .../client/gis/OpenLayerOSM.java | 8 +- .../client/resources/Images.java | 3 + .../client/resources/italy.png | Bin 0 -> 1398 bytes .../client/ui/GeonaDataViewMainPanel.java | 49 +++-- .../client/ui/GeonaDataViewMainPanel.ui.xml | 17 +- .../client/ui/map/ExtentMapUtil.java | 170 ++++++++++++++++ .../client/ui/map/MapView.java | 26 ++- .../products/concessioni/ConcessioneView.java | 13 +- .../concessioni/LayerConcessioneView.java | 14 +- 16 files changed, 491 insertions(+), 182 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/MapExtentToEvent.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/MapExtentToEventHandler.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/italy.png create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/ExtentMapUtil.java 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 71936ed..e2e42de 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 @@ -7,6 +7,7 @@ import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.LayerItem; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.model.RecordDV; +import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MapEventType; import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEventHandler; @@ -335,7 +336,7 @@ public class GeoportalDataViewer implements EntryPoint { Double y = concessioneDV.getCentroidLat(); GWT.log("X: "+x +", Y:"+y); if(x!=null && y!=null) { - Coordinate transfCoord = MapUtils.transformCoordiante(new Coordinate(x, y), GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857); + Coordinate transfCoord = MapUtils.transformCoordiante(new Coordinate(x, y), MAP_PROJECTION.EPSG_4326.getName(), MAP_PROJECTION.EPSG_3857.getName()); GeoQuery select = olMapMng.toDataPointQuery(transfCoord,false); GWT.log("GeoQuery: "+select); //GeoportalDataViewerConstants.print("fireEvent QueryDataEvent"); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java index caccf86..6792d3b 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java @@ -10,15 +10,15 @@ import com.google.gwt.i18n.client.DateTimeFormat; * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * - * Nov 24, 2020 + * Nov 24, 2020 */ public class GeoportalDataViewerConstants { - public static final String EPSG_4326 = "EPSG:4326"; - public static final String EPSG_3857 = "EPSG:3857"; +// public static final String EPSG_4326 = "EPSG:4326"; +// public static final String EPSG_3857 = "EPSG:3857"; public static final String MAP_DIV = "map"; - + public static final String GET_WMS_PARAMETER = "wmsrequest"; public static final String GET_GEONA_ITEM_TYPE = "git"; public static final String GET_GEONA_ITEM_ID = "gid"; @@ -27,32 +27,51 @@ public class GeoportalDataViewerConstants { public static final String GET_MAX_ZOOM_LEVEL = OpenLayersMapParameters.OL_MAP_PARAM.maxzoomlevel.name(); public static final String GET_ZOOM = OpenLayersMapParameters.OL_MAP_PARAM.zoom.name(); public static final String GET_CENTER_MAP_TO_LONG_LAT = OpenLayersMapParameters.OL_MAP_PARAM.centermap.name(); - - public static enum MapEventType {INIT, MAP_ZOOM_END, MOVE_END, ADDED_LAYER_TO_MAP} - + + public static enum MapEventType { + INIT, MAP_ZOOM_END, MOVE_END, ADDED_LAYER_TO_MAP + } + /** * The Enum LayerType. * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * - * Nov 24, 2020 + * Nov 24, 2020 */ - public enum LayerType {RASTER_BASELAYER, FEATURE_TYPE}; - - public static final int MAX_WFS_FEATURES = 3; // zero for no limit - - public static final String NEW_LINE_BR = "
"; - - public static final double ITALY_CENTER_LONG = 12.45; - - public static final double ITALY_CENTER_LAT = 42.98; - - public static final int LIGHT_MAP_ITALY_FIT_ZOOM_ON = 5; - - public static final int MAP_ITALY_FIT_ZOOM_ON = 6; - + public enum LayerType { + RASTER_BASELAYER, FEATURE_TYPE + }; + public static DateTimeFormat DT_FORMAT = DateTimeFormat.getFormat(ConvertToDataViewModel.DATE_FORMAT); - + + public static final int MAX_WFS_FEATURES = 3; // zero for no limit + + public static final String NEW_LINE_BR = "
"; + + public static enum MAP_PROJECTION { + + EPSG_4326("EPSG:4326"), EPSG_3857("EPSG:3857"); + + String name; + + MAP_PROJECTION(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + } + + public static final double ITALY_CENTER_LONG = 12.45; + + public static final double ITALY_CENTER_LAT = 42.98; + + public static final int LIGHT_MAP_ITALY_FIT_ZOOM_ON = 5; + + public static final int MAP_ITALY_FIT_ZOOM_ON = 6; /** * Prints the. @@ -60,8 +79,7 @@ public class GeoportalDataViewerConstants { * @param msg the msg */ public static native void printJs(String msg)/*-{ - console.log("js console: "+msg); + console.log("js console: " + msg); }-*/; - } 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 35a000c..3222214 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 @@ -13,7 +13,7 @@ import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceCo import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV; 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.MapEventType; +import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION; import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEventHandler; import org.gcube.portlets.user.geoportaldataviewer.client.events.QueryDataEvent; @@ -123,8 +123,8 @@ public class LayerManager { double minX = queryEvent.getGeoQuery().getX1(); double minY = queryEvent.getGeoQuery().getY1(); Coordinate centerCoordinate = new Coordinate(minX, minY); - centerCoordinate = olMap.transform(centerCoordinate, GeoportalDataViewerConstants.EPSG_3857, - GeoportalDataViewerConstants.EPSG_4326); + centerCoordinate = olMap.transform(centerCoordinate, MAP_PROJECTION.EPSG_3857.getName(), + MAP_PROJECTION.EPSG_4326.getName()); mapBBOX.setLowerLeftX(centerCoordinate.getX()); mapBBOX.setLowerLeftY(centerCoordinate.getY()); @@ -133,12 +133,12 @@ public class LayerManager { double maxX = queryEvent.getGeoQuery().getX2(); double maxY = queryEvent.getGeoQuery().getY2(); centerCoordinate = new Coordinate(maxX, maxY); - centerCoordinate = olMap.transform(centerCoordinate, GeoportalDataViewerConstants.EPSG_3857, - GeoportalDataViewerConstants.EPSG_4326); + centerCoordinate = olMap.transform(centerCoordinate, MAP_PROJECTION.EPSG_3857.getName(), + MAP_PROJECTION.EPSG_4326.getName()); mapBBOX.setUpperRightX(centerCoordinate.getX()); mapBBOX.setUpperRightY(centerCoordinate.getY()); - mapBBOX.setCrs(GeoportalDataViewerConstants.EPSG_4326); + mapBBOX.setCrs(MAP_PROJECTION.EPSG_4326.getName()); GWT.log("Bounds is: " + mapBBOX); GWT.log("MAX_WFS_FEATURES is: " + GeoportalDataViewerConstants.MAX_WFS_FEATURES); @@ -254,10 +254,10 @@ public class LayerManager { olMap.removeAllDetailLayers(); } - if(queryEvent.getSourceMapEventType() != null && queryEvent.getSourceMapEventType().equals(MapEventType.MAP_ZOOM_END)) { - GWT.log("EVENT IS "+MapEventType.MAP_ZOOM_END +" retuning"); - return; - } +// if(queryEvent.getSourceMapEventType() != null && queryEvent.getSourceMapEventType().equals(MapEventType.MAP_ZOOM_END)) { +// GWT.log("EVENT IS "+MapEventType.MAP_ZOOM_END +" retuning"); +// return; +// } //Showing properties belonging to concessioni centroid layer Map> entries = feature.getMapProperties(); @@ -412,6 +412,7 @@ public class LayerManager { @Override public void onZoomOut(ZoomOutOverMinimumEvent zoomOutEvent) { GWT.log("Fired into layerManagerBus " + zoomOutEvent); + olMap.removeAllDetailLayers(); applicationBus.fireEvent(zoomOutEvent); } }); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java index d5aa4e8..a09d472 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java @@ -1,11 +1,15 @@ package org.gcube.portlets.user.geoportaldataviewer.client; +import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MapEventType; import org.gcube.portlets.user.geoportaldataviewer.client.events.QueryDataEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.ZoomOutOverMinimumEvent; import org.gcube.portlets.user.geoportaldataviewer.client.gis.ExtentWrapped; import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils; import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerOSM; +import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil; +import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.Location; +import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.PLACE; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery.TYPE; @@ -15,7 +19,6 @@ import com.google.gwt.event.shared.HandlerManager; import ol.Coordinate; import ol.MapBrowserEvent; import ol.MapEvent; -import ol.OLFactory; /** * The Class OLMapManager. @@ -121,13 +124,17 @@ public class OLMapManager { }; // EPSG_4326_TO_ITALY - Coordinate centerCoordinate = OLFactory.createCoordinate(GeoportalDataViewerConstants.ITALY_CENTER_LONG, - GeoportalDataViewerConstants.ITALY_CENTER_LAT); - Coordinate transformedCenterCoordinate = MapUtils.transformCoordiante(centerCoordinate, - GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857); +// Coordinate centerCoordinate = OLFactory.createCoordinate(GeoportalDataViewerConstants.ITALY_CENTER_LONG, +// GeoportalDataViewerConstants.ITALY_CENTER_LAT); +// Coordinate transformedCenterCoordinate = MapUtils.transformCoordiante(centerCoordinate, +// MAP_PROJECTION.EPSG_4326.getName(), MAP_PROJECTION.EPSG_3857.getName()); +// olMap.setCenter(transformedCenterCoordinate); +// olMap.setZoom(GeoportalDataViewerConstants.MAP_ITALY_FIT_ZOOM_ON); + Location italyLocation = ExtentMapUtil.getLocation(PLACE.ITALY); + Coordinate transformedCenterCoordinate = italyLocation.getCoordinate(MAP_PROJECTION.EPSG_3857); olMap.setCenter(transformedCenterCoordinate); - olMap.setZoom(GeoportalDataViewerConstants.MAP_ITALY_FIT_ZOOM_ON); + olMap.setZoom(italyLocation.getZoomLevel()); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/MapExtentToEvent.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/MapExtentToEvent.java new file mode 100644 index 0000000..af4c60e --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/MapExtentToEvent.java @@ -0,0 +1,52 @@ +package org.gcube.portlets.user.geoportaldataviewer.client.events; + +import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.Location; + +import com.google.gwt.event.shared.GwtEvent; + +/** + * The Class MapExtentToEvent. + * + * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) + * + * Sep 1, 2021 + */ +public class MapExtentToEvent extends GwtEvent { + public static Type TYPE = new Type(); + private Location location; + + /** + * Instantiates a new map extent to event. + * + * @param layerItem the layer item + */ + public MapExtentToEvent(Location location) { + this.location = location; + } + + /** + * Gets the associated type. + * + * @return the associated type + */ + @Override + public Type getAssociatedType() { + return TYPE; + } + + /** + * Dispatch. + * + * @param handler the handler + */ + @Override + protected void dispatch(MapExtentToEventHandler handler) { + handler.onExtentEvent(this); + + } + + public Location getLocation() { + return location; + } + +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/MapExtentToEventHandler.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/MapExtentToEventHandler.java new file mode 100644 index 0000000..172c6ac --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/MapExtentToEventHandler.java @@ -0,0 +1,20 @@ +package org.gcube.portlets.user.geoportaldataviewer.client.events; + +import com.google.gwt.event.shared.EventHandler; + +/** + * The Interface MapExtentToEventHandler. + * + * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) + * + * Sep 1, 2021 + */ +public interface MapExtentToEventHandler extends EventHandler { + + /** + * On extent event. + * + * @param mapExtentToEvent the map extent to event + */ + void onExtentEvent(MapExtentToEvent mapExtentToEvent); +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerOSM.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerOSM.java index 4d62cb6..cb44a29 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerOSM.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerOSM.java @@ -1,7 +1,7 @@ package org.gcube.portlets.user.geoportaldataviewer.client.gis; import org.gcube.application.geoportalcommon.shared.gis.BoundsMap; -import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants; +import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION; import org.gcube.portlets.user.geoportaldataviewer.client.resources.Images; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery.TYPE; @@ -39,34 +39,33 @@ import ol.style.Style; import ol.style.Text; import ol.style.TextOptions; - /** - * The Class LightOpenLayerOSM. - * - * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) - * - * Nov 11, 2020 - */ - public class LightOpenLayerOSM { - +/** + * The Class LightOpenLayerOSM. + * + * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) + * + * Nov 11, 2020 + */ +public class LightOpenLayerOSM { + /** The map. */ private Map map; - + /** The view. */ private View view; - + /** The view options. */ private ViewOptions viewOptions = OLFactory.createOptions(); - + /** The projection options. */ private ProjectionOptions projectionOptions = OLFactory.createOptions(); - + private boolean isQueryPointActive; - + private ol.layer.Vector geometryLayer; - + private String markerURL = Images.ICONS.mapMarkerIcon().getURL(); - - + /** * Instantiates a new light open layer OSM. * @@ -74,123 +73,122 @@ import ol.style.TextOptions; */ public LightOpenLayerOSM(String divTargetId) { - // create a OSM-layer - XyzOptions osmSourceOptions = OLFactory.createOptions(); + // create a OSM-layer + XyzOptions osmSourceOptions = OLFactory.createOptions(); - Osm osmSource = new Osm(osmSourceOptions); - LayerOptions osmLayerOptions = OLFactory.createOptions(); - osmLayerOptions.setSource(osmSource); + Osm osmSource = new Osm(osmSourceOptions); + LayerOptions osmLayerOptions = OLFactory.createOptions(); + osmLayerOptions.setSource(osmSource); - Tile osmLayer = new Tile(osmLayerOptions); + Tile osmLayer = new Tile(osmLayerOptions); // create a projection - projectionOptions.setCode(GeoportalDataViewerConstants.EPSG_3857); + projectionOptions.setCode(MAP_PROJECTION.EPSG_3857.getName()); projectionOptions.setUnits("m"); Projection projection = new Projection(projectionOptions); viewOptions.setProjection(projection); viewOptions.setMaxZoom(20); - // create a view - view = new View(viewOptions); - - // create the map - MapOptions mapOptions = OLFactory.createOptions(); - mapOptions.setTarget(divTargetId); - mapOptions.setView(view); + // create a view + view = new View(viewOptions); - map = new Map(mapOptions); + // create the map + MapOptions mapOptions = OLFactory.createOptions(); + mapOptions.setTarget(divTargetId); + mapOptions.setView(view); - map.addLayer(osmLayer); - //map.addLayer(tileDebugLayer); + map = new Map(mapOptions); + + map.addLayer(osmLayer); + // map.addLayer(tileDebugLayer); + + Attribution attribution = new Attribution(); + attribution.setCollapsed(true); + + map.addClickListener(new EventListener() { - Attribution attribution = new Attribution(); - attribution.setCollapsed(true); - - map.addClickListener(new EventListener() { - @Override public void onEvent(MapBrowserEvent event) { // TODO Auto-generated method stub Coordinate coordinate = event.getCoordinate(); - if(isQueryPointActive) { - + if (isQueryPointActive) { + double lon = coordinate.getX(); double lat = coordinate.getY(); - + int w = (int) map.getSize().getWidth(); int h = (int) map.getSize().getHeight(); - // handler.clickOnMap(x, y, w, h); - - // ratio - mapPixelWeight : bboxWeight = 10px : geoRectangleWidth + // handler.clickOnMap(x, y, w, h); + + // ratio - mapPixelWeight : bboxWeight = 10px : geoRectangleWidth // where 10px is the pixel diameter dimension of the clicked point double bboxWidth = Math.abs(getExtent().getLowerLeftX() - getExtent().getUpperRightX()); double geoWidth = (bboxWidth / w) * (20 / 2); - double x1 = Math.min(lon+geoWidth, lon-geoWidth); - double x2 = Math.max(lon+geoWidth, lon-geoWidth); - double y1 = Math.min(lat+geoWidth, lat-geoWidth); - double y2 = Math.max(lat+geoWidth, lat-geoWidth); - //GWT.log("("+x1+","+y1+")("+x2+","+y2+")"); + double x1 = Math.min(lon + geoWidth, lon - geoWidth); + double x2 = Math.max(lon + geoWidth, lon - geoWidth); + double y1 = Math.min(lat + geoWidth, lat - geoWidth); + double y2 = Math.max(lat + geoWidth, lat - geoWidth); + // GWT.log("("+x1+","+y1+")("+x2+","+y2+")"); // Point pt = new Point(coordinate); // ol.Extent extent = pt.getExtent(); // //new ClickDataInfo(x1, y1, x2, y2) // SelectDataInfo selectDataInfo - //selectBox(new GeoQuery(x1, y1, x2, y2, GeoQuery.TYPE.POINT)); + // selectBox(new GeoQuery(x1, y1, x2, y2, GeoQuery.TYPE.POINT)); GeoQuery select = new GeoQuery(x1, y1, x2, y2, TYPE.POINT); - + } } }); - map.addControl(attribution); + map.addControl(attribution); + + // add some interactions + map.addInteraction(new KeyboardPan()); + map.addInteraction(new KeyboardZoom()); + + } - // add some interactions - map.addInteraction(new KeyboardPan()); - map.addInteraction(new KeyboardZoom()); - - } - - /** * Sets the center. * * @param centerCoordinate the new center */ public void setCenter(Coordinate centerCoordinate) { - view.setCenter(centerCoordinate); + view.setCenter(centerCoordinate); } - + /** * Sets the center. * * @param zoom the new zoom */ public void setZoom(int zoom) { - view.setZoom(zoom); + view.setZoom(zoom); } - + /** * Adds the WMS layer. * * @param mapServerHost the map server host - * @param layerName the layer name - * @param bbox + * @param layerName the layer name + * @param bbox * @return the image */ public Image addWMSLayer(String mapServerHost, String layerName, BoundsMap bbox) { - GWT.log("Adding wmsLayer with mapServerHost: "+mapServerHost+", layerName: "+layerName); - + GWT.log("Adding wmsLayer with mapServerHost: " + mapServerHost + ", layerName: " + layerName); + ImageWmsParams imageWMSParams = OLFactory.createOptions(); imageWMSParams.setLayers(layerName); - //imageWMSParams.setSize(new Size(400,400)); - //imageWMSParams.setVersion("1.1.0"); + // imageWMSParams.setSize(new Size(400,400)); + // imageWMSParams.setVersion("1.1.0"); // if(bbox!=null) // imageWMSParams.set("BBOX", bbox.getLowerLeftX()+","+bbox.getLowerLeftY()+","+bbox.getUpperRightX()+","+bbox.getUpperRightY()); ImageWmsOptions imageWMSOptions = OLFactory.createOptions(); imageWMSOptions.setUrl(mapServerHost); imageWMSOptions.setParams(imageWMSParams); - //imageWMSOptions.setRatio(1.5f); + // imageWMSOptions.setRatio(1.5f); ImageWms imageWMSSource = new ImageWms(imageWMSOptions); @@ -198,50 +196,48 @@ import ol.style.TextOptions; layerOptions.setSource(imageWMSSource); ol.layer.Image wmsLayer = new ol.layer.Image(layerOptions); - //visibleLayerItems + // visibleLayerItems map.addLayer(wmsLayer); return wmsLayer; } - - + /** * Gets the first layer. * * @return the first layer */ public Image getFirstLayer() { - if(map.getLayers()!=null) { + if (map.getLayers() != null) { return (Image) map.getLayers().getArray()[0]; } return null; } - /** * Adds the point. * - * @param coordinate the coordinate + * @param coordinate the coordinate * @param showCoordinateText the show coordinate text - * @param asMarker the as marker + * @param asMarker the as marker */ public void addPoint(Coordinate coordinate, boolean showCoordinateText, boolean asMarker) { - - if(geometryLayer!=null) { + + if (geometryLayer != null) { map.removeLayer(geometryLayer); - }else { - + } else { + } Style style = new Style(); - - if(asMarker) { + + if (asMarker) { IconOptions iconOptions = new IconOptions(); iconOptions.setSrc(markerURL); Icon icon = new Icon(iconOptions); style.setImage(icon); } - - if(showCoordinateText) { + + if (showCoordinateText) { TextOptions textOptions = new TextOptions(); textOptions.setOffsetY(-25); // StrokeOptions strokeOptions = new StrokeOptions(); @@ -253,10 +249,11 @@ import ol.style.TextOptions; // fillOptions.setColor(new Color(0, 0, 0, 0.0)); // textOptions.setFill(new Fill(fillOptions)); - Coordinate transfCoord = MapUtils.transformCoordiante(coordinate, GeoportalDataViewerConstants.EPSG_3857, GeoportalDataViewerConstants.EPSG_4326); - //DecimalFormat df = new DecimalFormat("#.####"); + Coordinate transfCoord = MapUtils.transformCoordiante(coordinate, MAP_PROJECTION.EPSG_3857.getName(), + MAP_PROJECTION.EPSG_4326.getName()); + // DecimalFormat df = new DecimalFormat("#.####"); NumberFormat fmt = NumberFormat.getFormat("#.####"); - textOptions.setText("Long: "+fmt.format(transfCoord.getX()) + ", Lat: "+fmt.format(transfCoord.getY())); + textOptions.setText("Long: " + fmt.format(transfCoord.getX()) + ", Lat: " + fmt.format(transfCoord.getY())); Text text = new Text(textOptions); // FillOptions fillOptions = new FillOptions(); @@ -266,7 +263,6 @@ import ol.style.TextOptions; // style.setFill(fill); style.setText(text); - } Point thePoint = new Point(coordinate); Feature vf = new Feature(thePoint); @@ -278,7 +274,7 @@ import ol.style.TextOptions; geometryLayer = new ol.layer.Vector(vectorLayerOptions); map.addLayer(geometryLayer); } - + /** * Gets the map. * @@ -297,7 +293,6 @@ import ol.style.TextOptions; return map.getView().getProjection().getCode(); } - /** * Gets the current zoom level. * @@ -306,9 +301,7 @@ import ol.style.TextOptions; public double getCurrentZoomLevel() { return map.getView().getZoom(); } - - - + /** * Gets the bbox. * @@ -317,7 +310,7 @@ import ol.style.TextOptions; public ol.Extent getBBOX() { return getExtent(); } - + /** * Gets the extent. * @@ -326,6 +319,5 @@ import ol.style.TextOptions; public ol.Extent getExtent() { return this.map.getView().calculateExtent(map.getSize()); } - -} +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java index 2c254e6..954d0a0 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java @@ -2,7 +2,7 @@ package org.gcube.portlets.user.geoportaldataviewer.client.gis; import java.util.HashMap; -import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants; +import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION; import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEvent; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem; @@ -51,7 +51,7 @@ import ol.source.Osm; import ol.source.Vector; import ol.source.XyzOptions; -// TODO: Auto-generated Javadoc + /** * The Class OpenLayerOSM. * @@ -147,7 +147,7 @@ public abstract class OpenLayerOSM { Tile osmLayer = new Tile(osmLayerOptions); // create a projection - projectionOptions.setCode(GeoportalDataViewerConstants.EPSG_3857); + projectionOptions.setCode(MAP_PROJECTION.EPSG_3857.getName()); projectionOptions.setUnits("m"); Projection projection = new Projection(projectionOptions); @@ -392,6 +392,8 @@ public abstract class OpenLayerOSM { if (wmsDetailsLayerMap == null) return; + GWT.log("Removing layers: " + wmsDetailsLayerMap.keySet() + " from map"); + for (String key : wmsDetailsLayerMap.keySet()) { Image layer = wmsDetailsLayerMap.get(key); map.removeLayer(layer); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/Images.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/Images.java index d8434c3..0843c61 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/Images.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/Images.java @@ -16,4 +16,7 @@ public interface Images extends ClientBundle { @Source("icon_share.png") ImageResource shareIcon(); + + @Source("italy.png") + ImageResource italyIcon(); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/italy.png b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/italy.png new file mode 100644 index 0000000000000000000000000000000000000000..e68a7a0dcf46d504cd279135eeb2b9feab20d7fa GIT binary patch literal 1398 zcmV-+1&R8JP)00004b3#c}2nYxW zdt7#sq|091cQ__`Eiu+vzujp_}YX?)z&Xxv8mUo&yqs*LK5gezN|BhD*+ zyh(V4co<8t3vajZZ|TH2ln9?H7H?5lfgM;typZsAavlN(5Qz(j7h!9M0F4L8zl&2_ z?C+sL7HPuAa2avJ^l)P*&LJaP(&Bs=FOzM?UukC8hQBCCCg|)=0g8aCU4gZ@0?*KM zSF+a^5jSEzVTgDLIUy1+#h)mBrIU2r64CXWiRaL`i}HWR536?(A8s-1k#=t{aW3(0 zdUkXOFqJCH$X}aaJSZilFH6a26FoneDL^*8VdZ}~Cfeg(T#l!u%y>7or4wg%2v9kb zzBxtXIpdB&HX`ld^1@KUHM0m%TTZDbU92ECi`)55TZ>_0T0L{3~y_(E~b|I#sc&2a(NKaX3;ADV1p(!eeF z4i2ZXET4mYgk4gx0wMKnp4V=LHi_sL3%Kqu^=}hbG4QRiS1_3#S%`%+ZYSP0W{*1v zIq_`5F#1v2&oz zM*CN=ns9RgS0eA4+BwNN92lZ;194q)8kb1P>%zkM%Q!;VPOYEHDQy6nKb+8h`uG5& z+Au=--}G)HJcdse35s-i-7BT1rR<`q$e499@JX*h0LM?zcJv*f1g$xTHU{=d|{=0XXyrVi%1&Qnm{d zE72LKlBe(RFy6s8iGwG;-lW>t@*pv!_JgOVcK;dF4pD!q-OR}@qZz1@Q#ymn`;>=^ zf)!hvRIkKJGzmXyH+z~jVLLrl;+>V~BQD1vo+N&Ruoi2Hzabl>`4+wR&N2Y>e~#v} zSkS&d`!wDArdpvxfKk=HhWqh}F { } - + @UiField HTMLPanel mainContainerPanel; - + @UiField HTMLPanel mainToolBar; @@ -50,37 +52,39 @@ public class GeonaDataViewMainPanel extends Composite { @UiField NavLink dataBoxSelection; - + @UiField Button removeQuery; - + @UiField DetailsPanel detailsPanel; + @UiField + Button extentToItaly; + private MapPanel mapPanel; private OpenLayerOSM map; private HandlerManager applicationBus; - /** * Instantiates a new geona data view main panel. * * @param applicationBus the application bus - * @param mapHeight the map height + * @param mapHeight the map height */ public GeonaDataViewMainPanel(HandlerManager applicationBus, int mapHeight) { initWidget(uiBinder.createAndBindUi(this)); this.applicationBus = applicationBus; - mapPanel = new MapPanel(mapHeight+"px"); - detailsPanel.setHeight(mapHeight+"px"); + mapPanel = new MapPanel(mapHeight + "px"); + detailsPanel.setHeight(mapHeight + "px"); detailsPanel.setApplicationBus(applicationBus); mainContainerPanel.add(mapPanel); bindHandlers(); dataPointSelection.setIcon(IconType.SCREENSHOT); dataBoxSelection.setIcon(IconType.BOOKMARK); - + removeQuery.setIcon(IconType.REMOVE); } @@ -143,9 +147,9 @@ public class GeonaDataViewMainPanel extends Composite { removeQuery.setVisible(true); } }); - + removeQuery.addClickHandler(new ClickHandler() { - + @Override public void onClick(ClickEvent event) { map.removeQueryInteractions(); @@ -153,27 +157,36 @@ public class GeonaDataViewMainPanel extends Composite { } }); + extentToItaly.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + applicationBus.fireEvent(new MapExtentToEvent(ExtentMapUtil.getLocation(ExtentMapUtil.PLACE.ITALY))); + + } + }); + } /** * Show as details. * * @param concessioneDV the concessione DV - * @param geonaItemRef the geona item ref + * @param geonaItemRef the geona item ref */ public void showAsDetails(ConcessioneDV concessioneDV, GeoNaItemRef geonaItemRef) { detailsPanel.showDetailsFor(concessioneDV, geonaItemRef); - + } - + /** * Hide panel details. */ public void hidePanelDetails() { detailsPanel.hidePanelDetails(); - + } - + /** * Gets the displyed record. * diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml index bf1b0d5..f81d0da 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml @@ -7,6 +7,7 @@ .margin-right-10 { margin-right: 10px; } + .font-weight-bold { font-weight: bold; } @@ -19,9 +20,17 @@ Map Interactions - Use Shift+Drag to draw an extent for zoom in the Map - Click on the Points shown on the Map to view their features - + + + Use + Shift+Drag + to draw an extent for zoom in the Map + + + + Click on the Points shown on the Map to view their features + +
@@ -33,6 +42,8 @@ Selection + diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/ExtentMapUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/ExtentMapUtil.java new file mode 100644 index 0000000..384ddc6 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/ExtentMapUtil.java @@ -0,0 +1,170 @@ +package org.gcube.portlets.user.geoportaldataviewer.client.ui.map; + +import java.util.HashMap; +import java.util.Map; + +import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants; +import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION; +import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils; + +import ol.Coordinate; +import ol.OLFactory; + +/** + * The Class ExtentMapUtil. + * + * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) + * + * Sep 1, 2021 + */ +public class ExtentMapUtil { + + /** + * The Enum PLACE. + * + * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) + * + * Sep 1, 2021 + */ + public static enum PLACE { + ITALY + } + + final static Map mapExtent = new HashMap(); + + static { + + // EPSG_4326 ITALY LOCATION + Location location = new Location(PLACE.ITALY.name(), GeoportalDataViewerConstants.ITALY_CENTER_LONG, + GeoportalDataViewerConstants.ITALY_CENTER_LAT, MAP_PROJECTION.EPSG_4326, + GeoportalDataViewerConstants.MAP_ITALY_FIT_ZOOM_ON); + + mapExtent.put(PLACE.ITALY, location); + + } + + public static Location getLocation(PLACE place) { + return mapExtent.get(place); + } + + /** + * The Class Location. + * + * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) + * + * Sep 1, 2021 + */ + public static class Location { + public String name; + public double coordinateX; + public double coordinateY; + public MAP_PROJECTION projection; + public int zoomLevel; + + /** + * Instantiates a new location. + * + * @param name the name + * @param coordinateX the coordinate X + * @param coordinateY the coordinate Y + * @param projection the projection + * @param zoomLevel the zoom level + */ + public Location(String name, double coordinateX, double coordinateY, MAP_PROJECTION projection, int zoomLevel) { + super(); + this.name = name; + this.coordinateX = coordinateX; + this.coordinateY = coordinateY; + this.projection = projection; + this.zoomLevel = zoomLevel; + } + + /** + * Gets the name. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Gets the coordinate X. + * + * @return the coordinate X + */ + public double getCoordinateX() { + return coordinateX; + } + + /** + * Gets the coordinate Y. + * + * @return the coordinate Y + */ + public double getCoordinateY() { + return coordinateY; + } + + /** + * Gets the projection. + * + * @return the projection + */ + public MAP_PROJECTION getProjection() { + return projection; + } + + /** + * Gets the zoom level. + * + * @return the zoom level + */ + public int getZoomLevel() { + return zoomLevel; + } + + /** + * Gets the coordinate. + * + * @param targetProjection the target projection + * @return the coordinate + */ + public Coordinate getCoordinate(MAP_PROJECTION targetProjection) { + + Coordinate coordinate = OLFactory.createCoordinate(coordinateX, coordinateY); + if (projection.equals(targetProjection)) { + return coordinate; + } else { + Coordinate transformedCenterCoordinate = MapUtils.transformCoordiante(coordinate, projection.getName(), + targetProjection.getName()); + return transformedCenterCoordinate; + } + + } + + /** + * To string. + * + * @return the string + */ + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("Location [name="); + builder.append(name); + builder.append(", coordinateX="); + builder.append(coordinateX); + builder.append(", coordinateY="); + builder.append(coordinateY); + builder.append(", projection="); + builder.append(projection); + builder.append(", zoomLevel="); + builder.append(zoomLevel); + builder.append("]"); + return builder.toString(); + } + + } + +} 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 0928059..fee7970 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 @@ -2,9 +2,12 @@ package org.gcube.portlets.user.geoportaldataviewer.client.ui.map; import org.gcube.application.geoportalcommon.shared.gis.BoundsMap; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants; +import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION; import org.gcube.portlets.user.geoportaldataviewer.client.gis.ExtentWrapped; import org.gcube.portlets.user.geoportaldataviewer.client.gis.LightOpenLayerOSM; import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils; +import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.Location; +import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.PLACE; import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.Scheduler; @@ -67,12 +70,18 @@ import ol.OLFactory; @Override public void execute() { olsm = new LightOpenLayerOSM(theMapId); - //EPSG_4326_TO_ITALY - Coordinate centerCoordinate = OLFactory.createCoordinate(GeoportalDataViewerConstants.ITALY_CENTER_LONG, GeoportalDataViewerConstants.ITALY_CENTER_LAT); - Coordinate transformedCenterCoordinate = MapUtils.transformCoordiante(centerCoordinate, GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857); - + + //EPSG_3857 LOCATION TO ITALY + Location italyLocation = ExtentMapUtil.getLocation(PLACE.ITALY); + Coordinate transformedCenterCoordinate = italyLocation.getCoordinate(MAP_PROJECTION.EPSG_3857); olsm.setCenter(transformedCenterCoordinate); olsm.setZoom(GeoportalDataViewerConstants.LIGHT_MAP_ITALY_FIT_ZOOM_ON); + +// Coordinate centerCoordinate = OLFactory.createCoordinate(GeoportalDataViewerConstants.ITALY_CENTER_LONG, GeoportalDataViewerConstants.ITALY_CENTER_LAT); +// Coordinate transformedCenterCoordinate = MapUtils.transformCoordiante(centerCoordinate, GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857); +// olsm.setCenter(transformedCenterCoordinate); +// olsm.setZoom(GeoportalDataViewerConstants.LIGHT_MAP_ITALY_FIT_ZOOM_ON); + //setMapSize(); } @@ -136,14 +145,13 @@ import ol.OLFactory; if (bbox != null) { - Coordinate lower = OLFactory.createCoordinate(bbox.getLowerLeftX(), bbox.getLowerLeftY()); - Coordinate lowerCoord = MapUtils.transformCoordiante(lower, GeoportalDataViewerConstants.EPSG_4326, - GeoportalDataViewerConstants.EPSG_3857); + Coordinate lowerCoord = MapUtils.transformCoordiante(lower, MAP_PROJECTION.EPSG_4326.getName(), + MAP_PROJECTION.EPSG_3857.getName()); Coordinate upper = OLFactory.createCoordinate(bbox.getUpperRightX(), bbox.getUpperRightY()); - Coordinate upperCoord = MapUtils.transformCoordiante(upper, GeoportalDataViewerConstants.EPSG_4326, - GeoportalDataViewerConstants.EPSG_3857); + Coordinate upperCoord = MapUtils.transformCoordiante(upper, MAP_PROJECTION.EPSG_4326.getName(), + MAP_PROJECTION.EPSG_3857.getName()); ew = new ExtentWrapped(lowerCoord.getX(), lowerCoord.getY(), upperCoord.getX(), upperCoord.getY()); theBBOX = new BoundsMap(lowerCoord.getX(), lowerCoord.getY(), upperCoord.getX(), upperCoord.getY(), null); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java index 830ff95..8f1ac21 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java @@ -9,11 +9,15 @@ import org.gcube.application.geoportalcommon.shared.products.model.AbstractRelaz import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants; +import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync; import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils; import org.gcube.portlets.user.geoportaldataviewer.client.ui.ModalWindow; import org.gcube.portlets.user.geoportaldataviewer.client.ui.dialogs.DialogShareableLink; import org.gcube.portlets.user.geoportaldataviewer.client.ui.gallery.ImagesGallery; +import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil; +import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.Location; +import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.PLACE; import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.MapView; import org.gcube.portlets.user.geoportaldataviewer.client.ui.util.CustomFlexTable; @@ -35,7 +39,6 @@ import com.google.gwt.user.client.ui.HTMLPanel; import com.google.gwt.user.client.ui.Widget; import ol.Coordinate; -import ol.OLFactory; public class ConcessioneView extends Composite { @@ -300,13 +303,15 @@ public class ConcessioneView extends Composite { } private void addCentroidMap() { - Coordinate centerCoordinate = OLFactory.createCoordinate(GeoportalDataViewerConstants.ITALY_CENTER_LONG, GeoportalDataViewerConstants.ITALY_CENTER_LAT); - Coordinate transformedCenterCoordinate = MapUtils.transformCoordiante(centerCoordinate, GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857); +// Coordinate centerCoordinate = OLFactory.createCoordinate(GeoportalDataViewerConstants.ITALY_CENTER_LONG, GeoportalDataViewerConstants.ITALY_CENTER_LAT); +// Coordinate transformedCenterCoordinate = MapUtils.transformCoordiante(centerCoordinate, GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857); + Location italyLocation = ExtentMapUtil.getLocation(PLACE.ITALY); + Coordinate transformedCenterCoordinate = italyLocation.getCoordinate(MAP_PROJECTION.EPSG_3857); MapView mapView = new MapView(transformedCenterCoordinate, GeoportalDataViewerConstants.LIGHT_MAP_ITALY_FIT_ZOOM_ON, "70%", "300px"); if(concessioneDV!=null && concessioneDV.getCentroidLat()!=null && concessioneDV.getCentroidLong()!=null) { Coordinate coord = new Coordinate(concessioneDV.getCentroidLong(), concessioneDV.getCentroidLat()); - Coordinate transfCoord = MapUtils.transformCoordiante(coord, GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857); + Coordinate transfCoord = MapUtils.transformCoordiante(coord, MAP_PROJECTION.EPSG_4326.getName(), MAP_PROJECTION.EPSG_3857.getName()); //Coordinate invertedCoordinate = MapUtils.reverseCoordinate(coord); boolean authenticatedUser = myLogin!=null?true:false; mapView.addMarker(transfCoord, authenticatedUser); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/LayerConcessioneView.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/LayerConcessioneView.java index b36aeaa..0b76085 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/LayerConcessioneView.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/LayerConcessioneView.java @@ -2,7 +2,10 @@ package org.gcube.portlets.user.geoportaldataviewer.client.ui.products.concessio import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants; -import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils; +import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION; +import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil; +import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.Location; +import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.PLACE; import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.MapView; import org.gcube.portlets.user.geoportaldataviewer.client.ui.util.CustomFlexTable; @@ -14,7 +17,6 @@ import com.google.gwt.user.client.ui.HTMLPanel; import com.google.gwt.user.client.ui.Widget; import ol.Coordinate; -import ol.OLFactory; public class LayerConcessioneView extends Composite { @@ -44,8 +46,12 @@ public class LayerConcessioneView extends Composite { GWT.log("WMS LINK: "+layerDV.getWmsLink()); if(layerDV.getLayerName()!=null && layerDV.getWmsLink()!=null) { - Coordinate centerCoordinate = OLFactory.createCoordinate(GeoportalDataViewerConstants.ITALY_CENTER_LONG, GeoportalDataViewerConstants.ITALY_CENTER_LAT); - Coordinate transformedCenterCoordinate = MapUtils.transformCoordiante(centerCoordinate, GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857); + + + Location italyLocation = ExtentMapUtil.getLocation(PLACE.ITALY); + Coordinate transformedCenterCoordinate = italyLocation.getCoordinate(MAP_PROJECTION.EPSG_3857); +// Coordinate centerCoordinate = OLFactory.createCoordinate(GeoportalDataViewerConstants.ITALY_CENTER_LONG, GeoportalDataViewerConstants.ITALY_CENTER_LAT); +// Coordinate transformedCenterCoordinate = MapUtils.transformCoordiante(centerCoordinate, MAP_PROJECTION.EPSG_4326.getName(), MAP_PROJECTION.EPSG_3857.getName()); MapView mapView = new MapView(transformedCenterCoordinate, GeoportalDataViewerConstants.LIGHT_MAP_ITALY_FIT_ZOOM_ON, "70%", "300px"); mapViewPanel.add(mapView); -- 2.17.1 From 5a84d3a990d941ed3d75ebd1815e3b402451e34b Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 1 Sep 2021 16:26:07 +0200 Subject: [PATCH 11/38] added "Extent To" facility --- .settings/org.eclipse.wst.common.component | 3 -- .../client/GeoportalDataViewer.java | 12 ++++++ .../client/resources/Images.java | 9 +++-- .../client/resources/italy.png | Bin 1398 -> 1420 bytes .../client/resources/world.png | Bin 0 -> 3258 bytes .../client/ui/GeonaDataViewMainPanel.java | 37 +++++++++++++++++- .../client/ui/GeonaDataViewMainPanel.ui.xml | 13 +++++- .../client/ui/map/ExtentMapUtil.java | 12 ++++-- 8 files changed, 73 insertions(+), 13 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/world.png diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 70f376c..6ddcc0f 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -69,9 +69,6 @@ - - uses - 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 e2e42de..c7c7ed8 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 @@ -13,6 +13,8 @@ import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMap import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEventHandler; import org.gcube.portlets.user.geoportaldataviewer.client.events.ClosedViewDetailsEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.ClosedViewDetailsEventHandler; +import org.gcube.portlets.user.geoportaldataviewer.client.events.MapExtentToEvent; +import org.gcube.portlets.user.geoportaldataviewer.client.events.MapExtentToEventHandler; import org.gcube.portlets.user.geoportaldataviewer.client.events.QueryDataEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowDetailsEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowDetailsEventHandler; @@ -324,6 +326,16 @@ public class GeoportalDataViewer implements EntryPoint { } }); + + applicationBus.addHandler(MapExtentToEvent.TYPE, new MapExtentToEventHandler() { + + @Override + public void onExtentEvent(MapExtentToEvent mapExtentToEvent) { + // TODO Auto-generated method stub + + } + }); + } private void performWFSQueryOnCentroid(RecordDV record) { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/Images.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/Images.java index 0843c61..c097d2a 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/Images.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/Images.java @@ -10,13 +10,16 @@ public interface Images extends ClientBundle { @Source("loading.gif") ImageResource loading(); - + @Source("map-marker-icon.png") ImageResource mapMarkerIcon(); - + @Source("icon_share.png") ImageResource shareIcon(); - + @Source("italy.png") ImageResource italyIcon(); + + @Source("world.png") + ImageResource worldIcon(); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/italy.png b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/italy.png index e68a7a0dcf46d504cd279135eeb2b9feab20d7fa..9992bc98d69ff2033471c8334eb392b1af2f1f4b 100644 GIT binary patch delta 1342 zcmV-E1;P6E3XBVoJPO7D0071TuymWnkwzzf1qn$+K~z|U&DdXz-9;4#@X!2q+r4Wk zNb4U~YOAqDp@iCCYFkQE1F^o;l1L>cBnARTj7m&&_bz|JeQ?>`riqD9ZV6EmBWxNY zF|`3T2<_IGY9Z2UDoJSpEiKqTD6RX4z2n17?cLqm?f$tBexGK}oH^$^=bkxpem9tZ zGAbo1LzExFVl1P&iLL*hx{ZklQ*?eAgF6YW#8p{%lF&!>DNY|^`$&Tbw69|8zBKOm zGOfR6s1KJDzmSzi@EYc#iVxx$4&T9!(diIq9y|R`E5#1lw@~~OKVq;M$MI&3;wT{y zk79ii#lzEeo(Z(ir&xov`6P=ex`=Oo5U$L6^D}{A;>#2z;`KO#L9`G)FRnF>3+JV<+K(B<+}+RFF1!#%0!Oi72;X65%&{L)$H$|jdM~GUY(4O!BXsh#ys3e zaVj}40`UN1S__}Sj#(0jPY}v@Uyb}=HLe6 z?Uc7PfI!?VJw6{u^X2)p$C@au#Q7Vs1{+eNBA0JZ(sAch2{hFgue$=92>lG~IKU_OW0Xw`9Vv6BeKa#|fX}rt4WZhnrWju8o0L>v_6Z4(!JW)j!u?-Z4r~7q+K) zScP+VE+1++;j@Ha;%9_^@o&wg2=u&2xR2H+FSaqEbRVGuXQgIl4&i7%z?rNR(psfd z&qAF-^xb)EJ4@%caUCt+pi<`@s73pH%%^C_{WS}_rHEW3y)%8h*T=TECLvJ%Ch-Qs zJyP$tg6_XgPC!6Rg{b%;HcQdnkClX%h>N5sogm&t@3YkZ36>Lo?#)J<^NqL^a+03O z#=|DOB=s4Qcw=%N4q}M#3?09qGPe$a*gbCk!W0N(Y#*Wb9lCcBo|SsWJ$bPp_RzF} z_#j~^gFkJaXe2aC&1qf>mrb2OExI3|^Ht)tQs|FR>d*P~DCNV%_Bs(Lz2!m%%ijkx zL8SXJ;%~5=IA~0N*VWTc^KEqq3@`P+3JAl0pCN&a)4#<*!tD&cn4b3Y=z61G5-!9L z`tcCk-ku$S?IY54gk`DexqvzZ=I%|I-`tt2-S|#)8rYIcef4RaCVrjb@XYO96qVY8 zgfy>Qp4Z+_`CZDttG9EC9noai(!|h}ROV(uq!Ll3VycZF+keOaLDEG}Qs=3#uMIPS4TFEXzD#lYWK+n3MNgpcCGtli1pW0UQiMFct*(tUEG{97%|+l4kxt(fV5M-9OF zcK-hy4a$KjT6A8=O|9&Gr}4HYpi*2Yw==_k0Uxn!f%4=JUjP6A07*qoM6N<$f>1`D Ay8r+H delta 1320 zcmV+@1=sqF3-$_-JPODF0077V6#dsbkwzzf1oKHmK~z|U#n)eqoK+de@y~hRDQzi5 zwAN5^v&C^u#TP#WK?%%{1P{;O#oz)xtF@Fw198Q4hhVIT3b z!ZtWl=LNtc3mLwc>=G=-GMbz4IzC!|j9XX$4C5ut!)Ng>KEPajW~R=ir>L$YJc=X4 zorFvAEWS8?Xmg0{Rh)&TWA^wS;XdNu@G8B3o*@8Ke@6Ja6lAc|Sg?)i4V-Cw+|+2? zM)_YeaoVbk>WzdeTbv`#D}KC5c!hWvORx)XxA1T2#5t4*pDGq_QCNW;SU|jgknnbL z9s&jsi3^AqVQYr~jR(lTi&I7or4wg%2v9kbzBxtXIpdB&HX`ld^1@KUHM0m%TTZDbU9-TtIX5L|ja`oP2&U9`PZn*G?CpG>LsXx{GgYERxV@)l>N~*?d9~ z^>H|T!dwgyZl!t=o*I6~M?t)I#%Z2+1-oX~#y_yD8YFhcp?^ll?OhEEm=igbD1E2Z!6V+HwxZH{4H z!ck*K^t9;%w5t1i^#7gaxrD`py}Y=kh^Kp~4dV7TJJ8r~EP|08I5B__x$1uM-(fZJ z16H+ET|HaK*S7(Gn6tu%84$uhPYhsG`yZFyeJ}a*>1rR<`q$e499@JX*h0LM?zcJv z*f1g$xTHU{=d|{=0XXyrVi%1&Qnm{dE72LKlBe(RFy6s8iGwG;-lW>t@*pv!_JgOV zcK;dF4pD!q-OR}@qZz1@Q#ymn`;>=^f)!hvRIkKJGzmX{YBzhDHDNnFRpOnM=p!!2 zAf6KCiN7Hmr1=)T_s%i^^nZ@#vslo+Kl?P@`=(lA>xrX?8dY_v;ALCSC)ZV^rF1079?QW^4Plisa^OLH|s`2^$|Ei7I eSh_ti{SQME7kH|s+8b#A0000fq!&tVg*1q%+ zj(vsr87fCJcPaPhi0OGpnaU!{>*%~?M^-nE$8ZuO~l)YGs$jB zhOj%~5aOTU`#1?Zk3W4jm&NxMbGFj+w}kWQnZuF|EZmcgn_036`RMWIx3J4{9ER0& z?KxC9ZL@J9VJE^D$WNsC8}uJf^(q{JcL=M9_tEvQ+c3-(mr?x^nu{*~Nz+BOcyQTn zlviR3*~f`{5#FSF4n9k^h4=$1-=+N2_(t&}T?f~GF5Hv+)nw4Fv&SB?;B$0;EiL+t zGP7R7-pOd8hy3Am^(n$Psjecs5{)$(u}T=ZQ!03nt`i3u$|ENJG?ilr%|irTK+lJ{ z{ARM2gLR`|MBS%{XSbu&{x+(~vQ% zliP(elR~9qsr(4{6aI=AD9>WitEqeY3gS^?DAPq}`{?$u(9z1)2k4wl`zch{ll>R= zt#AB9h!GbQ-UzaExwVg`gRqZL7S3CS2&fWw!=K}2JVf>4G$gD-Bn#yC4jDgIfZs?{ zcm0ZQI_PYk zvTKOX6Awr-A!K7{^g12u##Z+7gK58?wlCJ&n%3hy7JQxj2(%J5PrUGLVl&z8#hR`e z$%%$|OsNey@lE^^z2wtJ2%9p-9xb6tzMQ@v81%Si=om6kZuaoh^EHn@s$CgnS`tdZ?9}}0+)iJU|VVI6qsz>22%EzSWymnW- zF`|D=F=rT_NqoXe${!%i#BXW3I6V#nTk{e6kEHty^8cXyiP8E_ou5uQ>r<@CenOtG7)mGNPnoyV$X;cx*pL4GXuh6~O|?fi^|0V|>@`HGKt8P& zhT>Yf4^Q{=Rx&B zd#V52Z_vMjMbFh_JhXzPzaBoKO~beG(8Px6`UT;3!bgiT#Tu#=yiMpY-f%e1dQX`Qe3^R8dMvV{AxcDPmJDZJCfV zYowRfL+qyO3EHO+A0JP%2@K;`6Fe^$c~qVjv*^hQZ83cKSyWCYdydWzG5;?Je@A5n zrB=eX$%{CWttLMmFXBk_kZ+;9Q{lx!k)d%!cJn%Y3ux%1{Y~QOG+i;CW_56c`7e+i zG(o4k={k90StGIVaPpg_eLsu%Fup_iaT-3zmNT(0;b@dnybJx(cKQQmrfX;=Hjg_E zh!x5Q(z6pyUnREFy==VRb#R2^AHgXFm#M0GS-<46OX)gkVmV{sm@gCNVn0kzyd}&g z-32PHMq=SSvg6Z{J1{=9Vm4u3;UyQQDql7;oiG~7?!sp21+@^@7uOky ziN{sMEoASEG3l~2*LVqR4RtOky8%lI<@>mCE%WxHcb|0Ro0D0MjrGaR+rCB1ohiCcyPKWQqpc&AJ?lYV0|riuW+{HWg=r~k4h?B*3~-d}eG&o8 zi!I&4Z@-t~+LVLUjPnkgKS=&fRMMv#_fY=JRL`yMUY~y3wFMThqH6}_QxQ@iT<~q$ zU#9!ZDRm$EiDO%6JdC)R*h3!DqO+Dn;<6%4P*h2gX&HL2qCmoxJ4<_djCr+h0Ck0+oWwHHZ^=P;Qv0>32saV}`JX-kob7@~g+XmX6q3!SM5OP0Z z1$qgaq@bRqV>eWW)BKPpCLE6=zCdUkP0C8=ra)aS+Lvs=|Ily&;h8iJ`fnj#TF<(7 zz%TQwN`4x#jD`ogenOhT=rZ5cjJ*iyXdX5!Wq zBi0_A>N<7HdYCvXebpQ&zz?wM_y^)uTr-AY#+3C@{Dj`qX#PAtomg*th=#57tW1Z< z*m#$Q=_s>xb=u2%B~CE}G2&I+K=+b~FP8vGl|DBVw?{e;@@hEa8lcY#uW!D7qO zr-(-4!tIySbSb^RDU!yGZ2hOy-nkshcTBfx9l2b7HXca#*R7dEkEsr2qk(wKw(1?@ zqvQF4{x2h*%njQt57epKE4BOhCRUB^lMnj?(Qg-=_QA9hcQvS3XleVg()a z-^%sRN;KnHe4yy?7}x%6=!i))jE(6Mo}}~0Nt8PYxb78vVMs$x_Sy7DBWN8}+n&U& zl)qG5Z=O7v|DRa=B&9RypFNcE4qy@u6N-N|WMk~#_bMt!jGz{Sn8d9Vf0{T#y`1H} sfbPZPJ()z0dF6|Eja}+U7T^2$KLy7o2$V^M-T(jq07*qoM6N<$g2Lrq$p8QV literal 0 HcmV?d00001 diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java index f18bad3..4721c13 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java @@ -3,14 +3,18 @@ package org.gcube.portlets.user.geoportaldataviewer.client.ui; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.model.RecordDV; +import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION; import org.gcube.portlets.user.geoportaldataviewer.client.events.MapExtentToEvent; import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerOSM; +import org.gcube.portlets.user.geoportaldataviewer.client.resources.Images; import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil; +import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.Location; import com.github.gwtbootstrap.client.ui.Button; import com.github.gwtbootstrap.client.ui.NavLink; import com.github.gwtbootstrap.client.ui.constants.IconType; import com.google.gwt.core.client.GWT; +import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.shared.HandlerManager; @@ -18,6 +22,7 @@ import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.HTMLPanel; +import com.google.gwt.user.client.ui.Image; import com.google.gwt.user.client.ui.Widget; /** @@ -61,6 +66,9 @@ public class GeonaDataViewMainPanel extends Composite { @UiField Button extentToItaly; + + @UiField + Button extentToEarth; private MapPanel mapPanel; @@ -84,8 +92,18 @@ public class GeonaDataViewMainPanel extends Composite { bindHandlers(); dataPointSelection.setIcon(IconType.SCREENSHOT); dataBoxSelection.setIcon(IconType.BOOKMARK); - removeQuery.setIcon(IconType.REMOVE); + + Image italyImg = new Image(Images.ICONS.italyIcon()); + italyImg.getElement().getStyle().setPaddingLeft(20, Unit.PX); + extentToItaly.getElement().appendChild(italyImg.getElement()); + extentToItaly.setWidth("140px"); + + Image worldImg = new Image(Images.ICONS.worldIcon()); + worldImg.getElement().getStyle().setPaddingLeft(20, Unit.PX); + extentToEarth.getElement().appendChild(worldImg.getElement()); + extentToEarth.setWidth("140px"); + } /** @@ -161,7 +179,22 @@ public class GeonaDataViewMainPanel extends Composite { @Override public void onClick(ClickEvent event) { - applicationBus.fireEvent(new MapExtentToEvent(ExtentMapUtil.getLocation(ExtentMapUtil.PLACE.ITALY))); + Location italyLocation = ExtentMapUtil.getLocation(ExtentMapUtil.PLACE.ITALY); + applicationBus.fireEvent(new MapExtentToEvent(italyLocation)); + map.setCenter(italyLocation.getCoordinate(MAP_PROJECTION.EPSG_3857)); + map.setZoom(italyLocation.getZoomLevel()); + + } + }); + + extentToEarth.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + Location earthLocation = ExtentMapUtil.getLocation(ExtentMapUtil.PLACE.EARTH); + applicationBus.fireEvent(new MapExtentToEvent(earthLocation)); + map.setCenter(earthLocation.getCoordinate(MAP_PROJECTION.EPSG_3857)); + map.setZoom(earthLocation.getZoomLevel()); } }); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml index f81d0da..ba74905 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml @@ -32,6 +32,17 @@ + + + + + + + + @@ -42,8 +53,6 @@ Selection - diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/ExtentMapUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/ExtentMapUtil.java index 384ddc6..cfd4f11 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/ExtentMapUtil.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/ExtentMapUtil.java @@ -27,7 +27,7 @@ public class ExtentMapUtil { * Sep 1, 2021 */ public static enum PLACE { - ITALY + ITALY, EARTH } final static Map mapExtent = new HashMap(); @@ -35,11 +35,17 @@ public class ExtentMapUtil { static { // EPSG_4326 ITALY LOCATION - Location location = new Location(PLACE.ITALY.name(), GeoportalDataViewerConstants.ITALY_CENTER_LONG, + Location ita = new Location(PLACE.ITALY.name(), GeoportalDataViewerConstants.ITALY_CENTER_LONG, GeoportalDataViewerConstants.ITALY_CENTER_LAT, MAP_PROJECTION.EPSG_4326, GeoportalDataViewerConstants.MAP_ITALY_FIT_ZOOM_ON); + + // EPSG_4326 EARTH LOCATION + Location earth = new Location(PLACE.EARTH.name(), 0, + 0, MAP_PROJECTION.EPSG_4326, + 2); - mapExtent.put(PLACE.ITALY, location); + mapExtent.put(PLACE.ITALY, ita); + mapExtent.put(PLACE.EARTH, earth); } -- 2.17.1 From 6230560af79f817db6777293c779334c2b7ca710 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 1 Sep 2021 17:37:05 +0200 Subject: [PATCH 12/38] added download layer --- .../client/ui/GeonaDataViewMainPanel.ui.xml | 2 +- .../client/ui/map/MapView.java | 3 +- .../products/concessioni/ConcessioneView.java | 2 +- .../concessioni/LayerConcessioneView.java | 36 +++++++++++-------- .../client/util/URLUtil.java | 32 +++++++++++++++++ 5 files changed, 58 insertions(+), 17 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml index ba74905..73a6768 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml @@ -32,7 +32,7 @@ - { } - + @UiField HTMLPanel layerConcessionePanel; - + @UiField HTMLPanel mapViewPanel; - + private CustomFlexTable customTable = new CustomFlexTable(); public LayerConcessioneView(LayerConcessioneDV layerDV) { initWidget(uiBinder.createAndBindUi(this)); - GWT.log("Showing: "+layerDV); - + GWT.log("Showing: " + layerDV); + customTable.addNextKeyValue("Abstract", layerDV.getAbstractSection()); customTable.addNextKeyValue("Valutazione qualità", layerDV.getValutazioneQualita()); customTable.addNextKeyValue("Metodo raccolta dati", layerDV.getMetodoRaccoltaDati()); customTable.addNextKeyValue("Scala acquisizione dati", layerDV.getScalaAcquisizione()); customTable.addNextKeyValues("Autori", layerDV.getAuthors(), GeoportalDataViewerConstants.NEW_LINE_BR); layerConcessionePanel.add(customTable); - - GWT.log("WMS LINK: "+layerDV.getWmsLink()); - if(layerDV.getLayerName()!=null && layerDV.getWmsLink()!=null) { - - + + GWT.log("WMS LINK: " + layerDV.getWmsLink()); + if (layerDV.getLayerName() != null && layerDV.getWmsLink() != null) { + + String pngWMSLink = URLUtil.setValueOfParameter("FORMAT", layerDV.getWmsLink(), "image/png", true); + + customTable.addNextKeyWidget("Layer", new HTML("download image")); + Location italyLocation = ExtentMapUtil.getLocation(PLACE.ITALY); - Coordinate transformedCenterCoordinate = italyLocation.getCoordinate(MAP_PROJECTION.EPSG_3857); + Coordinate transformedCenterCoordinate = italyLocation.getCoordinate(MAP_PROJECTION.EPSG_3857); // Coordinate centerCoordinate = OLFactory.createCoordinate(GeoportalDataViewerConstants.ITALY_CENTER_LONG, GeoportalDataViewerConstants.ITALY_CENTER_LAT); // Coordinate transformedCenterCoordinate = MapUtils.transformCoordiante(centerCoordinate, MAP_PROJECTION.EPSG_4326.getName(), MAP_PROJECTION.EPSG_3857.getName()); - MapView mapView = new MapView(transformedCenterCoordinate, GeoportalDataViewerConstants.LIGHT_MAP_ITALY_FIT_ZOOM_ON, "70%", "300px"); - + MapView mapView = new MapView(transformedCenterCoordinate, + GeoportalDataViewerConstants.LIGHT_MAP_ITALY_FIT_ZOOM_ON, "70%", "300px"); + mapViewPanel.add(mapView); - String mapServerHost = layerDV.getWmsLink().contains("?")? layerDV.getWmsLink().substring(0,layerDV.getWmsLink().indexOf("?")):layerDV.getWmsLink(); + String mapServerHost = layerDV.getWmsLink().contains("?") + ? layerDV.getWmsLink().substring(0, layerDV.getWmsLink().indexOf("?")) + : layerDV.getWmsLink(); mapView.addWMSLayer(mapServerHost, layerDV.getLayerName(), layerDV.getBbox()); } } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/util/URLUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/util/URLUtil.java index adb64bd..85539da 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/util/URLUtil.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/util/URLUtil.java @@ -1,5 +1,8 @@ package org.gcube.portlets.user.geoportaldataviewer.client.util; +import org.gcube.spatial.data.geoutility.bean.WmsParameters; + +// TODO: Auto-generated Javadoc /** * The Class URLUtil. * @@ -60,6 +63,35 @@ public class URLUtil { } + + /** + * Sets the value of parameter. + * + * @param wmsParam the wms param + * @param wmsLink the wms link + * @param newValue the new value + * @param addIfNotExists the add if not exists + * @return the string + */ + public static String setValueOfParameter(String wmsParam, String wmsLink, String newValue, boolean addIfNotExists){ + String toLowerWmsLink = wmsLink.toLowerCase(); + String toLowerWmsParam = wmsParam.toLowerCase(); + + int index = toLowerWmsLink.indexOf(toLowerWmsParam+"="); //END WITH CHAR "=" TO BE SURE THAT IT IS A PARAMETER + if(index > -1){ + int indexStartValue = index + toLowerWmsParam.length()+1; //add +1 for char '=' + int indexOfSeparator = toLowerWmsLink.indexOf("&", indexStartValue); //GET THE FIRST "&" STARTING FROM INDEX VALUE +// logger.trace("indexOfSeparator index of "+wmsParam+ " is: "+indexOfSeparator); + int indexEndValue = indexOfSeparator!=-1?indexOfSeparator:toLowerWmsLink.length(); +// logger.trace("end: "+indexEndValue); + return wmsLink.substring(0, indexStartValue) + newValue +wmsLink.substring(indexEndValue, wmsLink.length()); + }else if (addIfNotExists){ + wmsLink+="&"+wmsParam+"="+newValue; + } +// logger.trace("return value: "+value); + return wmsLink; + } + /** * Extract value of parameter from URL. * -- 2.17.1 From 94d1ffbe0598bd86c5b9a7ad0b447e930a73fba3 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 1 Sep 2021 17:39:15 +0200 Subject: [PATCH 13/38] removed unused import --- .../portlets/user/geoportaldataviewer/client/util/URLUtil.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/util/URLUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/util/URLUtil.java index 85539da..0f7bb55 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/util/URLUtil.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/util/URLUtil.java @@ -1,7 +1,5 @@ package org.gcube.portlets.user.geoportaldataviewer.client.util; -import org.gcube.spatial.data.geoutility.bean.WmsParameters; - // TODO: Auto-generated Javadoc /** * The Class URLUtil. -- 2.17.1 From 6900a988f27f13281a433811a969e1e2d58dcce1 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 2 Sep 2021 12:54:39 +0200 Subject: [PATCH 14/38] #21946 managed detail layer with min/max resolution --- .../client/GeoportalDataViewer.java | 187 +++++++++--------- .../client/LayerManager.java | 49 ++--- .../client/OLMapManager.java | 4 + .../client/gis/OpenLayerOSM.java | 32 ++- .../shared/gis/LayerItem.java | 51 ++++- 5 files changed, 205 insertions(+), 118 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 c7c7ed8..575bcdd 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 @@ -44,7 +44,7 @@ import ol.Coordinate; * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * - * Oct 27, 2020 + * Oct 27, 2020 */ public class GeoportalDataViewer implements EntryPoint { @@ -52,37 +52,36 @@ public class GeoportalDataViewer implements EntryPoint { public final static String APP_DIV = "geoportal-data-viewer"; /** The ol map. */ - //private OpenLayerOSM olMap = null; + // private OpenLayerOSM olMap = null; /** The main panel. */ private GeonaDataViewMainPanel mainPanel; /** The param wms request. */ private String paramWmsRequest; - + /** The param UUID. */ - //private String paramUUID; - + // private String paramUUID; + private String paramGeonaItemType; - + /** The param layer title. */ private String paramLayerTitle; - + private HandlerManager applicationBus = new HandlerManager(""); - + /** The layer manager. */ private LayerManager layerManager = new LayerManager(applicationBus); private String paramGeonaItemID; - + private GeoNaDataViewerProfile geonaDataViewerProfile; - + private OLMapManager olMapMng = null; - + int attempt = 0; - - - //https://data.d4science.org/gis-viewer-app/?wmsrequest=https%3A%2F%2Fgeona-proto.d4science.org%2Fgeoserver%2Fconcessioni_conf%2Fwms%3Fservice%3DWMS%26version%3D1.1.0%26request%3DGetMap%26layers%3Dconcessioni_conf%3Acentroids_concessioni%26styles%3D%26bbox%3D8.476%2C39.179%2C17.391%2C45.772%26width%3D768%26height%3D567%26srs%3DEPSG%3A4326%26format%3Dapplication%2Fopenlayers&zoom=6¢ermap=12.45%2C42.98 + + // https://data.d4science.org/gis-viewer-app/?wmsrequest=https%3A%2F%2Fgeona-proto.d4science.org%2Fgeoserver%2Fconcessioni_conf%2Fwms%3Fservice%3DWMS%26version%3D1.1.0%26request%3DGetMap%26layers%3Dconcessioni_conf%3Acentroids_concessioni%26styles%3D%26bbox%3D8.476%2C39.179%2C17.391%2C45.772%26width%3D768%26height%3D567%26srs%3DEPSG%3A4326%26format%3Dapplication%2Fopenlayers&zoom=6¢ermap=12.45%2C42.98 /** * This is the entry point method. @@ -171,7 +170,7 @@ public class GeoportalDataViewer implements EntryPoint { GWT.log("The layerItem is: " + layerItem); layerManager.addLayer(theItemType, null, null, layerItem.getWmsLink(), false, false, - null, false); + null, false, null, null); if (paramGeonaItemID != null) { if (paramGeonaItemType == null) { @@ -193,9 +192,7 @@ public class GeoportalDataViewer implements EntryPoint { bindEvents(); } - - - + /** * Update window size. */ @@ -204,91 +201,93 @@ public class GeoportalDataViewer implements EntryPoint { int rootHeight = getClientHeight(); int height = rootHeight; mainPanel.setPanelsHeight(height); - GWT.log("Set height: "+height); - + GWT.log("Set height: " + height); + } - + public int getClientHeight() { RootPanel principalDiv = RootPanel.get(APP_DIV); int topBorder = principalDiv.getAbsoluteTop(); int rootHeight = Window.getClientHeight() - topBorder; return rootHeight; } - + /** * Bind events. */ private void bindEvents() { applicationBus.addHandler(ShowDetailsEvent.TYPE, new ShowDetailsEventHandler() { - + @Override public void onShowDetails(ShowDetailsEvent showDetailsEvent) { - GWT.log("Fired event: "+showDetailsEvent); - + GWT.log("Fired event: " + showDetailsEvent); + String geonaMongoId = showDetailsEvent.getGeonaMongoID(); - if(geonaMongoId==null) { + if (geonaMongoId == null) { Window.alert("Item Id not found"); return; } - - //TODO - boolean found = false; - GWT.log("Product with id: "+geonaMongoId+" found? "+found); - - if(!found) { - - if(showDetailsEvent.getGeonaItemType().equalsIgnoreCase("Concessione")) { - GeoportalDataViewerServiceAsync.Util.getInstance().getConcessioneForId(geonaMongoId, new AsyncCallback() { - - @Override - public void onFailure(Throwable caught) { - Window.alert(caught.getMessage()); - mainPanel.hidePanelDetails(); - - } - - @Override - public void onSuccess(ConcessioneDV concessioneDV) { - GWT.log("Showing: "+concessioneDV); - mainPanel.showAsDetails(concessioneDV, showDetailsEvent.getGeonaItemRef()); - } - }); + // TODO + boolean found = false; + GWT.log("Product with id: " + geonaMongoId + " found? " + found); + + if (!found) { + + if (showDetailsEvent.getGeonaItemType().equalsIgnoreCase("Concessione")) { + + GeoportalDataViewerServiceAsync.Util.getInstance().getConcessioneForId(geonaMongoId, + new AsyncCallback() { + + @Override + public void onFailure(Throwable caught) { + Window.alert(caught.getMessage()); + mainPanel.hidePanelDetails(); + + } + + @Override + public void onSuccess(ConcessioneDV concessioneDV) { + GWT.log("Showing: " + concessioneDV); + mainPanel.showAsDetails(concessioneDV, showDetailsEvent.getGeonaItemRef()); + } + }); } } } - + }); - + applicationBus.addHandler(AddedLayerToMapEvent.TYPE, new AddedLayerToMapEventHandler() { - + @Override public void onLayerRendered(AddedLayerToMapEvent addedLayerToMapEvent) { - GWT.log("Fired AddedLayerToMapEvent "+addedLayerToMapEvent.getLayerItem()); - //GeoportalDataViewerConstants.print("Fired AddedLayerToMapEvent "+addedLayerToMapEvent.getLayerItem()); - + GWT.log("Fired AddedLayerToMapEvent " + addedLayerToMapEvent.getLayerItem()); + // GeoportalDataViewerConstants.print("Fired AddedLayerToMapEvent + // "+addedLayerToMapEvent.getLayerItem()); + try { - + attempt = 0; - - if(paramGeonaItemID!=null) { - //waiting for record retrieved by service before calling the WFS + + if (paramGeonaItemID != null) { + // waiting for record retrieved by service before calling the WFS final int MAX_RETRY = 7; Timer timer = new com.google.gwt.user.client.Timer() { @Override public void run() { attempt++; - GWT.log("waiting got record tenative: "+attempt); + GWT.log("waiting got record tenative: " + attempt); RecordDV record = mainPanel.getDisplyedRecord(); - if(record!=null) { + if (record != null) { this.cancel(); GWT.log("cancelled timer"); performWFSQueryOnCentroid(record); } - - if(attempt>MAX_RETRY) { + + if (attempt > MAX_RETRY) { GWT.log("MAX_RETRY reached, cancelled timer"); this.cancel(); } @@ -296,65 +295,69 @@ public class GeoportalDataViewer implements EntryPoint { } }; timer.scheduleRepeating(1000); - + } - }catch (Exception e) { + } catch (Exception e) { // TODO: handle exception } - + } }); - + applicationBus.addHandler(ZoomOutOverMinimumEvent.TYPE, new ZoomOutOverMinimumEventHandler() { - + @Override public void onZoomOut(ZoomOutOverMinimumEvent zoomOutEvent) { - - if(mainPanel.getDisplyedRecord()==null && !olMapMng.isQueryPointActive()) { + + if (mainPanel.getDisplyedRecord() == null && !olMapMng.isQueryPointActive()) { olMapMng.hidePopInfo(); olMapMng.removeDetailLayers(); } - + } }); - + applicationBus.addHandler(ClosedViewDetailsEvent.TYPE, new ClosedViewDetailsEventHandler() { - + @Override public void onClosed(ClosedViewDetailsEvent closedViewDetailsEvent) { olMapMng.hidePopInfo(); } }); - - + applicationBus.addHandler(MapExtentToEvent.TYPE, new MapExtentToEventHandler() { - + @Override public void onExtentEvent(MapExtentToEvent mapExtentToEvent) { // TODO Auto-generated method stub - + } }); - + } - + private void performWFSQueryOnCentroid(RecordDV record) { - if(record!=null) { - GWT.log("record instanceof ConcessioneDV: " +(record instanceof ConcessioneDV) +" with mongo item id: "+record.getItemId()); - //GeoportalDataViewerConstants.print("record instanceof ConcessioneDV: " +(record instanceof ConcessioneDV)); - if(record instanceof ConcessioneDV) { + if (record != null) { + GWT.log("record instanceof ConcessioneDV: " + (record instanceof ConcessioneDV) + " with mongo item id: " + + record.getItemId()); + // GeoportalDataViewerConstants.print("record instanceof ConcessioneDV: " + // +(record instanceof ConcessioneDV)); + if (record instanceof ConcessioneDV) { ConcessioneDV concessioneDV = (ConcessioneDV) record; Double x = concessioneDV.getCentroidLong(); Double y = concessioneDV.getCentroidLat(); - GWT.log("X: "+x +", Y:"+y); - if(x!=null && y!=null) { - Coordinate transfCoord = MapUtils.transformCoordiante(new Coordinate(x, y), MAP_PROJECTION.EPSG_4326.getName(), MAP_PROJECTION.EPSG_3857.getName()); - GeoQuery select = olMapMng.toDataPointQuery(transfCoord,false); - GWT.log("GeoQuery: "+select); - //GeoportalDataViewerConstants.print("fireEvent QueryDataEvent"); - layerManager.getLayerManagerBus().fireEvent(new QueryDataEvent(select, transfCoord, record.getItemId(), true, MapEventType.ADDED_LAYER_TO_MAP)); - }else { - GeoportalDataViewerConstants.printJs("I cannot select the point one or both coordiantes are null. X: "+x +", Y:"+y); + GWT.log("X: " + x + ", Y:" + y); + if (x != null && y != null) { + Coordinate transfCoord = MapUtils.transformCoordiante(new Coordinate(x, y), + MAP_PROJECTION.EPSG_4326.getName(), MAP_PROJECTION.EPSG_3857.getName()); + GeoQuery select = olMapMng.toDataPointQuery(transfCoord, false); + GWT.log("GeoQuery: " + select); + // GeoportalDataViewerConstants.print("fireEvent QueryDataEvent"); + layerManager.getLayerManagerBus().fireEvent(new QueryDataEvent(select, transfCoord, + record.getItemId(), true, MapEventType.ADDED_LAYER_TO_MAP)); + } else { + GeoportalDataViewerConstants.printJs( + "I cannot select the point one or both coordiantes are null. X: " + x + ", Y:" + y); } } } 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 3222214..b359f34 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 @@ -221,7 +221,8 @@ public class LayerManager { GWT.log("the product id is: " + theProductId); - // retrieving and showing WMS layers of a concessione if the ZOOM level is > QUERY_MIN_ZOOM_LEVEL + // 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, @@ -239,27 +240,25 @@ public class LayerManager { for (LayerConcessioneDV layer : result) { addLayer("concessione", layer.getLayerName(), layer.getLayerName(), layer.getWmsLink(), - false, false, layer.getLayerUUID(), true); -// LayerItem li = new LayerItem(); -// li.setBaseLayer(false); -// li.setWmsLink(layer.getWmsLink()); -// li.setTitle(layer.getLayerName()); -// olMap.addWMSLayer(li); + false, false, layer.getLayerUUID(), true, + OLMapManager.LAYER_DETAIL_MIN_RESOLUTION, + OLMapManager.LAYER_DETAIL_MAX_RESOLUTION); } } }); } else { - // removing all WMS detail layers if the ZOOM level is < QUERY_MIN_ZOOM_LEVEL + // removing all WMS detail layers if the ZOOM level is < + // QUERY_MIN_ZOOM_LEVEL olMap.removeAllDetailLayers(); } - + // if(queryEvent.getSourceMapEventType() != null && queryEvent.getSourceMapEventType().equals(MapEventType.MAP_ZOOM_END)) { // GWT.log("EVENT IS "+MapEventType.MAP_ZOOM_END +" retuning"); // return; // } - - //Showing properties belonging to concessioni centroid layer + + // Showing properties belonging to concessioni centroid layer Map> entries = feature.getMapProperties(); String nome = ""; @@ -455,10 +454,12 @@ public class LayerManager { * @param displayInLayerSwitcher the display in layer switcher * @param UUID the uuid * @param asDetailLayer the as detail layer + * @param minResolution the min resolution + * @param maxResolution the max resolution */ public void addLayer(final String geonaItemType, final String layerTitle, final String layerName, final String wmsLink, final boolean isBase, final boolean displayInLayerSwitcher, final String UUID, - final boolean asDetailLayer) { + final boolean asDetailLayer, Double minResolution, Double maxResolution) { // final LayoutContainer westPanel = (LayoutContainer) layersPanel.getParent(); // @@ -469,12 +470,12 @@ public class LayerManager { final LayerType featureType = isBase ? LayerType.RASTER_BASELAYER : LayerType.FEATURE_TYPE; // Info.display("Adding Layer", layerName); - - if(wmsLink==null || wmsLink.isEmpty()) { + + if (wmsLink == null || wmsLink.isEmpty()) { GeoportalDataViewerConstants.printJs("Skipping add layer for wmsLink as null or empty"); return; } - + GeoportalDataViewerServiceAsync.Util.getInstance().parseWmsRequest(wmsLink, layerName, new AsyncCallback() { @@ -498,23 +499,23 @@ public class LayerManager { geoInfoWMS.getWmsRequest(), geoInfoWMS.getBaseWmsServiceHost(), true, isBase, displayInLayerSwitcher, (ArrayList) geoInfoWMS.getStyles().getGeoStyles(), geoInfoWMS.getWmsRequest(), false, geoInfoWMS.getMapWMSNoStandard(), - geoInfoWMS.isNcWMS(), UUID, geoInfoWMS.getZAxis()); + geoInfoWMS.isNcWMS(), UUID, geoInfoWMS.getZAxis(), minResolution, maxResolution); LayerObject lo = new LayerObject(); lo.setLayerItem(layerItem); lo.setItemType(geonaItemType); String key = layerItem.getMapServerHost() + "/layer/" + layerItem.getName(); -// //if a detail layer checking if it is already added to map -// if (asDetailLayer && layerObjects.containsKey(key)) { -// GWT.log("Skipping layer already added to Map"); -// } else { + // if a detail layer checking if it is already added to map + if (asDetailLayer && layerObjects.containsKey(key)) { + GWT.log("Skipping layer " + key + " already added to Map"); + } else { layerObjects.put(key, lo); if (!asDetailLayer) olMap.addWMSLayer(layerItem); else olMap.addWMSDetailLayer(layerItem); -// } + } } }); } @@ -537,12 +538,14 @@ public class LayerManager { * @param isNcWms the is nc wms * @param UUID the uuid * @param zAxis the z axis + * @param minResolution the min resolution + * @param maxResolution the max resolution * @return the layer item */ private LayerItem toLayerItem(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) { + boolean isNcWms, String UUID, ZAxis zAxis, Double minResolution, Double maxResolution) { // GWT.log("Add addLayerByWms 1"); LayerItem layerItem = new LayerItem(); @@ -559,6 +562,8 @@ public class LayerManager { layerItem.setNcWms(isNcWms); layerItem.setUUID(UUID); layerItem.setZAxis(zAxis); + layerItem.setMinResolution(minResolution); + layerItem.setMaxResolution(maxResolution); switch (layerType) { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java index a09d472..d479963 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java @@ -37,6 +37,9 @@ public class OLMapManager { private Double zoomEnd = null; private ol.Extent dragEndExtent = null; public static final int QUERY_MIN_ZOOM_LEVEL = 13; + public static final Double LAYER_DETAIL_MIN_RESOLUTION = 0.10; + public static final Double LAYER_DETAIL_MAX_RESOLUTION = 13.0; + /** * Instantiates a new OL map manager. @@ -192,6 +195,7 @@ public class OLMapManager { private void checkSelectQuery(MapEventType mapEventType) { GWT.log("Zoom is:" + olMap.getCurrentZoomLevel()); + GWT.log("Resolution is:" + olMap.getCurrentResolution()); if (dragStartExtent != null && olMap.getCurrentZoomLevel() > QUERY_MIN_ZOOM_LEVEL) { dragEndExtent = olMap.getExtent(); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java index 954d0a0..c400859 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java @@ -333,13 +333,21 @@ public abstract class OpenLayerOSM { LayerOptions layerOptions = OLFactory.createOptions(); layerOptions.setSource(imageWMSSource); + + //Settings MIN and MAX Resolution + if(layerItem.getMinResolution()!=null) { + layerOptions.setMinResolution(layerItem.getMinResolution()); + } + if(layerItem.getMaxResolution()!=null) { + layerOptions.setMaxResolution(layerItem.getMaxResolution()); + } Image wmsLayer = new Image(layerOptions); // visibleLayerItems map.addLayer(wmsLayer); - GWT.log("Fired the event Added Layer"); + GWT.log("Added WMSLayer for layer: "+layerItem.getName()); eventBus.fireEvent(new AddedLayerToMapEvent(layerItem)); } @@ -372,6 +380,13 @@ public abstract class OpenLayerOSM { LayerOptions layerOptions = OLFactory.createOptions(); layerOptions.setSource(imageWMSSource); + //Settings MIN and MAX Resolution + if(layerItem.getMinResolution()!=null) { + layerOptions.setMinResolution(layerItem.getMinResolution()); + } + if(layerItem.getMaxResolution()!=null) { + layerOptions.setMaxResolution(layerItem.getMaxResolution()); + } Image wmsLayer = new Image(layerOptions); @@ -380,7 +395,7 @@ public abstract class OpenLayerOSM { map.addLayer(wmsLayer); wmsDetailsLayerMap.put(key, wmsLayer); - GWT.log("Fired the event Added Layer"); + GWT.log("Added WMSDetailLayer for layer name: "+layerItem.getName()); eventBus.fireEvent(new AddedLayerToMapEvent(layerItem)); } else { GWT.log("The detail layer with key: " + key + " already exists, skipping"); @@ -389,6 +404,9 @@ public abstract class OpenLayerOSM { } public void removeAllDetailLayers() { + + + /* if (wmsDetailsLayerMap == null) return; @@ -400,6 +418,7 @@ public abstract class OpenLayerOSM { } wmsDetailsLayerMap.clear(); + */ } @@ -595,6 +614,15 @@ public abstract class OpenLayerOSM { public double getCurrentZoomLevel() { return map.getView().getZoom(); } + + /** + * Gets the current zoom level. + * + * @return the current zoom level + */ + public double getCurrentResolution() { + return map.getView().getResolution(); + } /** * Gets the bbox. 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 c4feff4..58f17f1 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,7 +9,6 @@ import org.gcube.application.geoportalcommon.shared.gis.BoundsMap; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.Property; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.ZAxis; -// TODO: Auto-generated Javadoc /** * The Class LayerItem. * @@ -115,6 +114,10 @@ public class LayerItem implements Serializable, Cloneable { /** The Constant INT_TYPE. */ public static final String INT_TYPE = "xsd:int"; + public Double minResolution; + + public Double maxResolution; + /** * Instantiates a new layer item. */ @@ -849,6 +852,47 @@ public class LayerItem implements Serializable, Cloneable { this.zAxisSelected = zAxisSelected; } + /** + * Sets the max resolution. + * + * @param maxResolution the new max resolution + */ + public void setMaxResolution(Double maxResolution) { + this.maxResolution = maxResolution; + } + + /** + * Sets the min resolution. + * + * @param minResolution the new min resolution + */ + public void setMinResolution(Double minResolution) { + this.minResolution = minResolution; + } + + /** + * Gets the min resolution. + * + * @return the min resolution + */ + public Double getMinResolution() { + return minResolution; + } + + /** + * Gets the max resolution. + * + * @return the max resolution + */ + public Double getMaxResolution() { + return maxResolution; + } + + /** + * To string. + * + * @return the string + */ @Override public String toString() { StringBuilder builder = new StringBuilder(); @@ -910,9 +954,12 @@ public class LayerItem implements Serializable, Cloneable { builder.append(zAxis); builder.append(", zAxisSelected="); builder.append(zAxisSelected); + builder.append(", minResolution="); + builder.append(minResolution); + builder.append(", maxResolution="); + builder.append(maxResolution); builder.append("]"); return builder.toString(); } - } -- 2.17.1 From 30ab1b9185619f5095ba3e6124fb6d585f1355f9 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 2 Sep 2021 18:15:15 +0200 Subject: [PATCH 15/38] added download layer --- .../client/GeoportalDataViewerConstants.java | 22 +++- .../client/OLMapManager.java | 8 -- .../client/gis/LightOpenLayerOSM.java | 91 ++++++++++++++- .../client/gis/OpenLayerOSM.java | 58 +++++----- .../client/ui/map/MapView.java | 109 +++++++++--------- .../products/concessioni/ConcessioneView.java | 8 +- .../concessioni/LayerConcessioneView.java | 76 +++++++++++- 7 files changed, 268 insertions(+), 104 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java index 6792d3b..a19011f 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java @@ -14,9 +14,6 @@ import com.google.gwt.i18n.client.DateTimeFormat; */ public class GeoportalDataViewerConstants { -// public static final String EPSG_4326 = "EPSG:4326"; -// public static final String EPSG_3857 = "EPSG:3857"; - public static final String MAP_DIV = "map"; public static final String GET_WMS_PARAMETER = "wmsrequest"; @@ -81,5 +78,24 @@ public class GeoportalDataViewerConstants { public static native void printJs(String msg)/*-{ console.log("js console: " + msg); }-*/; + + /** + * Prints the. + * + * @param msg the msg + */ + public static native void printJsObj(Object object)/*-{ + console.log("js obj: "+JSON.stringify(object, null, 4)); + }-*/; + + + /** + * Prints the. + * + * @param msg the msg + */ + public static native String toJsonObj(Object object)/*-{ + return JSON.stringify(object); + }-*/; } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java index d479963..216f6ab 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java @@ -126,14 +126,6 @@ public class OLMapManager { }; - // EPSG_4326_TO_ITALY -// Coordinate centerCoordinate = OLFactory.createCoordinate(GeoportalDataViewerConstants.ITALY_CENTER_LONG, -// GeoportalDataViewerConstants.ITALY_CENTER_LAT); -// Coordinate transformedCenterCoordinate = MapUtils.transformCoordiante(centerCoordinate, -// MAP_PROJECTION.EPSG_4326.getName(), MAP_PROJECTION.EPSG_3857.getName()); -// olMap.setCenter(transformedCenterCoordinate); -// olMap.setZoom(GeoportalDataViewerConstants.MAP_ITALY_FIT_ZOOM_ON); - Location italyLocation = ExtentMapUtil.getLocation(PLACE.ITALY); Coordinate transformedCenterCoordinate = italyLocation.getCoordinate(MAP_PROJECTION.EPSG_3857); olMap.setCenter(transformedCenterCoordinate); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerOSM.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerOSM.java index cb44a29..025120a 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerOSM.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerOSM.java @@ -1,6 +1,11 @@ package org.gcube.portlets.user.geoportaldataviewer.client.gis; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + import org.gcube.application.geoportalcommon.shared.gis.BoundsMap; +import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION; import org.gcube.portlets.user.geoportaldataviewer.client.resources.Images; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery; @@ -8,7 +13,12 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery.TYPE; import com.google.gwt.core.client.GWT; import com.google.gwt.i18n.client.NumberFormat; +import com.google.gwt.json.client.JSONObject; +import com.google.gwt.json.client.JSONParser; +import com.google.gwt.json.client.JSONString; +import com.google.gwt.json.client.JSONValue; +import ol.Collection; import ol.Coordinate; import ol.Feature; import ol.Map; @@ -22,6 +32,7 @@ import ol.event.EventListener; import ol.geom.Point; import ol.interaction.KeyboardPan; import ol.interaction.KeyboardZoom; +import ol.layer.Base; import ol.layer.Image; import ol.layer.LayerOptions; import ol.layer.Tile; @@ -32,6 +43,7 @@ import ol.source.ImageWms; import ol.source.ImageWmsOptions; import ol.source.ImageWmsParams; import ol.source.Osm; +import ol.source.Source; import ol.source.XyzOptions; import ol.style.Icon; import ol.style.IconOptions; @@ -172,7 +184,7 @@ public class LightOpenLayerOSM { * * @param mapServerHost the map server host * @param layerName the layer name - * @param bbox + * @param bbox the bbox * @return the image */ public Image addWMSLayer(String mapServerHost, String layerName, BoundsMap bbox) { @@ -214,6 +226,83 @@ public class LightOpenLayerOSM { return null; } + /** + * Gets the layers. + * + * @return the layers + */ + public List getLayers() { + Collection layers = map.getLayers(); + List layerNames = null; + if (layers != null) { + Base[] layersArr = layers.getArray(); + layerNames = new ArrayList(layersArr.length); + for (int i = 0; i < layersArr.length; i++) { + Base layer = layersArr[i]; + if (layer instanceof Image) { + Image layerImage = (Image) layer; + + Source source = layerImage.getSource(); +// GWT.log("source: "+source.toString()); + GeoportalDataViewerConstants.printJsObj(source); + String sorceRootObj = GeoportalDataViewerConstants.toJsonObj(source); + JSONValue jsonObj = JSONParser.parseStrict(sorceRootObj); + // GWT.log("jsonObj: " + jsonObj.toString()); + JSONObject jsonSourceObj = (JSONObject) jsonObj; + + JSONObject jsonParamsObj = (JSONObject) jsonSourceObj.get("params_"); + // GWT.log("jsonParamsObj is: "+jsonParamsObj); + JSONValue jsonLayers = jsonParamsObj.get("LAYERS"); + GWT.log("theLayerName name is: " + jsonLayers); + layerNames.add(jsonLayers.toString()); + } + } + } + return layerNames; + } + + public java.util.Map getLayerURLsProperty() { + + Collection layers = map.getLayers(); + java.util.Map mapLayerNameURL = new HashMap(); + if (layers != null) { + Base[] layersArr = layers.getArray(); + for (int i = 0; i < layersArr.length; i++) { + Base layer = layersArr[i]; + // GeoportalDataViewerConstants.printJsObj(layer); + if (layer instanceof Image) { + Image layerImage = (Image) layer; + + Source source = layerImage.getSource(); +// GWT.log("source: "+source.toString()); +// GeoportalDataViewerConstants.printJsObj(source); + String sorceRootObj = GeoportalDataViewerConstants.toJsonObj(source); + JSONValue jsonObj = JSONParser.parseStrict(sorceRootObj); +// GWT.log("jsonObj: " + jsonObj.toString()); + JSONObject jsonSourceObj = (JSONObject) jsonObj; + + JSONObject jsonParamsObj = (JSONObject) jsonSourceObj.get("params_"); + // GWT.log("jsonParamsObj is: "+jsonParamsObj); + JSONString jsonLayers = (JSONString) jsonParamsObj.get("LAYERS"); + String layerName = jsonLayers.stringValue(); + GWT.log("jsonLayers is: " + layerName); +// GWT.log("theLayerName name is: " + jsonLayers); + + JSONValue jsonImage = jsonSourceObj.get("image_"); +// GWT.log("jsonImage: " + jsonImage.toString()); + JSONObject jsonImageObj = (JSONObject) jsonImage; + JSONString jsonSrc = (JSONString) jsonImageObj.get("src_"); + String layerURL = jsonSrc.stringValue(); + GWT.log("jsonSrc: " + layerURL); + mapLayerNameURL.put(layerName, layerURL); + } + + } + } + GWT.log("returning mapLayerNameURL: "+mapLayerNameURL); + return mapLayerNameURL; + } + /** * Adds the point. * diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java index c400859..3bb4bd3 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java @@ -403,8 +403,12 @@ public abstract class OpenLayerOSM { } + /** + * Removes the all detail layers. + */ public void removeAllDetailLayers() { + //NOT NEEDED ANYMORE.. I'M USING MIN/MAX LAYER RESOLUTION /* if (wmsDetailsLayerMap == null) @@ -422,32 +426,6 @@ public abstract class OpenLayerOSM { } -// public void addGeometry(Geometry theGeom) { -// -// if(theGeom==null) -// return; -// -// if(geometryLayer==null) { -// geometryLayer = new Vector("Feature selected"); -// geometryLayer.setDisplayInLayerSwitcher(false); -// map.addLayer(geometryLayer); -// }else { -// geometryLayer.removeAllFeatures(); -// } -// Style style = new Style(); -// style.setFillColor("#00FF00"); -// style.setGraphicName("circle"); -// style.setPointRadius(10); -// VectorFeature vf = new VectorFeature(theGeom, style); -// geometryLayer.addFeature(vf); -// } -// -// -// protected void removeGeometries() { -// if(geometryLayer!=null) -// geometryLayer.removeAllFeatures(); -// } - /** * Adds the vector. * @@ -588,7 +566,7 @@ public abstract class OpenLayerOSM { for (int i = 0; i < layersArr.length; i++) { Base layer = layersArr[i]; String theLayerName = (String) layer.get("name"); - GWT.log("The Layer name is: " + layerName); + GWT.log("The Layer name is: " + theLayerName); if (theLayerName != null && theLayerName.equals(layerName)) return true; } @@ -596,6 +574,32 @@ public abstract class OpenLayerOSM { return false; } + + + /** + * Gets the layer property. + * + * @param layerName the layer name + * @param property the property + * @return the layer property + */ + public String getLayerProperty(String layerName, String property) { + + Collection layers = map.getLayers(); + + if (layers != null) { + Base[] layersArr = layers.getArray(); + for (int i = 0; i < layersArr.length; i++) { + Base layer = layersArr[i]; + String theLayerName = (String) layer.get("name"); + GWT.log("The Layer name is: " + layerName); + if (theLayerName != null && theLayerName.equals(layerName)) + return layer.get(property); + } + } + + return null; + } /** * Gets the projection code. 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 829b4f7..6761490 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 @@ -23,14 +23,14 @@ import com.google.gwt.user.client.ui.Widget; import ol.Coordinate; import ol.OLFactory; - /** - * The Class MapView. - * - * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) - * - * Nov 11, 2020 - */ - public class MapView extends Composite{ +/** + * The Class MapView. + * + * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) + * + * Nov 11, 2020 + */ +public class MapView extends Composite { private static MapViewUiBinder uiBinder = GWT.create(MapViewUiBinder.class); @@ -39,55 +39,47 @@ import ol.OLFactory; * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * - * Nov 11, 2020 + * Nov 11, 2020 */ interface MapViewUiBinder extends UiBinder { } - + @UiField HTMLPanel theMap; - + @UiField HorizontalPanel coordinatePanel; - - private LightOpenLayerOSM olsm; - + + private LightOpenLayerOSM lightOLSM; + /** * Instantiates a new map view. * * @param centerTo the center to - * @param zoom the zoom + * @param zoom the zoom */ public MapView(Coordinate centerTo, int zoom, String internalMapWidth, String internalMapHeight) { initWidget(uiBinder.createAndBindUi(this)); - String theMapId = "map"+Random.nextInt(); + String theMapId = "map" + Random.nextInt(); theMap.getElement().setId(theMapId); theMap.setWidth(internalMapWidth); theMap.setHeight(internalMapHeight); - + Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { - olsm = new LightOpenLayerOSM(theMapId); - - //EPSG_3857 LOCATION TO ITALY + lightOLSM = new LightOpenLayerOSM(theMapId); + + // EPSG_3857 LOCATION TO ITALY Location italyLocation = ExtentMapUtil.getLocation(PLACE.ITALY); Coordinate transformedCenterCoordinate = italyLocation.getCoordinate(MAP_PROJECTION.EPSG_3857); - olsm.setCenter(transformedCenterCoordinate); - olsm.setZoom(GeoportalDataViewerConstants.LIGHT_MAP_ITALY_FIT_ZOOM_ON); - -// Coordinate centerCoordinate = OLFactory.createCoordinate(GeoportalDataViewerConstants.ITALY_CENTER_LONG, GeoportalDataViewerConstants.ITALY_CENTER_LAT); -// Coordinate transformedCenterCoordinate = MapUtils.transformCoordiante(centerCoordinate, GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857); -// olsm.setCenter(transformedCenterCoordinate); -// olsm.setZoom(GeoportalDataViewerConstants.LIGHT_MAP_ITALY_FIT_ZOOM_ON); - - //setMapSize(); - + lightOLSM.setCenter(transformedCenterCoordinate); + lightOLSM.setZoom(GeoportalDataViewerConstants.LIGHT_MAP_ITALY_FIT_ZOOM_ON); } }); } - + private void setMapSize() { Scheduler.get().scheduleDeferred(new ScheduledCommand() { @@ -95,38 +87,38 @@ import ol.OLFactory; public void execute() { int width = theMap.getParent().getOffsetWidth(); int height = theMap.getParent().getOffsetHeight(); - if(width==0) + if (width == 0) width = 300; - - if(height==0) + + if (height == 0) height = 300; - - GWT.log("Internal Map w: "+width + ", h: "+height); - theMap.setSize(width+"px", height+"px"); + + GWT.log("Internal Map w: " + width + ", h: " + height); + theMap.setSize(width + "px", height + "px"); } }); } - + /** * Adds the marker. * - * @param coordinate the coordinate + * @param coordinate the coordinate * @param showCoordinateText the show coordinate text */ - public void addMarker(Coordinate coordinate, boolean showCoordinateText) { - + public void addMarker(Coordinate coordinate, boolean showCoordinateText) { + Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { - if(olsm!=null) { - olsm.addPoint(coordinate, showCoordinateText, true); - olsm.getMap().getView().setCenter(coordinate); + if (lightOLSM != null) { + lightOLSM.addPoint(coordinate, showCoordinateText, true); + lightOLSM.getMap().getView().setCenter(coordinate); } } }); } - + /** * Adds the WMS layer. * @@ -139,12 +131,12 @@ import ol.OLFactory; @Override public void execute() { - + ExtentWrapped ew = null; BoundsMap theBBOX = bbox; - + if (bbox != null) { - + Coordinate lower = OLFactory.createCoordinate(bbox.getLowerLeftX(), bbox.getLowerLeftY()); Coordinate lowerCoord = MapUtils.transformCoordiante(lower, MAP_PROJECTION.EPSG_4326.getName(), MAP_PROJECTION.EPSG_3857.getName()); @@ -152,22 +144,27 @@ import ol.OLFactory; Coordinate upper = OLFactory.createCoordinate(bbox.getUpperRightX(), bbox.getUpperRightY()); Coordinate upperCoord = MapUtils.transformCoordiante(upper, MAP_PROJECTION.EPSG_4326.getName(), MAP_PROJECTION.EPSG_3857.getName()); - + ew = new ExtentWrapped(lowerCoord.getX(), lowerCoord.getY(), upperCoord.getX(), upperCoord.getY()); - theBBOX = new BoundsMap(lowerCoord.getX(), lowerCoord.getY(), upperCoord.getX(), upperCoord.getY(), null); + theBBOX = new BoundsMap(lowerCoord.getX(), lowerCoord.getY(), upperCoord.getX(), upperCoord.getY(), + null); } - - olsm.addWMSLayer(mapServerHost, layerName, theBBOX); + + lightOLSM.addWMSLayer(mapServerHost, layerName, theBBOX); if (ew != null) { - - olsm.getMap().getView().fit(ew); + + lightOLSM.getMap().getView().fit(ew); } } }); - + } - + + public LightOpenLayerOSM getLightOLSM() { + return lightOLSM; + } + } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java index 959e434..1423f69 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java @@ -266,16 +266,16 @@ public class ConcessioneView extends Composite { if(listLayersDV==null) return; - for (LayerConcessioneDV layer : listLayersDV) { + for (LayerConcessioneDV layerDV : listLayersDV) { - if(layer.getPolicy()==null || layer.getPolicy().equalsIgnoreCase("OPEN")) { + if(layerDV.getPolicy()==null || layerDV.getPolicy().equalsIgnoreCase("OPEN")) { piantaFineScavoPanel.setVisible(true); - piantaFineScavoPanel.add(new LayerConcessioneView(layer)); + piantaFineScavoPanel.add(new LayerConcessioneView(layerDV)); }else { //I need to be authenticated to show the fields according to POLICY if(myLogin!=null) { piantaFineScavoPanel.setVisible(true); - piantaFineScavoPanel.add(new LayerConcessioneView(layer)); + piantaFineScavoPanel.add(new LayerConcessioneView(layerDV)); } } } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/LayerConcessioneView.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/LayerConcessioneView.java index 0b1e57a..d194695 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/LayerConcessioneView.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/LayerConcessioneView.java @@ -1,5 +1,7 @@ package org.gcube.portlets.user.geoportaldataviewer.client.ui.products.concessioni; +import java.util.Map; + import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION; @@ -8,11 +10,15 @@ import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.L import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.PLACE; import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.MapView; import org.gcube.portlets.user.geoportaldataviewer.client.ui.util.CustomFlexTable; -import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil; +import com.github.gwtbootstrap.client.ui.DropdownButton; +import com.github.gwtbootstrap.client.ui.NavLink; import com.google.gwt.core.client.GWT; +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; +import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HTMLPanel; @@ -49,10 +55,6 @@ public class LayerConcessioneView extends Composite { GWT.log("WMS LINK: " + layerDV.getWmsLink()); if (layerDV.getLayerName() != null && layerDV.getWmsLink() != null) { - String pngWMSLink = URLUtil.setValueOfParameter("FORMAT", layerDV.getWmsLink(), "image/png", true); - - customTable.addNextKeyWidget("Layer", new HTML("download image")); - Location italyLocation = ExtentMapUtil.getLocation(PLACE.ITALY); Coordinate transformedCenterCoordinate = italyLocation.getCoordinate(MAP_PROJECTION.EPSG_3857); // Coordinate centerCoordinate = OLFactory.createCoordinate(GeoportalDataViewerConstants.ITALY_CENTER_LONG, GeoportalDataViewerConstants.ITALY_CENTER_LAT); @@ -64,8 +66,72 @@ public class LayerConcessioneView extends Composite { String mapServerHost = layerDV.getWmsLink().contains("?") ? layerDV.getWmsLink().substring(0, layerDV.getWmsLink().indexOf("?")) : layerDV.getWmsLink(); + + DropdownButton downloadButt = new DropdownButton("download as..."); + NavLink navLink = new NavLink("PNG"); + HTML html = new HTML(""); + navLink.getElement().appendChild(html.getElement()); + navLink.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + Map mapLayerURLs = mapView.getLightOLSM().getLayerURLsProperty(); + + String layerURL = mapLayerURLs.get(layerDV.getLayerName()); + GWT.log("layerDV name is: " + layerDV.getLayerName()); + if (layerURL != null) + Window.open(layerURL, "_blank", null); + + //downloadMap(mapView.getLightOLSM().getMap()); + } + }); + + downloadButt.add(navLink); + customTable.addNextKeyWidget("Layer", downloadButt); mapView.addWMSLayer(mapServerHost, layerDV.getLayerName(), layerDV.getBbox()); } } + /** + * Prints the. + * + * @param msg the msg + */ + public static native void downloadMap(ol.Map map)/*-{ + console.log("map: " + map); + map.once('rendercomplete', function() { + var mapCanvas = document.createElement('canvas'); + var size = map.getSize(); + mapCanvas.width = size[0]; + mapCanvas.height = size[1]; + var mapContext = mapCanvas.getContext('2d'); + Array.prototype.forEach.call(document + .querySelectorAll('.ol-layer canvas'), function(canvas) { + if (canvas.width > 0) { + var opacity = canvas.parentNode.style.opacity; + mapContext.globalAlpha = opacity === '' ? 1 + : Number(opacity); + var transform = canvas.style.transform; + // Get the transform parameters from the style's transform matrix + var matrix = transform.match(/^matrix\(([^\(]*)\)$/)[1] + .split(',').map(Number); + // Apply the transform to the export map context + CanvasRenderingContext2D.prototype.setTransform.apply( + mapContext, matrix); + mapContext.drawImage(canvas, 0, 0); + } + }); + if (navigator.msSaveBlob) { + // link download attribute does not work on MS browsers + navigator.msSaveBlob(mapCanvas.msToBlob(), 'map.png'); + } else { + console.log('qui'); +// var link = document.getElementById('image-download'); +// link.href = mapCanvas.toDataURL(); + window.open(mapCanvas.toDataURL(),'_blank'); + } + }); + map.renderSync(); + }-*/; + } -- 2.17.1 From 6f3b2e258ff0a87cbab98b38568ca63a13e37ff5 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 3 Sep 2021 18:22:42 +0200 Subject: [PATCH 16/38] fixed CORS issue vs Geoserver --- .../client/gis/LightOpenLayerOSM.java | 8 +- .../client/gis/OpenLayerOSM.java | 4 +- .../client/ui/map/MapView.java | 8 +- .../concessioni/LayerConcessioneView.java | 136 +++++++++++++++--- src/main/webapp/GeoportalDataViewer.html | 4 + 5 files changed, 139 insertions(+), 21 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerOSM.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerOSM.java index 025120a..4c662dd 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerOSM.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerOSM.java @@ -87,11 +87,12 @@ public class LightOpenLayerOSM { // create a OSM-layer XyzOptions osmSourceOptions = OLFactory.createOptions(); + osmSourceOptions.setCrossOrigin("Anonymous"); +// osmSourceOptions.setTileLoadFunction(null); Osm osmSource = new Osm(osmSourceOptions); LayerOptions osmLayerOptions = OLFactory.createOptions(); osmLayerOptions.setSource(osmSource); - Tile osmLayer = new Tile(osmLayerOptions); // create a projection projectionOptions.setCode(MAP_PROJECTION.EPSG_3857.getName()); @@ -198,6 +199,7 @@ public class LightOpenLayerOSM { // imageWMSParams.set("BBOX", bbox.getLowerLeftX()+","+bbox.getLowerLeftY()+","+bbox.getUpperRightX()+","+bbox.getUpperRightY()); ImageWmsOptions imageWMSOptions = OLFactory.createOptions(); + imageWMSOptions.setCrossOrigin("Anonymous"); imageWMSOptions.setUrl(mapServerHost); imageWMSOptions.setParams(imageWMSParams); // imageWMSOptions.setRatio(1.5f); @@ -263,13 +265,13 @@ public class LightOpenLayerOSM { public java.util.Map getLayerURLsProperty() { - Collection layers = map.getLayers(); + Collection layers = map.getLayerGroup().getLayers(); java.util.Map mapLayerNameURL = new HashMap(); if (layers != null) { Base[] layersArr = layers.getArray(); for (int i = 0; i < layersArr.length; i++) { Base layer = layersArr[i]; - // GeoportalDataViewerConstants.printJsObj(layer); + //GeoportalDataViewerConstants.printJs(layer.toString()); if (layer instanceof Image) { Image layerImage = (Image) layer; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java index 3bb4bd3..ddb62c0 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java @@ -140,7 +140,9 @@ public abstract class OpenLayerOSM { // create a OSM-layer XyzOptions osmSourceOptions = OLFactory.createOptions(); - +// osmSourceOptions.setCrossOrigin("Anonymous"); +// osmSourceOptions.setTileLoadFunction(null); + Osm osmSource = new Osm(osmSourceOptions); LayerOptions osmLayerOptions = OLFactory.createOptions(); osmLayerOptions.setSource(osmSource); 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 6761490..e28412b 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 @@ -52,6 +52,8 @@ public class MapView extends Composite { private LightOpenLayerOSM lightOLSM; + private String theMapId = null; + /** * Instantiates a new map view. * @@ -60,7 +62,7 @@ public class MapView extends Composite { */ public MapView(Coordinate centerTo, int zoom, String internalMapWidth, String internalMapHeight) { initWidget(uiBinder.createAndBindUi(this)); - String theMapId = "map" + Random.nextInt(); + theMapId = "map" + Random.nextInt(); theMap.getElement().setId(theMapId); theMap.setWidth(internalMapWidth); theMap.setHeight(internalMapHeight); @@ -99,6 +101,10 @@ public class MapView extends Composite { }); } + public String getPanelMapElementId() { + return theMapId; + } + /** * Adds the marker. * diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/LayerConcessioneView.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/LayerConcessioneView.java index d194695..af27a42 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/LayerConcessioneView.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/LayerConcessioneView.java @@ -1,5 +1,7 @@ package org.gcube.portlets.user.geoportaldataviewer.client.ui.products.concessioni; +import java.util.ArrayList; +import java.util.Collection; import java.util.Map; import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV; @@ -14,6 +16,8 @@ import org.gcube.portlets.user.geoportaldataviewer.client.ui.util.CustomFlexTabl import com.github.gwtbootstrap.client.ui.DropdownButton; import com.github.gwtbootstrap.client.ui.NavLink; import com.google.gwt.core.client.GWT; +import com.google.gwt.dom.client.Document; +import com.google.gwt.dom.client.Element; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.uibinder.client.UiBinder; @@ -69,20 +73,31 @@ public class LayerConcessioneView extends Composite { DropdownButton downloadButt = new DropdownButton("download as..."); NavLink navLink = new NavLink("PNG"); - HTML html = new HTML(""); - navLink.getElement().appendChild(html.getElement()); + String htmlLinkId = mapView.getPanelMapElementId() + "-image-download"; + final HTML htmlLink = new HTML(""); + navLink.getElement().appendChild(htmlLink.getElement()); navLink.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { - Map mapLayerURLs = mapView.getLightOLSM().getLayerURLsProperty(); +// Map mapLayerURLs = mapView.getLightOLSM().getLayerURLsProperty(); +// Collection layerURLs = mapLayerURLs.values(); +// ArrayList layers = new ArrayList(layerURLs); +// exportPDF(layers.get(0)); + + + +// String layerURL = mapLayerURLs.get(layerDV.getLayerName()); +// GWT.log("layerDV name is: " + layerDV.getLayerName()); +// if (layerURL != null) +// Window.open(layerURL, "_blank", null); - String layerURL = mapLayerURLs.get(layerDV.getLayerName()); - GWT.log("layerDV name is: " + layerDV.getLayerName()); - if (layerURL != null) - Window.open(layerURL, "_blank", null); - - //downloadMap(mapView.getLightOLSM().getMap()); +// GWT.log("GWT Map panel id: " + mapView.getPanelMapElementId()); +// Element mapContainer = +// Document.get().getElementById(mapView.getPanelMapElementId()); +// GWT.log("GWT Map panel id: " + mapContainer); + downloadMap(mapView.getLightOLSM().getMap(), mapView.getPanelMapElementId(), htmlLinkId); + // mapExport(mapView.getLightOLSM().getMap(), mapView.getPanelMapElementId()); } }); @@ -92,20 +107,31 @@ public class LayerConcessioneView extends Composite { } } + public static native void exportPDF(String layerURL) /*-{ + var image = new Image(layerURL); + + var doc = new $wnd.jspdf.jsPDF(); + doc.addImage(layerURL, 'PNG', 0, 0,image.width,image.height); + doc.save("map.pdf") + }-*/; + /** * Prints the. * * @param msg the msg */ - public static native void downloadMap(ol.Map map)/*-{ + public static native void downloadMap(ol.Map map, String mapPanelId, String linkId)/*-{ console.log("map: " + map); + map.once('rendercomplete', function() { - var mapCanvas = document.createElement('canvas'); + var mapCanvas = $doc.createElement('canvas'); var size = map.getSize(); mapCanvas.width = size[0]; mapCanvas.height = size[1]; var mapContext = mapCanvas.getContext('2d'); - Array.prototype.forEach.call(document + var mapContainer = $doc.querySelector('#'+mapPanelId); + //console.log("mapContainer:" +JSON.stringify(mapContainer, null, 4)); + Array.prototype.forEach.call(mapContainer .querySelectorAll('.ol-layer canvas'), function(canvas) { if (canvas.width > 0) { var opacity = canvas.parentNode.style.opacity; @@ -125,13 +151,91 @@ public class LayerConcessioneView extends Composite { // link download attribute does not work on MS browsers navigator.msSaveBlob(mapCanvas.msToBlob(), 'map.png'); } else { - console.log('qui'); -// var link = document.getElementById('image-download'); -// link.href = mapCanvas.toDataURL(); - window.open(mapCanvas.toDataURL(),'_blank'); + var link = $doc.getElementById(linkId); + link.href = mapCanvas.toDataURL(); + link.click(); } }); map.renderSync(); }-*/; +// public static native void mapExport(ol.Map map, String mapPanelId)/*-{ +// try { +// var dims = { +// a0 : [ 1189, 841 ], +// a1 : [ 841, 594 ], +// a2 : [ 594, 420 ], +// a3 : [ 420, 297 ], +// a4 : [ 297, 210 ], +// a5 : [ 210, 148 ], +// }; +// +// var resolutions = { +// 72 : 72, +// 150 : 150, +// 300 : 300, +// }; +// +// //var format = document.getElementById('format').value; +// var format = 'a4'; +// //var resolution = document.getElementById('resolution').value; +// var resolution = resolutions[150]; +// var dim = dims[format]; +// var width = Math.round((dim[0] * resolution) / 25.4); +// var height = Math.round((dim[1] * resolution) / 25.4); +// var size = map.getSize(); +// var viewResolution = map.getView().getResolution(); +// +// map.once('rendercomplete', function() { +// var mapCanvas = $doc.createElement('canvas'); +// mapCanvas.width = width; +// mapCanvas.height = height; +// var mapContext = mapCanvas.getContext('2d'); +// var selectId = "#" + mapPanelId; +// console.log('selectId: ' + selectId); +// var container = $doc.querySelector(selectId); +// console.log('container: ' + container); +// Array.prototype.forEach.call(container +// .querySelectorAll('.ol-layer canvas'), +// function(canvas) { +// canvas.crossOrigin = "anonymous"; // This enables CORS +// if (canvas.width > 0) { +// var opacity = canvas.parentNode.style.opacity; +// mapContext.globalAlpha = opacity === '' ? 1 +// : Number(opacity); +// var transform = canvas.style.transform; +// // Get the transform parameters from the style's transform matrix +// var matrix = transform +// .match(/^matrix\(([^\(]*)\)$/)[1] +// .split(',').map(Number); +// // Apply the transform to the export map context +// CanvasRenderingContext2D.prototype.setTransform +// .apply(mapContext, matrix); +// mapContext.drawImage(canvas, 0, 0); +// } +// }); +// +// //window.open(mapCanvas.toDataURL(), '_blank'); +// +// var pdf = new $wnd.jspdf.jsPDF('landscape', undefined, format); +// pdf.addImage(mapCanvas.toDataURL('image/jpeg'), 'JPEG', 0, 0, +// dim[0], dim[1]); +// pdf.save('map.pdf'); +// // Reset original map size +// map.setSize(size); +// map.getView().setResolution(viewResolution); +// exportButton.disabled = false; +// document.body.style.cursor = 'auto'; +// }); +// //map.renderSync(); +// // Set print size +// var printSize = [width, height]; +// map.setSize(printSize); +// var scaling = Math.min(width / size[0], height / size[1]); +// map.getView().setResolution(viewResolution / scaling); +// } catch (error) { +// window.alert(error); +// } +// }-*/; + } diff --git a/src/main/webapp/GeoportalDataViewer.html b/src/main/webapp/GeoportalDataViewer.html index 9eb5b3d..6050d5f 100644 --- a/src/main/webapp/GeoportalDataViewer.html +++ b/src/main/webapp/GeoportalDataViewer.html @@ -20,6 +20,10 @@ href="//cdnjs.cloudflare.com/ajax/libs/nanogallery2/3.0.5/css/nanogallery2.min.css" rel="stylesheet" type="text/css"> + + -- 2.17.1 From c471f39d508942600af3877c4cd97a23bbb9c46b Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 6 Sep 2021 11:05:43 +0200 Subject: [PATCH 17/38] completed download of map image --- .../concessioni/LayerConcessioneView.java | 123 +++++++++++------- 1 file changed, 73 insertions(+), 50 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/LayerConcessioneView.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/LayerConcessioneView.java index af27a42..61d0409 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/LayerConcessioneView.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/LayerConcessioneView.java @@ -1,9 +1,5 @@ package org.gcube.portlets.user.geoportaldataviewer.client.ui.products.concessioni; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Map; - import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION; @@ -15,9 +11,10 @@ import org.gcube.portlets.user.geoportaldataviewer.client.ui.util.CustomFlexTabl import com.github.gwtbootstrap.client.ui.DropdownButton; import com.github.gwtbootstrap.client.ui.NavLink; +import com.github.gwtbootstrap.client.ui.constants.ButtonType; import com.google.gwt.core.client.GWT; -import com.google.gwt.dom.client.Document; -import com.google.gwt.dom.client.Element; +import com.google.gwt.dom.client.Style; +import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.uibinder.client.UiBinder; @@ -45,73 +42,98 @@ public class LayerConcessioneView extends Composite { private CustomFlexTable customTable = new CustomFlexTable(); + private static enum IMAGE_EXPORT_AS { + PNG, JPEG + }; + + int downloadAttempt = 0; + public LayerConcessioneView(LayerConcessioneDV layerDV) { initWidget(uiBinder.createAndBindUi(this)); GWT.log("Showing: " + layerDV); - customTable.addNextKeyValue("Abstract", layerDV.getAbstractSection()); - customTable.addNextKeyValue("Valutazione qualità", layerDV.getValutazioneQualita()); - customTable.addNextKeyValue("Metodo raccolta dati", layerDV.getMetodoRaccoltaDati()); - customTable.addNextKeyValue("Scala acquisizione dati", layerDV.getScalaAcquisizione()); - customTable.addNextKeyValues("Autori", layerDV.getAuthors(), GeoportalDataViewerConstants.NEW_LINE_BR); - layerConcessionePanel.add(customTable); - + DropdownButton exportMapButton = new DropdownButton("Export Map as..."); + exportMapButton.setType(ButtonType.LINK); + exportMapButton.setTitle("Export this map view (OSM + layer) as an image..."); + exportMapButton.setVisible(false); + Style expButton = exportMapButton.getElement().getStyle(); + expButton.setMarginTop(2, Unit.PX); + GWT.log("WMS LINK: " + layerDV.getWmsLink()); if (layerDV.getLayerName() != null && layerDV.getWmsLink() != null) { Location italyLocation = ExtentMapUtil.getLocation(PLACE.ITALY); Coordinate transformedCenterCoordinate = italyLocation.getCoordinate(MAP_PROJECTION.EPSG_3857); -// Coordinate centerCoordinate = OLFactory.createCoordinate(GeoportalDataViewerConstants.ITALY_CENTER_LONG, GeoportalDataViewerConstants.ITALY_CENTER_LAT); -// Coordinate transformedCenterCoordinate = MapUtils.transformCoordiante(centerCoordinate, MAP_PROJECTION.EPSG_4326.getName(), MAP_PROJECTION.EPSG_3857.getName()); MapView mapView = new MapView(transformedCenterCoordinate, GeoportalDataViewerConstants.LIGHT_MAP_ITALY_FIT_ZOOM_ON, "70%", "300px"); - + + exportMapButton.setVisible(true); + mapViewPanel.add(exportMapButton); mapViewPanel.add(mapView); String mapServerHost = layerDV.getWmsLink().contains("?") ? layerDV.getWmsLink().substring(0, layerDV.getWmsLink().indexOf("?")) : layerDV.getWmsLink(); - DropdownButton downloadButt = new DropdownButton("download as..."); - NavLink navLink = new NavLink("PNG"); + String htmlLinkId = mapView.getPanelMapElementId() + "-image-download"; - final HTML htmlLink = new HTML(""); - navLink.getElement().appendChild(htmlLink.getElement()); - navLink.addClickHandler(new ClickHandler() { - @Override - public void onClick(ClickEvent event) { -// Map mapLayerURLs = mapView.getLightOLSM().getLayerURLsProperty(); -// Collection layerURLs = mapLayerURLs.values(); -// ArrayList layers = new ArrayList(layerURLs); -// exportPDF(layers.get(0)); - - - -// String layerURL = mapLayerURLs.get(layerDV.getLayerName()); -// GWT.log("layerDV name is: " + layerDV.getLayerName()); -// if (layerURL != null) -// Window.open(layerURL, "_blank", null); + for (IMAGE_EXPORT_AS exportType : IMAGE_EXPORT_AS.values()) { + NavLink navLink = new NavLink(exportType.name()); + String exportExt = exportType.name().toLowerCase(); + String filename = layerDV.getLayerName() + "." + exportExt; + String mimeType = "image/" + exportExt; + final HTML htmlLink = new HTML(""); + navLink.getElement().appendChild(htmlLink.getElement()); + navLink.addClickHandler(new ClickHandler() { -// GWT.log("GWT Map panel id: " + mapView.getPanelMapElementId()); -// Element mapContainer = -// Document.get().getElementById(mapView.getPanelMapElementId()); -// GWT.log("GWT Map panel id: " + mapContainer); - downloadMap(mapView.getLightOLSM().getMap(), mapView.getPanelMapElementId(), htmlLinkId); - // mapExport(mapView.getLightOLSM().getMap(), mapView.getPanelMapElementId()); - } - }); + @Override + public void onClick(ClickEvent event) { + + // DOWNLOAD only the layer by Geoserver + /* + * Map mapLayerURLs = + * mapView.getLightOLSM().getLayerURLsProperty(); Collection layerURLs = + * mapLayerURLs.values(); ArrayList layers = new + * ArrayList(layerURLs); exportPDF(layers.get(0)); String layerURL = + * mapLayerURLs.get(layerDV.getLayerName()); GWT.log("layerDV name is: " + + * layerDV.getLayerName()); if (layerURL != null) Window.open(layerURL, + * "_blank", null); + */ + + downloadAttempt++; + + if (downloadAttempt > 3) { + Window.alert("LOOP"); + return; + } + + // DOWNLOAD the OSM + layer by canvas + downloadMap(mapView.getLightOLSM().getMap(), mapView.getPanelMapElementId(), htmlLinkId, + filename, mimeType); + // mapExport(mapView.getLightOLSM().getMap(), mapView.getPanelMapElementId()); + } + }); + + exportMapButton.add(navLink); + + } + + customTable.addNextKeyValue("Abstract", layerDV.getAbstractSection()); + customTable.addNextKeyValue("Valutazione qualità", layerDV.getValutazioneQualita()); + customTable.addNextKeyValue("Metodo raccolta dati", layerDV.getMetodoRaccoltaDati()); + customTable.addNextKeyValue("Scala acquisizione dati", layerDV.getScalaAcquisizione()); + customTable.addNextKeyValues("Autori", layerDV.getAuthors(), GeoportalDataViewerConstants.NEW_LINE_BR); + layerConcessionePanel.add(customTable); - downloadButt.add(navLink); - customTable.addNextKeyWidget("Layer", downloadButt); mapView.addWMSLayer(mapServerHost, layerDV.getLayerName(), layerDV.getBbox()); } } public static native void exportPDF(String layerURL) /*-{ var image = new Image(layerURL); - + var doc = new $wnd.jspdf.jsPDF(); - doc.addImage(layerURL, 'PNG', 0, 0,image.width,image.height); + doc.addImage(layerURL, 'PNG', 0, 0, image.width, image.height); doc.save("map.pdf") }-*/; @@ -120,7 +142,8 @@ public class LayerConcessioneView extends Composite { * * @param msg the msg */ - public static native void downloadMap(ol.Map map, String mapPanelId, String linkId)/*-{ + public static native void downloadMap(ol.Map map, String mapPanelId, String linkId, String filename, + String mimeType)/*-{ console.log("map: " + map); map.once('rendercomplete', function() { @@ -129,7 +152,7 @@ public class LayerConcessioneView extends Composite { mapCanvas.width = size[0]; mapCanvas.height = size[1]; var mapContext = mapCanvas.getContext('2d'); - var mapContainer = $doc.querySelector('#'+mapPanelId); + var mapContainer = $doc.querySelector('#' + mapPanelId); //console.log("mapContainer:" +JSON.stringify(mapContainer, null, 4)); Array.prototype.forEach.call(mapContainer .querySelectorAll('.ol-layer canvas'), function(canvas) { @@ -149,10 +172,10 @@ public class LayerConcessioneView extends Composite { }); if (navigator.msSaveBlob) { // link download attribute does not work on MS browsers - navigator.msSaveBlob(mapCanvas.msToBlob(), 'map.png'); + navigator.msSaveBlob(mapCanvas.msToBlob(), filename); } else { var link = $doc.getElementById(linkId); - link.href = mapCanvas.toDataURL(); + link.href = mapCanvas.toDataURL(mimeType); link.click(); } }); -- 2.17.1 From ad71d45158f375a2374ff01fcb1c5be09b665508 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 6 Sep 2021 12:17:01 +0200 Subject: [PATCH 18/38] fixed the Export Map as --- .../client/ui/GeonaDataViewMainPanel.ui.xml | 2 +- .../products/concessioni/ConcessioneView.java | 16 ++++---- .../concessioni/ConcessioneView.ui.xml | 2 +- .../concessioni/LayerConcessioneView.java | 41 ++++++++++--------- 4 files changed, 31 insertions(+), 30 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml index 73a6768..3a2b810 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml @@ -40,7 +40,7 @@ + text="World" title="Center to World"> Share - View + Expand diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/LayerConcessioneView.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/LayerConcessioneView.java index 61d0409..4415cab 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/LayerConcessioneView.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/LayerConcessioneView.java @@ -12,6 +12,7 @@ import org.gcube.portlets.user.geoportaldataviewer.client.ui.util.CustomFlexTabl import com.github.gwtbootstrap.client.ui.DropdownButton; import com.github.gwtbootstrap.client.ui.NavLink; import com.github.gwtbootstrap.client.ui.constants.ButtonType; +import com.github.gwtbootstrap.client.ui.constants.IconType; import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.Style; import com.google.gwt.dom.client.Style.Unit; @@ -52,31 +53,32 @@ public class LayerConcessioneView extends Composite { initWidget(uiBinder.createAndBindUi(this)); GWT.log("Showing: " + layerDV); - DropdownButton exportMapButton = new DropdownButton("Export Map as..."); - exportMapButton.setType(ButtonType.LINK); - exportMapButton.setTitle("Export this map view (OSM + layer) as an image..."); - exportMapButton.setVisible(false); - Style expButton = exportMapButton.getElement().getStyle(); - expButton.setMarginTop(2, Unit.PX); - GWT.log("WMS LINK: " + layerDV.getWmsLink()); if (layerDV.getLayerName() != null && layerDV.getWmsLink() != null) { + + DropdownButton exportMapButton = new DropdownButton("Export Map as..."); + exportMapButton.setType(ButtonType.LINK); + exportMapButton.setIcon(IconType.DOWNLOAD_ALT); + exportMapButton.setTitle("Export the map view (OSM + layer) as an image..."); + Style exportStyle = exportMapButton.getElement().getStyle(); + exportStyle.setWidth(100, Unit.PCT); + exportStyle.setMarginLeft(70, Unit.PCT); Location italyLocation = ExtentMapUtil.getLocation(PLACE.ITALY); Coordinate transformedCenterCoordinate = italyLocation.getCoordinate(MAP_PROJECTION.EPSG_3857); MapView mapView = new MapView(transformedCenterCoordinate, GeoportalDataViewerConstants.LIGHT_MAP_ITALY_FIT_ZOOM_ON, "70%", "300px"); - exportMapButton.setVisible(true); - mapViewPanel.add(exportMapButton); mapViewPanel.add(mapView); + mapViewPanel.add(exportMapButton); String mapServerHost = layerDV.getWmsLink().contains("?") ? layerDV.getWmsLink().substring(0, layerDV.getWmsLink().indexOf("?")) : layerDV.getWmsLink(); - + mapView.addWMSLayer(mapServerHost, layerDV.getLayerName(), layerDV.getBbox()); + String htmlLinkId = mapView.getPanelMapElementId() + "-image-download"; - + for (IMAGE_EXPORT_AS exportType : IMAGE_EXPORT_AS.values()) { NavLink navLink = new NavLink(exportType.name()); String exportExt = exportType.name().toLowerCase(); @@ -117,16 +119,15 @@ public class LayerConcessioneView extends Composite { exportMapButton.add(navLink); } - - customTable.addNextKeyValue("Abstract", layerDV.getAbstractSection()); - customTable.addNextKeyValue("Valutazione qualità", layerDV.getValutazioneQualita()); - customTable.addNextKeyValue("Metodo raccolta dati", layerDV.getMetodoRaccoltaDati()); - customTable.addNextKeyValue("Scala acquisizione dati", layerDV.getScalaAcquisizione()); - customTable.addNextKeyValues("Autori", layerDV.getAuthors(), GeoportalDataViewerConstants.NEW_LINE_BR); - layerConcessionePanel.add(customTable); - - mapView.addWMSLayer(mapServerHost, layerDV.getLayerName(), layerDV.getBbox()); + //mapViewPanel.add(exportMapButton); } + + customTable.addNextKeyValue("Abstract", layerDV.getAbstractSection()); + customTable.addNextKeyValue("Valutazione qualità", layerDV.getValutazioneQualita()); + customTable.addNextKeyValue("Metodo raccolta dati", layerDV.getMetodoRaccoltaDati()); + customTable.addNextKeyValue("Scala acquisizione dati", layerDV.getScalaAcquisizione()); + customTable.addNextKeyValues("Autori", layerDV.getAuthors(), GeoportalDataViewerConstants.NEW_LINE_BR); + layerConcessionePanel.add(customTable); } public static native void exportPDF(String layerURL) /*-{ -- 2.17.1 From 0e082c0c37b8188b24bd04b8c1dddcc34a6a47ac Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 6 Sep 2021 16:39:12 +0200 Subject: [PATCH 19/38] removed PointsPath and passed to Geometry JSON string --- .../client/GeoportalDataViewerConstants.java | 17 ++- .../client/LayerManager.java | 81 ++++++++-- .../server/gis/FeatureParser.java | 140 +++++++++--------- .../shared/gis/wfs/FeatureGeometry.java | 44 ++++-- .../shared/gis/wfs/PointsPath.java | 60 -------- .../shared/gis/wfs/WFSGeometry.java | 11 +- 6 files changed, 188 insertions(+), 165 deletions(-) delete mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/wfs/PointsPath.java diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java index a19011f..d7ae1db 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java @@ -48,14 +48,20 @@ public class GeoportalDataViewerConstants { public static enum MAP_PROJECTION { - EPSG_4326("EPSG:4326"), EPSG_3857("EPSG:3857"); + EPSG_4326("4326", "EPSG:4326"), EPSG_3857("3857", "EPSG:3857"); + String id; String name; - MAP_PROJECTION(String name) { + MAP_PROJECTION(String id, String name) { + this.id = id; this.name = name; } + public String getId() { + return id; + } + public String getName() { return name; } @@ -78,17 +84,16 @@ public class GeoportalDataViewerConstants { public static native void printJs(String msg)/*-{ console.log("js console: " + msg); }-*/; - + /** * Prints the. * * @param msg the msg */ public static native void printJsObj(Object object)/*-{ - console.log("js obj: "+JSON.stringify(object, null, 4)); + console.log("js obj: " + JSON.stringify(object, null, 4)); }-*/; - - + /** * Prints the. * 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 b359f34..fee25ae 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 @@ -21,6 +21,8 @@ import org.gcube.portlets.user.geoportaldataviewer.client.events.QueryDataEventH import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowDetailsEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.ZoomOutOverMinimumEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.ZoomOutOverMinimumEventHandler; +import org.gcube.portlets.user.geoportaldataviewer.client.gis.ExtentWrapped; +import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils; import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerOSM; import org.gcube.portlets.user.geoportaldataviewer.client.util.StringUtil; import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil; @@ -29,7 +31,6 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.FeatureRow; -import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.PointsPath; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformationForWMSRequest; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.ZAxis; @@ -41,6 +42,8 @@ import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.shared.HandlerManager; +import com.google.gwt.json.client.JSONArray; +import com.google.gwt.json.client.JSONParser; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Event; @@ -52,6 +55,10 @@ import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.VerticalPanel; import ol.Coordinate; +import ol.Extent; +import ol.OLFactory; +import ol.format.GeoJson; +import ol.geom.Geometry; /** * The Class LayerManager. @@ -350,17 +357,69 @@ public class LayerManager { } 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()); - PointsPath path = feature.getGeometry().getPath(); - GWT.log("Points Path: " + path); - if (path != null && path.getCoordinates() != null - && path.getCoordinates().length > 0) { - org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.Coordinate center = path - .getCoordinates()[0]; - centerTo = new Coordinate(center.getX(), center.getY()); } + GWT.log("center is: "+centerTo); +// PointsPath path = feature.getGeometry().getPath(); +// GWT.log("Points Path: " + path); +// if (path != null && path.getCoordinates() != null +// && path.getCoordinates().length > 0) { +// org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.Coordinate center = path +// .getCoordinates()[0]; +// centerTo = new Coordinate(center.getX(), center.getY()); +// } } // fallback @@ -538,8 +597,8 @@ public class LayerManager { * @param isNcWms the is nc wms * @param UUID the uuid * @param zAxis the z axis - * @param minResolution the min resolution - * @param maxResolution the max resolution + * @param minResolution the min resolution + * @param maxResolution the max resolution * @return the layer item */ private LayerItem toLayerItem(LayerType layerType, String layerTitle, String layerName, String layerURL, diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/gis/FeatureParser.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/gis/FeatureParser.java index fa3362b..f7f52b8 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/gis/FeatureParser.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/gis/FeatureParser.java @@ -19,23 +19,20 @@ import org.gcube.application.geoportalcommon.shared.gis.BoundsMap; import org.gcube.application.geoportalcommon.util.URLParserUtil; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem; -import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.Coordinate; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.FeatureGeometry; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.FeatureRow; -import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.PointsPath; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - /** * The Class FeatureParser. * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * - * Nov 13, 2020 + * Nov 13, 2020 */ public class FeatureParser { @@ -44,125 +41,132 @@ public class FeatureParser { /** * Gets the WFS features. * - * @param layerItem the layer item - * @param mapSrsName the map srs name - * @param selectBBOX the select BBOX + * @param layerItem the layer item + * @param mapSrsName the map srs name + * @param selectBBOX the select BBOX * @param maxWFSFeature the max WFS feature * @return the WFS features */ - public static List getWFSFeatures(LayerItem layerItem, String mapSrsName, BoundsMap selectBBOX, int maxWFSFeature) { + public static List getWFSFeatures(LayerItem layerItem, String mapSrsName, BoundsMap selectBBOX, + int maxWFSFeature) { - if(maxWFSFeature<0) { + if (maxWFSFeature < 0) { maxWFSFeature = GeoportalDataViewerConstants.MAX_WFS_FEATURES; } return getWFSFeatureProperties(layerItem, mapSrsName, selectBBOX, maxWFSFeature); } - - - - + /** * Gets the WFS feature properties. * - * @param layerItem the layer item - * @param mapSrsName the map srs name - * @param selectBBOX the select BBOX + * @param layerItem the layer item + * @param mapSrsName the map srs name + * @param selectBBOX the select BBOX * @param maxWFSFeature the max WFS feature * @return the WFS feature properties */ @SuppressWarnings("unchecked") - private static List getWFSFeatureProperties(LayerItem layerItem, String mapSrsName, BoundsMap selectBBOX, int maxWFSFeature) { + private static List getWFSFeatureProperties(LayerItem layerItem, String mapSrsName, + BoundsMap selectBBOX, int maxWFSFeature) { - LOG.info("getWFSFeatureProperties for layerItem: "+layerItem.getName() +" in the "+selectBBOX +" and maxWFSFeature: "+maxWFSFeature); + LOG.info("getWFSFeatureProperties for layerItem: " + layerItem.getName() + " in the " + selectBBOX + + " and maxWFSFeature: " + maxWFSFeature); InputStream is = null; List listFeaturesRow = new ArrayList(); try { - String url = GisMakers.buildWFSFeatureQuery(layerItem, mapSrsName, selectBBOX, maxWFSFeature, GisMakers.JSON); + String url = GisMakers.buildWFSFeatureQuery(layerItem, mapSrsName, selectBBOX, maxWFSFeature, + GisMakers.JSON); String cqlFilterValue = URLParserUtil.extractValueOfParameterFromURL(GisMakers.CQL_FILTER_PARAMETER, url); - LOG.info("Found CQL filter value into query string: "+cqlFilterValue); - - if(cqlFilterValue!=null) { - String notEncodedCQLFilter = String.format("%s=%s",GisMakers.CQL_FILTER_PARAMETER,cqlFilterValue); - //log.info("Found CQL filter: "+notEncodedCQLFilter); - String toEncodeCQLFilter = String.format("%s=%s",GisMakers.CQL_FILTER_PARAMETER,URLEncoder.encode(cqlFilterValue,"UTF-8")); - LOG.debug("Encoded CQL filter: "+toEncodeCQLFilter); + LOG.info("Found CQL filter value into query string: " + cqlFilterValue); + + if (cqlFilterValue != null) { + String notEncodedCQLFilter = String.format("%s=%s", GisMakers.CQL_FILTER_PARAMETER, cqlFilterValue); + // log.info("Found CQL filter: "+notEncodedCQLFilter); + String toEncodeCQLFilter = String.format("%s=%s", GisMakers.CQL_FILTER_PARAMETER, + URLEncoder.encode(cqlFilterValue, "UTF-8")); + LOG.debug("Encoded CQL filter: " + toEncodeCQLFilter); url = url.replace(notEncodedCQLFilter, toEncodeCQLFilter); } - - LOG.info("Built WFS URL: "+url); + + LOG.info("Built WFS URL: " + url); is = new URL(url).openStream(); String jsonTxt = IOUtils.toString(is); - if(jsonTxt==null || jsonTxt.isEmpty()){ + if (jsonTxt == null || jsonTxt.isEmpty()) { jsonTxt = "{\"type\":\"FeatureCollection\",\"features\":[]}"; } - + // get json object JSONObject json = new JSONObject(jsonTxt); // iterate features JSONArray features = json.getJSONArray("features"); - if(features.length()==0) { + if (features.length() == 0) { LOG.info("No features detected in the response, returning empty list"); return listFeaturesRow; } - + String featureCRSName = ""; try { JSONObject crs = json.getJSONObject("crs"); JSONObject crsProp = crs.getJSONObject("properties"); featureCRSName = crsProp.getString("name"); - LOG.info("Crs name found: "+featureCRSName); - }catch (Exception e) { + LOG.info("Crs name found: " + featureCRSName); + } catch (Exception e) { LOG.warn("Unable to read the field 'crs'"); } - LOG.info("Features are: "+features.length()); - - for (int i=0; i> mapProperties = new HashMap>(); + Map> mapProperties = new HashMap>(); @SuppressWarnings("unchecked") Iterator ii = properties.keys(); while (ii.hasNext()) { String key = ii.next(); - String value = properties.optString(key,""); - + String value = properties.optString(key, ""); + List theValues = mapProperties.get(key); - if(theValues==null) + if (theValues == null) mapProperties.put(key, Arrays.asList(value)); else { theValues.add(value); @@ -171,18 +175,18 @@ public class FeatureParser { } row.setMapProperties(mapProperties); listFeaturesRow.add(row); - LOG.info("Added row "+row+" to exported properties"); + LOG.info("Added row " + row + " to exported properties"); } } catch (IOException e) { - LOG.error("Error for layerItem name: "+layerItem.getName(), e); + LOG.error("Error for layerItem name: " + layerItem.getName(), e); } catch (JSONException e) { - LOG.error("Error for layerItem name: "+layerItem.getName(), e); - }finally{ + LOG.error("Error for layerItem name: " + layerItem.getName(), e); + } finally { IOUtils.closeQuietly(is); } - LOG.info("Returning "+listFeaturesRow.size()+" features"); + LOG.info("Returning " + listFeaturesRow.size() + " features"); return listFeaturesRow; } } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/wfs/FeatureGeometry.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/wfs/FeatureGeometry.java index 89f62e5..a8364ba 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/wfs/FeatureGeometry.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/wfs/FeatureGeometry.java @@ -3,44 +3,60 @@ package org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs; import java.io.Serializable; /** - * The Class FeatureGeoemtry. + * The Class FeatureGeometry. * - * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * - * Oct 29, 2020 + * Sep 6, 2021 */ public class FeatureGeometry implements WFSGeometry, Serializable { /** * */ - private static final long serialVersionUID = 6251162740446739453L; + private static final long serialVersionUID = 8134176011135233810L; private String type; - private PointsPath path; + private String coordinatesJSON; + private String toJSON; + /** + * Instantiates a new feature geometry. + */ public FeatureGeometry() { } - public FeatureGeometry(String type, PointsPath path) { + /** + * Instantiates a new feature geometry. + * + * @param type the type + * @param coordinatesJSON the coordinates JSON + */ + public FeatureGeometry(String type, String coordinatesJSON) { super(); this.type = type; - this.path = path; + this.coordinatesJSON = coordinatesJSON; } public String getType() { return type; } + public String getCoordinatesJSON() { + return coordinatesJSON; + } + public void setType(String type) { this.type = type; } - public PointsPath getPath() { - return path; + public void setCoordinatesJSON(String coordinatesJSON) { + this.coordinatesJSON = coordinatesJSON; } - public void setPath(PointsPath path) { - this.path = path; + public String getToJSONObject() { + if(toJSON==null) + toJSON = "{\"type\":\""+type+"\",\"coordinates\":"+coordinatesJSON+"}"; + return toJSON; } @Override @@ -48,10 +64,10 @@ public class FeatureGeometry implements WFSGeometry, Serializable { StringBuilder builder = new StringBuilder(); builder.append("FeatureGeometry [type="); builder.append(type); - builder.append(", path="); - builder.append(path); + builder.append(", coordinatesJSON="); + builder.append(coordinatesJSON); builder.append("]"); return builder.toString(); } -} +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/wfs/PointsPath.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/wfs/PointsPath.java deleted file mode 100644 index d153b0f..0000000 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/wfs/PointsPath.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs; - -import java.io.Serializable; -import java.util.Arrays; - - -/** - * The Class PointsPath. - * - * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) - * - * Nov 16, 2020 - */ -public class PointsPath implements Serializable{ - - /** - * - */ - private static final long serialVersionUID = -3295493507974317970L; - - private Coordinate[] coordinates; - - /** - * Instantiates a new points path. - */ - public PointsPath() { - - } - - /** - * Instantiates a new points path. - * - * @param coordinates the coordinates - */ - public PointsPath(Coordinate[] coordinates) { - super(); - this.coordinates = coordinates; - } - - public Coordinate[] getCoordinates() { - return coordinates; - } - - /** - * To string. - * - * @return the string - */ - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("PointsPath [coordinates="); - builder.append(Arrays.toString(coordinates)); - builder.append("]"); - return builder.toString(); - } - - - -} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/wfs/WFSGeometry.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/wfs/WFSGeometry.java index 7a81954..f70685e 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/wfs/WFSGeometry.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/wfs/WFSGeometry.java @@ -4,9 +4,9 @@ package org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs; /** * The Interface WFSGeometry. * - * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * - * Nov 16, 2020 + * Sep 6, 2021 */ public interface WFSGeometry { @@ -16,13 +16,12 @@ public interface WFSGeometry { * @return the type */ String getType(); - /** - * Gets the path. + * Gets the coordinates JSON. * - * @return the path + * @return the coordinates JSON */ - PointsPath getPath(); + String getCoordinatesJSON(); } -- 2.17.1 From 2af0252338f34c90da216a89fc92447037607be5 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 6 Sep 2021 17:15:38 +0200 Subject: [PATCH 20/38] fixed css. managing popup info separately --- .../client/LayerManager.java | 527 ++++++++++++------ .../client/ui/GeonaDataViewMainPanel.java | 2 +- .../client/ui/map/ExtentMapUtil.java | 8 +- .../concessioni/LayerConcessioneView.java | 2 +- 4 files changed, 352 insertions(+), 187 deletions(-) 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 fee25ae..382fff5 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 @@ -107,11 +107,11 @@ public class LayerManager { GWT.log("(" + selectDataInfo.getX1() + "," + selectDataInfo.getY1() + ")(" + selectDataInfo.getX2() + "," + selectDataInfo.getY2() + ")"); - for (LayerObject layerObj : layerObjects.values()) { - // TODO - isLayerVisible(layerObj.getLayerItem()); - - } +// for (LayerObject layerObj : layerObjects.values()) { +// // TODO +// isLayerVisible(layerObj.getLayerItem()); +// +// } BoundsMap mapBBOX = new BoundsMap(); // THIS IS SHOULD BE CORRET, THE BOUND AND CRS ARE READ FROM MAP @@ -227,6 +227,8 @@ public class LayerManager { } GWT.log("the product id is: " + theProductId); + //Displaying popup info for centroid layer + showPopupInfoForCentroidLayer(geoNaDataObject, feature, queryEvent.getOnFailureCenterTo()); // retrieving and showing WMS layers of a concessione if the ZOOM level is > // QUERY_MIN_ZOOM_LEVEL @@ -260,195 +262,185 @@ public class LayerManager { olMap.removeAllDetailLayers(); } -// if(queryEvent.getSourceMapEventType() != null && queryEvent.getSourceMapEventType().equals(MapEventType.MAP_ZOOM_END)) { -// GWT.log("EVENT IS "+MapEventType.MAP_ZOOM_END +" retuning"); -// 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 : ""; +// } // } - // 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()); +// 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.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); - } - } - } - } - - featureFound = true; +// 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.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); +// } +// } +// } +// } +// +// featureFound = true; // break; //Only the first one } - if (feature == null) - return; +// if (feature == null) +// return; +// +// GWT.log("The selected Feature is: " + feature); +// // GeoportalDataViewerConstants.print("The selected Feature is: "+feature); +// FeatureRow theFeature = feature; +// Button button = null; +// if (!featureFound) { +// flex.setHTML(0, 0, new HTML("No data available").toString()); +// } else { +// button = new Button("Open Details"); +// button.getElement().setId("open-details"); +// button.setType(ButtonType.LINK); +// } +// +// VerticalPanel vpPanel = new VerticalPanel(); +// vpPanel.add(flex); - GWT.log("The selected Feature is: " + feature); - // GeoportalDataViewerConstants.print("The selected Feature is: "+feature); - FeatureRow theFeature = feature; - Button button = null; - if (!featureFound) { - flex.setHTML(0, 0, new HTML("No data available").toString()); - } else { - 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); +// +// } +// }); +// } - VerticalPanel vpPanel = new VerticalPanel(); - vpPanel.add(flex); - - 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( +// 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())); - - 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); -// PointsPath path = feature.getGeometry().getPath(); -// GWT.log("Points Path: " + path); -// if (path != null && path.getCoordinates() != null -// && path.getCoordinates().length > 0) { -// org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.Coordinate center = path -// .getCoordinates()[0]; -// centerTo = new Coordinate(center.getX(), center.getY()); +// +// 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 = queryEvent.getOnFailureCenterTo(); - - 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); - } - } - }); - } - }); +// // fallback +// if (centerTo == null) +// centerTo = queryEvent.getOnFailureCenterTo(); +// +// 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); +// } +// } +// }); +// } +// }); } } }); @@ -663,6 +655,179 @@ public class LayerManager { return layerItem; } + /** + * Show popup info for centroid layer. + * + * @param geoNaDataObject the geo na data object + * @param feature the feature + * @param onFailureCenterTo the on failure center to + */ + 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) { + olMap.showPopup(vpPanel.toString(), onFailureCenterTo); + flex.setHTML(0, 0, new HTML("No data available").toString()); + 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.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); + } + } + }); + } + }); + + } + /** * Checks if is layer visible. * diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java index 4721c13..54e264d 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java @@ -191,7 +191,7 @@ public class GeonaDataViewMainPanel extends Composite { @Override public void onClick(ClickEvent event) { - Location earthLocation = ExtentMapUtil.getLocation(ExtentMapUtil.PLACE.EARTH); + Location earthLocation = ExtentMapUtil.getLocation(ExtentMapUtil.PLACE.WORLD); applicationBus.fireEvent(new MapExtentToEvent(earthLocation)); map.setCenter(earthLocation.getCoordinate(MAP_PROJECTION.EPSG_3857)); map.setZoom(earthLocation.getZoomLevel()); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/ExtentMapUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/ExtentMapUtil.java index cfd4f11..d64795d 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/ExtentMapUtil.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/ExtentMapUtil.java @@ -27,7 +27,7 @@ public class ExtentMapUtil { * Sep 1, 2021 */ public static enum PLACE { - ITALY, EARTH + ITALY, WORLD } final static Map mapExtent = new HashMap(); @@ -39,13 +39,13 @@ public class ExtentMapUtil { GeoportalDataViewerConstants.ITALY_CENTER_LAT, MAP_PROJECTION.EPSG_4326, GeoportalDataViewerConstants.MAP_ITALY_FIT_ZOOM_ON); - // EPSG_4326 EARTH LOCATION - Location earth = new Location(PLACE.EARTH.name(), 0, + // EPSG_4326 WORLD LOCATION + Location earth = new Location(PLACE.WORLD.name(), 0, 0, MAP_PROJECTION.EPSG_4326, 2); mapExtent.put(PLACE.ITALY, ita); - mapExtent.put(PLACE.EARTH, earth); + mapExtent.put(PLACE.WORLD, earth); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/LayerConcessioneView.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/LayerConcessioneView.java index 4415cab..c1743c9 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/LayerConcessioneView.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/LayerConcessioneView.java @@ -61,7 +61,7 @@ public class LayerConcessioneView extends Composite { exportMapButton.setIcon(IconType.DOWNLOAD_ALT); exportMapButton.setTitle("Export the map view (OSM + layer) as an image..."); Style exportStyle = exportMapButton.getElement().getStyle(); - exportStyle.setWidth(100, Unit.PCT); + //exportStyle.setWidth(100, Unit.PCT); exportStyle.setMarginLeft(70, Unit.PCT); Location italyLocation = ExtentMapUtil.getLocation(PLACE.ITALY); -- 2.17.1 From 0c5085ca62232b78fb9f8e2017acc90e7b6d5f6a Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Tue, 7 Sep 2021 17:29:56 +0200 Subject: [PATCH 21/38] optimized popup-info for detail layers --- .../client/GeoportalDataViewer.java | 6 +- .../client/GeoportalDataViewerConstants.java | 4 +- .../client/GeoportalDataViewerService.java | 3 +- .../GeoportalDataViewerServiceAsync.java | 3 +- .../client/LayerManager.java | 340 +++++++----------- .../client/OLMapManager.java | 3 +- .../client/gis/OpenLayerOSM.java | 95 +++-- .../server/ConcessioneImageUtil.java | 89 +++++ .../GeoportalDataViewerServiceImpl.java | 56 +-- .../server/gis/FeatureParser.java | 17 +- .../server/util/SessionUtil.java | 54 +++ .../shared/GeoNaSpatialQueryResult.java | 2 +- .../shared/gis/LayerObject.java | 10 +- .../shared/gis/wfs/FeatureRow.java | 20 +- src/main/webapp/GeoportalDataViewer.css | 41 ++- 15 files changed, 415 insertions(+), 328 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConcessioneImageUtil.java 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 575bcdd..8236661 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 @@ -22,6 +22,7 @@ import org.gcube.portlets.user.geoportaldataviewer.client.events.ZoomOutOverMini import org.gcube.portlets.user.geoportaldataviewer.client.events.ZoomOutOverMinimumEventHandler; import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils; import org.gcube.portlets.user.geoportaldataviewer.client.ui.GeonaDataViewMainPanel; +import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery; import com.google.gwt.core.client.EntryPoint; @@ -168,7 +169,10 @@ public class GeoportalDataViewer implements EntryPoint { return; } - GWT.log("The layerItem is: " + layerItem); + GWT.log("ON module load The layerItem is: " + layerItem); + String layerName = URLUtil.getValueOfParameter("layers", layerItem.getWmsLink()); + layerItem.setName(layerName); + layerManager.setBaseLayerFromIsProfile(layerItem); layerManager.addLayer(theItemType, null, null, layerItem.getWmsLink(), false, false, null, false, null, null); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java index d7ae1db..6e0d9e1 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java @@ -26,7 +26,7 @@ public class GeoportalDataViewerConstants { public static final String GET_CENTER_MAP_TO_LONG_LAT = OpenLayersMapParameters.OL_MAP_PARAM.centermap.name(); public static enum MapEventType { - INIT, MAP_ZOOM_END, MOVE_END, ADDED_LAYER_TO_MAP + MOUSE_CLICK, MAP_ZOOM_END, MOVE_END, ADDED_LAYER_TO_MAP } /** @@ -74,7 +74,7 @@ public class GeoportalDataViewerConstants { public static final int LIGHT_MAP_ITALY_FIT_ZOOM_ON = 5; - public static final int MAP_ITALY_FIT_ZOOM_ON = 6; + public static final int MAP_ITALY_FIT_ZOOM_ON = 5; /** * Prints the. diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java index 0167a55..b4f9611 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java @@ -90,7 +90,7 @@ public interface GeoportalDataViewerService extends RemoteService { * @return the uploaded images for id * @throws Exception */ - List getUploadedImagesForId(String itemType, String itemId, int maxImages) throws Exception; + List getUploadedImagesForId(String itemType, String itemId, Integer maxImages) throws Exception; /** * Gets the public links for. @@ -124,4 +124,5 @@ public interface GeoportalDataViewerService extends RemoteService { List getWFSFeatures(List layerObjects, String mapSrsName, BoundsMap selectBBOX, int maxWFSFeature, double zoomLevel); + } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java index 564b6dd..fd50869 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java @@ -47,7 +47,8 @@ public interface GeoportalDataViewerServiceAsync { void getGeoNaDataViewProfile(AsyncCallback callback); - void getUploadedImagesForId(String itemType, String itemId, int maxImages, AsyncCallback> callback); + void getUploadedImagesForId(String itemType, String itemId, Integer maxImages, + AsyncCallback> callback); void getPublicLinksFor(GeoNaItemRef item, AsyncCallback asyncCallback); 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 382fff5..5b93a9b 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 @@ -14,6 +14,7 @@ import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessi 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; import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEventHandler; import org.gcube.portlets.user.geoportaldataviewer.client.events.QueryDataEvent; @@ -35,10 +36,13 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformation import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.ZAxis; import com.github.gwtbootstrap.client.ui.Button; +import com.github.gwtbootstrap.client.ui.Label; import com.github.gwtbootstrap.client.ui.constants.ButtonType; +import com.github.gwtbootstrap.client.ui.constants.LabelType; import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; +import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.shared.HandlerManager; @@ -52,6 +56,7 @@ import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.FlexTable; import com.google.gwt.user.client.ui.HTML; +import com.google.gwt.user.client.ui.ScrollPanel; import com.google.gwt.user.client.ui.VerticalPanel; import ol.Coordinate; @@ -78,6 +83,8 @@ public class LayerManager { private HandlerManager applicationBus; + private org.gcube.application.geoportalcommon.shared.LayerItem baseLayerFromISProfile; + /** * Instantiates a new layer manager. * @@ -110,23 +117,9 @@ public class LayerManager { // for (LayerObject layerObj : layerObjects.values()) { // // TODO // isLayerVisible(layerObj.getLayerItem()); -// // } BoundsMap mapBBOX = new BoundsMap(); - // THIS IS SHOULD BE CORRET, THE BOUND AND CRS ARE READ FROM MAP - /* - * mapBBOX.setCrs(olMap.getProjectionCode()); - * mapBBOX.setLowerLeftX(olMap.getExtent().getLowerLeftX()); - * mapBBOX.setLowerLeftY(olMap.getExtent().getLowerLeftY()); - * mapBBOX.setUpperRightX(olMap.getExtent().getUpperRightX()); - * mapBBOX.setUpperRightY(olMap.getExtent().getUpperRightY()); - */ - - // THE FOLLOWING SHOULD BE NOT NEEDED BUT THE GETFEATURE WITH EPSG_3857 SEEMS - // NOT WORK IN OUR GEOSERVER -// double minX = olMap.getExtent().getLowerLeftX(); -// double minY = olMap.getExtent().getLowerLeftY(); double minX = queryEvent.getGeoQuery().getX1(); double minY = queryEvent.getGeoQuery().getY1(); Coordinate centerCoordinate = new Coordinate(minX, minY); @@ -150,6 +143,16 @@ public class LayerManager { GWT.log("Bounds is: " + mapBBOX); GWT.log("MAX_WFS_FEATURES is: " + GeoportalDataViewerConstants.MAX_WFS_FEATURES); // GeoportalDataViewerConstants.print("calling getDataResult"); + +// List mapLayers = olMap.getLayers(); +//// List listLO = new ArrayList(mapLayers.size()); +// for (String layerName : mapLayers) { +//// LayerItem layerItem = new LayerItem(); +//// layerItem.setName(layerName); +//// listLO.add(new LayerObject("Concessione",layerItem)); +// GWT.log("Layer found: "+layerName); +// } + List listLO = new ArrayList(layerObjects.values()); GeoportalDataViewerServiceAsync.Util.getInstance().getDataResult(listLO, olMap.getProjectionCode(), mapBBOX, GeoportalDataViewerConstants.MAX_WFS_FEATURES, olMap.getCurrentZoomLevel(), @@ -165,28 +168,26 @@ public class LayerManager { public void onSuccess(List listGeonaDataObjects) { GWT.log("GeoNaDataObject's is/are " + listGeonaDataObjects.size()); - GWT.log("GeoNaDataObject's: " + listGeonaDataObjects); + //GWT.log("GeoNaDataObject's: " + listGeonaDataObjects); // GeoportalDataViewerConstants.print("GeoNaDataObject's: // "+listGeonaDataObjects); if (listGeonaDataObjects == null || listGeonaDataObjects.isEmpty()) return; - FlexTable flex = new FlexTable(); - flex.setCellPadding(1); - flex.setCellSpacing(1); - flex.getElement().addClassName("popup-table"); - boolean featureFound = false; FeatureRow feature = null; // 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 exaclty the feature with produc_id == recordId + // I need to show exactly the feature with produc_id == recordId if (mongoItemId != null) { for (FeatureRow fRow : features) { List productIdLst = fRow.getMapProperties() @@ -212,9 +213,19 @@ public class LayerManager { List productIdLst = feature.getMapProperties() .get("product_id"); if (productIdLst == null) { - // in this case the feature returned is a (detail) layer belonging + // in this case the feature/s returned is/are a (detail) layer/s + // belonging // to a record/concessione (not centroid layer), - // so returning + // so calling show popuup info on detail layers if the + // following events are true. + if (queryEvent.getSourceMapEventType() + .equals(MapEventType.MOUSE_CLICK) + && olMap.getCurrentZoomLevel() > OLMapManager.QUERY_MIN_ZOOM_LEVEL) { + + //Here I need to pass only the visible layers + showPopupInfoForLayer(listGeonaDataObjects, + queryEvent.getOnFailureCenterTo()); + } return; } theProductId = productIdLst.get(0); @@ -227,8 +238,9 @@ public class LayerManager { } GWT.log("the product id is: " + theProductId); - //Displaying popup info for centroid layer - showPopupInfoForCentroidLayer(geoNaDataObject, feature, queryEvent.getOnFailureCenterTo()); + // Displaying popup info for centroid layer + showPopupInfoForCentroidLayer(geoNaDataObject, feature, + queryEvent.getOnFailureCenterTo()); // retrieving and showing WMS layers of a concessione if the ZOOM level is > // QUERY_MIN_ZOOM_LEVEL @@ -261,186 +273,7 @@ public class LayerManager { // QUERY_MIN_ZOOM_LEVEL olMap.removeAllDetailLayers(); } - - - // 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.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); -// } -// } -// } -// } -// -// featureFound = true; - // break; //Only the first one } - -// if (feature == null) -// return; -// -// GWT.log("The selected Feature is: " + feature); -// // GeoportalDataViewerConstants.print("The selected Feature is: "+feature); -// FeatureRow theFeature = feature; -// Button button = null; -// if (!featureFound) { -// flex.setHTML(0, 0, new HTML("No data available").toString()); -// } else { -// button = new Button("Open Details"); -// button.getElement().setId("open-details"); -// button.setType(ButtonType.LINK); -// } -// -// VerticalPanel vpPanel = new VerticalPanel(); -// vpPanel.add(flex); - -// 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 = queryEvent.getOnFailureCenterTo(); -// -// 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); -// } -// } -// }); -// } -// }); } } }); @@ -655,11 +488,96 @@ public class LayerManager { return layerItem; } + /** + * Show popup info for layer. + * + * @param geoNaDataObject the geo na data object + * @param feature the feature + * @param onFailureCenterTo the on failure center to + */ + public void showPopupInfoForLayer(List listGeoNaDataObject, + Coordinate onFailureCenterTo) { + + ScrollPanel scrollPanel = new ScrollPanel(); + VerticalPanel vpPanel = new VerticalPanel(); + scrollPanel.add(vpPanel); + + for (GeoNaSpatialQueryResult geoNaSpatialQueryResult : listGeoNaDataObject) { + + GWT.log("baseLayerFromISProfile.getName() :"+baseLayerFromISProfile.getName()); + String layerSource = geoNaSpatialQueryResult.getSourceLayerObject().getLayerItem().getName(); + + //skipping centroid layer + if(layerSource==null || layerSource.compareToIgnoreCase(baseLayerFromISProfile.getName())==0) { + continue; + } + + Label layerLabel = new Label(); + layerLabel.setType(LabelType.INFO); + + layerLabel.setText(layerSource); + layerLabel.getElement().getStyle().setMarginTop(10, Unit.PX); + layerLabel.getElement().getStyle().setMarginBottom(5, Unit.PX); + vpPanel.add(layerLabel); + + List features = geoNaSpatialQueryResult.getFeatures(); + + if (features == null || features.isEmpty()) { + FlexTable flex = new FlexTable(); + flex.setCellPadding(1); + flex.setCellSpacing(1); + flex.getElement().addClassName("table-feature"); + flex.setHTML(0, 0, new HTML("No data available").toString()); + vpPanel.add(flex); + continue; + //olMap.showPopup(vpPanel.toString(), onFailureCenterTo); + } + + for (FeatureRow feature : 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()); + intFlex.setHTML(1, 0, new HTML(feature.getId()).toString()); + + // Showing properties belonging to concessioni centroid layer + Map> entries = feature.getMapProperties(); + + if (entries.size() == 0) { + intFlex.setHTML(1, 1, new HTML("No property available").toString()); + } + int j = 1; + 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); + intFlex.setHTML(0, j, new HTML(key).toString()); + intFlex.setHTML(1, j, new HTML(valueToDisplay).toString()); + j++; + + } + + vpPanel.add(intFlex); + } + + } + + olMap.showPopup(scrollPanel.toString(), onFailureCenterTo); + + } + /** * Show popup info for centroid layer. * - * @param geoNaDataObject the geo na data object - * @param feature the feature + * @param geoNaDataObject the geo na data object + * @param feature the feature * @param onFailureCenterTo the on failure center to */ public void showPopupInfoForCentroidLayer(GeoNaSpatialQueryResult geoNaDataObject, FeatureRow feature, @@ -673,8 +591,8 @@ public class LayerManager { vpPanel.add(flex); if (feature == null) { - olMap.showPopup(vpPanel.toString(), onFailureCenterTo); flex.setHTML(0, 0, new HTML("No data available").toString()); + olMap.showPopup(vpPanel.toString(), onFailureCenterTo); return; } @@ -856,4 +774,12 @@ public class LayerManager { return layerManagerBus; } + public void setBaseLayerFromIsProfile(org.gcube.application.geoportalcommon.shared.LayerItem layerItem) { + this.baseLayerFromISProfile = layerItem; + } + + public org.gcube.application.geoportalcommon.shared.LayerItem getBaseLayerFromISProile() { + return baseLayerFromISProfile; + } + } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java index 216f6ab..12908fd 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java @@ -73,7 +73,7 @@ public class OLMapManager { // } GeoQuery select = toDataPointQuery(coordinate, true); - layerManagerBus.fireEvent(new QueryDataEvent(select, coordinate, null, true, MapEventType.INIT)); + layerManagerBus.fireEvent(new QueryDataEvent(select, coordinate, null, true, MapEventType.MOUSE_CLICK)); } @@ -152,6 +152,7 @@ public class OLMapManager { // ratio - mapPixelWeight : bboxWeight = 20px : geoRectangleWidth // where 10px is the pixel diameter dimension of the clicked point double bboxWidth = Math.abs(olMap.getExtent().getLowerLeftX() - olMap.getExtent().getUpperRightX()); + double geoWidth = 0; // adding a tolerance in case of manual click if (manualClick) { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java index ddb62c0..2cf916d 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java @@ -1,7 +1,10 @@ package org.gcube.portlets.user.geoportaldataviewer.client.gis; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; +import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION; import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEvent; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem; @@ -9,6 +12,9 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem; import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.Style.Visibility; import com.google.gwt.event.shared.HandlerManager; +import com.google.gwt.json.client.JSONObject; +import com.google.gwt.json.client.JSONParser; +import com.google.gwt.json.client.JSONValue; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Element; import com.google.gwt.user.client.Event; @@ -48,10 +54,10 @@ import ol.source.ImageWms; import ol.source.ImageWmsOptions; import ol.source.ImageWmsParams; import ol.source.Osm; +import ol.source.Source; import ol.source.Vector; import ol.source.XyzOptions; - /** * The Class OpenLayerOSM. * @@ -142,7 +148,7 @@ public abstract class OpenLayerOSM { XyzOptions osmSourceOptions = OLFactory.createOptions(); // osmSourceOptions.setCrossOrigin("Anonymous"); // osmSourceOptions.setTileLoadFunction(null); - + Osm osmSource = new Osm(osmSourceOptions); LayerOptions osmLayerOptions = OLFactory.createOptions(); osmLayerOptions.setSource(osmSource); @@ -335,12 +341,12 @@ public abstract class OpenLayerOSM { LayerOptions layerOptions = OLFactory.createOptions(); layerOptions.setSource(imageWMSSource); - - //Settings MIN and MAX Resolution - if(layerItem.getMinResolution()!=null) { + + // Settings MIN and MAX Resolution + if (layerItem.getMinResolution() != null) { layerOptions.setMinResolution(layerItem.getMinResolution()); } - if(layerItem.getMaxResolution()!=null) { + if (layerItem.getMaxResolution() != null) { layerOptions.setMaxResolution(layerItem.getMaxResolution()); } @@ -349,7 +355,7 @@ public abstract class OpenLayerOSM { // visibleLayerItems map.addLayer(wmsLayer); - GWT.log("Added WMSLayer for layer: "+layerItem.getName()); + GWT.log("Added WMSLayer for layer: " + layerItem.getName()); eventBus.fireEvent(new AddedLayerToMapEvent(layerItem)); } @@ -382,11 +388,11 @@ public abstract class OpenLayerOSM { LayerOptions layerOptions = OLFactory.createOptions(); layerOptions.setSource(imageWMSSource); - //Settings MIN and MAX Resolution - if(layerItem.getMinResolution()!=null) { + // Settings MIN and MAX Resolution + if (layerItem.getMinResolution() != null) { layerOptions.setMinResolution(layerItem.getMinResolution()); } - if(layerItem.getMaxResolution()!=null) { + if (layerItem.getMaxResolution() != null) { layerOptions.setMaxResolution(layerItem.getMaxResolution()); } @@ -397,7 +403,7 @@ public abstract class OpenLayerOSM { map.addLayer(wmsLayer); wmsDetailsLayerMap.put(key, wmsLayer); - GWT.log("Added WMSDetailLayer for layer name: "+layerItem.getName()); + GWT.log("Added WMSDetailLayer for layer name: " + layerItem.getName()); eventBus.fireEvent(new AddedLayerToMapEvent(layerItem)); } else { GWT.log("The detail layer with key: " + key + " already exists, skipping"); @@ -409,22 +415,19 @@ public abstract class OpenLayerOSM { * Removes the all detail layers. */ public void removeAllDetailLayers() { - - //NOT NEEDED ANYMORE.. I'M USING MIN/MAX LAYER RESOLUTION - + + // NOT NEEDED ANYMORE.. I'M USING MIN/MAX LAYER RESOLUTION + /* - if (wmsDetailsLayerMap == null) - return; - - GWT.log("Removing layers: " + wmsDetailsLayerMap.keySet() + " from map"); - - for (String key : wmsDetailsLayerMap.keySet()) { - Image layer = wmsDetailsLayerMap.get(key); - map.removeLayer(layer); - } - - wmsDetailsLayerMap.clear(); - */ + * if (wmsDetailsLayerMap == null) return; + * + * GWT.log("Removing layers: " + wmsDetailsLayerMap.keySet() + " from map"); + * + * for (String key : wmsDetailsLayerMap.keySet()) { Image layer = + * wmsDetailsLayerMap.get(key); map.removeLayer(layer); } + * + * wmsDetailsLayerMap.clear(); + */ } @@ -576,13 +579,12 @@ public abstract class OpenLayerOSM { return false; } - /** * Gets the layer property. * * @param layerName the layer name - * @param property the property + * @param property the property * @return the layer property */ public String getLayerProperty(String layerName, String property) { @@ -620,7 +622,7 @@ public abstract class OpenLayerOSM { public double getCurrentZoomLevel() { return map.getView().getZoom(); } - + /** * Gets the current zoom level. * @@ -696,4 +698,39 @@ public abstract class OpenLayerOSM { return this.map != null; } + /** + * Gets the layers. + * + * @return the layers + */ + public List getLayers() { + Collection layers = map.getLayers(); + List layerNames = null; + if (layers != null) { + Base[] layersArr = layers.getArray(); + layerNames = new ArrayList(layersArr.length); + for (int i = 0; i < layersArr.length; i++) { + Base layer = layersArr[i]; + if (layer instanceof Image) { + Image layerImage = (Image) layer; + + Source source = layerImage.getSource(); +// GWT.log("source: "+source.toString()); + //GeoportalDataViewerConstants.printJsObj(source); + String sorceRootObj = GeoportalDataViewerConstants.toJsonObj(source); + JSONValue jsonObj = JSONParser.parseStrict(sorceRootObj); + // GWT.log("jsonObj: " + jsonObj.toString()); + JSONObject jsonSourceObj = (JSONObject) jsonObj; + + JSONObject jsonParamsObj = (JSONObject) jsonSourceObj.get("params_"); + // GWT.log("jsonParamsObj is: "+jsonParamsObj); + JSONValue jsonLayers = jsonParamsObj.get("LAYERS"); + GWT.log("theLayerName name is: " + jsonLayers); + layerNames.add(jsonLayers.toString()); + } + } + } + return layerNames; + } + } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConcessioneImageUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConcessioneImageUtil.java new file mode 100644 index 0000000..0fefc04 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConcessioneImageUtil.java @@ -0,0 +1,89 @@ +package org.gcube.portlets.user.geoportaldataviewer.server; + +import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.statefulMongoConcessioni; + +import java.util.ArrayList; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; + +import org.gcube.application.geoportal.client.legacy.ConcessioniManagerI; +import org.gcube.application.geoportal.common.model.legacy.Concessione; +import org.gcube.application.geoportal.common.model.legacy.UploadedImage; +import org.gcube.application.geoportalcommon.ConvertToDataViewModel; +import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV; +import org.gcube.portlets.user.geoportaldataviewer.server.util.SessionUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * The Class ConcessioneImageUtil. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Sep 7, 2021 + */ +public class ConcessioneImageUtil { + + private static final Logger LOG = LoggerFactory.getLogger(ConcessioneImageUtil.class); + + /** + * Gets the uploaded images for id. + * + * @param httpServletRequest the http servlet request + * @param itemType the item type + * @param itemId the item id + * @param maxImages the max images + * @return the uploaded images for id + * @throws Exception the exception + */ + public List getUploadedImagesForId(HttpServletRequest httpServletRequest, String itemType, + String itemId, Integer maxImages) throws Exception { + LOG.info("getUploadedImagesForId [itemId: " + itemId + ", itemType: " + itemType + "] called"); + + if (itemType == null) + throw new Exception("Invalid parameter. The itemType is null"); + + if (itemId == null) + throw new Exception("Invalid parameter. The itemId is null"); + + List listUI = null; + + try { + + if (itemType.equalsIgnoreCase("concessione")) { + + LOG.info("Trying to get concessione for id " + itemId); + SessionUtil.getCurrentContext(httpServletRequest, true); + SessionUtil.getCurrentToken(httpServletRequest, true); + ConcessioniManagerI concessioniManager = statefulMongoConcessioni().build(); + Concessione concessione = concessioniManager.getById(itemId); + if (concessione != null) { + LOG.info("For id " + itemId + ", got concessione " + concessione.getNome() + " from service"); + List images = concessione.getImmaginiRappresentative(); + + if (images != null) { + listUI = new ArrayList(); + int max = maxImages < images.size() ? maxImages : images.size(); + for (int i = 0; i < max; i++) { + UploadedImageDV ui = ConvertToDataViewModel.toUploadedImage(images.get(i)); + listUI.add(ui); + } + LOG.info("For id " + itemId + ", got " + listUI.size() + " image/s"); + } + } else + throw new Exception("Concessione with id '" + itemId + "' not available"); + } + + return listUI; + + } catch (Exception e) { + String erroMsg = UploadedImage.class.getSimpleName() + " not available for " + + Concessione.class.getSimpleName() + " with id " + itemId; + LOG.error(erroMsg, e); + throw new Exception(erroMsg); + } + + } + +} 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 83b63de..ee5178e 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 @@ -3,6 +3,7 @@ package org.gcube.portlets.user.geoportaldataviewer.server; import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.statefulMongoConcessioni; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; @@ -11,7 +12,6 @@ import java.util.Map; import org.gcube.application.geoportal.client.legacy.ConcessioniManagerI; import org.gcube.application.geoportal.common.model.legacy.Concessione; import org.gcube.application.geoportal.common.model.legacy.LayerConcessione; -import org.gcube.application.geoportal.common.model.legacy.UploadedImage; import org.gcube.application.geoportalcommon.ConvertToDataViewModel; import org.gcube.application.geoportalcommon.GeoNaDataViewerProfileReader; import org.gcube.application.geoportalcommon.GeoportalCommon; @@ -147,9 +147,10 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme if (concessioneIds != null && concessioneIds.size() > 0) { String cId = concessioneIds.get(0); try { - List listUI = getUploadedImagesForId("Concessione", cId, 1); + UploadedImageDV uplImg = SessionUtil.getPreviewImageForConcessione(this.getThreadLocalRequest(), "Concessione", cId); + //List listUI = getUploadedImagesForId("Concessione", cId, 1); Map> mapImages = new LinkedHashMap>(); - mapImages.put(cId, listUI); + mapImages.put(cId, Arrays.asList(uplImg)); geoDAO.setMapImages(mapImages); } catch (Exception e) { LOG.warn("Error on loading uploaded images for concessione: " + cId, e); @@ -176,55 +177,12 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme * @throws Exception the exception */ @Override - public List getUploadedImagesForId(String itemType, String itemId, int maxImages) + public List getUploadedImagesForId(String itemType, String itemId, Integer maxImages) throws Exception { LOG.info("getUploadedImagesForId [itemId: " + itemId + ", itemType: " + itemType + "] called"); - if (itemType == null) - throw new Exception("Invalid parameter. The itemType is null"); - - if (itemId == null) - throw new Exception("Invalid parameter. The itemId is null"); - - List listUI = null; - - try { - - SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); - - if (itemType.equalsIgnoreCase("concessione")) { - - LOG.info("Trying to get concessione for id " + itemId); - SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); - SessionUtil.getCurrentToken(this.getThreadLocalRequest(), true); - ConcessioniManagerI concessioniManager = statefulMongoConcessioni().build(); - Concessione concessione = concessioniManager.getById(itemId); - if (concessione != null) { - LOG.info("For id " + itemId + ", got concessione " + concessione.getNome() + " from service"); - List images = concessione.getImmaginiRappresentative(); - - if (images != null) { - listUI = new ArrayList(); - int max = maxImages < images.size() ? maxImages : images.size(); - for (int i = 0; i < max; i++) { - UploadedImageDV ui = ConvertToDataViewModel.toUploadedImage(images.get(i)); - listUI.add(ui); - } - LOG.info("For id " + itemId + ", got " + listUI.size() + " image/s"); - } - } else - throw new Exception("Concessione with id '" + itemId + "' not available"); - } - - return listUI; - - } catch (Exception e) { - String erroMsg = UploadedImage.class.getSimpleName() + " not available for " - + Concessione.class.getSimpleName() + " with id " + itemId; - LOG.error(erroMsg, e); - throw new Exception(erroMsg); - } - + return new ConcessioneImageUtil().getUploadedImagesForId(this.getThreadLocalRequest(), itemType, itemId, + maxImages); } /** diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/gis/FeatureParser.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/gis/FeatureParser.java index f7f52b8..b398432 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/gis/FeatureParser.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/gis/FeatureParser.java @@ -124,29 +124,18 @@ public class FeatureParser { LOG.debug("Building at index: " + i); try { + String fetaureId = theFeature.getString("id"); + row.setId(fetaureId); JSONObject geometry = theFeature.getJSONObject("geometry"); String typeValue = geometry.getString("type"); - // JSONArray coordinates = geometry.getJSONArray("coordinates"); - // String toCoordinates = coordinates.toString(); -// String x1 = coordinates.get(0).toString(); -// String y1 = coordinates.get(1).toString(); -// LOG.debug("Coordinate x1: "+x1); -// LOG.debug("Coordinate y1: "+y1); -// Double coordX = null; -// Double coordY = null; FeatureGeometry fg = new FeatureGeometry(); fg.setType(typeValue); - // TODO ONLY POINT GEOMETRY + try { JSONArray coordinates = geometry.getJSONArray("coordinates"); String coordinateJSONString = coordinates.toString(); LOG.debug("coordinates are: " + coordinateJSONString); fg.setCoordinatesJSON(coordinates.toString()); -// coordX = Double.parseDouble(x1); -// coordY = Double.parseDouble(y1); -// Coordinate coord = new Coordinate(coordX, coordY); -// fg.setPath(new PointsPath(new Coordinate[] {coord})); - } catch (Exception e) { LOG.warn("Not able to parse the 'coordinates' field: ", e); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/SessionUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/SessionUtil.java index d7c552f..7293449 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/SessionUtil.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/SessionUtil.java @@ -3,12 +3,18 @@ */ package org.gcube.portlets.user.geoportaldataviewer.server.util; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; +import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV; import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.common.portal.PortalContext; import org.gcube.common.scope.api.ScopeProvider; +import org.gcube.portlets.user.geoportaldataviewer.server.ConcessioneImageUtil; import org.gcube.portlets.user.urlshortener.UrlShortener; import org.gcube.vomanagement.usermanagement.GroupManager; import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault; @@ -35,6 +41,8 @@ public class SessionUtil { public static final String URL_SHORTENER_SERVICE = "URL_SHORTENER_SERVICE"; + public static final String CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE = "MAP_IMAGE_PREVIEW_FOR_CONCESSIONE"; + /** * Checks if is into portal. * @@ -168,4 +176,50 @@ public class SessionUtil { return shortener; } + + /** + * Gets the preview image for concessione. It is the first image retrieved from + * mongoService for mongoConcessioneId. Caching it into session + * + * @param httpServletRequest the http servlet request + * @param itemType the item type + * @param mongoConcessioneId the mongo concessione id + * @return the preview image for concessione + */ + public static UploadedImageDV getPreviewImageForConcessione(HttpServletRequest httpServletRequest, String itemType, + String mongoConcessioneId) { + + HttpSession session = httpServletRequest.getSession(); + Map> mapImages = null; + List lUI = null; + try { + mapImages = (LinkedHashMap) session.getAttribute(CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE); + + if (mapImages == null) { + mapImages = new LinkedHashMap>(); + } + + List imagePreviewForConcessione = mapImages.get(mongoConcessioneId); + + if (imagePreviewForConcessione == null || imagePreviewForConcessione.size() == 0) { + LOG.info("Into " + CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE + " object session the mongoConcessioneId " + + mongoConcessioneId + " is empty or null, loading from service and filling it"); + lUI = new ConcessioneImageUtil().getUploadedImagesForId(httpServletRequest, itemType, + mongoConcessioneId, 1); + mapImages.put(mongoConcessioneId, lUI); + } + + lUI = mapImages.get(mongoConcessioneId); + LOG.info("From " + CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE + " object session read image: " + lUI); + session.setAttribute(CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE, mapImages); + + } catch (Exception e) { + LOG.warn("Error occurred when instancing the " + UrlShortener.class.getSimpleName(), e); + } + + if (lUI == null || lUI.isEmpty()) + return null; + + return lUI.get(0); + } } 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 6decadf..6c80e33 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 @@ -24,7 +24,7 @@ public class GeoNaSpatialQueryResult implements Serializable { private static final long serialVersionUID = 3513120677727206958L; private List features; private LayerObject sourceLayerObject; - // Map with couple (mongoId concessione, list of uplaoded Images for the concessione) + // Map with couple (mongoId concessione, list of uploaded Images for the concessione) private Map> mapImages = null; /** 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 de25d4c..9f7f72c 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/LayerObject.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/LayerObject.java @@ -2,13 +2,12 @@ package org.gcube.portlets.user.geoportaldataviewer.shared.gis; import java.io.Serializable; - /** * The Class LayerObject. * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * - * Nov 13, 2020 + * Nov 13, 2020 */ public class LayerObject implements Serializable { @@ -24,7 +23,12 @@ public class LayerObject implements Serializable { * Instantiates a new layer object. */ public LayerObject() { - // TODO Auto-generated constructor stub + } + + public LayerObject(String itemType, LayerItem layerItem) { + super(); + this.itemType = itemType; + this.layerItem = layerItem; } /** diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/wfs/FeatureRow.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/wfs/FeatureRow.java index 0027806..b9d365d 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/wfs/FeatureRow.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/wfs/FeatureRow.java @@ -21,10 +21,12 @@ public class FeatureRow implements Serializable { */ private static final long serialVersionUID = 6254861811998867626L; + private String id; + private Map> mapProperties; private FeatureGeometry geometry; - + private String crsName; public FeatureRow() { @@ -36,6 +38,14 @@ public class FeatureRow implements Serializable { this.setGeometry(geometry); } + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + public Map> getMapProperties() { return mapProperties; } @@ -63,14 +73,16 @@ public class FeatureRow implements Serializable { @Override public String toString() { StringBuilder builder = new StringBuilder(); - builder.append("FeatureRow [mapProperties="); + builder.append("FeatureRow [id="); + builder.append(id); + builder.append(", mapProperties="); builder.append(mapProperties); builder.append(", geometry="); builder.append(geometry); + builder.append(", crsName="); + builder.append(crsName); builder.append("]"); return builder.toString(); } - - } diff --git a/src/main/webapp/GeoportalDataViewer.css b/src/main/webapp/GeoportalDataViewer.css index dba823e..8efa665 100644 --- a/src/main/webapp/GeoportalDataViewer.css +++ b/src/main/webapp/GeoportalDataViewer.css @@ -31,7 +31,7 @@ body { bottom: 12px; left: -50px; min-width: 280px; - max-width: 350px; + max-width: 500px; visibility: hidden; } @@ -94,12 +94,9 @@ body { padding-top: 5px; } - /* #page-view-details .page-header h1 { font-size: 28px; } */ - - #page-view-details p { font-size: 14px; padding: 10px; @@ -198,14 +195,15 @@ body { } .inner-toolbar .btn-link { - border: 1px solid #eee; - background-color: #fcfcfc; - text-align: center; - margin: 1px; + border: 1px solid #eee; + background-color: #fcfcfc; + text-align: center; + margin: 1px; } + .inner-toolbar .btn-link:hover, .inner-toolbar .btn-link:focus { - background-color: #f3f3f3 !important; - text-decoration: none; + background-color: #f3f3f3 !important; + text-decoration: none; } .style-layer { @@ -219,7 +217,7 @@ body { } .style-layer table { - width: 100%; + width: 100%; } .info-interaction { @@ -232,10 +230,7 @@ body { padding-bottom: 5px; } - - /** NanoGallery2 **/ - .nGY2Viewer { background: rgba(4, 4, 4, .8) !important; } @@ -244,7 +239,6 @@ body { background: rgba(4, 4, 4, .8) !important; } - .nGY2 .toolbar .ngbt { font-size: 1em !important; padding: 12px 12px !important; @@ -265,3 +259,20 @@ body { color: #696969 !important; font-family: arial !important; } + +.table-feature { + border: 1px solid #ddd; + text-align: left; + border-collapse: collapse; + width: 100%; +} + +.table-feature td { + border: 1px solid #ddd; + text-align: left; + padding: 5px; +} + +.table-feature tr:first-child { + font-weight: bold; +} \ No newline at end of file -- 2.17.1 From 66d3bd0c0b1df4743fe48b3b728b55f857a7b8fd Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 8 Sep 2021 14:40:36 +0200 Subject: [PATCH 22/38] bug fixing on showing details --- .../client/GeoportalDataViewer.java | 6 +- .../client/LayerManager.java | 65 +++++++--- .../client/OLMapManager.java | 18 +-- .../client/events/QueryDataEvent.java | 27 ++--- .../client/gis/OpenLayerOSM.java | 113 ++++++++++++------ .../GeoportalDataViewerServiceImpl.java | 1 + 6 files changed, 143 insertions(+), 87 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 8236661..8c01391 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 @@ -20,6 +20,7 @@ import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowDetailsEven import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowDetailsEventHandler; import org.gcube.portlets.user.geoportaldataviewer.client.events.ZoomOutOverMinimumEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.ZoomOutOverMinimumEventHandler; +import org.gcube.portlets.user.geoportaldataviewer.client.gis.ExtentWrapped; import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils; import org.gcube.portlets.user.geoportaldataviewer.client.ui.GeonaDataViewMainPanel; import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil; @@ -315,7 +316,7 @@ public class GeoportalDataViewer implements EntryPoint { if (mainPanel.getDisplyedRecord() == null && !olMapMng.isQueryPointActive()) { olMapMng.hidePopInfo(); - olMapMng.removeDetailLayers(); + layerManager.removeAllDetailLayers(); } } @@ -357,7 +358,8 @@ public class GeoportalDataViewer implements EntryPoint { GeoQuery select = olMapMng.toDataPointQuery(transfCoord, false); GWT.log("GeoQuery: " + select); // GeoportalDataViewerConstants.print("fireEvent QueryDataEvent"); - layerManager.getLayerManagerBus().fireEvent(new QueryDataEvent(select, transfCoord, + ExtentWrapped toExt = new ExtentWrapped(transfCoord.getX(), transfCoord.getY(), transfCoord.getX(), transfCoord.getY()); + layerManager.getLayerManagerBus().fireEvent(new QueryDataEvent(select, toExt, record.getItemId(), true, MapEventType.ADDED_LAYER_TO_MAP)); } else { GeoportalDataViewerConstants.printJs( 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 5b93a9b..3bc96e0 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 @@ -77,7 +77,8 @@ public class LayerManager { /** The ol map. */ private OpenLayerOSM olMap; - private Map layerObjects = new HashMap(); + private Map mapDetailLayerObjects = new HashMap(); + private Map mapBaseLayerObjects = new HashMap(); private HandlerManager layerManagerBus = new HandlerManager(""); @@ -153,7 +154,15 @@ public class LayerManager { // GWT.log("Layer found: "+layerName); // } - List listLO = new ArrayList(layerObjects.values()); + List listLO = new ArrayList(); + //for querying base layers + listLO.addAll(mapBaseLayerObjects.values()); + + //for querying detail layers only in this case + if(olMap.getCurrentResolution()>() { @@ -224,7 +233,7 @@ public class LayerManager { //Here I need to pass only the visible layers showPopupInfoForLayer(listGeonaDataObjects, - queryEvent.getOnFailureCenterTo()); + queryEvent.getQueryClickExtent()); } return; } @@ -239,8 +248,11 @@ public class LayerManager { GWT.log("the product id is: " + theProductId); // Displaying popup info for centroid layer - showPopupInfoForCentroidLayer(geoNaDataObject, feature, - queryEvent.getOnFailureCenterTo()); + if (queryEvent.getSourceMapEventType() + .equals(MapEventType.MOUSE_CLICK)){ + showPopupInfoForCentroidLayer(geoNaDataObject, feature, + queryEvent.getQueryClickExtent().getCenter()); + } // retrieving and showing WMS layers of a concessione if the ZOOM level is > // QUERY_MIN_ZOOM_LEVEL @@ -271,7 +283,7 @@ public class LayerManager { } else { // removing all WMS detail layers if the ZOOM level is < // QUERY_MIN_ZOOM_LEVEL - olMap.removeAllDetailLayers(); + removeAllDetailLayers(); } } } @@ -295,11 +307,16 @@ public class LayerManager { @Override public void onZoomOut(ZoomOutOverMinimumEvent zoomOutEvent) { GWT.log("Fired into layerManagerBus " + zoomOutEvent); - olMap.removeAllDetailLayers(); + removeAllDetailLayers(); applicationBus.fireEvent(zoomOutEvent); } }); } + + public void removeAllDetailLayers() { + mapDetailLayerObjects.clear(); + olMap.removeAllDetailLayers(); + } /** * Parses the geona references. @@ -384,21 +401,31 @@ public class LayerManager { displayInLayerSwitcher, (ArrayList) geoInfoWMS.getStyles().getGeoStyles(), geoInfoWMS.getWmsRequest(), false, geoInfoWMS.getMapWMSNoStandard(), geoInfoWMS.isNcWMS(), UUID, geoInfoWMS.getZAxis(), minResolution, maxResolution); + LayerObject lo = new LayerObject(); lo.setLayerItem(layerItem); lo.setItemType(geonaItemType); - String key = layerItem.getMapServerHost() + "/layer/" + layerItem.getName(); - - // if a detail layer checking if it is already added to map - if (asDetailLayer && layerObjects.containsKey(key)) { - GWT.log("Skipping layer " + key + " already added to Map"); - } else { - layerObjects.put(key, lo); - if (!asDetailLayer) + String key = layerItem.getName(); //should be unique + //layerObjects.put(key, lo); + + if(!asDetailLayer) { + //is a base layer + LayerObject blo = mapBaseLayerObjects.get(key); + if(blo==null) { olMap.addWMSLayer(layerItem); - else + 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); + }else { + GWT.log("Skipping detail layer " + key + " already added to Map"); + } } } }); @@ -496,7 +523,7 @@ public class LayerManager { * @param onFailureCenterTo the on failure center to */ public void showPopupInfoForLayer(List listGeoNaDataObject, - Coordinate onFailureCenterTo) { + ExtentWrapped queryClick) { ScrollPanel scrollPanel = new ScrollPanel(); VerticalPanel vpPanel = new VerticalPanel(); @@ -534,7 +561,7 @@ public class LayerManager { } for (FeatureRow feature : features) { - + FlexTable intFlex = new FlexTable(); intFlex.setCellPadding(1); intFlex.setCellSpacing(1); @@ -569,7 +596,7 @@ public class LayerManager { } - olMap.showPopup(scrollPanel.toString(), onFailureCenterTo); + olMap.showPopup(scrollPanel.toString(), queryClick.getCenter()); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java index 12908fd..d5f00de 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java @@ -72,8 +72,9 @@ public class OLMapManager { // // } + ExtentWrapped toExt = new ExtentWrapped(coordinate.getX(), coordinate.getY(), coordinate.getX(), coordinate.getY()); GeoQuery select = toDataPointQuery(coordinate, true); - layerManagerBus.fireEvent(new QueryDataEvent(select, coordinate, null, true, MapEventType.MOUSE_CLICK)); + layerManagerBus.fireEvent(new QueryDataEvent(select, toExt, null, true, MapEventType.MOUSE_CLICK)); } @@ -203,7 +204,8 @@ public class OLMapManager { GWT.log("the distance is: " + dist); if (dist > 5000 || startExt.containsExtent(endExt)) { GeoQuery select = toDataBoxQuery(dragEndExtent); - layerManagerBus.fireEvent(new QueryDataEvent(select, endExt.getCenter(), null, false, mapEventType)); + //TODO THE AUTOMATICALLY SHOWING POP-UP ACCORDING TO ZOOM IS BUGGY + layerManagerBus.fireEvent(new QueryDataEvent(select, endExt, null, false, mapEventType)); } } else if (zoomStart != null && zoomEnd != null) { @@ -252,11 +254,11 @@ public class OLMapManager { olMap.hidePopup(); } - /** - * Removes the detail layers. - */ - public void removeDetailLayers() { - olMap.removeAllDetailLayers(); - } +// /** +// * Removes the detail layers. +// */ +// public void removeDetailLayers() { +// olMap.removeAllDetailLayers(); +// } } 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 4d3f7b7..fdfca9b 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 @@ -1,12 +1,11 @@ package org.gcube.portlets.user.geoportaldataviewer.client.events; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MapEventType; +import org.gcube.portlets.user.geoportaldataviewer.client.gis.ExtentWrapped; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery; import com.google.gwt.event.shared.GwtEvent; -import ol.Coordinate; - /** * The Class QueryDataEvent. * @@ -17,7 +16,7 @@ import ol.Coordinate; public class QueryDataEvent extends GwtEvent { public static Type TYPE = new Type(); private GeoQuery select; - private Coordinate onFailureCenterTo; + private ExtentWrapped queryClickExtent; private String mongoItemId; private boolean onInit; private MapEventType sourceMapEventType; @@ -31,10 +30,10 @@ public class QueryDataEvent extends GwtEvent { * @param onInit the on init * @param mapEventType the map event type */ - public QueryDataEvent(GeoQuery select, Coordinate onFailureCenterTo, String mongoItemId, boolean onInit, + public QueryDataEvent(GeoQuery select, ExtentWrapped queryClickExtent, String mongoItemId, boolean onInit, MapEventType mapEventType) { this.select = select; - this.onFailureCenterTo = onFailureCenterTo; + this.queryClickExtent = queryClickExtent; this.mongoItemId = mongoItemId; this.onInit = onInit; this.sourceMapEventType = mapEventType; @@ -88,13 +87,8 @@ public class QueryDataEvent extends GwtEvent { return select; } - /** - * Gets the on failure center to. - * - * @return the on failure center to - */ - public Coordinate getOnFailureCenterTo() { - return onFailureCenterTo; + public ExtentWrapped getQueryClickExtent() { + return queryClickExtent; } /** @@ -106,18 +100,13 @@ public class QueryDataEvent extends GwtEvent { return sourceMapEventType; } - /** - * To string. - * - * @return the string - */ @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append("QueryDataEvent [select="); builder.append(select); - builder.append(", onFailureCenterTo="); - builder.append(onFailureCenterTo); + builder.append(", queryClickExtent="); + builder.append(queryClickExtent); builder.append(", mongoItemId="); builder.append(mongoItemId); builder.append(", onInit="); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java index 2cf916d..ccd6759 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java @@ -58,6 +58,7 @@ import ol.source.Source; import ol.source.Vector; import ol.source.XyzOptions; +// TODO: Auto-generated Javadoc /** * The Class OpenLayerOSM. * @@ -130,6 +131,8 @@ public abstract class OpenLayerOSM { private java.util.Map wmsDetailsLayerMap; + private HashMap wmsLayerMap; + /** * Instantiates a new open layer OSM. * @@ -329,34 +332,46 @@ public abstract class OpenLayerOSM { */ public void addWMSLayer(LayerItem layerItem) { - ImageWmsParams imageWMSParams = OLFactory.createOptions(); - imageWMSParams.setLayers(layerItem.getName()); + if (wmsLayerMap == null) + wmsLayerMap = new HashMap(); - ImageWmsOptions imageWMSOptions = OLFactory.createOptions(); - imageWMSOptions.setUrl(layerItem.getMapServerHost()); - imageWMSOptions.setParams(imageWMSParams); - // imageWMSOptions.setRatio(1.5f); + String key = layerItem.getName(); - ImageWms imageWMSSource = new ImageWms(imageWMSOptions); + Image layer = wmsLayerMap.get(key); + if (layer == null) { + ImageWmsParams imageWMSParams = OLFactory.createOptions(); + imageWMSParams.setLayers(layerItem.getName()); - LayerOptions layerOptions = OLFactory.createOptions(); - layerOptions.setSource(imageWMSSource); + ImageWmsOptions imageWMSOptions = OLFactory.createOptions(); + imageWMSOptions.setUrl(layerItem.getMapServerHost()); + imageWMSOptions.setParams(imageWMSParams); + // imageWMSOptions.setRatio(1.5f); - // Settings MIN and MAX Resolution - if (layerItem.getMinResolution() != null) { - layerOptions.setMinResolution(layerItem.getMinResolution()); + ImageWms imageWMSSource = new ImageWms(imageWMSOptions); + + LayerOptions layerOptions = OLFactory.createOptions(); + layerOptions.setSource(imageWMSSource); + + // Settings MIN and MAX Resolution + if (layerItem.getMinResolution() != null) { + layerOptions.setMinResolution(layerItem.getMinResolution()); + } + if (layerItem.getMaxResolution() != null) { + layerOptions.setMaxResolution(layerItem.getMaxResolution()); + } + + Image wmsLayer = new Image(layerOptions); + + // visibleLayerItems + + map.addLayer(wmsLayer); + wmsLayerMap.put(key, wmsLayer); + + GWT.log("Added WMSLayer for layer: " + layerItem.getName()); + eventBus.fireEvent(new AddedLayerToMapEvent(layerItem)); + } else { + GWT.log("The WMS layer with key: " + key + " already exists, skipping"); } - if (layerItem.getMaxResolution() != null) { - layerOptions.setMaxResolution(layerItem.getMaxResolution()); - } - - Image wmsLayer = new Image(layerOptions); - - // visibleLayerItems - - map.addLayer(wmsLayer); - GWT.log("Added WMSLayer for layer: " + layerItem.getName()); - eventBus.fireEvent(new AddedLayerToMapEvent(layerItem)); } @@ -370,7 +385,7 @@ public abstract class OpenLayerOSM { if (wmsDetailsLayerMap == null) wmsDetailsLayerMap = new HashMap(); - String key = layerItem.getMapServerHost() + "/layer/" + layerItem.getName(); + String key = layerItem.getName(); Image layer = wmsDetailsLayerMap.get(key); @@ -406,7 +421,7 @@ public abstract class OpenLayerOSM { GWT.log("Added WMSDetailLayer for layer name: " + layerItem.getName()); eventBus.fireEvent(new AddedLayerToMapEvent(layerItem)); } else { - GWT.log("The detail layer with key: " + key + " already exists, skipping"); + GWT.log("The WMS detail layer with key: " + key + " already exists, skipping"); } } @@ -418,16 +433,17 @@ public abstract class OpenLayerOSM { // NOT NEEDED ANYMORE.. I'M USING MIN/MAX LAYER RESOLUTION - /* - * if (wmsDetailsLayerMap == null) return; - * - * GWT.log("Removing layers: " + wmsDetailsLayerMap.keySet() + " from map"); - * - * for (String key : wmsDetailsLayerMap.keySet()) { Image layer = - * wmsDetailsLayerMap.get(key); map.removeLayer(layer); } - * - * wmsDetailsLayerMap.clear(); - */ + if (wmsDetailsLayerMap == null) + return; + + GWT.log("Removing layers: " + wmsDetailsLayerMap.keySet() + " from map"); + + for (String key : wmsDetailsLayerMap.keySet()) { + Image layer = wmsDetailsLayerMap.get(key); + map.removeLayer(layer); + } + + wmsDetailsLayerMap.clear(); } @@ -698,12 +714,13 @@ public abstract class OpenLayerOSM { return this.map != null; } + /** - * Gets the layers. + * Gets the layers from map. * - * @return the layers + * @return the layers from map */ - public List getLayers() { + public List getLayersFromMap() { Collection layers = map.getLayers(); List layerNames = null; if (layers != null) { @@ -716,7 +733,7 @@ public abstract class OpenLayerOSM { Source source = layerImage.getSource(); // GWT.log("source: "+source.toString()); - //GeoportalDataViewerConstants.printJsObj(source); + // GeoportalDataViewerConstants.printJsObj(source); String sorceRootObj = GeoportalDataViewerConstants.toJsonObj(source); JSONValue jsonObj = JSONParser.parseStrict(sorceRootObj); // GWT.log("jsonObj: " + jsonObj.toString()); @@ -733,4 +750,22 @@ public abstract class OpenLayerOSM { return layerNames; } + /** + * Gets the wms details layer map. + * + * @return the wms details layer map + */ + public java.util.Map getWmsDetailsLayerMap() { + return wmsDetailsLayerMap; + } + + /** + * Gets the wms layer map. + * + * @return the wms layer map + */ + public HashMap getWmsLayerMap() { + return wmsLayerMap; + } + } 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 ee5178e..4d57181 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 @@ -151,6 +151,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme //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); -- 2.17.1 From 035b71be37df71243d4b167eb1f1b02d1d6c9669 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 8 Sep 2021 15:59:29 +0200 Subject: [PATCH 23/38] working on #21976 --- CHANGELOG.md | 1 + README.md | 2 +- .../client/LayerManager.java | 8 -- .../GeoportalDataViewerServiceImpl.java | 76 +++++++++++++++- .../server/util/CheckAccessUtil.java | 87 +++++++++++++++++++ 5 files changed, 161 insertions(+), 13 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/CheckAccessUtil.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c5f138..1c56088 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm [#21890] Porting to ConcessioniManagerI and pass to mongoID [#20595] Porting and using the model view provided by geoportal-common [#21946] Show layers of a concessione automatically on map according to zoom level +[#21976] Access policies checked on server-side ## [v1.2.0-SNAPSHOT] - 2021-07-19 diff --git a/README.md b/README.md index 847a6d1..9012d74 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ The GeoPortal Data Viewer App is an application to access, discovery and navigat * [OpenJDK](https://openjdk.java.net/) - The JDK used * [Maven](https://maven.apache.org/) - Dependency Management -** Uses ** +**Uses** * [GWT-OL3](https://github.com/TDesjardins/gwt-ol) GWT-OpenLayers 3+ v.8.0.0-gwt2_9 * [OpenLayers](https://openlayers.org/) OpenLayers v.6.X 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 3bc96e0..dbcd4e3 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 @@ -145,14 +145,6 @@ public class LayerManager { GWT.log("MAX_WFS_FEATURES is: " + GeoportalDataViewerConstants.MAX_WFS_FEATURES); // GeoportalDataViewerConstants.print("calling getDataResult"); -// List mapLayers = olMap.getLayers(); -//// List listLO = new ArrayList(mapLayers.size()); -// for (String layerName : mapLayers) { -//// LayerItem layerItem = new LayerItem(); -//// layerItem.setName(layerName); -//// listLO.add(new LayerObject("Concessione",layerItem)); -// GWT.log("Layer found: "+layerName); -// } List listLO = new ArrayList(); //for querying base layers 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 4d57181..7403483 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 @@ -20,12 +20,17 @@ import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.LayerItem; import org.gcube.application.geoportalcommon.shared.gis.BoundsMap; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; +import org.gcube.application.geoportalcommon.shared.products.model.AbstractRelazioneScavoDV; import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV; +import org.gcube.application.geoportalcommon.shared.products.model.RelazioneScavoDV; import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV; import org.gcube.application.geoportalcommon.util.URLParserUtil; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerService; +import org.gcube.portlets.user.geoportaldataviewer.client.ui.gallery.ImagesGallery; +import org.gcube.portlets.user.geoportaldataviewer.client.ui.products.concessioni.RelazioneScavoView; import org.gcube.portlets.user.geoportaldataviewer.server.gis.FeatureParser; import org.gcube.portlets.user.geoportaldataviewer.server.gis.WMSUrlValidator; +import org.gcube.portlets.user.geoportaldataviewer.server.util.CheckAccessUtil; import org.gcube.portlets.user.geoportaldataviewer.server.util.SessionUtil; import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject; @@ -147,11 +152,12 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme if (concessioneIds != null && concessioneIds.size() > 0) { String cId = concessioneIds.get(0); try { - UploadedImageDV uplImg = SessionUtil.getPreviewImageForConcessione(this.getThreadLocalRequest(), "Concessione", cId); - //List listUI = getUploadedImagesForId("Concessione", cId, 1); + UploadedImageDV uplImg = SessionUtil + .getPreviewImageForConcessione(this.getThreadLocalRequest(), "Concessione", cId); + // List listUI = getUploadedImagesForId("Concessione", cId, 1); Map> mapImages = new LinkedHashMap>(); mapImages.put(cId, Arrays.asList(uplImg)); - //mapImages.put(cId, listUI); + // mapImages.put(cId, listUI); geoDAO.setMapImages(mapImages); } catch (Exception e) { LOG.warn("Error on loading uploaded images for concessione: " + cId, e); @@ -271,9 +277,71 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme // Obtain the client ConcessioniManagerI manager = statefulMongoConcessioni().build(); Concessione concessione = manager.getById(mongoId); - LOG.info("Got concessione for mongoId " + mongoId); + LOG.info("Got concessione for mongoId: " + mongoId); if (concessione != null) { concessionDV = ConvertToDataViewModel.toConcessione(concessione); + + GCubeUser user = SessionUtil.getCurrentUser(this.getThreadLocalRequest()); + String userName = user == null ? null : user.getUsername(); + + //TODO THIS IS A WORKAROUND WAITING FOR USER ROLE. + //I CAN CHECK THE ACCCESS POLICIES ONLY IF THE USER IS NOT LOGGED IN. + if (user != null) { + + // CHECKING ACCESS POLICY + LOG.info("Applying access policies for concessione " + mongoId + " returned by service"); + LayerConcessioneDV layerPosizionamento = concessionDV.getPosizionamentoScavo(); + if (layerPosizionamento != null) { + if (!CheckAccessUtil.isAccessible(layerPosizionamento.getPolicy(), userName)) { + concessionDV.setPosizionamentoScavo(null); + } + } + + List listLayersDV = concessionDV.getPianteFineScavo(); + if (listLayersDV != null) { + List accessibleListLayersDV = new ArrayList(); + for (LayerConcessioneDV layerDV : listLayersDV) { + if (CheckAccessUtil.isAccessible(layerDV.getPolicy(), userName)) { + accessibleListLayersDV.add(layerDV); + } + } + concessionDV.setPianteFineScavo(accessibleListLayersDV); + } + + AbstractRelazioneScavoDV abstractRS = concessionDV.getAbstractRelazioneScavo(); + if (abstractRS != null) { + if (!CheckAccessUtil.isAccessible(abstractRS.getPolicy(), userName)) { + concessionDV.setAbstractRelazioneScavo(null); + } + } + + RelazioneScavoDV relazioneScavo = concessionDV.getRelazioneScavo(); + if (relazioneScavo != null) { + if (!CheckAccessUtil.isAccessible(relazioneScavo.getPolicy(), userName)) { + concessionDV.setRelazioneScavo(null); + } + } + + List immagini = concessionDV.getImmaginiRappresentative(); + if (immagini != null && immagini.size() > 0) { + List accessibleListImages = new ArrayList(); + + // SHOWING ACESSIBLE IMAGES + for (UploadedImageDV uploadedImageDV : immagini) { + + if (CheckAccessUtil.isAccessible(uploadedImageDV.getPolicy(), userName)) { + accessibleListImages.add(uploadedImageDV); + } + + } + concessionDV.setImmaginiRappresentative(accessibleListImages); + + } + + // END CHECKING ACCESS POLICY + LOG.info("Access policies applied"); + } + } if (concessionDV == null) diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/CheckAccessUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/CheckAccessUtil.java new file mode 100644 index 0000000..545528c --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/CheckAccessUtil.java @@ -0,0 +1,87 @@ +package org.gcube.portlets.user.geoportaldataviewer.server.util; + +/** + * The Class CheckAccessUtil. + * + * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) + * + * Sep 8, 2021 + */ +public class CheckAccessUtil { + + /** + * The Enum ACCESS_POLICY. + * + * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) + * + * Sep 8, 2021 + */ + public static enum ACCESS_POLICY { + OPEN, RESTICTED + } + + /** + * Checks if is open access. + * + * @param policy the policy + * @return true, if is open access + */ + private static boolean isOpenAccess(String policy) { + if (policy == null || policy.equalsIgnoreCase(ACCESS_POLICY.OPEN.name())) { + return true; + } + + return false; + + } + + /** + * Checks if is restricted access. + * + * @param policy the policy + * @return true, if is restricted access + */ + private static boolean isRestrictedAccess(String policy) { + if (policy == null || policy.equalsIgnoreCase(ACCESS_POLICY.RESTICTED.name())) { + return true; + } + + return false; + + } + + /** + * Checks if is accessible. + * + * @param policy the policy + * @param myLogin the my login + * @return true, if is accessible + */ + public static boolean isAccessible(String policy, String myLogin) { + + boolean bool = isOpenAccess(policy); + + if (bool) { + // is open access + return true; + } + + if (myLogin == null || myLogin.isEmpty()) { + // is not open and the user is not authenticated + return false; + } + + // Here the login is not null, so checking if the access to item is RESTICTED + bool = isRestrictedAccess(policy); + + if (bool) { + // is restricted access + return true; + } + + // Here the user is authenticated, but the policy is not managed, so returning + // true + return true; + } + +} -- 2.17.1 From 3d003a742904a2d0348e79bdd8423007214eb987 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 8 Sep 2021 16:15:36 +0200 Subject: [PATCH 24/38] increasing max zoom level and min resolution --- .../user/geoportaldataviewer/client/OLMapManager.java | 2 +- .../geoportaldataviewer/client/gis/LightOpenLayerOSM.java | 2 ++ .../user/geoportaldataviewer/client/gis/OpenLayerOSM.java | 4 +++- .../server/GeoportalDataViewerServiceImpl.java | 2 -- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java index d5f00de..33540d6 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java @@ -37,7 +37,7 @@ public class OLMapManager { private Double zoomEnd = null; private ol.Extent dragEndExtent = null; public static final int QUERY_MIN_ZOOM_LEVEL = 13; - public static final Double LAYER_DETAIL_MIN_RESOLUTION = 0.10; + public static final Double LAYER_DETAIL_MIN_RESOLUTION = 0.01; public static final Double LAYER_DETAIL_MAX_RESOLUTION = 13.0; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerOSM.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerOSM.java index 4c662dd..73615d7 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerOSM.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerOSM.java @@ -59,6 +59,8 @@ import ol.style.TextOptions; * Nov 11, 2020 */ public class LightOpenLayerOSM { + + public static final int MAX_ZOOM = 20; /** The map. */ private Map map; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java index ccd6759..0232c01 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java @@ -68,6 +68,8 @@ import ol.source.XyzOptions; */ public abstract class OpenLayerOSM { + public static final int MAX_ZOOM = 21; + /** * Click listener. * @@ -163,7 +165,7 @@ public abstract class OpenLayerOSM { Projection projection = new Projection(projectionOptions); viewOptions.setProjection(projection); - viewOptions.setMaxZoom(19); + viewOptions.setMaxZoom(MAX_ZOOM); // create a view view = new View(viewOptions); 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 7403483..d14ebbb 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 @@ -26,8 +26,6 @@ import org.gcube.application.geoportalcommon.shared.products.model.RelazioneScav import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV; import org.gcube.application.geoportalcommon.util.URLParserUtil; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerService; -import org.gcube.portlets.user.geoportaldataviewer.client.ui.gallery.ImagesGallery; -import org.gcube.portlets.user.geoportaldataviewer.client.ui.products.concessioni.RelazioneScavoView; import org.gcube.portlets.user.geoportaldataviewer.server.gis.FeatureParser; import org.gcube.portlets.user.geoportaldataviewer.server.gis.WMSUrlValidator; import org.gcube.portlets.user.geoportaldataviewer.server.util.CheckAccessUtil; -- 2.17.1 From 35c5ede770cd7743f12cb14aa7e642dfe7c460a7 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 8 Sep 2021 17:13:59 +0200 Subject: [PATCH 25/38] bug fixing and improvements --- .../geoportaldataviewer/client/GeoportalDataViewer.java | 4 ++-- .../client/GeoportalDataViewerConstants.java | 2 +- .../user/geoportaldataviewer/client/LayerManager.java | 8 +++++--- .../user/geoportaldataviewer/client/OLMapManager.java | 3 ++- .../server/GeoportalDataViewerServiceImpl.java | 4 ++-- 5 files changed, 12 insertions(+), 9 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 8c01391..a5a31d3 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 @@ -284,7 +284,7 @@ public class GeoportalDataViewer implements EntryPoint { @Override public void run() { attempt++; - GWT.log("waiting got record tenative: " + attempt); + GWT.log("waiting get record: " + attempt); RecordDV record = mainPanel.getDisplyedRecord(); if (record != null) { this.cancel(); @@ -360,7 +360,7 @@ public class GeoportalDataViewer implements EntryPoint { // GeoportalDataViewerConstants.print("fireEvent QueryDataEvent"); ExtentWrapped toExt = new ExtentWrapped(transfCoord.getX(), transfCoord.getY(), transfCoord.getX(), transfCoord.getY()); layerManager.getLayerManagerBus().fireEvent(new QueryDataEvent(select, toExt, - record.getItemId(), true, MapEventType.ADDED_LAYER_TO_MAP)); + record.getItemId(), true, MapEventType.ADDED_CENTROID_LAYER_TO_MAP)); } else { GeoportalDataViewerConstants.printJs( "I cannot select the point one or both coordiantes are null. X: " + x + ", Y:" + y); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java index 6e0d9e1..c0b87b4 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java @@ -26,7 +26,7 @@ public class GeoportalDataViewerConstants { public static final String GET_CENTER_MAP_TO_LONG_LAT = OpenLayersMapParameters.OL_MAP_PARAM.centermap.name(); public static enum MapEventType { - MOUSE_CLICK, MAP_ZOOM_END, MOVE_END, ADDED_LAYER_TO_MAP + MOUSE_CLICK, MAP_ZOOM_END, MOVE_END, ADDED_CENTROID_LAYER_TO_MAP } /** 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 dbcd4e3..7dc30c6 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 @@ -177,6 +177,8 @@ public class LayerManager { return; FeatureRow feature = null; + + MapEventType sourceEvent = queryEvent.getSourceMapEventType(); // TODO SWTCH FOR EARCH ITEM TYPE for (GeoNaSpatialQueryResult geoNaDataObject : listGeonaDataObjects) { @@ -219,7 +221,7 @@ public class LayerManager { // to a record/concessione (not centroid layer), // so calling show popuup info on detail layers if the // following events are true. - if (queryEvent.getSourceMapEventType() + if (sourceEvent .equals(MapEventType.MOUSE_CLICK) && olMap.getCurrentZoomLevel() > OLMapManager.QUERY_MIN_ZOOM_LEVEL) { @@ -240,8 +242,8 @@ public class LayerManager { GWT.log("the product id is: " + theProductId); // Displaying popup info for centroid layer - if (queryEvent.getSourceMapEventType() - .equals(MapEventType.MOUSE_CLICK)){ + if (sourceEvent + .equals(MapEventType.MOUSE_CLICK) || sourceEvent.equals(MapEventType.ADDED_CENTROID_LAYER_TO_MAP)){ showPopupInfoForCentroidLayer(geoNaDataObject, feature, queryEvent.getQueryClickExtent().getCenter()); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java index 33540d6..6914a0a 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java @@ -158,7 +158,8 @@ public class OLMapManager { // adding a tolerance in case of manual click if (manualClick) { // adding a tolerance for clicking - geoWidth = (bboxWidth / w) * (14 / 2); + //geoWidth = (bboxWidth / w) * (14 / 2); + geoWidth = (bboxWidth / w) * (16 / 2); } else { // data point selection for coordinate loaded from concessione geoWidth = (bboxWidth / w) * (2); 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 d14ebbb..b245a53 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 @@ -283,8 +283,8 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme String userName = user == null ? null : user.getUsername(); //TODO THIS IS A WORKAROUND WAITING FOR USER ROLE. - //I CAN CHECK THE ACCCESS POLICIES ONLY IF THE USER IS NOT LOGGED IN. - if (user != null) { + //I CAN CHECK THE ACCCESS POLICIES IF AND ONLY IF THE USER IS NOT LOGGED IN. + if (user == null) { // CHECKING ACCESS POLICY LOG.info("Applying access policies for concessione " + mongoId + " returned by service"); -- 2.17.1 From b6af6ad299063545f9c35936c3e41544084b3f7e Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 9 Sep 2021 11:38:25 +0200 Subject: [PATCH 26/38] added refersTo BaseConcessione --- .../client/GeoportalDataViewer.java | 2 +- .../client/LayerManager.java | 31 +++++-- .../products/concessioni/ConcessioneView.java | 92 +++++++++++-------- .../concessioni/RelazioneScavoView.java | 32 ++++--- .../GeoportalDataViewerServiceImpl.java | 11 ++- .../shared/gis/LayerObject.java | 58 +++++++++--- src/main/webapp/GeoportalDataViewer.css | 1 + 7 files changed, 152 insertions(+), 75 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 a5a31d3..66f4cf2 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 @@ -175,7 +175,7 @@ public class GeoportalDataViewer implements EntryPoint { layerItem.setName(layerName); layerManager.setBaseLayerFromIsProfile(layerItem); layerManager.addLayer(theItemType, null, null, layerItem.getWmsLink(), false, false, - null, false, null, null); + null, false, null, null,null); if (paramGeonaItemID != null) { if (paramGeonaItemType == null) { 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 7dc30c6..5a5e2e6 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 @@ -9,6 +9,7 @@ import java.util.List; import java.util.Map; import org.gcube.application.geoportalcommon.shared.gis.BoundsMap; +import org.gcube.application.geoportalcommon.shared.products.BaseConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceContentDV; import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV; @@ -36,6 +37,7 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformation import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.ZAxis; import com.github.gwtbootstrap.client.ui.Button; +import com.github.gwtbootstrap.client.ui.Heading; import com.github.gwtbootstrap.client.ui.Label; import com.github.gwtbootstrap.client.ui.constants.ButtonType; import com.github.gwtbootstrap.client.ui.constants.LabelType; @@ -269,7 +271,7 @@ public class LayerManager { layer.getLayerName(), layer.getWmsLink(), false, false, layer.getLayerUUID(), true, OLMapManager.LAYER_DETAIL_MIN_RESOLUTION, - OLMapManager.LAYER_DETAIL_MAX_RESOLUTION); + OLMapManager.LAYER_DETAIL_MAX_RESOLUTION,layer.getRefersTo()); } } @@ -351,10 +353,11 @@ public class LayerManager { * @param asDetailLayer the as detail layer * @param minResolution the min resolution * @param maxResolution the max resolution + * @param refersToBaseConcessione the refers to base concessione */ public void addLayer(final String geonaItemType, final String layerTitle, final String layerName, final String wmsLink, final boolean isBase, final boolean displayInLayerSwitcher, final String UUID, - final boolean asDetailLayer, Double minResolution, Double maxResolution) { + final boolean asDetailLayer, Double minResolution, Double maxResolution, BaseConcessioneDV refersToBaseConcessione) { // final LayoutContainer westPanel = (LayoutContainer) layersPanel.getParent(); // @@ -399,6 +402,7 @@ public class LayerManager { LayerObject lo = new LayerObject(); lo.setLayerItem(layerItem); lo.setItemType(geonaItemType); + lo.setSourceConcessione(refersToBaseConcessione); String key = layerItem.getName(); //should be unique //layerObjects.put(key, lo); @@ -523,20 +527,36 @@ public class LayerManager { VerticalPanel vpPanel = new VerticalPanel(); scrollPanel.add(vpPanel); + String prevConcessioneName = ""; for (GeoNaSpatialQueryResult geoNaSpatialQueryResult : listGeoNaDataObject) { GWT.log("baseLayerFromISProfile.getName() :"+baseLayerFromISProfile.getName()); - String layerSource = geoNaSpatialQueryResult.getSourceLayerObject().getLayerItem().getName(); + LayerObject lo = geoNaSpatialQueryResult.getSourceLayerObject(); + LayerItem sourceLI = lo.getLayerItem(); + + String layerSourceName = sourceLI.getName(); //skipping centroid layer - if(layerSource==null || layerSource.compareToIgnoreCase(baseLayerFromISProfile.getName())==0) { + if(layerSourceName==null || layerSourceName.compareToIgnoreCase(baseLayerFromISProfile.getName())==0) { continue; } + String nomeConcessione = lo.getSourceConcessione().getNome(); + if(prevConcessioneName.compareTo(nomeConcessione)!=0) { + String concessioneIntro = StringUtil.ellipsize(lo.getSourceConcessione().getNome(), 40); + Heading heading = new Heading(4, concessioneIntro); + heading.getElement().getStyle().setMarginBottom(10, Unit.PX); + vpPanel.add(heading); + HTML subText = new HTML("

Layers and Properties

"); + vpPanel.add(subText); + } + + prevConcessioneName = nomeConcessione; + Label layerLabel = new Label(); layerLabel.setType(LabelType.INFO); - layerLabel.setText(layerSource); + layerLabel.setText(layerSourceName); layerLabel.getElement().getStyle().setMarginTop(10, Unit.PX); layerLabel.getElement().getStyle().setMarginBottom(5, Unit.PX); vpPanel.add(layerLabel); @@ -587,7 +607,6 @@ public class LayerManager { vpPanel.add(intFlex); } - } olMap.showPopup(scrollPanel.toString(), queryClick.getCenter()); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java index 2f5bcff..bad8c0e 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java @@ -244,17 +244,21 @@ public class ConcessioneView extends Composite { if(layer==null) return; - if(layer.getPolicy()==null || layer.getPolicy().equalsIgnoreCase("OPEN")) { - posizionamentoAreaIndaginePanel.setVisible(true); - posizionamentoAreaIndaginePanel.add(new LayerConcessioneView(layer)); - }else { - //I need to be authenticated to show the fields according to POLICY - if(myLogin!=null) { - posizionamentoAreaIndaginePanel.setVisible(true); - posizionamentoAreaIndaginePanel.add(new LayerConcessioneView(layer)); - } - - } + //NO LONGER NEEDED. MANAGED ON THE SERVER-SIDE #21976 +// if(layer.getPolicy()==null || layer.getPolicy().equalsIgnoreCase("OPEN")) { +// posizionamentoAreaIndaginePanel.setVisible(true); +// posizionamentoAreaIndaginePanel.add(new LayerConcessioneView(layer)); +// }else { +// //I need to be authenticated to show the fields according to POLICY +// if(myLogin!=null) { +// posizionamentoAreaIndaginePanel.setVisible(true); +// posizionamentoAreaIndaginePanel.add(new LayerConcessioneView(layer)); +// } +// +// } +// + posizionamentoAreaIndaginePanel.setVisible(true); + posizionamentoAreaIndaginePanel.add(new LayerConcessioneView(layer)); } @@ -266,18 +270,23 @@ public class ConcessioneView extends Composite { if(listLayersDV==null) return; + for (LayerConcessioneDV layerDV : listLayersDV) { - if(layerDV.getPolicy()==null || layerDV.getPolicy().equalsIgnoreCase("OPEN")) { - piantaFineScavoPanel.setVisible(true); - piantaFineScavoPanel.add(new LayerConcessioneView(layerDV)); - }else { - //I need to be authenticated to show the fields according to POLICY - if(myLogin!=null) { - piantaFineScavoPanel.setVisible(true); - piantaFineScavoPanel.add(new LayerConcessioneView(layerDV)); - } - } + //NO LONGER NEEDED. MANAGED ON THE SERVER-SIDE #21976 +// if(layerDV.getPolicy()==null || layerDV.getPolicy().equalsIgnoreCase("OPEN")) { +// piantaFineScavoPanel.setVisible(true); +// piantaFineScavoPanel.add(new LayerConcessioneView(layerDV)); +// }else { +// //I need to be authenticated to show the fields according to POLICY +// if(myLogin!=null) { +// piantaFineScavoPanel.setVisible(true); +// piantaFineScavoPanel.add(new LayerConcessioneView(layerDV)); +// } +// } +// + piantaFineScavoPanel.setVisible(true); + piantaFineScavoPanel.add(new LayerConcessioneView(layerDV)); } @@ -290,16 +299,20 @@ public class ConcessioneView extends Composite { if(abstractRS==null) return; - if(abstractRS.getPolicy()==null || abstractRS.getPolicy().equalsIgnoreCase("OPEN")) { - relazioneScavoPanel.setVisible(true); - relazioneScavoPanel.add(new RelazioneScavoView(abstractRS, concessioneDV.getRelazioneScavo(), false)); - }else { - //I need to be authenticated to show the fields according to POLICY - if(myLogin!=null) { - relazioneScavoPanel.setVisible(true); - relazioneScavoPanel.add(new RelazioneScavoView(abstractRS, concessioneDV.getRelazioneScavo(), true)); - } - } + //NO LONGER NEEDED. MANAGED ON THE SERVER-SIDE #21976 +// if(abstractRS.getPolicy()==null || abstractRS.getPolicy().equalsIgnoreCase("OPEN")) { +// relazioneScavoPanel.setVisible(true); +// relazioneScavoPanel.add(new RelazioneScavoView(abstractRS, concessioneDV.getRelazioneScavo(), false)); +// }else { +// //I need to be authenticated to show the fields according to POLICY +// if(myLogin!=null) { +// relazioneScavoPanel.setVisible(true); +// relazioneScavoPanel.add(new RelazioneScavoView(abstractRS, concessioneDV.getRelazioneScavo(), true)); +// } +// } + + relazioneScavoPanel.setVisible(true); + relazioneScavoPanel.add(new RelazioneScavoView(abstractRS, concessioneDV.getRelazioneScavo())); } private void addCentroidMap() { @@ -331,13 +344,16 @@ public class ConcessioneView extends Composite { //SHOWING ONLY OPEN IMAGES OR IF THE USER IS LOGGED for (UploadedImageDV uploadedImageDV : immagini) { - if(uploadedImageDV.getPolicy()==null || uploadedImageDV.getPolicy().equalsIgnoreCase("OPEN")) { - immaginiToShow.add(uploadedImageDV); - }else { - if(myLogin!=null) { - immaginiToShow.add(uploadedImageDV); - } - } + //NO LONGER NEEDED. MANAGED ON THE SERVER-SIDE #21976 +// if(uploadedImageDV.getPolicy()==null || uploadedImageDV.getPolicy().equalsIgnoreCase("OPEN")) { +// immaginiToShow.add(uploadedImageDV); +// }else { +// if(myLogin!=null) { +// immaginiToShow.add(uploadedImageDV); +// } +// } +// + immaginiToShow.add(uploadedImageDV); } if(immaginiToShow.size()>0) { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/RelazioneScavoView.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/RelazioneScavoView.java index efa1707..577151b 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/RelazioneScavoView.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/RelazioneScavoView.java @@ -46,7 +46,7 @@ public class RelazioneScavoView extends Composite { private CustomFlexTable customTable = new CustomFlexTable(); - public RelazioneScavoView(AbstractRelazioneScavoDV abstractDV, RelazioneScavoDV relazioneScavoDV, boolean autheticatedUser) { + public RelazioneScavoView(AbstractRelazioneScavoDV abstractDV, RelazioneScavoDV relazioneScavoDV) { initWidget(uiBinder.createAndBindUi(this)); if(abstractDV.getAbstractSectionIta()!=null) { @@ -58,6 +58,10 @@ public class RelazioneScavoView extends Composite { } } + if(relazioneScavoDV==null) + return; + + //customTable.addNextKeyValue("Created", relazioneScavoDV.getCreationTime()); //customTable.addNextKeyValue("ID Licenza", relazioneScavoDV.getLicenseID()); customTable.addNextKeyValues("Responsabili", relazioneScavoDV.getResponsabili(), GeoportalDataViewerConstants.NEW_LINE_BR); @@ -81,17 +85,21 @@ public class RelazioneScavoView extends Composite { } }); - //Showing the Download PFD relazione accoding to policy - if(relazioneScavoDV.getPolicy()==null || relazioneScavoDV.getPolicy().equalsIgnoreCase("OPEN")) { - relazioneScavoPanel.setVisible(true); - showLintToDownloadLastContent(relazioneScavoDV.getListWsContent()); - //DOWNLOAD RS - }else { - //I need to be authenticated to show the fields according to POLICY - if(autheticatedUser) { - showLintToDownloadLastContent(relazioneScavoDV.getListWsContent()); - } - } + //Showing the Download PDF relazione accoding to policy + //NO LONGER NEEDED. MANAGED ON THE SERVER-SIDE #21976 +// if(relazioneScavoDV.getPolicy()==null || relazioneScavoDV.getPolicy().equalsIgnoreCase("OPEN")) { +// relazioneScavoPanel.setVisible(true); +// showLintToDownloadLastContent(relazioneScavoDV.getListWsContent()); +// //DOWNLOAD RS +// }else { +// //I need to be authenticated to show the fields according to POLICY +// if(autheticatedUser) { +// showLintToDownloadLastContent(relazioneScavoDV.getListWsContent()); +// } +// } +// + relazioneScavoPanel.setVisible(true); + showLintToDownloadLastContent(relazioneScavoDV.getListWsContent()); relazioneScavoPanel.add(customTable); } 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 b245a53..ef37f91 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 @@ -19,6 +19,7 @@ import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.LayerItem; import org.gcube.application.geoportalcommon.shared.gis.BoundsMap; +import org.gcube.application.geoportalcommon.shared.products.BaseConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.model.AbstractRelazioneScavoDV; import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV; @@ -221,19 +222,20 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme SessionUtil.getCurrentToken(this.getThreadLocalRequest(), true); ConcessioniManagerI concessioniManager = statefulMongoConcessioni().build(); Concessione concessione = concessioniManager.getById(itemId); + BaseConcessioneDV baseConcessione = ConvertToDataViewModel.toBaseConcessione(concessione); if (concessione != null) { LOG.info("For id " + itemId + ", got concessione " + concessione.getNome() + " from service"); listLayers = new ArrayList(); if (concessione.getPianteFineScavo() != null) { for (LayerConcessione lc : concessione.getPianteFineScavo()) { - listLayers.add(ConvertToDataViewModel.toLayerConcessione(lc)); + listLayers.add(ConvertToDataViewModel.toLayerConcessione(lc, baseConcessione)); } } if (concessione.getPosizionamentoScavo() != null) { LayerConcessioneDV thePosizScavo = ConvertToDataViewModel - .toLayerConcessione(concessione.getPosizionamentoScavo()); + .toLayerConcessione(concessione.getPosizionamentoScavo(), baseConcessione); if (thePosizScavo != null) listLayers.add(thePosizScavo); } @@ -282,8 +284,8 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme GCubeUser user = SessionUtil.getCurrentUser(this.getThreadLocalRequest()); String userName = user == null ? null : user.getUsername(); - //TODO THIS IS A WORKAROUND WAITING FOR USER ROLE. - //I CAN CHECK THE ACCCESS POLICIES IF AND ONLY IF THE USER IS NOT LOGGED IN. + // TODO THIS IS A WORKAROUND WAITING FOR USER ROLE. + // I CAN CHECK THE ACCCESS POLICIES IF AND ONLY IF THE USER IS NOT LOGGED IN. if (user == null) { // CHECKING ACCESS POLICY @@ -339,7 +341,6 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme // END CHECKING ACCESS POLICY LOG.info("Access policies applied"); } - } if (concessionDV == null) 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 9f7f72c..f0c2a3c 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/LayerObject.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/LayerObject.java @@ -2,12 +2,15 @@ package org.gcube.portlets.user.geoportaldataviewer.shared.gis; import java.io.Serializable; +import org.gcube.application.geoportalcommon.shared.products.BaseConcessioneDV; + + /** * The Class LayerObject. * - * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * - * Nov 13, 2020 + * Sep 9, 2021 */ public class LayerObject implements Serializable { @@ -18,6 +21,7 @@ public class LayerObject implements Serializable { /* This is the layer/product type. E.g. Concessione */ private String itemType; private LayerItem layerItem; + private BaseConcessioneDV sourceConcessione; /** * Instantiates a new layer object. @@ -25,10 +29,18 @@ public class LayerObject implements Serializable { public LayerObject() { } - public LayerObject(String itemType, LayerItem layerItem) { + /** + * Instantiates a new layer object. + * + * @param itemType the item type + * @param layerItem the layer item + * @param sourceConcessione the source concessione + */ + public LayerObject(String itemType, LayerItem layerItem, BaseConcessioneDV sourceConcessione) { super(); this.itemType = itemType; this.layerItem = layerItem; + this.sourceConcessione = sourceConcessione; } /** @@ -40,15 +52,6 @@ public class LayerObject implements Serializable { return itemType; } - /** - * Sets the item type. - * - * @param itemType the new item type - */ - public void setItemType(String itemType) { - this.itemType = itemType; - } - /** * Gets the layer item. * @@ -58,6 +61,24 @@ public class LayerObject implements Serializable { return layerItem; } + /** + * Gets the source concessione. + * + * @return the source concessione + */ + public BaseConcessioneDV getSourceConcessione() { + return sourceConcessione; + } + + /** + * Sets the item type. + * + * @param itemType the new item type + */ + public void setItemType(String itemType) { + this.itemType = itemType; + } + /** * Sets the layer item. * @@ -67,6 +88,15 @@ public class LayerObject implements Serializable { this.layerItem = layerItem; } + /** + * Sets the source concessione. + * + * @param sourceConcessione the new source concessione + */ + public void setSourceConcessione(BaseConcessioneDV sourceConcessione) { + this.sourceConcessione = sourceConcessione; + } + /** * To string. * @@ -79,8 +109,10 @@ public class LayerObject implements Serializable { builder.append(itemType); builder.append(", layerItem="); builder.append(layerItem); + builder.append(", sourceConcessione="); + builder.append(sourceConcessione); builder.append("]"); return builder.toString(); } -} +} \ No newline at end of file diff --git a/src/main/webapp/GeoportalDataViewer.css b/src/main/webapp/GeoportalDataViewer.css index 8efa665..c471d94 100644 --- a/src/main/webapp/GeoportalDataViewer.css +++ b/src/main/webapp/GeoportalDataViewer.css @@ -265,6 +265,7 @@ body { text-align: left; border-collapse: collapse; width: 100%; + margin-bottom:10px; } .table-feature td { -- 2.17.1 From fb1ee8456f9415a7c91094e068706b2a0629cc67 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 9 Sep 2021 15:55:33 +0200 Subject: [PATCH 27/38] improvement display features --- .../client/GeoportalDataViewerConstants.java | 2 +- .../client/LayerManager.java | 339 ++++++++++++------ .../server/ConcessioneImageUtil.java | 10 +- .../server/ConcessioniMongoService.java | 49 +++ .../GeoportalDataViewerServiceImpl.java | 38 +- ...ssUtil.java => CheckAccessPolicyUtil.java} | 11 +- 6 files changed, 304 insertions(+), 145 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConcessioniMongoService.java rename src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/{CheckAccessUtil.java => CheckAccessPolicyUtil.java} (87%) diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java index c0b87b4..e1117c0 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java @@ -42,7 +42,7 @@ public class GeoportalDataViewerConstants { public static DateTimeFormat DT_FORMAT = DateTimeFormat.getFormat(ConvertToDataViewModel.DATE_FORMAT); - public static final int MAX_WFS_FEATURES = 3; // zero for no limit + public static final int MAX_WFS_FEATURES = 10; // zero for no limit public static final String NEW_LINE_BR = "
"; 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 5a5e2e6..bcf91c2 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 @@ -57,6 +57,7 @@ import com.google.gwt.user.client.EventListener; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.FlexTable; +import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.ScrollPanel; import com.google.gwt.user.client.ui.VerticalPanel; @@ -147,16 +148,15 @@ public class LayerManager { GWT.log("MAX_WFS_FEATURES is: " + GeoportalDataViewerConstants.MAX_WFS_FEATURES); // GeoportalDataViewerConstants.print("calling getDataResult"); - List listLO = new ArrayList(); - //for querying base layers + // for querying base layers listLO.addAll(mapBaseLayerObjects.values()); - - //for querying detail layers only in this case - if(olMap.getCurrentResolution()>() { @@ -171,7 +171,7 @@ public class LayerManager { public void onSuccess(List listGeonaDataObjects) { GWT.log("GeoNaDataObject's is/are " + listGeonaDataObjects.size()); - //GWT.log("GeoNaDataObject's: " + listGeonaDataObjects); + // GWT.log("GeoNaDataObject's: " + listGeonaDataObjects); // GeoportalDataViewerConstants.print("GeoNaDataObject's: // "+listGeonaDataObjects); @@ -179,7 +179,7 @@ public class LayerManager { return; FeatureRow feature = null; - + MapEventType sourceEvent = queryEvent.getSourceMapEventType(); // TODO SWTCH FOR EARCH ITEM TYPE @@ -223,11 +223,10 @@ public class LayerManager { // 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 + 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()); } @@ -244,8 +243,8 @@ public class LayerManager { 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)){ + if (sourceEvent.equals(MapEventType.MOUSE_CLICK) + || sourceEvent.equals(MapEventType.ADDED_CENTROID_LAYER_TO_MAP)) { showPopupInfoForCentroidLayer(geoNaDataObject, feature, queryEvent.getQueryClickExtent().getCenter()); } @@ -271,7 +270,8 @@ public class LayerManager { layer.getLayerName(), layer.getWmsLink(), false, false, layer.getLayerUUID(), true, OLMapManager.LAYER_DETAIL_MIN_RESOLUTION, - OLMapManager.LAYER_DETAIL_MAX_RESOLUTION,layer.getRefersTo()); + OLMapManager.LAYER_DETAIL_MAX_RESOLUTION, + layer.getRefersTo()); } } @@ -308,7 +308,7 @@ public class LayerManager { } }); } - + public void removeAllDetailLayers() { mapDetailLayerObjects.clear(); olMap.removeAllDetailLayers(); @@ -343,21 +343,22 @@ public class LayerManager { /** * Adds the layer. * - * @param geonaItemType the geona item type - * @param layerTitle the layer title - * @param layerName the layer name - * @param wmsLink the wms link - * @param isBase the is base - * @param displayInLayerSwitcher the display in layer switcher - * @param UUID the uuid - * @param asDetailLayer the as detail layer - * @param minResolution the min resolution - * @param maxResolution the max resolution + * @param geonaItemType the geona item type + * @param layerTitle the layer title + * @param layerName the layer name + * @param wmsLink the wms link + * @param isBase the is base + * @param displayInLayerSwitcher the display in layer switcher + * @param UUID the uuid + * @param asDetailLayer the as detail layer + * @param minResolution the min resolution + * @param maxResolution the max resolution * @param refersToBaseConcessione the refers to base concessione */ public void addLayer(final String geonaItemType, 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, BaseConcessioneDV refersToBaseConcessione) { + final boolean asDetailLayer, Double minResolution, Double maxResolution, + BaseConcessioneDV refersToBaseConcessione) { // final LayoutContainer westPanel = (LayoutContainer) layersPanel.getParent(); // @@ -398,30 +399,30 @@ public class LayerManager { displayInLayerSwitcher, (ArrayList) geoInfoWMS.getStyles().getGeoStyles(), geoInfoWMS.getWmsRequest(), false, geoInfoWMS.getMapWMSNoStandard(), geoInfoWMS.isNcWMS(), UUID, geoInfoWMS.getZAxis(), minResolution, maxResolution); - + LayerObject lo = new LayerObject(); lo.setLayerItem(layerItem); lo.setItemType(geonaItemType); lo.setSourceConcessione(refersToBaseConcessione); - String key = layerItem.getName(); //should be unique - //layerObjects.put(key, lo); - - if(!asDetailLayer) { - //is a base layer + String key = layerItem.getName(); // should be unique + // layerObjects.put(key, lo); + + if (!asDetailLayer) { + // is a base layer LayerObject blo = mapBaseLayerObjects.get(key); - if(blo==null) { + if (blo == null) { olMap.addWMSLayer(layerItem); mapBaseLayerObjects.put(key, lo); - }else { + } else { GWT.log("Skipping base layer " + key + " already added to Map"); } - }else { + } else { LayerObject dlo = mapDetailLayerObjects.get(key); - if(dlo==null) { + if (dlo == null) { mapDetailLayerObjects.put(key, lo); olMap.addWMSDetailLayer(layerItem); - }else { + } else { GWT.log("Skipping detail layer " + key + " already added to Map"); } } @@ -520,98 +521,210 @@ public class LayerManager { * @param feature the feature * @param onFailureCenterTo the on failure center to */ - public void showPopupInfoForLayer(List listGeoNaDataObject, - ExtentWrapped queryClick) { - + public void showPopupInfoForLayer(List listGeoNaDataObject, ExtentWrapped queryClick) { + ScrollPanel scrollPanel = new ScrollPanel(); - VerticalPanel vpPanel = new VerticalPanel(); - scrollPanel.add(vpPanel); - + FlowPanel flowPanel = new FlowPanel(); + scrollPanel.add(flowPanel); + String prevConcessioneName = ""; for (GeoNaSpatialQueryResult geoNaSpatialQueryResult : listGeoNaDataObject) { - - 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; - } - - String nomeConcessione = lo.getSourceConcessione().getNome(); - if(prevConcessioneName.compareTo(nomeConcessione)!=0) { - String concessioneIntro = StringUtil.ellipsize(lo.getSourceConcessione().getNome(), 40); - Heading heading = new Heading(4, concessioneIntro); - heading.getElement().getStyle().setMarginBottom(10, Unit.PX); - vpPanel.add(heading); - HTML subText = new HTML("

Layers and Properties

"); - vpPanel.add(subText); - } - - prevConcessioneName = nomeConcessione; - - Label layerLabel = new Label(); - layerLabel.setType(LabelType.INFO); - - layerLabel.setText(layerSourceName); - layerLabel.getElement().getStyle().setMarginTop(10, Unit.PX); - layerLabel.getElement().getStyle().setMarginBottom(5, Unit.PX); - vpPanel.add(layerLabel); - - List features = geoNaSpatialQueryResult.getFeatures(); + try { + GWT.log("baseLayerFromISProfile.getName() :" + baseLayerFromISProfile.getName()); + LayerObject lo = geoNaSpatialQueryResult.getSourceLayerObject(); + LayerItem sourceLI = lo.getLayerItem(); - if (features == null || features.isEmpty()) { - FlexTable flex = new FlexTable(); - flex.setCellPadding(1); - flex.setCellSpacing(1); - flex.getElement().addClassName("table-feature"); - flex.setHTML(0, 0, new HTML("No data available").toString()); - vpPanel.add(flex); - continue; - //olMap.showPopup(vpPanel.toString(), onFailureCenterTo); - } - - for (FeatureRow feature : features) { + String layerSourceName = sourceLI.getName(); + + // skipping centroid layer + if (layerSourceName == null + || layerSourceName.compareToIgnoreCase(baseLayerFromISProfile.getName()) == 0) { + continue; + } + + String nomeConcessione = lo.getSourceConcessione().getNome(); + if (prevConcessioneName.compareTo(nomeConcessione) != 0) { + String concessioneIntro = StringUtil.ellipsize(lo.getSourceConcessione().getNome(), 40); + Heading heading = new Heading(4, concessioneIntro); + heading.getElement().getStyle().setMarginBottom(10, Unit.PX); + flowPanel.add(heading); + HTML subText = new HTML( + "

Layers and Properties

"); + flowPanel.add(subText); + } + + prevConcessioneName = nomeConcessione; + + Label layerLabel = new Label(); + layerLabel.setType(LabelType.INFO); + + layerLabel.setText(layerSourceName); + layerLabel.getElement().getStyle().setMarginTop(10, Unit.PX); + layerLabel.getElement().getStyle().setMarginBottom(5, Unit.PX); + flowPanel.add(layerLabel); + + List features = geoNaSpatialQueryResult.getFeatures(); + if (features == null || features.isEmpty()) { + FlexTable flex = new FlexTable(); + flex.setCellPadding(1); + flex.setCellSpacing(1); + flex.getElement().addClassName("table-feature"); + flex.setHTML(0, 0, new HTML("No data available").toString()); + flowPanel.add(flex); + continue; + // olMap.showPopup(vpPanel.toString(), onFailureCenterTo); + } + + 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()); - intFlex.setHTML(1, 0, new HTML(feature.getId()).toString()); - - // Showing properties belonging to concessioni centroid layer - Map> entries = feature.getMapProperties(); - - if (entries.size() == 0) { - intFlex.setHTML(1, 1, new HTML("No property available").toString()); - } - int j = 1; - for (String key : entries.keySet()) { - List theValues = entries.get(key); - String valueToDisplay = ""; - for (String value : theValues) { - valueToDisplay+=value+", "; - + + 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()); } - valueToDisplay = valueToDisplay.substring(0,valueToDisplay.length()-2); - intFlex.setHTML(0, j, new HTML(key).toString()); - intFlex.setHTML(1, j, new HTML(valueToDisplay).toString()); - j++; - + 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++; } - - vpPanel.add(intFlex); + flowPanel.add(intFlex); + } catch (Exception e) { + GeoportalDataViewerConstants.printJs("Error: "+e.getMessage()); } } olMap.showPopup(scrollPanel.toString(), queryClick.getCenter()); } + +// /** +// * Show popup info for layer. +// * +// * @param geoNaDataObject the geo na data object +// * @param feature the feature +// * @param onFailureCenterTo the on failure center to +// */ +// public void showPopupInfoForLayer(List listGeoNaDataObject, +// ExtentWrapped queryClick) { +// +// ScrollPanel scrollPanel = new ScrollPanel(); +// VerticalPanel vpPanel = new VerticalPanel(); +// scrollPanel.add(vpPanel); +// +// String prevConcessioneName = ""; +// for (GeoNaSpatialQueryResult geoNaSpatialQueryResult : listGeoNaDataObject) { +// +// 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; +// } +// +// String nomeConcessione = lo.getSourceConcessione().getNome(); +// if(prevConcessioneName.compareTo(nomeConcessione)!=0) { +// String concessioneIntro = StringUtil.ellipsize(lo.getSourceConcessione().getNome(), 40); +// Heading heading = new Heading(4, concessioneIntro); +// heading.getElement().getStyle().setMarginBottom(10, Unit.PX); +// vpPanel.add(heading); +// HTML subText = new HTML("

Layers and Properties

"); +// vpPanel.add(subText); +// } +// +// prevConcessioneName = nomeConcessione; +// +// Label layerLabel = new Label(); +// layerLabel.setType(LabelType.INFO); +// +// layerLabel.setText(layerSourceName); +// layerLabel.getElement().getStyle().setMarginTop(10, Unit.PX); +// layerLabel.getElement().getStyle().setMarginBottom(5, Unit.PX); +// vpPanel.add(layerLabel); +// +// List features = geoNaSpatialQueryResult.getFeatures(); +// +// if (features == null || features.isEmpty()) { +// FlexTable flex = new FlexTable(); +// flex.setCellPadding(1); +// flex.setCellSpacing(1); +// flex.getElement().addClassName("table-feature"); +// flex.setHTML(0, 0, new HTML("No data available").toString()); +// vpPanel.add(flex); +// continue; +// //olMap.showPopup(vpPanel.toString(), onFailureCenterTo); +// } +// +// for (FeatureRow feature : 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()); +// intFlex.setHTML(1, 0, new HTML(feature.getId()).toString()); +// +// // Showing properties belonging to concessioni centroid layer +// Map> entries = feature.getMapProperties(); +// +// if (entries.size() == 0) { +// intFlex.setHTML(1, 1, new HTML("No property available").toString()); +// } +// int j = 1; +// 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); +// intFlex.setHTML(0, j, new HTML(key).toString()); +// intFlex.setHTML(1, j, new HTML(valueToDisplay).toString()); +// j++; +// +// } +// +// vpPanel.add(intFlex); +// } +// } +// +// olMap.showPopup(scrollPanel.toString(), queryClick.getCenter()); +// +// } /** * Show popup info for centroid layer. diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConcessioneImageUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConcessioneImageUtil.java index 0fefc04..6e52f6a 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConcessioneImageUtil.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConcessioneImageUtil.java @@ -1,18 +1,14 @@ package org.gcube.portlets.user.geoportaldataviewer.server; -import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.statefulMongoConcessioni; - import java.util.ArrayList; import java.util.List; import javax.servlet.http.HttpServletRequest; -import org.gcube.application.geoportal.client.legacy.ConcessioniManagerI; import org.gcube.application.geoportal.common.model.legacy.Concessione; import org.gcube.application.geoportal.common.model.legacy.UploadedImage; import org.gcube.application.geoportalcommon.ConvertToDataViewModel; import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV; -import org.gcube.portlets.user.geoportaldataviewer.server.util.SessionUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -54,10 +50,8 @@ public class ConcessioneImageUtil { if (itemType.equalsIgnoreCase("concessione")) { LOG.info("Trying to get concessione for id " + itemId); - SessionUtil.getCurrentContext(httpServletRequest, true); - SessionUtil.getCurrentToken(httpServletRequest, true); - ConcessioniManagerI concessioniManager = statefulMongoConcessioni().build(); - Concessione concessione = concessioniManager.getById(itemId); + ConcessioniMongoService cms = new ConcessioniMongoService(); + Concessione concessione = cms.getItemById(httpServletRequest, itemId); if (concessione != null) { LOG.info("For id " + itemId + ", got concessione " + concessione.getNome() + " from service"); List images = concessione.getImmaginiRappresentative(); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConcessioniMongoService.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConcessioniMongoService.java new file mode 100644 index 0000000..c3317db --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConcessioniMongoService.java @@ -0,0 +1,49 @@ +package org.gcube.portlets.user.geoportaldataviewer.server; + +import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.statefulMongoConcessioni; + +import javax.servlet.http.HttpServletRequest; + +import org.gcube.application.geoportal.client.legacy.ConcessioniManagerI; +import org.gcube.application.geoportal.common.model.legacy.Concessione; +import org.gcube.portlets.user.geoportaldataviewer.server.util.SessionUtil; + + +/** + * The Class ConcessioniMongoService. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Sep 9, 2021 + */ +public class ConcessioniMongoService { + + + /** + * Instantiates a new concessioni mongo service, interface for client statefulMongoConcessioni. + */ + public ConcessioniMongoService() { + } + + + /** + * Gets the item by id. + * + * @param request the request + * @param mongoItemId the mongo item id + * @return the item by id + * @throws Exception the exception + */ + Concessione getItemById(HttpServletRequest request, String mongoItemId) throws Exception{ + SessionUtil.getCurrentContext(request, true); + SessionUtil.getCurrentToken(request, true); + //Obtain the client + ConcessioniManagerI concessioniManager = statefulMongoConcessioni().build(); + //Returning item by Id + return concessioniManager.getById(mongoItemId); + } + + + + +} 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 ef37f91..a302db0 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 @@ -1,7 +1,5 @@ package org.gcube.portlets.user.geoportaldataviewer.server; -import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.statefulMongoConcessioni; - import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -9,7 +7,6 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import org.gcube.application.geoportal.client.legacy.ConcessioniManagerI; import org.gcube.application.geoportal.common.model.legacy.Concessione; import org.gcube.application.geoportal.common.model.legacy.LayerConcessione; import org.gcube.application.geoportalcommon.ConvertToDataViewModel; @@ -29,7 +26,7 @@ import org.gcube.application.geoportalcommon.util.URLParserUtil; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerService; import org.gcube.portlets.user.geoportaldataviewer.server.gis.FeatureParser; import org.gcube.portlets.user.geoportaldataviewer.server.gis.WMSUrlValidator; -import org.gcube.portlets.user.geoportaldataviewer.server.util.CheckAccessUtil; +import org.gcube.portlets.user.geoportaldataviewer.server.util.CheckAccessPolicyUtil; import org.gcube.portlets.user.geoportaldataviewer.server.util.SessionUtil; import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject; @@ -145,6 +142,8 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme 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"); @@ -218,10 +217,9 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme if (itemType.equalsIgnoreCase("concessione")) { LOG.info("Trying to get concessione for id " + itemId); - SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); - SessionUtil.getCurrentToken(this.getThreadLocalRequest(), true); - ConcessioniManagerI concessioniManager = statefulMongoConcessioni().build(); - Concessione concessione = concessioniManager.getById(itemId); + ConcessioniMongoService cms = new ConcessioniMongoService(); + Concessione concessione = cms.getItemById(this.getThreadLocalRequest(), itemId); + BaseConcessioneDV baseConcessione = ConvertToDataViewModel.toBaseConcessione(concessione); if (concessione != null) { LOG.info("For id " + itemId + ", got concessione " + concessione.getNome() + " from service"); @@ -272,11 +270,15 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme try { LOG.info("Trying to get record for id " + mongoId); - SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); - SessionUtil.getCurrentToken(this.getThreadLocalRequest(), true); - // Obtain the client - ConcessioniManagerI manager = statefulMongoConcessioni().build(); - Concessione concessione = manager.getById(mongoId); +// SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); +// SessionUtil.getCurrentToken(this.getThreadLocalRequest(), true); +// // Obtain the client +// ConcessioniManagerI manager = statefulMongoConcessioni().build(); +// Concessione concessione = manager.getById(mongoId); + + ConcessioniMongoService cms = new ConcessioniMongoService(); + Concessione concessione = cms.getItemById(this.getThreadLocalRequest(), mongoId); + LOG.info("Got concessione for mongoId: " + mongoId); if (concessione != null) { concessionDV = ConvertToDataViewModel.toConcessione(concessione); @@ -292,7 +294,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme LOG.info("Applying access policies for concessione " + mongoId + " returned by service"); LayerConcessioneDV layerPosizionamento = concessionDV.getPosizionamentoScavo(); if (layerPosizionamento != null) { - if (!CheckAccessUtil.isAccessible(layerPosizionamento.getPolicy(), userName)) { + if (!CheckAccessPolicyUtil.isAccessible(layerPosizionamento.getPolicy(), userName)) { concessionDV.setPosizionamentoScavo(null); } } @@ -301,7 +303,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme if (listLayersDV != null) { List accessibleListLayersDV = new ArrayList(); for (LayerConcessioneDV layerDV : listLayersDV) { - if (CheckAccessUtil.isAccessible(layerDV.getPolicy(), userName)) { + if (CheckAccessPolicyUtil.isAccessible(layerDV.getPolicy(), userName)) { accessibleListLayersDV.add(layerDV); } } @@ -310,14 +312,14 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme AbstractRelazioneScavoDV abstractRS = concessionDV.getAbstractRelazioneScavo(); if (abstractRS != null) { - if (!CheckAccessUtil.isAccessible(abstractRS.getPolicy(), userName)) { + if (!CheckAccessPolicyUtil.isAccessible(abstractRS.getPolicy(), userName)) { concessionDV.setAbstractRelazioneScavo(null); } } RelazioneScavoDV relazioneScavo = concessionDV.getRelazioneScavo(); if (relazioneScavo != null) { - if (!CheckAccessUtil.isAccessible(relazioneScavo.getPolicy(), userName)) { + if (!CheckAccessPolicyUtil.isAccessible(relazioneScavo.getPolicy(), userName)) { concessionDV.setRelazioneScavo(null); } } @@ -329,7 +331,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme // SHOWING ACESSIBLE IMAGES for (UploadedImageDV uploadedImageDV : immagini) { - if (CheckAccessUtil.isAccessible(uploadedImageDV.getPolicy(), userName)) { + if (CheckAccessPolicyUtil.isAccessible(uploadedImageDV.getPolicy(), userName)) { accessibleListImages.add(uploadedImageDV); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/CheckAccessUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/CheckAccessPolicyUtil.java similarity index 87% rename from src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/CheckAccessUtil.java rename to src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/CheckAccessPolicyUtil.java index 545528c..f4416d5 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/CheckAccessUtil.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/CheckAccessPolicyUtil.java @@ -1,13 +1,14 @@ package org.gcube.portlets.user.geoportaldataviewer.server.util; + /** - * The Class CheckAccessUtil. + * The Class CheckAccessPolicyUtil. * - * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * - * Sep 8, 2021 + * Sep 9, 2021 */ -public class CheckAccessUtil { +public class CheckAccessPolicyUtil { /** * The Enum ACCESS_POLICY. @@ -51,7 +52,7 @@ public class CheckAccessUtil { } /** - * Checks if is accessible. + * Checks if is accessible accoding to access policies * * @param policy the policy * @param myLogin the my login -- 2.17.1 From e10b0cec44f90e08a6d3e8d6f2c865b61e136ed4 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Tue, 14 Sep 2021 13:09:35 +0200 Subject: [PATCH 28/38] added optional shorting of URL --- .../portlets/user/geoportaldataviewer/client/LayerManager.java | 1 + .../server/GeoportalDataViewerServiceImpl.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) 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 bcf91c2..96c4b48 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 @@ -525,6 +525,7 @@ public class LayerManager { ScrollPanel scrollPanel = new ScrollPanel(); FlowPanel flowPanel = new FlowPanel(); + //flowPanel.getElement().getStyle().setProperty("maxHeight", "600px"); scrollPanel.add(flowPanel); String prevConcessioneName = ""; 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 a302db0..9be15df 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 @@ -478,7 +478,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); GeoportalCommon gc = new GeoportalCommon(); - return gc.getPublicLinksFor(item); + return gc.getPublicLinksFor(item,true); } catch (Exception e) { LOG.error("Error on getPublicLinksFor for: " + item, e); -- 2.17.1 From bea4f8dc0a13288a43eed6e82401107f50db8d8f Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 15 Sep 2021 11:20:00 +0200 Subject: [PATCH 29/38] changed config --- .classpath | 1 - .settings/org.eclipse.wst.common.component | 33 +++++++++++++++------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/.classpath b/.classpath index 7118c71..acfc760 100644 --- a/.classpath +++ b/.classpath @@ -35,6 +35,5 @@ - diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 6ddcc0f..113106b 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,5 +1,6 @@ - + + @@ -12,7 +13,8 @@ - + + @@ -25,7 +27,8 @@ - + + @@ -38,7 +41,8 @@ - + + @@ -51,7 +55,8 @@ - + + @@ -60,7 +65,8 @@ - + + @@ -69,7 +75,11 @@ - + + uses + + + @@ -82,7 +92,8 @@ - + + @@ -93,7 +104,8 @@ - + + @@ -106,7 +118,8 @@ - + + -- 2.17.1 From 97ab51e415ebcd4652bce9058002d53dc4be215c Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 16 Sep 2021 12:14:38 +0200 Subject: [PATCH 30/38] completed README --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9012d74..86ee60d 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,10 @@ The GeoPortal Data Viewer App is an application to access, discovery and navigat **Uses** -* [GWT-OL3](https://github.com/TDesjardins/gwt-ol) GWT-OpenLayers 3+ v.8.0.0-gwt2_9 -* [OpenLayers](https://openlayers.org/) OpenLayers v.6.X +* GWT v.2.9.0. [GWT](http://www.gwtproject.org) is licensed under [Apache License 2.0](http://www.gwtproject.org/terms.html) +* GWT-Bootstrap v.2.3.2.0. [GWT-Bootstrap](https://github.com/gwtbootstrap) is licensed under [[Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0) +* GWT-OpenLayers 3+ v.8.0.0-gwt2_9. [GWT-OL3](https://github.com/TDesjardins/gwt-ol) +* OpenLayers v.6.X. [OpenLayers](https://openlayers.org/) is licensed under [BSD 2-Clause "Simplified"](https://github.com/openlayers/openlayers/blob/main/LICENSE.md) ## Documentation -- 2.17.1 From eba361389ee0c4d253958087586cee4ba6c35bf4 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 22 Sep 2021 12:18:58 +0200 Subject: [PATCH 31/38] #21976 Access Policies now are applied also on retrieving layers for id --- .../client/GeoportalDataViewer.java | 2 - .../client/gis/OpenLayerOSM.java | 6 +-- .../GeoportalDataViewerServiceImpl.java | 49 +++++++++++++------ .../server/util/CheckAccessPolicyUtil.java | 9 +++- 4 files changed, 43 insertions(+), 23 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 66f4cf2..65d862d 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 @@ -83,8 +83,6 @@ public class GeoportalDataViewer implements EntryPoint { int attempt = 0; - // https://data.d4science.org/gis-viewer-app/?wmsrequest=https%3A%2F%2Fgeona-proto.d4science.org%2Fgeoserver%2Fconcessioni_conf%2Fwms%3Fservice%3DWMS%26version%3D1.1.0%26request%3DGetMap%26layers%3Dconcessioni_conf%3Acentroids_concessioni%26styles%3D%26bbox%3D8.476%2C39.179%2C17.391%2C45.772%26width%3D768%26height%3D567%26srs%3DEPSG%3A4326%26format%3Dapplication%2Fopenlayers&zoom=6¢ermap=12.45%2C42.98 - /** * This is the entry point method. */ diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java index 0232c01..b0e1a2c 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java @@ -150,14 +150,14 @@ public abstract class OpenLayerOSM { this.eventBus = eventBus; // create a OSM-layer - XyzOptions osmSourceOptions = OLFactory.createOptions(); + XyzOptions xyzOptions = OLFactory.createOptions(); // osmSourceOptions.setCrossOrigin("Anonymous"); // osmSourceOptions.setTileLoadFunction(null); - Osm osmSource = new Osm(osmSourceOptions); + Osm osmSource = new Osm(xyzOptions); LayerOptions osmLayerOptions = OLFactory.createOptions(); osmLayerOptions.setSource(osmSource); - + Tile osmLayer = new Tile(osmLayerOptions); // create a projection projectionOptions.setCode(MAP_PROJECTION.EPSG_3857.getName()); 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 9be15df..e945088 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 @@ -213,6 +213,12 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme try { SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); + String userName = null; + try { + userName = SessionUtil.getCurrentUser(this.getThreadLocalRequest()).getUsername(); + }catch (Exception e) { + LOG.info("User not found in session, the userName for cecking policy will be null"); + } if (itemType.equalsIgnoreCase("concessione")) { @@ -227,15 +233,24 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme if (concessione.getPianteFineScavo() != null) { for (LayerConcessione lc : concessione.getPianteFineScavo()) { - listLayers.add(ConvertToDataViewModel.toLayerConcessione(lc, baseConcessione)); + if (CheckAccessPolicyUtil.isAccessible(lc.getPolicy().name(), userName)) { + listLayers.add(ConvertToDataViewModel.toLayerConcessione(lc, baseConcessione)); + } + } + + LayerConcessione lcPosizionamento = concessione.getPosizionamentoScavo(); + + if (lcPosizionamento != null) { + + if (CheckAccessPolicyUtil.isAccessible(lcPosizionamento.getPolicy().name(), userName)) { + + LayerConcessioneDV thePosizScavo = ConvertToDataViewModel + .toLayerConcessione(lcPosizionamento, baseConcessione); + if (thePosizScavo != null) + listLayers.add(thePosizScavo); + } } - } - if (concessione.getPosizionamentoScavo() != null) { - LayerConcessioneDV thePosizScavo = ConvertToDataViewModel - .toLayerConcessione(concessione.getPosizionamentoScavo(), baseConcessione); - if (thePosizScavo != null) - listLayers.add(thePosizScavo); } } else @@ -270,11 +285,6 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme try { LOG.info("Trying to get record for id " + mongoId); -// SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); -// SessionUtil.getCurrentToken(this.getThreadLocalRequest(), true); -// // Obtain the client -// ConcessioniManagerI manager = statefulMongoConcessioni().build(); -// Concessione concessione = manager.getById(mongoId); ConcessioniMongoService cms = new ConcessioniMongoService(); Concessione concessione = cms.getItemById(this.getThreadLocalRequest(), mongoId); @@ -283,12 +293,17 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme if (concessione != null) { concessionDV = ConvertToDataViewModel.toConcessione(concessione); - GCubeUser user = SessionUtil.getCurrentUser(this.getThreadLocalRequest()); - String userName = user == null ? null : user.getUsername(); + String userName = null; + try { + userName = SessionUtil.getCurrentUser(this.getThreadLocalRequest()).getUsername(); - // TODO THIS IS A WORKAROUND WAITING FOR USER ROLE. + }catch (Exception e) { + LOG.info("User not found in session, so going to apply the acess policies"); + } + + // TODO THIS IS A WORKAROUND WAITING FOR ADOPTING OF USER ROLES. AT THE MOMENT, A USER AUTHENTICATED CAN ACCESS EVERYTHING // I CAN CHECK THE ACCCESS POLICIES IF AND ONLY IF THE USER IS NOT LOGGED IN. - if (user == null) { + if (userName == null) { // CHECKING ACCESS POLICY LOG.info("Applying access policies for concessione " + mongoId + " returned by service"); @@ -296,6 +311,8 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme if (layerPosizionamento != null) { if (!CheckAccessPolicyUtil.isAccessible(layerPosizionamento.getPolicy(), userName)) { concessionDV.setPosizionamentoScavo(null); + }else { + LOG.info("Posizionamento di Scavo is not accessible by current user"); } } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/CheckAccessPolicyUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/CheckAccessPolicyUtil.java index f4416d5..0be6c5b 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/CheckAccessPolicyUtil.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/CheckAccessPolicyUtil.java @@ -1,5 +1,7 @@ package org.gcube.portlets.user.geoportaldataviewer.server.util; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * The Class CheckAccessPolicyUtil. @@ -9,7 +11,8 @@ package org.gcube.portlets.user.geoportaldataviewer.server.util; * Sep 9, 2021 */ public class CheckAccessPolicyUtil { - + + private static final Logger LOG = LoggerFactory.getLogger(CheckAccessPolicyUtil.class); /** * The Enum ACCESS_POLICY. * @@ -67,8 +70,10 @@ public class CheckAccessPolicyUtil { return true; } + //From here managing is NOT OPEN access + if (myLogin == null || myLogin.isEmpty()) { - // is not open and the user is not authenticated + // here is not open and the user is not authenticated return false; } -- 2.17.1 From 85230de9bbabc62a32c1e69c13256f60125be00e Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 23 Sep 2021 18:18:02 +0200 Subject: [PATCH 32/38] #22042 Implemented the public access --- CHANGELOG.md | 1 + pom.xml | 5 + .../ApplicationProfileNotFoundException.java | 40 ++--- .../server/ConcessioniMongoService.java | 49 ------ .../server/ConcessioniMongoService2.java | 163 ++++++++++++++++++ .../GeoportalDataViewerServiceImpl.java | 43 +++-- .../geoportaldataviewer/server/TestModel.java | 124 ------------- .../ConcessioneImageUtil.java | 6 +- .../mongoservice/ConcessioniMongoService.java | 66 +++++++ .../ConcessioniMongoServiceIdentityProxy.java | 77 +++++++++ .../IAMClientCredentialsReader.java | 82 +++++++++ .../accessidentities/GcubeIdentity.java | 28 +++ .../IAMClientCredentials.java | 91 ++++++++++ .../accessidentities/IAMClientIdentity.java | 83 +++++++++ .../accessidentities/UserIdentity.java | 28 +++ .../accesspolicy/GeoNACheckAccessPolicy.java} | 8 +- .../server/util/SessionUtil.java | 40 ++++- .../ConcessioneReader.java | 60 +++++++ .../geoportaldataviewer/GetConcessione.java | 67 ------- .../user/geoportaldataviewer/IAMClient.java | 40 +++++ .../{TestShortener.java => Shortener.java} | 10 +- 21 files changed, 818 insertions(+), 293 deletions(-) delete mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConcessioniMongoService.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConcessioniMongoService2.java delete mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/TestModel.java rename src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/{ => mongoservice}/ConcessioneImageUtil.java (91%) create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/ConcessioniMongoService.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/ConcessioniMongoServiceIdentityProxy.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/IAMClientCredentialsReader.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentities/GcubeIdentity.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentities/IAMClientCredentials.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentities/IAMClientIdentity.java create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentities/UserIdentity.java rename src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/{util/CheckAccessPolicyUtil.java => mongoservice/accesspolicy/GeoNACheckAccessPolicy.java} (87%) create mode 100644 src/test/java/org/gcube/portlets/user/geoportaldataviewer/ConcessioneReader.java delete mode 100644 src/test/java/org/gcube/portlets/user/geoportaldataviewer/GetConcessione.java create mode 100644 src/test/java/org/gcube/portlets/user/geoportaldataviewer/IAMClient.java rename src/test/java/org/gcube/portlets/user/geoportaldataviewer/{TestShortener.java => Shortener.java} (84%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c56088..f35f630 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm [#20595] Porting and using the model view provided by geoportal-common [#21946] Show layers of a concessione automatically on map according to zoom level [#21976] Access policies checked on server-side +[#22042] Implemented the public access ## [v1.2.0-SNAPSHOT] - 2021-07-19 diff --git a/pom.xml b/pom.xml index bea5067..bc610d1 100644 --- a/pom.xml +++ b/pom.xml @@ -179,6 +179,11 @@ + + org.gcube.common + keycloak-client + [1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT) + com.liferay.portal portal-service diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ApplicationProfileNotFoundException.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ApplicationProfileNotFoundException.java index 436675c..b21b33d 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ApplicationProfileNotFoundException.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ApplicationProfileNotFoundException.java @@ -1,20 +1,20 @@ -package org.gcube.portlets.user.geoportaldataviewer.server; - -/** - * The Class ApplicationProfileException. - * - * @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it - * Sep 6, 2016 - */ -@SuppressWarnings("serial") -public class ApplicationProfileNotFoundException extends Exception { - - /** - * Instantiates a new application profile exception. - * - * @param message the message - */ - public ApplicationProfileNotFoundException(String message) { - super(message); - } -} \ No newline at end of file +//package org.gcube.portlets.user.geoportaldataviewer.server; +// +///** +// * The Class ApplicationProfileException. +// * +// * @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it +// * Sep 6, 2016 +// */ +//@SuppressWarnings("serial") +//public class ApplicationProfileNotFoundException extends Exception { +// +// /** +// * Instantiates a new application profile exception. +// * +// * @param message the message +// */ +// public ApplicationProfileNotFoundException(String message) { +// super(message); +// } +//} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConcessioniMongoService.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConcessioniMongoService.java deleted file mode 100644 index c3317db..0000000 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConcessioniMongoService.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.gcube.portlets.user.geoportaldataviewer.server; - -import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.statefulMongoConcessioni; - -import javax.servlet.http.HttpServletRequest; - -import org.gcube.application.geoportal.client.legacy.ConcessioniManagerI; -import org.gcube.application.geoportal.common.model.legacy.Concessione; -import org.gcube.portlets.user.geoportaldataviewer.server.util.SessionUtil; - - -/** - * The Class ConcessioniMongoService. - * - * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it - * - * Sep 9, 2021 - */ -public class ConcessioniMongoService { - - - /** - * Instantiates a new concessioni mongo service, interface for client statefulMongoConcessioni. - */ - public ConcessioniMongoService() { - } - - - /** - * Gets the item by id. - * - * @param request the request - * @param mongoItemId the mongo item id - * @return the item by id - * @throws Exception the exception - */ - Concessione getItemById(HttpServletRequest request, String mongoItemId) throws Exception{ - SessionUtil.getCurrentContext(request, true); - SessionUtil.getCurrentToken(request, true); - //Obtain the client - ConcessioniManagerI concessioniManager = statefulMongoConcessioni().build(); - //Returning item by Id - return concessioniManager.getById(mongoItemId); - } - - - - -} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConcessioniMongoService2.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConcessioniMongoService2.java new file mode 100644 index 0000000..729a247 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConcessioniMongoService2.java @@ -0,0 +1,163 @@ +//package org.gcube.portlets.user.geoportaldataviewer.server; +// +//import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.statefulMongoConcessioni; +// +//import javax.servlet.http.HttpServletRequest; +// +//import org.gcube.application.geoportal.client.legacy.ConcessioniManagerI; +//import org.gcube.application.geoportal.common.model.legacy.Concessione; +//import org.gcube.common.authorization.library.provider.AccessTokenProvider; +//import org.gcube.common.keycloak.KeycloakClientFactory; +//import org.gcube.common.keycloak.model.TokenResponse; +//import org.gcube.common.scope.api.ScopeProvider; +//import org.gcube.portlets.user.geoportaldataviewer.server.util.SessionUtil; +//import org.slf4j.Logger; +//import org.slf4j.LoggerFactory; +// +// +///** +// * The Class ConcessioniMongoServiceIdentityProxy. +// * +// * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it +// * +// * Sep 23, 2021 +// */ +//public class ConcessioniMongoService2 { +// +// private static final Logger LOG = LoggerFactory.getLogger(ConcessioniMongoService2.class); +// +// /** +// * Instantiates a new concessioni mongo service, interface for client +// * statefulMongoConcessioni. +// */ +// public ConcessioniMongoService2() { +// } +// +// /** +// * Gets the item by id. +// * +// * @param request the request +// * @param mongoItemId the mongo item id +// * @return the item by id +// * @throws Exception the exception +// */ +// public Concessione getItemById(HttpServletRequest request, String mongoItemId) throws Exception { +// LOG.info("called getItemById: " + mongoItemId); +// SessionUtil.getCurrentContext(request, true); +// SessionUtil.getCurrentToken(request, true); +// // Obtain the client +// ConcessioniManagerI concessioniManager = statefulMongoConcessioni().build(); +// // Returning item by Id +// return concessioniManager.getById(mongoItemId); +// } +// +// /** +// * Gets the item by id. +// * +// * @param request the request +// * @param mongoItemId the mongo item id +// * @return the item by id +// * @throws Exception the exception +// */ +// public Concessione getItemById(String mongoItemId) throws Exception { +// LOG.info("called getItemById: " + mongoItemId); +// ConcessioniManagerI concessioniManager = statefulMongoConcessioni().build(); +// // Returning item by Id +// return concessioniManager.getById(mongoItemId); +// } +// +// /** +// * Iam client get item by. +// * +// * @param scope the scope +// * @param mongoItemId the mongo item id +// * @param clientId the client id +// * @param clientSecret the secret +// * @return the concessione +// * @throws Exception the exception +// */ +// public Concessione iamClientGetItemBy(String scope, String mongoItemId, String clientId, String clientSecret) +// throws Exception { +// LOG.info("called IAM Client getItemById: " + mongoItemId); +// +// ScopeProvider.instance.set(scope); +// +// if (clientId == null) { +// throw new Exception("Invalid parameter 'clientId'"); +// } +// +// if (clientSecret == null) { +// throw new Exception("Invalid parameter 'secret'"); +// } +// +// String umaAcessToken = null; +// try { +// +// LOG.info("Querying KeycloakClientFactory to get UMA token.."); +// TokenResponse tr = KeycloakClientFactory.newInstance().queryUMAToken(clientId, clientSecret, scope, null); +// umaAcessToken = tr.getAccessToken(); +// if (umaAcessToken != null && !umaAcessToken.isEmpty()) { +// LOG.info("UMA Access Token read correctly"); +// } else { +// LOG.error("UMA Access Token NOT RETRIEVED!!!"); +// throw new Exception("UMA Access Token is null or empty"); +// } +// } catch (Exception e2) { +// throw new Exception("Error occurred on reading UMA access token:", e2); +// } +// +// String previousUMAToken = null; +// try { +// +// try { +// // Here the previousUMAToken should be null +// previousUMAToken = AccessTokenProvider.instance.get(); +// } catch (Exception e) { +// // catching excpetion to be sure +// // silent +// } +// +// LOG.debug("JWT token: " + umaAcessToken.substring(0, 20) + "_MASKED_TOKEN_"); +// LOG.info("Setting clientId '" + clientId + "' identity by JWT token in the " +// + AccessTokenProvider.class.getSimpleName()); +// AccessTokenProvider.instance.set(umaAcessToken); +// ConcessioniManagerI concessioniManager = statefulMongoConcessioni().build(); +// // Returning item by Id +// return concessioniManager.getById(mongoItemId); +// +// } catch (Exception e) { +// LOG.error(e.getMessage(), e); +// throw new Exception(e.getMessage()); +// } finally { +// try { +// AccessTokenProvider.instance.set(previousUMAToken); +// LOG.info("Done reset to prevoius UMA token into " + AccessTokenProvider.class.getSimpleName()); +// } catch (Exception e) { +// } +// } +// } +// +// /** +// * To concessione. +// * +// * @param jsonString the json string +// * @return the concessione +// */ +// public Concessione toConcessione(String jsonString) { +// LOG.info("toConcessione called"); +// try { +// return org.gcube.application.geoportal.client.utils.Serialization.read(jsonString, Concessione.class); +// } catch (Exception e) { +// LOG.warn("Error on serializing: ", e); +// return null; +// } +// } +// +// /* +// * For testing public Concessione iamClientGetItemBy(HttpServletRequest request, +// * String mongoItemId, String clientId, String secret) throws Exception { String +// * scope = SessionUtil.getCurrentContext(request, true); return +// * iamClientGetItemBy(scope, mongoItemId, clientId, secret); } +// */ +// +//} 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 e945088..501ac19 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 @@ -26,7 +26,9 @@ import org.gcube.application.geoportalcommon.util.URLParserUtil; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerService; import org.gcube.portlets.user.geoportaldataviewer.server.gis.FeatureParser; import org.gcube.portlets.user.geoportaldataviewer.server.gis.WMSUrlValidator; -import org.gcube.portlets.user.geoportaldataviewer.server.util.CheckAccessPolicyUtil; +import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.ConcessioneImageUtil; +import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.ConcessioniMongoServiceIdentityProxy; +import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accesspolicy.GeoNACheckAccessPolicy; import org.gcube.portlets.user.geoportaldataviewer.server.util.SessionUtil; import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject; @@ -142,8 +144,8 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme maxWFSFeature); LOG.debug("For layer name: " + layerObject.getLayerItem().getName() + " got features: " + features); geoDAO.setFeatures(features); - - //Getting the concessioneId from WFS features + + // Getting the concessioneId from WFS features for (FeatureRow fRow : features) { if (fRow.getMapProperties() != null) { List concessioneIds = fRow.getMapProperties().get("product_id"); @@ -216,15 +218,16 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme String userName = null; try { userName = SessionUtil.getCurrentUser(this.getThreadLocalRequest()).getUsername(); - }catch (Exception e) { + } catch (Exception e) { LOG.info("User not found in session, the userName for cecking policy will be null"); } if (itemType.equalsIgnoreCase("concessione")) { LOG.info("Trying to get concessione for id " + itemId); - ConcessioniMongoService cms = new ConcessioniMongoService(); - Concessione concessione = cms.getItemById(this.getThreadLocalRequest(), itemId); + ConcessioniMongoServiceIdentityProxy cms = new ConcessioniMongoServiceIdentityProxy( + this.getThreadLocalRequest()); + Concessione concessione = cms.getItemById(itemId); BaseConcessioneDV baseConcessione = ConvertToDataViewModel.toBaseConcessione(concessione); if (concessione != null) { @@ -233,7 +236,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme if (concessione.getPianteFineScavo() != null) { for (LayerConcessione lc : concessione.getPianteFineScavo()) { - if (CheckAccessPolicyUtil.isAccessible(lc.getPolicy().name(), userName)) { + if (GeoNACheckAccessPolicy.isAccessible(lc.getPolicy().name(), userName)) { listLayers.add(ConvertToDataViewModel.toLayerConcessione(lc, baseConcessione)); } } @@ -242,7 +245,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme if (lcPosizionamento != null) { - if (CheckAccessPolicyUtil.isAccessible(lcPosizionamento.getPolicy().name(), userName)) { + if (GeoNACheckAccessPolicy.isAccessible(lcPosizionamento.getPolicy().name(), userName)) { LayerConcessioneDV thePosizScavo = ConvertToDataViewModel .toLayerConcessione(lcPosizionamento, baseConcessione); @@ -286,8 +289,9 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme try { LOG.info("Trying to get record for id " + mongoId); - ConcessioniMongoService cms = new ConcessioniMongoService(); - Concessione concessione = cms.getItemById(this.getThreadLocalRequest(), mongoId); + ConcessioniMongoServiceIdentityProxy cms = new ConcessioniMongoServiceIdentityProxy( + this.getThreadLocalRequest()); + Concessione concessione = cms.getItemById(mongoId); LOG.info("Got concessione for mongoId: " + mongoId); if (concessione != null) { @@ -297,11 +301,12 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme try { userName = SessionUtil.getCurrentUser(this.getThreadLocalRequest()).getUsername(); - }catch (Exception e) { + } catch (Exception e) { LOG.info("User not found in session, so going to apply the acess policies"); } - // TODO THIS IS A WORKAROUND WAITING FOR ADOPTING OF USER ROLES. AT THE MOMENT, A USER AUTHENTICATED CAN ACCESS EVERYTHING + // TODO THIS IS A WORKAROUND WAITING FOR ADOPTING OF USER ROLES. AT THE MOMENT, + // A USER AUTHENTICATED CAN ACCESS EVERYTHING // I CAN CHECK THE ACCCESS POLICIES IF AND ONLY IF THE USER IS NOT LOGGED IN. if (userName == null) { @@ -309,9 +314,9 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme LOG.info("Applying access policies for concessione " + mongoId + " returned by service"); LayerConcessioneDV layerPosizionamento = concessionDV.getPosizionamentoScavo(); if (layerPosizionamento != null) { - if (!CheckAccessPolicyUtil.isAccessible(layerPosizionamento.getPolicy(), userName)) { + if (!GeoNACheckAccessPolicy.isAccessible(layerPosizionamento.getPolicy(), userName)) { concessionDV.setPosizionamentoScavo(null); - }else { + } else { LOG.info("Posizionamento di Scavo is not accessible by current user"); } } @@ -320,7 +325,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme if (listLayersDV != null) { List accessibleListLayersDV = new ArrayList(); for (LayerConcessioneDV layerDV : listLayersDV) { - if (CheckAccessPolicyUtil.isAccessible(layerDV.getPolicy(), userName)) { + if (GeoNACheckAccessPolicy.isAccessible(layerDV.getPolicy(), userName)) { accessibleListLayersDV.add(layerDV); } } @@ -329,14 +334,14 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme AbstractRelazioneScavoDV abstractRS = concessionDV.getAbstractRelazioneScavo(); if (abstractRS != null) { - if (!CheckAccessPolicyUtil.isAccessible(abstractRS.getPolicy(), userName)) { + if (!GeoNACheckAccessPolicy.isAccessible(abstractRS.getPolicy(), userName)) { concessionDV.setAbstractRelazioneScavo(null); } } RelazioneScavoDV relazioneScavo = concessionDV.getRelazioneScavo(); if (relazioneScavo != null) { - if (!CheckAccessPolicyUtil.isAccessible(relazioneScavo.getPolicy(), userName)) { + if (!GeoNACheckAccessPolicy.isAccessible(relazioneScavo.getPolicy(), userName)) { concessionDV.setRelazioneScavo(null); } } @@ -348,7 +353,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme // SHOWING ACESSIBLE IMAGES for (UploadedImageDV uploadedImageDV : immagini) { - if (CheckAccessPolicyUtil.isAccessible(uploadedImageDV.getPolicy(), userName)) { + if (GeoNACheckAccessPolicy.isAccessible(uploadedImageDV.getPolicy(), userName)) { accessibleListImages.add(uploadedImageDV); } @@ -495,7 +500,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); GeoportalCommon gc = new GeoportalCommon(); - return gc.getPublicLinksFor(item,true); + return gc.getPublicLinksFor(item, true); } catch (Exception e) { LOG.error("Error on getPublicLinksFor for: " + item, e); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/TestModel.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/TestModel.java deleted file mode 100644 index eedffc7..0000000 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/TestModel.java +++ /dev/null @@ -1,124 +0,0 @@ -//package org.gcube.portlets.user.geoportaldataviewer.server; -// -//import java.time.LocalDateTime; -//import java.util.ArrayList; -//import java.util.Arrays; -//import java.util.List; -// -//import org.gcube.application.geoportal.common.model.legacy.AccessPolicy; -//import org.gcube.application.geoportal.common.model.legacy.BBOX; -//import org.gcube.application.geoportal.common.model.legacy.Concessione; -//import org.gcube.application.geoportal.common.model.legacy.LayerConcessione; -//import org.gcube.application.geoportal.common.model.legacy.PersistedContent; -//import org.gcube.application.geoportal.common.model.legacy.RelazioneScavo; -//import org.gcube.application.geoportal.common.model.legacy.UploadedImage; -//import org.gcube.application.geoportal.common.model.legacy.WorkspaceContent; -// -// -//public class TestModel { -// -// public static Concessione prepareEmptyConcessione() { -// Concessione concessione = new Concessione(); -// -// // Generic fields -// -// // Concessione fields -// -// concessione.setNome("Italia, forse"); -// concessione.setIntroduzione("This is my project"); -// concessione.setDescrizioneContenuto("It contains this and that"); -// -// concessione.setAuthors(Arrays.asList(new String[] { "Some one", "Some, oneelse" })); -// -// concessione.setContributore("Contrib 1"); -// concessione.setTitolari(Arrays.asList(new String[] { "Some one", "Some, oneelse" })); -// concessione.setResponsabile("Someone"); -// concessione.setEditore("Editore"); -// -// concessione.setFontiFinanziamento(Arrays.asList(new String[] { "Big pharma", "Pentagon" })); -// -// concessione.setSoggetto(Arrays.asList(new String[] { "Research Excavation", "Archeology" })); -// -// concessione -// .setRisorseCorrelate(Arrays.asList(new String[] { "https://google.com", "https://www.repubblica.it" })); -// -// concessione.setDataInizioProgetto(LocalDateTime.now()); -// concessione.setDataFineProgetto(LocalDateTime.now()); -// -// concessione.setLicenzaID("CC-BY"); -// -// concessione.setTitolareLicenza("Qualcun altro"); -// concessione.setTitolareCopyright("Chiedilo in giro"); -// -// concessione.setParoleChiaveLibere(Arrays.asList(new String[] { "Robba", "Stuff" })); -// concessione.setParoleChiaveICCD(Arrays.asList(new String[] { "vattelapesca", "somthing something" })); -// -// concessione.setLastUpdateTime(LocalDateTime.now()); -// concessione.setCreationTime(LocalDateTime.now()); -// concessione.setLastUpdateUser("fake user"); -// -// concessione.setCentroidLat(43.0); // N-S -// concessione.setCentroidLong(9.0); // E-W -// -// return concessione; -// } -// -// public static Concessione prepareConcessione() { -// -// Concessione concessione = prepareEmptyConcessione(); -// -// // Attachments -// -// // Relazione scavo -// RelazioneScavo relScavo = new RelazioneScavo(); -// -// relScavo.setAbstractSection("simple abstract section"); -// relScavo.setResponsabili(concessione.getAuthors()); -// -// concessione.setRelazioneScavo(relScavo); -// // Immagini rappresentative -// ArrayList imgs = new ArrayList<>(); -// for (int i = 0; i < 5; i++) { -// UploadedImage img = new UploadedImage(); -// img.setTitolo("My image number " + i); -// img.setDidascalia("You can see my image number " + i); -// img.setFormat("TIFF"); -// img.setCreationTime(LocalDateTime.now()); -// img.setResponsabili(concessione.getAuthors()); -// List actualContentList = new ArrayList(1); -// WorkspaceContent ws = new WorkspaceContent(); -// ws.setLink("https://data.dev.d4science.org/shub/E_azRkaVhqTFExMzZvTG9pY0hwSFJNV2tVTHBEMGEycFVsQitvWjZvb29WZjkwRU84b1hXQnp0QjRuSGhrODJqQg=="); -// actualContentList.add(ws); -// img.setActualContent(actualContentList); -// imgs.add(img); -// } -// concessione.setImmaginiRappresentative(imgs); -// // Posizionamento -// LayerConcessione posizionamento = new LayerConcessione(); -// posizionamento.setValutazioneQualita("Secondo me si"); -// posizionamento.setMetodoRaccoltaDati("Fattobbene"); -// posizionamento.setScalaAcquisizione("1:10000"); -// posizionamento.setAuthors(concessione.getAuthors()); -// concessione.setPosizionamentoScavo(posizionamento); -// -// // Piante fine scavo -// ArrayList piante = new ArrayList(); -// for (int i = 0; i < 4; i++) { -// LayerConcessione pianta = new LayerConcessione(); -// pianta.setValutazioneQualita("Secondo me si"); -// pianta.setMetodoRaccoltaDati("Fattobbene"); -// pianta.setScalaAcquisizione("1:10000"); -// pianta.setAuthors(concessione.getAuthors()); -// pianta.setPolicy(AccessPolicy.RESTRICTED); -// pianta.setLayerName("gna_conc_12:pos"); -// pianta.setWmsLink( -// "https://geoserver1.dev.d4science.org/geoserver/gna_conc_12/wms?service=WMS&version=1.1.0&request=GetMap&layers=gna_conc_12:pos&styles=&bbox=8.62091913167495,40.62975046683799,8.621178639172953,40.630257904721645&width=392&height=768&srs=EPSG:4326&format=application/openlayers#toggle"); -// -// pianta.setBbox(new BBOX(40.630257904721645,8.621178639172953,40.62975046683799,8.62091913167495)); -// piante.add(pianta); -// } -// concessione.setPianteFineScavo(piante); -// -// return concessione; -// } -//} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConcessioneImageUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/ConcessioneImageUtil.java similarity index 91% rename from src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConcessioneImageUtil.java rename to src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/ConcessioneImageUtil.java index 6e52f6a..5309815 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConcessioneImageUtil.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/ConcessioneImageUtil.java @@ -1,4 +1,4 @@ -package org.gcube.portlets.user.geoportaldataviewer.server; +package org.gcube.portlets.user.geoportaldataviewer.server.mongoservice; import java.util.ArrayList; import java.util.List; @@ -50,8 +50,8 @@ public class ConcessioneImageUtil { if (itemType.equalsIgnoreCase("concessione")) { LOG.info("Trying to get concessione for id " + itemId); - ConcessioniMongoService cms = new ConcessioniMongoService(); - Concessione concessione = cms.getItemById(httpServletRequest, itemId); + ConcessioniMongoServiceIdentityProxy cms = new ConcessioniMongoServiceIdentityProxy(httpServletRequest); + Concessione concessione = cms.getItemById(itemId); if (concessione != null) { LOG.info("For id " + itemId + ", got concessione " + concessione.getNome() + " from service"); List images = concessione.getImmaginiRappresentative(); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/ConcessioniMongoService.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/ConcessioniMongoService.java new file mode 100644 index 0000000..2d1dc18 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/ConcessioniMongoService.java @@ -0,0 +1,66 @@ +package org.gcube.portlets.user.geoportaldataviewer.server.mongoservice; + +import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.statefulMongoConcessioni; + +import org.gcube.application.geoportal.client.legacy.ConcessioniManagerI; +import org.gcube.application.geoportal.common.model.legacy.Concessione; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +/** + * The Class ConcessioniMongoService. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Sep 23, 2021 + */ +public class ConcessioniMongoService { + + private static final Logger LOG = LoggerFactory.getLogger(ConcessioniMongoService.class); + + /** + * Instantiates a new concessioni mongo service. + */ + protected ConcessioniMongoService() { + } + + /** + * Gets the item by id. + * + * @param mongoItemId the mongo item id + * @return the item by id + * @throws Exception the exception + */ + protected Concessione getItemById(String mongoItemId) throws Exception { + LOG.info("called getItemById: " + mongoItemId); + ConcessioniManagerI concessioniManager = statefulMongoConcessioni().build(); + // Returning item by Id + return concessioniManager.getById(mongoItemId); + } + + + /** + * To concessione. + * + * @param jsonString the json string + * @return the concessione + */ + protected Concessione toConcessione(String jsonString) { + LOG.info("toConcessione called"); + try { + return org.gcube.application.geoportal.client.utils.Serialization.read(jsonString, Concessione.class); + } catch (Exception e) { + LOG.warn("Error on serializing: ", e); + return null; + } + } + + /* + * For testing public Concessione iamClientGetItemBy(HttpServletRequest request, + * String mongoItemId, String clientId, String secret) throws Exception { String + * scope = SessionUtil.getCurrentContext(request, true); return + * iamClientGetItemBy(scope, mongoItemId, clientId, secret); } + */ + +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/ConcessioniMongoServiceIdentityProxy.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/ConcessioniMongoServiceIdentityProxy.java new file mode 100644 index 0000000..b15fb78 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/ConcessioniMongoServiceIdentityProxy.java @@ -0,0 +1,77 @@ +package org.gcube.portlets.user.geoportaldataviewer.server.mongoservice; + +import javax.servlet.http.HttpServletRequest; + +import org.gcube.application.geoportal.common.model.legacy.Concessione; +import org.gcube.common.portal.PortalContext; +import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentities.GcubeIdentity; +import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentities.IAMClientIdentity; +import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentities.UserIdentity; +import org.gcube.portlets.user.geoportaldataviewer.server.util.SessionUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +/** + * The Class ConcessioniMongoServiceIdentityProxy. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Sep 23, 2021 + */ +public class ConcessioniMongoServiceIdentityProxy { + + private static final Logger LOG = LoggerFactory.getLogger(ConcessioniMongoServiceIdentityProxy.class); + + private GcubeIdentity gCubeIdentity; + + + /** + * Instantiates a new concessioni mongo service proxy. + * + * @param request the request + * @throws Exception the exception + */ + public ConcessioniMongoServiceIdentityProxy(HttpServletRequest request) throws Exception { + SessionUtil.getCurrentContext(request, true); + PortalContext pContext = PortalContext.getConfiguration(); + String username = null; + try { + username = pContext.getCurrentUser(request).getUsername(); + }catch (Exception e) { + LOG.info("Username not detected in session"); + } + if (username != null) { + LOG.info("User detected, using its identity"); + gCubeIdentity = new UserIdentity(); + } else { + LOG.info("User not detected, using IAM Client identity"); + gCubeIdentity = new IAMClientIdentity(); + } + + gCubeIdentity.setIdentity(request); + } + + + /** + * Gets the item by id. + * + * @param mongoItemId the mongo item id + * @return the item by id + * @throws Exception the exception + */ + public Concessione getItemById(String mongoItemId) throws Exception { + + try { + // Obtain the client + ConcessioniMongoService concessioniManager = new ConcessioniMongoService(); + // Returning item by Id + return concessioniManager.getItemById(mongoItemId); + }catch(Exception e) { + LOG.error("Error on reading itemById: "+mongoItemId, e); + throw(e); + }finally { + gCubeIdentity.resetIdentity(); + } + } +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/IAMClientCredentialsReader.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/IAMClientCredentialsReader.java new file mode 100644 index 0000000..6d1ab37 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/IAMClientCredentialsReader.java @@ -0,0 +1,82 @@ +package org.gcube.portlets.user.geoportaldataviewer.server.mongoservice; + +import static org.gcube.resources.discovery.icclient.ICFactory.clientFor; +import static org.gcube.resources.discovery.icclient.ICFactory.queryFor; + +import java.util.Collection; +import java.util.List; + +import org.gcube.common.encryption.StringEncrypter; +import org.gcube.common.resources.gcore.ServiceEndpoint; +import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint; +import org.gcube.common.scope.api.ScopeProvider; +import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentities.IAMClientCredentials; +import org.gcube.resources.discovery.client.api.DiscoveryClient; +import org.gcube.resources.discovery.client.queries.api.SimpleQuery; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * The Class IAMClientCredentialsReader. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Sep 23, 2021 + */ +public class IAMClientCredentialsReader { + + private static Logger LOG = LoggerFactory.getLogger(IAMClientCredentialsReader.class); + + private static final String SE_PROFILE_NAME = "geoportal-data-viewer-app"; + private static final String SE_CATEGORY_NAME = "SystemClient"; + + /** + * Gets the credentials. + * + * @return the credentials + * @throws Exception the exception + */ + public static IAMClientCredentials getCredentials() throws Exception { + + LOG.info("Searching SE in the scope: " + ScopeProvider.instance.get() + " with profile name: " + SE_PROFILE_NAME + + " and category name: " + SE_CATEGORY_NAME); + + SimpleQuery query = queryFor(ServiceEndpoint.class); + query.addCondition("$resource/Profile/Name/text() eq '" + SE_PROFILE_NAME + "'"); + query.addCondition("$resource/Profile/Category/text() eq '" + SE_CATEGORY_NAME + "'"); + + DiscoveryClient client = clientFor(ServiceEndpoint.class); + List resources = client.submit(query); + + if (resources.size() > 0) + LOG.info("The query returned " + resources.size() + " ServiceEndpoint/s"); + else + throw new RuntimeException("ServiceEndpoint not found. Searching for profile name: " + SE_PROFILE_NAME + + " and category name: " + SE_CATEGORY_NAME + "in the scope: " + ScopeProvider.instance.get()); + + ServiceEndpoint se = resources.get(0); + Collection theAccessPoints = se.profile().accessPoints().asCollection(); + String clientId = null; + String secredPwd = null; + for (AccessPoint accessPoint : theAccessPoints) { + clientId = accessPoint.username(); + secredPwd = accessPoint.password(); + LOG.debug("Found clientId: " + clientId + " and encrypted secret: " + secredPwd); + // decrypting the pwd + try { + if (secredPwd != null) { + secredPwd = StringEncrypter.getEncrypter().decrypt(secredPwd); + LOG.debug("Secret decrypted is: " + secredPwd.substring(0, secredPwd.length() / 2) + + "_MASKED_TOKEN_"); + } + } catch (Exception e) { + throw new RuntimeException("Error on decrypting the pwd: ", e); + } + } + + LOG.info("Returning keycloack credentials read from SE"); + return new IAMClientCredentials(clientId, secredPwd); + + } + +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentities/GcubeIdentity.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentities/GcubeIdentity.java new file mode 100644 index 0000000..ac81b18 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentities/GcubeIdentity.java @@ -0,0 +1,28 @@ +package org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentities; + +import javax.servlet.http.HttpServletRequest; + + +/** + * The Interface GcubeIdentity. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Sep 23, 2021 + */ +public interface GcubeIdentity { + + /** + * Sets the identity. + * + * @param httpRequest the new identity + * @throws Exception the exception + */ + public void setIdentity(HttpServletRequest httpRequest) throws Exception; + + /** + * Reset identity. + */ + public void resetIdentity(); + +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentities/IAMClientCredentials.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentities/IAMClientCredentials.java new file mode 100644 index 0000000..267b991 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentities/IAMClientCredentials.java @@ -0,0 +1,91 @@ +package org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentities; + +import java.io.Serializable; + + +/** + * The Class IAMClientCredentials. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Sep 23, 2021 + */ +public class IAMClientCredentials implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 7242909633989611318L; + private String clientId; + private String clientSecret; + + /** + * Instantiates a new IAM client credentials. + */ + public IAMClientCredentials() { + } + + /** + * Instantiates a new IAM client credentials. + * + * @param clientId the client id + * @param clientSecret the client secret + */ + public IAMClientCredentials(String clientId, String clientSecret) { + this.clientId = clientId; + this.clientSecret = clientSecret; + } + + /** + * Gets the client id. + * + * @return the client id + */ + public String getClientId() { + return clientId; + } + + /** + * Gets the client secret. + * + * @return the client secret + */ + public String getClientSecret() { + return clientSecret; + } + + /** + * Sets the client id. + * + * @param clientId the new client id + */ + public void setClientId(String clientId) { + this.clientId = clientId; + } + + /** + * Sets the client secret. + * + * @param clientSecret the new client secret + */ + public void setClientSecret(String clientSecret) { + this.clientSecret = clientSecret; + } + + /** + * To string. + * + * @return the string + */ + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("IAMClientCredentials [clientId="); + builder.append(clientId); + builder.append(", clientSecret="); + builder.append(clientSecret); + builder.append("]"); + return builder.toString(); + } + +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentities/IAMClientIdentity.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentities/IAMClientIdentity.java new file mode 100644 index 0000000..edf61e6 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentities/IAMClientIdentity.java @@ -0,0 +1,83 @@ +package org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentities; + +import javax.servlet.http.HttpServletRequest; + +import org.gcube.common.authorization.library.provider.AccessTokenProvider; +import org.gcube.common.keycloak.KeycloakClientFactory; +import org.gcube.common.keycloak.model.TokenResponse; +import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.IAMClientCredentialsReader; +import org.gcube.portlets.user.geoportaldataviewer.server.util.SessionUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class IAMClientIdentity implements GcubeIdentity { + + private static final Logger LOG = LoggerFactory.getLogger(IAMClientIdentity.class); + + private String previousUMAToken = null; + + @Override + public void setIdentity(HttpServletRequest httpRequest) throws Exception { + LOG.info("setIdentity called"); + String currentScope = SessionUtil.getCurrentContext(httpRequest, true); + IAMClientCredentials credentials = SessionUtil.getIAMClientCredentials(httpRequest); + try { + if(credentials==null) { + credentials = IAMClientCredentialsReader.getCredentials(); + SessionUtil.setIAMClientCredentials(httpRequest,credentials); + } + } catch (Exception e) { + LOG.error("Error on discovering IAM Client credentials", e); + throw new Exception("IAM Client discovery failed"); + } + + LOG.trace("Read credentials: " + credentials); + String umaAcessToken = null; + String clientId = credentials.getClientId(); + String clientSecret = credentials.getClientSecret(); + try { + + LOG.info("Querying KeycloakClientFactory to get UMA token.."); + TokenResponse tr = KeycloakClientFactory.newInstance().queryUMAToken(clientId, clientSecret, currentScope, + null); + umaAcessToken = tr.getAccessToken(); + if (umaAcessToken != null && !umaAcessToken.isEmpty()) { + LOG.info("UMA Access Token read correctly"); + } else { + LOG.error("UMA Access Token NOT RETRIEVED!!!"); + throw new Exception("UMA Access Token is null or empty"); + } + } catch (Exception e2) { + throw new Exception("Error occurred on reading UMA access token:", e2); + } + + try { + + try { + // Here the previousUMAToken should be null + previousUMAToken = AccessTokenProvider.instance.get(); + } catch (Exception e) { + // catching excpetion to be sure + // silent + } + + LOG.debug("JWT token: " + umaAcessToken.substring(0, 20) + "_MASKED_TOKEN_"); + LOG.info("Setting clientId '" + clientId + "' identity by JWT token in the " + + AccessTokenProvider.class.getSimpleName()); + AccessTokenProvider.instance.set(umaAcessToken); + } catch (Exception e) { + LOG.error(e.getMessage(), e); + throw new Exception(e.getMessage()); + } + + } + + @Override + public void resetIdentity() { + LOG.info("resetIdentity called"); + AccessTokenProvider.instance.set(previousUMAToken); + LOG.info("resetIdentity to previous AccessToken"); + + } + +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentities/UserIdentity.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentities/UserIdentity.java new file mode 100644 index 0000000..c59f0c0 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentities/UserIdentity.java @@ -0,0 +1,28 @@ +package org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentities; + +import javax.servlet.http.HttpServletRequest; + +import org.gcube.portlets.user.geoportaldataviewer.server.util.SessionUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class UserIdentity implements GcubeIdentity { + + private static final Logger LOG = LoggerFactory.getLogger(UserIdentity.class); + + public UserIdentity() { + } + + @Override + public void setIdentity(HttpServletRequest httpRequest) throws Exception { + LOG.info("setIdentity called"); + SessionUtil.getCurrentToken(httpRequest, true); + + } + + @Override + public void resetIdentity() { + LOG.info("resetIdentity called, doing nothing"); + // doing nothing + } +} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/CheckAccessPolicyUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accesspolicy/GeoNACheckAccessPolicy.java similarity index 87% rename from src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/CheckAccessPolicyUtil.java rename to src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accesspolicy/GeoNACheckAccessPolicy.java index 0be6c5b..6eeda7a 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/CheckAccessPolicyUtil.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accesspolicy/GeoNACheckAccessPolicy.java @@ -1,18 +1,18 @@ -package org.gcube.portlets.user.geoportaldataviewer.server.util; +package org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accesspolicy; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * The Class CheckAccessPolicyUtil. + * The Class GeoNACheckAccessPolicy. * * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * * Sep 9, 2021 */ -public class CheckAccessPolicyUtil { +public class GeoNACheckAccessPolicy { - private static final Logger LOG = LoggerFactory.getLogger(CheckAccessPolicyUtil.class); + private static final Logger LOG = LoggerFactory.getLogger(GeoNACheckAccessPolicy.class); /** * The Enum ACCESS_POLICY. * diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/SessionUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/SessionUtil.java index 7293449..7d1cf93 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/SessionUtil.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/SessionUtil.java @@ -14,7 +14,8 @@ import org.gcube.application.geoportalcommon.shared.products.model.UploadedImage import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.common.portal.PortalContext; import org.gcube.common.scope.api.ScopeProvider; -import org.gcube.portlets.user.geoportaldataviewer.server.ConcessioneImageUtil; +import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.ConcessioneImageUtil; +import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentities.IAMClientCredentials; import org.gcube.portlets.user.urlshortener.UrlShortener; import org.gcube.vomanagement.usermanagement.GroupManager; import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault; @@ -39,9 +40,11 @@ public class SessionUtil { /** The log. */ private static Logger LOG = LoggerFactory.getLogger(SessionUtil.class); - public static final String URL_SHORTENER_SERVICE = "URL_SHORTENER_SERVICE"; + private static final String URL_SHORTENER_SERVICE = "URL_SHORTENER_SERVICE"; - public static final String CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE = "MAP_IMAGE_PREVIEW_FOR_CONCESSIONE"; + private static final String CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE = "MAP_IMAGE_PREVIEW_FOR_CONCESSIONE"; + + private static final String IAM_CLIENT_CREDENTIALS = "IAM_CLIENT_CREDENTIALS"; /** * Checks if is into portal. @@ -222,4 +225,35 @@ public class SessionUtil { return lUI.get(0); } + + /** + * Gets the IAM client credentials. + * + * @param httpRequest the http request + * @return the IAM client credentials + */ + public static IAMClientCredentials getIAMClientCredentials(HttpServletRequest httpRequest) { + HttpSession session = httpRequest.getSession(); + try { + return (IAMClientCredentials) session.getAttribute(IAM_CLIENT_CREDENTIALS); + } catch (Exception e) { + LOG.warn("Error occurred when reading " + IAM_CLIENT_CREDENTIALS + " from session"); + return null; + } + } + + /** + * Sets the IAM client credentials. + * + * @param httpRequest the http request + * @param iamCC the iam CC + */ + public static void setIAMClientCredentials(HttpServletRequest httpRequest, IAMClientCredentials iamCC) { + HttpSession session = httpRequest.getSession(); + try { + session.setAttribute(IAM_CLIENT_CREDENTIALS, iamCC); + } catch (Exception e) { + LOG.warn("Error occurred when setting " + IAM_CLIENT_CREDENTIALS + " into session"); + } + } } diff --git a/src/test/java/org/gcube/portlets/user/geoportaldataviewer/ConcessioneReader.java b/src/test/java/org/gcube/portlets/user/geoportaldataviewer/ConcessioneReader.java new file mode 100644 index 0000000..dce5720 --- /dev/null +++ b/src/test/java/org/gcube/portlets/user/geoportaldataviewer/ConcessioneReader.java @@ -0,0 +1,60 @@ +package org.gcube.portlets.user.geoportaldataviewer; + +import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.statefulMongoConcessioni; + +import org.gcube.application.geoportal.client.legacy.ConcessioniManagerI; +import org.gcube.application.geoportal.common.model.legacy.Concessione; +import org.gcube.application.geoportalcommon.ConvertToDataViewModel; +import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; +import org.gcube.common.authorization.library.provider.SecurityTokenProvider; +import org.gcube.common.scope.api.ScopeProvider; + +public class ConcessioneReader { + + private static final String YOUR_TOKEN = ""; + + public static String SCOPE = "/gcube/devsec/devVRE"; + public static String mongoConcessioneID = "6102c07002ad3d05b5f81ddc"; + + //@Before + public void setEnviroment() { + ScopeProvider.instance.set(SCOPE); + SecurityTokenProvider.instance.set(YOUR_TOKEN); + + } + + //@Test + public void readConcessione() throws Exception { + System.out.println("getConcessioneForId " + mongoConcessioneID + "called"); + + ConcessioneDV concessionDV = null; + + if (mongoConcessioneID == null) + throw new Exception("Invalid parameter. The Id is null"); + + try { + System.out.println("Trying to get record for id " + mongoConcessioneID); + ConcessioniManagerI concessioniManager = statefulMongoConcessioni().build(); + Concessione concessione = concessioniManager.getById(mongoConcessioneID); + System.out.println("For id " + mongoConcessioneID + ", got concessione " + concessione); + System.out.println("Immagini Rappresentative are: " + concessione.getImmaginiRappresentative()); + System.out.println("Relazione scavo: " + concessione.getRelazioneScavo()); + System.out.println("Pianta Fine scavo: " + concessione.getPianteFineScavo()); + System.out.println("Posizionamento scavo: " + concessione.getPosizionamentoScavo()); + + if (concessione != null) { + concessionDV = ConvertToDataViewModel.toConcessione(concessione); + } + + if (concessionDV == null) + throw new Exception("Concessione not retrieved"); + + System.out.println("Got concessione: " + concessionDV); + + } catch (Exception e) { + String erroMsg = Concessione.class.getSimpleName() + " with id " + mongoConcessioneID + " not available"; + throw new Exception(erroMsg); + } + } + +} diff --git a/src/test/java/org/gcube/portlets/user/geoportaldataviewer/GetConcessione.java b/src/test/java/org/gcube/portlets/user/geoportaldataviewer/GetConcessione.java deleted file mode 100644 index 58b3a59..0000000 --- a/src/test/java/org/gcube/portlets/user/geoportaldataviewer/GetConcessione.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.gcube.portlets.user.geoportaldataviewer; - -import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.statefulMongoConcessioni; - -import org.gcube.application.geoportal.client.legacy.ConcessioniManagerI; -import org.gcube.application.geoportal.common.model.legacy.Concessione; -import org.gcube.application.geoportalcommon.ConvertToDataViewModel; -import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; -import org.gcube.common.authorization.library.provider.SecurityTokenProvider; -import org.gcube.common.scope.api.ScopeProvider; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class GetConcessione { - - private static final Logger LOG = LoggerFactory.getLogger(GetConcessione.class); - - private static final String YOUR_TOKEN = ""; - - public static String SCOPE = "/gcube/devsec/devVRE"; - public static String concessioneId = "6102c07002ad3d05b5f81ddc"; - - public static ConcessioneDV getConcessioneForId(String mongoID) throws Exception{ - LOG.info("getConcessioneForId "+mongoID+ "called"); - - ConcessioneDV concessionDV = null; - - if(mongoID==null) - throw new Exception("Invalid parameter. The Id is null"); - - try { - LOG.info("Trying to get record for id "+mongoID); - ConcessioniManagerI concessioniManager = statefulMongoConcessioni().build(); - Concessione concessione = concessioniManager.getById(mongoID); - LOG.info("For id "+mongoID+", got concessione "+concessione); - LOG.info("Immagini Rappresentative are: "+concessione.getImmaginiRappresentative()); - LOG.info("Relazione scavo: "+concessione.getRelazioneScavo()); - LOG.info("Pianta Fine scavo: "+concessione.getPianteFineScavo()); - LOG.info("Posizionamento scavo: "+concessione.getPosizionamentoScavo()); - - if(concessione !=null) { - concessionDV = ConvertToDataViewModel.toConcessione(concessione); - } - - if(concessionDV==null) - throw new Exception("Concessione not retrieved"); - - return concessionDV; - - }catch (Exception e) { - String erroMsg = Concessione.class.getSimpleName() +" with id "+mongoID+" not available"; - LOG.error(erroMsg,e); - throw new Exception(erroMsg); - } - - } - - public static void main(String[] args) throws Exception { - ScopeProvider.instance.set(SCOPE); - SecurityTokenProvider.instance.set(YOUR_TOKEN); - LOG.info("Trying to get record for id "+concessioneId); - ConcessioneDV concessione = getConcessioneForId(concessioneId); - LOG.info("Got record for id "+concessione); - } - - -} diff --git a/src/test/java/org/gcube/portlets/user/geoportaldataviewer/IAMClient.java b/src/test/java/org/gcube/portlets/user/geoportaldataviewer/IAMClient.java new file mode 100644 index 0000000..1df1bc7 --- /dev/null +++ b/src/test/java/org/gcube/portlets/user/geoportaldataviewer/IAMClient.java @@ -0,0 +1,40 @@ +package org.gcube.portlets.user.geoportaldataviewer; + +import java.util.List; + +import org.gcube.application.geoportal.common.model.legacy.Concessione; +import org.gcube.common.scope.api.ScopeProvider; +import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.IAMClientCredentialsReader; +import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentities.IAMClientCredentials; +import org.junit.Test; + +public class IAMClient { + + private static final String SCOPE = "/gcube/devsec/devVRE"; + private static final String MONGO_ITEM_ID = "614af6a502ad3d6128abd43f"; + + @Test + public void readCredentials() { + System.out.println("called readCredentials test"); + ScopeProvider.instance.set(SCOPE); + IAMClientCredentials credentials = null; + try { + credentials = IAMClientCredentialsReader.getCredentials(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + System.out.println("Read credentials: " + credentials); + Concessione concessione; + try { +// concessione = new ConcessioniMongoServiceIdentityProxy(); + + // System.out.println("Get concessione: " + concessione); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +} diff --git a/src/test/java/org/gcube/portlets/user/geoportaldataviewer/TestShortener.java b/src/test/java/org/gcube/portlets/user/geoportaldataviewer/Shortener.java similarity index 84% rename from src/test/java/org/gcube/portlets/user/geoportaldataviewer/TestShortener.java rename to src/test/java/org/gcube/portlets/user/geoportaldataviewer/Shortener.java index a13f365..ec844c5 100644 --- a/src/test/java/org/gcube/portlets/user/geoportaldataviewer/TestShortener.java +++ b/src/test/java/org/gcube/portlets/user/geoportaldataviewer/Shortener.java @@ -7,9 +7,11 @@ import java.util.Arrays; import org.gcube.common.scope.api.ScopeProvider; import org.gcube.portlets.user.urlshortener.UrlShortener; -public class TestShortener { +public class Shortener { - public static void main(String[] args) { + //@Test + public void availableInTheScope() { + System.out.println("called availableInTheScope test"); try { String toShort = "https://next.d4science.org/group/nextnext/geona-data-viewer"; String[] splitted = toShort.split("\\?"); @@ -27,12 +29,12 @@ public class TestShortener { System.out.println("encodedQuery is: "+encodedQuery); link = String.format("%s?%s", splitted[0], encodedQuery); } - ScopeProvider.instance.set("/gcube/devNext/NextNext"); + ScopeProvider.instance.set("/gcube/devsec/devVRE"); UrlShortener shortener = new UrlShortener(); System.out.println(shortener.shorten(link)); } catch (Exception e) { e.printStackTrace(); } - } + } -- 2.17.1 From 46ae55e8ddbef5fc3aacbd24b9732608743b8e71 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 24 Sep 2021 11:13:25 +0200 Subject: [PATCH 33/38] refactoring --- .../GeoportalDataViewerServiceImpl.java | 120 ++++++++++++- .../mongoservice/ConcessioneImageUtil.java | 166 +++++++++--------- .../accessidentities/IAMClientIdentity.java | 38 +++- .../server/util/SessionUtil.java | 132 +++++--------- 4 files changed, 279 insertions(+), 177 deletions(-) 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 501ac19..708d003 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 @@ -7,8 +7,12 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; + import org.gcube.application.geoportal.common.model.legacy.Concessione; import org.gcube.application.geoportal.common.model.legacy.LayerConcessione; +import org.gcube.application.geoportal.common.model.legacy.UploadedImage; import org.gcube.application.geoportalcommon.ConvertToDataViewModel; import org.gcube.application.geoportalcommon.GeoNaDataViewerProfileReader; import org.gcube.application.geoportalcommon.GeoportalCommon; @@ -26,7 +30,6 @@ import org.gcube.application.geoportalcommon.util.URLParserUtil; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerService; import org.gcube.portlets.user.geoportaldataviewer.server.gis.FeatureParser; import org.gcube.portlets.user.geoportaldataviewer.server.gis.WMSUrlValidator; -import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.ConcessioneImageUtil; import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.ConcessioniMongoServiceIdentityProxy; import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accesspolicy.GeoNACheckAccessPolicy; import org.gcube.portlets.user.geoportaldataviewer.server.util.SessionUtil; @@ -36,6 +39,7 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.FeatureRow; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformationForWMSRequest; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.Styles; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.ZAxis; +import org.gcube.portlets.user.urlshortener.UrlShortener; import org.gcube.spatial.data.geoutility.GeoNcWMSMetadataUtility; import org.gcube.spatial.data.geoutility.bean.LayerStyles; import org.gcube.spatial.data.geoutility.bean.LayerZAxis; @@ -60,6 +64,8 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme /** The Constant LOG. */ private static final Logger LOG = LoggerFactory.getLogger(GeoportalDataViewerServiceImpl.class); + private static final String CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE = "MAP_IMAGE_PREVIEW_FOR_CONCESSIONE"; + /** * Parses the wms request. * @@ -152,8 +158,8 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme if (concessioneIds != null && concessioneIds.size() > 0) { String cId = concessioneIds.get(0); try { - UploadedImageDV uplImg = SessionUtil - .getPreviewImageForConcessione(this.getThreadLocalRequest(), "Concessione", cId); + UploadedImageDV uplImg = sessionloadPreviewImageForConcessione(this.getThreadLocalRequest(), + "Concessione", cId); // List listUI = getUploadedImagesForId("Concessione", cId, 1); Map> mapImages = new LinkedHashMap>(); mapImages.put(cId, Arrays.asList(uplImg)); @@ -188,8 +194,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme throws Exception { LOG.info("getUploadedImagesForId [itemId: " + itemId + ", itemType: " + itemType + "] called"); - return new ConcessioneImageUtil().getUploadedImagesForId(this.getThreadLocalRequest(), itemType, itemId, - maxImages); + return getUploadedImagesForId(this.getThreadLocalRequest(), itemType, itemId, maxImages); } /** @@ -551,4 +556,109 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme return listDAO; } + /** + * Gets the preview image for concessione from http session. It is the first + * image retrieved from mongoService for mongoConcessioneId. Caching it into + * session + * + * @param httpServletRequest the http servlet request + * @param itemType the item type + * @param mongoConcessioneId the mongo concessione id + * @return the preview image for concessione + */ + private UploadedImageDV sessionloadPreviewImageForConcessione(HttpServletRequest httpServletRequest, + String itemType, String mongoConcessioneId) { + LOG.info("sessionloadPreviewImageForConcessione [mongoConcessioneId: " + mongoConcessioneId + ", itemType: " + + itemType + "] called"); + + HttpSession session = httpServletRequest.getSession(); + Map> mapImages = null; + List lUI = null; + try { + mapImages = (LinkedHashMap) session.getAttribute(CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE); + + if (mapImages == null) { + mapImages = new LinkedHashMap>(); + } + + List imagePreviewForConcessione = mapImages.get(mongoConcessioneId); + + if (imagePreviewForConcessione == null || imagePreviewForConcessione.size() == 0) { + LOG.info("Into " + CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE + " object session the mongoConcessioneId " + + mongoConcessioneId + " is empty or null, loading from service and filling it"); + lUI = getUploadedImagesForId(httpServletRequest, itemType, mongoConcessioneId, 1); + mapImages.put(mongoConcessioneId, lUI); + } + + lUI = mapImages.get(mongoConcessioneId); + LOG.info("From " + CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE + " object session read image: " + lUI); + session.setAttribute(CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE, mapImages); + + } catch (Exception e) { + LOG.warn("Error occurred when instancing the " + UrlShortener.class.getSimpleName(), e); + } + + if (lUI == null || lUI.isEmpty()) + return null; + + return lUI.get(0); + } + + /** + * Gets the uploaded images for id. + * + * @param httpServletRequest the http servlet request + * @param itemType the item type + * @param itemId the item id + * @param maxImages the max images + * @return the uploaded images for id + * @throws Exception the exception + */ + private List getUploadedImagesForId(HttpServletRequest httpServletRequest, String itemType, + String itemId, Integer maxImages) throws Exception { + LOG.info("getUploadedImagesForId [itemId: " + itemId + ", itemType: " + itemType + "] called"); + + if (itemType == null) + throw new Exception("Invalid parameter. The itemType is null"); + + if (itemId == null) + throw new Exception("Invalid parameter. The itemId is null"); + + List listUI = null; + + try { + + if (itemType.equalsIgnoreCase("concessione")) { + + LOG.info("Trying to get concessione for id " + itemId); + ConcessioniMongoServiceIdentityProxy cms = new ConcessioniMongoServiceIdentityProxy(httpServletRequest); + Concessione concessione = cms.getItemById(itemId); + if (concessione != null) { + LOG.info("For id " + itemId + ", got concessione " + concessione.getNome() + " from service"); + List images = concessione.getImmaginiRappresentative(); + + if (images != null) { + listUI = new ArrayList(); + int max = maxImages < images.size() ? maxImages : images.size(); + for (int i = 0; i < max; i++) { + UploadedImageDV ui = ConvertToDataViewModel.toUploadedImage(images.get(i)); + listUI.add(ui); + } + LOG.info("For id " + itemId + ", got " + listUI.size() + " image/s"); + } + } else + throw new Exception("Concessione with id '" + itemId + "' not available"); + } + + return listUI; + + } catch (Exception e) { + String erroMsg = UploadedImage.class.getSimpleName() + " not available for " + + Concessione.class.getSimpleName() + " with id " + itemId; + LOG.error(erroMsg, e); + throw new Exception(erroMsg); + } + + } + } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/ConcessioneImageUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/ConcessioneImageUtil.java index 5309815..99a6b04 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/ConcessioneImageUtil.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/ConcessioneImageUtil.java @@ -1,83 +1,83 @@ -package org.gcube.portlets.user.geoportaldataviewer.server.mongoservice; - -import java.util.ArrayList; -import java.util.List; - -import javax.servlet.http.HttpServletRequest; - -import org.gcube.application.geoportal.common.model.legacy.Concessione; -import org.gcube.application.geoportal.common.model.legacy.UploadedImage; -import org.gcube.application.geoportalcommon.ConvertToDataViewModel; -import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * The Class ConcessioneImageUtil. - * - * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it - * - * Sep 7, 2021 - */ -public class ConcessioneImageUtil { - - private static final Logger LOG = LoggerFactory.getLogger(ConcessioneImageUtil.class); - - /** - * Gets the uploaded images for id. - * - * @param httpServletRequest the http servlet request - * @param itemType the item type - * @param itemId the item id - * @param maxImages the max images - * @return the uploaded images for id - * @throws Exception the exception - */ - public List getUploadedImagesForId(HttpServletRequest httpServletRequest, String itemType, - String itemId, Integer maxImages) throws Exception { - LOG.info("getUploadedImagesForId [itemId: " + itemId + ", itemType: " + itemType + "] called"); - - if (itemType == null) - throw new Exception("Invalid parameter. The itemType is null"); - - if (itemId == null) - throw new Exception("Invalid parameter. The itemId is null"); - - List listUI = null; - - try { - - if (itemType.equalsIgnoreCase("concessione")) { - - LOG.info("Trying to get concessione for id " + itemId); - ConcessioniMongoServiceIdentityProxy cms = new ConcessioniMongoServiceIdentityProxy(httpServletRequest); - Concessione concessione = cms.getItemById(itemId); - if (concessione != null) { - LOG.info("For id " + itemId + ", got concessione " + concessione.getNome() + " from service"); - List images = concessione.getImmaginiRappresentative(); - - if (images != null) { - listUI = new ArrayList(); - int max = maxImages < images.size() ? maxImages : images.size(); - for (int i = 0; i < max; i++) { - UploadedImageDV ui = ConvertToDataViewModel.toUploadedImage(images.get(i)); - listUI.add(ui); - } - LOG.info("For id " + itemId + ", got " + listUI.size() + " image/s"); - } - } else - throw new Exception("Concessione with id '" + itemId + "' not available"); - } - - return listUI; - - } catch (Exception e) { - String erroMsg = UploadedImage.class.getSimpleName() + " not available for " - + Concessione.class.getSimpleName() + " with id " + itemId; - LOG.error(erroMsg, e); - throw new Exception(erroMsg); - } - - } - -} +//package org.gcube.portlets.user.geoportaldataviewer.server.mongoservice; +// +//import java.util.ArrayList; +//import java.util.List; +// +//import javax.servlet.http.HttpServletRequest; +// +//import org.gcube.application.geoportal.common.model.legacy.Concessione; +//import org.gcube.application.geoportal.common.model.legacy.UploadedImage; +//import org.gcube.application.geoportalcommon.ConvertToDataViewModel; +//import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV; +//import org.slf4j.Logger; +//import org.slf4j.LoggerFactory; +// +///** +// * The Class ConcessioneImageUtil. +// * +// * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it +// * +// * Sep 7, 2021 +// */ +//public class ConcessioneImageUtil { +// +// private static final Logger LOG = LoggerFactory.getLogger(ConcessioneImageUtil.class); +// +// /** +// * Gets the uploaded images for id. +// * +// * @param httpServletRequest the http servlet request +// * @param itemType the item type +// * @param itemId the item id +// * @param maxImages the max images +// * @return the uploaded images for id +// * @throws Exception the exception +// */ +// public List getUploadedImagesForId(HttpServletRequest httpServletRequest, String itemType, +// String itemId, Integer maxImages) throws Exception { +// LOG.info("getUploadedImagesForId [itemId: " + itemId + ", itemType: " + itemType + "] called"); +// +// if (itemType == null) +// throw new Exception("Invalid parameter. The itemType is null"); +// +// if (itemId == null) +// throw new Exception("Invalid parameter. The itemId is null"); +// +// List listUI = null; +// +// try { +// +// if (itemType.equalsIgnoreCase("concessione")) { +// +// LOG.info("Trying to get concessione for id " + itemId); +// ConcessioniMongoServiceIdentityProxy cms = new ConcessioniMongoServiceIdentityProxy(httpServletRequest); +// Concessione concessione = cms.getItemById(itemId); +// if (concessione != null) { +// LOG.info("For id " + itemId + ", got concessione " + concessione.getNome() + " from service"); +// List images = concessione.getImmaginiRappresentative(); +// +// if (images != null) { +// listUI = new ArrayList(); +// int max = maxImages < images.size() ? maxImages : images.size(); +// for (int i = 0; i < max; i++) { +// UploadedImageDV ui = ConvertToDataViewModel.toUploadedImage(images.get(i)); +// listUI.add(ui); +// } +// LOG.info("For id " + itemId + ", got " + listUI.size() + " image/s"); +// } +// } else +// throw new Exception("Concessione with id '" + itemId + "' not available"); +// } +// +// return listUI; +// +// } catch (Exception e) { +// String erroMsg = UploadedImage.class.getSimpleName() + " not available for " +// + Concessione.class.getSimpleName() + " with id " + itemId; +// LOG.error(erroMsg, e); +// throw new Exception(erroMsg); +// } +// +// } +// +//} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentities/IAMClientIdentity.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentities/IAMClientIdentity.java index edf61e6..01d319f 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentities/IAMClientIdentity.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentities/IAMClientIdentity.java @@ -1,6 +1,7 @@ package org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentities; import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; import org.gcube.common.authorization.library.provider.AccessTokenProvider; import org.gcube.common.keycloak.KeycloakClientFactory; @@ -15,16 +16,18 @@ public class IAMClientIdentity implements GcubeIdentity { private static final Logger LOG = LoggerFactory.getLogger(IAMClientIdentity.class); private String previousUMAToken = null; + + private static final String IAM_CLIENT_CREDENTIALS = "IAM_CLIENT_CREDENTIALS"; @Override public void setIdentity(HttpServletRequest httpRequest) throws Exception { LOG.info("setIdentity called"); String currentScope = SessionUtil.getCurrentContext(httpRequest, true); - IAMClientCredentials credentials = SessionUtil.getIAMClientCredentials(httpRequest); + IAMClientCredentials credentials = sessionGetIAMClientCredentials(httpRequest); try { if(credentials==null) { credentials = IAMClientCredentialsReader.getCredentials(); - SessionUtil.setIAMClientCredentials(httpRequest,credentials); + sessionSetIAMClientCredentials(httpRequest,credentials); } } catch (Exception e) { LOG.error("Error on discovering IAM Client credentials", e); @@ -79,5 +82,36 @@ public class IAMClientIdentity implements GcubeIdentity { LOG.info("resetIdentity to previous AccessToken"); } + + /** + * Gets the IAM client credentials. + * + * @param httpRequest the http request + * @return the IAM client credentials + */ + public static IAMClientCredentials sessionGetIAMClientCredentials(HttpServletRequest httpRequest) { + HttpSession session = httpRequest.getSession(); + try { + return (IAMClientCredentials) session.getAttribute(IAM_CLIENT_CREDENTIALS); + } catch (Exception e) { + LOG.warn("Error occurred when reading " + IAM_CLIENT_CREDENTIALS + " from session"); + return null; + } + } + + /** + * Sets the IAM client credentials. + * + * @param httpRequest the http request + * @param iamCC the iam CC + */ + public static void sessionSetIAMClientCredentials(HttpServletRequest httpRequest, IAMClientCredentials iamCC) { + HttpSession session = httpRequest.getSession(); + try { + session.setAttribute(IAM_CLIENT_CREDENTIALS, iamCC); + } catch (Exception e) { + LOG.warn("Error occurred when setting " + IAM_CLIENT_CREDENTIALS + " into session"); + } + } } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/SessionUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/SessionUtil.java index 7d1cf93..ed43dcf 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/SessionUtil.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/SessionUtil.java @@ -3,19 +3,12 @@ */ package org.gcube.portlets.user.geoportaldataviewer.server.util; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; -import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV; import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.common.portal.PortalContext; import org.gcube.common.scope.api.ScopeProvider; -import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.ConcessioneImageUtil; -import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentities.IAMClientCredentials; import org.gcube.portlets.user.urlshortener.UrlShortener; import org.gcube.vomanagement.usermanagement.GroupManager; import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault; @@ -42,10 +35,6 @@ public class SessionUtil { private static final String URL_SHORTENER_SERVICE = "URL_SHORTENER_SERVICE"; - private static final String CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE = "MAP_IMAGE_PREVIEW_FOR_CONCESSIONE"; - - private static final String IAM_CLIENT_CREDENTIALS = "IAM_CLIENT_CREDENTIALS"; - /** * Checks if is into portal. * @@ -180,80 +169,49 @@ public class SessionUtil { return shortener; } - /** - * Gets the preview image for concessione. It is the first image retrieved from - * mongoService for mongoConcessioneId. Caching it into session - * - * @param httpServletRequest the http servlet request - * @param itemType the item type - * @param mongoConcessioneId the mongo concessione id - * @return the preview image for concessione - */ - public static UploadedImageDV getPreviewImageForConcessione(HttpServletRequest httpServletRequest, String itemType, - String mongoConcessioneId) { - - HttpSession session = httpServletRequest.getSession(); - Map> mapImages = null; - List lUI = null; - try { - mapImages = (LinkedHashMap) session.getAttribute(CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE); - - if (mapImages == null) { - mapImages = new LinkedHashMap>(); - } - - List imagePreviewForConcessione = mapImages.get(mongoConcessioneId); - - if (imagePreviewForConcessione == null || imagePreviewForConcessione.size() == 0) { - LOG.info("Into " + CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE + " object session the mongoConcessioneId " - + mongoConcessioneId + " is empty or null, loading from service and filling it"); - lUI = new ConcessioneImageUtil().getUploadedImagesForId(httpServletRequest, itemType, - mongoConcessioneId, 1); - mapImages.put(mongoConcessioneId, lUI); - } - - lUI = mapImages.get(mongoConcessioneId); - LOG.info("From " + CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE + " object session read image: " + lUI); - session.setAttribute(CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE, mapImages); - - } catch (Exception e) { - LOG.warn("Error occurred when instancing the " + UrlShortener.class.getSimpleName(), e); - } - - if (lUI == null || lUI.isEmpty()) - return null; - - return lUI.get(0); - } - - /** - * Gets the IAM client credentials. - * - * @param httpRequest the http request - * @return the IAM client credentials - */ - public static IAMClientCredentials getIAMClientCredentials(HttpServletRequest httpRequest) { - HttpSession session = httpRequest.getSession(); - try { - return (IAMClientCredentials) session.getAttribute(IAM_CLIENT_CREDENTIALS); - } catch (Exception e) { - LOG.warn("Error occurred when reading " + IAM_CLIENT_CREDENTIALS + " from session"); - return null; - } - } - - /** - * Sets the IAM client credentials. - * - * @param httpRequest the http request - * @param iamCC the iam CC - */ - public static void setIAMClientCredentials(HttpServletRequest httpRequest, IAMClientCredentials iamCC) { - HttpSession session = httpRequest.getSession(); - try { - session.setAttribute(IAM_CLIENT_CREDENTIALS, iamCC); - } catch (Exception e) { - LOG.warn("Error occurred when setting " + IAM_CLIENT_CREDENTIALS + " into session"); - } - } +// /** +// * Gets the preview image for concessione. It is the first image retrieved from +// * mongoService for mongoConcessioneId. Caching it into session +// * +// * @param httpServletRequest the http servlet request +// * @param itemType the item type +// * @param mongoConcessioneId the mongo concessione id +// * @return the preview image for concessione +// */ +// public static UploadedImageDV getPreviewImageForConcessione(HttpServletRequest httpServletRequest, String itemType, +// String mongoConcessioneId) { +// +// HttpSession session = httpServletRequest.getSession(); +// Map> mapImages = null; +// List lUI = null; +// try { +// mapImages = (LinkedHashMap) session.getAttribute(CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE); +// +// if (mapImages == null) { +// mapImages = new LinkedHashMap>(); +// } +// +// List imagePreviewForConcessione = mapImages.get(mongoConcessioneId); +// +// if (imagePreviewForConcessione == null || imagePreviewForConcessione.size() == 0) { +// LOG.info("Into " + CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE + " object session the mongoConcessioneId " +// + mongoConcessioneId + " is empty or null, loading from service and filling it"); +// lUI = new ConcessioneImageUtil().getUploadedImagesForId(httpServletRequest, itemType, +// mongoConcessioneId, 1); +// mapImages.put(mongoConcessioneId, lUI); +// } +// +// lUI = mapImages.get(mongoConcessioneId); +// LOG.info("From " + CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE + " object session read image: " + lUI); +// session.setAttribute(CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE, mapImages); +// +// } catch (Exception e) { +// LOG.warn("Error occurred when instancing the " + UrlShortener.class.getSimpleName(), e); +// } +// +// if (lUI == null || lUI.isEmpty()) +// return null; +// +// return lUI.get(0); +// } } -- 2.17.1 From 6224dd7f7cf78db0502f816845d160ca06de9350 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 24 Sep 2021 13:14:02 +0200 Subject: [PATCH 34/38] #22040 Revisited the "Abstract e Relazione di Scavo". Removed commented code --- CHANGELOG.md | 1 + .../products/concessioni/ConcessioneView.java | 220 +++++++----------- .../concessioni/RelazioneScavoView.java | 104 +++++---- .../ApplicationProfileNotFoundException.java | 20 -- .../server/ConcessioniMongoService2.java | 163 ------------- .../server/gis/GisMakers.java | 4 +- .../server/gis/WMSUrlValidator.java | 1 - .../mongoservice/ConcessioneImageUtil.java | 83 ------- .../server/util/SessionUtil.java | 48 +--- .../shared/gis/wms/ZAxis.java | 24 +- .../user/geoportaldataviewer/IAMClient.java | 2 - 11 files changed, 156 insertions(+), 514 deletions(-) delete mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ApplicationProfileNotFoundException.java delete mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConcessioniMongoService2.java delete mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/ConcessioneImageUtil.java diff --git a/CHANGELOG.md b/CHANGELOG.md index f35f630..dd312ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm [#21946] Show layers of a concessione automatically on map according to zoom level [#21976] Access policies checked on server-side [#22042] Implemented the public access +[#22040] Revisited the "Abstract and Relazione di Scavo" ## [v1.2.0-SNAPSHOT] - 2021-07-19 diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java index bad8c0e..6610bf5 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java @@ -7,6 +7,7 @@ import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.model.AbstractRelazioneScavoDV; import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV; +import org.gcube.application.geoportalcommon.shared.products.model.RelazioneScavoDV; import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION; @@ -41,7 +42,7 @@ import com.google.gwt.user.client.ui.Widget; import ol.Coordinate; public class ConcessioneView extends Composite { - + private static ConcessioneViewUiBinder uiBinder = GWT.create(ConcessioneViewUiBinder.class); interface ConcessioneViewUiBinder extends UiBinder { @@ -52,10 +53,10 @@ public class ConcessioneView extends Composite { @UiField Paragraph introduzione; - + @UiField HTMLPanel concessioniPanel; - + @UiField HTMLPanel relazioneScavoPanel; @@ -67,19 +68,16 @@ public class ConcessioneView extends Composite { @UiField HTMLPanel mapViewPanel; - + @UiField HTMLPanel posizionamentoAreaIndaginePanel; - + @UiField HTMLPanel piantaFineScavoPanel; - -// @UiField -// HTMLPanel sharePanel; - + @UiField Button shareButton; - + @UiField Button expandButton; @@ -90,7 +88,7 @@ public class ConcessioneView extends Composite { private CustomFlexTable customTable = new CustomFlexTable(); private GeoNaItemRef geonaItemRef; - + private String myLogin; private boolean viewImageButtonVisible = true; @@ -101,36 +99,41 @@ public class ConcessioneView extends Composite { initWidget(uiBinder.createAndBindUi(this)); pageViewDetails.getElement().setId("page-view-details"); } - + public ConcessioneView(GeoNaItemRef item, ConcessioneDV concDV) { this(item, concDV, true, true); } - public ConcessioneView(GeoNaItemRef item, ConcessioneDV concDV, boolean viewImageButtonVisible, boolean openImageButtonVisible) { + public ConcessioneView(GeoNaItemRef item, ConcessioneDV concDV, boolean viewImageButtonVisible, + boolean openImageButtonVisible) { this(); - GWT.log("Rendering "+concDV.getNome()); + GWT.log("Rendering " + concDV.getNome()); this.concessioneDV = concDV; this.geonaItemRef = item; this.viewImageButtonVisible = viewImageButtonVisible; this.openImageButtonVisible = openImageButtonVisible; - + titolo.setText(concessioneDV.getNome()); introduzione.setText(concessioneDV.getIntroduzione()); if (concessioneDV.getDataInizioProgetto() != null) { - customTable.addNextKeyValue("Data Inizio Progetto", GeoportalDataViewerConstants.DT_FORMAT.format(concessioneDV.getDataInizioProgetto())); + customTable.addNextKeyValue("Data Inizio Progetto", + GeoportalDataViewerConstants.DT_FORMAT.format(concessioneDV.getDataInizioProgetto())); } if (concessioneDV.getDataFineProgetto() != null) { - customTable.addNextKeyValue("Data Fine Progetto", GeoportalDataViewerConstants.DT_FORMAT.format(concessioneDV.getDataFineProgetto())); + customTable.addNextKeyValue("Data Fine Progetto", + GeoportalDataViewerConstants.DT_FORMAT.format(concessioneDV.getDataFineProgetto())); } - + if (concessioneDV.getParoleChiaveLibere() != null) { - customTable.addNextKeyValues("Parole chiave Libere", concessioneDV.getParoleChiaveLibere(), GeoportalDataViewerConstants.NEW_LINE_BR); + customTable.addNextKeyValues("Parole chiave Libere", concessioneDV.getParoleChiaveLibere(), + GeoportalDataViewerConstants.NEW_LINE_BR); } if (concessioneDV.getParoleChiaveICCD() != null) { - customTable.addNextKeyValues("Parole chiave Cronologia", concessioneDV.getParoleChiaveICCD(), GeoportalDataViewerConstants.NEW_LINE_BR); + customTable.addNextKeyValues("Parole chiave Cronologia", concessioneDV.getParoleChiaveICCD(), + GeoportalDataViewerConstants.NEW_LINE_BR); } if (concessioneDV.getAuthors() != null) { @@ -144,21 +147,24 @@ public class ConcessioneView extends Composite { if (concessioneDV.getEditore() != null) { customTable.addNextKeyValue("Editore", concessioneDV.getEditore()); } - + if (concessioneDV.getResponsabile() != null) { customTable.addNextKeyValue("Responsabile", concessioneDV.getResponsabile()); } - + if (concessioneDV.getRisorseCorrelate() != null) { - customTable.addNextKeyValues("Risorse Correlate", concessioneDV.getRisorseCorrelate(), GeoportalDataViewerConstants.NEW_LINE_BR); + customTable.addNextKeyValues("Risorse Correlate", concessioneDV.getRisorseCorrelate(), + GeoportalDataViewerConstants.NEW_LINE_BR); } - + if (concessioneDV.getTitolari() != null) { - customTable.addNextKeyValues("Titolari dei dati", concessioneDV.getTitolari(), GeoportalDataViewerConstants.NEW_LINE_BR); + customTable.addNextKeyValues("Titolari dei dati", concessioneDV.getTitolari(), + GeoportalDataViewerConstants.NEW_LINE_BR); } - + if (concessioneDV.getSoggetto() != null) { - customTable.addNextKeyValues("Soggetti", concessioneDV.getSoggetto(), GeoportalDataViewerConstants.NEW_LINE_BR); + customTable.addNextKeyValues("Soggetti", concessioneDV.getSoggetto(), + GeoportalDataViewerConstants.NEW_LINE_BR); } if (concessioneDV.getEditore() != null) { @@ -166,60 +172,63 @@ public class ConcessioneView extends Composite { } if (concessioneDV.getFontiFinanziamento() != null) { - customTable.addNextKeyValues("Fonti di Finanziamento", concessioneDV.getFontiFinanziamento(), GeoportalDataViewerConstants.NEW_LINE_BR); + customTable.addNextKeyValues("Fonti di Finanziamento", concessioneDV.getFontiFinanziamento(), + GeoportalDataViewerConstants.NEW_LINE_BR); } - + if (concessioneDV.getLicenzaID() != null) { customTable.addNextKeyValue("ID Licenza", concessioneDV.getLicenzaID()); } - + if (concessioneDV.getTitolariLicenza() != null) { - customTable.addNextKeyValues("Titolare Licenza", concessioneDV.getTitolariLicenza(), GeoportalDataViewerConstants.NEW_LINE_BR); + customTable.addNextKeyValues("Titolare Licenza", concessioneDV.getTitolariLicenza(), + GeoportalDataViewerConstants.NEW_LINE_BR); } - + if (concessioneDV.getTitolariCopyright() != null) { - customTable.addNextKeyValues("Titolare Copyright", concessioneDV.getTitolariCopyright(),GeoportalDataViewerConstants.NEW_LINE_BR); + customTable.addNextKeyValues("Titolare Copyright", concessioneDV.getTitolariCopyright(), + GeoportalDataViewerConstants.NEW_LINE_BR); } - + shareButton.setType(ButtonType.LINK); shareButton.setIcon(IconType.SHARE); shareButton.setTitle("Get a link to share with..."); - + shareButton.addClickHandler(new ClickHandler() { - + @Override public void onClick(ClickEvent event) { DialogShareableLink dg = new DialogShareableLink(geonaItemRef, null); - + } }); - + expandButton.setType(ButtonType.LINK); expandButton.setIcon(IconType.EXPAND); expandButton.setTitle("Show this view in new Window"); - + expandButton.addClickHandler(new ClickHandler() { - + @Override public void onClick(ClickEvent event) { ConcessioneView cv = new ConcessioneView(geonaItemRef, concessioneDV, false, openImageButtonVisible); cv.setExpandViewButtonVisible(false); - int width = Window.getClientWidth()*75/100; - int height = Window.getClientHeight()*70/100; + int width = Window.getClientWidth() * 75 / 100; + int height = Window.getClientHeight() * 70 / 100; ModalWindow mw = new ModalWindow(concessioneDV.getNome(), width, height); mw.add(cv); mw.setCaller(ConcessioneView.this); - //mw.setWidth(900); + // mw.setWidth(900); mw.show(); - + } }); - + concessioniPanel.add(customTable); - + GeoportalDataViewerServiceAsync.Util.getInstance().getMyLogin(new AsyncCallback() { - + @Override public void onSuccess(String result) { myLogin = result; @@ -228,135 +237,84 @@ public class ConcessioneView extends Composite { addPosizionamentoAreaIndagine(); addPiantaFineScavo(); } - + @Override public void onFailure(Throwable caught) { } }); - + addUploadedImages(); } private void addPosizionamentoAreaIndagine() { - + LayerConcessioneDV layer = concessioneDV.getPosizionamentoScavo(); - if(layer==null) + if (layer == null) return; - - //NO LONGER NEEDED. MANAGED ON THE SERVER-SIDE #21976 -// if(layer.getPolicy()==null || layer.getPolicy().equalsIgnoreCase("OPEN")) { -// posizionamentoAreaIndaginePanel.setVisible(true); -// posizionamentoAreaIndaginePanel.add(new LayerConcessioneView(layer)); -// }else { -// //I need to be authenticated to show the fields according to POLICY -// if(myLogin!=null) { -// posizionamentoAreaIndaginePanel.setVisible(true); -// posizionamentoAreaIndaginePanel.add(new LayerConcessioneView(layer)); -// } -// -// } -// + posizionamentoAreaIndaginePanel.setVisible(true); posizionamentoAreaIndaginePanel.add(new LayerConcessioneView(layer)); - } - - + private void addPiantaFineScavo() { - + List listLayersDV = concessioneDV.getPianteFineScavo(); - - if(listLayersDV==null) + + if (listLayersDV == null) return; - - + for (LayerConcessioneDV layerDV : listLayersDV) { - - //NO LONGER NEEDED. MANAGED ON THE SERVER-SIDE #21976 -// if(layerDV.getPolicy()==null || layerDV.getPolicy().equalsIgnoreCase("OPEN")) { -// piantaFineScavoPanel.setVisible(true); -// piantaFineScavoPanel.add(new LayerConcessioneView(layerDV)); -// }else { -// //I need to be authenticated to show the fields according to POLICY -// if(myLogin!=null) { -// piantaFineScavoPanel.setVisible(true); -// piantaFineScavoPanel.add(new LayerConcessioneView(layerDV)); -// } -// } -// piantaFineScavoPanel.setVisible(true); piantaFineScavoPanel.add(new LayerConcessioneView(layerDV)); } - - } private void addRelazioneDiScavo() { - + AbstractRelazioneScavoDV abstractRS = concessioneDV.getAbstractRelazioneScavo(); - - if(abstractRS==null) + RelazioneScavoDV relazioneScavo = concessioneDV.getRelazioneScavo(); + if (abstractRS == null && relazioneScavo==null) return; - - //NO LONGER NEEDED. MANAGED ON THE SERVER-SIDE #21976 -// if(abstractRS.getPolicy()==null || abstractRS.getPolicy().equalsIgnoreCase("OPEN")) { -// relazioneScavoPanel.setVisible(true); -// relazioneScavoPanel.add(new RelazioneScavoView(abstractRS, concessioneDV.getRelazioneScavo(), false)); -// }else { -// //I need to be authenticated to show the fields according to POLICY -// if(myLogin!=null) { -// relazioneScavoPanel.setVisible(true); -// relazioneScavoPanel.add(new RelazioneScavoView(abstractRS, concessioneDV.getRelazioneScavo(), true)); -// } -// } - + relazioneScavoPanel.setVisible(true); relazioneScavoPanel.add(new RelazioneScavoView(abstractRS, concessioneDV.getRelazioneScavo())); } private void addCentroidMap() { -// Coordinate centerCoordinate = OLFactory.createCoordinate(GeoportalDataViewerConstants.ITALY_CENTER_LONG, GeoportalDataViewerConstants.ITALY_CENTER_LAT); -// Coordinate transformedCenterCoordinate = MapUtils.transformCoordiante(centerCoordinate, GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857); Location italyLocation = ExtentMapUtil.getLocation(PLACE.ITALY); - Coordinate transformedCenterCoordinate = italyLocation.getCoordinate(MAP_PROJECTION.EPSG_3857); - MapView mapView = new MapView(transformedCenterCoordinate, GeoportalDataViewerConstants.LIGHT_MAP_ITALY_FIT_ZOOM_ON, "70%", "300px"); - - if(concessioneDV!=null && concessioneDV.getCentroidLat()!=null && concessioneDV.getCentroidLong()!=null) { + Coordinate transformedCenterCoordinate = italyLocation.getCoordinate(MAP_PROJECTION.EPSG_3857); + MapView mapView = new MapView(transformedCenterCoordinate, + GeoportalDataViewerConstants.LIGHT_MAP_ITALY_FIT_ZOOM_ON, "70%", "300px"); + + if (concessioneDV != null && concessioneDV.getCentroidLat() != null + && concessioneDV.getCentroidLong() != null) { Coordinate coord = new Coordinate(concessioneDV.getCentroidLong(), concessioneDV.getCentroidLat()); - Coordinate transfCoord = MapUtils.transformCoordiante(coord, MAP_PROJECTION.EPSG_4326.getName(), MAP_PROJECTION.EPSG_3857.getName()); - //Coordinate invertedCoordinate = MapUtils.reverseCoordinate(coord); - boolean authenticatedUser = myLogin!=null?true:false; + Coordinate transfCoord = MapUtils.transformCoordiante(coord, MAP_PROJECTION.EPSG_4326.getName(), + MAP_PROJECTION.EPSG_3857.getName()); + // Coordinate invertedCoordinate = MapUtils.reverseCoordinate(coord); + boolean authenticatedUser = myLogin != null ? true : false; mapView.addMarker(transfCoord, authenticatedUser); mapViewPanel.add(mapView); - }else if(concessioneDV!=null){ - GeoportalDataViewerConstants.printJs("I cannot add centroid as maker one or both coordinates are null. Lat: "+concessioneDV.getCentroidLong() +", Long:"+concessioneDV.getCentroidLat()); + } else if (concessioneDV != null) { + GeoportalDataViewerConstants + .printJs("I cannot add centroid as maker one or both coordinates are null. Lat: " + + concessioneDV.getCentroidLong() + ", Long:" + concessioneDV.getCentroidLat()); } } private void addUploadedImages() { - GWT.log("Managing immagini: "+concessioneDV.getImmaginiRappresentative()); + GWT.log("Managing immagini: " + concessioneDV.getImmaginiRappresentative()); List immagini = concessioneDV.getImmaginiRappresentative(); if (immagini != null && immagini.size() > 0) { imagesPanel.setVisible(true); - + List immaginiToShow = new ArrayList(); - //SHOWING ONLY OPEN IMAGES OR IF THE USER IS LOGGED for (UploadedImageDV uploadedImageDV : immagini) { - - //NO LONGER NEEDED. MANAGED ON THE SERVER-SIDE #21976 -// if(uploadedImageDV.getPolicy()==null || uploadedImageDV.getPolicy().equalsIgnoreCase("OPEN")) { -// immaginiToShow.add(uploadedImageDV); -// }else { -// if(myLogin!=null) { -// immaginiToShow.add(uploadedImageDV); -// } -// } -// immaginiToShow.add(uploadedImageDV); } - - if(immaginiToShow.size()>0) { + + if (immaginiToShow.size() > 0) { ImagesGallery gallery = new ImagesGallery(immaginiToShow); imagesPanel.add(gallery.getGalleryPanel()); gallery.fillGallery(); @@ -367,7 +325,7 @@ public class ConcessioneView extends Composite { public ConcessioneDV getConcessioneDV() { return concessioneDV; } - + protected void setExpandViewButtonVisible(boolean bool) { expandButton.setVisible(bool); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/RelazioneScavoView.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/RelazioneScavoView.java index 577151b..ead6659 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/RelazioneScavoView.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/RelazioneScavoView.java @@ -30,86 +30,90 @@ public class RelazioneScavoView extends Composite { interface RelazioneScavoViewUiBinder extends UiBinder { } - + @UiField HTMLPanel relazioneScavoPanel; - + @UiField Paragraph abstractParagraphIta; - + @UiField Paragraph abstractParagraphEng; - + @UiField Button linkAbstractLanguage; - + private CustomFlexTable customTable = new CustomFlexTable(); - - - public RelazioneScavoView(AbstractRelazioneScavoDV abstractDV, RelazioneScavoDV relazioneScavoDV) { + + public RelazioneScavoView(AbstractRelazioneScavoDV abstractRelazioneDV, RelazioneScavoDV relazioneScavoDV) { initWidget(uiBinder.createAndBindUi(this)); - - if(abstractDV.getAbstractSectionIta()!=null) { - abstractParagraphIta.setText(abstractDV.getAbstractSectionIta()); - if(abstractDV.getAbstractSectionEng()!=null) { - linkAbstractLanguage.setVisible(true); - abstractParagraphEng.setText(abstractDV.getAbstractSectionEng()); - linkAbstractLanguage.setText(SHOW_ENGLISH_DESCR); + GWT.log("Showing abstract: "+abstractRelazioneDV); + GWT.log("Showing relazioneScavoDV: "+relazioneScavoDV); + + if (abstractRelazioneDV != null) { + relazioneScavoPanel.setVisible(true); + if (abstractRelazioneDV.getAbstractSectionIta() != null) { + abstractParagraphIta.setText(abstractRelazioneDV.getAbstractSectionIta()); + if (abstractRelazioneDV.getAbstractSectionEng() != null) { + linkAbstractLanguage.setVisible(true); + abstractParagraphEng.setText(abstractRelazioneDV.getAbstractSectionEng()); + linkAbstractLanguage.setText(SHOW_ENGLISH_DESCR); + } } + + showLinkToDownloadWsContent("Abstract Relazione", abstractRelazioneDV.getListWsContent()); } - - if(relazioneScavoDV==null) - return; - - - //customTable.addNextKeyValue("Created", relazioneScavoDV.getCreationTime()); - //customTable.addNextKeyValue("ID Licenza", relazioneScavoDV.getLicenseID()); - customTable.addNextKeyValues("Responsabili", relazioneScavoDV.getResponsabili(), GeoportalDataViewerConstants.NEW_LINE_BR); - linkAbstractLanguage.addClickHandler(new ClickHandler() { - + @Override public void onClick(ClickEvent event) { GWT.log("Clicked"); - if(abstractParagraphIta.isVisible()) { + if (abstractParagraphIta.isVisible()) { linkAbstractLanguage.setText(SHOW_ITALIAN_DESCR); abstractParagraphIta.setVisible(false); abstractParagraphEng.setVisible(true); - }else { + } else { linkAbstractLanguage.setText(SHOW_ENGLISH_DESCR); abstractParagraphIta.setVisible(true); abstractParagraphEng.setVisible(false); } - + } }); - //Showing the Download PDF relazione accoding to policy - //NO LONGER NEEDED. MANAGED ON THE SERVER-SIDE #21976 -// if(relazioneScavoDV.getPolicy()==null || relazioneScavoDV.getPolicy().equalsIgnoreCase("OPEN")) { -// relazioneScavoPanel.setVisible(true); -// showLintToDownloadLastContent(relazioneScavoDV.getListWsContent()); -// //DOWNLOAD RS -// }else { -// //I need to be authenticated to show the fields according to POLICY -// if(autheticatedUser) { -// showLintToDownloadLastContent(relazioneScavoDV.getListWsContent()); -// } -// } -// - relazioneScavoPanel.setVisible(true); - showLintToDownloadLastContent(relazioneScavoDV.getListWsContent()); + if (relazioneScavoDV != null) { + relazioneScavoPanel.setVisible(true); + // customTable.addNextKeyValue("Created", relazioneScavoDV.getCreationTime()); + // customTable.addNextKeyValue("ID Licenza", relazioneScavoDV.getLicenseID()); + customTable.addNextKeyValues("Responsabili", relazioneScavoDV.getResponsabili(), + GeoportalDataViewerConstants.NEW_LINE_BR); + + showLinkToDownloadWsContent("Relazione", relazioneScavoDV.getListWsContent()); + } relazioneScavoPanel.add(customTable); } - - private void showLintToDownloadLastContent(List listContent) { - if(listContent!=null) { - int size = listContent.size(); - WorkspaceContentDV lastDoc = listContent.get(size-1); - customTable.addNextKeyWidget("PDF Relazione", new HTML("download")); + + private void showLinkToDownloadWsContent(String title, List listContent) { + if (listContent != null) { + int i = 0; + String fieldLabel = title; + for (WorkspaceContentDV workspaceContentDV : listContent) { + + if (i > 0) { + fieldLabel = ""; + } + + String downloadLabel = "download"; + if(workspaceContentDV.getName()!=null) { + downloadLabel = workspaceContentDV.getName(); + } + + customTable.addNextKeyWidget(fieldLabel, new HTML( + "" + downloadLabel + "")); + } } } - + } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ApplicationProfileNotFoundException.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ApplicationProfileNotFoundException.java deleted file mode 100644 index b21b33d..0000000 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ApplicationProfileNotFoundException.java +++ /dev/null @@ -1,20 +0,0 @@ -//package org.gcube.portlets.user.geoportaldataviewer.server; -// -///** -// * The Class ApplicationProfileException. -// * -// * @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it -// * Sep 6, 2016 -// */ -//@SuppressWarnings("serial") -//public class ApplicationProfileNotFoundException extends Exception { -// -// /** -// * Instantiates a new application profile exception. -// * -// * @param message the message -// */ -// public ApplicationProfileNotFoundException(String message) { -// super(message); -// } -//} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConcessioniMongoService2.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConcessioniMongoService2.java deleted file mode 100644 index 729a247..0000000 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConcessioniMongoService2.java +++ /dev/null @@ -1,163 +0,0 @@ -//package org.gcube.portlets.user.geoportaldataviewer.server; -// -//import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.statefulMongoConcessioni; -// -//import javax.servlet.http.HttpServletRequest; -// -//import org.gcube.application.geoportal.client.legacy.ConcessioniManagerI; -//import org.gcube.application.geoportal.common.model.legacy.Concessione; -//import org.gcube.common.authorization.library.provider.AccessTokenProvider; -//import org.gcube.common.keycloak.KeycloakClientFactory; -//import org.gcube.common.keycloak.model.TokenResponse; -//import org.gcube.common.scope.api.ScopeProvider; -//import org.gcube.portlets.user.geoportaldataviewer.server.util.SessionUtil; -//import org.slf4j.Logger; -//import org.slf4j.LoggerFactory; -// -// -///** -// * The Class ConcessioniMongoServiceIdentityProxy. -// * -// * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it -// * -// * Sep 23, 2021 -// */ -//public class ConcessioniMongoService2 { -// -// private static final Logger LOG = LoggerFactory.getLogger(ConcessioniMongoService2.class); -// -// /** -// * Instantiates a new concessioni mongo service, interface for client -// * statefulMongoConcessioni. -// */ -// public ConcessioniMongoService2() { -// } -// -// /** -// * Gets the item by id. -// * -// * @param request the request -// * @param mongoItemId the mongo item id -// * @return the item by id -// * @throws Exception the exception -// */ -// public Concessione getItemById(HttpServletRequest request, String mongoItemId) throws Exception { -// LOG.info("called getItemById: " + mongoItemId); -// SessionUtil.getCurrentContext(request, true); -// SessionUtil.getCurrentToken(request, true); -// // Obtain the client -// ConcessioniManagerI concessioniManager = statefulMongoConcessioni().build(); -// // Returning item by Id -// return concessioniManager.getById(mongoItemId); -// } -// -// /** -// * Gets the item by id. -// * -// * @param request the request -// * @param mongoItemId the mongo item id -// * @return the item by id -// * @throws Exception the exception -// */ -// public Concessione getItemById(String mongoItemId) throws Exception { -// LOG.info("called getItemById: " + mongoItemId); -// ConcessioniManagerI concessioniManager = statefulMongoConcessioni().build(); -// // Returning item by Id -// return concessioniManager.getById(mongoItemId); -// } -// -// /** -// * Iam client get item by. -// * -// * @param scope the scope -// * @param mongoItemId the mongo item id -// * @param clientId the client id -// * @param clientSecret the secret -// * @return the concessione -// * @throws Exception the exception -// */ -// public Concessione iamClientGetItemBy(String scope, String mongoItemId, String clientId, String clientSecret) -// throws Exception { -// LOG.info("called IAM Client getItemById: " + mongoItemId); -// -// ScopeProvider.instance.set(scope); -// -// if (clientId == null) { -// throw new Exception("Invalid parameter 'clientId'"); -// } -// -// if (clientSecret == null) { -// throw new Exception("Invalid parameter 'secret'"); -// } -// -// String umaAcessToken = null; -// try { -// -// LOG.info("Querying KeycloakClientFactory to get UMA token.."); -// TokenResponse tr = KeycloakClientFactory.newInstance().queryUMAToken(clientId, clientSecret, scope, null); -// umaAcessToken = tr.getAccessToken(); -// if (umaAcessToken != null && !umaAcessToken.isEmpty()) { -// LOG.info("UMA Access Token read correctly"); -// } else { -// LOG.error("UMA Access Token NOT RETRIEVED!!!"); -// throw new Exception("UMA Access Token is null or empty"); -// } -// } catch (Exception e2) { -// throw new Exception("Error occurred on reading UMA access token:", e2); -// } -// -// String previousUMAToken = null; -// try { -// -// try { -// // Here the previousUMAToken should be null -// previousUMAToken = AccessTokenProvider.instance.get(); -// } catch (Exception e) { -// // catching excpetion to be sure -// // silent -// } -// -// LOG.debug("JWT token: " + umaAcessToken.substring(0, 20) + "_MASKED_TOKEN_"); -// LOG.info("Setting clientId '" + clientId + "' identity by JWT token in the " -// + AccessTokenProvider.class.getSimpleName()); -// AccessTokenProvider.instance.set(umaAcessToken); -// ConcessioniManagerI concessioniManager = statefulMongoConcessioni().build(); -// // Returning item by Id -// return concessioniManager.getById(mongoItemId); -// -// } catch (Exception e) { -// LOG.error(e.getMessage(), e); -// throw new Exception(e.getMessage()); -// } finally { -// try { -// AccessTokenProvider.instance.set(previousUMAToken); -// LOG.info("Done reset to prevoius UMA token into " + AccessTokenProvider.class.getSimpleName()); -// } catch (Exception e) { -// } -// } -// } -// -// /** -// * To concessione. -// * -// * @param jsonString the json string -// * @return the concessione -// */ -// public Concessione toConcessione(String jsonString) { -// LOG.info("toConcessione called"); -// try { -// return org.gcube.application.geoportal.client.utils.Serialization.read(jsonString, Concessione.class); -// } catch (Exception e) { -// LOG.warn("Error on serializing: ", e); -// return null; -// } -// } -// -// /* -// * For testing public Concessione iamClientGetItemBy(HttpServletRequest request, -// * String mongoItemId, String clientId, String secret) throws Exception { String -// * scope = SessionUtil.getCurrentContext(request, true); return -// * iamClientGetItemBy(scope, mongoItemId, clientId, secret); } -// */ -// -//} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/gis/GisMakers.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/gis/GisMakers.java index 24469bf..faf168d 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/gis/GisMakers.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/gis/GisMakers.java @@ -75,7 +75,7 @@ public class GisMakers { LOG.debug("wms url contains wxs is a map server? no appending /wfs "); outputformat = MapServerRecognize.outputFormatRecognize(SERVERTYPE.MAPSERVER, outputFormat); boundingBox = BBOX_FORMAT(COORDINATE_FORMAT.YX, ",",mapBBOX.getLowerLeftX(),mapBBOX.getLowerLeftY(),mapBBOX.getUpperRightX(),mapBBOX.getUpperRightY()); // USE AXIS XY - // TODO DEBUG + // DEBUG LOG.debug("SERVERTYPE.MAPSERVER outputformat: " + outputformat); LOG.debug("SERVERTYPE.MAPSERVER srsName: " + mapSrsName); LOG.debug("SERVERTYPE.MAPSERVER boundingBox: " + boundingBox); @@ -85,7 +85,7 @@ public class GisMakers { outputformat = MapServerRecognize.outputFormatRecognize(SERVERTYPE.GEOSEVER, outputFormat); mapSrsName = "urn:x-ogc:def:crs:"+mapSrsName; boundingBox = BBOX_FORMAT(COORDINATE_FORMAT.YX, ",",mapBBOX.getLowerLeftX(),mapBBOX.getLowerLeftY(),mapBBOX.getUpperRightX(),mapBBOX.getUpperRightY()); // USE AXIS XY - // TODO DEBUG + // DEBUG LOG.debug("SERVERTYPE.GEOSEVER outputformat: " + outputformat); LOG.debug("SERVERTYPE.GEOSEVER srsName: " + mapSrsName); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/gis/WMSUrlValidator.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/gis/WMSUrlValidator.java index 8e22431..2be8861 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/gis/WMSUrlValidator.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/gis/WMSUrlValidator.java @@ -395,7 +395,6 @@ public class WMSUrlValidator { System.out.println("Returned wms: "+wms.toString()); } catch (Exception e) { - // TODO Auto-generated catch block e.printStackTrace(); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/ConcessioneImageUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/ConcessioneImageUtil.java deleted file mode 100644 index 99a6b04..0000000 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/ConcessioneImageUtil.java +++ /dev/null @@ -1,83 +0,0 @@ -//package org.gcube.portlets.user.geoportaldataviewer.server.mongoservice; -// -//import java.util.ArrayList; -//import java.util.List; -// -//import javax.servlet.http.HttpServletRequest; -// -//import org.gcube.application.geoportal.common.model.legacy.Concessione; -//import org.gcube.application.geoportal.common.model.legacy.UploadedImage; -//import org.gcube.application.geoportalcommon.ConvertToDataViewModel; -//import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV; -//import org.slf4j.Logger; -//import org.slf4j.LoggerFactory; -// -///** -// * The Class ConcessioneImageUtil. -// * -// * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it -// * -// * Sep 7, 2021 -// */ -//public class ConcessioneImageUtil { -// -// private static final Logger LOG = LoggerFactory.getLogger(ConcessioneImageUtil.class); -// -// /** -// * Gets the uploaded images for id. -// * -// * @param httpServletRequest the http servlet request -// * @param itemType the item type -// * @param itemId the item id -// * @param maxImages the max images -// * @return the uploaded images for id -// * @throws Exception the exception -// */ -// public List getUploadedImagesForId(HttpServletRequest httpServletRequest, String itemType, -// String itemId, Integer maxImages) throws Exception { -// LOG.info("getUploadedImagesForId [itemId: " + itemId + ", itemType: " + itemType + "] called"); -// -// if (itemType == null) -// throw new Exception("Invalid parameter. The itemType is null"); -// -// if (itemId == null) -// throw new Exception("Invalid parameter. The itemId is null"); -// -// List listUI = null; -// -// try { -// -// if (itemType.equalsIgnoreCase("concessione")) { -// -// LOG.info("Trying to get concessione for id " + itemId); -// ConcessioniMongoServiceIdentityProxy cms = new ConcessioniMongoServiceIdentityProxy(httpServletRequest); -// Concessione concessione = cms.getItemById(itemId); -// if (concessione != null) { -// LOG.info("For id " + itemId + ", got concessione " + concessione.getNome() + " from service"); -// List images = concessione.getImmaginiRappresentative(); -// -// if (images != null) { -// listUI = new ArrayList(); -// int max = maxImages < images.size() ? maxImages : images.size(); -// for (int i = 0; i < max; i++) { -// UploadedImageDV ui = ConvertToDataViewModel.toUploadedImage(images.get(i)); -// listUI.add(ui); -// } -// LOG.info("For id " + itemId + ", got " + listUI.size() + " image/s"); -// } -// } else -// throw new Exception("Concessione with id '" + itemId + "' not available"); -// } -// -// return listUI; -// -// } catch (Exception e) { -// String erroMsg = UploadedImage.class.getSimpleName() + " not available for " -// + Concessione.class.getSimpleName() + " with id " + itemId; -// LOG.error(erroMsg, e); -// throw new Exception(erroMsg); -// } -// -// } -// -//} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/SessionUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/SessionUtil.java index ed43dcf..b99787c 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/SessionUtil.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/SessionUtil.java @@ -121,7 +121,7 @@ public class SessionUtil { if (token != null && setInThread) SecurityTokenProvider.instance.set(token); - LOG.debug("Returning token " + token.substring(1, 10) + "MASKED_TOKEN"); + LOG.debug("Returning token " + token.substring(1, 10) + "_MASKED_TOKEN_"); return token; } @@ -168,50 +168,4 @@ public class SessionUtil { return shortener; } - -// /** -// * Gets the preview image for concessione. It is the first image retrieved from -// * mongoService for mongoConcessioneId. Caching it into session -// * -// * @param httpServletRequest the http servlet request -// * @param itemType the item type -// * @param mongoConcessioneId the mongo concessione id -// * @return the preview image for concessione -// */ -// public static UploadedImageDV getPreviewImageForConcessione(HttpServletRequest httpServletRequest, String itemType, -// String mongoConcessioneId) { -// -// HttpSession session = httpServletRequest.getSession(); -// Map> mapImages = null; -// List lUI = null; -// try { -// mapImages = (LinkedHashMap) session.getAttribute(CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE); -// -// if (mapImages == null) { -// mapImages = new LinkedHashMap>(); -// } -// -// List imagePreviewForConcessione = mapImages.get(mongoConcessioneId); -// -// if (imagePreviewForConcessione == null || imagePreviewForConcessione.size() == 0) { -// LOG.info("Into " + CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE + " object session the mongoConcessioneId " -// + mongoConcessioneId + " is empty or null, loading from service and filling it"); -// lUI = new ConcessioneImageUtil().getUploadedImagesForId(httpServletRequest, itemType, -// mongoConcessioneId, 1); -// mapImages.put(mongoConcessioneId, lUI); -// } -// -// lUI = mapImages.get(mongoConcessioneId); -// LOG.info("From " + CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE + " object session read image: " + lUI); -// session.setAttribute(CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE, mapImages); -// -// } catch (Exception e) { -// LOG.warn("Error occurred when instancing the " + UrlShortener.class.getSimpleName(), e); -// } -// -// if (lUI == null || lUI.isEmpty()) -// return null; -// -// return lUI.get(0); -// } } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/wms/ZAxis.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/wms/ZAxis.java index b026180..2d26ff6 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/wms/ZAxis.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/gis/wms/ZAxis.java @@ -6,16 +6,14 @@ package org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms; import java.io.Serializable; import java.util.List; - -// TODO: Auto-generated Javadoc /** * The Class ZAxis. * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * - * Oct 27, 2020 + * Oct 27, 2020 */ -public class ZAxis implements Serializable{ +public class ZAxis implements Serializable { /** * @@ -24,10 +22,10 @@ public class ZAxis implements Serializable{ /** The units. */ private String units; - + /** The positive. */ private boolean positive; - + /** The values. */ private List values; @@ -40,9 +38,9 @@ public class ZAxis implements Serializable{ /** * Instantiates a new layer z axis. * - * @param units the units + * @param units the units * @param positive the positive - * @param values the values + * @param values the values */ public ZAxis(String units, boolean positive, List values) { this.units = units; @@ -50,7 +48,6 @@ public class ZAxis implements Serializable{ this.values = values; } - /** * Gets the units. * @@ -61,7 +58,6 @@ public class ZAxis implements Serializable{ return units; } - /** * Checks if is positive. * @@ -72,7 +68,6 @@ public class ZAxis implements Serializable{ return positive; } - /** * Gets the values. * @@ -83,7 +78,6 @@ public class ZAxis implements Serializable{ return values; } - /** * Sets the units. * @@ -94,7 +88,6 @@ public class ZAxis implements Serializable{ this.units = units; } - /** * Sets the positive. * @@ -105,7 +98,6 @@ public class ZAxis implements Serializable{ this.positive = positive; } - /** * Sets the values. * @@ -121,7 +113,9 @@ public class ZAxis implements Serializable{ * * @return the string */ - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.lang.Object#toString() */ @Override diff --git a/src/test/java/org/gcube/portlets/user/geoportaldataviewer/IAMClient.java b/src/test/java/org/gcube/portlets/user/geoportaldataviewer/IAMClient.java index 1df1bc7..3a81e6b 100644 --- a/src/test/java/org/gcube/portlets/user/geoportaldataviewer/IAMClient.java +++ b/src/test/java/org/gcube/portlets/user/geoportaldataviewer/IAMClient.java @@ -21,7 +21,6 @@ public class IAMClient { try { credentials = IAMClientCredentialsReader.getCredentials(); } catch (Exception e) { - // TODO Auto-generated catch block e.printStackTrace(); } @@ -32,7 +31,6 @@ public class IAMClient { // System.out.println("Get concessione: " + concessione); } catch (Exception e) { - // TODO Auto-generated catch block e.printStackTrace(); } } -- 2.17.1 From 7dff2451a3e225ad41906fbb6a3517800d4e5d06 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 24 Sep 2021 17:28:03 +0200 Subject: [PATCH 35/38] updated CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd312ab..0795930 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm [#21976] Access policies checked on server-side [#22042] Implemented the public access [#22040] Revisited the "Abstract and Relazione di Scavo" +[#22041] Files have been ported to FileSet model ## [v1.2.0-SNAPSHOT] - 2021-07-19 -- 2.17.1 From 8095db9d7e79e3a18e2b6a6be0e7d233324bf84c Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 27 Sep 2021 14:45:18 +0200 Subject: [PATCH 36/38] just a refactor --- .../mongoservice/ConcessioniMongoServiceIdentityProxy.java | 6 +++--- .../server/mongoservice/IAMClientCredentialsReader.java | 2 +- .../{accessidentities => accessidentity}/GcubeIdentity.java | 2 +- .../IAMClientCredentials.java | 2 +- .../IAMClientIdentity.java | 2 +- .../{accessidentities => accessidentity}/UserIdentity.java | 2 +- .../gcube/portlets/user/geoportaldataviewer/IAMClient.java | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) rename src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/{accessidentities => accessidentity}/GcubeIdentity.java (95%) rename src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/{accessidentities => accessidentity}/IAMClientCredentials.java (98%) rename src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/{accessidentities => accessidentity}/IAMClientIdentity.java (99%) rename src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/{accessidentities => accessidentity}/UserIdentity.java (96%) diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/ConcessioniMongoServiceIdentityProxy.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/ConcessioniMongoServiceIdentityProxy.java index b15fb78..735f381 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/ConcessioniMongoServiceIdentityProxy.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/ConcessioniMongoServiceIdentityProxy.java @@ -4,9 +4,9 @@ import javax.servlet.http.HttpServletRequest; import org.gcube.application.geoportal.common.model.legacy.Concessione; import org.gcube.common.portal.PortalContext; -import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentities.GcubeIdentity; -import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentities.IAMClientIdentity; -import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentities.UserIdentity; +import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentity.GcubeIdentity; +import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentity.IAMClientIdentity; +import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentity.UserIdentity; import org.gcube.portlets.user.geoportaldataviewer.server.util.SessionUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/IAMClientCredentialsReader.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/IAMClientCredentialsReader.java index 6d1ab37..6df98b6 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/IAMClientCredentialsReader.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/IAMClientCredentialsReader.java @@ -10,7 +10,7 @@ import org.gcube.common.encryption.StringEncrypter; import org.gcube.common.resources.gcore.ServiceEndpoint; import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint; import org.gcube.common.scope.api.ScopeProvider; -import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentities.IAMClientCredentials; +import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentity.IAMClientCredentials; import org.gcube.resources.discovery.client.api.DiscoveryClient; import org.gcube.resources.discovery.client.queries.api.SimpleQuery; import org.slf4j.Logger; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentities/GcubeIdentity.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentity/GcubeIdentity.java similarity index 95% rename from src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentities/GcubeIdentity.java rename to src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentity/GcubeIdentity.java index ac81b18..ad1e4e4 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentities/GcubeIdentity.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentity/GcubeIdentity.java @@ -1,4 +1,4 @@ -package org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentities; +package org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentity; import javax.servlet.http.HttpServletRequest; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentities/IAMClientCredentials.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentity/IAMClientCredentials.java similarity index 98% rename from src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentities/IAMClientCredentials.java rename to src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentity/IAMClientCredentials.java index 267b991..21956f6 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentities/IAMClientCredentials.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentity/IAMClientCredentials.java @@ -1,4 +1,4 @@ -package org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentities; +package org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentity; import java.io.Serializable; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentities/IAMClientIdentity.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentity/IAMClientIdentity.java similarity index 99% rename from src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentities/IAMClientIdentity.java rename to src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentity/IAMClientIdentity.java index 01d319f..45dbc63 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentities/IAMClientIdentity.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentity/IAMClientIdentity.java @@ -1,4 +1,4 @@ -package org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentities; +package org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentity; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentities/UserIdentity.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentity/UserIdentity.java similarity index 96% rename from src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentities/UserIdentity.java rename to src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentity/UserIdentity.java index c59f0c0..f2ee8f9 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentities/UserIdentity.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentity/UserIdentity.java @@ -1,4 +1,4 @@ -package org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentities; +package org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentity; import javax.servlet.http.HttpServletRequest; diff --git a/src/test/java/org/gcube/portlets/user/geoportaldataviewer/IAMClient.java b/src/test/java/org/gcube/portlets/user/geoportaldataviewer/IAMClient.java index 3a81e6b..0aa3b91 100644 --- a/src/test/java/org/gcube/portlets/user/geoportaldataviewer/IAMClient.java +++ b/src/test/java/org/gcube/portlets/user/geoportaldataviewer/IAMClient.java @@ -5,7 +5,7 @@ import java.util.List; import org.gcube.application.geoportal.common.model.legacy.Concessione; import org.gcube.common.scope.api.ScopeProvider; import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.IAMClientCredentialsReader; -import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentities.IAMClientCredentials; +import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentity.IAMClientCredentials; import org.junit.Test; public class IAMClient { -- 2.17.1 From 1ef815eddcfc77684064471b885b1c009a40ab92 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 6 Oct 2021 16:03:41 +0200 Subject: [PATCH 37/38] increased the MAX_RETRY --- CHANGELOG.md | 22 +++++++++---------- .../client/GeoportalDataViewer.java | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0795930..186f674 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,28 +8,28 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm #### Enhancements -[#21890] Porting to ConcessioniManagerI and pass to mongoID -[#20595] Porting and using the model view provided by geoportal-common -[#21946] Show layers of a concessione automatically on map according to zoom level -[#21976] Access policies checked on server-side -[#22042] Implemented the public access -[#22040] Revisited the "Abstract and Relazione di Scavo" -[#22041] Files have been ported to FileSet model +- [#21890] Porting to ConcessioniManagerI and pass to mongoID +- [#20595] Porting and using the model view provided by geoportal-common +- [#21946] Show layers of a concessione automatically on map according to zoom level +- [#21976] Access policies checked on server-side +- [#22042] Implemented the public access +- [#22040] Revisited the "Abstract and Relazione di Scavo" +- [#22041] Files have been ported to FileSet model ## [v1.2.0-SNAPSHOT] - 2021-07-19 #### Enhancements -[#21847] Integrated with an Image and LighBox gallery for images -Moved to maven-portal-bom 3.6.3 +- [#21847] Integrated with an Image and LighBox gallery for images +- Moved to maven-portal-bom 3.6.3 ## [v1.1.0] - 2020-12-21 #### Enhancements -[#20357] Improvements feedback-driven +- [#20357] Improvements feedback-driven ## [v1.0.0] - 2020-12-09 -[#20004] First release +- [#20004] First release 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 65d862d..ba5ee1a 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 @@ -277,7 +277,7 @@ public class GeoportalDataViewer implements EntryPoint { if (paramGeonaItemID != null) { // waiting for record retrieved by service before calling the WFS - final int MAX_RETRY = 7; + final int MAX_RETRY = 15; Timer timer = new com.google.gwt.user.client.Timer() { @Override public void run() { -- 2.17.1 From bbc38bc2dffbcfe5a0a495b7326c3fa9d033a3a0 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 6 Oct 2021 16:56:57 +0200 Subject: [PATCH 38/38] moved to 2.0.0-SNAPSHOT --- .classpath | 6 +- .../com.gwtplugins.gdt.eclipse.core.prefs | 2 +- .settings/org.eclipse.wst.common.component | 87 ++++++++++++++++--- CHANGELOG.md | 2 +- pom.xml | 2 +- 5 files changed, 81 insertions(+), 18 deletions(-) diff --git a/.classpath b/.classpath index acfc760..68e48a9 100644 --- a/.classpath +++ b/.classpath @@ -1,12 +1,12 @@ - + - + @@ -35,5 +35,5 @@ - + diff --git a/.settings/com.gwtplugins.gdt.eclipse.core.prefs b/.settings/com.gwtplugins.gdt.eclipse.core.prefs index 18cc930..64194f3 100644 --- a/.settings/com.gwtplugins.gdt.eclipse.core.prefs +++ b/.settings/com.gwtplugins.gdt.eclipse.core.prefs @@ -1,4 +1,4 @@ eclipse.preferences.version=1 -lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-viewer-app/target/geoportal-data-viewer-app-1.3.0-SNAPSHOT +lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-viewer-app/target/geoportal-data-viewer-app-2.0.0-SNAPSHOT warSrcDir=src/main/webapp warSrcDirIsOutput=false diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 113106b..3463b99 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,5 +1,5 @@ - + @@ -12,8 +12,20 @@ - - + + + + + + + + + + + + + + @@ -27,7 +39,13 @@ - + + + + + + + @@ -41,7 +59,13 @@ - + + + + + + + @@ -55,7 +79,13 @@ - + + + + + + + @@ -65,7 +95,13 @@ - + + + + + + + @@ -75,10 +111,19 @@ - + + + uses + - + + + + + + + @@ -92,7 +137,13 @@ - + + + + + + + @@ -104,7 +155,13 @@ - + + + + + + + @@ -118,7 +175,13 @@ - + + + + + + + diff --git a/CHANGELOG.md b/CHANGELOG.md index 186f674..fb933d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [v1.3.0-SNAPSHOT] - 2021-07-30 +## [v2.0.0-SNAPSHOT] - 2021-07-30 #### Enhancements diff --git a/pom.xml b/pom.xml index bc610d1..aefd6e0 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.gcube.portlets.user geoportal-data-viewer-app war - 1.3.0-SNAPSHOT + 2.0.0-SNAPSHOT GeoPortal Data Viewer App The GeoPortal Data Viewer App is an application to access, discovery and navigate the GeoNa products by a Web-Map Interface -- 2.17.1