diff --git a/.classpath b/.classpath index 285ac7e..68e48a9 100644 --- a/.classpath +++ b/.classpath @@ -1,12 +1,12 @@ - + - + @@ -35,6 +35,5 @@ - - + diff --git a/.settings/com.gwtplugins.gdt.eclipse.core.prefs b/.settings/com.gwtplugins.gdt.eclipse.core.prefs index afbfdeb..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.2.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/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 0d454c2..3463b99 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,13 +1,37 @@ - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -15,7 +39,19 @@ - + + + + + + + + + + + + + @@ -23,7 +59,19 @@ - + + + + + + + + + + + + + @@ -31,15 +79,57 @@ - + + + + + + + + + + + + + - + + + + + + + + + + + + + - + + + + uses + + + + + + + + + + + + + + + @@ -47,13 +137,37 @@ - + + + + + + + + + + + + + - + + + + + + + + + + + + + @@ -61,7 +175,19 @@ - + + + + + + + + + + + + + diff --git a/CHANGELOG.md b/CHANGELOG.md index ab37615..fb933d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,20 +4,32 @@ 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). +## [v2.0.0-SNAPSHOT] - 2021-07-30 + +#### 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 ## [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/README.md b/README.md index 76b58a0..86ee60d 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,13 @@ 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 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 N/A diff --git a/pom.xml b/pom.xml index 433770e..aefd6e0 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.gcube.portlets.user geoportal-data-viewer-app war - 1.2.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 @@ -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/client/GeoportalDataViewer.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java index e844663..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 @@ -5,20 +5,26 @@ 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.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.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; 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; 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; @@ -40,7 +46,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 { @@ -48,37 +54,34 @@ 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 /** * This is the entry point method. @@ -124,14 +127,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() { @@ -165,9 +168,12 @@ 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, true); + null, false, null, null,null); if (paramGeonaItemID != null) { if (paramGeonaItemType == null) { @@ -177,7 +183,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)); } @@ -189,9 +195,7 @@ public class GeoportalDataViewer implements EntryPoint { bindEvents(); } - - - + /** * Update window size. */ @@ -200,91 +204,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); - - Long id = showDetailsEvent.getGeonaID(); + GWT.log("Fired event: " + showDetailsEvent); - if(id==null) { + String geonaMongoId = showDetailsEvent.getGeonaMongoID(); + + if (geonaMongoId == null) { Window.alert("Item Id not found"); return; } - - //TODO - boolean found = false; - GWT.log("Product with id: "+id+" found? "+found); - - if(!found) { - - if(showDetailsEvent.getGeonaItemType().equalsIgnoreCase("Concessione")) { - GeoportalDataViewerServiceAsync.Util.getInstance().getConcessioneForId(id, 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 - final int MAX_RETRY = 7; + + if (paramGeonaItemID != null) { + // waiting for record retrieved by service before calling the WFS + final int MAX_RETRY = 15; Timer timer = new com.google.gwt.user.client.Timer() { @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) { + 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(); } @@ -292,54 +298,70 @@ 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(); + layerManager.removeAllDetailLayers(); } - + } }); - + 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)); - //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), GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857); - GeoQuery select = olMapMng.toDataPointQuery(transfCoord); - GWT.log("GeoQuery: "+select); - //GeoportalDataViewerConstants.print("fireEvent QueryDataEvent"); - layerManager.getLayerManagerBus().fireEvent(new QueryDataEvent(select, transfCoord, record.getId(), true)); - }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"); + ExtentWrapped toExt = new ExtentWrapped(transfCoord.getX(), transfCoord.getY(), transfCoord.getX(), transfCoord.getY()); + layerManager.getLayerManagerBus().fireEvent(new QueryDataEvent(select, toExt, + 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 9e83645..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 @@ -1,21 +1,21 @@ 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. * * @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 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"; @@ -24,28 +24,57 @@ 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 { + MOUSE_CLICK, MAP_ZOOM_END, MOVE_END, ADDED_CENTROID_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 enum LayerType { + RASTER_BASELAYER, FEATURE_TYPE + }; + + public static DateTimeFormat DT_FORMAT = DateTimeFormat.getFormat(ConvertToDataViewModel.DATE_FORMAT); + + public static final int MAX_WFS_FEATURES = 10; // zero for no limit + public static final String NEW_LINE_BR = "
"; - + + public static enum MAP_PROJECTION { + + EPSG_4326("4326", "EPSG:4326"), EPSG_3857("3857", "EPSG:3857"); + + String id; + String name; + + MAP_PROJECTION(String id, String name) { + this.id = id; + this.name = name; + } + + public String getId() { + return id; + } + + 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; - + + public static final int MAP_ITALY_FIT_ZOOM_ON = 5; /** * Prints the. @@ -53,8 +82,25 @@ public class GeoportalDataViewerConstants { * @param msg the msg */ public static native void printJs(String msg)/*-{ - console.log("js console: "+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/GeoportalDataViewerService.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java index 87b956b..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 @@ -4,12 +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.UploadedImageDV; import com.google.gwt.user.client.rpc.RemoteService; import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; @@ -19,7 +20,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 +29,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 +38,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 +51,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 +85,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, Integer maxImages) throws Exception; /** * Gets the public links for. @@ -100,4 +101,28 @@ 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; + + /** + * 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 048ee65..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 @@ -4,12 +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.UploadedImageDV; import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.rpc.AsyncCallback; @@ -38,7 +39,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,8 +47,15 @@ public interface GeoportalDataViewerServiceAsync { void getGeoNaDataViewProfile(AsyncCallback callback); - void getUploadedImagesForId(String itemType, Long id, int maxImages, AsyncCallback> callback); + void getUploadedImagesForId(String itemType, String itemId, Integer maxImages, + AsyncCallback> callback); void getPublicLinksFor(GeoNaItemRef item, AsyncCallback asyncCallback); + 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 2ad56da..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 @@ -8,7 +8,14 @@ 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.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; 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; @@ -16,29 +23,33 @@ 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; 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; 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.Heading; +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; +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; @@ -46,32 +57,38 @@ 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; import ol.Coordinate; - +import ol.Extent; +import ol.OLFactory; +import ol.format.GeoJson; +import ol.geom.Geometry; /** * 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 Map mapDetailLayerObjects = new HashMap(); + private Map mapBaseLayerObjects = new HashMap(); + private HandlerManager layerManagerBus = new HandlerManager(""); private HandlerManager applicationBus; + private org.gcube.application.geoportalcommon.shared.LayerItem baseLayerFromISProfile; + /** * Instantiates a new layer manager. * @@ -81,312 +98,267 @@ 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 - isLayerVisible(layerObj.getLayerItem()); - - } - + String mongoItemId = queryEvent.getMongoItemId(); + + GWT.log("(" + selectDataInfo.getX1() + "," + selectDataInfo.getY1() + ")(" + selectDataInfo.getX2() + + "," + selectDataInfo.getY2() + ")"); + +// 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); - 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()); - + // 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, MAP_PROJECTION.EPSG_3857.getName(), + MAP_PROJECTION.EPSG_4326.getName()); 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()); - } + mapBBOX.setCrs(MAP_PROJECTION.EPSG_4326.getName()); - @Override - public void onSuccess(List listGeonaDataObjects) { - - GWT.log("GeoNaDataObject's: "+listGeonaDataObjects); - //GeoportalDataViewerConstants.print("GeoNaDataObject's: "+listGeonaDataObjects); - - if(listGeonaDataObjects==null || listGeonaDataObjects.isEmpty()) - return; + GWT.log("Bounds is: " + mapBBOX); + GWT.log("MAX_WFS_FEATURES is: " + GeoportalDataViewerConstants.MAX_WFS_FEATURES); + // GeoportalDataViewerConstants.print("calling getDataResult"); - 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(); + List listLO = new ArrayList(); + // for querying base layers + listLO.addAll(mapBaseLayerObjects.values()); - //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); - try { - long productId = Long.parseLong(thePID); - if(productId==recordId) { - feature = fRow; - GWT.log("Found recorId == product_id with id: "+productId); - break; + // for querying detail layers only in this case + if (olMap.getCurrentResolution() < OLMapManager.LAYER_DETAIL_MAX_RESOLUTION) { + listLO.addAll(mapDetailLayerObjects.values()); + } + + GeoportalDataViewerServiceAsync.Util.getInstance().getDataResult(listLO, olMap.getProjectionCode(), + mapBBOX, GeoportalDataViewerConstants.MAX_WFS_FEATURES, olMap.getCurrentZoomLevel(), + new AsyncCallback>() { + + @Override + public void onFailure(Throwable caught) { + // GeoportalDataViewerConstants.print("on Failure DataResult: + // "+caught.getMessage()); + } + + @Override + public void onSuccess(List listGeonaDataObjects) { + + GWT.log("GeoNaDataObject's is/are " + listGeonaDataObjects.size()); + // GWT.log("GeoNaDataObject's: " + listGeonaDataObjects); + // GeoportalDataViewerConstants.print("GeoNaDataObject's: + // "+listGeonaDataObjects); + + if (listGeonaDataObjects == null || listGeonaDataObjects.isEmpty()) + return; + + FeatureRow feature = null; + + MapEventType sourceEvent = queryEvent.getSourceMapEventType(); + + // TODO SWTCH FOR EARCH ITEM TYPE + for (GeoNaSpatialQueryResult geoNaDataObject : listGeonaDataObjects) { + List features = geoNaDataObject.getFeatures(); + + GWT.log("GeoNaDataObject Source layer item name: " + + geoNaDataObject.getSourceLayerObject().getLayerItem().getName()); + + // USING ONLY THE FIRST FEATURE IN THE LIST + if (features != null && features.size() > 0) { + String theProductId = null; + // I need to show exactly the feature with produc_id == recordId + if (mongoItemId != null) { + for (FeatureRow fRow : features) { + List productIdLst = fRow.getMapProperties() + .get("product_id"); + theProductId = productIdLst.get(0); + try { + // long productId = Long.parseLong(thePID); + if (theProductId == mongoItemId) { + feature = fRow; + GWT.log("Found recorId == product_id with id: " + + theProductId); + break; + } + } catch (Exception e) { + // TODO: handle exception + } } - }catch (Exception e) { - // TODO: handle exception + } + + // If mongoItemId not passed, I'm using the first feature returned + if (mongoItemId == null) { + feature = features.get(0); + List productIdLst = feature.getMapProperties() + .get("product_id"); + if (productIdLst == null) { + // in this case the feature/s returned is/are a (detail) layer/s + // belonging + // to a record/concessione (not centroid layer), + // so calling show popuup info on detail layers if the + // following events are true. + if (sourceEvent.equals(MapEventType.MOUSE_CLICK) && olMap + .getCurrentZoomLevel() > OLMapManager.QUERY_MIN_ZOOM_LEVEL) { + + // Here I need to pass only the visible layers + showPopupInfoForLayer(listGeonaDataObjects, + queryEvent.getQueryClickExtent()); + } + return; + } + theProductId = productIdLst.get(0); + } else { + // the recordId to show has been passed but not found into list of + // FeatureRow + if (feature == null) { + return; + } + } + + GWT.log("the product id is: " + theProductId); + // Displaying popup info for centroid layer + if (sourceEvent.equals(MapEventType.MOUSE_CLICK) + || sourceEvent.equals(MapEventType.ADDED_CENTROID_LAYER_TO_MAP)) { + showPopupInfoForCentroidLayer(geoNaDataObject, feature, + queryEvent.getQueryClickExtent().getCenter()); + } + + // 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, + OLMapManager.LAYER_DETAIL_MIN_RESOLUTION, + OLMapManager.LAYER_DETAIL_MAX_RESOLUTION, + layer.getRefersTo()); + } + + } + }); + } else { + // removing all WMS detail layers if the ZOOM level is < + // QUERY_MIN_ZOOM_LEVEL + removeAllDetailLayers(); } } } - - //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) { - 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 { - 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); - } - } - } - } - - 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); - } - } - }); - } - }); - } - } - }); + }); } } }); - + 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); + removeAllDetailLayers(); applicationBus.fireEvent(zoomOutEvent); } }); } - - + + public void removeAllDetailLayers() { + mapDetailLayerObjects.clear(); + olMap.removeAllDetailLayers(); + } + /** * 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 displayInLayerSwitcher the display in layer switcher - * @param UUID the uuid - * @param onTop the on top + * @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 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 asDetailLayer, Double minResolution, Double maxResolution, + BaseConcessioneDV refersToBaseConcessione) { // final LayoutContainer westPanel = (LayoutContainer) layersPanel.getParent(); // @@ -395,54 +367,95 @@ 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() { - @Override - public void onFailure(Throwable caught) { + if (wmsLink == null || wmsLink.isEmpty()) { + GeoportalDataViewerConstants.printJs("Skipping add layer for wmsLink as null or empty"); + return; + } - Window.alert(caught.getMessage()); - } + GeoportalDataViewerServiceAsync.Util.getInstance().parseWmsRequest(wmsLink, layerName, + new AsyncCallback() { - @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 onFailure(Throwable caught) { + + 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(), 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 + LayerObject blo = mapBaseLayerObjects.get(key); + if (blo == null) { + olMap.addWMSLayer(layerItem); + mapBaseLayerObjects.put(key, lo); + } else { + GWT.log("Skipping base layer " + key + " already added to Map"); + } + } else { + LayerObject dlo = mapDetailLayerObjects.get(key); + if (dlo == null) { + mapDetailLayerObjects.put(key, lo); + olMap.addWMSDetailLayer(layerItem); + } else { + GWT.log("Skipping detail layer " + key + " already added to Map"); + } + } + } + }); } - /** * 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 + * @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) { + 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, Double minResolution, Double maxResolution) { // GWT.log("Add addLayerByWms 1"); LayerItem layerItem = new LayerItem(); @@ -451,7 +464,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); @@ -459,56 +472,444 @@ public class LayerManager { layerItem.setNcWms(isNcWms); layerItem.setUUID(UUID); layerItem.setZAxis(zAxis); + layerItem.setMinResolution(minResolution); + layerItem.setMaxResolution(maxResolution); 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; } + + /** + * 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(); + FlowPanel flowPanel = new FlowPanel(); + //flowPanel.getElement().getStyle().setProperty("maxHeight", "600px"); + scrollPanel.add(flowPanel); + + String prevConcessioneName = ""; + for (GeoNaSpatialQueryResult geoNaSpatialQueryResult : listGeoNaDataObject) { + try { + GWT.log("baseLayerFromISProfile.getName() :" + baseLayerFromISProfile.getName()); + LayerObject lo = geoNaSpatialQueryResult.getSourceLayerObject(); + LayerItem sourceLI = lo.getLayerItem(); + + String layerSourceName = sourceLI.getName(); + + // skipping centroid layer + if (layerSourceName == null + || layerSourceName.compareToIgnoreCase(baseLayerFromISProfile.getName()) == 0) { + continue; + } + + 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()); + + int i = 0; + for (FeatureRow feature : features) { + + intFlex.setHTML(i + 1, 0, new HTML(feature.getId()).toString()); + + // Showing properties belonging to concessioni layer + Map> entries = feature.getMapProperties(); + + if (entries.size() == 0) { + //Adding this row to show "no property" for feature + //intFlex.setHTML(i + 1, 1, new HTML("No property").toString()); + } + int j = 0; + for (String key : entries.keySet()) { + List theValues = entries.get(key); + String valueToDisplay = ""; + for (String value : theValues) { + valueToDisplay += value + ", "; + + } + valueToDisplay = valueToDisplay.substring(0, valueToDisplay.length() - 2); + + // adding the keys only of first feature row. They are equal for all features + // (beloning to same layer). + if (i == 0) + intFlex.setHTML(0, j + 1, new HTML(key).toString()); + + intFlex.setHTML(i + 1, j + 1, new HTML(valueToDisplay).toString()); + j++; + + } + i++; + } + flowPanel.add(intFlex); + } catch (Exception e) { + GeoportalDataViewerConstants.printJs("Error: "+e.getMessage()); + } + } + + olMap.showPopup(scrollPanel.toString(), queryClick.getCenter()); + + } +// /** +// * 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. + * + * @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) { + flex.setHTML(0, 0, new HTML("No data available").toString()); + olMap.showPopup(vpPanel.toString(), onFailureCenterTo); + return; + } + + // Showing properties belonging to concessioni centroid layer + Map> entries = feature.getMapProperties(); + + String nome = ""; + String descrizione = ""; + String date = ""; + + for (String key : entries.keySet()) { + String theValue = entries.get(key).get(0); + if (key.equalsIgnoreCase("nome")) { + nome = theValue != null ? theValue : ""; + } else if (key.equalsIgnoreCase("descrizione")) { + descrizione = theValue != null ? theValue : ""; + } else if (key.equalsIgnoreCase("date_scavo")) { + date = theValue != null ? theValue : ""; + } + } + + // GeoportalDataViewerConstants.print("0: "+nome); + flex.setHTML(0, 0, new HTML(nome).toString()); + try { + descrizione = StringUtil.ellipsize(descrizione, 100); + GWT.log("reduced: " + descrizione); + } catch (Exception e) { + GWT.log("error: " + e.getMessage()); + } + // GeoportalDataViewerConstants.print("1: "+descrizione); + flex.setText(1, 0, descrizione); + // GeoportalDataViewerConstants.print("2: "+date); + date = StringUtil.formatDate(date); + flex.setHTML(2, 0, new HTML("" + date + "").toString()); + + if (geoNaDataObject.getMapImages() != null) { + for (String key : geoNaDataObject.getMapImages().keySet()) { + List listUI = geoNaDataObject.getMapImages().get(key); + GWT.log("Adding images: " + listUI); + if (listUI != null && listUI.size() > 0) { + UploadedImageDV img = listUI.get(0); + if (img.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. * * @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. * @@ -527,4 +928,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 24fb887..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 @@ -1,10 +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; @@ -14,14 +19,13 @@ import com.google.gwt.event.shared.HandlerManager; import ol.Coordinate; import ol.MapBrowserEvent; import ol.MapEvent; -import ol.OLFactory; /** * The Class OLMapManager. * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * - * Nov 19, 2020 + * Nov 19, 2020 */ public class OLMapManager { @@ -32,12 +36,15 @@ 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; + public static final Double LAYER_DETAIL_MIN_RESOLUTION = 0.01; + public static final Double LAYER_DETAIL_MAX_RESOLUTION = 13.0; + /** * 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,77 +63,74 @@ 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); - layerManagerBus.fireEvent(new QueryDataEvent(select, coordinate, null, true)); + + ExtentWrapped toExt = new ExtentWrapped(coordinate.getX(), coordinate.getY(), coordinate.getX(), coordinate.getY()); + GeoQuery select = toDataPointQuery(coordinate, true); + layerManagerBus.fireEvent(new QueryDataEvent(select, toExt, null, true, MapEventType.MOUSE_CLICK)); } @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); } }; - // 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); - + 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()); } @@ -136,11 +140,11 @@ 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(); - GWT.log("To quey DP: "+coordinate); + GWT.log("To quey DP: " + coordinate); int w = (int) olMap.getSize().getWidth(); int h = (int) olMap.getSize().getHeight(); @@ -149,7 +153,18 @@ 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); + geoWidth = (bboxWidth / w) * (16 / 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); @@ -172,9 +187,10 @@ public class OLMapManager { /** * Check select query. */ - private void checkSelectQuery() { - + 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(); @@ -189,12 +205,12 @@ 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)); + //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) { - - if(zoomEnd { + 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/events/QueryDataEvent.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/QueryDataEvent.java index 38caafb..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,39 +1,42 @@ 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. * - * @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 + * Aug 31, 2021 */ public class QueryDataEvent extends GwtEvent { public static Type TYPE = new Type(); private GeoQuery select; - private Coordinate onFailureCenterTo; - private Long recordId; + private ExtentWrapped queryClickExtent; + private String mongoItemId; private boolean onInit; - + private MapEventType sourceMapEventType; /** * 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 + * @param mapEventType the map event type */ - public QueryDataEvent(GeoQuery select, Coordinate onFailureCenterTo, Long recordId, boolean onInit) { + public QueryDataEvent(GeoQuery select, ExtentWrapped queryClickExtent, String mongoItemId, boolean onInit, + MapEventType mapEventType) { this.select = select; - this.onFailureCenterTo = onFailureCenterTo; - this.recordId = recordId; + this.queryClickExtent = queryClickExtent; + this.mongoItemId = mongoItemId; this.onInit = onInit; + this.sourceMapEventType = mapEventType; } /** @@ -45,15 +48,14 @@ public class QueryDataEvent extends GwtEvent { public Type getAssociatedType() { return TYPE; } - - + /** - * Gets the record id. + * Gets the mongo item id. * - * @return the record id + * @return the mongo item id */ - public Long getRecordId() { - return recordId; + public String getMongoItemId() { + return mongoItemId; } /** @@ -64,6 +66,7 @@ public class QueryDataEvent extends GwtEvent { public boolean isOnInit() { return onInit; } + /** * Dispatch. * @@ -74,7 +77,7 @@ public class QueryDataEvent extends GwtEvent { handler.onQueryInteraction(this); } - + /** * Gets the geo query. * @@ -83,10 +86,18 @@ public class QueryDataEvent extends GwtEvent { public GeoQuery getGeoQuery() { return select; } - - - public Coordinate getOnFailureCenterTo() { - return onFailureCenterTo; + + public ExtentWrapped getQueryClickExtent() { + return queryClickExtent; + } + + /** + * Gets the source map event type. + * + * @return the source map event type + */ + public MapEventType getSourceMapEventType() { + return sourceMapEventType; } @Override @@ -94,19 +105,16 @@ public class QueryDataEvent extends GwtEvent { StringBuilder builder = new StringBuilder(); builder.append("QueryDataEvent [select="); builder.append(select); - builder.append(", onFailureCenterTo="); - builder.append(onFailureCenterTo); - builder.append(", recordId="); - builder.append(recordId); + builder.append(", queryClickExtent="); + builder.append(queryClickExtent); + builder.append(", mongoItemId="); + builder.append(mongoItemId); builder.append(", onInit="); builder.append(onInit); + builder.append(", sourceMapEventType="); + builder.append(sourceMapEventType); 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/client/gis/LightOpenLayerOSM.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerOSM.java index b1803a4..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 @@ -1,14 +1,24 @@ 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.BoundsMap; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery; 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; @@ -39,34 +51,35 @@ 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 { + public static final int MAX_ZOOM = 20; + /** 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 +87,124 @@ import ol.style.TextOptions; */ public LightOpenLayerOSM(String divTargetId) { - // create a OSM-layer - XyzOptions osmSourceOptions = OLFactory.createOptions(); + // 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); + Osm osmSource = new Osm(osmSourceOptions); + LayerOptions osmLayerOptions = OLFactory.createOptions(); + osmLayerOptions.setSource(osmSource); + 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 the 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.setCrossOrigin("Anonymous"); imageWMSOptions.setUrl(mapServerHost); imageWMSOptions.setParams(imageWMSParams); - //imageWMSOptions.setRatio(1.5f); + // imageWMSOptions.setRatio(1.5f); ImageWms imageWMSSource = new ImageWms(imageWMSOptions); @@ -198,50 +212,125 @@ 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; } - + /** + * 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.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.printJs(layer.toString()); + 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. * - * @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 +342,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 +356,6 @@ import ol.style.TextOptions; // style.setFill(fill); style.setText(text); - } Point thePoint = new Point(coordinate); Feature vf = new Feature(thePoint); @@ -278,7 +367,7 @@ import ol.style.TextOptions; geometryLayer = new ol.layer.Vector(vectorLayerOptions); map.addLayer(geometryLayer); } - + /** * Gets the map. * @@ -297,7 +386,6 @@ import ol.style.TextOptions; return map.getView().getProjection().getCode(); } - /** * Gets the current zoom level. * @@ -306,9 +394,7 @@ import ol.style.TextOptions; public double getCurrentZoomLevel() { return map.getView().getZoom(); } - - - + /** * Gets the bbox. * @@ -317,7 +403,7 @@ import ol.style.TextOptions; public ol.Extent getBBOX() { return getExtent(); } - + /** * Gets the extent. * @@ -326,6 +412,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 6bb974a..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 @@ -1,18 +1,28 @@ 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; 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; import ol.Collection; import ol.Coordinate; +import ol.Feature; +import ol.FeatureOptions; import ol.Map; import ol.MapBrowserEvent; import ol.MapEvent; @@ -25,6 +35,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,123 +47,160 @@ 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; import ol.source.ImageWmsOptions; import ol.source.ImageWmsParams; import ol.source.Osm; +import ol.source.Source; 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 { - + + public static final int MAX_ZOOM = 21; + + /** + * 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; + + private HashMap wmsLayerMap; + + /** + * 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 xyzOptions = 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); + Osm osmSource = new Osm(xyzOptions); + LayerOptions osmLayerOptions = OLFactory.createOptions(); + osmLayerOptions.setSource(osmSource); + + 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(19); - + viewOptions.setMaxZoom(MAX_ZOOM); - // 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 +216,7 @@ public abstract class OpenLayerOSM { moveEndListener(event); } }); - + map.addMoveStartListener(new EventListener() { @Override @@ -176,7 +224,7 @@ public abstract class OpenLayerOSM { moveStartListener(event); } }); - + map.addMapZoomListener(new EventListener() { @Override @@ -184,7 +232,7 @@ public abstract class OpenLayerOSM { mapZoomListener(event); } }); - + map.addMapZoomEndListener(new EventListener() { @Override @@ -193,32 +241,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 +279,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 +309,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,51 +327,172 @@ 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); + if (wmsLayerMap == null) + wmsLayerMap = new HashMap(); - ImageWms imageWMSSource = new ImageWms(imageWMSOptions); + String key = layerItem.getName(); - LayerOptions layerOptions = OLFactory.createOptions(); - layerOptions.setSource(imageWMSSource); + Image layer = wmsLayerMap.get(key); + if (layer == null) { + 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); + + // 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"); + } - Image wmsLayer = new Image(layerOptions); - - //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.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); + // 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); + wmsDetailsLayerMap.put(key, wmsLayer); + + GWT.log("Added WMSDetailLayer for layer name: " + layerItem.getName()); + eventBus.fireEvent(new AddedLayerToMapEvent(layerItem)); + } else { + GWT.log("The WMS detail layer with key: " + key + " already exists, skipping"); + } + + } + + /** + * Removes the all detail layers. + */ + public void removeAllDetailLayers() { + + // 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(); + + } + + /** + * 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 +505,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 +546,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 +581,47 @@ 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: " + theLayerName); + if (theLayerName != null && theLayerName.equals(layerName)) return true; } } - + 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. @@ -431,7 +631,6 @@ public abstract class OpenLayerOSM { public String getProjectionCode() { return map.getView().getProjection().getCode(); } - /** * Gets the current zoom level. @@ -441,9 +640,16 @@ 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. * @@ -452,7 +658,7 @@ public abstract class OpenLayerOSM { public ol.Extent getBBOX() { return getExtent(); } - + /** * Gets the extent. * @@ -461,26 +667,107 @@ 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; + } + + + /** + * Gets the layers from map. + * + * @return the layers from map + */ + public List getLayersFromMap() { + 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; + } + + /** + * 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/client/resources/Images.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/Images.java index d8434c3..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,10 +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 new file mode 100644 index 0000000..9992bc9 Binary files /dev/null and b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/italy.png differ diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/world.png b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/world.png new file mode 100644 index 0000000..e3c80f5 Binary files /dev/null and b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/resources/world.png differ 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..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 @@ -1,14 +1,20 @@ 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.shared.products.ConcessioneDV; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.RecordDV; +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; @@ -16,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; /** @@ -23,7 +30,7 @@ import com.google.gwt.user.client.ui.Widget; * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * - * Nov 19, 2020 + * Nov 19, 2020 */ public class GeonaDataViewMainPanel extends Composite { @@ -34,14 +41,14 @@ public class GeonaDataViewMainPanel extends Composite { * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * - * Nov 19, 2020 + * Nov 19, 2020 */ interface GeonaDataViewMainPanelUiBinder extends UiBinder { } - + @UiField HTMLPanel mainContainerPanel; - + @UiField HTMLPanel mainToolBar; @@ -50,38 +57,53 @@ public class GeonaDataViewMainPanel extends Composite { @UiField NavLink dataBoxSelection; - + @UiField Button removeQuery; - + @UiField DetailsPanel detailsPanel; + @UiField + Button extentToItaly; + + @UiField + Button extentToEarth; + 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); + + 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"); + } /** @@ -143,9 +165,9 @@ public class GeonaDataViewMainPanel extends Composite { removeQuery.setVisible(true); } }); - + removeQuery.addClickHandler(new ClickHandler() { - + @Override public void onClick(ClickEvent event) { map.removeQueryInteractions(); @@ -153,27 +175,51 @@ public class GeonaDataViewMainPanel extends Composite { } }); + extentToItaly.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + 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.WORLD); + applicationBus.fireEvent(new MapExtentToEvent(earthLocation)); + map.setCenter(earthLocation.getCoordinate(MAP_PROJECTION.EPSG_3857)); + map.setZoom(earthLocation.getZoomLevel()); + + } + }); + } /** * 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..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 @@ -7,6 +7,7 @@ .margin-right-10 { margin-right: 10px; } + .font-weight-bold { font-weight: bold; } @@ -19,9 +20,28 @@ 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 + + + + + + + + + + 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 @@ } + - - 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..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 @@ -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; @@ -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', @@ -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/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/ExtentMapUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/ExtentMapUtil.java new file mode 100644 index 0000000..d64795d --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/ExtentMapUtil.java @@ -0,0 +1,176 @@ +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, WORLD + } + + final static Map mapExtent = new HashMap(); + + static { + + // EPSG_4326 ITALY LOCATION + 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 WORLD LOCATION + Location earth = new Location(PLACE.WORLD.name(), 0, + 0, MAP_PROJECTION.EPSG_4326, + 2); + + mapExtent.put(PLACE.ITALY, ita); + mapExtent.put(PLACE.WORLD, earth); + + } + + 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 98580ff..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 @@ -1,10 +1,13 @@ 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.shared.gis.BoundsMap; +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; @@ -20,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); @@ -36,49 +39,49 @@ 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; + + private String theMapId = null; + /** * 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(); + 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_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); + lightOLSM = new LightOpenLayerOSM(theMapId); - olsm.setCenter(transformedCenterCoordinate); - olsm.setZoom(GeoportalDataViewerConstants.LIGHT_MAP_ITALY_FIT_ZOOM_ON); - //setMapSize(); - + // EPSG_3857 LOCATION TO ITALY + Location italyLocation = ExtentMapUtil.getLocation(PLACE.ITALY); + Coordinate transformedCenterCoordinate = italyLocation.getCoordinate(MAP_PROJECTION.EPSG_3857); + lightOLSM.setCenter(transformedCenterCoordinate); + lightOLSM.setZoom(GeoportalDataViewerConstants.LIGHT_MAP_ITALY_FIT_ZOOM_ON); } }); } - + private void setMapSize() { Scheduler.get().scheduleDeferred(new ScheduledCommand() { @@ -86,38 +89,42 @@ 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"); } }); } - + + public String getPanelMapElementId() { + return theMapId; + } + /** * 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. * @@ -130,30 +137,30 @@ 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, 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); + 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); } @@ -161,4 +168,9 @@ import ol.OLFactory; }); } + + public LightOpenLayerOSM getLightOLSM() { + return lightOLSM; + } + } 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..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,7 +1,8 @@ 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 org.gcube.portlets.user.geoportaldataviewer.shared.products.model.RecordDV; import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.Style.Unit; @@ -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 40a115e..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 @@ -4,18 +4,23 @@ 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.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; 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; -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; @@ -35,12 +40,9 @@ 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 { - - private static ConcessioneViewUiBinder uiBinder = GWT.create(ConcessioneViewUiBinder.class); interface ConcessioneViewUiBinder extends UiBinder { @@ -51,10 +53,10 @@ public class ConcessioneView extends Composite { @UiField Paragraph introduzione; - + @UiField HTMLPanel concessioniPanel; - + @UiField HTMLPanel relazioneScavoPanel; @@ -66,21 +68,18 @@ public class ConcessioneView extends Composite { @UiField HTMLPanel mapViewPanel; - + @UiField HTMLPanel posizionamentoAreaIndaginePanel; - + @UiField HTMLPanel piantaFineScavoPanel; - -// @UiField -// HTMLPanel sharePanel; - + @UiField Button shareButton; - + @UiField - Button viewButton; + Button expandButton; private ConcessioneDV concessioneDV; @@ -89,7 +88,7 @@ public class ConcessioneView extends Composite { private CustomFlexTable customTable = new CustomFlexTable(); private GeoNaItemRef geonaItemRef; - + private String myLogin; private boolean viewImageButtonVisible = true; @@ -100,40 +99,45 @@ 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", 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) { - 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) { - customTable.addNextKeyValues("Autori", concessioneDV.getAuthors(), GeoportalDataViewerConstants.NEW_LINE_BR); + customTable.addNextKeyValues("Staff", concessioneDV.getAuthors(), GeoportalDataViewerConstants.NEW_LINE_BR); } if (concessioneDV.getContributore() != null) { @@ -143,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) { @@ -165,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); - + } }); - - viewButton.setType(ButtonType.LINK); - viewButton.setIcon(IconType.EXPAND); - viewButton.setTitle("View Details in New Dialog"); - - viewButton.addClickHandler(new ClickHandler() { - + + 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.setViewDetailsButtonVisible(false); - int width = Window.getClientWidth()*75/100; - int height = Window.getClientHeight()*70/100; + cv.setExpandViewButtonVisible(false); + 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; @@ -227,117 +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; - - 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 layer : listLayersDV) { - - if(layer.getPolicy()==null || layer.getPolicy().equalsIgnoreCase("OPEN")) { - piantaFineScavoPanel.setVisible(true); - piantaFineScavoPanel.add(new LayerConcessioneView(layer)); - }else { - //I need to be authenticated to show the fields according to POLICY - if(myLogin!=null) { - piantaFineScavoPanel.setVisible(true); - piantaFineScavoPanel.add(new LayerConcessioneView(layer)); - } - } + + for (LayerConcessioneDV layerDV : listLayersDV) { + 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; - - 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); - MapView mapView = new MapView(transformedCenterCoordinate, GeoportalDataViewerConstants.LIGHT_MAP_ITALY_FIT_ZOOM_ON, "70%", "300px"); - - if(concessioneDV!=null && concessioneDV.getCentroidLat()!=null && concessioneDV.getCentroidLong()!=null) { + 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 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) { - - 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(); @@ -348,9 +325,9 @@ public class ConcessioneView extends Composite { public ConcessioneDV getConcessioneDV() { return concessioneDV; } - - protected void setViewDetailsButtonVisible(boolean bool) { - viewButton.setVisible(bool); + + protected void setExpandViewButtonVisible(boolean bool) { + expandButton.setVisible(bool); } } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.ui.xml index 947c31f..d93dadd 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.ui.xml @@ -38,7 +38,7 @@ 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 1ec2934..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 @@ -1,20 +1,32 @@ 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.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; -import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.LayerConcessioneDV; +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; +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; import com.google.gwt.user.client.ui.Widget; import ol.Coordinate; -import ol.OLFactory; public class LayerConcessioneView extends Composite { @@ -22,36 +34,232 @@ public class LayerConcessioneView extends Composite { interface LayerConcessioneUiBinder extends UiBinder { } - + @UiField HTMLPanel layerConcessionePanel; - + @UiField HTMLPanel mapViewPanel; - + 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); - + GWT.log("Showing: " + layerDV); + + 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"); + + 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(); + String filename = layerDV.getLayerName() + "." + exportExt; + String mimeType = "image/" + exportExt; + final HTML htmlLink = new HTML(""); + navLink.getElement().appendChild(htmlLink.getElement()); + navLink.addClickHandler(new ClickHandler() { + + @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); + + } + //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); - - 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); - 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(); - 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.save("map.pdf") + }-*/; + + /** + * Prints the. + * + * @param msg the msg + */ + public static native void downloadMap(ol.Map map, String mapPanelId, String linkId, String filename, + String mimeType)/*-{ + console.log("map: " + map); + + map.once('rendercomplete', function() { + var mapCanvas = $doc.createElement('canvas'); + var size = map.getSize(); + mapCanvas.width = size[0]; + mapCanvas.height = size[1]; + var mapContext = mapCanvas.getContext('2d'); + 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; + 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(), filename); + } else { + var link = $doc.getElementById(linkId); + link.href = mapCanvas.toDataURL(mimeType); + 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/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..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 @@ -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; @@ -30,78 +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, boolean autheticatedUser) { - 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); - } - } - - //customTable.addNextKeyValue("Created", relazioneScavoDV.getCreationTime()); - //customTable.addNextKeyValue("ID Licenza", relazioneScavoDV.getLicenseID()); - customTable.addNextKeyValues("Responsabili", relazioneScavoDV.getResponsabili(), GeoportalDataViewerConstants.NEW_LINE_BR); + private CustomFlexTable customTable = new CustomFlexTable(); + + public RelazioneScavoView(AbstractRelazioneScavoDV abstractRelazioneDV, RelazioneScavoDV relazioneScavoDV) { + initWidget(uiBinder.createAndBindUi(this)); + 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()); + } 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 PFD relazione accoding to policy - if(relazioneScavoDV.getPolicy()==null || relazioneScavoDV.getPolicy().equalsIgnoreCase("OPEN")) { + if (relazioneScavoDV != null) { 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()); - } + // 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/client/util/URLUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/util/URLUtil.java index adb64bd..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,5 +1,6 @@ package org.gcube.portlets.user.geoportaldataviewer.client.util; +// TODO: Auto-generated Javadoc /** * The Class URLUtil. * @@ -60,6 +61,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. * 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 436675c..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/ConvertToDataViewModel.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConvertToDataViewModel.java deleted file mode 100644 index 3513355..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.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.setId(concessione.getId()); - 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; - } - } - - -} 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..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 @@ -1,33 +1,45 @@ package org.gcube.portlets.user.geoportaldataviewer.server; import java.util.ArrayList; +import java.util.Arrays; 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 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; 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; +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.server.gis.FeatureParser; import org.gcube.portlets.user.geoportaldataviewer.server.gis.WMSUrlValidator; +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.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.UploadedImageDV; +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; @@ -43,21 +55,22 @@ 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); + private static final String CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE = "MAP_IMAGE_PREVIEW_FOR_CONCESSIONE"; + /** * 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 +78,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 +96,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,154 +130,270 @@ 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); + + // Getting the concessioneId from WFS 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); + UploadedImageDV uplImg = sessionloadPreviewImageForConcessione(this.getThreadLocalRequest(), + "Concessione", cId); + // List listUI = getUploadedImagesForId("Concessione", cId, 1); + Map> mapImages = new LinkedHashMap>(); + mapImages.put(cId, Arrays.asList(uplImg)); + // mapImages.put(cId, listUI); geoDAO.setMapImages(mapImages); - }catch (Exception e) { - LOG.warn("Error on loading uploaded images for concessione: "+cId, e); + } 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, Integer maxImages) + throws Exception { + LOG.info("getUploadedImagesForId [itemId: " + itemId + ", itemType: " + itemType + "] called"); + + return getUploadedImagesForId(this.getThreadLocalRequest(), itemType, itemId, maxImages); + } + + /** + * 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(id==null) - throw new Exception("Invalid parameter. The Id is null"); - - List listUI = 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 "+id); - ConcessioniManager concessioniManager = new ConcessioniManager(); - Concessione concessione = concessioniManager.getById(id+""); - if (concessione != null) { - LOG.info("For id "+id+", 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 "+id+", got "+listUI.size() +" image/s"); - } - }else - throw new Exception("Concessione with id: "+id +" not available"); + 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"); } - - return listUI; - - }catch (Exception e) { - String erroMsg = UploadedImage.class.getSimpleName() +" not available for "+Concessione.class.getSimpleName() +" with id "+id; - LOG.error(erroMsg,e); + + if (itemType.equalsIgnoreCase("concessione")) { + + LOG.info("Trying to get concessione for id " + itemId); + ConcessioniMongoServiceIdentityProxy cms = new ConcessioniMongoServiceIdentityProxy( + this.getThreadLocalRequest()); + Concessione concessione = cms.getItemById(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()) { + if (GeoNACheckAccessPolicy.isAccessible(lc.getPolicy().name(), userName)) { + listLayers.add(ConvertToDataViewModel.toLayerConcessione(lc, baseConcessione)); + } + } + + LayerConcessione lcPosizionamento = concessione.getPosizionamentoScavo(); + + if (lcPosizionamento != null) { + + if (GeoNACheckAccessPolicy.isAccessible(lcPosizionamento.getPolicy().name(), userName)) { + + LayerConcessioneDV thePosizScavo = ConvertToDataViewModel + .toLayerConcessione(lcPosizionamento, baseConcessione); + 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. * - * @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); - SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); - Concessione concessione = new ConcessioniManager().getById(id+""); - LOG.info("Got concessione for id "+id); - if(concessione !=null) { + LOG.info("Trying to get record for id " + mongoId); + + ConcessioniMongoServiceIdentityProxy cms = new ConcessioniMongoServiceIdentityProxy( + this.getThreadLocalRequest()); + Concessione concessione = cms.getItemById(mongoId); + + LOG.info("Got concessione for mongoId: " + mongoId); + if (concessione != null) { concessionDV = ConvertToDataViewModel.toConcessione(concessione); + + String userName = null; + try { + userName = SessionUtil.getCurrentUser(this.getThreadLocalRequest()).getUsername(); + + } 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 (userName == null) { + + // CHECKING ACCESS POLICY + LOG.info("Applying access policies for concessione " + mongoId + " returned by service"); + LayerConcessioneDV layerPosizionamento = concessionDV.getPosizionamentoScavo(); + if (layerPosizionamento != null) { + if (!GeoNACheckAccessPolicy.isAccessible(layerPosizionamento.getPolicy(), userName)) { + concessionDV.setPosizionamentoScavo(null); + } else { + LOG.info("Posizionamento di Scavo is not accessible by current user"); + } + } + + List listLayersDV = concessionDV.getPianteFineScavo(); + if (listLayersDV != null) { + List accessibleListLayersDV = new ArrayList(); + for (LayerConcessioneDV layerDV : listLayersDV) { + if (GeoNACheckAccessPolicy.isAccessible(layerDV.getPolicy(), userName)) { + accessibleListLayersDV.add(layerDV); + } + } + concessionDV.setPianteFineScavo(accessibleListLayersDV); + } + + AbstractRelazioneScavoDV abstractRS = concessionDV.getAbstractRelazioneScavo(); + if (abstractRS != null) { + if (!GeoNACheckAccessPolicy.isAccessible(abstractRS.getPolicy(), userName)) { + concessionDV.setAbstractRelazioneScavo(null); + } + } + + RelazioneScavoDV relazioneScavo = concessionDV.getRelazioneScavo(); + if (relazioneScavo != null) { + if (!GeoNACheckAccessPolicy.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 (GeoNACheckAccessPolicy.isAccessible(uploadedImageDV.getPolicy(), userName)) { + accessibleListImages.add(uploadedImageDV); + } + + } + concessionDV.setImmaginiRappresentative(accessibleListImages); + + } + + // END CHECKING ACCESS POLICY + LOG.info("Access policies applied"); + } } - - 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 +407,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 +438,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 +471,23 @@ 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; } - + /** + * 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); @@ -359,25 +496,169 @@ 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); - + return gc.getPublicLinksFor(item, true); + } 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()); } } - + + /** + * 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()); } - + + /** + * 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; + } + + /** + * 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/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/gis/FeatureParser.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/gis/FeatureParser.java index a50cf28..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 @@ -15,27 +15,24 @@ 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; 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,121 @@ 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 +164,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/server/gis/GisMakers.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/gis/GisMakers.java index ef156f6..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 @@ -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; @@ -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/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..735f381 --- /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.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; + + +/** + * 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..6df98b6 --- /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.accessidentity.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/accessidentity/GcubeIdentity.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentity/GcubeIdentity.java new file mode 100644 index 0000000..ad1e4e4 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentity/GcubeIdentity.java @@ -0,0 +1,28 @@ +package org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentity; + +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/accessidentity/IAMClientCredentials.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentity/IAMClientCredentials.java new file mode 100644 index 0000000..21956f6 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentity/IAMClientCredentials.java @@ -0,0 +1,91 @@ +package org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentity; + +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/accessidentity/IAMClientIdentity.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentity/IAMClientIdentity.java new file mode 100644 index 0000000..45dbc63 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentity/IAMClientIdentity.java @@ -0,0 +1,117 @@ +package org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentity; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; + +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; + + 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 = sessionGetIAMClientCredentials(httpRequest); + try { + if(credentials==null) { + credentials = IAMClientCredentialsReader.getCredentials(); + sessionSetIAMClientCredentials(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"); + + } + + /** + * 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/mongoservice/accessidentity/UserIdentity.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentity/UserIdentity.java new file mode 100644 index 0000000..f2ee8f9 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accessidentity/UserIdentity.java @@ -0,0 +1,28 @@ +package org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentity; + +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/mongoservice/accesspolicy/GeoNACheckAccessPolicy.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accesspolicy/GeoNACheckAccessPolicy.java new file mode 100644 index 0000000..6eeda7a --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/accesspolicy/GeoNACheckAccessPolicy.java @@ -0,0 +1,93 @@ +package org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accesspolicy; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * The Class GeoNACheckAccessPolicy. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Sep 9, 2021 + */ +public class GeoNACheckAccessPolicy { + + private static final Logger LOG = LoggerFactory.getLogger(GeoNACheckAccessPolicy.class); + /** + * 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 accoding to access policies + * + * @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; + } + + //From here managing is NOT OPEN access + + if (myLogin == null || myLogin.isEmpty()) { + // here 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; + } + +} 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..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 @@ -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,20 +21,19 @@ 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"; + + private static final String URL_SHORTENER_SERVICE = "URL_SHORTENER_SERVICE"; /** * Checks if is into portal. @@ -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..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 @@ -4,16 +4,17 @@ import java.io.Serializable; import java.util.List; import java.util.Map; +import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV; import org.gcube.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 uploaded 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/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..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 @@ -5,10 +5,10 @@ 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; -// TODO: Auto-generated Javadoc /** * The Class LayerItem. * @@ -114,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. */ @@ -848,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(); @@ -909,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(); } - } 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..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,13 +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 { @@ -19,12 +21,26 @@ 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. */ public LayerObject() { - // TODO Auto-generated constructor stub + } + + /** + * 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; } /** @@ -36,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. * @@ -54,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. * @@ -63,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. * @@ -75,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/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/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/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(); } 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/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 aac4991..0000000 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/products/model/RecordDV.java +++ /dev/null @@ -1,291 +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 id. */ - private Long id; - - /** 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 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 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 [id="); - builder.append(id); - 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/main/webapp/GeoportalDataViewer.css b/src/main/webapp/GeoportalDataViewer.css index 99a7645..c471d94 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; @@ -254,3 +248,32 @@ 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; +} + +.table-feature { + border: 1px solid #ddd; + text-align: left; + border-collapse: collapse; + width: 100%; + margin-bottom:10px; +} + +.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 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"> + + 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 e8915ed..0000000 --- a/src/test/java/org/gcube/portlets/user/geoportaldataviewer/GetConcessione.java +++ /dev/null @@ -1,64 +0,0 @@ -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.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; - -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 long concessioneId = 8; - - public static ConcessioneDV getConcessioneForId(Long id) throws Exception{ - LOG.info("getConcessioneForId "+id+ "called"); - - ConcessioneDV concessionDV = null; - - if(id==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("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 "+id+" 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..0aa3b91 --- /dev/null +++ b/src/test/java/org/gcube/portlets/user/geoportaldataviewer/IAMClient.java @@ -0,0 +1,38 @@ +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.accessidentity.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) { + e.printStackTrace(); + } + + System.out.println("Read credentials: " + credentials); + Concessione concessione; + try { +// concessione = new ConcessioniMongoServiceIdentityProxy(); + + // System.out.println("Get concessione: " + concessione); + } catch (Exception e) { + 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(); } - } + }