Compare commits

..

No commits in common. "master" and "v3.2.1" have entirely different histories.

82 changed files with 2466 additions and 4823 deletions

View File

@ -1,11 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="src" output="target/geoportal-data-viewer-app-3.7.0-SNAPSHOT/WEB-INF/classes" path="src/main/java"> <classpathentry kind="src" output="target/geoportal-data-viewer-app-3.2.1/WEB-INF/classes" path="src/main/java">
<attributes> <attributes>
<attribute name="optional" value="true"/> <attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry excluding="**" kind="src" output="target/geoportal-data-viewer-app-3.2.1/WEB-INF/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"> <classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes> <attributes>
<attribute name="test" value="true"/> <attribute name="test" value="true"/>
@ -30,10 +35,5 @@
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry excluding="**" kind="src" output="target/geoportal-data-viewer-app-3.7.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources"> <classpathentry kind="output" path="target/geoportal-data-viewer-app-3.2.1/WEB-INF/classes"/>
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/geoportal-data-viewer-app-3.7.0-SNAPSHOT/WEB-INF/classes"/>
</classpath> </classpath>

View File

@ -1,4 +1,4 @@
eclipse.preferences.version=1 eclipse.preferences.version=1
lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-viewer-app/target/geoportal-data-viewer-app-3.7.0-SNAPSHOT lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-viewer-app/target/geoportal-data-viewer-app-3.2.1
warSrcDir=src/main/webapp warSrcDir=src/main/webapp
warSrcDirIsOutput=false warSrcDirIsOutput=false

View File

@ -51,183 +51,7 @@
<wb-module deploy-name="geoportal-data-viewer-app-3.2.1">
<wb-module deploy-name="geoportal-data-viewer-app-3.7.0-SNAPSHOT">
@ -312,94 +136,6 @@
@ -453,94 +189,6 @@
@ -594,94 +242,6 @@
@ -725,106 +285,41 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="metadata-profile-form-builder-widget-2.2.0.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/metadata-profile-form-builder-widget/metadata-profile-form-builder-widget"> <dependent-module archiveName="geoportal-data-common-2.0.2.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-data-common/geoportal-data-common">
<dependency-type>uses</dependency-type> <dependency-type>uses</dependency-type>
</dependent-module> </dependent-module>
<dependent-module archiveName="geoportal-client-1.2.2-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-client/geoportal-client">
<dependency-type>uses</dependency-type>
</dependent-module>
@ -909,94 +404,6 @@
@ -1050,94 +457,6 @@
@ -1191,94 +510,6 @@

View File

@ -4,40 +4,6 @@
All notable changes to this project will be documented in this file. 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). This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v3.7.0]
- Provided the "Export as PDF" facility [#26026]
- Integrated the GeoportalExporter as service [#27321]
- Passed to the new KC-client [#27398]
## [v3.6.0]
- GUI optimization [#25461]
- Using the latest libraries version: gwt-ol.v8.4.1 (with openlayers.v6.6.1) and gwt.v2.10
- Showing basic statistics (i.e. "X project published") via 'countByPhase' method [#25598]
## [v3.5.0]
- Supported the cross-filtering [#25074]
- Supported the grouped custom layers [#25110]
- Managed the (WMS) Layer Style facility [#25066]
## [v3.4.0] - 2023-05-11
- Integrated the geoportal-data-mapper component [#24978]
## [v3.3.1] - 2023-03-30
- Just including new dependencies
- Improved css
## [v3.3.0] - 2023-02-20
#### Fixes
- [#24632] Returning the public layer index if the private is missing
- [#24632] No temporal info shown if the temporal extent is missing
## [v3.2.1] - 2023-02-03 ## [v3.2.1] - 2023-02-03
#### Fixes #### Fixes

View File

@ -1,6 +1,6 @@
# GeoPortal Data Viewer App # GeoPortal Data Viewer App
The "Geoportal data-viewer" technology allows users to access and search for spatio-temporal documents through a web GIS which allows them to: (i) navigate and select the projects published in the system by "geographical map" (spatial dimension) , (ii) navigate and select the relationships between projects (evolution of over time) via "timeline" (temporal dimension), (iii) view metadata and resources (images, layers, etc. .) of documents via the "project view detail", (iv) export a view of the map with the layer of interest or add the layers of a project to the main map, (v) manage the order and overlapping of the layers, (vi) execute spatial queries on the layers and view the results, (vii) search through metadata or temporal dimension queries for the projects of interest, (vii) apply spatial filters for cross-layer. The GeoPortal Data Viewer App is an application to access, discovery and navigate the Geoportal projects/documents by a Web-Map Interface
## Built With ## Built With
@ -9,44 +9,16 @@ The "Geoportal data-viewer" technology allows users to access and search for spa
**Uses** **Uses**
* GWT v.2.10.0. [GWT](http://www.gwtproject.org) is licensed under [Apache License 2.0](http://www.gwtproject.org/terms.html) * 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-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.5.0-gwt2_9. [GWT-OL3](https://github.com/TDesjardins/gwt-ol) * GWT-OpenLayers 3+ v.8.1.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) * OpenLayers v.6.x [OpenLayers](https://openlayers.org/) is licensed under [BSD 2-Clause "Simplified"](https://github.com/openlayers/openlayers/blob/main/LICENSE.md)
* NanoGallery v2.X [NanoGallery2](https://github.com/nanostudio-org/nanogallery2) is licensed under [GNU General Public License "gplv3"](https://www.gnu.org/licenses/gpl-3.0.html)
* Vis-Timeline v7.x [VisTimeline](https://github.com/visjs/vis-timeline) is licensed under [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0) and MIT * Vis-Timeline v7.x [VisTimeline](https://github.com/visjs/vis-timeline) is licensed under [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0) and MIT
* Handlebarsjs v4.x [Handlebarsjs](https://handlebarsjs.com/) is licensed under MIT * Handlebarsjs v4.x [Handlebarsjs](https://handlebarsjs.com/) is licensed under MIT
## Architecture
<img src="https://gcube.wiki.gcube-system.org/images_gcube/8/82/GeoPortalDataViewer_Architecture.png" style="max-width:800px;" alt="GeoPortal Data-Viewer - Architecture" />
## Showcase
##### D4GNA instance of Geoportal D4Science
see at [Dataset per il Geoportale Nazionale per lArcheologia (D4GNA)](https://gna.d4science.org/)
**D4GNA Viewer - OSM**
<img src="https://gcube.wiki.gcube-system.org/images_gcube/0/06/D4GNA_Viewer_OSM.png" style="max-width:800px;" alt="Data_Viewer_OSM" />
**D4GNA Viewer - MapBox**
<img src="https://gcube.wiki.gcube-system.org/images_gcube/9/9c/D4GNA_Viewer_MapBox.png" style="max-width:800px;" alt="Data_Viewer_MapBox" />
**D4GNA Viewer - Discovering...**
<img src="https://gcube.wiki.gcube-system.org/images_gcube/8/85/D4GNA_ERCIM_3.png" style="max-width:800px;" alt="D4GNA_ERCIM_3" />
<br />
<br />
<img src="https://gcube.wiki.gcube-system.org/images_gcube/9/9c/D4GNA_ERCIM_2.png" style="max-width:800px;" alt="D4GNA_ERCIM_2" />
## Documentation ## Documentation
Geoportal Service Documentation is available at [gCube CMS Suite](https://geoportal.d4science.org/geoportal-service/docs/index.html) N/A
User Guide (DRAFT ITA) is available at [Guida al DataViewer D4GNA (DRAFT-ITA)](https://gcube.wiki.gcube-system.org/images_gcube/b/b3/D4science_Guida_al_DataViewer_D4GNA_bozza.pdf)
## Change log ## Change log

78
pom.xml
View File

@ -7,23 +7,22 @@
<parent> <parent>
<artifactId>maven-parent</artifactId> <artifactId>maven-parent</artifactId>
<groupId>org.gcube.tools</groupId> <groupId>org.gcube.tools</groupId>
<version>1.2.0</version> <version>1.1.0</version>
<relativePath /> <relativePath />
</parent> </parent>
<groupId>org.gcube.portlets.user</groupId> <groupId>org.gcube.portlets.user</groupId>
<artifactId>geoportal-data-viewer-app</artifactId> <artifactId>geoportal-data-viewer-app</artifactId>
<packaging>war</packaging> <packaging>war</packaging>
<version>3.7.0-SNAPSHOT</version> <version>3.2.1</version>
<name>GeoPortal Data Viewer App</name> <name>GeoPortal Data Viewer App</name>
<description>The GeoPortal Data Viewer App is an application to access, discovery and navigate the Geoportal projects/documents by a Web-Map Interface</description> <description>The GeoPortal Data Viewer App is an application to access, discovery and navigate the Geoportal projects/documents by a Web-Map Interface</description>
<properties> <properties>
<!-- Convenience property to set the GWT version --> <!-- Convenience property to set the GWT version -->
<gwt.version>2.10.0</gwt.version> <gwt.version>2.9.0</gwt.version>
<gwt.compiler.style>PRETTY</gwt.compiler.style> <gwt.compiler.style>PRETTY</gwt.compiler.style>
<gson.version>2.6.2</gson.version> <gson.version>2.6.2</gson.version>
<gwt.ol.version>8.5.0</gwt.ol.version>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory> <webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
<!-- GWT 2.9 support 8, 9 and 11 --> <!-- GWT 2.9 support 8, 9 and 11 -->
<maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.source>1.8</maven.compiler.source>
@ -56,41 +55,13 @@
<dependency> <dependency>
<groupId>org.gcube.distribution</groupId> <groupId>org.gcube.distribution</groupId>
<artifactId>maven-portal-bom</artifactId> <artifactId>maven-portal-bom</artifactId>
<version>${maven.portal.bom}</version> <version>3.6.4</version>
<type>pom</type> <type>pom</type>
<scope>import</scope> <scope>import</scope>
</dependency> </dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
<profiles>
<!-- PROD profile -->
<profile>
<id>geoportal-data-viewer-app-release-profile</id>
<activation>
<property>
<name>Release</name>
</property>
</activation>
<properties>
<maven.portal.bom>3.7.0</maven.portal.bom>
</properties>
</profile>
<!-- DEV profile -->
<profile>
<id>geoportal-data-viewer-app-snapshot-profile</id>
<activation>
<property>
<name>!Release</name>
</property>
</activation>
<properties>
<maven.portal.bom>3.8.0-SNAPSHOT</maven.portal.bom>
</properties>
</profile>
</profiles>
<dependencies> <dependencies>
<dependency> <dependency>
@ -131,7 +102,7 @@
<dependency> <dependency>
<groupId>com.github.tdesjardins</groupId> <groupId>com.github.tdesjardins</groupId>
<artifactId>gwt-ol3</artifactId> <artifactId>gwt-ol3</artifactId>
<version>${gwt.ol.version}</version> <version>8.1.0-gwt2_9</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.github.gwtbootstrap</groupId> <groupId>com.github.gwtbootstrap</groupId>
@ -164,6 +135,13 @@
<artifactId>usermanagement-core</artifactId> <artifactId>usermanagement-core</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>org.gcube.portlets.user</groupId>
<artifactId>gcube-url-shortener</artifactId>
<version>[1.0.0,2.0.0-SNAPSHOT)</version>
<scope>compile</scope>
</dependency>
<!-- REQUIRED FOR JDK_11 --> <!-- REQUIRED FOR JDK_11 -->
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
@ -172,16 +150,34 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- END --> <!-- END -->
<dependency> <dependency>
<groupId>org.gcube.application</groupId> <groupId>org.gcube.portlets.widgets</groupId>
<artifactId>geoportal-data-mapper</artifactId> <artifactId>metadata-profile-form-builder-widget</artifactId>
<version>[1.0.1, 2.0.0-SNAPSHOT)</version> <version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
<scope>compile</scope> <scope>compile</scope>
<!-- does not remove these exclusions, there are conflict with jackson
2.7 used by geo-json dependency -->
<exclusions>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</exclusion>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</exclusion>
<exclusion>
<groupId>de.grundid.opendatalab</groupId>
<artifactId>geojson-jackson</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.gcube.application</groupId> <groupId>org.gcube.application</groupId>
<artifactId>geoportal-data-common</artifactId> <artifactId>geoportal-data-common</artifactId>
<version>[2.0.0, 3.0.0-SNAPSHOT)</version> <version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -203,26 +199,30 @@
<dependency> <dependency>
<groupId>org.gcube.common</groupId> <groupId>org.gcube.common</groupId>
<artifactId>keycloak-client</artifactId> <artifactId>keycloak-client</artifactId>
<version>[2.0.0, 3.0.0-SNAPSHOT)</version> <version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.liferay.portal</groupId> <groupId>com.liferay.portal</groupId>
<artifactId>portal-service</artifactId> <artifactId>portal-service</artifactId>
<!-- <version>6.2.5</version> -->
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>javax.portlet</groupId> <groupId>javax.portlet</groupId>
<artifactId>portlet-api</artifactId> <artifactId>portlet-api</artifactId>
<!-- <version>2.0</version> -->
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId> <artifactId>slf4j-log4j12</artifactId>
<!-- <version>1.6.4</version> -->
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId> <artifactId>slf4j-api</artifactId>
<!-- <version>1.6.4</version> -->
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>

View File

@ -17,17 +17,11 @@
<inherits name="com.google.gwt.json.JSON" /> <inherits name="com.google.gwt.json.JSON" />
<inherits
name='org.gcube.portal.clientcontext.GCubeClientContext' />
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> --> <!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> --> <!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
<!-- Other module inherits --> <!-- Other module inherits -->
<servlet path="/geoportalexporterservice"
class="org.gcube.portlets.user.geoportaldataviewer.server.GeoportalExporterActionServlet" />
<!-- Specify the app entry point class. --> <!-- Specify the app entry point class. -->
<entry-point <entry-point
class='org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewer' /> class='org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewer' />

View File

@ -5,18 +5,13 @@ import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set; import java.util.Set;
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile; import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences; import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences;
import org.gcube.application.geoportalcommon.shared.geoportal.config.GroupedLayersDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.layers.LayerIDV;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.GCubeSDILayer;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.IndexLayerDV; import org.gcube.application.geoportalcommon.shared.geoportal.materialization.IndexLayerDV;
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV; import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
import org.gcube.application.geoportalcommon.shared.geoportal.project.RelationshipDV; import org.gcube.application.geoportalcommon.shared.geoportal.project.RelationshipDV;
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_DATA_HANDLER;
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView; import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION; 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.GeoportalDataViewerConstants.MapEventType;
@ -25,8 +20,6 @@ import org.gcube.portlets.user.geoportaldataviewer.client.events.AddLayerToMapEv
import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEvent.LAYER_TYPE; import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEvent.LAYER_TYPE;
import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEventHandler; import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEventHandler;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ApplyCQLToLayerOnMapEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ApplyCQLToLayerOnMapEventHandler;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ChangeMapLayerEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.ChangeMapLayerEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ChangeMapLayerEventHandler; import org.gcube.portlets.user.geoportaldataviewer.client.events.ChangeMapLayerEventHandler;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ClosedViewDetailsEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.ClosedViewDetailsEvent;
@ -35,12 +28,8 @@ import org.gcube.portlets.user.geoportaldataviewer.client.events.DoActionOnDetai
import org.gcube.portlets.user.geoportaldataviewer.client.events.DoActionOnDetailLayersEvent.DO_LAYER_ACTION; import org.gcube.portlets.user.geoportaldataviewer.client.events.DoActionOnDetailLayersEvent.DO_LAYER_ACTION;
import org.gcube.portlets.user.geoportaldataviewer.client.events.DoActionOnDetailLayersEvent.SwapLayer; import org.gcube.portlets.user.geoportaldataviewer.client.events.DoActionOnDetailLayersEvent.SwapLayer;
import org.gcube.portlets.user.geoportaldataviewer.client.events.DoActionOnDetailLayersEventHandler; import org.gcube.portlets.user.geoportaldataviewer.client.events.DoActionOnDetailLayersEventHandler;
import org.gcube.portlets.user.geoportaldataviewer.client.events.FitMapToExtentEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.FitMapToExtentEventHandler;
import org.gcube.portlets.user.geoportaldataviewer.client.events.MapExtentToEvent; 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.MapExtentToEventHandler;
import org.gcube.portlets.user.geoportaldataviewer.client.events.OverlayCustomLayerToMapEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.OverlayCustomLayerToMapEventHandler;
import org.gcube.portlets.user.geoportaldataviewer.client.events.QueryDataEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.QueryDataEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.SearchPerformedEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.SearchPerformedEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.SearchPerformedEventHandler; import org.gcube.portlets.user.geoportaldataviewer.client.events.SearchPerformedEventHandler;
@ -52,8 +41,6 @@ import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowPopupOnCent
import org.gcube.portlets.user.geoportaldataviewer.client.events.TimelineProjectRelationsEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.TimelineProjectRelationsEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.TimelineProjectRelationsEvent.EVENT_TYPE; import org.gcube.portlets.user.geoportaldataviewer.client.events.TimelineProjectRelationsEvent.EVENT_TYPE;
import org.gcube.portlets.user.geoportaldataviewer.client.events.TimelineProjectRelationsEventHandler; import org.gcube.portlets.user.geoportaldataviewer.client.events.TimelineProjectRelationsEventHandler;
import org.gcube.portlets.user.geoportaldataviewer.client.events.UpdateLayerToMapEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.UpdateLayerToMapEventHandler;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ZoomOutOverMinimumEvent; 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.events.ZoomOutOverMinimumEventHandler;
import org.gcube.portlets.user.geoportaldataviewer.client.events.collections.CloseCollectionEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.collections.CloseCollectionEvent;
@ -63,11 +50,9 @@ import org.gcube.portlets.user.geoportaldataviewer.client.events.collections.Ope
import org.gcube.portlets.user.geoportaldataviewer.client.gis.ExtentWrapped; 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.MapUtils;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerMap; import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerMap;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerMap.CQL_FACILITY_ORIGIN; import org.gcube.portlets.user.geoportaldataviewer.client.resources.GNAImages;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.GeoportalImages;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.GeonaDataViewMainPanel; import org.gcube.portlets.user.geoportaldataviewer.client.ui.GeonaDataViewMainPanel;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.project.relation.TimelineManagerStatus; import org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.project.relation.TimelineManagerStatus;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.util.OLGeoJSONUtil;
import org.gcube.portlets.user.geoportaldataviewer.client.util.ControlledCallBack; import org.gcube.portlets.user.geoportaldataviewer.client.util.ControlledCallBack;
import org.gcube.portlets.user.geoportaldataviewer.client.util.LoaderIcon; import org.gcube.portlets.user.geoportaldataviewer.client.util.LoaderIcon;
import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil; import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil;
@ -100,6 +85,12 @@ import com.google.gwt.user.client.ui.Widget;
import ol.Coordinate; import ol.Coordinate;
import ol.Feature; import ol.Feature;
import ol.OLFactory;
import ol.format.GeoJson;
import ol.format.GeoJsonFeatureOptions;
import ol.format.GeoJsonOptions;
import ol.proj.Projection;
import ol.proj.ProjectionOptions;
/** /**
* Entry point classes define <code>onModuleLoad()</code>. * Entry point classes define <code>onModuleLoad()</code>.
@ -112,8 +103,6 @@ public class GeoportalDataViewer implements EntryPoint {
public static final String DIV_TIMELINE_DATA = "timeline-data"; public static final String DIV_TIMELINE_DATA = "timeline-data";
public static final String DIV_LAYER_VIEW = "layer-viewer";
public static final String APP_NOTIFIER = "app-notifier"; public static final String APP_NOTIFIER = "app-notifier";
/** The Constant APP_DIV. */ /** The Constant APP_DIV. */
@ -150,7 +139,7 @@ public class GeoportalDataViewer implements EntryPoint {
int attempt = 0; int attempt = 0;
private LoaderIcon loaderApp = new LoaderIcon("Loading application... please wait", private LoaderIcon loaderApp = new LoaderIcon("Loading application... please wait",
new com.google.gwt.user.client.ui.Image(GeoportalImages.ICONS.spinnerEarth())); new com.google.gwt.user.client.ui.Image(GNAImages.ICONS.spinnerEarth()));
private HTML attributionDiv = new HTML(); private HTML attributionDiv = new HTML();
@ -165,8 +154,6 @@ public class GeoportalDataViewer implements EntryPoint {
// A cache (Layer_ID, GeoJSON) of layer features loaded via GetFeature Request // A cache (Layer_ID, GeoJSON) of layer features loaded via GetFeature Request
private HashMap<String, String> layerFeaturesCache = new HashMap<String, String>(); private HashMap<String, String> layerFeaturesCache = new HashMap<String, String>();
private ViewerConfiguration viewerConfiguration;
/** /**
* This is the entry point method. * This is the entry point method.
*/ */
@ -241,7 +228,6 @@ public class GeoportalDataViewer implements EntryPoint {
@Override @Override
public void onSuccess(ViewerConfiguration result) { public void onSuccess(ViewerConfiguration result) {
super.onSuccess(result); super.onSuccess(result);
viewerConfiguration = result;
GWT.log("Received init config : " + result); GWT.log("Received init config : " + result);
GWT.log("Loading base layers, count : " + result.getBaseLayers().size()); GWT.log("Loading base layers, count : " + result.getBaseLayers().size());
@ -296,8 +282,6 @@ public class GeoportalDataViewer implements EntryPoint {
mainPanel.openCollectionMenu(); mainPanel.openCollectionMenu();
loadConfigureduGroupedLayersForUCD();
GWT.log("DONE INIT LOAD"); GWT.log("DONE INIT LOAD");
} }
@ -318,77 +302,6 @@ public class GeoportalDataViewer implements EntryPoint {
RootPanel.get(APP_DIV).add(attributionDiv); RootPanel.get(APP_DIV).add(attributionDiv);
} }
/**
* Load Overlay Layers and Cross-Filtering layers for UCD
*
* Load configuredu grouped layers for UCD.
*/
public void loadConfigureduGroupedLayersForUCD() {
GeoportalDataViewerServiceAsync.Util.getInstance().getAvaiableCustomGroupedLayersForUCD(
GEOPORTAL_DATA_HANDLER.geoportal_grouped_overlay_layers,
new AsyncCallback<Map<String, List<GroupedLayersDV<? extends LayerIDV>>>>() {
@Override
public void onFailure(Throwable caught) {
GWT.log("loadConfigureduGroupedLayersForUCD error for "
+ GEOPORTAL_DATA_HANDLER.geoportal_grouped_overlay_layers + ": " + caught.getMessage());
}
@Override
public void onSuccess(Map<String, List<GroupedLayersDV<? extends LayerIDV>>> result) {
GWT.log(GEOPORTAL_DATA_HANDLER.geoportal_grouped_overlay_layers + " returned: " + result);
if (result != null && result.size() > 0) {
Map<String, GCubeCollection> collections = viewerConfiguration.getAvailableCollections();
for (String profileId : result.keySet()) {
List<GroupedLayersDV<? extends LayerIDV>> list = result.get(profileId);
if (list != null && list.size() > 0) {
GCubeCollection collection = collections.get(profileId);
mainPanel.addOverlayLayers(collection, list);
}
}
}
}
});
GeoportalDataViewerServiceAsync.Util.getInstance().getAvaiableCustomGroupedLayersForUCD(
GEOPORTAL_DATA_HANDLER.geoportal_grouped_cross_filtering,
new AsyncCallback<Map<String, List<GroupedLayersDV<? extends LayerIDV>>>>() {
@Override
public void onFailure(Throwable caught) {
GWT.log("loadConfigureduGroupedLayersForUCD error for "
+ GEOPORTAL_DATA_HANDLER.geoportal_grouped_cross_filtering + ": "
+ caught.getMessage());
}
@Override
public void onSuccess(Map<String, List<GroupedLayersDV<? extends LayerIDV>>> result) {
GWT.log(GEOPORTAL_DATA_HANDLER.geoportal_grouped_cross_filtering + " returned: " + result);
if (result != null && result.size() > 0) {
Map<String, GCubeCollection> collections = viewerConfiguration.getAvailableCollections();
for (String profileId : result.keySet()) {
List<GroupedLayersDV<? extends LayerIDV>> list = result.get(profileId);
if (list != null && list.size() > 0) {
GCubeCollection collection = collections.get(profileId);
mainPanel.addCrossFilteringLayers(collection, list);
}
}
}
}
});
}
/** /**
* Gets the status. * Gets the status.
* *
@ -417,7 +330,6 @@ public class GeoportalDataViewer implements EntryPoint {
mainPanel.setPanelsHeight(height); mainPanel.setPanelsHeight(height);
GWT.log("Set height: " + height); GWT.log("Set height: " + height);
mainPanel.setPanelsWidth(Window.getClientWidth());
} }
/** /**
@ -543,7 +455,7 @@ public class GeoportalDataViewer implements EntryPoint {
Modal errorModal = new Modal(true, true); Modal errorModal = new Modal(true, true);
errorModal.setCloseVisible(true); errorModal.setCloseVisible(true);
errorModal.setTitle("Oops..."); errorModal.setTitle("Oops...");
Image geoportalError = new Image(GeoportalImages.ICONS.warningError()); Image geoportalError = new Image(GNAImages.ICONS.warningError());
FlowPanel errorPanelMsg = new FlowPanel(); FlowPanel errorPanelMsg = new FlowPanel();
errorPanelMsg.getElement().addClassName("general_warning"); errorPanelMsg.getElement().addClassName("general_warning");
errorPanelMsg.add(geoportalError); errorPanelMsg.add(geoportalError);
@ -760,24 +672,6 @@ public class GeoportalDataViewer implements EntryPoint {
} }
}); });
applicationBus.addHandler(OverlayCustomLayerToMapEvent.TYPE, new OverlayCustomLayerToMapEventHandler() {
@Override
public void onCustomOverlayLayerAction(OverlayCustomLayerToMapEvent customOverLayerToMapEvent) {
if (customOverLayerToMapEvent.getLayerItem() == null)
return;
if (customOverLayerToMapEvent.getActionType()
.equals(OverlayCustomLayerToMapEvent.ACTION_TYPE.VISIBILITY)) {
OpenLayerMap olMap = olMapMng.getOLMap();
olMap.setWMSGroupedCustomLayerVisible(customOverLayerToMapEvent.getLayerItem(),
customOverLayerToMapEvent.isEnabled());
}
}
});
applicationBus.addHandler(ChangeMapLayerEvent.TYPE, new ChangeMapLayerEventHandler() { applicationBus.addHandler(ChangeMapLayerEvent.TYPE, new ChangeMapLayerEventHandler() {
@Override @Override
@ -809,8 +703,8 @@ public class GeoportalDataViewer implements EntryPoint {
// Showing popup after clicking on map // Showing popup after clicking on map
if (showPopupOnCentroiEvent.getProfileID() != null && showPopupOnCentroiEvent.getProjectID() != null) { if (showPopupOnCentroiEvent.getProfileID() != null && showPopupOnCentroiEvent.getProjectID() != null) {
Coordinate transfCoord = MapUtils.geoJSONToBBOXCenter(showPopupOnCentroiEvent.getSpatialReference(), Coordinate transfCoord = MapUtils
null, null); .geoJSONTToBBoxCenter(showPopupOnCentroiEvent.getSpatialReference(), null, null);
performWFSQueryOnCentroid(showPopupOnCentroiEvent.getProjectID(), transfCoord.getX(), performWFSQueryOnCentroid(showPopupOnCentroiEvent.getProjectID(), transfCoord.getX(),
transfCoord.getY()); transfCoord.getY());
@ -831,7 +725,7 @@ public class GeoportalDataViewer implements EntryPoint {
if (searchPerformedEvent != null) { if (searchPerformedEvent != null) {
LinkedHashMap<String, ol.layer.Image> wmsMap = olMapMng.getOLMap().getWmsLayerMap(); LinkedHashMap<String, ol.layer.Image> wmsMap = olMapMng.getOLMap().getWmsLayerMap();
// String firstWMSKey = wmsMap.keySet().iterator().next(); String firstWMSKey = wmsMap.keySet().iterator().next();
List<String> result = searchPerformedEvent.getListProjectIDs(); List<String> result = searchPerformedEvent.getListProjectIDs();
ViewerConfiguration viewerConfig = GeoportalDataViewer.getStatus().getViewerConfig(); ViewerConfiguration viewerConfig = GeoportalDataViewer.getStatus().getViewerConfig();
@ -856,126 +750,35 @@ public class GeoportalDataViewer implements EntryPoint {
// TODO: handle exception // TODO: handle exception
} }
String newCqlFilter = null; // default String setCqlFilter = null; // default
if (layerName == null) { if (result != null && result.size() > 0) {
GWT.log("CQL FILTER skipped, layerName is NULL!!");
return;
}
// Applying CQL filter only if there are results and its number are less or
// equal to SEARCH_LIMIT_RESULTS_TO_MAXIMUM
if (result != null && result.size() > 0
&& result.size() <= GeoportalDataViewerConstants.SEARCH_LIMIT_RESULTS_TO_MAXIMUM) {
String cqlFilter = GeoportalDataViewerConstants.PROJECT_ID_KEY_FEATURE + " IN("; String cqlFilter = GeoportalDataViewerConstants.PROJECT_ID_KEY_FEATURE + " IN(";
for (String projectId : result) { for (String projectId : result) {
cqlFilter += "'" + projectId + "',"; cqlFilter += "'" + projectId + "',";
} }
cqlFilter = cqlFilter.substring(0, cqlFilter.length() - 1) + ")"; cqlFilter = cqlFilter.substring(0, cqlFilter.length() - 1) + ")";
setCqlFilter = cqlFilter;
newCqlFilter = olMapMng.getOLMap().setCQLFilterToWMSLayer(CQL_FACILITY_ORIGIN.SEARCH, layerName, olMapMng.getOLMap().setCQLFilterToWMSLayer(firstWMSKey, cqlFilter);
cqlFilter);
} else { } else {
newCqlFilter = olMapMng.getOLMap().setCQLFilterToWMSLayer(CQL_FACILITY_ORIGIN.SEARCH, layerName, olMapMng.getOLMap().setCQLFilterToWMSLayer(firstWMSKey, null);
null); setCqlFilter = null; // is already null
} }
if (searchPerformedEvent.isSearchReset()) { if (searchPerformedEvent.isSearchReset()) {
newCqlFilter = olMapMng.getOLMap().setCQLFilterToWMSLayer(CQL_FACILITY_ORIGIN.SEARCH, layerName, olMapMng.getOLMap().setCQLFilterToWMSLayer(firstWMSKey, null);
null); setCqlFilter = null; // is already null
} }
GWT.log("New CQL Filter is: " + newCqlFilter);
// Resetting CQL Filter
if (layerName != null) if (layerName != null)
layerManager.setCQLForLayerToIndexLayer(layerName, newCqlFilter);
}
}
});
applicationBus.addHandler(ApplyCQLToLayerOnMapEvent.TYPE, new ApplyCQLToLayerOnMapEventHandler() {
@Override
public void onApplyCQL(ApplyCQLToLayerOnMapEvent applyCQLToLayerMapEvent) {
GWT.log("Fired: " + applyCQLToLayerMapEvent);
if (applyCQLToLayerMapEvent != null) {
String layerName = null;
GCubeSDILayer layer = applyCQLToLayerMapEvent.getTheIndeLayer().getLayer();
try {
String wmsLink = layer.getOgcLinks().get("wms");
layerName = URLUtil.extractValueOfParameterFromURL("layers", wmsLink);
} catch (Exception e) {
// TODO: handle exception
}
String setCqlFilter = null;
if (layerName != null) {
GWT.log("ApplyCQLToLayerOnMapEvent: " + layerName + ", filter : "
+ applyCQLToLayerMapEvent.getCqlFilterValue());
if (applyCQLToLayerMapEvent.getCqlFilterValue() == null) {
olMapMng.getOLMap().setCQLFilterToWMSLayer(CQL_FACILITY_ORIGIN.CROSS_FILTERING, layerName,
null);
setCqlFilter = null; // is already null
} else {
setCqlFilter = applyCQLToLayerMapEvent.getCqlFilterValue();
olMapMng.getOLMap().setCQLFilterToWMSLayer(CQL_FACILITY_ORIGIN.CROSS_FILTERING, layerName,
setCqlFilter);
}
layerManager.setCQLForLayerToIndexLayer(layerName, setCqlFilter); layerManager.setCQLForLayerToIndexLayer(layerName, setCqlFilter);
}
} }
} }
}); });
applicationBus.addHandler(FitMapToExtentEvent.TYPE, new FitMapToExtentEventHandler() {
@Override
public void onFitToMap(FitMapToExtentEvent fitMapToExtentEvent) {
if (fitMapToExtentEvent.getExtent() != null) {
olMapMng.getOLMap().fitToExtent(fitMapToExtentEvent.getExtent());
}
}
});
applicationBus.addHandler(UpdateLayerToMapEvent.TYPE, new UpdateLayerToMapEventHandler() {
@Override
public void onUpdateLayer(UpdateLayerToMapEvent updateLayerToMapEvent) {
if (updateLayerToMapEvent != null && updateLayerToMapEvent.getOperation() != null) {
if (updateLayerToMapEvent.getLayerType().equals(
org.gcube.portlets.user.geoportaldataviewer.client.events.UpdateLayerToMapEvent.LAYER_TYPE.INDEX)) {
switch (updateLayerToMapEvent.getOperation()) {
case STYLE:
olMapMng.getOLMap().setLayerStyleForIndex(updateLayerToMapEvent.getLayerName(),
updateLayerToMapEvent.getValue());
break;
default:
break;
}
}
}
}
});
} }
/** /**
@ -1072,7 +875,7 @@ public class GeoportalDataViewer implements EntryPoint {
* @return the general error panel * @return the general error panel
*/ */
private FlowPanel getGeneralErrorPanel() { private FlowPanel getGeneralErrorPanel() {
Image geoportalError = new Image(GeoportalImages.ICONS.geoportaServiceError()); Image geoportalError = new Image(GNAImages.ICONS.geoportaServiceError());
FlowPanel errorPanelMsg = new FlowPanel(); FlowPanel errorPanelMsg = new FlowPanel();
errorPanelMsg.getElement().addClassName("general_error"); errorPanelMsg.getElement().addClassName("general_error");
errorPanelMsg.add(geoportalError); errorPanelMsg.add(geoportalError);
@ -1092,10 +895,34 @@ public class GeoportalDataViewer implements EntryPoint {
*/ */
private void showLayerFeatures(LayerItem layerItem, String geoJSONFeatures, ProjectDV projectDV) { private void showLayerFeatures(LayerItem layerItem, String geoJSONFeatures, ProjectDV projectDV) {
Feature[] features = OLGeoJSONUtil.readGeoJsonFeatures(MAP_PROJECTION.EPSG_4326, geoJSONFeatures); GeoJsonFeatureOptions fo = new GeoJsonFeatureOptions();
ProjectionOptions projectionOptions = new ProjectionOptions();
projectionOptions.setCode(MAP_PROJECTION.EPSG_4326.getName());
Projection fp = new Projection(projectionOptions);
fo.setFeatureProjection(fp);
fo.setDataProjection(fp);
GeoJsonOptions geoJsonOpt = new GeoJsonOptions();
geoJsonOpt.setDefaultDataProjection(fp);
geoJsonOpt.setFeatureProjection(fp);
GeoJson geoJson = OLFactory.createGeoJSON(geoJsonOpt);
Feature[] features = geoJson.readFeatures(geoJSONFeatures);
GWT.log("features: " + features); GWT.log("features: " + features);
olMapMng.getOLMap().addLayerFeaturesAsHighlight(layerItem, features, true); olMapMng.getOLMap().addLayerFeaturesAsHighlight(layerItem, features, true);
/* Fit to extent calculating the features extent
if (projectDV != null) {
GeoJSON spatialReference = projectDV.getSpatialReference();
GWT.log("spatialReference is: " + spatialReference);
Coordinate transfCoord = MapUtils.geoJSONTToBBoxCenter(spatialReference, MAP_PROJECTION.EPSG_4326.getName(),
MAP_PROJECTION.EPSG_3857.getName());
GWT.log("transfCoord is: " + transfCoord);
if (transfCoord != null)
olMapMng.getOLMap().setCenter(transfCoord);
}
*/
} }
} }

View File

@ -3,7 +3,6 @@ package org.gcube.portlets.user.geoportaldataviewer.client;
import org.gcube.application.geoportalcommon.ConvertToDataViewModel; import org.gcube.application.geoportalcommon.ConvertToDataViewModel;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayersMapParameters; import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayersMapParameters;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.Element;
import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.i18n.client.DateTimeFormat;
@ -16,17 +15,6 @@ import com.google.gwt.i18n.client.DateTimeFormat;
*/ */
public class GeoportalDataViewerConstants { public class GeoportalDataViewerConstants {
//Geoportal_Exporter_ACTION_SERVLET
public static final String UCD_ID_PARAMETER = "ucdID";
public static final String PROIECT_ID_PARAMETER = "projectID";
public static final String CONTEXT_ID_PARAMETER = "c_id";
public static final String USER_ID_PARAMETER = "u_id";
public static final String USERNAME_PARAMETER = "usn";
public static final String GEOPORTAL_EXPORT_ACTION_SERVLET = GWT.getModuleBaseURL()
+ "geoportalexporterservice";
public static final int TABLET_WIDTH = 1601;
public static final String MAP_DIV = "map"; public static final String MAP_DIV = "map";
public static final String GET_WMS_PARAMETER = "wmsrequest"; public static final String GET_WMS_PARAMETER = "wmsrequest";
@ -38,9 +26,6 @@ public class GeoportalDataViewerConstants {
public static final String GET_ZOOM = OpenLayersMapParameters.OL_MAP_PARAM.zoom.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 final String GET_CENTER_MAP_TO_LONG_LAT = OpenLayersMapParameters.OL_MAP_PARAM.centermap.name();
public static final Double INITIAL_LAYER_OPACITY = 0.8;
public static final int SEARCH_LIMIT_RESULTS_TO_MAXIMUM = 50;
public static final DateTimeFormat DATE_TIME_FORMAT = DateTimeFormat.getFormat("dd MMMM yyyy"); public static final DateTimeFormat DATE_TIME_FORMAT = DateTimeFormat.getFormat("dd MMMM yyyy");
public static enum MapEventType { public static enum MapEventType {
@ -49,29 +34,6 @@ public class GeoportalDataViewerConstants {
public static final String PROJECT_ID_KEY_FEATURE = "projectid"; public static final String PROJECT_ID_KEY_FEATURE = "projectid";
public static enum GisToolbarFacilities {
COLLECTION("Collection", "Open the collections"), MAP("Map", "Select the base Map"),
OVERLAY("Overlay", "Add overlay layers"), SEARCH("Search", "Search in the collections"),
FILTER("Filter", "Apply spatial filtering"), LAYERS("Layers", "Layers added to Map"),
PRESET_LOCATION("Preset Location", "Center the Map to Location");
String name;
String tooltip;
GisToolbarFacilities(String name, String tooltip) {
this.name = name;
this.tooltip = tooltip;
}
public String getName() {
return name;
}
public String getTooltip() {
return tooltip;
}
}
/** /**
* The Enum LayerType. * The Enum LayerType.
* *
@ -190,8 +152,7 @@ public class GeoportalDataViewerConstants {
var tabCell = tr.insertCell(-1); var tabCell = tr.insertCell(-1);
var theValue = jsonObj[j][col[i]]; var theValue = jsonObj[j][col[i]];
//console.log("the value: "+theValue); //console.log("the value: "+theValue);
if (theValue !== null if (theValue !== null && Object.prototype.toString.call(theValue) === '[object Array]') {
&& Object.prototype.toString.call(theValue) === '[object Array]') {
var formattedValueArray = ""; var formattedValueArray = "";
for (var k = 0; k < theValue.length; k++) { for (var k = 0; k < theValue.length; k++) {
var theValueArray = theValue[k]; var theValueArray = theValue[k];

View File

@ -2,19 +2,15 @@ package org.gcube.portlets.user.geoportaldataviewer.client;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile; import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences; import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences;
import org.gcube.application.geoportalcommon.shared.SearchingFilter; import org.gcube.application.geoportalcommon.shared.SearchingFilter;
import org.gcube.application.geoportalcommon.shared.geoportal.config.GroupedLayersDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.layers.LayerIDV;
import org.gcube.application.geoportalcommon.shared.geoportal.geojson.GeoJSON; import org.gcube.application.geoportalcommon.shared.geoportal.geojson.GeoJSON;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.GCubeSDIViewerLayerDV; import org.gcube.application.geoportalcommon.shared.geoportal.materialization.GCubeSDIViewerLayerDV;
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_DATA_HANDLER;
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView; import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
import org.gcube.application.geoportalcommon.shared.gis.BoundsMap; import org.gcube.application.geoportalcommon.shared.gis.BoundsMap;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoportalSpatialQueryResult; import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult;
import org.gcube.portlets.user.geoportaldataviewer.shared.ItemFieldsResponse; import org.gcube.portlets.user.geoportaldataviewer.shared.ItemFieldsResponse;
import org.gcube.portlets.user.geoportaldataviewer.shared.ResultSetPaginatedDataIDs; import org.gcube.portlets.user.geoportaldataviewer.shared.ResultSetPaginatedDataIDs;
import org.gcube.portlets.user.geoportaldataviewer.shared.ViewerConfiguration; import org.gcube.portlets.user.geoportaldataviewer.shared.ViewerConfiguration;
@ -57,8 +53,8 @@ public interface GeoportalDataViewerService extends RemoteService {
* @return the data result * @return the data result
* @throws Exception the exception * @throws Exception the exception
*/ */
List<GeoportalSpatialQueryResult> getDataResult(List<LayerObject> layerObjects, String mapSrsName, List<GeoNaSpatialQueryResult> getDataResult(List<LayerObject> layerObjects, String mapSrsName, BoundsMap mapBBOX,
BoundsMap mapBBOX, int maxWFSFeature, double zoomLevel) throws Exception; int maxWFSFeature, double zoomLevel) throws Exception;
/** /**
* Gets the my login. * Gets the my login.
@ -104,7 +100,7 @@ public interface GeoportalDataViewerService extends RemoteService {
* @param zoomLevel the zoom level * @param zoomLevel the zoom level
* @return the WFS features * @return the WFS features
*/ */
List<GeoportalSpatialQueryResult> getWFSFeatures(List<LayerObject> layerObjects, String mapSrsName, List<GeoNaSpatialQueryResult> getWFSFeatures(List<LayerObject> layerObjects, String mapSrsName,
BoundsMap selectBBOX, int maxWFSFeature, double zoomLevel); BoundsMap selectBBOX, int maxWFSFeature, double zoomLevel);
/** /**
@ -187,10 +183,10 @@ public interface GeoportalDataViewerService extends RemoteService {
/** /**
* Gets the WFS request. * Gets the WFS request.
* *
* @param layerItem the layer item * @param layerItem the layer item
* @param mapSrsName the map srs name * @param mapSrsName the map srs name
* @param mapBBOX the map BBOX * @param mapBBOX the map BBOX
* @param maxFeatures the max features. If 0 means all feature * @param maxFeatures the max features. If 0 means all feature
* @param outputFormat the output format * @param outputFormat the output format
* @return the WFS request * @return the WFS request
*/ */
@ -210,25 +206,4 @@ public interface GeoportalDataViewerService extends RemoteService {
String getWFSResponse(LayerItem layerItem, String mapSrsName, BoundsMap mapBBOX, int maxFeatures, String getWFSResponse(LayerItem layerItem, String mapSrsName, BoundsMap mapBBOX, int maxFeatures,
String outputFormat); String outputFormat);
/**
* Gets the avaiable custom grouped layers for UCD.
*
* @param theHandler the the handler
* @return the avaiable custom grouped layers for UCD
*/
Map<String, List<GroupedLayersDV<? extends LayerIDV>>> getAvaiableCustomGroupedLayersForUCD(
GEOPORTAL_DATA_HANDLER theHandler);
/**
* Gets the HTTP response for URL.
*
* @param url the url
* @return the HTTP response for URL
*/
String getHTTPResponseForURL(String url);
Integer getCountFor(String profileID, String phase, String status);
Boolean checkExportAsPDFConfig();
} }

View File

@ -2,19 +2,15 @@ package org.gcube.portlets.user.geoportaldataviewer.client;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile; import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences; import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences;
import org.gcube.application.geoportalcommon.shared.SearchingFilter; import org.gcube.application.geoportalcommon.shared.SearchingFilter;
import org.gcube.application.geoportalcommon.shared.geoportal.config.GroupedLayersDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.layers.LayerIDV;
import org.gcube.application.geoportalcommon.shared.geoportal.geojson.GeoJSON; import org.gcube.application.geoportalcommon.shared.geoportal.geojson.GeoJSON;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.GCubeSDIViewerLayerDV; import org.gcube.application.geoportalcommon.shared.geoportal.materialization.GCubeSDIViewerLayerDV;
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_DATA_HANDLER;
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView; import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
import org.gcube.application.geoportalcommon.shared.gis.BoundsMap; import org.gcube.application.geoportalcommon.shared.gis.BoundsMap;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoportalSpatialQueryResult; import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult;
import org.gcube.portlets.user.geoportaldataviewer.shared.ItemFieldsResponse; import org.gcube.portlets.user.geoportaldataviewer.shared.ItemFieldsResponse;
import org.gcube.portlets.user.geoportaldataviewer.shared.ResultSetPaginatedDataIDs; import org.gcube.portlets.user.geoportaldataviewer.shared.ResultSetPaginatedDataIDs;
import org.gcube.portlets.user.geoportaldataviewer.shared.ViewerConfiguration; import org.gcube.portlets.user.geoportaldataviewer.shared.ViewerConfiguration;
@ -48,7 +44,7 @@ public interface GeoportalDataViewerServiceAsync {
void parseWmsRequest(String wmsRequest, String layerName, AsyncCallback<GeoInformationForWMSRequest> callback); void parseWmsRequest(String wmsRequest, String layerName, AsyncCallback<GeoInformationForWMSRequest> callback);
void getDataResult(List<LayerObject> layerObjects, String mapSrsName, BoundsMap mapBBOX, int maxWFSFeature, void getDataResult(List<LayerObject> layerObjects, String mapSrsName, BoundsMap mapBBOX, int maxWFSFeature,
double zoomLevel, AsyncCallback<List<GeoportalSpatialQueryResult>> callback); double zoomLevel, AsyncCallback<List<GeoNaSpatialQueryResult>> callback);
void getMyLogin(AsyncCallback<String> callback); void getMyLogin(AsyncCallback<String> callback);
@ -60,7 +56,7 @@ public interface GeoportalDataViewerServiceAsync {
AsyncCallback<List<GCubeSDIViewerLayerDV>> asyncCallback); AsyncCallback<List<GCubeSDIViewerLayerDV>> asyncCallback);
void getWFSFeatures(List<LayerObject> layerObjects, String mapSrsName, BoundsMap selectBBOX, int maxWFSFeature, void getWFSFeatures(List<LayerObject> layerObjects, String mapSrsName, BoundsMap selectBBOX, int maxWFSFeature,
double zoomLevel, AsyncCallback<List<GeoportalSpatialQueryResult>> callback); double zoomLevel, AsyncCallback<List<GeoNaSpatialQueryResult>> callback);
void getListBaseLayers(AsyncCallback<List<BaseMapLayer>> callback); void getListBaseLayers(AsyncCallback<List<BaseMapLayer>> callback);
@ -86,13 +82,4 @@ public interface GeoportalDataViewerServiceAsync {
void getWFSResponse(LayerItem layerItem, String mapSrsName, BoundsMap mapBBOX, int maxFeatures, String outputFormat, void getWFSResponse(LayerItem layerItem, String mapSrsName, BoundsMap mapBBOX, int maxFeatures, String outputFormat,
AsyncCallback<String> callback); AsyncCallback<String> callback);
void getAvaiableCustomGroupedLayersForUCD(GEOPORTAL_DATA_HANDLER theHandler,
AsyncCallback<Map<String, List<GroupedLayersDV<? extends LayerIDV>>>> callback);
void getHTTPResponseForURL(String url, AsyncCallback<String> callback);
void getCountFor(String profileID, String phase, String status, AsyncCallback<Integer> callback);
void checkExportAsPDFConfig(AsyncCallback<Boolean> callback);
} }

View File

@ -40,7 +40,7 @@ import org.gcube.portlets.user.geoportaldataviewer.client.ui.ModalWindow;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.project.ProjectUtil; import org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.project.ProjectUtil;
import org.gcube.portlets.user.geoportaldataviewer.client.util.StringUtil; import org.gcube.portlets.user.geoportaldataviewer.client.util.StringUtil;
import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil; import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoportalSpatialQueryResult; import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery; 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.LayerItem;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject;
@ -94,9 +94,6 @@ import ol.geom.Geometry;
*/ */
public class LayerManager { public class LayerManager {
private static final String ZOOM_TO_LAYERS_LABEL = "Zoom...";
private static final String ZOOM_TO_LAYERS_TITLE = "Zoom to Layers";
/** The ol map. */ /** The ol map. */
private OpenLayerMap olMap; private OpenLayerMap olMap;
@ -190,7 +187,7 @@ public class LayerManager {
GeoportalDataViewerServiceAsync.Util.getInstance().getDataResult(listLO, olMap.getProjectionCode(), GeoportalDataViewerServiceAsync.Util.getInstance().getDataResult(listLO, olMap.getProjectionCode(),
mapBBOX, GeoportalDataViewerConstants.MAX_WFS_FEATURES, olMap.getCurrentZoomLevel(), mapBBOX, GeoportalDataViewerConstants.MAX_WFS_FEATURES, olMap.getCurrentZoomLevel(),
new AsyncCallback<List<GeoportalSpatialQueryResult>>() { new AsyncCallback<List<GeoNaSpatialQueryResult>>() {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
@ -199,7 +196,7 @@ public class LayerManager {
} }
@Override @Override
public void onSuccess(List<GeoportalSpatialQueryResult> listGeonaDataObjects) { public void onSuccess(List<GeoNaSpatialQueryResult> listGeonaDataObjects) {
if (listGeonaDataObjects == null) if (listGeonaDataObjects == null)
return; return;
@ -221,7 +218,7 @@ public class LayerManager {
List<FeatureRow> theFeatures = null; List<FeatureRow> theFeatures = null;
// TODO SWTCH FOR EARCH ITEM TYPE // TODO SWTCH FOR EARCH ITEM TYPE
for (final GeoportalSpatialQueryResult geoNaDataObject : listGeonaDataObjects) { for (final GeoNaSpatialQueryResult geoNaDataObject : listGeonaDataObjects) {
GWT.log("GeoNaDataObject: " + geoNaDataObject); GWT.log("GeoNaDataObject: " + geoNaDataObject);
List<FeatureRow> features = geoNaDataObject.getFeatures(); List<FeatureRow> features = geoNaDataObject.getFeatures();
LayerItem layerItem = geoNaDataObject.getSourceLayerObject().getLayerItem(); LayerItem layerItem = geoNaDataObject.getSourceLayerObject().getLayerItem();
@ -515,7 +512,7 @@ public class LayerManager {
GWT.log("Parsed WMS Request returned: " + geoInfoWMS); GWT.log("Parsed WMS Request returned: " + geoInfoWMS);
LayerItem layerItem = toLayerItem(featureType, layerTitle, geoInfoWMS.getLayerName(), LayerItem layerItem = toLayerItem(featureType, layerTitle, geoInfoWMS.getLayerName(),
geoInfoWMS.getWmsRequest(), geoInfoWMS.getServiceEndPoint(), true, isBase, geoInfoWMS.getWmsRequest(), geoInfoWMS.getBaseWmsServiceHost(), true, isBase,
displayInLayerSwitcher, (ArrayList<String>) geoInfoWMS.getStyles().getGeoStyles(), displayInLayerSwitcher, (ArrayList<String>) geoInfoWMS.getStyles().getGeoStyles(),
geoInfoWMS.getWmsRequest(), false, geoInfoWMS.getMapWMSNoStandard(), geoInfoWMS.getWmsRequest(), false, geoInfoWMS.getMapWMSNoStandard(),
geoInfoWMS.isNcWMS(), UUID, geoInfoWMS.getZAxis(), minResolution, maxResolution); geoInfoWMS.isNcWMS(), UUID, geoInfoWMS.getZAxis(), minResolution, maxResolution);
@ -553,7 +550,7 @@ public class LayerManager {
theLo = lo; theLo = lo;
mapOtherLayerObjects.put(layerNameKey, theLo); mapOtherLayerObjects.put(layerNameKey, theLo);
GWT.log("PROJECT_LAYER mapOtherLayerObjects is: " + mapOtherLayerObjects); GWT.log("PROJECT_LAYER mapOtherLayerObjects is: " + mapOtherLayerObjects);
olMap.addWMSDetailLayer(layerItem, GeoportalDataViewerConstants.INITIAL_LAYER_OPACITY); olMap.addWMSDetailLayer(layerItem);
overlayLayerManager.addLayerItem(theLo); overlayLayerManager.addLayerItem(theLo);
} else { } else {
GWT.log("Skipping " + lo.getType() + " layer " + theLo.getLayerItem().getName() GWT.log("Skipping " + lo.getType() + " layer " + theLo.getLayerItem().getName()
@ -582,7 +579,9 @@ public class LayerManager {
public void setCQLForLayerToIndexLayer(String layerName, String cqlFilter) { public void setCQLForLayerToIndexLayer(String layerName, String cqlFilter) {
LayerObject theLo = mapIndexLayerObjects.get(layerName); LayerObject theLo = mapIndexLayerObjects.get(layerName);
if (theLo != null) { if (theLo != null) {
boolean isCQLFilter = cqlFilter != null;
theLo.getLayerItem().setCqlFilter(cqlFilter); theLo.getLayerItem().setCqlFilter(cqlFilter);
theLo.getLayerItem().setCqlFilterAvailable(isCQLFilter);
} }
} }
@ -709,7 +708,7 @@ public class LayerManager {
* @param listGeoNaDataObject the list geo na data object * @param listGeoNaDataObject the list geo na data object
* @param queryClick the query click * @param queryClick the query click
*/ */
public void showPopupInfoForLayer(List<GeoportalSpatialQueryResult> listGeoNaDataObject, ExtentWrapped queryClick) { public void showPopupInfoForLayer(List<GeoNaSpatialQueryResult> listGeoNaDataObject, ExtentWrapped queryClick) {
GWT.log("showPopupInfoForLayer called for " + listGeoNaDataObject); GWT.log("showPopupInfoForLayer called for " + listGeoNaDataObject);
ScrollPanel scrollPanel = new ScrollPanel(); ScrollPanel scrollPanel = new ScrollPanel();
@ -767,7 +766,7 @@ public class LayerManager {
// } // }
String prevProjectId = ""; String prevProjectId = "";
for (GeoportalSpatialQueryResult geoNaSpatialQueryResult : listGeoNaDataObject) { for (GeoNaSpatialQueryResult geoNaSpatialQueryResult : listGeoNaDataObject) {
try { try {
Set<String> indexLayers = mapIndexLayerObjects.keySet(); Set<String> indexLayers = mapIndexLayerObjects.keySet();
@ -807,8 +806,7 @@ public class LayerManager {
TemporalReferenceDV tempRef = projectDV.getTemporalReference(); TemporalReferenceDV tempRef = projectDV.getTemporalReference();
if (tempRef != null) { if (tempRef != null) {
if(tempRef.getStart()!=null || tempRef.getEnd()!=null) flowPanel.add(new HTML(ProjectUtil.toHTMLCode(tempRef)));
flowPanel.add(new HTML(ProjectUtil.toHTMLCode(tempRef)));
} }
Button buttOpenProject = new Button("Open Project"); Button buttOpenProject = new Button("Open Project");
@ -959,8 +957,7 @@ public class LayerManager {
GWT.log("Temporal reference is: "+tempRef); GWT.log("Temporal reference is: "+tempRef);
if (tempRef != null) { if (tempRef != null) {
if(tempRef.getStart()!=null || tempRef.getEnd()!=null) flex.setHTML(flex.getRowCount() + 1, 0, ProjectUtil.toHTMLCode(tempRef));
flex.setHTML(flex.getRowCount() + 1, 0, ProjectUtil.toHTMLCode(tempRef));
} }
List<SectionView> selections = projectView.getListSections(); List<SectionView> selections = projectView.getListSections();
@ -976,7 +973,7 @@ public class LayerManager {
if (payloads != null && payloads.size() > 0) { if (payloads != null && payloads.size() > 0) {
PayloadDV img = payloads.get(0); PayloadDV img = payloads.get(0);
if (img != null && img.getLink() != null) { if (img != null && img.getLink() != null) {
String theImgHTML = "<div id='pop-img'><img src=\"" + img.getLink() + "\"></img></div>"; String theImgHTML = "<img src=\"" + img.getLink() + "\"></img>";
GWT.log("theImgHTML: " + theImgHTML); GWT.log("theImgHTML: " + theImgHTML);
flex.setHTML(flex.getRowCount() + 1, 0, theImgHTML); flex.setHTML(flex.getRowCount() + 1, 0, theImgHTML);
firstImageFound = true; firstImageFound = true;
@ -1011,9 +1008,9 @@ public class LayerManager {
} }
}); });
final Button buttonViewLayers = new Button(ZOOM_TO_LAYERS_LABEL); final Button buttonViewLayers = new Button("Zoom to Layers");
buttonViewLayers.getElement().setId("go-to-layers"); buttonViewLayers.getElement().setId("go-to-layers");
buttonViewLayers.getElement().setTitle(ZOOM_TO_LAYERS_TITLE); buttonViewLayers.getElement().setTitle("Zoom to Layers");
buttonViewLayers.setType(ButtonType.LINK); buttonViewLayers.setType(ButtonType.LINK);
if (olMap.getCurrentZoomLevel() >= OLMapManager.LAYER_DETAIL_MAX_RESOLUTION) { if (olMap.getCurrentZoomLevel() >= OLMapManager.LAYER_DETAIL_MAX_RESOLUTION) {
@ -1123,7 +1120,7 @@ public class LayerManager {
* @param feature the feature * @param feature the feature
* @param onFailureCenterTo the on failure center to * @param onFailureCenterTo the on failure center to
*/ */
public void showPopupInfoForCentroidLayer(GeoportalSpatialQueryResult geoNaDataObject, FeatureRow feature, public void showPopupInfoForCentroidLayer(GeoNaSpatialQueryResult geoNaDataObject, FeatureRow feature,
Coordinate onFailureCenterTo) { Coordinate onFailureCenterTo) {
GWT.log("showPopupInfoForCentroidLayer showing feature: " + feature); GWT.log("showPopupInfoForCentroidLayer showing feature: " + feature);
GWT.log("showPopupInfoForCentroidLayer showing layerObject: " + geoNaDataObject.getSourceLayerObject()); GWT.log("showPopupInfoForCentroidLayer showing layerObject: " + geoNaDataObject.getSourceLayerObject());
@ -1142,7 +1139,6 @@ public class LayerManager {
FlexTable intFlex = new FlexTable(); FlexTable intFlex = new FlexTable();
intFlex.setCellPadding(1); intFlex.setCellPadding(1);
intFlex.setCellSpacing(1); intFlex.setCellSpacing(1);
intFlex.getElement().addClassName("thePopDataTable");
if (projectDV.getTheDocument() != null) { if (projectDV.getTheDocument() != null) {
LinkedHashMap<String, Object> map = projectDV.getTheDocument().getDocumentAsMap(); LinkedHashMap<String, Object> map = projectDV.getTheDocument().getDocumentAsMap();
// my-html-table // my-html-table
@ -1166,8 +1162,8 @@ public class LayerManager {
TemporalReferenceDV tempRef = projectDV.getTemporalReference(); TemporalReferenceDV tempRef = projectDV.getTemporalReference();
if (tempRef != null) { if (tempRef != null) {
if(tempRef.getStart()!=null || tempRef.getEnd()!=null)
flex.setHTML(flex.getRowCount() + 1, 0, ProjectUtil.toHTMLCode(tempRef)); flex.setHTML(flex.getRowCount() + 1, 0, ProjectUtil.toHTMLCode(tempRef));
} }
} }
@ -1178,7 +1174,7 @@ public class LayerManager {
if (listUI != null && listUI.size() > 0) { if (listUI != null && listUI.size() > 0) {
PayloadDV img = listUI.get(0); PayloadDV img = listUI.get(0);
if (img != null && img.getLink() != null) { if (img != null && img.getLink() != null) {
String theImgHTML = "<div id='pop-img'><img src=\"" + img.getLink() + "\"></img></div>"; String theImgHTML = "<img src=\"" + img.getLink() + "\"></img>";
GWT.log("theImgHTML: " + theImgHTML); GWT.log("theImgHTML: " + theImgHTML);
// GeoportalDataViewerConstants.print("The row are: // GeoportalDataViewerConstants.print("The row are:
// "+flex.getRowCount()); // "+flex.getRowCount());
@ -1204,9 +1200,9 @@ public class LayerManager {
} }
}); });
final Button buttonViewLayers = new Button(ZOOM_TO_LAYERS_LABEL); final Button buttonViewLayers = new Button("Zoom to Layers");
buttonViewLayers.getElement().setId("go-to-layers"); buttonViewLayers.getElement().setId("go-to-layers");
buttonViewLayers.getElement().setTitle(ZOOM_TO_LAYERS_TITLE); buttonViewLayers.getElement().setTitle("Zoom to Layers");
buttonViewLayers.setType(ButtonType.LINK); buttonViewLayers.setType(ButtonType.LINK);
if (olMap.getCurrentZoomLevel() >= OLMapManager.LAYER_DETAIL_MAX_RESOLUTION) { if (olMap.getCurrentZoomLevel() >= OLMapManager.LAYER_DETAIL_MAX_RESOLUTION) {

View File

@ -1,72 +0,0 @@
package org.gcube.portlets.user.geoportaldataviewer.client.events;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.IndexLayerDV;
import com.google.gwt.event.shared.GwtEvent;
/**
* The Class AddedLayerToMapEvent.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Nov 18, 2020
*/
public class ApplyCQLToLayerOnMapEvent extends GwtEvent<ApplyCQLToLayerOnMapEventHandler> {
public static Type<ApplyCQLToLayerOnMapEventHandler> TYPE = new Type<ApplyCQLToLayerOnMapEventHandler>();
private IndexLayerDV theIndeLayer;
private String cqlFilterValue;
/**
* Instantiates a new apply CQL to layer map event.
*
* @param theIndeLayer the the inde layer
* @param cqlFilter the cql filter
*/
public ApplyCQLToLayerOnMapEvent(IndexLayerDV theIndeLayer, String cqlFilterValue) {
this.theIndeLayer = theIndeLayer;
this.cqlFilterValue = cqlFilterValue;
}
/**
* Gets the associated type.
*
* @return the associated type
*/
@Override
public Type<ApplyCQLToLayerOnMapEventHandler> getAssociatedType() {
return TYPE;
}
/**
* Dispatch.
*
* @param handler the handler
*/
@Override
protected void dispatch(ApplyCQLToLayerOnMapEventHandler handler) {
handler.onApplyCQL(this);
}
public IndexLayerDV getTheIndeLayer() {
return theIndeLayer;
}
public String getCqlFilterValue() {
return cqlFilterValue;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("ApplyCQLToLayerOnMapEvent [theIndeLayer=");
builder.append(theIndeLayer);
builder.append(", cqlFilterValue=");
builder.append(cqlFilterValue);
builder.append("]");
return builder.toString();
}
}

View File

@ -1,20 +0,0 @@
package org.gcube.portlets.user.geoportaldataviewer.client.events;
import com.google.gwt.event.shared.EventHandler;
/**
* The Interface ApplyCQLToLayerOnMapEventHandler.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* May 31, 2023
*/
public interface ApplyCQLToLayerOnMapEventHandler extends EventHandler {
/**
* On apply CQL.
*
* @param applyCQLToLayerMapEvent the apply CQL to layer map event
*/
void onApplyCQL(ApplyCQLToLayerOnMapEvent applyCQLToLayerMapEvent);
}

View File

@ -1,52 +0,0 @@
package org.gcube.portlets.user.geoportaldataviewer.client.events;
import com.google.gwt.event.shared.GwtEvent;
import ol.Extent;
/**
* The Class FitMapToExtentEvent.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jun 6, 2023
*/
public class FitMapToExtentEvent extends GwtEvent<FitMapToExtentEventHandler> {
public static Type<FitMapToExtentEventHandler> TYPE = new Type<FitMapToExtentEventHandler>();
private Extent extent;
/**
* Instantiates a new fit map to extent event.
*
* @param extent the extent
*/
public FitMapToExtentEvent(Extent extent) {
this.extent = extent;
}
/**
* Gets the associated type.
*
* @return the associated type
*/
@Override
public Type<FitMapToExtentEventHandler> getAssociatedType() {
return TYPE;
}
/**
* Dispatch.
*
* @param handler the handler
*/
@Override
protected void dispatch(FitMapToExtentEventHandler handler) {
handler.onFitToMap(this);
}
public Extent getExtent() {
return extent;
}
}

View File

@ -1,20 +0,0 @@
package org.gcube.portlets.user.geoportaldataviewer.client.events;
import com.google.gwt.event.shared.EventHandler;
/**
* The Interface FitMapToExtentEventHandler.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jun 6, 2023
*/
public interface FitMapToExtentEventHandler extends EventHandler {
/**
* On fit to map.
*
* @param fitMapToExtentEvent the fit map to extent event
*/
void onFitToMap(FitMapToExtentEvent fitMapToExtentEvent);
}

View File

@ -1,92 +0,0 @@
package org.gcube.portlets.user.geoportaldataviewer.client.events;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
import com.google.gwt.event.shared.GwtEvent;
/**
* The Class OverlayCustomLayerToMapEvent.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* May 15, 2023
*/
public class OverlayCustomLayerToMapEvent extends GwtEvent<OverlayCustomLayerToMapEventHandler> {
public static Type<OverlayCustomLayerToMapEventHandler> TYPE = new Type<OverlayCustomLayerToMapEventHandler>();
private LayerItem layerItem;
private ACTION_TYPE actionType;
private boolean enabled;
/**
* The Enum ACTION_TYPE.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* May 15, 2023
*/
public enum ACTION_TYPE {
VISIBILITY
}
/**
* Instantiates a new overlay custom layer to map event.
*
* @param layerItem the layer item
* @param actionType the action type
* @param enabled the enabled
*/
public OverlayCustomLayerToMapEvent(LayerItem layerItem, ACTION_TYPE actionType, boolean enabled) {
this.layerItem = layerItem;
this.actionType = actionType;
this.enabled = enabled;
}
/**
* Gets the associated type.
*
* @return the associated type
*/
@Override
public Type<OverlayCustomLayerToMapEventHandler> getAssociatedType() {
return TYPE;
}
/**
* Dispatch.
*
* @param handler the handler
*/
@Override
protected void dispatch(OverlayCustomLayerToMapEventHandler handler) {
handler.onCustomOverlayLayerAction(this);
}
/**
* Gets the layer item.
*
* @return the layer item
*/
public LayerItem getLayerItem() {
return layerItem;
}
/**
* Gets the action type.
*
* @return the action type
*/
public ACTION_TYPE getActionType() {
return actionType;
}
/**
* Checks if is enabled.
*
* @return true, if is enabled
*/
public boolean isEnabled() {
return enabled;
}
}

View File

@ -1,20 +0,0 @@
package org.gcube.portlets.user.geoportaldataviewer.client.events;
import com.google.gwt.event.shared.EventHandler;
/**
* The Interface OverlayCustomLayerToMapEventHandler.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* May 15, 2023
*/
public interface OverlayCustomLayerToMapEventHandler extends EventHandler {
/**
* On custom overlay layer action.
*
* @param customOverLayerToMapEvent the custom over layer to map event
*/
void onCustomOverlayLayerAction(OverlayCustomLayerToMapEvent customOverLayerToMapEvent);
}

View File

@ -1,134 +0,0 @@
package org.gcube.portlets.user.geoportaldataviewer.client.events;
import org.gcube.portlets.user.geoportaldataviewer.shared.GCubeCollection;
import com.google.gwt.event.shared.GwtEvent;
/**
* The Class UpdateLayerToMapEvent.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jun 15, 2023
*/
public class UpdateLayerToMapEvent extends GwtEvent<UpdateLayerToMapEventHandler> {
public static Type<UpdateLayerToMapEventHandler> TYPE = new Type<UpdateLayerToMapEventHandler>();
private GCubeCollection collection;
private String layerName;
private REQUEST_PARAMETER operation;
private String value;
private LAYER_TYPE layerType;
/**
* The Enum REQUEST_PARAMETER.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jun 15, 2023
*/
public static enum REQUEST_PARAMETER {
STYLE
}
/**
* The Enum LAYER_TYPE.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jun 15, 2023
*/
public static enum LAYER_TYPE {
INDEX, DETAILS
}
/**
* Instantiates a new adds the layer to map event.
*
* @param collection the collection
* @param layerName the layer name
* @param type the type
*/
public UpdateLayerToMapEvent(GCubeCollection collection, String layerName, LAYER_TYPE type) {
this.collection = collection;
this.layerName = layerName;
this.layerType = type;
}
/**
* Gets the associated type.
*
* @return the associated type
*/
@Override
public Type<UpdateLayerToMapEventHandler> getAssociatedType() {
return TYPE;
}
/**
* Sets the operation.
*
* @param operation the operation
* @param value the value
*/
public void setOperation(REQUEST_PARAMETER operation, String value) {
this.operation = operation;
this.value = value;
}
/**
* Gets the value.
*
* @return the value
*/
public String getValue() {
return value;
}
/**
* Gets the layer type.
*
* @return the layer type
*/
public LAYER_TYPE getLayerType() {
return layerType;
}
/**
* Gets the operation.
*
* @return the operation
*/
public REQUEST_PARAMETER getOperation() {
return operation;
}
/**
* Gets the layer name.
*
* @return the layer name
*/
public String getLayerName() {
return layerName;
}
/**
* Gets the collection.
*
* @return the collection
*/
public GCubeCollection getCollection() {
return collection;
}
/**
* Dispatch.
*
* @param handler the handler
*/
@Override
protected void dispatch(UpdateLayerToMapEventHandler handler) {
handler.onUpdateLayer(this);
}
}

View File

@ -1,20 +0,0 @@
package org.gcube.portlets.user.geoportaldataviewer.client.events;
import com.google.gwt.event.shared.EventHandler;
/**
* The Interface UpdateLayerToMapEventHandler.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jun 15, 2023
*/
public interface UpdateLayerToMapEventHandler extends EventHandler {
/**
* On update layer.
*
* @param updateLayerToMapEvent the update layer to map event
*/
void onUpdateLayer(UpdateLayerToMapEvent updateLayerToMapEvent);
}

View File

@ -32,15 +32,15 @@ public class ExtentWrapped extends ol.Extent {
super(minX, minY, maxX, maxY); super(minX, minY, maxX, maxY);
} }
// /** /**
// * @param coordinate coordinate to check. * @param coordinate coordinate to check.
// * @return true if the passed coordinate is contained or on the edge of the * @return true if the passed coordinate is contained or on the edge of the
// * extent. * extent.
// */ */
// @JsOverlay @JsOverlay
// public final Coordinate getCenter() { public final Coordinate getCenter() {
// return getCenter((ol.Extent) this); return getCenter((ol.Extent) this);
// } }
@JsMethod(name = "getCenter", namespace = PACKAGE_EXTENT) @JsMethod(name = "getCenter", namespace = PACKAGE_EXTENT)
private static native Coordinate getCenter(Extent extent); private static native Coordinate getCenter(Extent extent);

View File

@ -19,18 +19,17 @@ public class LayerOrder {
* Nov 12, 2021 * Nov 12, 2021
*/ */
public static enum LAYER_TYPE { public static enum LAYER_TYPE {
BASE_MAP, CUSTOM_WMS_DETAIL, BASE_WMS, WMS_DETAIL, VECTOR BASE_MAP, BASE_WMS, WMS_DETAIL, VECTOR
} }
public static final HashMap<LAYER_TYPE, Integer> LAYER_OFFSET = new HashMap<LAYER_TYPE, Integer>(5); public static final HashMap<LAYER_TYPE, Integer> LAYER_OFFSET = new HashMap<LAYER_TYPE, Integer>(5);
static { static {
LAYER_OFFSET.put(LAYER_TYPE.BASE_MAP, 0); //Base OL or MapBox LAYER_OFFSET.put(LAYER_TYPE.BASE_MAP, 0);
LAYER_OFFSET.put(LAYER_TYPE.CUSTOM_WMS_DETAIL, 70); //WMS custom Overlay. Es. Layer "Limiti Amministrativi" LAYER_OFFSET.put(LAYER_TYPE.BASE_WMS, 70);
LAYER_OFFSET.put(LAYER_TYPE.BASE_WMS, 210); // Index layers (i.e. centroids for UCD) LAYER_OFFSET.put(LAYER_TYPE.WMS_DETAIL, 140);
LAYER_OFFSET.put(LAYER_TYPE.WMS_DETAIL, 140); //Layer/s belonging to a Project (materialized layers. Ex. "Posizionamento Scavo") LAYER_OFFSET.put(LAYER_TYPE.VECTOR, 210);
LAYER_OFFSET.put(LAYER_TYPE.VECTOR, 320); //Vector layer to show other info. Ex. Pointer with coordinates (x,y) in the Light OL Map.
} }
/** /**

View File

@ -8,7 +8,7 @@ import org.gcube.application.geoportalcommon.shared.gis.BoundsMap;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewer; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewer;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants; 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.GeoportalDataViewerConstants.MAP_PROJECTION;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.GeoportalImages; import org.gcube.portlets.user.geoportaldataviewer.client.resources.GNAImages;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery.TYPE; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery.TYPE;
@ -87,7 +87,7 @@ public class LightOpenLayerMap {
private ol.layer.Vector geometryLayer; private ol.layer.Vector geometryLayer;
private String markerURL = GeoportalImages.ICONS.mapMarkerIcon().getURL(); private String markerURL = GNAImages.ICONS.mapMarkerIcon().getURL();
private LayerOrder layerOrder = new LayerOrder(); private LayerOrder layerOrder = new LayerOrder();

View File

@ -6,7 +6,6 @@ import com.google.gwt.core.client.GWT;
import ol.Collection; import ol.Collection;
import ol.Coordinate; import ol.Coordinate;
import ol.Extent;
import ol.control.Attribution; import ol.control.Attribution;
import ol.control.Control; import ol.control.Control;
import ol.control.FullScreen; import ol.control.FullScreen;
@ -56,18 +55,6 @@ public final class MapUtils {
return Projection.transform(centerCoordinate, source, target); return Projection.transform(centerCoordinate, source, target);
} }
/**
* Transform extent.
*
* @param extent the extent
* @param source the source
* @param target the target
* @return the extent
*/
public static Extent transformExtent(Extent extent, String source, String target) {
return Projection.transformExtent(extent, source, target);
}
/** /**
* Distance between centroid. * Distance between centroid.
* *
@ -108,14 +95,14 @@ public final class MapUtils {
} }
/** /**
* Geo JSON to B box center. * Geo JSONT to B box center.
* *
* @param spatialReference the spatial reference * @param spatialReference the spatial reference
* @param transforFrom the transfor from * @param transforFrom the transfor from
* @param transformTo the transform to * @param transformTo the transform to
* @return the coordinate * @return the coordinate
*/ */
public static Coordinate geoJSONToBBOXCenter(GeoJSON spatialReference, String transforFrom, String transformTo) { public static Coordinate geoJSONTToBBoxCenter(GeoJSON spatialReference, String transforFrom, String transformTo) {
try { try {
if (spatialReference != null) { if (spatialReference != null) {

View File

@ -1,7 +1,6 @@
package org.gcube.portlets.user.geoportaldataviewer.client.gis; package org.gcube.portlets.user.geoportaldataviewer.client.gis;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
@ -9,7 +8,6 @@ import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerCon
import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEvent.LAYER_TYPE; import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEvent.LAYER_TYPE;
import org.gcube.portlets.user.geoportaldataviewer.client.events.DoActionOnDetailLayersEvent.SwapLayer; import org.gcube.portlets.user.geoportaldataviewer.client.events.DoActionOnDetailLayersEvent.SwapLayer;
import org.gcube.portlets.user.geoportaldataviewer.client.util.WFSMakerUtil;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
@ -37,7 +35,6 @@ import ol.Overlay;
import ol.OverlayOptions; import ol.OverlayOptions;
import ol.Size; import ol.Size;
import ol.View; import ol.View;
import ol.ViewFitOptions;
import ol.ViewOptions; import ol.ViewOptions;
import ol.animation.AnimationOptions; import ol.animation.AnimationOptions;
import ol.color.Color; import ol.color.Color;
@ -81,8 +78,6 @@ import ol.style.Style;
*/ */
public abstract class OpenLayerMap { public abstract class OpenLayerMap {
public static final String CQL_FILTER_PARAMETER = WFSMakerUtil.CQL_FILTER_PARAMETER;
private static final int MAX_LENGHT_CQL_FOR_GET_REQUEST = 1600; // 1600 characters private static final int MAX_LENGHT_CQL_FOR_GET_REQUEST = 1600; // 1600 characters
public static final int SET_CENTER_ANIMATED_DURATION = 500; public static final int SET_CENTER_ANIMATED_DURATION = 500;
@ -91,19 +86,6 @@ public abstract class OpenLayerMap {
public static final int MAX_ZOOM = 21; public static final int MAX_ZOOM = 21;
/**
* The Enum CQL_FACILITY_ORIGIN.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jun 6, 2023
*/
public static enum CQL_FACILITY_ORIGIN {
SEARCH, CROSS_FILTERING
}
public HashMap<CQL_FACILITY_ORIGIN, String> cqlFilterMap = new HashMap<CQL_FACILITY_ORIGIN, String>();
/** /**
* Click listener. * Click listener.
* *
@ -167,8 +149,6 @@ public abstract class OpenLayerMap {
private LinkedHashMap<String, Image> wmsDetailsLayerMap; private LinkedHashMap<String, Image> wmsDetailsLayerMap;
private LinkedHashMap<String, Image> wmsGroupedCustomLayerMap;
private LinkedHashMap<String, Image> wmsLayerMap; private LinkedHashMap<String, Image> wmsLayerMap;
private LinkedHashMap<String, ol.layer.Vector> vectorLayersHighlighted = new LinkedHashMap<String, ol.layer.Vector>(); private LinkedHashMap<String, ol.layer.Vector> vectorLayersHighlighted = new LinkedHashMap<String, ol.layer.Vector>();
@ -367,7 +347,7 @@ public abstract class OpenLayerMap {
elPopup.getStyle().setVisibility(Visibility.VISIBLE); elPopup.getStyle().setVisibility(Visibility.VISIBLE);
if (popupOverlay == null) { if (popupOverlay == null) {
popupOverlay = addOverlay(elPopup); popupOverlay = addOverlay(elPopup);
addPopupCloserHandler(popupOverlay); addPopupCloserHandelr(popupOverlay);
} }
Element popContent = DOM.getElementById("popup-content"); Element popContent = DOM.getElementById("popup-content");
popContent.setInnerHTML(html); popContent.setInnerHTML(html);
@ -385,11 +365,11 @@ public abstract class OpenLayerMap {
} }
/** /**
* Adds the popup closer handler. * Adds the popup closer handelr.
* *
* @param popupOverlay the popup overlay * @param popupOverlay the popup overlay
*/ */
private void addPopupCloserHandler(Overlay popupOverlay) { private void addPopupCloserHandelr(Overlay popupOverlay) {
Element elPopupCloser = DOM.getElementById("popup-closer"); Element elPopupCloser = DOM.getElementById("popup-closer");
Event.sinkEvents(elPopupCloser, Event.ONCLICK); Event.sinkEvents(elPopupCloser, Event.ONCLICK);
Event.setEventListener(elPopupCloser, new com.google.gwt.user.client.EventListener() { Event.setEventListener(elPopupCloser, new com.google.gwt.user.client.EventListener() {
@ -437,9 +417,11 @@ public abstract class OpenLayerMap {
if (layer == null) { if (layer == null) {
ImageWmsParams imageWMSParams = OLFactory.createOptions(); ImageWmsParams imageWMSParams = OLFactory.createOptions();
imageWMSParams.setLayers(layerItem.getName()); imageWMSParams.setLayers(layerItem.getName());
// imageWMSParams.set("CQL_FILTER", "product_id
// IN('6165b07202ad3d60e1d26f42','6166ff8002ad3d60e1d26fb7')");
ImageWmsOptions imageWMSOptions = OLFactory.createOptions(); ImageWmsOptions imageWMSOptions = OLFactory.createOptions();
imageWMSOptions.setUrl(layerItem.getMapServerEndpoint()); imageWMSOptions.setUrl(layerItem.getMapServerHost());
imageWMSOptions.setParams(imageWMSParams); imageWMSOptions.setParams(imageWMSParams);
// imageWMSOptions.setRatio(1.5f); // imageWMSOptions.setRatio(1.5f);
@ -476,60 +458,41 @@ public abstract class OpenLayerMap {
/** /**
* Sets the CQL filter to WMS layer. * Sets the CQL filter to WMS layer.
* *
* @param origin the origin * @param key the key
* @param layerName the key * @param cqlFilterExpression the cql filter expression
* @param newCQLFilterExpression the cql filter expression
* @return the new CQL Filter
*/ */
public String setCQLFilterToWMSLayer(CQL_FACILITY_ORIGIN origin, String layerName, String newCQLFilterExpression) { public void setCQLFilterToWMSLayer(String key, String cqlFilterExpression) {
GWT.log("Getting key (layerName): " + layerName);
GWT.log("Adding CQL FILTER: " + newCQLFilterExpression); GWT.log("Getting key: " + key);
GWT.log("Setting CQL FILTER: " + cqlFilterExpression);
Image wmsLayer = wmsLayerMap.get(key);
Image wmsLayer = wmsLayerMap.get(layerName);
GWT.log("WMS layer is: " + wmsLayer); GWT.log("WMS layer is: " + wmsLayer);
// map.removeLayer(wmsLayer);
ImageWms imageWMSSource = wmsLayer.getSource(); ImageWms imageWMSSource = wmsLayer.getSource();
ImageWmsParams imageWMSParams = imageWMSSource.getParams(); ImageWmsParams imageWMSParams = imageWMSSource.getParams();
// Setting new CQL filter for Origin if (cqlFilterExpression == null || cqlFilterExpression.length() > MAX_LENGHT_CQL_FOR_GET_REQUEST) {
cqlFilterMap.put(origin, newCQLFilterExpression); imageWMSParams.delete("CQL_FILTER");
} else {
String setCQLFilter = ""; imageWMSParams.set("CQL_FILTER", cqlFilterExpression);
// Building new CQL filter
for (CQL_FACILITY_ORIGIN originKey : cqlFilterMap.keySet()) {
String originCQLFilter = cqlFilterMap.get(originKey);
if (originCQLFilter != null) {
if (setCQLFilter.isEmpty()) {
setCQLFilter = originCQLFilter;
} else {
setCQLFilter += " AND " + originCQLFilter;
}
}
} }
if (setCQLFilter.isEmpty())
imageWMSParams.delete(CQL_FILTER_PARAMETER);
else
imageWMSParams.set(CQL_FILTER_PARAMETER, setCQLFilter);
imageWMSSource.updateParams(imageWMSParams); imageWMSSource.updateParams(imageWMSParams);
wmsLayer.setSource(imageWMSSource); wmsLayer.setSource(imageWMSSource);
wmsLayer.changed(); wmsLayer.changed();
GWT.log("returning " + CQL_FILTER_PARAMETER + ": " + setCQLFilter);
return setCQLFilter;
} }
/** /**
* Adds the WMS detail layer. * Adds the WMS detail layer.
* *
* @param layerItem the layer item * @param layerItem the layer item
* @param initialOpacity the initial opacity
*/ */
public void addWMSDetailLayer(LayerItem layerItem, double initialOpacity) { public void addWMSDetailLayer(LayerItem layerItem) {
if (wmsDetailsLayerMap == null) if (wmsDetailsLayerMap == null)
wmsDetailsLayerMap = new LinkedHashMap<String, Image>(); wmsDetailsLayerMap = new LinkedHashMap<String, Image>();
@ -544,7 +507,7 @@ public abstract class OpenLayerMap {
imageWMSParams.setLayers(layerItem.getName()); imageWMSParams.setLayers(layerItem.getName());
ImageWmsOptions imageWMSOptions = OLFactory.createOptions(); ImageWmsOptions imageWMSOptions = OLFactory.createOptions();
imageWMSOptions.setUrl(layerItem.getMapServerEndpoint()); imageWMSOptions.setUrl(layerItem.getMapServerHost());
imageWMSOptions.setParams(imageWMSParams); imageWMSOptions.setParams(imageWMSParams);
// imageWMSOptions.setRatio(1.5f); // imageWMSOptions.setRatio(1.5f);
@ -563,7 +526,6 @@ public abstract class OpenLayerMap {
Image wmsLayer = new Image(layerOptions); Image wmsLayer = new Image(layerOptions);
int zIndex = layerOrder.getOffset(LayerOrder.LAYER_TYPE.WMS_DETAIL) + wmsDetailsLayerMap.size() + 1; int zIndex = layerOrder.getOffset(LayerOrder.LAYER_TYPE.WMS_DETAIL) + wmsDetailsLayerMap.size() + 1;
wmsLayer.setZIndex(zIndex); wmsLayer.setZIndex(zIndex);
wmsLayer.setOpacity(initialOpacity);
map.addLayer(wmsLayer); map.addLayer(wmsLayer);
wmsDetailsLayerMap.put(key, wmsLayer); wmsDetailsLayerMap.put(key, wmsLayer);
@ -575,57 +537,6 @@ public abstract class OpenLayerMap {
} }
/**
* Adds the custom WMS detail layer.
*
* @param layerItem the layer item
*/
public void addGroupedCustomWMSLayer(LayerItem layerItem) {
if (wmsGroupedCustomLayerMap == null)
wmsGroupedCustomLayerMap = new LinkedHashMap<String, Image>();
String key = layerItem.getName();
Image layer = wmsGroupedCustomLayerMap.get(key);
if (layer == null) {
GWT.log("The grouped custom 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.getMapServerEndpoint());
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);
int zIndex = layerOrder.getOffset(LayerOrder.LAYER_TYPE.CUSTOM_WMS_DETAIL) + wmsGroupedCustomLayerMap.size()
+ 1;
wmsLayer.setZIndex(zIndex);
map.addLayer(wmsLayer);
wmsGroupedCustomLayerMap.put(key, wmsLayer);
GWT.log("Added GroupedCustomWMSLayer for layer name: " + layerItem.getName());
eventBus.fireEvent(new AddedLayerToMapEvent(layerItem, LAYER_TYPE.OVERLAY));
} else {
GWT.log("The WMS detail layer with key: " + key + " already exists, skipping");
}
}
/** /**
* Removes the all detail layers. * Removes the all detail layers.
* *
@ -722,9 +633,8 @@ public abstract class OpenLayerMap {
/** /**
* Adds the vector. * Adds the vector.
* *
* @param layerItem the layer item * @param layerItem the layer item
* @param features the features * @param features the features
* @param fitMapToFeaturesExtent the fit map to features extent
*/ */
public void addLayerFeaturesAsHighlight(LayerItem layerItem, Feature[] features, boolean fitMapToFeaturesExtent) { public void addLayerFeaturesAsHighlight(LayerItem layerItem, Feature[] features, boolean fitMapToFeaturesExtent) {
@ -745,7 +655,7 @@ public abstract class OpenLayerMap {
@Override @Override
public void onEvent(ol.events.Event event) { public void onEvent(ol.events.Event event) {
ol.Extent theExtent = vectorSource.getExtent(); ol.Extent theExtent = vectorSource.getExtent();
// GWT.log(theExtent.toString()); //GWT.log(theExtent.toString());
map.getView().fit(theExtent); map.getView().fit(theExtent);
} }
@ -1130,23 +1040,6 @@ public abstract class OpenLayerMap {
layer.setVisible(visible); layer.setVisible(visible);
} }
public void setLayerStyleForIndex(String layerName, String value) {
GWT.log("Setting style " + value + " for " + layerName);
Image indexWmsLayer = wmsLayerMap.get(layerName);
GWT.log("WMS layer is: " + indexWmsLayer);
if (indexWmsLayer != null) {
ImageWms imageWMSSource = indexWmsLayer.getSource();
ImageWmsParams imageWMSParams = imageWMSSource.getParams();
imageWMSParams.set("STYLES", value);
imageWMSSource.updateParams(imageWMSParams);
indexWmsLayer.setSource(imageWMSSource);
indexWmsLayer.changed();
}
}
/** /**
* Sets the WMS detail layer opacity. * Sets the WMS detail layer opacity.
* *
@ -1156,21 +1049,7 @@ public abstract class OpenLayerMap {
public void setWMSDetailLayerOpacity(LayerItem layerItem, double opacity) { public void setWMSDetailLayerOpacity(LayerItem layerItem, double opacity) {
String key = layerItem.getName(); String key = layerItem.getName();
Image layer = wmsDetailsLayerMap.get(key); Image layer = wmsDetailsLayerMap.get(key);
if (layer != null) layer.setOpacity(opacity);
layer.setOpacity(opacity);
}
/**
* Sets the WMS detail layer visible.
*
* @param layerItem the layer item
* @param visible the visible
*/
public void setWMSGroupedCustomLayerVisible(LayerItem layerItem, boolean visible) {
String key = layerItem.getName();
Image layer = wmsGroupedCustomLayerMap.get(key);
if (layer != null)
layer.setVisible(visible);
} }
/** /**
@ -1210,17 +1089,4 @@ public abstract class OpenLayerMap {
return map.get((map.keySet().toArray())[index]); return map.get((map.keySet().toArray())[index]);
} }
/**
* Fit to extent.
*
* @param extent the extent
*/
public void fitToExtent(ol.Extent extent) {
ViewFitOptions opt = new ViewFitOptions();
opt.setMaxZoom(16);
opt.setDuration(SET_CENTER_ANIMATED_DURATION * 5);
map.getView().fit(extent, opt);
}
} }

View File

@ -4,7 +4,7 @@ import com.github.gwtbootstrap.client.ui.constants.BaseIconType;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.resources.client.ClientBundle; import com.google.gwt.resources.client.ClientBundle;
public interface GeoportalIcons extends ClientBundle { public interface GNAIcons extends ClientBundle {
/** My custom base icon collection */ /** My custom base icon collection */
public enum CustomIconType implements BaseIconType { public enum CustomIconType implements BaseIconType {
@ -15,7 +15,7 @@ public interface GeoportalIcons extends ClientBundle {
/** Inject the icon's css once at first usage */ /** Inject the icon's css once at first usage */
static { static {
GeoportalImages icons = GWT.create(GeoportalImages.class); GNAImages icons = GWT.create(GNAImages.class);
icons.css().ensureInjected(); icons.css().ensureInjected();
} }

View File

@ -5,13 +5,13 @@ import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.CssResource; import com.google.gwt.resources.client.CssResource;
import com.google.gwt.resources.client.ImageResource; import com.google.gwt.resources.client.ImageResource;
public interface GeoportalImages extends ClientBundle { public interface GNAImages extends ClientBundle {
/** Get access to the css resource during gwt compilation */ /** Get access to the css resource during gwt compilation */
@Source("baseIcons.css") @Source("baseIcons.css")
CssResource css(); CssResource css();
public static final GeoportalImages ICONS = GWT.create(GeoportalImages.class); public static final GNAImages ICONS = GWT.create(GNAImages.class);
/** /**
* Our sample image icon. Makes the image resource for the gwt-compiler's css * Our sample image icon. Makes the image resource for the gwt-compiler's css

View File

@ -11,20 +11,9 @@
top: 50px; top: 50px;
right: 10px; right: 10px;
} }
.to-align-left {
position: absolute;
top: 5px;
color: white !important;
text-decoration: none !important;
}
.to-align-left :hover {
color: #F5F5F5;
}
</ui:style> </ui:style>
<g:HTMLPanel ui:field="detailsHTMLPanel" visible="false"> <g:HTMLPanel ui:field="detailsHTMLPanel" visible="false">
<b:Button ui:field="closeButton" addStyleNames="{style.to-align-left}"></b:Button> <b:Button ui:field="closeButton" addStyleNames="{style.to-align-right}"></b:Button>
<g:HTMLPanel ui:field="datailsContainerPanel"></g:HTMLPanel> <g:HTMLPanel ui:field="datailsContainerPanel"></g:HTMLPanel>
</g:HTMLPanel> </g:HTMLPanel>
</ui:UiBinder> </ui:UiBinder>

View File

@ -8,33 +8,24 @@ import java.util.List;
import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences; import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences;
import org.gcube.application.geoportalcommon.shared.SearchingFilter; import org.gcube.application.geoportalcommon.shared.SearchingFilter;
import org.gcube.application.geoportalcommon.shared.SearchingFilter.ORDER; import org.gcube.application.geoportalcommon.shared.SearchingFilter.ORDER;
import org.gcube.application.geoportalcommon.shared.geoportal.config.GroupedLayersDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV; import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.layers.ConfiguredLayerDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.layers.LayerIDV;
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.UseCaseDescriptorDV; import org.gcube.application.geoportalcommon.shared.geoportal.ucd.UseCaseDescriptorDV;
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView; import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewer;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.GisToolbarFacilities;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ChangeMapLayerEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.ChangeMapLayerEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.MapExtentToEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.MapExtentToEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.collections.OpenCollectionEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.collections.OpenCollectionEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerMap; import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerMap;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.GeoportalIcons; import org.gcube.portlets.user.geoportaldataviewer.client.resources.GNAIcons;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.GeoportalImages; import org.gcube.portlets.user.geoportaldataviewer.client.resources.GNAImages;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.search.SearchFacilityUI; import org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.search.SearchFacilityUI;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.crossfiltering.CrossFilteringLayerPanel;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.customoverlays.OverlayCustomLayerPanel;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.layercollection.LayerCollectionPanel; import org.gcube.portlets.user.geoportaldataviewer.client.ui.layercollection.LayerCollectionPanel;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil; 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.Location;
import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil;
import org.gcube.portlets.user.geoportaldataviewer.shared.GCubeCollection; import org.gcube.portlets.user.geoportaldataviewer.shared.GCubeCollection;
import org.gcube.portlets.user.geoportaldataviewer.shared.ItemFieldsResponse; import org.gcube.portlets.user.geoportaldataviewer.shared.ItemFieldsResponse;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
import com.github.gwtbootstrap.client.ui.Button; import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.CheckBox; import com.github.gwtbootstrap.client.ui.CheckBox;
@ -43,7 +34,6 @@ import com.github.gwtbootstrap.client.ui.ListBox;
import com.github.gwtbootstrap.client.ui.NavLink; import com.github.gwtbootstrap.client.ui.NavLink;
import com.github.gwtbootstrap.client.ui.Paragraph; import com.github.gwtbootstrap.client.ui.Paragraph;
import com.github.gwtbootstrap.client.ui.constants.IconType; import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.github.gwtbootstrap.client.ui.constants.LabelType;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.core.client.Scheduler.ScheduledCommand;
@ -60,13 +50,10 @@ import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField; import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HTMLPanel; import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Image; import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.LayoutPanel;
import com.google.gwt.user.client.ui.RadioButton; import com.google.gwt.user.client.ui.RadioButton;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.ScrollPanel; import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.SimplePanel; import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
@ -80,8 +67,6 @@ import com.google.gwt.user.client.ui.Widget;
*/ */
public class GeonaDataViewMainPanel extends Composite { public class GeonaDataViewMainPanel extends Composite {
private static final String PLACEHOLDER_SELECT_SEARCH_IN = "Select Collection..."; private static final String PLACEHOLDER_SELECT_SEARCH_IN = "Select Collection...";
private static GeonaDataViewMainPanelUiBinder uiBinder = GWT.create(GeonaDataViewMainPanelUiBinder.class); private static GeonaDataViewMainPanelUiBinder uiBinder = GWT.create(GeonaDataViewMainPanelUiBinder.class);
@ -126,18 +111,6 @@ public class GeonaDataViewMainPanel extends Composite {
@UiField @UiField
DropdownButton openCollectionDropDown; DropdownButton openCollectionDropDown;
@UiField
DropdownButton linkCustomOverlayLayers;
@UiField
DropdownButton linkCrossFilteringLayers;
@UiField
HTMLPanel panelCustomOverlayLayers;
@UiField
HTMLPanel panelCrossFilteringLayers;
@UiField @UiField
HTMLPanel openCollectionPanel; HTMLPanel openCollectionPanel;
@ -147,10 +120,8 @@ public class GeonaDataViewMainPanel extends Composite {
@UiField @UiField
ListBox navListSearch; ListBox navListSearch;
//@UiField @UiField
//ScrollPanel overlayLayersPanel; ScrollPanel overlayLayersPanel;
RootPanel overlayLayersPanel = RootPanel.get(GeoportalDataViewer.DIV_LAYER_VIEW);
@UiField @UiField
ScrollPanel searchFacilityPanel; ScrollPanel searchFacilityPanel;
@ -186,26 +157,25 @@ public class GeonaDataViewMainPanel extends Composite {
mapPanel = new MapPanel(mapHeight + "px"); mapPanel = new MapPanel(mapHeight + "px");
detailsPanel.setHeight(mapHeight + "px"); detailsPanel.setHeight(mapHeight + "px");
detailsPanel.setApplicationBus(applicationBus); detailsPanel.setApplicationBus(applicationBus);
overlayLayersPanel.setVisible(false);
mainContainerPanel.add(mapPanel); mainContainerPanel.add(mapPanel);
bindHandlers(); bindHandlers();
dataPointSelection.setIcon(IconType.SCREENSHOT); dataPointSelection.setIcon(IconType.SCREENSHOT);
dataBoxSelection.setIcon(IconType.BOOKMARK); dataBoxSelection.setIcon(IconType.BOOKMARK);
removeQuery.setIcon(IconType.REMOVE); removeQuery.setIcon(IconType.REMOVE);
Image italyImg = new Image(GeoportalImages.ICONS.italyIcon()); Image italyImg = new Image(GNAImages.ICONS.italyIcon());
italyImg.getElement().getStyle().setPaddingLeft(20, Unit.PX); italyImg.getElement().getStyle().setPaddingLeft(20, Unit.PX);
extentToItaly.getElement().appendChild(italyImg.getElement()); extentToItaly.getElement().appendChild(italyImg.getElement());
extentToItaly.setWidth("140px"); extentToItaly.setWidth("140px");
Image worldImg = new Image(GeoportalImages.ICONS.worldIcon()); Image worldImg = new Image(GNAImages.ICONS.worldIcon());
worldImg.getElement().getStyle().setPaddingLeft(20, Unit.PX); worldImg.getElement().getStyle().setPaddingLeft(20, Unit.PX);
extentToEarth.getElement().appendChild(worldImg.getElement()); extentToEarth.getElement().appendChild(worldImg.getElement());
extentToEarth.setWidth("140px"); extentToEarth.setWidth("140px");
// linkMap.setCustomIconStyle(GeoportalIcons.CustomIconType.MAP.get()); linkMap.setCustomIconStyle(GNAIcons.CustomIconType.MAP.get());
linkPresetLocation.setCustomIconStyle(GeoportalIcons.CustomIconType.PRESET_LOCATION.get()); linkPresetLocation.setCustomIconStyle(GNAIcons.CustomIconType.PRESET_LOCATION.get());
linkLayers.setCustomIconStyle(GeoportalIcons.CustomIconType.LAYERS.get()); linkLayers.setCustomIconStyle(GNAIcons.CustomIconType.LAYERS.get());
openCollectionDropDown.setIcon(IconType.COMPASS); openCollectionDropDown.setIcon(IconType.COMPASS);
@ -218,6 +188,14 @@ public class GeonaDataViewMainPanel extends Composite {
navListSearch.getElement().getFirstChildElement().setAttribute("disabled", "disabled"); navListSearch.getElement().getFirstChildElement().setAttribute("disabled", "disabled");
// List<UseCaseDescriptorDV> listUCDs = new ArrayList<UseCaseDescriptorDV>();
//
// for (ItemFieldsResponse itemFieldsResponse : itemFieldsReponse) {
// listUCDs.add(itemFieldsResponse.getUseCaseDescriptorDV());
// }
//
// Collections.sort(listUCDs);
for (final ItemFieldsResponse itemFieldResp : itemFieldsReponse) { for (final ItemFieldsResponse itemFieldResp : itemFieldsReponse) {
UseCaseDescriptorDV ucd = itemFieldResp.getUseCaseDescriptorDV(); UseCaseDescriptorDV ucd = itemFieldResp.getUseCaseDescriptorDV();
@ -282,24 +260,15 @@ public class GeonaDataViewMainPanel extends Composite {
@Override @Override
public void execute() { public void execute() {
searchFacilityPanel.getElement().getParentElement().addClassName("opacity-09"); searchFacilityPanel.getElement().getParentElement().getStyle().setOpacity(0.9);
panelCustomOverlayLayers.getElement().getParentElement().addClassName("opacity-09");
panelCrossFilteringLayers.getElement().getParentElement().addClassName("opacity-09");
} }
}); });
openCollectionDropDown.setTitle(GisToolbarFacilities.COLLECTION.getTooltip());
linkCustomOverlayLayers.setTitle(GisToolbarFacilities.OVERLAY.getTooltip());
linkCrossFilteringLayers.setTitle(GisToolbarFacilities.FILTER.getTooltip());
searchFacilityButton.setTitle(GisToolbarFacilities.SEARCH.getTooltip());
linkLayers.setTitle(GisToolbarFacilities.LAYERS.getTooltip());
linkMap.setTitle(GisToolbarFacilities.MAP.getTooltip());
linkPresetLocation.setTitle(GisToolbarFacilities.PRESET_LOCATION.getTooltip());
// layersDDB.setToggle(true); // layersDDB.setToggle(true);
bindEvents(); bindEvents();
} }
/** /**
@ -341,26 +310,6 @@ public class GeonaDataViewMainPanel extends Composite {
} }
}, ClickEvent.getType()); }, ClickEvent.getType());
linkCustomOverlayLayers.addDomHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
// event.preventDefault();
event.stopPropagation();
}
}, ClickEvent.getType());
linkCrossFilteringLayers.addDomHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
// event.preventDefault();
event.stopPropagation();
}
}, ClickEvent.getType());
} }
/** /**
@ -377,27 +326,6 @@ public class GeonaDataViewMainPanel extends Composite {
} }
public void setPanelsWidth(int clientWidth) {
if(clientWidth<GeoportalDataViewerConstants.TABLET_WIDTH) {
openCollectionDropDown.setText("");
linkCustomOverlayLayers.setText("");
linkCrossFilteringLayers.setText("");
searchFacilityButton.setText("");
linkLayers.setText("");
linkPresetLocation.setText("");
linkMap.setText("");
}else {
openCollectionDropDown.setText(GisToolbarFacilities.COLLECTION.getName());
linkCustomOverlayLayers.setText(GisToolbarFacilities.OVERLAY.getName());
linkCrossFilteringLayers.setText(GisToolbarFacilities.FILTER.getName());
searchFacilityButton.setText(GisToolbarFacilities.SEARCH.getName());
linkLayers.setText(GisToolbarFacilities.LAYERS.getName());
linkMap.setText(GisToolbarFacilities.MAP.getName());
linkPresetLocation.setText(GisToolbarFacilities.PRESET_LOCATION.getName());
}
}
/** /**
* Sets the overlay panel max height. * Sets the overlay panel max height.
*/ */
@ -680,107 +608,4 @@ public class GeonaDataViewMainPanel extends Composite {
} }
public void addOverlayLayers(GCubeCollection collection,
List<GroupedLayersDV<? extends LayerIDV>> listGroupedLayers) {
if (listGroupedLayers == null)
return;
com.github.gwtbootstrap.client.ui.Label collectionGroup = new com.github.gwtbootstrap.client.ui.Label(
collection.getUcd().getName());
collectionGroup.setType(LabelType.WARNING);
LayoutPanel lc = new LayoutPanel();
lc.add(collectionGroup);
panelCustomOverlayLayers.add(lc);
for (GroupedLayersDV gCustomLayerDV : listGroupedLayers) {
if (gCustomLayerDV.getListCustomLayers() != null) {
FlowPanel lcInner = new FlowPanel();
lcInner.getElement().getStyle().setMarginLeft(5.0, Unit.PX);
com.github.gwtbootstrap.client.ui.Label labelGroup = new com.github.gwtbootstrap.client.ui.Label(
gCustomLayerDV.getName());
labelGroup.setType(LabelType.INFO);
String descr = gCustomLayerDV.getDescription() != null && !gCustomLayerDV.getDescription().isEmpty()
? gCustomLayerDV.getDescription()
: gCustomLayerDV.getName();
labelGroup.setTitle(descr);
lcInner.add(labelGroup);
if (descr.compareTo(gCustomLayerDV.getName()) != 0) {
HTML overlayGroupDescr = new HTML();
overlayGroupDescr.getElement().setClassName("overlay-panel-style-description");
overlayGroupDescr.setHTML(descr);
lcInner.add(overlayGroupDescr);
}
List<ConfiguredLayerDV> list = gCustomLayerDV.getListCustomLayers();
for (ConfiguredLayerDV customLayer : list) {
if (customLayer.isDisplay()) {
LayerItem layerItem = new LayerItem();
if (customLayer.getWMS_URL() != null) {
final String mapServerHost = URLUtil.getPathURL(customLayer.getWMS_URL());
GWT.log("mapServerHost: " + mapServerHost);
layerItem.setMapServerHost(mapServerHost);
layerItem.setBaseLayer(false);
layerItem.setName(customLayer.getName());
layerItem.setTitle(customLayer.getTitle());
layerItem.setWmsLink(customLayer.getWMS_URL());
// panelCustomOverlayLayers.add(new CrossFilteringLayerPanel(layerItem,
// applicationBus));
lcInner.add(new OverlayCustomLayerPanel(layerItem, applicationBus));
map.addGroupedCustomWMSLayer(layerItem);
}
}
}
panelCustomOverlayLayers.add(lcInner);
}
}
linkCustomOverlayLayers.setVisible(listGroupedLayers.size() > 0);
}
public void addCrossFilteringLayers(GCubeCollection collection,
List<GroupedLayersDV<? extends LayerIDV>> listGroupedLayers) {
if (listGroupedLayers == null)
return;
com.github.gwtbootstrap.client.ui.Label collectionGroup = new com.github.gwtbootstrap.client.ui.Label(
collection.getUcd().getName());
collectionGroup.setType(LabelType.WARNING);
LayoutPanel lc = new LayoutPanel();
lc.add(collectionGroup);
panelCrossFilteringLayers.add(lc);
for (GroupedLayersDV<? extends LayerIDV> groupedLayerDV : listGroupedLayers) {
FlowPanel lcInner = new FlowPanel();
lcInner.getElement().getStyle().setMarginLeft(5.0, Unit.PX);
com.github.gwtbootstrap.client.ui.Label labelGroup = new com.github.gwtbootstrap.client.ui.Label(
groupedLayerDV.getName());
labelGroup.setType(LabelType.INFO);
String descr = groupedLayerDV.getDescription() != null && !groupedLayerDV.getDescription().isEmpty()
? groupedLayerDV.getDescription()
: groupedLayerDV.getName();
labelGroup.setTitle(descr);
lcInner.add(labelGroup);
// panelCustomOverlayLayers.add(labelGroup);
if (descr.compareTo(groupedLayerDV.getName()) != 0) {
HTML overlayGroupDescr = new HTML();
overlayGroupDescr.getElement().setClassName("filter-panel-style-description");
overlayGroupDescr.setHTML(descr);
lcInner.add(overlayGroupDescr);
// panelCustomOverlayLayers.add(overlayGroupDescr);
}
CrossFilteringLayerPanel cfp = new CrossFilteringLayerPanel(collection, groupedLayerDV, applicationBus);
cfp.setFilterButton(linkCrossFilteringLayers);
lcInner.add(cfp);
panelCrossFilteringLayers.add(lcInner);
}
linkCrossFilteringLayers.setVisible(listGroupedLayers.size() > 0);
}
} }

View File

@ -49,24 +49,17 @@
</g:HTMLPanel> </g:HTMLPanel>
</g:HTMLPanel> </g:HTMLPanel>
</b:DropdownButton> </b:DropdownButton>
<b:DropdownButton type="LINK" text="Collection" <b:DropdownButton type="LINK"
ui:field="openCollectionDropDown"> text="Open Collection" ui:field="openCollectionDropDown">
<g:HTMLPanel ui:field="openCollectionPanel" <g:HTMLPanel ui:field="openCollectionPanel"
addStyleNames="open-collection-style"> addStyleNames="open-collection-style">
</g:HTMLPanel> </g:HTMLPanel>
</b:DropdownButton> </b:DropdownButton>
<b:DropdownButton type="LINK" text="Map" ui:field="linkMap" icon="GLOBE"> <b:DropdownButton type="LINK"
title="Select the Map" text="Map" ui:field="linkMap">
<g:HTMLPanel ui:field="panelBaseLayers"> <g:HTMLPanel ui:field="panelBaseLayers">
</g:HTMLPanel> </g:HTMLPanel>
</b:DropdownButton> </b:DropdownButton>
<b:DropdownButton type="LINK" visible="false" text="Overlay" ui:field="linkCustomOverlayLayers" icon="REORDER">
<g:HTMLPanel ui:field="panelCustomOverlayLayers" addStyleNames="overlay-panel-style">
</g:HTMLPanel>
</b:DropdownButton>
<b:DropdownButton type="LINK" visible="false" text="Filter" ui:field="linkCrossFilteringLayers" icon="FILTER">
<g:HTMLPanel ui:field="panelCrossFilteringLayers" addStyleNames="filter-panel-style">
</g:HTMLPanel>
</b:DropdownButton>
<b:DropdownButton type="LINK" text="Search" <b:DropdownButton type="LINK" text="Search"
ui:field="searchFacilityButton"> ui:field="searchFacilityButton">
<g:FlowPanel addStyleNames="search-field"> <g:FlowPanel addStyleNames="search-field">
@ -80,8 +73,9 @@
<g:ScrollPanel ui:field="searchFacilityPanel" <g:ScrollPanel ui:field="searchFacilityPanel"
addStyleNames="search-facility"></g:ScrollPanel> addStyleNames="search-facility"></g:ScrollPanel>
</b:DropdownButton> </b:DropdownButton>
<b:DropdownButton type="LINK" text="Preset Location" <b:DropdownButton type="LINK"
ui:field="linkPresetLocation" addStyleNames="preset-location"> title="Center Map to Location" text="Preset Location"
ui:field="linkPresetLocation">
<b:Nav> <b:Nav>
<b:Button type="LINK" ui:field="extentToItaly" <b:Button type="LINK" ui:field="extentToItaly"
text="Italy" title="Center to Italy"></b:Button> text="Italy" title="Center to Italy"></b:Button>
@ -105,8 +99,8 @@
text="Remove Query" visible="false"></b:Button> text="Remove Query" visible="false"></b:Button>
<b:Button type="LINK" text="Layers" ui:field="linkLayers"> <b:Button type="LINK" text="Layers" ui:field="linkLayers">
</b:Button> </b:Button>
<!-- <g:ScrollPanel ui:field="overlayLayersPanel" <g:ScrollPanel ui:field="overlayLayersPanel"
addStyleNames="layers-panel" visible="false"></g:ScrollPanel> --> addStyleNames="layers-panel" visible="false"></g:ScrollPanel>
</g:HTMLPanel> </g:HTMLPanel>
</g:HTMLPanel> </g:HTMLPanel>
<c:DetailsPanel ui:field="detailsPanel" <c:DetailsPanel ui:field="detailsPanel"

View File

@ -4,11 +4,9 @@ import java.util.List;
import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences; import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences;
import org.gcube.application.geoportalcommon.shared.geoportal.geojson.GeoJSON; import org.gcube.application.geoportalcommon.shared.geoportal.geojson.GeoJSON;
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
import org.gcube.application.geoportalcommon.shared.geoportal.project.RelationshipDV; import org.gcube.application.geoportalcommon.shared.geoportal.project.RelationshipDV;
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView; import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
import org.gcube.application.geoportalcommon.shared.geoportal.view.SectionView; import org.gcube.application.geoportalcommon.shared.geoportal.view.SectionView;
import org.gcube.portal.clientcontext.client.GCubeClientContext;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants; 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.GeoportalDataViewerConstants.MAP_PROJECTION;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync;
@ -27,7 +25,6 @@ import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.constants.ButtonType; import com.github.gwtbootstrap.client.ui.constants.ButtonType;
import com.github.gwtbootstrap.client.ui.constants.IconType; import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.FormElement;
import com.google.gwt.dom.client.UListElement; import com.google.gwt.dom.client.UListElement;
import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.ClickHandler;
@ -38,16 +35,8 @@ import com.google.gwt.user.client.Random;
import com.google.gwt.user.client.Window; import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FormPanel;
import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteEvent;
import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteHandler;
import com.google.gwt.user.client.ui.FormPanel.SubmitEvent;
import com.google.gwt.user.client.ui.FormPanel.SubmitHandler;
import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HTMLPanel; import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Hidden;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget; import com.google.gwt.user.client.ui.Widget;
import ol.Coordinate; import ol.Coordinate;
@ -94,9 +83,6 @@ public class ProjectViewer extends Composite {
@UiField @UiField
Button expandButton; Button expandButton;
@UiField
Button exportButton;
@UiField @UiField
Button relationshipsButton; Button relationshipsButton;
@ -150,22 +136,6 @@ public class ProjectViewer extends Composite {
this.geoportalItemReferences = geoportalItemRefs; this.geoportalItemReferences = geoportalItemRefs;
this.applicationBus = applicationBus; this.applicationBus = applicationBus;
GeoportalDataViewerServiceAsync.Util.getInstance().checkExportAsPDFConfig(new AsyncCallback<Boolean>() {
@Override
public void onFailure(Throwable caught) {
// TODO Auto-generated method stub
}
@Override
public void onSuccess(Boolean result) {
GWT.log("Export as PDF visible: " + result);
exportButton.setVisible(result);
}
});
final String theTitle = projectView.getTheProjectDV().getProfileName() != null final String theTitle = projectView.getTheProjectDV().getProfileName() != null
? projectView.getTheProjectDV().getProfileName() ? projectView.getTheProjectDV().getProfileName()
: "Project ID: " + projectView.getTheProjectDV().getId(); : "Project ID: " + projectView.getTheProjectDV().getId();
@ -213,79 +183,6 @@ public class ProjectViewer extends Composite {
} }
}); });
exportButton.setType(ButtonType.LINK);
exportButton.setIcon(IconType.FILE);
exportButton.setTitle("Export as PDF");
exportButton.setVisible(false);
exportButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
String theProjectName = "";
try {
theProjectName = (String) projectView.getTheProjectDV().getTheDocument().getFirstEntryOfMap()
.getValue();
theProjectName = theProjectName != null ? theProjectName
: "Project ID: " + projectView.getTheProjectDV().getId();
} catch (Exception e) {
// TODO: handle exception
}
// Reading contextId and userId from GCubeClientContext
String currentContextId = GCubeClientContext.getCurrentContextId();
String currentUserId = GCubeClientContext.getCurrentUserId();
ProjectDV thePDV = projectView.getTheProjectDV();
final String targetWindow = "target_window_" + Random.nextInt() + "_" + Random.nextInt();
final FormPanel form = new FormPanel();
final FormElement fe = form.getElement().cast();
//NewBrowserWindow theNewTabWindow = NewBrowserWindow.open("", "", null);
RootPanel.get().add(form);
VerticalPanel panel = new VerticalPanel();
form.setWidget(panel);
form.setAction(GeoportalDataViewerConstants.GEOPORTAL_EXPORT_ACTION_SERVLET);
form.setEncoding(FormPanel.ENCODING_URLENCODED);
form.setMethod(FormPanel.METHOD_POST);
panel.add(new Hidden(GeoportalDataViewerConstants.UCD_ID_PARAMETER, thePDV.getProfileID()));
panel.add(new Hidden(GeoportalDataViewerConstants.PROIECT_ID_PARAMETER, thePDV.getId()));
panel.add(new Hidden(GeoportalDataViewerConstants.CONTEXT_ID_PARAMETER, currentContextId));
panel.add(new Hidden(GeoportalDataViewerConstants.USER_ID_PARAMETER, currentUserId));
if(myLogin!=null) {
panel.add(new Hidden(GeoportalDataViewerConstants.USERNAME_PARAMETER, myLogin));
}
// final Modal contactinServiceModal = new Modal(true, true);
// contactinServiceModal.setCloseVisible(false);
// contactinServiceModal.setTitle("Export");
// FlowPanel panelMsg = new FlowPanel();
// panelMsg.add(new HTML("Contacting the service..."));
// contactinServiceModal.add(panelMsg);
// contactinServiceModal.show();
// Add an event handler to the form.
form.addSubmitHandler(new SubmitHandler() {
public void onSubmit(SubmitEvent event) {
GWT.log("onSubmit done");
fe.setTarget(targetWindow);
}
});
form.addSubmitCompleteHandler(new SubmitCompleteHandler() {
public void onSubmitComplete(SubmitCompleteEvent event) {
GWT.log("onSubmitComplete done");
//contactinServiceModal.hide();
}
});
form.submit();
}
});
relationshipsButton.setType(ButtonType.LINK); relationshipsButton.setType(ButtonType.LINK);
relationshipsButton.setIcon(IconType.LINK); relationshipsButton.setIcon(IconType.LINK);
relationshipsButton.setTitle("Show Relationships of this Project"); relationshipsButton.setTitle("Show Relationships of this Project");
@ -343,6 +240,14 @@ public class ProjectViewer extends Composite {
public void onClick(ClickEvent event) { public void onClick(ClickEvent event) {
boolean visible = toc_list_container.isVisible(); boolean visible = toc_list_container.isVisible();
setTocContentVisible(!visible); setTocContentVisible(!visible);
// if (visible) {
// toc_list_container.setVisible(false);
// reduceToc.setIcon(IconType.PLUS_SIGN_ALT);
// } else {
// toc_list_container.setVisible(true);
// reduceToc.setIcon(IconType.MINUS_SIGN_ALT);
// }
} }
}); });
@ -399,7 +304,7 @@ public class ProjectViewer extends Composite {
GeoJSON spatialReference = theProjectView.getTheProjectDV().getSpatialReference(); GeoJSON spatialReference = theProjectView.getTheProjectDV().getSpatialReference();
Coordinate transfCoord = MapUtils.geoJSONToBBOXCenter(spatialReference, MAP_PROJECTION.EPSG_4326.getName(), Coordinate transfCoord = MapUtils.geoJSONTToBBoxCenter(spatialReference, MAP_PROJECTION.EPSG_4326.getName(),
MAP_PROJECTION.EPSG_3857.getName()); MAP_PROJECTION.EPSG_3857.getName());
if (transfCoord != null) { if (transfCoord != null) {

View File

@ -23,7 +23,6 @@
color: white; color: white;
padding: 10px 10px; padding: 10px 10px;
font-size: 14px; font-size: 14px;
padding-left: 40px;
} }
.width-100 { .width-100 {
@ -44,10 +43,9 @@
<g:HorizontalPanel <g:HorizontalPanel
addStyleNames="functionalities-style"> addStyleNames="functionalities-style">
<b:Button ui:field="shareButton">Share</b:Button> <b:Button ui:field="shareButton">Share</b:Button>
<b:Button ui:field="exportButton">Export</b:Button>
<b:Button ui:field="expandButton">Expand</b:Button> <b:Button ui:field="expandButton">Expand</b:Button>
<b:Button ui:field="relationshipsButton">Relationships</b:Button> <b:Button ui:field="relationshipsButton">Relationships</b:Button>
<b:Button ui:field="addLayersToMap">Add Layers</b:Button> <b:Button ui:field="addLayersToMap">Add Layers to Map</b:Button>
</g:HorizontalPanel> </g:HorizontalPanel>
<g:HTMLPanel ui:field="centroidPanel"></g:HTMLPanel> <g:HTMLPanel ui:field="centroidPanel"></g:HTMLPanel>
<g:HTMLPanel ui:field="tableOfContentPanel" <g:HTMLPanel ui:field="tableOfContentPanel"

View File

@ -124,7 +124,7 @@ public class SectionViewer extends Composite {
List<FilesetDV> files = subDocumentView.getListFiles(); List<FilesetDV> files = subDocumentView.getListFiles();
if (files != null) { if (files != null) {
for (FilesetDV fileset : files) { for (FilesetDV fileset : files) {
showLinkToDownloadWsContent(fileset.getGcubeProfileFieldName(), fileset.getListPayload()); showLinkToDownloadWsContent(fileset.getName(), fileset.getListPayload());
} }
} }
} }

View File

@ -7,7 +7,7 @@ import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowDetailsEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowDetailsEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowDetailsEvent.EVENT_SOURCE; import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowDetailsEvent.EVENT_SOURCE;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.GeoportalImages; import org.gcube.portlets.user.geoportaldataviewer.client.resources.GNAImages;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.project.ProjectUtil; import org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.project.ProjectUtil;
import org.gcube.portlets.user.geoportaldataviewer.client.util.LoaderIcon; import org.gcube.portlets.user.geoportaldataviewer.client.util.LoaderIcon;
@ -45,7 +45,7 @@ public class TimelineRelationPanel extends Composite {
Anchor timelinePopupCloser; Anchor timelinePopupCloser;
private LoaderIcon loaderData = new LoaderIcon("Loading data... please wait", private LoaderIcon loaderData = new LoaderIcon("Loading data... please wait",
new Image(GeoportalImages.ICONS.spinnerClock())); new Image(GNAImages.ICONS.spinnerClock()));
private TimelineRelationPanel instance = this; private TimelineRelationPanel instance = this;

View File

@ -15,7 +15,6 @@ import org.gcube.application.geoportalcommon.shared.WhereClause;
import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV; import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV;
import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV; import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV; import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ClosedViewDetailsEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.ClosedViewDetailsEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.SearchPerformedEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.SearchPerformedEvent;
@ -62,6 +61,8 @@ import com.google.gwt.user.client.ui.Widget;
*/ */
public class SearchFacilityUI extends Composite { public class SearchFacilityUI extends Composite {
private static final int SEARCHING_LIMIT_RESULTS_TO = 50;
private static SearchFacilityPanelUiBinder uiBinder = GWT.create(SearchFacilityPanelUiBinder.class); private static SearchFacilityPanelUiBinder uiBinder = GWT.create(SearchFacilityPanelUiBinder.class);
protected static final int MIN_LENGHT_SERCHING_STRING = 3; protected static final int MIN_LENGHT_SERCHING_STRING = 3;
@ -126,7 +127,6 @@ public class SearchFacilityUI extends Composite {
* *
* @param profileID the profile ID * @param profileID the profile ID
* @param appManagerBus the app manager bus * @param appManagerBus the app manager bus
* @param displayByFields the display by fields
* @param sortByFields the sort by fields * @param sortByFields the sort by fields
* @param searchForFields the search for fields * @param searchForFields the search for fields
* @param initialSortFilter the initial sort filter * @param initialSortFilter the initial sort filter
@ -237,9 +237,6 @@ public class SearchFacilityUI extends Composite {
} }
/**
* Reset current search.
*/
public void resetCurrentSearch() { public void resetCurrentSearch() {
searchField.setText(""); searchField.setText("");
resetSearch.setVisible(false); resetSearch.setVisible(false);
@ -271,9 +268,8 @@ public class SearchFacilityUI extends Composite {
panelResults.clear(); panelResults.clear();
panelResults.add(new HTML("<hr>")); panelResults.add(new HTML("<hr>"));
panelResults.add(new LoaderIcon("Searching...")); panelResults.add(new LoaderIcon("Searching..."));
GeoportalDataViewerServiceAsync.Util.getInstance().getListProjects(profileID, 0, GeoportalDataViewerServiceAsync.Util.getInstance().getListProjects(profileID, 0, SEARCHING_LIMIT_RESULTS_TO,
GeoportalDataViewerConstants.SEARCH_LIMIT_RESULTS_TO_MAXIMUM, filter, false, filter, false, new AsyncCallback<ResultSetPaginatedDataIDs>() {
new AsyncCallback<ResultSetPaginatedDataIDs>() {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
@ -313,14 +309,13 @@ public class SearchFacilityUI extends Composite {
+ "). Please find below the top " + returnedItems + ".<br>"; + "). Please find below the top " + returnedItems + ".<br>";
} else if (returnedItems > 0) { } else if (returnedItems > 0) {
message = "Found " + returnedItems; message = "Found " + returnedItems;
message += returnedItems > 0 ? " projects" : " project"; message += returnedItems > 0 ? " items" : " item";
message += "."; message += ". ";
} }
if (returnedItems > 0 // if (returnedItems > 0) {
&& returnedItems <= GeoportalDataViewerConstants.SEARCH_LIMIT_RESULTS_TO_MAXIMUM) { // message += "On the map you can see all the projects with a centroid matching the query";
message += "On the map you can see all the projects with a centroid matching the query"; // }
}
HTML resultMessage = new HTML(message); HTML resultMessage = new HTML(message);
resultMessage.getElement().addClassName("search_result_msg"); resultMessage.getElement().addClassName("search_result_msg");
@ -361,8 +356,7 @@ public class SearchFacilityUI extends Composite {
profileID); profileID);
// here // here
appManagerBus.fireEvent(new ClosedViewDetailsEvent()); appManagerBus.fireEvent(new ClosedViewDetailsEvent());
appManagerBus.fireEvent( appManagerBus.fireEvent(new ShowDetailsEvent(gir, null, true, true, EVENT_SOURCE.LOCATE_SEARCHED));
new ShowDetailsEvent(gir, null, true, true, EVENT_SOURCE.LOCATE_SEARCHED));
// appManagerBus.fireEvent(new ShowPopupOnCentroidEvent(profileID, // appManagerBus.fireEvent(new ShowPopupOnCentroidEvent(profileID,
// resultDoc.getProjectID(), resultDoc.getSpatialReference())); // resultDoc.getProjectID(), resultDoc.getSpatialReference()));

View File

@ -1,672 +0,0 @@
package org.gcube.portlets.user.geoportaldataviewer.client.ui.crossfiltering;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import org.gcube.application.geoportalcommon.shared.geoportal.config.GroupedLayersDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.layers.CrossFilteringLayerDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.layers.LayerIDV;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.GCubeSDILayer;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.IndexLayerDV;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.BBOXDV;
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.events.ApplyCQLToLayerOnMapEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.FitMapToExtentEvent;
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.util.OLGeoJSONUtil;
import org.gcube.portlets.user.geoportaldataviewer.client.util.LoaderIcon;
import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil;
import org.gcube.portlets.user.geoportaldataviewer.client.util.WFSMakerUtil;
import org.gcube.portlets.user.geoportaldataviewer.shared.GCubeCollection;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformationForWMSRequest;
import com.github.gwtbootstrap.client.ui.Alert;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.CheckBox;
import com.github.gwtbootstrap.client.ui.ControlGroup;
import com.github.gwtbootstrap.client.ui.ControlLabel;
import com.github.gwtbootstrap.client.ui.Controls;
import com.github.gwtbootstrap.client.ui.DropdownButton;
import com.github.gwtbootstrap.client.ui.Fieldset;
import com.github.gwtbootstrap.client.ui.ListBox;
import com.github.gwtbootstrap.client.ui.constants.AlertType;
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
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.http.client.URL;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlexTable;
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 jsinterop.base.JsPropertyMap;
import ol.Extent;
import ol.Feature;
import ol.source.Vector;
/**
* The Class CrossFilteringLayerPanel.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* May 15, 2023
*/
public class CrossFilteringLayerPanel extends Composite {
private static final double BBOX_OFFESET_ON_FEATURES = 18000.0;
private static final String ITEM_LABEL = "centroid";
public static String COLORSCALERANGE = "COLORSCALERANGE";
@UiField
Fieldset fieldSet;
@UiField
HTMLPanel panelResults;
@UiField
Button buttonReset;
private CheckBox checkbox;
private GeoInformationForWMSRequest geoInformation;
private static CrossFilteringLayerPanelUiBinder uiBinder = GWT.create(CrossFilteringLayerPanelUiBinder.class);
private HandlerManager applicationBus;
private LayerItem layerItem;
private LinkedHashMap<Integer, List<? extends LayerIDV>> mapInnestedFiltering = new LinkedHashMap<Integer, List<? extends LayerIDV>>();
private LinkedHashMap<Integer, HashMap<String, SelectableItem>> mapInnestedFeatures = new LinkedHashMap<Integer, HashMap<String, SelectableItem>>();
private LinkedHashMap<Integer, List<ListBox>> mapInnestedListBoxes = new LinkedHashMap<Integer, List<ListBox>>();
private GroupedLayersDV<? extends LayerIDV> groupedLayersDV;
private GCubeCollection gCubeCollection;
private DropdownButton filterButton;
/**
* The Interface LayerCollectionPanelUiBinder.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jan 16, 2023
*/
interface CrossFilteringLayerPanelUiBinder extends UiBinder<Widget, CrossFilteringLayerPanel> {
}
/**
* Instantiates a new overlay custom layer panel.
*
* @param gCubeCollection the g cube collection
* @param groupedLayersDV the grouped layers DV
* @param applicationBus the application bus
*/
public CrossFilteringLayerPanel(GCubeCollection gCubeCollection,
GroupedLayersDV<? extends LayerIDV> groupedLayersDV, HandlerManager applicationBus) {
initWidget(uiBinder.createAndBindUi(this));
this.applicationBus = applicationBus;
this.groupedLayersDV = groupedLayersDV;
this.gCubeCollection = gCubeCollection;
GWT.log("Building cross-filtering for: " + groupedLayersDV);
buttonReset.setType(ButtonType.LINK);
int level = 0;
// Building mapInnestedFiltering
recursivelyBuildSelectableLevels(level, groupedLayersDV.getListCustomLayers());
GWT.log("cross-filtering mapInnestedFiltering: " + mapInnestedFiltering);
for (Integer theLevel : mapInnestedFiltering.keySet()) {
addListBoxesLevelToPanel(theLevel, mapInnestedFiltering.get(theLevel));
}
fillSelectableLevel(level, null);
bindEvents();
}
/**
* Bind events.
*/
private void bindEvents() {
buttonReset.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
panelResults.clear();
for (int i = 1; i < mapInnestedListBoxes.size(); i++) {
resetListBoxLevel(i);
}
// Selecting the placeholder of the fist list box
List<ListBox> listBox = mapInnestedListBoxes.get(0);
listBox.get(0).setSelectedIndex(0);
// Resetting CQL filtering
applicationBus.fireEvent(new ApplyCQLToLayerOnMapEvent(gCubeCollection.getIndexes().get(0), null));
setFilterHighLighted(false);
}
});
}
/**
* Recursively build selectable levels.
*
* @param level the level
* @param layersIDV the layers IDV
*/
private void recursivelyBuildSelectableLevels(int level, List<? extends LayerIDV> layersIDV) {
if (layersIDV == null)
return;
mapInnestedFiltering.put(level, layersIDV);
for (LayerIDV layerIDV : layersIDV) {
if (layerIDV instanceof CrossFilteringLayerDV) {
CrossFilteringLayerDV crossFilteringLayer = (CrossFilteringLayerDV) layerIDV;
if (crossFilteringLayer.getRelated_to() != null) {
recursivelyBuildSelectableLevels(++level, crossFilteringLayer.getRelated_to());
}
}
}
}
/**
* Fill selectable level.
*
* @param level the level
* @param selectedItem the selected item
*/
private void fillSelectableLevel(int level, SelectableItem selectedItem) {
List<? extends LayerIDV> layersIDV = mapInnestedFiltering.get(level);
List<ListBox> listBoxes = mapInnestedListBoxes.get(level);
if (layersIDV == null)
return;
final HashMap<String, SelectableItem> mapSelectableFeatures = new HashMap<String, CrossFilteringLayerPanel.SelectableItem>();
LayerIDV layerIDV = layersIDV.get(0); // Expected one
if (layerIDV instanceof CrossFilteringLayerDV) {
CrossFilteringLayerDV crossFilteringLayer = (CrossFilteringLayerDV) layerIDV;
String wfsURL = crossFilteringLayer.getWFS_URL();
if (selectedItem != null) {
String cqlFilterValue = crossFilteringLayer.getTable_parent_key_field() + "=" + selectedItem.keyValue;
wfsURL += "&" + WFSMakerUtil.CQL_FILTER_PARAMETER + "=" + URL.encode(cqlFilterValue);
}
GWT.log("wfsURL request: " + wfsURL);
GeoportalDataViewerServiceAsync.Util.getInstance().getHTTPResponseForURL(wfsURL,
new AsyncCallback<String>() {
@Override
public void onSuccess(String response) {
GWT.log("wfsURL response: " + response);
Feature[] features = OLGeoJSONUtil.readGeoJsonFeatures(MAP_PROJECTION.EPSG_4326, response);
for (Feature feature : features) {
JsPropertyMap<Object> properties = feature.getProperties();
Object keyValue = properties.get(crossFilteringLayer.getTable_key_field());
Object itemField = properties.get(crossFilteringLayer.getTable_show_field());
Object parentKey = null;
if (crossFilteringLayer.getTable_parent_key_field() != null
&& !crossFilteringLayer.getTable_parent_key_field().isEmpty())
parentKey = properties.get(crossFilteringLayer.getTable_parent_key_field());
parentKey = parentKey == null ? "" : parentKey;
SelectableItem selectableItem = new SelectableItem(
crossFilteringLayer.getTable_key_field() + "", keyValue + "",
crossFilteringLayer.getTable_parent_key_field(), itemField + "",
crossFilteringLayer.getName(), crossFilteringLayer.getTable_geometry_name());
GWT.log("selectableItem: " + selectableItem);
String pathFeatureKey = pathFeatureKey(selectableItem);
mapSelectableFeatures.put(pathFeatureKey, selectableItem);
}
GWT.log("mapSelectableFeatures: " + mapSelectableFeatures);
mapInnestedFeatures.put(level, mapSelectableFeatures);
String placholder = placeholderLayer(layersIDV.get(0)); // Expected one
fillListBoxLevel(level, mapSelectableFeatures, listBoxes, placholder);
}
@Override
public void onFailure(Throwable caught) {
panelResults.clear();
HTML error = new HTML(
"Sorry, an issue is occurred on loading data for cross-filtering facility. Error is: "
+ caught.getMessage());
panelResults.add(error);
}
});
}
}
/**
* Path feature key.
*
* @param selectableItem the selectable item
* @return the string
*/
private String pathFeatureKey(SelectableItem selectableItem) {
return "root_" + selectableItem.parentKeyField + "_" + selectableItem.keyField + "_" + selectableItem.keyValue;
}
/**
* Placeholder layer.
*
* @param layersIDV the layers IDV
* @return the string
*/
private String placeholderLayer(LayerIDV layersIDV) {
String placeholder = "Select";
// if (layersIDV != null)
// placeholder += " " + layersIDV.getTitle();
placeholder += " ...";
return placeholder;
}
/**
* Adds the list boxes level to panel.
*
* @param level the level
* @param layersIDV the layers IDV
*/
private void addListBoxesLevelToPanel(int level, List<? extends LayerIDV> layersIDV) {
if (layersIDV == null)
return;
List<ListBox> listBoxes = new ArrayList<ListBox>(layersIDV.size());
for (LayerIDV layerIDV : layersIDV) {
ControlGroup cg = new ControlGroup();
ControlLabel cl = new ControlLabel(layerIDV.getTitle());
Controls controls = new Controls();
ListBox listBox = new ListBox();
String placeholder = placeholderLayer(layerIDV);
listBox.addItem(placeholder);
setEnabledBox(listBox, false);
listBoxes.add(listBox);
controls.add(listBox);
cg.add(cl);
cg.add(controls);
fieldSet.add(cg);
}
mapInnestedListBoxes.put(level, listBoxes);
}
/**
* Sets the enabled box.
*
* @param listBox the list box
* @param bool the bool
*/
public void setEnabledBox(ListBox listBox, boolean bool) {
listBox.setEnabled(bool);
}
/**
* Clear list box.
*
* @param listBox the list box
* @param bool the bool
*/
public void clearListBox(ListBox listBox, boolean bool) {
listBox.setEnabled(bool);
}
/**
* Reset list box level.
*
* @param level the level
*/
private void resetListBoxLevel(int level) {
List<ListBox> listBoxes = mapInnestedListBoxes.get(level);
if (listBoxes != null) {
for (ListBox listBox : listBoxes) {
listBox.clear();
setEnabledBox(listBox, false);
}
}
}
/**
* Fill list box level.
*
* @param level the level
* @param mapSelectableFeatures the map selectable features
* @param listBoxes the list boxes
* @param placeholder the placeholder
*/
private void fillListBoxLevel(int level, HashMap<String, SelectableItem> mapSelectableFeatures,
List<ListBox> listBoxes, String placeholder) {
// GWT.log("fillBox level: " + level + " map: " + mapSelectableFeatures);
if (mapSelectableFeatures == null)
return;
ListBox listBox = listBoxes.get(0); // Expected one
listBox.clear();
listBox.addItem(placeholder);
listBox.getElement().getFirstChildElement().setAttribute("disabled", "disabled");
for (String key : mapSelectableFeatures.keySet()) {
SelectableItem selItem = mapSelectableFeatures.get(key);
listBox.addItem(selItem.itemValue, key);
}
listBox.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
loadInnerLevel(level, listBox.getSelectedValue());
for (int i = level + 1; i < mapInnestedListBoxes.size(); i++) {
resetListBoxLevel(i);
}
String key = listBox.getSelectedValue();
SelectableItem selectableItem = mapSelectableFeatures.get(key);
buildCrossFilteringCQLAndFireEvent(selectableItem);
setFilterHighLighted(true);
}
});
setEnabledBox(listBox, true);
}
/**
* Builds the cross filtering CQL and fire event.
*
* @param selectableItem the selectable item
*/
private void buildCrossFilteringCQLAndFireEvent(SelectableItem selectableItem) {
String setCqlFilter = "INTERSECTS(geom,querySingle('" + selectableItem.layername + "','"
+ selectableItem.theGeometryName + "','" + selectableItem.keyField + "=''" + selectableItem.keyValue
+ "'''))";
// setCqlFilter = URL.encode(setCqlFilter);
GWT.log("CQL FILTER built: " + setCqlFilter);
IndexLayerDV indexLayer = gCubeCollection.getIndexes().get(0);
try {
GCubeSDILayer layer = indexLayer.getLayer();
String wmsLink = layer.getOgcLinks().get("wms");
String layerName = URLUtil.extractValueOfParameterFromURL("layers", wmsLink);
String serviceURL = URLUtil.getPathURL(wmsLink);
String toLServiceURL = serviceURL.toLowerCase();
if (toLServiceURL.endsWith("wms")) {
toLServiceURL = toLServiceURL.substring(0, toLServiceURL.length() - 3) + "ows";
}
String wfsCrossFilteringQuery = WFSMakerUtil.buildWFSRequest(toLServiceURL, layerName, 1000, "geom",
setCqlFilter);
GWT.log("wfsCrossFilteringQuery: " + wfsCrossFilteringQuery);
showCountResultsOfWFSCrossFiltering(wfsCrossFilteringQuery);
} catch (Exception e) {
// TODO: handle exception
}
applicationBus.fireEvent(new ApplyCQLToLayerOnMapEvent(indexLayer, setCqlFilter));
}
public void showCountResultsOfWFSCrossFiltering(String wfsQuery) {
panelResults.clear();
panelResults.add(new HTML("<hr>"));
panelResults.add(new LoaderIcon("Applying spatial filter..."));
GeoportalDataViewerServiceAsync.Util.getInstance().getHTTPResponseForURL(wfsQuery, new AsyncCallback<String>() {
@Override
public void onFailure(Throwable caught) {
panelResults.clear();
panelResults.add(new HTML("<hr>"));
Alert alert = new Alert("Error on returning number of items");
alert.setType(AlertType.ERROR);
alert.setClose(false);
panelResults.add(alert);
}
@Override
public void onSuccess(String response) {
Feature[] features = OLGeoJSONUtil.readGeoJsonFeatures(MAP_PROJECTION.EPSG_4326, response);
if (features != null) {
int dataCount = features.length;
panelResults.clear();
panelResults.add(new HTML("<hr>"));
FlexTable flexTable = new FlexTable();
String message = "";
if (dataCount <= 0) {
message = "No " + ITEM_LABEL + " found";
} else {
message = "Found " + dataCount;
message += dataCount > 1 ? " " + ITEM_LABEL + "s" : " " + ITEM_LABEL;
}
HTML resultMessage = new HTML();
resultMessage.getElement().addClassName("search_result_msg");
resultMessage.setHTML(message);
flexTable.setWidget(0, 0, resultMessage.asWidget());
panelResults.add(flexTable);
try {
if (features.length > 0) {
// Calculating Extend of the selected Features
Vector vector = new Vector();
vector.addFeatures(features);
Extent theExtent = vector.getExtent();
GWT.log("Extent from features is: " + theExtent);
theExtent = MapUtils.transformExtent(theExtent, MAP_PROJECTION.EPSG_4326.getName(),
MAP_PROJECTION.EPSG_3857.getName());
double bboxOffset = features.length>1?BBOX_OFFESET_ON_FEATURES:0;
final Extent transfExtent = new ExtentWrapped(theExtent.getLowerLeftX() - bboxOffset,
theExtent.getLowerLeftY() - bboxOffset, theExtent.getUpperRightX() + bboxOffset,
theExtent.getUpperRightY() + bboxOffset);
GWT.log("Zoom to selected - transf extent: " + transfExtent);
Button selectTo = new Button("Zoom to selected");
selectTo.setTitle("Zoom to select centroids...");
selectTo.setType(ButtonType.DEFAULT);
selectTo.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
applicationBus.fireEvent(new FitMapToExtentEvent(transfExtent));
}
});
flexTable.setWidget(1, 0, selectTo);
}
} catch (Exception e) {
// TODO: handle exception
}
}
}
});
}
public static final BBOXDV fromGeoJSON(double[] coords) {
BBOXDV toReturn = new BBOXDV();
toReturn.setMaxX(coords[0]);
toReturn.setMinY(coords[1]);
if (coords.length == 6) {
// 3D
toReturn.setMinZ(coords[2]);
toReturn.setMinX(coords[3]);
toReturn.setMaxY(coords[4]);
toReturn.setMaxZ(coords[5]);
} else {
toReturn.setMinX(coords[2]);
toReturn.setMaxY(coords[3]);
}
return toReturn;
}
/**
* Load inner level.
*
* @param level the level
* @param selectableItemValue the selectable item value
*/
private void loadInnerLevel(int level, String selectableItemValue) {
// GWT.log("selected level " + level + " selectableItemValue " +
// selectableItemValue);
HashMap<String, SelectableItem> mapSelectableItem = mapInnestedFeatures.get(level);
SelectableItem selectedItem = mapSelectableItem.get(selectableItemValue);
// GWT.log("selected selectableItem " + selectedItem);
int innerLevel = level + 1;
List<? extends LayerIDV> selectedLayers = mapInnestedFiltering.get(innerLevel);
// if layer filtering exists at this level
if (selectedLayers != null) {
List<ListBox> selectedListBoxes = mapInnestedListBoxes.get(innerLevel);
GWT.log("loading inner layers " + selectedLayers);
GWT.log("loading selectedListBoxes " + selectedListBoxes);
fillSelectableLevel(innerLevel, selectedItem);
}
}
/**
* Sets the filter high lighted.
*
* @param bool the new filter high lighted
*/
private void setFilterHighLighted(boolean bool) {
if (bool) {
filterButton.getElement().addClassName("highlight-button");
} else {
filterButton.getElement().removeClassName("highlight-button");
}
}
/**
* Sets the search button.
*
* @param searchFacilityButton the new search button
*/
public void setFilterButton(DropdownButton searchFacilityButton) {
this.filterButton = searchFacilityButton;
}
/**
* The Class SelectableItem.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* May 31, 2023
*/
public class SelectableItem {
protected String keyField;
protected String keyValue;
protected String parentKeyField;
protected String itemValue;
protected String layername;
protected String theGeometryName;
/**
* Instantiates a new selectable item.
*/
SelectableItem() {
}
/**
* Instantiates a new selectable item.
*
* @param keyField the key field
* @param keyValue the key value
* @param parentKeyField the parent key field
* @param itemValue the item value
* @param layername the layername
* @param theGeometryName the the geometry name
*/
public SelectableItem(String keyField, String keyValue, String parentKeyField, String itemValue,
String layername, String theGeometryName) {
super();
this.keyField = keyField;
this.keyValue = keyValue;
this.parentKeyField = parentKeyField;
this.itemValue = itemValue;
this.layername = layername;
this.theGeometryName = theGeometryName;
}
/**
* To string.
*
* @return the string
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("SelectableItem [keyField=");
builder.append(keyField);
builder.append(", keyValue=");
builder.append(keyValue);
builder.append(", parentKeyField=");
builder.append(parentKeyField);
builder.append(", itemValue=");
builder.append(itemValue);
builder.append(", layername=");
builder.append(layername);
builder.append(", theGeometryName=");
builder.append(theGeometryName);
builder.append("]");
return builder.toString();
}
}
}

View File

@ -1,28 +0,0 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
<ui:style>
.important {
font-weight: bold;
}
.margin-left-10 {
margin-left: 10px;
}
</ui:style>
<g:HTMLPanel>
<g:ScrollPanel>
<g:HTMLPanel>
<b:Form ui:field="panelForm">
<b:Fieldset ui:field="fieldSet">
</b:Fieldset>
</b:Form>
<g:HTMLPanel ui:field="panelResults">
</g:HTMLPanel>
<b:Button icon="REMOVE_CIRCLE" ui:field="buttonReset"
title="Reset the filter">Reset</b:Button>
</g:HTMLPanel>
</g:ScrollPanel>
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -1,278 +0,0 @@
package org.gcube.portlets.user.geoportaldataviewer.client.ui.customoverlays;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync;
import org.gcube.portlets.user.geoportaldataviewer.client.events.OverlayCustomLayerToMapEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformationForWMSRequest;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.CheckBox;
import com.github.gwtbootstrap.client.ui.ListBox;
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.FontWeight;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.ErrorEvent;
import com.google.gwt.event.dom.client.ErrorHandler;
import com.google.gwt.event.dom.client.LoadEvent;
import com.google.gwt.event.dom.client.LoadHandler;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.event.shared.HandlerManager;
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.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite;
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.HTMLPanel;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.Widget;
/**
* The Class OverlayCustomLayerPanel.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* May 15, 2023
*/
public class OverlayCustomLayerPanel extends Composite {
public static String COLORSCALERANGE = "COLORSCALERANGE";
@UiField
HTMLPanel basePanel;
@UiField
HTMLPanel stylePanel;
@UiField
HTMLPanel styleListPanel;
@UiField
Button buttonLegend;
@UiField
ScrollPanel legendPanel;
private CheckBox checkbox;
private GeoInformationForWMSRequest geoInformation;
private static OverlayCustomLayerPanelUiBinder uiBinder = GWT.create(OverlayCustomLayerPanelUiBinder.class);
private ListBox listBoxStyles = new ListBox();
private HandlerManager applicationBus;
private LayerItem layerItem;
/**
* The Interface LayerCollectionPanelUiBinder.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jan 16, 2023
*/
interface OverlayCustomLayerPanelUiBinder extends UiBinder<Widget, OverlayCustomLayerPanel> {
}
/**
* Instantiates a new overlay custom layer panel.
*
* @param layerItem the layer item
* @param applicationBus the application bus
*/
public OverlayCustomLayerPanel(LayerItem layerItem, HandlerManager applicationBus) {
initWidget(uiBinder.createAndBindUi(this));
this.applicationBus = applicationBus;
this.layerItem = layerItem;
buttonLegend.setType(ButtonType.LINK);
legendPanel.setVisible(false);
GWT.log("Found available layerItem " + layerItem);
String label = layerItem.getTitle();
final String layerName = layerItem.getName();
checkbox = new CheckBox(label);
checkbox.setId("gcubeCustomLayerSelector_" + layerName);
checkbox.getElement().getStyle().setFontWeight(FontWeight.BOLD);
checkbox.setChecked(true);
checkbox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
GWT.log("CustomLayer selector flag changed to value : " + event.toDebugString());
if (event.getValue()) {
// OPEN COLLECTION
applicationBus.fireEvent(new OverlayCustomLayerToMapEvent(layerItem, OverlayCustomLayerToMapEvent.ACTION_TYPE.VISIBILITY, true));
} else {
// CLOSE COLLECTION
legendPanel.clear();
legendPanel.setVisible(false);
applicationBus.fireEvent(new OverlayCustomLayerToMapEvent(layerItem, OverlayCustomLayerToMapEvent.ACTION_TYPE.VISIBILITY, false));
}
}
});
basePanel.add(checkbox);
final String wmsLink = layerItem.getWmsLink();
GeoportalDataViewerServiceAsync.Util.getInstance().parseWmsRequest(wmsLink, layerName,
new AsyncCallback<GeoInformationForWMSRequest>() {
@Override
public void onFailure(Throwable caught) {
Window.alert(caught.getMessage());
}
@Override
public void onSuccess(GeoInformationForWMSRequest geoInfoWMS) {
geoInformation = geoInfoWMS;
GWT.log("Parsed WMS Request returned: " + geoInfoWMS);
if (geoInfoWMS.getStyles() != null && geoInfoWMS.getStyles().getGeoStyles() != null) {
if (geoInfoWMS.getStyles().getGeoStyles().size() > 0) {
stylePanel.setVisible(true);
listBoxStyles.clear();
for (String styleName : geoInfoWMS.getStyles().getGeoStyles()) {
listBoxStyles.addItem(styleName, styleName);
}
styleListPanel.add(listBoxStyles);
}
}
listBoxStyles.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
legendPanel.clear();
legendPanel.setVisible(false);
}
});
buttonLegend.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
GWT.log("is isToggle: " + buttonLegend.isToggle());
GWT.log("is isToggled: " + buttonLegend.isToggled());
if (legendPanel.isVisible()) {
legendPanel.clear();
legendPanel.setVisible(false);
} else {
legendPanel.setVisible(true);
loadLegend(wmsLink);
}
}
});
}
});
}
/**
* Gets the checkbox.
*
* @return the checkbox
*/
public CheckBox getCheckbox() {
return checkbox;
}
/**
* Load legend.
*
* @param wmsLink the wms link
*/
private void loadLegend(String wmsLink) {
legendPanel.clear();
String theLayerName = geoInformation.getLayerName();
final FlexTable flexTable = new FlexTable();
legendPanel.add(flexTable);
// Case no style found
if (listBoxStyles.getSelectedValue() == null) {
flexTable.setWidget(0, 0, new HTML("No style found"));
return;
}
FlowPanel flow = new FlowPanel();
flow.add(new HTMLPanel("Legend for: " + theLayerName));
final HorizontalPanel hpLegend = new HorizontalPanel();
String url = geoInformation.getServiceEndPoint() + "?service=WMS&" + "version="
+ URLUtil.getValueOfParameter("version", wmsLink) + "&" + "request=GetLegendGraphic&" + "layer="
+ theLayerName;
String styleName = null;
try {
styleName = listBoxStyles.getSelectedValue();
} catch (Exception e) {
}
styleName = styleName != null && !styleName.isEmpty() ? styleName : "";
if (!geoInformation.isNcWMS()) {
url += "&format=image/png" + "&STYLE=" + styleName
+ "&LEGEND_OPTIONS=forceRule:True;dx:0.2;dy:0.2;mx:0.2;my:0.2;fontStyle:bold;"
+ "borderColor:000000;border:true;fontColor:000000;fontSize:14";
} else {
int isNcWmsStyle = styleName.indexOf("/");
if (isNcWmsStyle != -1) {
styleName = styleName.substring(isNcWmsStyle + 1, styleName.length());
}
url += "&palette=" + styleName;
if (geoInformation.getMapWMSNoStandard() != null) {
for (String key : geoInformation.getMapWMSNoStandard().keySet()) { // ADDING COLORSCALERANGE?
if (key.compareToIgnoreCase(COLORSCALERANGE) == 0) {
url += "&" + key + "=" + geoInformation.getMapWMSNoStandard().get(key);
break;
}
}
}
}
GWT.log(url);
flexTable.setStyleName("layer-style-panel-table-legend");
flexTable.setWidget(0, 0, new Label("Legend"));
final Image legendImage = new Image(url);
legendImage.addLoadHandler(new LoadHandler() {
@Override
public void onLoad(LoadEvent event) {
}
});
legendImage.addErrorHandler(new ErrorHandler() {
@Override
public void onError(ErrorEvent event) {
GWT.log("ErrorEvent ");
flexTable.setWidget(0, 1, new HTML("Error on loading the style"));
}
});
hpLegend.add(legendImage);
flexTable.setWidget(0, 1, hpLegend);
}
}

View File

@ -1,29 +0,0 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
<ui:style>
.important {
font-weight: bold;
}
.margin-left-10 {
margin-left: 10px;
}
</ui:style>
<g:HTMLPanel addStyleNames="{style.margin-left-10}">
<g:HTMLPanel ui:field="basePanel">
</g:HTMLPanel>
<g:HTMLPanel ui:field="stylePanel" visible="false"
addStyleNames="layer-style-panel">
Layer Style
<g:HorizontalPanel>
<g:HTMLPanel ui:field="styleListPanel"></g:HTMLPanel>
<b:Button icon="BAR_CHART" ui:field="buttonLegend"
title="Show the Legend"></b:Button>
</g:HorizontalPanel>
<g:ScrollPanel ui:field="legendPanel"></g:ScrollPanel>
</g:HTMLPanel>
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -8,7 +8,7 @@ import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerSer
import org.gcube.portlets.user.geoportaldataviewer.client.events.DoActionOnDetailLayersEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.DoActionOnDetailLayersEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.DoActionOnDetailLayersEvent.DO_LAYER_ACTION; import org.gcube.portlets.user.geoportaldataviewer.client.events.DoActionOnDetailLayersEvent.DO_LAYER_ACTION;
import org.gcube.portlets.user.geoportaldataviewer.client.events.DoActionOnDetailLayersEvent.SwapLayer; import org.gcube.portlets.user.geoportaldataviewer.client.events.DoActionOnDetailLayersEvent.SwapLayer;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.GeoportalImages; import org.gcube.portlets.user.geoportaldataviewer.client.resources.GNAImages;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.project.ProjectUtil; import org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.project.ProjectUtil;
import org.gcube.portlets.user.geoportaldataviewer.client.util.LoaderIcon; import org.gcube.portlets.user.geoportaldataviewer.client.util.LoaderIcon;
import org.gcube.portlets.user.geoportaldataviewer.client.util.StringUtil; import org.gcube.portlets.user.geoportaldataviewer.client.util.StringUtil;
@ -50,11 +50,11 @@ public class DragDropLayer extends FlowPanel {
private static DragDropLayer draggingTarget = null; private static DragDropLayer draggingTarget = null;
final boolean droppable; final boolean droppable;
private Label labelLayerName; private Label labelLayerName;
private Image imgLayerVisible = new Image(GeoportalImages.ICONS.layerVisible()); private Image imgLayerVisible = new Image(GNAImages.ICONS.layerVisible());
private Image imgLayerInvisible = new Image(GeoportalImages.ICONS.layerInvisible()); private Image imgLayerInvisible = new Image(GNAImages.ICONS.layerInvisible());
private Image imgLocate = new Image(GeoportalImages.ICONS.locate()); private Image imgLocate = new Image(GNAImages.ICONS.locate());
private Image imgLocateNone = new Image(GeoportalImages.ICONS.locateNone()); private Image imgLocateNone = new Image(GNAImages.ICONS.locateNone());
private boolean locateEnabled = false; private boolean locateEnabled = false;
private HTML buttonLocate = new HTML(); private HTML buttonLocate = new HTML();
@ -189,8 +189,8 @@ public class DragDropLayer extends FlowPanel {
if(layerObject.getProjectDV().getTemporalReference()!=null) { if(layerObject.getProjectDV().getTemporalReference()!=null) {
TemporalReferenceDV tempRef = layerObject.getProjectDV().getTemporalReference(); TemporalReferenceDV tempRef = layerObject.getProjectDV().getTemporalReference();
if(tempRef.getStart()!=null || tempRef.getEnd()!=null) // ft.setWidget(ft.getRowCount() + 1, 2, new HTML(ProjectUtil.toHTMLCode(tempRef)));
vpInner.add(new HTML(ProjectUtil.toHTMLCode(tempRef))); vpInner.add(new HTML(ProjectUtil.toHTMLCode(tempRef)));
} }
vpInner.add(labelLayerName); vpInner.add(labelLayerName);

View File

@ -1,6 +1,5 @@
package org.gcube.portlets.user.geoportaldataviewer.client.ui.dandd; package org.gcube.portlets.user.geoportaldataviewer.client.ui.dandd;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
import org.gcube.portlets.user.geoportaldataviewer.client.events.DoActionOnDetailLayersEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.DoActionOnDetailLayersEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.DoActionOnDetailLayersEvent.DO_LAYER_ACTION; import org.gcube.portlets.user.geoportaldataviewer.client.events.DoActionOnDetailLayersEvent.DO_LAYER_ACTION;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
@ -39,8 +38,8 @@ public class RangeSlider extends Composite {
sliderId = "slider-" + Random.nextInt(); sliderId = "slider-" + Random.nextInt();
theSlider.addClassName("slider"); theSlider.addClassName("slider");
theSlider.setId(sliderId); theSlider.setId(sliderId);
theSlider.setTitle("Set opacity of the layer");
theSlider.setPropertyObject("value", GeoportalDataViewerConstants.INITIAL_LAYER_OPACITY*100); theSlider.setTitle("Set opacity of "+layer.getName());
bindEvents(); bindEvents();
} }
@ -57,9 +56,9 @@ public class RangeSlider extends Composite {
DoActionOnDetailLayersEvent actionChangeOpacity = new DoActionOnDetailLayersEvent( DoActionOnDetailLayersEvent actionChangeOpacity = new DoActionOnDetailLayersEvent(
DO_LAYER_ACTION.OPACITY, layer, null); DO_LAYER_ACTION.OPACITY, layer, null);
int value = Integer.parseInt((String) theSlider.getPropertyObject("value")); int value = Integer.parseInt((String) theSlider.getPropertyObject("value"));
// GWT.log("opacity int value: "+value); //GWT.log("opacity int value: "+value);
double opacity = (double) ((double) value / 100); double opacity = (double) ((double) value/100);
GWT.log("opacity double value: " + opacity); GWT.log("opacity double value: "+opacity);
actionChangeOpacity.setOpacity(opacity); actionChangeOpacity.setOpacity(opacity);
applicationBus.fireEvent(actionChangeOpacity); applicationBus.fireEvent(actionChangeOpacity);
} }

View File

@ -5,9 +5,6 @@ import java.util.HashMap;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.IndexLayerDV; import org.gcube.application.geoportalcommon.shared.geoportal.materialization.IndexLayerDV;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewer; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewer;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync;
import org.gcube.portlets.user.geoportaldataviewer.client.events.UpdateLayerToMapEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.UpdateLayerToMapEvent.LAYER_TYPE;
import org.gcube.portlets.user.geoportaldataviewer.client.events.UpdateLayerToMapEvent.REQUEST_PARAMETER;
import org.gcube.portlets.user.geoportaldataviewer.client.events.collections.CloseCollectionEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.collections.CloseCollectionEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.collections.OpenCollectionEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.collections.OpenCollectionEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil; import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil;
@ -21,8 +18,6 @@ import com.github.gwtbootstrap.client.ui.ListBox;
import com.github.gwtbootstrap.client.ui.constants.ButtonType; import com.github.gwtbootstrap.client.ui.constants.ButtonType;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.FontWeight; import com.google.gwt.dom.client.Style.FontWeight;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.ErrorEvent; import com.google.gwt.event.dom.client.ErrorEvent;
@ -52,7 +47,7 @@ import com.google.gwt.user.client.ui.Widget;
* *
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
* *
* May 15, 2023 * Jan 16, 2023
*/ */
public class LayerCollectionPanel extends Composite { public class LayerCollectionPanel extends Composite {
@ -67,9 +62,6 @@ public class LayerCollectionPanel extends Composite {
@UiField @UiField
HTMLPanel styleListPanel; HTMLPanel styleListPanel;
@UiField
HTMLPanel statisticPanel;
@UiField @UiField
Button buttonLegend; Button buttonLegend;
@ -84,12 +76,6 @@ public class LayerCollectionPanel extends Composite {
private ListBox listBoxStyles = new ListBox(); private ListBox listBoxStyles = new ListBox();
private String layerName;
private GCubeCollection gcubeCollection;
private HandlerManager applicationBus;
/** /**
* The Interface LayerCollectionPanelUiBinder. * The Interface LayerCollectionPanelUiBinder.
* *
@ -106,13 +92,11 @@ public class LayerCollectionPanel extends Composite {
* @param coll the coll * @param coll the coll
* @param applicationBus the application bus * @param applicationBus the application bus
*/ */
public LayerCollectionPanel(final GCubeCollection coll, HandlerManager applicationBus) { public LayerCollectionPanel(GCubeCollection coll, HandlerManager applicationBus) {
initWidget(uiBinder.createAndBindUi(this)); initWidget(uiBinder.createAndBindUi(this));
this.applicationBus = applicationBus;
buttonLegend.setType(ButtonType.LINK); buttonLegend.setType(ButtonType.LINK);
legendPanel.setVisible(false); legendPanel.setVisible(false);
statisticPanel.setVisible(false);
GWT.log("Found available collection " + coll); GWT.log("Found available collection " + coll);
String label = coll.getUcd().getName(); String label = coll.getUcd().getName();
@ -127,16 +111,18 @@ public class LayerCollectionPanel extends Composite {
@Override @Override
public void onValueChange(ValueChangeEvent<Boolean> event) { public void onValueChange(ValueChangeEvent<Boolean> event) {
GWT.log("Collection selector flag changed to value : " + event.toDebugString()); GWT.log("Collection selector flag changed to value : " + event.toDebugString());
// String collectionID = ((CheckBox) event.getSource()).getId().replace("gcubeCollectionSelector_",
// "");
GWT.log("Collection ID is : " + collectionID + ", event value: " + event.getValue()); GWT.log("Collection ID is : " + collectionID + ", event value: " + event.getValue());
if (event.getValue()) { if (event.getValue()) {
// OPEN COLLECTION // OPEN COLLECTION
applicationBus.fireEvent(new OpenCollectionEvent(collectionID)); applicationBus.fireEvent(new OpenCollectionEvent(collectionID));
enableLayerStyle(true);
} else { } else {
// CLOSE COLLECTION // CLOSE COLLECTION
hideStyleLegend(); legendPanel.clear();
resetLayerStyle(); legendPanel.setVisible(false);
enableLayerStyle(false);
applicationBus.fireEvent(new CloseCollectionEvent(collectionID)); applicationBus.fireEvent(new CloseCollectionEvent(collectionID));
} }
} }
@ -144,33 +130,8 @@ public class LayerCollectionPanel extends Composite {
basePanel.add(checkbox); basePanel.add(checkbox);
GeoportalDataViewerServiceAsync.Util.getInstance().getCountFor(collectionID, "Published", "OK", new AsyncCallback<Integer>() {
@Override
public void onFailure(Throwable caught) {
// TODO Auto-generated method stub
}
@Override
public void onSuccess(Integer result) {
if(result!=null) {
String resultLabel = result+" project";
if(result>1) {
resultLabel+="s";
}
resultLabel+= " published";
statisticPanel.setVisible(true);
statisticPanel.add(new HTML(resultLabel));
}
}
});
ViewerConfiguration theConfig = GeoportalDataViewer.getStatus().getViewerConfig(); ViewerConfiguration theConfig = GeoportalDataViewer.getStatus().getViewerConfig();
final GCubeCollection toOpen = theConfig.getAvailableCollections().get(collectionID); GCubeCollection toOpen = theConfig.getAvailableCollections().get(collectionID);
// Check if indexes is empty // Check if indexes is empty
if (toOpen.getIndexes() == null || toOpen.getIndexes().isEmpty()) { if (toOpen.getIndexes() == null || toOpen.getIndexes().isEmpty()) {
@ -178,7 +139,6 @@ public class LayerCollectionPanel extends Composite {
Window.alert("Cannot open collection index layer for " + toOpen.getUcd().getName() + "."); Window.alert("Cannot open collection index layer for " + toOpen.getUcd().getName() + ".");
return; return;
} }
this.gcubeCollection = toOpen;
// TODO Get Default Index Layer // TODO Get Default Index Layer
// For now we just take the first - only 1 is expected // For now we just take the first - only 1 is expected
IndexLayerDV layer = toOpen.getIndexes().get(0); IndexLayerDV layer = toOpen.getIndexes().get(0);
@ -186,7 +146,7 @@ public class LayerCollectionPanel extends Composite {
HashMap<String, String> ogcLinks = layer.getLayer().getOgcLinks(); HashMap<String, String> ogcLinks = layer.getLayer().getOgcLinks();
final String wmsLink = ogcLinks.get("wms"); final String wmsLink = ogcLinks.get("wms");
this.layerName = URLUtil.getValueOfParameter("layers", wmsLink); final String layerName = URLUtil.getValueOfParameter("layers", wmsLink);
GeoportalDataViewerServiceAsync.Util.getInstance().parseWmsRequest(wmsLink, layerName, GeoportalDataViewerServiceAsync.Util.getInstance().parseWmsRequest(wmsLink, layerName,
new AsyncCallback<GeoInformationForWMSRequest>() { new AsyncCallback<GeoInformationForWMSRequest>() {
@ -221,7 +181,9 @@ public class LayerCollectionPanel extends Composite {
GWT.log("is isToggle: " + buttonLegend.isToggle()); GWT.log("is isToggle: " + buttonLegend.isToggle());
GWT.log("is isToggled: " + buttonLegend.isToggled()); GWT.log("is isToggled: " + buttonLegend.isToggled());
if (legendPanel.isVisible()) { if (legendPanel.isVisible()) {
hideStyleLegend(); legendPanel.clear();
legendPanel.setVisible(false);
} else { } else {
legendPanel.setVisible(true); legendPanel.setVisible(true);
loadLegend(wmsLink); loadLegend(wmsLink);
@ -230,45 +192,11 @@ public class LayerCollectionPanel extends Composite {
} }
}); });
listBoxStyles.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
setLayerStyle();
}
});
} }
}); });
} }
private void setLayerStyle() {
UpdateLayerToMapEvent updateLayer = new UpdateLayerToMapEvent(this.gcubeCollection, this.layerName,
LAYER_TYPE.INDEX);
updateLayer.setOperation(REQUEST_PARAMETER.STYLE, listBoxStyles.getSelectedValue());
applicationBus.fireEvent(updateLayer);
if (legendPanel.isVisible()) {
legendPanel.clear();
legendPanel.setVisible(false);
}
}
private void resetLayerStyle() {
listBoxStyles.setSelectedIndex(0);
listBoxStyles.setSelectedValue(listBoxStyles.getSelectedValue());
}
private void enableLayerStyle(boolean enabled) {
listBoxStyles.setEnabled(enabled);
}
private void hideStyleLegend() {
legendPanel.clear();
legendPanel.setVisible(false);
}
/** /**
* Gets the checkbox. * Gets the checkbox.
* *
@ -300,7 +228,7 @@ public class LayerCollectionPanel extends Composite {
flow.add(new HTMLPanel("Legend for: " + theLayerName)); flow.add(new HTMLPanel("Legend for: " + theLayerName));
final HorizontalPanel hpLegend = new HorizontalPanel(); final HorizontalPanel hpLegend = new HorizontalPanel();
String url = geoInformation.getServiceEndPoint() + "?service=WMS&" + "version=" String url = geoInformation.getBaseWmsServiceHost() + "?service=WMS&" + "version="
+ URLUtil.getValueOfParameter("version", wmsLink) + "&" + "request=GetLegendGraphic&" + "layer=" + URLUtil.getValueOfParameter("version", wmsLink) + "&" + "request=GetLegendGraphic&" + "layer="
+ theLayerName; + theLayerName;

View File

@ -10,8 +10,6 @@
<g:HTMLPanel> <g:HTMLPanel>
<g:HTMLPanel ui:field="basePanel"> <g:HTMLPanel ui:field="basePanel">
</g:HTMLPanel> </g:HTMLPanel>
<g:HTMLPanel ui:field="statisticPanel" addStyleNames="statistic-style-panel">
</g:HTMLPanel>
<g:HTMLPanel ui:field="stylePanel" visible="false" addStyleNames="layer-style-panel"> <g:HTMLPanel ui:field="stylePanel" visible="false" addStyleNames="layer-style-panel">
Layer Style Layer Style
<g:HorizontalPanel> <g:HorizontalPanel>

View File

@ -9,7 +9,7 @@ import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerCon
import org.gcube.portlets.user.geoportaldataviewer.client.gis.ExtentWrapped; import org.gcube.portlets.user.geoportaldataviewer.client.gis.ExtentWrapped;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.LightOpenLayerMap; import org.gcube.portlets.user.geoportaldataviewer.client.gis.LightOpenLayerMap;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils; import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.GeoportalIcons; import org.gcube.portlets.user.geoportaldataviewer.client.resources.GNAIcons;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.Location; 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.ExtentMapUtil.PLACE;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
@ -86,7 +86,7 @@ public class MapView extends Composite {
theMapPanel.setWidth(internalMapWidth); theMapPanel.setWidth(internalMapWidth);
theMapPanel.setHeight(internalMapHeight); theMapPanel.setHeight(internalMapHeight);
linkMap.setCustomIconStyle(GeoportalIcons.CustomIconType.MAP.get()); linkMap.setCustomIconStyle(GNAIcons.CustomIconType.MAP.get());
Scheduler.get().scheduleDeferred(new ScheduledCommand() { Scheduler.get().scheduleDeferred(new ScheduledCommand() {

View File

@ -1,59 +0,0 @@
package org.gcube.portlets.user.geoportaldataviewer.client.ui.util;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION;
import ol.Feature;
import ol.OLFactory;
import ol.format.GeoJson;
import ol.format.GeoJsonFeatureOptions;
import ol.format.GeoJsonOptions;
import ol.proj.Projection;
import ol.proj.ProjectionOptions;
/**
* The Class OLGeoJSONUtil.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* May 25, 2023
*/
public class OLGeoJSONUtil {
/**
* Builds the geo JSON.
*
* @param projection the projection
* @return the geo json
*/
public static GeoJson buildGeoJSON(MAP_PROJECTION projection) {
try {
GeoJsonFeatureOptions fo = new GeoJsonFeatureOptions();
ProjectionOptions projectionOptions = new ProjectionOptions();
projectionOptions.setCode(projection.getName());
Projection fp = new Projection(projectionOptions);
fo.setFeatureProjection(fp);
fo.setDataProjection(fp);
GeoJsonOptions geoJsonOpt = new GeoJsonOptions();
geoJsonOpt.setDefaultDataProjection(fp);
geoJsonOpt.setFeatureProjection(fp);
return OLFactory.createGeoJSON(geoJsonOpt);
} catch (Exception e) {
// silent
return OLFactory.createGeoJSON();
}
}
/**
* Read geo json features.
*
* @param projection the projection
* @param geoJSONString the geo JSON string
* @return the feature[]
*/
public static Feature[] readGeoJsonFeatures(MAP_PROJECTION projection, String geoJSONString) {
GeoJson geoJson = buildGeoJSON(projection);
return geoJson.readFeatures(geoJSONString);
}
}

View File

@ -3,7 +3,7 @@
*/ */
package org.gcube.portlets.user.geoportaldataviewer.client.util; package org.gcube.portlets.user.geoportaldataviewer.client.util;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.GeoportalImages; import org.gcube.portlets.user.geoportaldataviewer.client.resources.GNAImages;
import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.HorizontalPanel;
@ -18,7 +18,7 @@ import com.google.gwt.user.client.ui.Image;
public class LoaderIcon extends HorizontalPanel{ public class LoaderIcon extends HorizontalPanel{
private Image imgLoading = new Image(GeoportalImages.ICONS.loading()); private Image imgLoading = new Image(GNAImages.ICONS.loading());
private HTML txtLoading = new HTML(""); private HTML txtLoading = new HTML("");
/** /**

View File

@ -1,7 +1,7 @@
package org.gcube.portlets.user.geoportaldataviewer.client.util; package org.gcube.portlets.user.geoportaldataviewer.client.util;
/** /**
* The Class HTTPRequestUtil. * The Class URLUtil.
* *
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
* *
@ -35,20 +35,6 @@ public class URLUtil {
return value; return value;
} }
/**
* Gets the path URL.
*
* @param url the url
* @return the path URL
*/
public static String getPathURL(String url) {
int index = url.toLowerCase().indexOf("?");
if (index > -1) {
return url.substring(0, index);
} else
return null;
}
/** /**
* Adds the parameter to query string. * Adds the parameter to query string.
* *

View File

@ -1,50 +0,0 @@
package org.gcube.portlets.user.geoportaldataviewer.client.util;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.WFSGetFeature;
import com.google.gwt.http.client.URL;
public class WFSMakerUtil {
public static final String CQL_FILTER_PARAMETER = "CQL_FILTER";
public static String buildWFSRequest(String webserviceURL, String layerName, int maxFeatures, String propertyName,
String cqlFilter) throws Exception {
if (layerName == null)
throw new Exception("Bad parameter layerName is null");
if (webserviceURL == null)
throw new Exception("Bad parameter webserviceURL is null");
StringBuilder builder = new StringBuilder();
builder.append(webserviceURL);
builder.append("?");
builder.append(WFSGetFeature.SERVICE.getParameter() + "=" + WFSGetFeature.SERVICE.getValue());
builder.append("&");
builder.append(WFSGetFeature.VERSION.getParameter() + "=" + WFSGetFeature.VERSION.getValue());
builder.append("&");
builder.append(WFSGetFeature.REQUEST.getParameter() + "=" + WFSGetFeature.REQUEST.getValue());
builder.append("&");
builder.append(WFSGetFeature.OUTPUTFORMAT.getParameter() + "=" + URL.encode("application/json"));
builder.append("&");
builder.append(WFSGetFeature.TYPENAME.getParameter() + "=" + layerName);
builder.append("&");
if (maxFeatures > 0) {
builder.append(WFSGetFeature.MAXFEATURES.getParameter() + "=" + maxFeatures);
builder.append("&");
}
if (propertyName != null) {
builder.append(WFSGetFeature.PROPERTYNAME.getParameter() + "=" + propertyName);
builder.append("&");
}
if (cqlFilter != null) {
builder.append(CQL_FILTER_PARAMETER + "=" + cqlFilter);
}
return builder.toString();
}
}

View File

@ -0,0 +1,68 @@
package org.gcube.portlets.user.geoportaldataviewer.server;
import java.io.Serializable;
import java.util.List;
import org.gcube.application.geoportalcommon.shared.geoportal.config.GcubeProfileDV;
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean;
public class GcubeProfilesMetadataForUCD implements Serializable {
/**
*
*/
private static final long serialVersionUID = -8953445402356442872L;
private String profileID;
private GcubeProfileDV gcubeProfile;
private List<MetaDataProfileBean> listMetadataProfileBean;
public GcubeProfilesMetadataForUCD() {
}
public GcubeProfilesMetadataForUCD(String profileID, GcubeProfileDV gcubeProfile,
List<MetaDataProfileBean> listMetadataProfileBean) {
this.profileID = profileID;
this.gcubeProfile = gcubeProfile;
this.listMetadataProfileBean = listMetadataProfileBean;
}
public String getProfileID() {
return profileID;
}
public GcubeProfileDV getGcubeProfile() {
return gcubeProfile;
}
public List<MetaDataProfileBean> getListMetadataProfileBean() {
return listMetadataProfileBean;
}
public void setProfileID(String profileID) {
this.profileID = profileID;
}
public void setGcubeProfile(GcubeProfileDV gcubeProfile) {
this.gcubeProfile = gcubeProfile;
}
public void setListMetadataProfileBean(List<MetaDataProfileBean> listMetadataProfileBean) {
this.listMetadataProfileBean = listMetadataProfileBean;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("GcubeProfilesMetadataForUCD [profileID=");
builder.append(profileID);
builder.append(", gcubeProfile=");
builder.append(gcubeProfile);
builder.append(", listMetadataProfileBean=");
builder.append(listMetadataProfileBean);
builder.append("]");
return builder.toString();
}
}

View File

@ -0,0 +1,162 @@
/**
*
*/
package org.gcube.portlets.user.geoportaldataviewer.server;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.gcube.application.geoportal.common.model.useCaseDescriptor.HandlerDeclaration;
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
import org.gcube.application.geoportalcommon.ConvertToDataValueObjectModel;
import org.gcube.application.geoportalcommon.geoportal.GeoportalClientCaller;
import org.gcube.application.geoportalcommon.geoportal.UseCaseDescriptorCaller;
import org.gcube.application.geoportalcommon.shared.geoportal.ConfigurationDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.GcubeProfileDV;
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_CONFIGURATION_TYPE;
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_DATA_HANDLER;
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.HandlerDeclarationDV;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portlets.widgets.mpformbuilder.server.MetadataProfileFormBuilderServiceImpl;
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.cache.RemovalListener;
import com.google.common.cache.RemovalNotification;
/**
* The Class GcubeProfilesPerUCDIdCache.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Oct 12, 2022
*/
public class GcubeProfilesPerUCDIdCache {
private static Logger LOG = LoggerFactory.getLogger(GcubeProfilesPerUCDIdCache.class);
private static LoadingCache<String, LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>>> gCubeProfilesPerProfileIDCache;
static {
CacheLoader<String, LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>>> loader = new CacheLoader<String, LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>>>() {
@Override
public LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>> load(String scope) throws Exception {
LOG.info("Loading the cache for scope: " + scope);
return loadGcubeProfilesForUCDIdInTheScope(scope);
}
};
RemovalListener<String, LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>>> removalListener = new RemovalListener<String, LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>>>() {
public void onRemoval(
RemovalNotification<String, LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>>> removal) {
LOG.info(GcubeProfilesPerUCDIdCache.class.getSimpleName() + " cache expired");
}
};
gCubeProfilesPerProfileIDCache = CacheBuilder.newBuilder().maximumSize(1000)
.expireAfterWrite(30, TimeUnit.MINUTES).removalListener(removalListener).build(loader);
LOG.info("cache instancied");
}
/**
* Gets the.
*
* @param scope the scope
* @return the geonetwork instance
* @throws Exception
*/
public static LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>> get(String scope) throws Exception {
LOG.info("GcubeProfilesPerUCDIdCache get - called in the scope: " + scope);
LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>> map = gCubeProfilesPerProfileIDCache.get(scope);
LOG.info("GcubeProfilesPerUCDIdCache returning map null? " + (map==null));
return map;
}
/**
* Load geonetwork instance.
*
* @param scope the scope
* @return the linked hash map
* @throws Exception the exception
*/
private static LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>> loadGcubeProfilesForUCDIdInTheScope(
String scope) throws Exception {
LOG.info("loadGcubeProfilesForUCDIdInTheScope called in the scope: " + scope);
LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>> linkedMap_UCDId_gCubeProfiles = new LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>>();
try {
ScopeProvider.instance.set(scope);
UseCaseDescriptorCaller clientUCD = GeoportalClientCaller.useCaseDescriptors();
List<UseCaseDescriptor> listUCDs = clientUCD.getList();
LOG.debug("listUCDs: " + listUCDs);
for (UseCaseDescriptor ucd : listUCDs) {
LOG.info("Loaded UCD for ID: " + ucd.getId());
String profileID = ucd.getId();
GEOPORTAL_DATA_HANDLER theHandler = GEOPORTAL_DATA_HANDLER.geoportal_data_entry;
List<HandlerDeclaration> handlers = ucd.getHandlersByType(theHandler.getType());
if (handlers.size() == 0) {
LOG.warn("No handler " + theHandler + "found into UCD " + ucd.getId() + ", continue...");
continue;
}
// Loading Handler gcube_profiles
HandlerDeclaration dataEntryHandler = handlers.get(0);
HandlerDeclarationDV handlerGcubeProfiles = ConvertToDataValueObjectModel
.toHandlerDeclarationDV(dataEntryHandler, ucd, GEOPORTAL_CONFIGURATION_TYPE.gcube_profiles);
LOG.debug("Handler " + GEOPORTAL_CONFIGURATION_TYPE.gcube_profiles + " for PROFILE_ID: " + ucd.getId());
LOG.debug("" + handlerGcubeProfiles);
ConfigurationDV<?> config = handlerGcubeProfiles.getConfiguration();
// List of gCube Profiles defined in the UCD
List<GcubeProfileDV> listGcubeProfiles = (List<GcubeProfileDV>) config.getConfiguration();
LOG.debug("List of GcubeProfileDV are: " + listGcubeProfiles);
List<GcubeProfilesMetadataForUCD> listProfilesBean = new ArrayList<GcubeProfilesMetadataForUCD>();
// Loading Metadata Profile from IS
MetadataProfileFormBuilderServiceImpl metaProfileBUilder = new MetadataProfileFormBuilderServiceImpl();
for (GcubeProfileDV gcubeProfileDV : listGcubeProfiles) {
ScopeProvider.instance.set(scope);
GcubeProfilesMetadataForUCD gCubeProfileMetadataForUCD = new GcubeProfilesMetadataForUCD();
List<MetaDataProfileBean> listProfiles = metaProfileBUilder.getProfilesInTheScopeForName(scope,
gcubeProfileDV.getGcubeSecondaryType(), gcubeProfileDV.getGcubeName());
String key = gcubeProfileDV.getGcubeSecondaryType() + gcubeProfileDV.getGcubeName();
LOG.debug("for key: " + key + " readi profiles: " + listGcubeProfiles);
gCubeProfileMetadataForUCD.setGcubeProfile(gcubeProfileDV);
gCubeProfileMetadataForUCD.setListMetadataProfileBean(listProfiles);
listProfilesBean.add(gCubeProfileMetadataForUCD);
}
linkedMap_UCDId_gCubeProfiles.put(ucd.getId(), listProfilesBean);
if (LOG.isDebugEnabled()) {
for (String key : linkedMap_UCDId_gCubeProfiles.keySet()) {
LOG.debug("For key '" + key + "' got profiles: " + linkedMap_UCDId_gCubeProfiles.get(key));
}
}
}
} catch (Exception e) {
String erroMsg = "Error occurred on preloadgCubeProfilesForUCDs: ";
LOG.error(erroMsg, e);
}
LOG.info("GcubeProfilesPerUCDIdCache loaded with " + linkedMap_UCDId_gCubeProfiles.size() + " item/s");
return linkedMap_UCDId_gCubeProfiles;
}
}

View File

@ -3,6 +3,10 @@ package org.gcube.portlets.user.geoportaldataviewer.server;
import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin.projects; import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin.projects;
import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin.useCaseDescriptors; import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin.useCaseDescriptors;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
@ -27,7 +31,6 @@ import org.gcube.application.geoportal.common.model.document.identification.Iden
import org.gcube.application.geoportal.common.model.document.relationships.Relationship; import org.gcube.application.geoportal.common.model.document.relationships.Relationship;
import org.gcube.application.geoportal.common.model.document.relationships.RelationshipNavigationObject; import org.gcube.application.geoportal.common.model.document.relationships.RelationshipNavigationObject;
import org.gcube.application.geoportal.common.model.rest.QueryRequest; import org.gcube.application.geoportal.common.model.rest.QueryRequest;
import org.gcube.application.geoportal.common.model.useCaseDescriptor.HandlerDeclaration;
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor; import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
import org.gcube.application.geoportal.common.rest.Projects; import org.gcube.application.geoportal.common.rest.Projects;
import org.gcube.application.geoportalcommon.ConvertToDataValueObjectModel; import org.gcube.application.geoportalcommon.ConvertToDataValueObjectModel;
@ -44,32 +47,20 @@ import org.gcube.application.geoportalcommon.shared.SearchingFilter;
import org.gcube.application.geoportalcommon.shared.geoportal.ConfigurationDV; import org.gcube.application.geoportalcommon.shared.geoportal.ConfigurationDV;
import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV; import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV;
import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV; import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.GeoportalConfigurationID;
import org.gcube.application.geoportalcommon.shared.geoportal.config.GroupedLayersDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV; import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.layers.ConfiguredLayerDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.layers.CrossFilteringLayerDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.layers.LayerIDV;
import org.gcube.application.geoportalcommon.shared.geoportal.geojson.GeoJSON; import org.gcube.application.geoportalcommon.shared.geoportal.geojson.GeoJSON;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.GCubeSDILayer;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.GCubeSDIViewerLayerDV; import org.gcube.application.geoportalcommon.shared.geoportal.materialization.GCubeSDIViewerLayerDV;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.GeoServerPlatformInfoDV;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.IndexLayerDV; import org.gcube.application.geoportalcommon.shared.geoportal.materialization.IndexLayerDV;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.PayloadDV; import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.PayloadDV;
import org.gcube.application.geoportalcommon.shared.geoportal.project.IdentificationReferencesTYPE; import org.gcube.application.geoportalcommon.shared.geoportal.project.IdentificationReferencesTYPE;
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV; import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
import org.gcube.application.geoportalcommon.shared.geoportal.project.TemporalReferenceDV; import org.gcube.application.geoportalcommon.shared.geoportal.project.TemporalReferenceDV;
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_CONFIGURATION_TYPE;
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_DATA_HANDLER; import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_DATA_HANDLER;
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.HandlerDeclarationDV; import org.gcube.application.geoportalcommon.shared.geoportal.ucd.HandlerDeclarationDV;
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.UseCaseDescriptorDV; import org.gcube.application.geoportalcommon.shared.geoportal.ucd.UseCaseDescriptorDV;
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView; import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
import org.gcube.application.geoportalcommon.shared.gis.BoundsMap; import org.gcube.application.geoportalcommon.shared.gis.BoundsMap;
import org.gcube.application.geoportalcommon.util.StringUtil;
import org.gcube.application.geoportalcommon.util.URLParserUtil; import org.gcube.application.geoportalcommon.util.URLParserUtil;
import org.gcube.application.geoportaldatamapper.GcubeProfilesPerUCDIdCache;
import org.gcube.application.geoportaldatamapper.Geoportal_JSON_Mapper;
import org.gcube.application.geoportaldatamapper.exporter.Geoportal_PDF_Exporter;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerService; 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.FeatureParser;
@ -77,11 +68,10 @@ import org.gcube.portlets.user.geoportaldataviewer.server.gis.GisMakers;
import org.gcube.portlets.user.geoportaldataviewer.server.gis.WMSUrlValidator; import org.gcube.portlets.user.geoportaldataviewer.server.gis.WMSUrlValidator;
import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.GeoportalServiceIdentityProxy; import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.GeoportalServiceIdentityProxy;
import org.gcube.portlets.user.geoportaldataviewer.server.util.ContextRequest; import org.gcube.portlets.user.geoportaldataviewer.server.util.ContextRequest;
import org.gcube.portlets.user.geoportaldataviewer.server.util.HTTPRequestUtil;
import org.gcube.portlets.user.geoportaldataviewer.server.util.SessionUtil; import org.gcube.portlets.user.geoportaldataviewer.server.util.SessionUtil;
import org.gcube.portlets.user.geoportaldataviewer.server.util.TemporalComparatorUtil; import org.gcube.portlets.user.geoportaldataviewer.server.util.TemporalComparatorUtil;
import org.gcube.portlets.user.geoportaldataviewer.shared.GCubeCollection; import org.gcube.portlets.user.geoportaldataviewer.shared.GCubeCollection;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoportalSpatialQueryResult; import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult;
import org.gcube.portlets.user.geoportaldataviewer.shared.ItemFieldsResponse; import org.gcube.portlets.user.geoportaldataviewer.shared.ItemFieldsResponse;
import org.gcube.portlets.user.geoportaldataviewer.shared.ResultSetPaginatedDataIDs; import org.gcube.portlets.user.geoportaldataviewer.shared.ResultSetPaginatedDataIDs;
import org.gcube.portlets.user.geoportaldataviewer.shared.ViewerConfiguration; import org.gcube.portlets.user.geoportaldataviewer.shared.ViewerConfiguration;
@ -128,52 +118,6 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
gif, png, jpeg, jpg, bmp, tif, tiff, svg, avif, webp gif, png, jpeg, jpg, bmp, tif, tiff, svg, avif, webp
} }
/**
* The Enum CENTROID_LAYER_INDEX_FLAG.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* May 25, 2023
*/
public static enum CENTROID_LAYER_INDEX_FLAG {
PUBLIC("public"), PRIVATE("internal");
String id;
/**
* Instantiates a new centroid layer index flag.
*
* @param id the id
*/
CENTROID_LAYER_INDEX_FLAG(String id) {
this.id = id;
}
/**
* Gets the id.
*
* @return the id
*/
public String getId() {
return id;
}
/**
* To string.
*
* @return the string
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("CENTROID_LAYER_INDEX_FLAG [id=");
builder.append(id);
builder.append("]");
return builder.toString();
}
}
/** /**
* The Class ImageDetector. * The Class ImageDetector.
* *
@ -264,7 +208,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
public GeoInformationForWMSRequest loadGeoInfoForWmsRequest(String wmsLink, String layerName) throws Exception { public GeoInformationForWMSRequest loadGeoInfoForWmsRequest(String wmsLink, String layerName) throws Exception {
try { try {
WMSUrlValidator validator = new WMSUrlValidator(wmsLink, layerName); WMSUrlValidator validator = new WMSUrlValidator(wmsLink, layerName);
String wmsServiceServiceEndpoint = validator.getWmsServiceEndPoint(); String wmsServiceHost = validator.getWmsServiceHost();
String validWMSRequest = validator.parseWMSRequest(true, true); String validWMSRequest = validator.parseWMSRequest(true, true);
layerName = validator.getLayerName(); layerName = validator.getLayerName();
String versionWms = validator.getValueOfParsedWMSParameter(WmsParameters.VERSION); String versionWms = validator.getValueOfParsedWMSParameter(WmsParameters.VERSION);
@ -291,8 +235,8 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
? new ZAxis(layerZAxis.getUnits(), layerZAxis.isPositive(), layerZAxis.getValues()) ? new ZAxis(layerZAxis.getUnits(), layerZAxis.isPositive(), layerZAxis.getValues())
: null; : null;
return new GeoInformationForWMSRequest(wmsServiceServiceEndpoint, validWMSRequest, layerName, versionWms, return new GeoInformationForWMSRequest(wmsServiceHost, validWMSRequest, layerName, versionWms, crs,
crs, mapWmsNotStandard, styles, styles.isNcWms(), zAxis); mapWmsNotStandard, styles, styles.isNcWms(), zAxis);
} catch (Exception e) { } catch (Exception e) {
String msg = "An error occurred during wms request validation for layer: " + layerName; String msg = "An error occurred during wms request validation for layer: " + layerName;
LOG.error(msg, e); LOG.error(msg, e);
@ -382,9 +326,9 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
if (item.getProfileID() == null) if (item.getProfileID() == null)
throw new Exception("Bad request, the profileID is null"); throw new Exception("Bad request, the profileID is null");
String gcubeScope = SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
GeoportalCommon gc = new GeoportalCommon(); GeoportalCommon gc = new GeoportalCommon();
return gc.getPublicLinksFor(gcubeScope, item, true); return gc.getPublicLinksFor(item, true);
} catch (Exception e) { } catch (Exception e) {
LOG.error("Error on getPublicLinksFor for: " + item, e); LOG.error("Error on getPublicLinksFor for: " + item, e);
@ -414,14 +358,14 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
* @return the WFS features * @return the WFS features
*/ */
@Override @Override
public List<GeoportalSpatialQueryResult> getWFSFeatures(List<LayerObject> layerObjects, String mapSrsName, public List<GeoNaSpatialQueryResult> getWFSFeatures(List<LayerObject> layerObjects, String mapSrsName,
BoundsMap selectBBOX, int maxWFSFeature, double zoomLevel) { BoundsMap selectBBOX, int maxWFSFeature, double zoomLevel) {
LOG.info("getWFSFeatures called"); LOG.info("getWFSFeatures called");
List<GeoportalSpatialQueryResult> listDAO = new ArrayList<GeoportalSpatialQueryResult>(layerObjects.size()); List<GeoNaSpatialQueryResult> listDAO = new ArrayList<GeoNaSpatialQueryResult>(layerObjects.size());
for (LayerObject layerObject : layerObjects) { for (LayerObject layerObject : layerObjects) {
GeoportalSpatialQueryResult geoDAO = new GeoportalSpatialQueryResult(); GeoNaSpatialQueryResult geoDAO = new GeoNaSpatialQueryResult();
List<FeatureRow> features = FeatureParser.getWFSFeatures(layerObject.getLayerItem(), mapSrsName, selectBBOX, List<FeatureRow> features = FeatureParser.getWFSFeatures(layerObject.getLayerItem(), mapSrsName, selectBBOX,
maxWFSFeature); maxWFSFeature);
LOG.debug("For layer name: " + layerObject.getLayerItem().getName() + " got features: " + features); LOG.debug("For layer name: " + layerObject.getLayerItem().getName() + " got features: " + features);
@ -498,53 +442,50 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
try { try {
LOG.debug("Checking configuration for collection " + u.getId()); LOG.debug("Checking configuration for collection " + u.getId());
SessionUtil.addCollectionToSession(getThreadLocalRequest(), u);
Projects<Project> p = projects(u.getId()).build(); Projects<Project> p = projects(u.getId()).build();
UseCaseDescriptorDV ucdDV = ConvertToDataValueObjectModel.toUseCaseDescriptorDV(u, null); UseCaseDescriptorDV ucd = ConvertToDataValueObjectModel.toUseCaseDescriptorDV(u, null);
Configuration ucdConfig = p.getConfiguration(); Configuration ucdConfig = p.getConfiguration();
GCubeCollection coll = new GCubeCollection(); GCubeCollection coll = new GCubeCollection();
coll.setUcd(ucdDV); coll.setUcd(ucd);
// TODO TO Check index flag should be in configuration or evaluated according to // TODO TO Check index flag should be in configuration or evaluated according to
// user credentials // user credentials
CENTROID_LAYER_INDEX_FLAG setIndexFlag = null; String indexFlag = "public"; // default
GeoportalServiceIdentityProxy gsp = getGeoportalServiceProxy(); GeoportalServiceIdentityProxy gsp = getGeoportalServiceProxy();
if (gsp.isUser()) { if (gsp.isUser()) {
setIndexFlag = CENTROID_LAYER_INDEX_FLAG.PRIVATE; indexFlag = "internal";
LOG.info("user logged - using indexFlag: " + setIndexFlag); LOG.info("user logged - using indexFlag: " + indexFlag);
} else if (gsp.isIAMClient()) { } else if (gsp.isIAMClient()) {
setIndexFlag = CENTROID_LAYER_INDEX_FLAG.PUBLIC; indexFlag = "public";
LOG.info("user not logged - using indexFlag: " + setIndexFlag); LOG.info("user not logged - using indexFlag: " + indexFlag);
} }
// TODO constant // TODO constant
coll.setIndexes(new ArrayList()); coll.setIndexes(new ArrayList());
LOG.debug("Checking if " + u.getId() + " is GIS Indexed. Index flag needed is '" LOG.debug(
+ setIndexFlag + "'"); "Checking if " + u.getId() + " is GIS Indexed. Index flag needed is " + indexFlag);
IndexLayerDV toAdd = getLayerIndex(ucdConfig, setIndexFlag);
if (toAdd != null) {
coll.getIndexes().add(toAdd);
}
// Using the public centroid layer as default for (Index index : ucdConfig.getIndexes()) {
if (coll.getIndexes().isEmpty()) { try {
LOG.info("No available GIS Index for collection " + coll.getUcd().getName() IndexLayerDV toAdd = ConvertToDataValueObjectModel.convert(index);
+ " with flag " + setIndexFlag.getId()); if (toAdd.getFlag().equals(indexFlag)) {
setIndexFlag = CENTROID_LAYER_INDEX_FLAG.PUBLIC; coll.getIndexes().add(toAdd);
LOG.info("Prevent fallback - getting the GIS index with flag '" + setIndexFlag.getId() }
+ "' available"); } catch (Exception e) {
toAdd = getLayerIndex(ucdConfig, setIndexFlag); LOG.debug("Skipping invalid index ", e);
if (toAdd != null) { } catch (Throwable t) {
coll.getIndexes().add(toAdd); LOG.error("Unable to check index ", t);
} }
} }
if (!coll.getIndexes().isEmpty()) // Return only if gis indexed
if (coll.getIndexes().isEmpty())
LOG.info("No available GIS Index for collection " + coll.getUcd().getName());
else
config.getAvailableCollections().put(coll.getUcd().getId(), coll); config.getAvailableCollections().put(coll.getUcd().getId(), coll);
} catch (Throwable t) { } catch (Throwable t) {
@ -564,151 +505,6 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
}.execute().getResult(); }.execute().getResult();
} }
/**
* Gets the avaiable custom grouped layers for UCD.
*
* @param theHandler the the handler
* @return the avaiable custom grouped layers for UCD
*/
@Override
public Map<String, List<GroupedLayersDV<? extends LayerIDV>>> getAvaiableCustomGroupedLayersForUCD(
GEOPORTAL_DATA_HANDLER theHandler) {
LOG.debug("getAvaiableCustomGroupedLayersForUCD called");
Map<String, List<GroupedLayersDV<? extends LayerIDV>>> mapProfileIDCustomGroupedLayers = new LinkedHashMap<>();
// Reading UCDs Collections from the session
Map<String, UseCaseDescriptor> ucdCollections = SessionUtil.getAvailableCollections(getThreadLocalRequest());
LOG.debug("ucdCollections in session are: " + ucdCollections.size());
for (String profileId : ucdCollections.keySet()) {
UseCaseDescriptor u = ucdCollections.get(profileId);
// Loading geoportal_grouped_overlay_layers if exists
List<HandlerDeclaration> handlers = u.getHandlersByType(theHandler.getType());
GEOPORTAL_CONFIGURATION_TYPE configurationType = null;
switch (theHandler) {
case geoportal_grouped_overlay_layers:
configurationType = GEOPORTAL_CONFIGURATION_TYPE.grouped_overlay_layers;
break;
case geoportal_grouped_cross_filtering:
configurationType = GEOPORTAL_CONFIGURATION_TYPE.grouped_cross_filtering_layers;
default:
break;
}
if (configurationType != null && handlers != null && handlers.size() > 0) {
// Loading Handler gcube_profiles
HandlerDeclaration handler = handlers.get(0);
List<GroupedLayersDV<? extends LayerIDV>> listGroupedCustomLayers = (List<GroupedLayersDV<? extends LayerIDV>>) getGroupedLayers(
u, handler, configurationType);
LOG.debug("listGroupedCustomLayers for type '{}' are: {}", configurationType, listGroupedCustomLayers);
mapProfileIDCustomGroupedLayers.put(profileId, listGroupedCustomLayers);
} else {
LOG.info("No handler '{}' found into UCD {}, continue...", theHandler, u.getId());
mapProfileIDCustomGroupedLayers.put(profileId, null);
}
}
LOG.debug("mapProfileIDCustomGroupedLayers returned: " + mapProfileIDCustomGroupedLayers);
LOG.info("mapProfileIDCustomGroupedLayers returned are: " + mapProfileIDCustomGroupedLayers.size());
return mapProfileIDCustomGroupedLayers;
}
/**
* Gets the layer index.
*
* @param ucdConfig the ucd config
* @param flag the flag
* @return the layer index
*/
private IndexLayerDV getLayerIndex(Configuration ucdConfig, CENTROID_LAYER_INDEX_FLAG flag) {
for (Index index : ucdConfig.getIndexes()) {
try {
IndexLayerDV toAdd = ConvertToDataValueObjectModel.convert(index);
toAdd = removeGSWorkspaceFromWMSPathOfOGCLinks(toAdd);
LOG.trace("Discovered index: " + toAdd);
if (toAdd.getFlag().compareToIgnoreCase(flag.getId()) == 0) {
LOG.debug("Layer index found for flag: " + flag + ", returning");
return toAdd;
}
} catch (Exception e) {
LOG.debug("Skipping invalid index ", e);
} catch (Throwable t) {
LOG.error("Unable to check index ", t);
}
}
return null;
}
/**
* Removes the GS workspace from WMS path of OGC links.
*
* @param index the index
* @return the index layer DV
*/
private IndexLayerDV removeGSWorkspaceFromWMSPathOfOGCLinks(IndexLayerDV index) {
LOG.info("removeGSWorkspaceFromWMSPathOfOGCLinks called");
GCubeSDILayer indexLayer = index.getLayer();
HashMap<String, String> ogcLinks = indexLayer.getOgcLinks();
String wmsLink = ogcLinks.get("wms");
LOG.info("wms link is {}", StringUtil.ellipsize(wmsLink, 150));
int lastCharOfthePath = wmsLink.indexOf("?");
String wmsPath = wmsLink.substring(0, lastCharOfthePath);
for (GeoServerPlatformInfoDV geoserver : indexLayer.getPlatformInfos()) {
// removing "workspace/" from the wms path
if (wmsPath.contains(geoserver.getWorkspace())) {
wmsPath = wmsPath.replace(geoserver.getWorkspace() + "/", "");
LOG.debug("purged wmsPath from the 'workspace' is {}", wmsPath);
wmsLink = wmsPath + wmsLink.substring(lastCharOfthePath, wmsLink.length());
ogcLinks.put("wms", wmsLink);
LOG.info("wms link without {} is {}", geoserver.getWorkspace(), StringUtil.ellipsize(wmsLink, 150));
}
}
return index;
}
/**
* Gets the grouped layers.
*
* @param ucd the ucd
* @param handler the handler
* @param type the type
* @return the grouped layers
*/
private List<? extends GeoportalConfigurationID> getGroupedLayers(UseCaseDescriptor ucd, HandlerDeclaration handler,
GEOPORTAL_CONFIGURATION_TYPE type) {
List<? extends GeoportalConfigurationID> listGroupedCustomLayers = null;
try {
HandlerDeclarationDV handlerDV = ConvertToDataValueObjectModel.toHandlerDeclarationDV(handler, ucd, type);
if (handler != null) {
ConfigurationDV<?> config = handlerDV.getConfiguration();
switch (config.getConfigurationType()) {
case grouped_overlay_layers:
listGroupedCustomLayers = (List<GroupedLayersDV<ConfiguredLayerDV>>) config.getConfiguration();
break;
case grouped_cross_filtering_layers:
listGroupedCustomLayers = (List<GroupedLayersDV<CrossFilteringLayerDV>>) config.getConfiguration();
default:
break;
}
}
} catch (Exception e) {
LOG.error("Error on loading {} config for ucd Id {}. Returning null", type, ucd.getId());
}
return listGroupedCustomLayers;
}
/** /**
* Gets the config list of fields for searching. * Gets the config list of fields for searching.
* *
@ -815,7 +611,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
*/ */
@Override @Override
protected void onBeforeRequestDeserialized(String serializedRequest) { protected void onBeforeRequestDeserialized(String serializedRequest) {
LOG.debug("onBeforeRequestDeserialized called"); LOG.info("onBeforeRequestDeserialized called");
String scope = ""; String scope = "";
try { try {
@ -980,7 +776,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
String filesetParentJSONPath = null; String filesetParentJSONPath = null;
// (see ticket #24390) //(see ticket #24390)
if (accessPolicy.equals(ACCESS_POLICY.OPEN)) { if (accessPolicy.equals(ACCESS_POLICY.OPEN)) {
// Filtering for ACCESS_POLICY.OPEN from the fileset when the username is not in // Filtering for ACCESS_POLICY.OPEN from the fileset when the username is not in
// session. IAM // session. IAM
@ -1199,7 +995,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
* @throws Exception the exception * @throws Exception the exception
*/ */
@Override @Override
public List<GeoportalSpatialQueryResult> getDataResult(List<LayerObject> layerObjects, String mapSrsName, public List<GeoNaSpatialQueryResult> getDataResult(List<LayerObject> layerObjects, String mapSrsName,
BoundsMap selectBBOX, int maxWFSFeature, double zoomLevel) throws Exception { BoundsMap selectBBOX, int maxWFSFeature, double zoomLevel) throws Exception {
LOG.info("getDataResult called"); LOG.info("getDataResult called");
@ -1214,13 +1010,13 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
+ ", zoomLevel: " + zoomLevel); + ", zoomLevel: " + zoomLevel);
} }
List<GeoportalSpatialQueryResult> listDAO = new ArrayList<GeoportalSpatialQueryResult>(layerObjects.size()); List<GeoNaSpatialQueryResult> listDAO = new ArrayList<GeoNaSpatialQueryResult>(layerObjects.size());
try { try {
new GeoportalServiceIdentityProxy(this.getThreadLocalRequest()); new GeoportalServiceIdentityProxy(this.getThreadLocalRequest());
for (LayerObject layerObject : layerObjects) { for (LayerObject layerObject : layerObjects) {
GeoportalSpatialQueryResult geoDAO = new GeoportalSpatialQueryResult(); GeoNaSpatialQueryResult geoDAO = new GeoNaSpatialQueryResult();
List<FeatureRow> features = FeatureParser.getWFSFeatures(layerObject.getLayerItem(), mapSrsName, List<FeatureRow> features = FeatureParser.getWFSFeatures(layerObject.getLayerItem(), mapSrsName,
selectBBOX, maxWFSFeature); selectBBOX, maxWFSFeature);
LOG.debug("For layer name: " + layerObject.getLayerItem().getName() + " got features: " + features); LOG.debug("For layer name: " + layerObject.getLayerItem().getName() + " got features: " + features);
@ -1480,7 +1276,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
break; break;
Entry<String, Object> entry = entrySetsIt.next(); Entry<String, Object> entry = entrySetsIt.next();
documentAsMap.put(entry.getKey(), entry.getValue() != null ? entry.getValue().toString() : null); documentAsMap.put(entry.getKey(), entry.getValue()!=null?entry.getValue().toString():null);
i++; i++;
} }
@ -1774,22 +1570,6 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
return url; return url;
} }
/**
* Gets the HTTP response for URL.
*
* @param url the url
* @return the HTTP response for URL
*/
@Override
public String getHTTPResponseForURL(String url) {
LOG.info("getHTTPResponseForURL called");
if (LOG.isDebugEnabled()) {
LOG.debug("getHTTPResponseForURL for URL {} ", url);
}
return HTTPRequestUtil.getResponse(url);
}
/** /**
* Gets the WFS response. * Gets the WFS response.
* *
@ -1811,42 +1591,39 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
} }
String url = getWFSRequest(layerItem, mapSrsName, mapBBOX, maxFeatures, outputFormat); String url = getWFSRequest(layerItem, mapSrsName, mapBBOX, maxFeatures, outputFormat);
return HTTPRequestUtil.getResponse(url); StringBuffer response = new StringBuffer();
} String theResponseString = "";
HttpURLConnection con = null;
@Override LOG.debug("Built URL: " + url);
public Integer getCountFor(String profileID, String phase, String status) {
LOG.debug("getCountFor profileID: " + profileID + ", phase: " + phase + ", status: " + status + "called");
Integer integer = null;
try { try {
new GeoportalServiceIdentityProxy(this.getThreadLocalRequest()); URL obj = new URL(url);
integer = GeoportalClientCaller.projects().getCountByPhaseFor(profileID, phase, status); con = (HttpURLConnection) obj.openConnection();
LOG.info("getCountFor profileID: " + profileID + ", phase: " + phase + ", status: " + status con.setRequestMethod("GET");
+ " returning: " + integer); int responseCode = con.getResponseCode();
} catch (Exception e) { LOG.debug("GET Response Code: " + responseCode);
LOG.error("Error occurred in getCountFor for profileID: " + profileID, e); if (responseCode == HttpURLConnection.HTTP_OK) { // success
} BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
return integer; String inputLine;
} while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
@Override }
public Boolean checkExportAsPDFConfig() { in.close();
LOG.debug("checkExportAsPDFConfig called"); } else {
Boolean configChecked = null; LOG.info("GET request did not work.");
try {
new GeoportalServiceIdentityProxy(this.getThreadLocalRequest());
configChecked = SessionUtil.getCheckConfigForPFDExporter(this.getThreadLocalRequest());
if(configChecked==null) {
Geoportal_PDF_Exporter gpdfe = new Geoportal_PDF_Exporter();
configChecked = gpdfe.checkConfig();
SessionUtil.setCheckConfigForPFDExporter(this.getThreadLocalRequest(), configChecked);
} }
LOG.info("Does the 'Export As PDF' config exists? " + configChecked); theResponseString = response.toString();
//LOG.trace(theResponseString);
if (LOG.isDebugEnabled()) {
LOG.debug("getWFSResponse is empty? " + theResponseString.isEmpty());
}
} catch (Exception e) { } catch (Exception e) {
LOG.error("Error occurred in checkExportAsPDFConfig", e); LOG.error("Error on performing the request to URL: " + url, e);
} finally {
} }
return configChecked; return theResponseString;
} }
} }

View File

@ -1,257 +0,0 @@
/**
*
*/
package org.gcube.portlets.user.geoportaldataviewer.server;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Enumeration;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.IOUtils;
import org.apache.http.client.methods.HttpGet;
import org.gcube.common.portal.PortalContext;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.GeoportalServiceIdentityProxy;
import org.gcube.portlets.user.geoportaldataviewer.server.util.SessionUtil;
import org.gcube.portlets.user.uriresolvermanager.geoportal.GeoportalExporterAPI;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class GeoportalExporterActionServlet.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Apr 23, 2024
*/
public class GeoportalExporterActionServlet extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = 6037090280489238565L;
protected static Logger logger = LoggerFactory.getLogger(GeoportalExporterActionServlet.class);
/**
* {@inheritDoc}
*/
@Override
public void init() throws ServletException {
super.init();
logger.trace(GeoportalExporterActionServlet.class.getSimpleName() + " ready.");
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
logger.info("doPost Called");
serveRequest(req, resp);
}
/**
* Do get.
*
* @param req the req
* @param resp the resp
* @throws IOException Signals that an I/O exception has occurred.
* @throws ServletException the servlet exception
*/
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException {
logger.info("doGet Called");
sendError(resp,
"The request cannot be served (via http GET). Please retry by using the Export facility provided by Data-Viewer UI");
}
/**
* Serve request.
*
* @param req the req
* @param resp the resp
* @throws IOException Signals that an I/O exception has occurred.
*/
public void serveRequest(HttpServletRequest req, HttpServletResponse resp) throws IOException {
// setSecretManager();
String projectID = req.getParameter(GeoportalDataViewerConstants.PROIECT_ID_PARAMETER);
String ucdID = req.getParameter(GeoportalDataViewerConstants.UCD_ID_PARAMETER);
String contextID = req.getParameter(GeoportalDataViewerConstants.CONTEXT_ID_PARAMETER);
String userID = req.getParameter(GeoportalDataViewerConstants.USER_ID_PARAMETER);
String username = req.getParameter(GeoportalDataViewerConstants.USERNAME_PARAMETER);
// logger.info("serveRequest called with [projectID: " + projectID + ", ucdID: " + ucdID + ", contextID: " + contextID+"]");
logger.info("serveRequest called with [projectID: " + projectID + ", ucdID: " + ucdID + ", contextID: "
+ contextID + ", userID: " + userID + ", username: " + username + "]");
if (contextID == null || contextID.isEmpty())
sendError(resp, "Bad Request. No context found!");
PortalContext pContext = PortalContext.getConfiguration();
String scope = pContext.getCurrentScope(contextID);
logger.info("The scope is {}", scope);
try {
// Setting header required to {@PortalContext}
MutableHttpServletRequest mutableRequest = new MutableHttpServletRequest(req);
mutableRequest.putHeader(PortalContext.VRE_ID_ATTR_NAME, contextID);
// DEV MODE
if (!SessionUtil.isIntoPortal()) {
logger.info("DEBUG MODE, putting header " + PortalContext.USER_ID_ATTR_NAME);
mutableRequest.putHeader(PortalContext.USER_ID_ATTR_NAME, userID);
}
// IF USERNAME exists, add the userID to request. So performing the request to
// exporter service on behalf of the user.
if (username != null) {
logger.info("Username found, putting header " + PortalContext.USER_ID_ATTR_NAME);
mutableRequest.putHeader(PortalContext.USER_ID_ATTR_NAME, userID);
}
ScopeProvider.instance.set(scope);
GeoportalServiceIdentityProxy identity = new GeoportalServiceIdentityProxy(mutableRequest);
String theToken = identity.getToken();
String theIdentity = identity.getIdentity();
logger.info("The identity is {}", theIdentity);
GeoportalExporterAPI geoportalExporterAPI = new GeoportalExporterAPI();
URL urlRequest = geoportalExporterAPI.exportProject("pdf", ucdID, projectID, false);
String urlToRedirect = urlRequest.toString();
logger.info("Performing request to {} with identity description {}", urlToRedirect,
identity.getDescription());
logger.info("Token is {}", theToken.substring(0, 20) + "_MASKED_TOKEN");
InputStream is = performHttpRequestToSGService(urlToRedirect, theIdentity, theToken);
resp.setContentType("text/html; charset=utf-8");
IOUtils.copy(is, resp.getOutputStream());
resp.flushBuffer();
} catch (Exception e) {
logger.error("Error occurred when exporting the Project with id: " + projectID, e);
sendError(resp, "Error occurred when exporting the Project. Error is: " + e.getMessage());
return;
}
}
/**
* Perform http request to SG service.
*
* @param urlToService the url to service
* @param identity the identity
* @param token the token
* @return the input stream
* @throws IOException Signals that an I/O exception has occurred.
*/
public static InputStream performHttpRequestToSGService(String urlToService, String identity, String token)
throws IOException {
logger.debug("performHttpRequestToSGService called");
try {
URL url = new URL(urlToService);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
// timeout at 60sec
conn.setConnectTimeout(6000);
conn.setDoOutput(true);
if (token.length() > 50) {
// is JWT TOKEN
conn.setRequestProperty("Authorization", "Bearer " + token);
} else {
// is legacy Token
conn.setRequestProperty("gcube-token", token);
}
conn.setRequestProperty("Content-Type", "text/html");
conn.setRequestMethod("GET");
logger.debug("performHttpRequestToSGService done, returning");
return conn.getInputStream();
} catch (IOException e) {
logger.error("Error on performing request to url " + urlToService, e);
throw e;
}
}
/**
* Sets the headers to target.
*
* @param httpSource the http source
* @param response the response
* @return the http servlet response
*/
public static HttpServletResponse setHeadersToTarget(HttpServletRequest httpSource, HttpServletResponse response) {
Enumeration<String> headersNames = httpSource.getHeaderNames();
while (headersNames.hasMoreElements()) {
String headerName = (String) headersNames.nextElement();
Enumeration<String> values = httpSource.getHeaders(headerName);
while (values.hasMoreElements()) {
String value = values.nextElement();
logger.info("Copying header {} with value {}", headerName, value);
response.addHeader(headerName, value);
}
}
return response;
}
/**
* Sets the headers to target.
*
* @param httpSource the http source
* @param httpTarget the http target
* @return the http get
*/
public static HttpGet setHeadersToTarget(HttpServletRequest httpSource, HttpGet httpTarget) {
Enumeration<String> headersNames = httpSource.getHeaderNames();
while (headersNames.hasMoreElements()) {
String headerName = (String) headersNames.nextElement();
Enumeration<String> values = httpSource.getHeaders(headerName);
while (values.hasMoreElements()) {
String value = values.nextElement();
logger.info("Copying header {} with value {}", headerName, value);
httpTarget.addHeader(headerName, value);
}
}
return httpTarget;
}
/**
* Sets the headers to response.
*
* @param httpSource the http source
* @param httpTarget the http target
* @return the http get
*/
public static HttpGet setHeadersToResponse(HttpServletRequest httpSource, HttpGet httpTarget) {
Enumeration<String> headersNames = httpSource.getHeaderNames();
while (headersNames.hasMoreElements()) {
String headerName = (String) headersNames.nextElement();
Enumeration<String> values = httpSource.getHeaders(headerName);
while (values.hasMoreElements()) {
String value = values.nextElement();
logger.info("Copying header {} with value {}", headerName, value);
httpTarget.addHeader(headerName, value);
}
}
return httpTarget;
}
/**
* Send response.
*
* @param response the response
* @param message the message
* @throws IOException Signals that an I/O exception has occurred.
*/
protected void sendError(HttpServletResponse response, String message) throws IOException {
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
response.setContentType("text/html");
response.getWriter().write("<html><head><title>Error</title></head><body>" + message + "</body></html>");
response.flushBuffer();
}
}

View File

@ -1,53 +0,0 @@
package org.gcube.portlets.user.geoportaldataviewer.server;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
final class MutableHttpServletRequest extends HttpServletRequestWrapper {
// holds custom header and value mapping
private final Map<String, String> customHeaders;
public MutableHttpServletRequest(HttpServletRequest request){
super(request);
this.customHeaders = new HashMap<String, String>();
}
public void putHeader(String name, String value){
this.customHeaders.put(name, value);
}
public String getHeader(String name) {
// check the custom headers first
String headerValue = customHeaders.get(name);
if (headerValue != null){
return headerValue;
}
// else return from into the original wrapped object
return ((HttpServletRequest) getRequest()).getHeader(name);
}
public Enumeration<String> getHeaderNames() {
// create a set of the custom header names
Set<String> set = new HashSet<String>(customHeaders.keySet());
// now add the headers from the wrapped request object
@SuppressWarnings("unchecked")
Enumeration<String> e = ((HttpServletRequest) getRequest()).getHeaderNames();
while (e.hasMoreElements()) {
// add the names of the request headers into the list
String n = e.nextElement();
set.add(n);
}
// create an enumeration from the set and return
return Collections.enumeration(set);
}
}

View File

@ -4,7 +4,6 @@ import org.gcube.application.geoportalcommon.shared.gis.BoundsMap;
import org.gcube.application.geoportalcommon.util.URLParserUtil; import org.gcube.application.geoportalcommon.util.URLParserUtil;
import org.gcube.portlets.user.geoportaldataviewer.server.gis.MapServerRecognize.SERVERTYPE; import org.gcube.portlets.user.geoportaldataviewer.server.gis.MapServerRecognize.SERVERTYPE;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.WFSGetFeature;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -61,8 +60,8 @@ public class GisMakers {
public static String buildWFSFeatureQuery(LayerItem layerItem, String mapSrsName, BoundsMap mapBBOX, public static String buildWFSFeatureQuery(LayerItem layerItem, String mapSrsName, BoundsMap mapBBOX,
int maxFeatures, String outputFormat) { int maxFeatures, String outputFormat) {
String link = layerItem.getMapServerEndpoint(); String link = layerItem.getMapServerHost();
LOG.debug("Map server endpoint: " + link); LOG.debug("Map server host URL: " + link);
LOG.debug("CQL filter is: " + layerItem.getCqlFilter()); LOG.debug("CQL filter is: " + layerItem.getCqlFilter());
LOG.debug("MAX FEATURES: " + maxFeatures); LOG.debug("MAX FEATURES: " + maxFeatures);
LOG.debug("BBOX: " + mapBBOX); LOG.debug("BBOX: " + mapBBOX);

View File

@ -1,4 +1,6 @@
package org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs; package org.gcube.portlets.user.geoportaldataviewer.server.gis;
/** /**
* The Enum WfsParameters. * The Enum WfsParameters.
@ -18,7 +20,6 @@ public enum WFSGetFeature {
WIDTH("WIDTH","676"), WIDTH("WIDTH","676"),
HEIGHT("HEIGHT","230"), HEIGHT("HEIGHT","230"),
SRSNAME("srsName","EPSG:4326"), SRSNAME("srsName","EPSG:4326"),
PROPERTYNAME("propertyName", ""),
// CRS("CRS","EPSG:4326"), //WMS 1.3.0 COMPLIANT // CRS("CRS","EPSG:4326"), //WMS 1.3.0 COMPLIANT
OUTPUTFORMAT("OUTPUTFORMAT","json"), OUTPUTFORMAT("OUTPUTFORMAT","json"),
MAXFEATURES("MAXFEATURES",""); MAXFEATURES("MAXFEATURES","");

View File

@ -12,10 +12,12 @@ import org.gcube.spatial.data.geoutility.wms.WmsUrlValidator;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
/** /**
* The Class GisViewerWMSUrlValidator. * The Class GisViewerWMSUrlValidator.
* *
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Jan 28, 2016 * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Jan 28, 2016
*/ */
public class WMSUrlValidator { public class WMSUrlValidator {
@ -24,7 +26,7 @@ public class WMSUrlValidator {
private static final String OWS = "ows"; private static final String OWS = "ows";
private HashMap<String, String> parametersValue = new HashMap<String, String>(); private HashMap<String, String> parametersValue = new HashMap<String, String>();
private String wmsRequestURI; private String wmsRequestURI;
private String wmsServiceEndPoint; private String wmsServiceHost;
private String layerName; private String layerName;
private String wmsNoStandardParameters = ""; private String wmsNoStandardParameters = "";
@ -33,95 +35,100 @@ public class WMSUrlValidator {
private static final Logger LOG = LoggerFactory.getLogger(WMSUrlValidator.class); private static final Logger LOG = LoggerFactory.getLogger(WMSUrlValidator.class);
/** /**
* Instantiates a new WMS url validator. * Instantiates a new WMS url validator.
* *
* @param wmsRequest the wms request * @param wmsRequest the wms request
* @param inputLayerName the input layer name * @param inputLayerName the input layer name
* @throws Exception the exception * @throws Exception the exception
*/ */
public WMSUrlValidator(String wmsRequest, String inputLayerName) throws Exception { public WMSUrlValidator(String wmsRequest, String inputLayerName) throws Exception{
LOG.debug("WMSURLValidator wmsRequest: " + wmsRequest); LOG.debug("WMSURLValidator wmsRequest: "+wmsRequest);
LOG.debug("WMSURLValidator layerName: " + inputLayerName); LOG.debug("WMSURLValidator layerName: "+inputLayerName);
if (wmsRequest == null || wmsRequest.isEmpty())
if(wmsRequest==null || wmsRequest.isEmpty())
throw new Exception("WMS request is null or empty"); throw new Exception("WMS request is null or empty");
this.wmsRequestURI = wmsRequest.trim(); this.wmsRequestURI = wmsRequest.trim();
boolean isOwsService = GeoWmsServiceUtility.isOWSSerice(this.wmsRequestURI);
WebMapServerHost webMapServerHost;
//IS WMS?
if(GeoWmsServiceUtility.isWMSService(wmsRequestURI)){
LOG.trace("found "+GeoWmsServiceUtility.SERVICE_WMS+" in wms request: "+wmsRequestURI);
webMapServerHost = getWebMapServerHost(wmsRequestURI);
}else
throw new Exception("WMS service not found for layer: "+inputLayerName);
//VALIDATION WMS
String baseWmsService = webMapServerHost.getHost();
//IS OWS OR WMS?
this.wmsServiceHost = appendWmsServiceToBaseUrl(wmsRequest.substring(0, wmsRequest.indexOf("?")),isOwsService);
this.layerName = inputLayerName;
// VALIDATION WMS
int endpointLastCharIndex = wmsRequest.lastIndexOf("?");
// No '?' char found
if (endpointLastCharIndex == -1) {
LOG.info("Char '?' not found, setting last index the end of the URI");
endpointLastCharIndex = wmsRequest.length();
}
String readWMSServiceEndpoint = wmsRequest.substring(0, endpointLastCharIndex);
this.wmsServiceEndPoint = readWMSServiceEndpoint;
try { try {
// VALIDATE WMS SERVICE FOR WEB MAP SERVER //VALIDATE WMS SERVICE FOR WEB MAP SERVER
if (!HttpRequestUtil.urlExists(this.wmsServiceEndPoint, true)) { if(!HttpRequestUtil.urlExists(this.wmsServiceHost, true)){
LOG.warn("baseWmsServiceUrl: " + wmsServiceEndPoint + " is not valid URL!!"); LOG.info("baseWmsServiceUrl: "+wmsServiceHost +" is not a geoserver, setting as input base wms server: "+baseWmsService);
this.wmsServiceEndPoint = readWMSServiceEndpoint; this.wmsServiceHost = baseWmsService;
} }
} catch (Exception e) { } catch (Exception e) {
LOG.error("Error on validating the endpoint: " + this.wmsServiceEndPoint, e); LOG.error("error on validating geoserver wms service: "+e);
boolean isOwsService = GeoWmsServiceUtility.isOWSSerice(this.wmsRequestURI); LOG.info("setting baseWmsService as input base wms server: "+baseWmsService);
LOG.info("Retrying by appending suffix WMS or WFS..."); this.wmsServiceHost = baseWmsService;
this.wmsServiceEndPoint = appendWmsServiceToBaseUrl(readWMSServiceEndpoint, isOwsService);
} }
// VALIDATION FOR THREDDS - FIND LAYER NAME INTO WMS PATH //VALIDATION FOR THREDDS - FIND LAYER NAME INTO WMS PATH
if (this.layerName == null || this.layerName.isEmpty()) { if(this.layerName==null || this.layerName.isEmpty()){
this.layerName = WmsUrlValidator.getValueOfParameter(WmsParameters.LAYERS, wmsRequest); this.layerName = WmsUrlValidator.getValueOfParameter(WmsParameters.LAYERS, wmsRequest);
if (this.layerName == null || this.layerName.isEmpty()) if(this.layerName==null || this.layerName.isEmpty())
throw new Exception("Layer name is null or empty"); throw new Exception("Layer name is null or empty");
} }
LOG.info("WMSURLValidator found endpoint: " + wmsServiceEndPoint);
parametersValue.put(WmsParameters.LAYERS.getParameter(), this.layerName); parametersValue.put(WmsParameters.LAYERS.getParameter(), this.layerName);
} }
/** /**
* Append wms service to base url. * Append wms service to base url.
* *
* @param url the url * @param url the url
* @param isOwsServer the is ows server * @param isOwsServer the is ows server
* @return the string * @return the string
*/ */
public String appendWmsServiceToBaseUrl(String url, boolean isOwsServer) { public String appendWmsServiceToBaseUrl(String url, boolean isOwsServer){
if (url.contains("/" + WMS) || url.contains("/" + OWS)) if(url.contains("/"+WMS) || url.contains("/"+OWS))
return url; return url;
if (url.lastIndexOf("/") != url.length()) { if(url.lastIndexOf("/") != url.length()){
url += "/"; url+="/";
} }
if (isOwsServer) if(isOwsServer)
return url += OWS; return url+=OWS;
else else
return url += WMS; return url+=WMS;
} }
/** /**
* Method: getFullWmsUrlRequest Create a correct wms url request Returns: * Method: getFullWmsUrlRequest
* Create a correct wms url request
* Returns:
* {String}. * {String}.
* *
* @param returnEmptyParameter if true the wms url returned contains also * @param returnEmptyParameter if true the wms url returned contains also wms parameter with empty value, none otherwise.
* wms parameter with empty value, none * and mandatory wms parameters that does not found are filled with empty values
* otherwise. and mandatory wms parameters
* that does not found are filled with empty
* values
* @param fillEmptyParameterAsDefault the fill empty parameter as default * @param fillEmptyParameterAsDefault the fill empty parameter as default
* @return a correct wms url request in formatted string like this: * @return a correct wms url request in formatted string like this:
* "wmsserver?key1=value1&key2=value2&key3=value3" * "wmsserver?key1=value1&key2=value2&key3=value3"
*/ */
public String parseWMSRequest(boolean returnEmptyParameter, boolean fillEmptyParameterAsDefault) { public String parseWMSRequest(boolean returnEmptyParameter, boolean fillEmptyParameterAsDefault){
urlValidator = new org.gcube.spatial.data.geoutility.wms.WmsUrlValidator(wmsRequestURI); urlValidator = new org.gcube.spatial.data.geoutility.wms.WmsUrlValidator(wmsRequestURI);
String fullWmsUrlBuilded; String fullWmsUrlBuilded;
@ -131,108 +138,106 @@ public class WMSUrlValidator {
parametersValue.putAll(urlValidator.getMapWmsParameters()); parametersValue.putAll(urlValidator.getMapWmsParameters());
String ln = parametersValue.get(WmsParameters.LAYERS.name()); String ln = parametersValue.get(WmsParameters.LAYERS.name());
LOG.debug("Comparing layer name from Wms request: " + ln + ", with OnLineResource layerName: " LOG.debug("Comparing layer name from Wms request: "+ln +", with OnLineResource layerName: "+this.layerName);
+ this.layerName); if(ln==null || ln.isEmpty() || ln.compareTo(this.layerName)!=0){
if (ln == null || ln.isEmpty() || ln.compareTo(this.layerName) != 0) { LOG.info("Layer name into wms request is different to OnLineResource layers name, replacing layer name: "+this.layerName);
LOG.info(
"Layer name into wms request is different to OnLineResource layers name, replacing layer name: "
+ this.layerName);
parametersValue.put(WmsParameters.LAYERS.getParameter(), this.layerName); parametersValue.put(WmsParameters.LAYERS.getParameter(), this.layerName);
urlValidator.getMapWmsParameters().put( urlValidator.getMapWmsParameters().put(org.gcube.spatial.data.geoutility.bean.WmsParameters.LAYERS.getParameter(), this.layerName);
org.gcube.spatial.data.geoutility.bean.WmsParameters.LAYERS.getParameter(), this.layerName); fullWmsUrlBuilded = org.gcube.spatial.data.geoutility.wms.WmsUrlValidator.setValueOfParameter(org.gcube.spatial.data.geoutility.bean.WmsParameters.LAYERS, fullWmsUrlBuilded, this.layerName, true);
fullWmsUrlBuilded = org.gcube.spatial.data.geoutility.wms.WmsUrlValidator.setValueOfParameter(
org.gcube.spatial.data.geoutility.bean.WmsParameters.LAYERS, fullWmsUrlBuilded, this.layerName,
true);
} }
// logger.trace("parametersValue: "+parametersValue); // logger.trace("parametersValue: "+parametersValue);
mapWmsNoStandardParams = new HashMap<String, String>(urlValidator.getMapWmsNoStandardParams().size()); mapWmsNoStandardParams = new HashMap<String, String>(urlValidator.getMapWmsNoStandardParams().size());
mapWmsNoStandardParams.putAll(urlValidator.getMapWmsNoStandardParams()); mapWmsNoStandardParams.putAll(urlValidator.getMapWmsNoStandardParams());
wmsNoStandardParameters = urlValidator.getWmsNoStandardParameters(); wmsNoStandardParameters = urlValidator.getWmsNoStandardParameters();
} catch (Exception e) { }
LOG.error("An error occurred during wms uri build, returning uri: " + wmsRequestURI, e); catch (Exception e) {
LOG.error("An error occurred during wms uri build, returning uri: "+wmsRequestURI, e);
fullWmsUrlBuilded = wmsRequestURI; fullWmsUrlBuilded = wmsRequestURI;
} }
LOG.trace("GisViewerWMSUrlValidator parseWMSRequest returning full wms url: " + fullWmsUrlBuilded); LOG.trace("GisViewerWMSUrlValidator parseWMSRequest returning full wms url: "+fullWmsUrlBuilded);
return fullWmsUrlBuilded; return fullWmsUrlBuilded;
} }
/** /**
* Gets the web map server host. * Gets the web map server host.
* *
* @param wmsRequest the wms request * @param wmsRequest the wms request
* @return the web map server host, (geoserver URI or the wmsRequest substring * @return the web map server host, (geoserver URI or the wmsRequest substring from start to index of '?' char (if exists))
* from start to index of '?' char (if exists))
*/ */
public WebMapServerHost getWebMapServerHost(String wmsRequest) { public WebMapServerHost getWebMapServerHost(String wmsRequest){
WebMapServerHost webMapServerHost = new WebMapServerHost(); WebMapServerHost webMapServerHost = new WebMapServerHost();
if (wmsRequest == null) if(wmsRequest==null)
return webMapServerHost; // uri is empty return webMapServerHost; //uri is empty
int end = wmsRequest.toLowerCase().lastIndexOf("?"); int end = wmsRequest.toLowerCase().lastIndexOf("?");
if (end == -1) { if(end==-1){
LOG.trace("char ? not found in geoserver uri, return: " + wmsRequest); LOG.trace("char ? not found in geoserver uri, return: "+wmsRequest);
return webMapServerHost; // uri is empty return webMapServerHost; //uri is empty
} }
String webMapServerBaseURL = wmsRequest.substring(0, wmsRequest.toLowerCase().lastIndexOf("?")); String webMapServerBaseURL = wmsRequest.substring(0, wmsRequest.toLowerCase().lastIndexOf("?"));
int index = webMapServerBaseURL.lastIndexOf(GEOSERVER); int index = webMapServerBaseURL.lastIndexOf(GEOSERVER);
if (index > -1) { // FOUND the string GEOSERVER into URL if(index>-1){ //FOUND the string GEOSERVER into URL
LOG.trace("found geoserver string: " + GEOSERVER + " in " + webMapServerBaseURL); LOG.trace("found geoserver string: "+GEOSERVER+" in "+webMapServerBaseURL);
// THERE IS SCOPE? //THERE IS SCOPE?
int lastSlash = webMapServerBaseURL.lastIndexOf("/"); int lastSlash = webMapServerBaseURL.lastIndexOf("/");
int includeGeoserverString = index + GEOSERVER.length(); int includeGeoserverString = index+GEOSERVER.length();
int endUrl = lastSlash > includeGeoserverString ? lastSlash : includeGeoserverString; int endUrl = lastSlash>includeGeoserverString?lastSlash:includeGeoserverString;
LOG.trace("indexs - lastSlash: [" + lastSlash + "], includeGeoserverString: [" + includeGeoserverString LOG.trace("indexs - lastSlash: ["+lastSlash+"], includeGeoserverString: ["+includeGeoserverString+"], endUrl: ["+endUrl+"]");
+ "], endUrl: [" + endUrl + "]"); int startScope = includeGeoserverString+1<endUrl?includeGeoserverString+1:endUrl; //INCLUDE SLASH
int startScope = includeGeoserverString + 1 < endUrl ? includeGeoserverString + 1 : endUrl; // INCLUDE SLASH
String scope = webMapServerBaseURL.substring(startScope, endUrl); String scope = webMapServerBaseURL.substring(startScope, endUrl);
LOG.trace("geoserver url include scope: " + webMapServerBaseURL.substring(includeGeoserverString, endUrl)); LOG.trace("geoserver url include scope: "+webMapServerBaseURL.substring(includeGeoserverString, endUrl));
webMapServerHost.setHost(webMapServerBaseURL.substring(0, endUrl)); webMapServerHost.setHost(webMapServerBaseURL.substring(0, endUrl));
webMapServerHost.setScope(scope); webMapServerHost.setScope(scope);
return webMapServerHost; return webMapServerHost;
} else { }else{
LOG.trace("the string 'geoserver' not found in " + webMapServerBaseURL); LOG.trace("the string 'geoserver' not found in "+webMapServerBaseURL);
// GET LAST INDEX OF '/' AND CONCATENATE GEOSERVER // GET LAST INDEX OF '/' AND CONCATENATE GEOSERVER
String urlConn = webMapServerBaseURL.substring(0, webMapServerBaseURL.lastIndexOf("/")) + GEOSERVER; String urlConn = webMapServerBaseURL.substring(0, webMapServerBaseURL.lastIndexOf("/"))+GEOSERVER;
LOG.trace("tentative concatenating string 'geoserver' at http url " + urlConn); LOG.trace("tentative concatenating string 'geoserver' at http url "+urlConn);
try { try {
if (HttpRequestUtil.urlExists(urlConn, false)) { if(HttpRequestUtil.urlExists(urlConn, false)){
LOG.trace("url: " + urlConn + " - open a connection, return " + urlConn); LOG.trace("url: "+urlConn+" - open a connection, return "+urlConn);
webMapServerHost.setHost(urlConn); webMapServerHost.setHost(urlConn);
return webMapServerHost; return webMapServerHost;
} else }
LOG.trace("url: " + urlConn + " - not open a connection"); else
LOG.trace("url: "+urlConn+" - not open a connection");
} catch (Exception e) { } catch (Exception e) {
LOG.error("url connection is wrong at :" + urlConn); LOG.error("url connection is wrong at :"+urlConn);
} }
String uriWithoutParameters = wmsRequest.substring(0, end); String uriWithoutParameters = wmsRequest.substring(0, end);
LOG.trace("url connection, returned: " + uriWithoutParameters); LOG.trace("url connection, returned: "+uriWithoutParameters);
webMapServerHost.setHost(uriWithoutParameters); webMapServerHost.setHost(uriWithoutParameters);
return webMapServerHost; return webMapServerHost;
} }
} }
/**
* Gets the wms service end point.
*
* @return the wms service end point
*/
public String getWmsServiceEndPoint() {
return wmsServiceEndPoint; /**
* Gets the wms service host.
*
* @return the wms service host
*/
public String getWmsServiceHost() {
return wmsServiceHost;
} }
/** /**
@ -255,40 +260,42 @@ public class WMSUrlValidator {
return wmsNoStandardParameters; return wmsNoStandardParameters;
} }
/** /**
* Gets the value of parsed wms parameter. * Gets the value of parsed wms parameter.
* *
* @param parameter the parameter * @param parameter the parameter
* @return the value of parsed wms parameter parsed from wms request. * @return the value of parsed wms parameter parsed from wms request.
*/ */
public String getValueOfParsedWMSParameter(WmsParameters parameter) { public String getValueOfParsedWMSParameter(WmsParameters parameter){
return parametersValue.get(parameter.getParameter()); return parametersValue.get(parameter.getParameter());
} }
/** /**
* Gets the value of parameter. * Gets the value of parameter.
* *
* @param wmsParam the wms param * @param wmsParam the wms param
* @param wmsUrlParameters the wms url parameters * @param wmsUrlParameters the wms url parameters
* @return the value of parameter * @return the value of parameter
*/ */
public static String getValueOfParameter(WmsParameters wmsParam, String wmsUrlParameters) { public static String getValueOfParameter(WmsParameters wmsParam, String wmsUrlParameters){
return WmsUrlValidator.getValueOfParameter(wmsParam, wmsUrlParameters); return WmsUrlValidator.getValueOfParameter(wmsParam, wmsUrlParameters);
} }
/** /**
* Sets the value of parameter. * Sets the value of parameter.
* *
* @param wmsParam the wms param * @param wmsParam the wms param
* @param wmsUrlParameters the wms url parameters * @param wmsUrlParameters the wms url parameters
* @param newValue the new value * @param newValue the new value
* @param addIfNotExists the add if not exists * @param addIfNotExists the add if not exists
* @return the string * @return the string
*/ */
public static String setValueOfParameter(WmsParameters wmsParam, String wmsUrlParameters, String newValue, public static String setValueOfParameter(WmsParameters wmsParam, String wmsUrlParameters, String newValue, boolean addIfNotExists){
boolean addIfNotExists) {
return WmsUrlValidator.setValueOfParameter(wmsParam, wmsUrlParameters, newValue, addIfNotExists); return WmsUrlValidator.setValueOfParameter(wmsParam, wmsUrlParameters, newValue, addIfNotExists);
} }
@ -302,6 +309,8 @@ public class WMSUrlValidator {
return layerName; return layerName;
} }
/** /**
* Gets the styles as list. * Gets the styles as list.
* *
@ -312,17 +321,18 @@ public class WMSUrlValidator {
List<String> listStyles = new ArrayList<String>(); List<String> listStyles = new ArrayList<String>();
String styles = getValueOfParsedWMSParameter(WmsParameters.STYLES); String styles = getValueOfParsedWMSParameter(WmsParameters.STYLES);
if (styles != null && !styles.isEmpty()) { if(styles!=null && !styles.isEmpty()){
String[] arrayStyle = styles.split(","); String[] arrayStyle = styles.split(",");
for (String style : arrayStyle) { for (String style : arrayStyle) {
if (style != null && !style.isEmpty()) if(style!=null && !style.isEmpty())
listStyles.add(style); listStyles.add(style);
} }
} }
return listStyles; return listStyles;
} }
/** /**
* Gets the map wms no standard params. * Gets the map wms no standard params.
* *
@ -332,4 +342,63 @@ public class WMSUrlValidator {
return mapWmsNoStandardParams; return mapWmsNoStandardParams;
} }
/**
* The main method.
*
* @param args the arguments
*/
public static void main(String[] args) {
// String baseGeoserverUrl = "http://repoigg.services.iit.cnr.it:8080/geoserver/IGG/ows";
// String baseGeoserverUrl = "http://www.fao.org/figis/geoserver/species";
// String fullPath = "http://www.fao.org/figis/geoserver/species?SERVICE=WMS&BBOX=-176.0,-90.0,180.0,90&styles=Species_prob, puppa&layers=layerName&FORMAT=image/gif";
// String fullPath = "http://repoigg.services.iit.cnr.it:8080/geoserver/IGG/ows?service=wms&version=1.1.0&request=GetMap&layers==IGG:area_temp_1000&width=676&height=330&srs=EPSG:4326&crs=EPSG:4326&format=application/openlayers&bbox=-85.5,-180.0,90.0,180.0";
// String baseGeoserverUrl = "http://thredds-d-d4s.d4science.org/thredds/wms/public/netcdf/test20.nc";
// String fullPath = "http://thredds-d-d4s.d4science.org/thredds/wms/public/netcdf/test20.nc?service=wms&version=1.3.0&request=GetMap&layers=analyzed_field&bbox=-85.0,-180.0,85.0,180.0&styles=&width=640&height=480&srs=EPSG:4326&CRS=EPSG:4326&format=image/png&COLORSCALERANGE=auto";
// WmsUrlValidator validator = new WmsUrlValidator(baseGeoserverUrl, fullPath , "", false);
// logger.trace("base wms service url: "+validator.getBaseWmsServiceUrl());
// logger.trace("layer name: "+validator.getLayerName());
// logger.trace("full wms url: "+validator.getFullWmsUrlRequest(false, true));
// logger.trace("style: "+validator.getStyles());
// logger.trace("not standard parameter: "+validator.getWmsNotStandardParameters());
// String[] arrayStyle = validator.getStyles().split(",");
//
// if(arrayStyle!=null && arrayStyle.length>0){
//
// for (String style : arrayStyle) {
// if(style!=null && !style.isEmpty())
//
// System.out.println("Style: "+style.trim());
// }
// }
//
// String fullPath = "http://thredds-d-d4s.d4science.org/thredds/wms/public/netcdf/test20.nc?service=wms&version=1.3.0&request=GetMap&layers=analyzed_field&bbox=-85.0,-180.0,85.0,180.0&styles=&width=640&height=480&srs=EPSG:4326&CRS=EPSG:4326&format=image/png&COLORSCALERANGE=auto";
//
// WmsGeoExplorerUrlValidator validator = new WmsGeoExplorerUrlValidator("http://thredds-d-d4s.d4science.org/thredds/wms/public/netcdf/test20.nc", fullPath , "", false);
// validator.getFullWmsUrlRequest(false,true);
//
// System.out.println(validator.getWmsNoStandardParameters());
// System.out.println(validator.getMapWmsNoStandardParams());
// fullPath = WmsUrlValidator.setValueOfParameter(WmsParameters.STYLES, fullPath, "123", true);
//
// MapPreviewGenerator map = new MapPreviewGenerator();
// fullPath = map.buildWmsRequestMapPreview(fullPath, "-85.0,-180.0,85.0,180.0");
// System.out.println(fullPath);
String wmsRequest = "http://geoserver-dev.d4science-ii.research-infrastructures.eu/geoserver/wms?CRS=EPSG:4326&BBOX=-85.5,-180.0,90.0,180.0&VERSION=1.1.0&FORMAT=application/openlayers&SERVICE=wms&HEIGHT=330&LAYERS=aquamaps:lsoleasolea20130716162322254cest&REQUEST=GetMap&STYLES=Species_prob&SRS=EPSG:4326&WIDTH=676";
// String wmsRequest = "http://thredds-d-d4s.d4science.org/thredds/wms/public/netcdf/test20.nc?service=wms&version=1.3.0&request=GetMap&layers=analyzed_field&styles=&width=640&height=480&srs=EPSG:4326&CRS=EPSG:4326&format=image/png&COLORSCALERANGE=auto&bbox=-85.0,-180.0,85.0,180.0";
WmsUrlValidator wms;
try {
wms = new WmsUrlValidator(wmsRequest);
System.out.println("Returned wms: "+wms.toString());
}
catch (Exception e) {
e.printStackTrace();
}
}
} }

View File

@ -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); }
// */
//
//}

View File

@ -65,16 +65,4 @@ public class GeoportalServiceIdentityProxy {
public boolean isIAMClient() { public boolean isIAMClient() {
return isIAMClient; return isIAMClient;
} }
public String getDescription() {
return gCubeIdentity.getIdentityDescription();
}
public String getToken() {
return gCubeIdentity.getToken();
}
public String getIdentity() {
return gCubeIdentity.getIdentity();
}
} }

View File

@ -2,12 +2,13 @@ package org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessid
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
/** /**
* The Interface GcubeIdentity. * The Interface GcubeIdentity.
* *
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
* *
* Sep 23, 2021 * Sep 23, 2021
*/ */
public interface GcubeIdentity { public interface GcubeIdentity {
@ -24,26 +25,4 @@ public interface GcubeIdentity {
*/ */
public void resetIdentity(); public void resetIdentity();
/**
* Gets the identity description.
*
* @return the identity description
*/
public String getIdentityDescription();
/**
* Gets the identity.
*
* @return the identity
*/
public String getIdentity();
/**
* Gets the token.
*
* @return the token
*/
public String getToken();
} }

View File

@ -17,22 +17,17 @@ public class IAMClientIdentity implements GcubeIdentity {
private String previousUMAToken = null; private String previousUMAToken = null;
private String currentUMAToken = null;
private String clientId = null;
private static final String IAM_CLIENT_CREDENTIALS = "IAM_CLIENT_CREDENTIALS"; private static final String IAM_CLIENT_CREDENTIALS = "IAM_CLIENT_CREDENTIALS";
@Override @Override
public void setIdentity(HttpServletRequest httpRequest) throws Exception { public void setIdentity(HttpServletRequest httpRequest) throws Exception {
LOG.info("setIdentity called"); LOG.info("setIdentity called");
String currentScope = SessionUtil.getCurrentContext(httpRequest, true); String currentScope = SessionUtil.getCurrentContext(httpRequest, true);
LOG.info("the scope is {}", currentScope); IAMClientCredentials credentials = sessionGetIAMClientCredentials(httpRequest);
IAMClientCredentials credentials = sessionGetIAMClientCredentials(httpRequest);
try { try {
if (credentials == null) { if(credentials==null) {
credentials = IAMClientCredentialsReader.getCredentials(); credentials = IAMClientCredentialsReader.getCredentials();
sessionSetIAMClientCredentials(httpRequest, credentials); sessionSetIAMClientCredentials(httpRequest,credentials);
} }
} catch (Exception e) { } catch (Exception e) {
LOG.error("Error on discovering IAM Client credentials", e); LOG.error("Error on discovering IAM Client credentials", e);
@ -40,16 +35,16 @@ public class IAMClientIdentity implements GcubeIdentity {
} }
LOG.trace("Read credentials: " + credentials); LOG.trace("Read credentials: " + credentials);
clientId = credentials.getClientId(); String umaAcessToken = null;
String clientId = credentials.getClientId();
String clientSecret = credentials.getClientSecret(); String clientSecret = credentials.getClientSecret();
try { try {
LOG.info("Querying KeycloakClientFactory to get UMA token.."); LOG.info("Querying KeycloakClientFactory to get UMA token..");
TokenResponse tr = KeycloakClientFactory.newInstance().queryUMAToken(currentScope, clientId, clientSecret, currentScope, TokenResponse tr = KeycloakClientFactory.newInstance().queryUMAToken(clientId, clientSecret, currentScope,
null); null);
umaAcessToken = tr.getAccessToken();
currentUMAToken = tr.getAccessToken(); if (umaAcessToken != null && !umaAcessToken.isEmpty()) {
if (currentUMAToken != null && !currentUMAToken.isEmpty()) {
LOG.info("UMA Access Token read correctly"); LOG.info("UMA Access Token read correctly");
} else { } else {
LOG.error("UMA Access Token NOT RETRIEVED!!!"); LOG.error("UMA Access Token NOT RETRIEVED!!!");
@ -61,8 +56,6 @@ public class IAMClientIdentity implements GcubeIdentity {
try { try {
LOG.debug("JWT token: " + currentUMAToken.substring(0, 20) + "_MASKED_TOKEN_");
try { try {
// Here the previousUMAToken should be null // Here the previousUMAToken should be null
previousUMAToken = AccessTokenProvider.instance.get(); previousUMAToken = AccessTokenProvider.instance.get();
@ -71,9 +64,10 @@ public class IAMClientIdentity implements GcubeIdentity {
// silent // silent
} }
LOG.debug("JWT token: " + umaAcessToken.substring(0, 20) + "_MASKED_TOKEN_");
LOG.info("Setting clientId '" + clientId + "' identity by JWT token in the " LOG.info("Setting clientId '" + clientId + "' identity by JWT token in the "
+ AccessTokenProvider.class.getSimpleName()); + AccessTokenProvider.class.getSimpleName());
AccessTokenProvider.instance.set(currentUMAToken); AccessTokenProvider.instance.set(umaAcessToken);
} catch (Exception e) { } catch (Exception e) {
LOG.error(e.getMessage(), e); LOG.error(e.getMessage(), e);
throw new Exception(e.getMessage()); throw new Exception(e.getMessage());
@ -81,11 +75,6 @@ public class IAMClientIdentity implements GcubeIdentity {
} }
@Override
public String getToken() {
return currentUMAToken;
}
@Override @Override
public void resetIdentity() { public void resetIdentity() {
LOG.info("resetIdentity called"); LOG.info("resetIdentity called");
@ -114,7 +103,7 @@ public class IAMClientIdentity implements GcubeIdentity {
* Sets the IAM client credentials. * Sets the IAM client credentials.
* *
* @param httpRequest the http request * @param httpRequest the http request
* @param iamCC the iam CC * @param iamCC the iam CC
*/ */
public static void sessionSetIAMClientCredentials(HttpServletRequest httpRequest, IAMClientCredentials iamCC) { public static void sessionSetIAMClientCredentials(HttpServletRequest httpRequest, IAMClientCredentials iamCC) {
HttpSession session = httpRequest.getSession(); HttpSession session = httpRequest.getSession();
@ -125,15 +114,4 @@ public class IAMClientIdentity implements GcubeIdentity {
} }
} }
@Override
public String getIdentityDescription() {
return "ClientId: " + clientId;
}
@Override
public String getIdentity() {
return clientId;
}
} }

View File

@ -3,7 +3,6 @@ package org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessid
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.gcube.portlets.user.geoportaldataviewer.server.util.SessionUtil; import org.gcube.portlets.user.geoportaldataviewer.server.util.SessionUtil;
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -11,19 +10,13 @@ public class UserIdentity implements GcubeIdentity {
private static final Logger LOG = LoggerFactory.getLogger(UserIdentity.class); private static final Logger LOG = LoggerFactory.getLogger(UserIdentity.class);
private HttpServletRequest httpRequest;
private GCubeUser user;
public UserIdentity() { public UserIdentity() {
} }
@Override @Override
public void setIdentity(HttpServletRequest httpRequest) throws Exception { public void setIdentity(HttpServletRequest httpRequest) throws Exception {
LOG.info("setIdentity called"); LOG.info("setIdentity called");
this.httpRequest = httpRequest; SessionUtil.getCurrentToken(httpRequest, true);
SessionUtil.getCurrentToken(this.httpRequest, true);
user = SessionUtil.getCurrentUser(this.httpRequest);
} }
@ -32,20 +25,4 @@ public class UserIdentity implements GcubeIdentity {
LOG.info("resetIdentity called, doing nothing"); LOG.info("resetIdentity called, doing nothing");
// doing nothing // doing nothing
} }
@Override
public String getToken() {
return SessionUtil.getCurrentToken(this.httpRequest, true);
}
@Override
public String getIdentityDescription() {
return user != null ? "user: " + user.getUsername() : "null";
}
@Override
public String getIdentity() {
return user.getUsername();
}
} }

View File

@ -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;
}
}

View File

@ -1,69 +0,0 @@
package org.gcube.portlets.user.geoportaldataviewer.server.util;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import org.gcube.portlets.user.geoportaldataviewer.server.GeoportalDataViewerServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class HTTPRequestUtil.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jun 5, 2023
*/
public class HTTPRequestUtil {
private static final Logger LOG = LoggerFactory.getLogger(GeoportalDataViewerServiceImpl.class);
/**
* Gets the response.
*
* @param url the url
* @return the response
*/
public static String getResponse(String url) {
if (url == null || url.isEmpty())
return null;
StringBuffer response = new StringBuffer();
String theResponseString = "";
HttpURLConnection con = null;
LOG.debug("Calling URL: " + url);
try {
URL obj = new URL(url);
con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
int responseCode = con.getResponseCode();
LOG.debug("GET Response Code: " + responseCode);
if (responseCode == HttpURLConnection.HTTP_OK) { // success
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
} else {
LOG.info("GET request did not work.");
}
theResponseString = response.toString();
// LOG.trace(theResponseString);
if (LOG.isDebugEnabled()) {
LOG.debug("getResponse is empty? " + theResponseString.isEmpty());
}
} catch (Exception e) {
LOG.error("Error on performing the request to URL: " + url, e);
} finally {
}
LOG.debug("returning response with size: " + theResponseString.length());
return theResponseString;
}
}

View File

@ -3,9 +3,7 @@
*/ */
package org.gcube.portlets.user.geoportaldataviewer.server.util; package org.gcube.portlets.user.geoportaldataviewer.server.util;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
@ -53,10 +51,6 @@ public class SessionUtil {
private static final String COUNT_DOCS_FOR_PROFILE_ID = "GNA_DATAVIEWER_COUNT_DOCS_FOR_PROFILE_ID"; private static final String COUNT_DOCS_FOR_PROFILE_ID = "GNA_DATAVIEWER_COUNT_DOCS_FOR_PROFILE_ID";
private static final String UCD_COLLECTIONS_SESSION = "THE_UCD_COLLECTIONS";
private static final String CHECKED_CONFIG_FOR_PDF_EXPORTER = "CHECKED_CONFIG_FOR_PDF_EXPORTER";
/** /**
* Checks if is into portal. * Checks if is into portal.
* *
@ -142,7 +136,7 @@ public class SessionUtil {
if (token != null) { if (token != null) {
LOG.debug("Returning token " + token.substring(1, 10) + "_MASKED_TOKEN_"); LOG.debug("Returning token " + token.substring(1, 10) + "_MASKED_TOKEN_");
if (setInThread) if(setInThread)
SecurityTokenProvider.instance.set(token); SecurityTokenProvider.instance.set(token);
} }
@ -279,6 +273,33 @@ public class SessionUtil {
HttpSession session = httpServletRequest.getSession(); HttpSession session = httpServletRequest.getSession();
List<Concessione> listOfConcessioni = (List<Concessione>) session.getAttribute(LIST_OF_CONCESSIONI); List<Concessione> listOfConcessioni = (List<Concessione>) session.getAttribute(LIST_OF_CONCESSIONI);
throw new Exception("getListConcessioni must be revisited!!!!"); throw new Exception("getListConcessioni must be revisited!!!!");
/*
* // setting null to force reloading from service if (reloadFromService)
* listOfConcessioni = null;
*
* if (listOfConcessioni == null) { listOfConcessioni = new
* ArrayList<Concessione>();
* LOG.info("Loading list of concessione from client mongo");
* SessionUtil.getCurrentContext(httpServletRequest, true); MongoServiceCommon
* serviceUtil = new MongoServiceCommon(); MongoConcessioni clientMongo =
* serviceUtil.getInstanceMongoConcessioni();
*
* Iterator<Concessione> concessioni = clientMongo.getList(); if (concessioni !=
* null) { while (concessioni.hasNext()) { Concessione concessione =
* (Concessione) concessioni.next(); listOfConcessioni.add(concessione);
*
* } } // LOG.debug("Got list of concessioni from client mongo: " +
* listOfConcessioni); session.setAttribute(LIST_OF_CONCESSIONI,
* listOfConcessioni);
* LOG.info("Saved in session list of concessioni from client mongo with size: "
* + listOfConcessioni.size());
*
* } else LOG.info("list of concessioni presents in session, using it");
*
* LOG.info("read list of concessioni with size: " + listOfConcessioni.size());
* return listOfConcessioni;
*
*/
} }
/** /**
@ -331,30 +352,4 @@ public class SessionUtil {
} }
public static void addCollectionToSession(HttpServletRequest httpServletRequest, UseCaseDescriptor u) {
HttpSession session = httpServletRequest.getSession();
Map<String, UseCaseDescriptor> ucds = (Map<String, UseCaseDescriptor>) session
.getAttribute(UCD_COLLECTIONS_SESSION);
if (ucds == null) {
ucds = new HashMap<String, UseCaseDescriptor>();
}
ucds.put(u.getId(), u);
session.setAttribute(UCD_COLLECTIONS_SESSION, ucds);
}
public static Map<String, UseCaseDescriptor> getAvailableCollections(HttpServletRequest httpServletRequest) {
HttpSession session = httpServletRequest.getSession();
return (Map<String, UseCaseDescriptor>) session.getAttribute(UCD_COLLECTIONS_SESSION);
}
public static Boolean getCheckConfigForPFDExporter(HttpServletRequest httpServletRequest) {
HttpSession session = httpServletRequest.getSession();
return (Boolean) session.getAttribute(CHECKED_CONFIG_FOR_PDF_EXPORTER);
}
public static void setCheckConfigForPFDExporter(HttpServletRequest httpServletRequest, Boolean configChecked) {
HttpSession session = httpServletRequest.getSession();
session.setAttribute(CHECKED_CONFIG_FOR_PDF_EXPORTER, configChecked);
}
} }

View File

@ -3,7 +3,7 @@ package org.gcube.portlets.user.geoportaldataviewer.server.util;
import java.util.Comparator; import java.util.Comparator;
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV; import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoportalSpatialQueryResult; import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult;
/** /**
* The Class TemporalComparatorUtil. * The Class TemporalComparatorUtil.
@ -12,7 +12,7 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.GeoportalSpatialQueryR
* *
* Nov 18, 2022 * Nov 18, 2022
*/ */
public class TemporalComparatorUtil implements Comparator<GeoportalSpatialQueryResult> { public class TemporalComparatorUtil implements Comparator<GeoNaSpatialQueryResult> {
/** /**
* Compare. * Compare.
@ -22,7 +22,7 @@ public class TemporalComparatorUtil implements Comparator<GeoportalSpatialQueryR
* @return the int * @return the int
*/ */
@Override @Override
public int compare(GeoportalSpatialQueryResult a, GeoportalSpatialQueryResult b) { public int compare(GeoNaSpatialQueryResult a, GeoNaSpatialQueryResult b) {
if (a == null || a.getSourceLayerObject() == null || a.getSourceLayerObject().getProjectDV() == null) { if (a == null || a.getSourceLayerObject() == null || a.getSourceLayerObject().getProjectDV() == null) {
return -1; return -1;
} }

View File

@ -9,7 +9,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
* The Class URLParserUtil. * The Class URLUtil.
* *
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* *

View File

@ -9,13 +9,13 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.FeatureRow; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.FeatureRow;
/** /**
* The Class GeoportalSpatialQueryResult. * 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
* *
* Jul 30, 2021 * Jul 30, 2021
*/ */
public class GeoportalSpatialQueryResult implements Serializable { public class GeoNaSpatialQueryResult implements Serializable {
/** /**
* *
@ -23,17 +23,27 @@ public class GeoportalSpatialQueryResult implements Serializable {
private static final long serialVersionUID = 3513120677727206958L; private static final long serialVersionUID = 3513120677727206958L;
private List<FeatureRow> features; private List<FeatureRow> features;
private LayerObject sourceLayerObject; private LayerObject sourceLayerObject;
// Map with couple (mongoId project, list of uploaded GeoportalImages for the // Map with couple (mongoId concessione, list of uploaded GNAImages for the
// project) // concessione)
private Map<String, List<PayloadDV>> mapImages = null; private Map<String, List<PayloadDV>> mapImages = null;
// private ProjectDV projectDV;
/** /**
* Instantiates a new geo na data object. * Instantiates a new geo na data object.
*/ */
public GeoportalSpatialQueryResult() { public GeoNaSpatialQueryResult() {
} }
// public void setProjectDV(ProjectDV projectDV) {
// this.projectDV = projectDV;
//
// }
//
// public ProjectDV getProjectDV() {
// return projectDV;
// }
/** /**
* Gets the features. * Gets the features.
* *
@ -91,7 +101,7 @@ public class GeoportalSpatialQueryResult implements Serializable {
@Override @Override
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("GeoportalSpatialQueryResult [features="); builder.append("GeoNaSpatialQueryResult [features=");
builder.append(features); builder.append(features);
builder.append(", sourceLayerObject="); builder.append(", sourceLayerObject=");
builder.append(sourceLayerObject); builder.append(sourceLayerObject);

View File

@ -0,0 +1,131 @@
package org.gcube.portlets.user.geoportaldataviewer.shared;
import java.util.ArrayList;
import java.util.List;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.FilesetDV;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.PayloadDV;
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.CategoryWrapper;
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean;
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetadataFieldWrapper;
/**
* The Class MetaDataProfileBeanExt.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Nov 23, 2022
*/
public class MetaDataProfileBeanExt extends MetaDataProfileBean implements Cloneable {
/**
*
*/
private static final long serialVersionUID = 2518128223147908835L;
private List<FilesetDV> listFileset = null;
/**
* Instantiates a new meta data profile bean ext.
*/
public MetaDataProfileBeanExt() {
super();
}
/**
* Instantiates a new meta data profile bean ext.
*
* @param type the type
* @param title the title
* @param metadataFields the metadata fields
* @param categories the categories
*/
public MetaDataProfileBeanExt(String type, String title, List<MetadataFieldWrapper> metadataFields,
List<CategoryWrapper> categories) {
super(type, title, metadataFields, categories);
}
/**
* Gets the list fileset.
*
* @return the list fileset
*/
public List<FilesetDV> getListFileset() {
if (listFileset == null)
listFileset = new ArrayList<FilesetDV>();
return listFileset;
}
/**
* Sets the list fileset.
*
* @param listFileset the new list fileset
*/
public void setListFileset(List<FilesetDV> listFileset) {
this.listFileset = listFileset;
}
@Override
protected MetaDataProfileBeanExt clone() throws CloneNotSupportedException {
MetaDataProfileBeanExt clonedMDPBE = new MetaDataProfileBeanExt();
clonedMDPBE.setTitle(this.getTitle());
clonedMDPBE.setType(this.getType());
ArrayList<FilesetDV> newListFileset = new ArrayList<FilesetDV>();
for (FilesetDV filesetDV : this.getListFileset()) {
FilesetDV newFileset = new FilesetDV();
for (PayloadDV payloadDV : filesetDV.getListPayload()) {
PayloadDV newPayloadDV = new PayloadDV();
newPayloadDV.setLink(payloadDV.getLink());
newPayloadDV.setMimetype(payloadDV.getMimetype());
newPayloadDV.setName(payloadDV.getName());
newPayloadDV.setStorageID(payloadDV.getStorageID());
newFileset.addPayloadDV(newPayloadDV);
}
newListFileset.add(newFileset);
}
clonedMDPBE.setListFileset(newListFileset);
ArrayList<MetadataFieldWrapper> newListMetadataFieldWrapper = new ArrayList<MetadataFieldWrapper>();
for (MetadataFieldWrapper mfw : this.getMetadataFields()) {
MetadataFieldWrapper newMfw = new MetadataFieldWrapper();
newMfw.setAsGroup(mfw.getAsGroup());
newMfw.setAsTag(mfw.getAsTag());
newMfw.setCurrentValue(mfw.getCurrentValue());
newMfw.setDefaultValue(mfw.getDefaultValue());
newMfw.setFieldId(mfw.getFieldId());
newMfw.setFieldName(mfw.getFieldName());
newMfw.setFieldNameFromCategory(mfw.getFieldNameFromCategory());
newMfw.setMandatory(mfw.getMandatory());
newMfw.setMaxOccurs(mfw.getMaxOccurs());
newMfw.setMultiSelection(mfw.isMultiSelection());
newMfw.setNote(mfw.getNote());
newMfw.setOwnerCategory(mfw.getOwnerCategory());
newMfw.setType(mfw.getType());
newMfw.setValidator(mfw.getValidator());
newMfw.setVocabulary(mfw.getVocabulary());
newListMetadataFieldWrapper.add(newMfw);
}
clonedMDPBE.setMetadataFields(newListMetadataFieldWrapper);
return clonedMDPBE;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("MetaDataProfileBeanExt [getType()=");
builder.append(getType());
builder.append(", getTitle()=");
builder.append(getTitle());
builder.append(", getMetadataFields()=");
builder.append(getMetadataFields());
builder.append("]");
return builder.toString();
}
}

View File

@ -0,0 +1,50 @@
package org.gcube.portlets.user.geoportaldataviewer.shared;
import java.io.Serializable;
import java.util.List;
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
public class ProjectEdit implements Serializable {
/**
*
*/
private static final long serialVersionUID = 2885327516680245601L;
private ProjectDV theProjectDV;
private List<MetaDataProfileBeanExt> theProfileBeans;
public ProjectEdit() {
}
public ProjectDV getTheProjectDV() {
return theProjectDV;
}
public List<MetaDataProfileBeanExt> getTheProfileBeans() {
return theProfileBeans;
}
public void setTheProjectDV(ProjectDV theProjectDV) {
this.theProjectDV = theProjectDV;
}
public void setTheProfileBeans(List<MetaDataProfileBeanExt> theProfileBeans) {
this.theProfileBeans = theProfileBeans;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("ProjectEdit [theProjectDV=");
builder.append(theProjectDV);
builder.append(", theProfileBeans=");
builder.append(theProfileBeans);
builder.append("]");
return builder.toString();
}
}

View File

@ -2,13 +2,18 @@ package org.gcube.portlets.user.geoportaldataviewer.shared.gis;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.gcube.application.geoportalcommon.shared.gis.BoundsMap; import org.gcube.application.geoportalcommon.shared.gis.BoundsMap;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.LayerType;
import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.Property; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.Property;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.ZAxis; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.ZAxis;
import com.google.gwt.core.client.GWT;
/** /**
* The Class LayerItem. * The Class LayerItem.
* *
@ -18,6 +23,7 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.ZAxis;
*/ */
public class LayerItem implements Serializable, Cloneable { public class LayerItem implements Serializable, Cloneable {
/** The Constant serialVersionUID. */ /** The Constant serialVersionUID. */
private static final long serialVersionUID = 1664082688635256899L; private static final long serialVersionUID = 1664082688635256899L;
@ -31,7 +37,7 @@ public class LayerItem implements Serializable, Cloneable {
private String url; private String url;
/** The base map server URL. */ /** The base map server URL. */
private String mapServerEndpoint; private String mapServerHost;
/** The style. */ /** The style. */
private String style; private String style;
@ -96,6 +102,9 @@ public class LayerItem implements Serializable, Cloneable {
/** The server wms request. */ /** The server wms request. */
public String wmsLink; public String wmsLink;
/** The cql filter available. */
private boolean cqlFilterAvailable = false;
/** The uuid. */ /** The uuid. */
private String UUID; private String UUID;
@ -747,7 +756,16 @@ public class LayerItem implements Serializable, Cloneable {
* @return true, if is cql filter available * @return true, if is cql filter available
*/ */
public boolean isCqlFilterAvailable() { public boolean isCqlFilterAvailable() {
return (cqlFilter != null) && (!cqlFilter.isEmpty()); return cqlFilterAvailable;
}
/**
* Sets the cql filter available.
*
* @param cqlFilterAvailable the new cql filter available
*/
public void setCqlFilterAvailable(boolean cqlFilterAvailable) {
this.cqlFilterAvailable = cqlFilterAvailable;
} }
/** /**
@ -769,21 +787,21 @@ public class LayerItem implements Serializable, Cloneable {
} }
/** /**
* Gets the map server endpoint. * Gets the map server host.
* *
* @return the map server endpoint * @return the map server host
*/ */
public String getMapServerEndpoint() { public String getMapServerHost() {
return mapServerEndpoint; return mapServerHost;
} }
/** /**
* Sets the map server host. * Sets the map server host.
* *
* @param mapServerEndpoint the new map server host * @param mapServerHost the new map server host
*/ */
public void setMapServerHost(String mapServerEndpoint) { public void setMapServerHost(String mapServerHost) {
this.mapServerEndpoint = mapServerEndpoint; this.mapServerHost = mapServerHost;
} }
/** /**
@ -890,8 +908,8 @@ public class LayerItem implements Serializable, Cloneable {
builder.append(title); builder.append(title);
builder.append(", url="); builder.append(", url=");
builder.append(url); builder.append(url);
builder.append(", mapServerEndpoint="); builder.append(", mapServerHost=");
builder.append(mapServerEndpoint); builder.append(mapServerHost);
builder.append(", style="); builder.append(", style=");
builder.append(style); builder.append(style);
builder.append(", isTrasparent="); builder.append(", isTrasparent=");
@ -934,6 +952,8 @@ public class LayerItem implements Serializable, Cloneable {
builder.append(isNcWms); builder.append(isNcWms);
builder.append(", wmsLink="); builder.append(", wmsLink=");
builder.append(wmsLink); builder.append(wmsLink);
builder.append(", cqlFilterAvailable=");
builder.append(cqlFilterAvailable);
builder.append(", UUID="); builder.append(", UUID=");
builder.append(UUID); builder.append(UUID);
builder.append(", zAxis="); builder.append(", zAxis=");
@ -948,4 +968,92 @@ public class LayerItem implements Serializable, Cloneable {
return builder.toString(); return builder.toString();
} }
/**
* 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 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 minResolution the min resolution
* @param maxResolution the max resolution
* @return the layer item
*/
// TODO Constructor from IndexLayerDV, GCUBESDILAeryDV or direct info
private LayerItem toLayerItem(LayerType layerType, String layerTitle, String layerName, String layerURL,
String mapServerHost, boolean isExternal, boolean isBase, boolean displayInLayerSwitcher,
ArrayList<String> styles, String wmsLink, boolean onTop, HashMap<String, String> wmsNotStandardParams,
boolean isNcWms, String UUID, ZAxis zAxis, Double minResolution, Double maxResolution) {
// GWT.log("Add addLayerByWms 1");
LayerItem layerItem = new LayerItem();
layerItem.setBaseLayer(isBase);
layerItem.setTitle(layerTitle);
layerItem.setName(layerName);
layerItem.setUrl(layerURL);
layerItem.setMapServerHost(mapServerHost);
// l.setExternal(isExternal);
layerItem.setOpacity(1d);
layerItem.setBuffer(2);
layerItem.setWmsLink(wmsLink);
layerItem.setWmsNotStandardParams(wmsNotStandardParams);
layerItem.setNcWms(isNcWms);
layerItem.setUUID(UUID);
layerItem.setZAxis(zAxis);
layerItem.setMinResolution(minResolution);
layerItem.setMaxResolution(maxResolution);
switch (layerType) {
// TODO IMPLEMENT THIS CASE
case RASTER_BASELAYER:
// l.setHasLegend(false);
layerItem.setBaseLayer(true);
layerItem.setTrasparent(false);
layerItem.setClickData(false);
break;
case FEATURE_TYPE:
// CASE FEATURE TYPE
layerItem.setBaseLayer(false);
layerItem.setClickData(true);
layerItem.setTrasparent(true);
break;
}
GWT.log("styles " + styles);
if (styles != null && styles.size() > 0) {
layerItem.setHasLegend(true);
layerItem.setDefaultStyle(styles.get(0));
layerItem.setStyle(styles.get(0));
layerItem.setStyles(styles);
} else {
String style = URLUtil.getValueOfParameter("styles", wmsLink);
if (style != null) { // CASE OF STYLE ="";
// TENTATIVE TO GET LEGEND
layerItem.setHasLegend(true);
}
}
GWT.log("Built layer: " + layerItem);
return layerItem;
}
} }

View File

@ -8,14 +8,15 @@ import java.util.HashMap;
* *
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* *
* Oct 27, 2020 * Oct 27, 2020
*/ */
public class GeoInformationForWMSRequest implements Serializable { public class GeoInformationForWMSRequest implements Serializable {
/** The Constant serialVersionUID. */ /** The Constant serialVersionUID. */
private static final long serialVersionUID = -6846636281073641003L; private static final long serialVersionUID = -6846636281073641003L;
private String serviceEndPoint; /** The base wms service host. */
private String baseWmsServiceHost;
/** The wms request. */ /** The wms request. */
private String wmsRequest; private String wmsRequest;
@ -52,19 +53,20 @@ public class GeoInformationForWMSRequest implements Serializable {
/** /**
* Instantiates a new geo information for wms request. * Instantiates a new geo information for wms request.
* *
* @param serviceEndPoint the base wms service host * @param baseWmsServiceHost the base wms service host
* @param wmsRequest the wms request * @param wmsRequest the wms request
* @param layerName the layer name * @param layerName the layer name
* @param versionWms the version wms * @param versionWms the version wms
* @param crs the crs * @param crs the crs
* @param mapWmsNoStandard the map wms not standard * @param mapWmsNoStandard the map wms not standard
* @param styles the layer styles * @param styles the layer styles
* @param isNcWMS the is nc WMS * @param isNcWMS the is nc WMS
* @param zAxis the z axis * @param zAxis the z axis
*/ */
public GeoInformationForWMSRequest(String serviceEndPoint, String wmsRequest, String layerName, String versionWms, public GeoInformationForWMSRequest(String baseWmsServiceHost, String wmsRequest, String layerName,
String crs, HashMap<String, String> mapWmsNoStandard, Styles styles, boolean isNcWMS, ZAxis zAxis) { String versionWms, String crs, HashMap<String, String> mapWmsNoStandard, Styles styles, boolean isNcWMS,
this.serviceEndPoint = serviceEndPoint; ZAxis zAxis) {
this.baseWmsServiceHost = baseWmsServiceHost;
this.wmsRequest = wmsRequest; this.wmsRequest = wmsRequest;
this.layerName = layerName; this.layerName = layerName;
this.versionWMS = versionWms; this.versionWMS = versionWms;
@ -96,21 +98,13 @@ public class GeoInformationForWMSRequest implements Serializable {
} }
/** /**
* Gets the service end point. * Gets the base wms service host.
* *
* @return the service end point * @return the baseWmsServiceHost
*/ */
public String getServiceEndPoint() { public String getBaseWmsServiceHost() {
return serviceEndPoint;
}
/** return baseWmsServiceHost;
* Sets the service end point.
*
* @param serviceEndPoint the new service end point
*/
public void setServiceEndPoint(String serviceEndPoint) {
this.serviceEndPoint = serviceEndPoint;
} }
/** /**
@ -186,11 +180,11 @@ public class GeoInformationForWMSRequest implements Serializable {
/** /**
* Sets the base wms service host. * Sets the base wms service host.
* *
* @param baseWmsServiceHost the new base wms service host * @param baseWmsServiceHost the baseWmsServiceHost to set
*/ */
public void setBaseWmsServiceHost(String baseWmsServiceHost) { public void setBaseWmsServiceHost(String baseWmsServiceHost) {
this.serviceEndPoint = baseWmsServiceHost; this.baseWmsServiceHost = baseWmsServiceHost;
} }
/** /**
@ -277,8 +271,8 @@ public class GeoInformationForWMSRequest implements Serializable {
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("GeoInformationForWMSRequest [serviceEndPoint="); builder.append("GeoInformationForWMSRequest [baseWmsServiceHost=");
builder.append(serviceEndPoint); builder.append(baseWmsServiceHost);
builder.append(", wmsRequest="); builder.append(", wmsRequest=");
builder.append(wmsRequest); builder.append(wmsRequest);
builder.append(", layerName="); builder.append(", layerName=");

View File

@ -17,17 +17,11 @@
<inherits name="com.google.gwt.json.JSON" /> <inherits name="com.google.gwt.json.JSON" />
<inherits
name='org.gcube.portal.clientcontext.GCubeClientContext' />
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> --> <!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> --> <!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
<!-- Other module inherits --> <!-- Other module inherits -->
<servlet path="/geoportalexporterservice"
class="org.gcube.portlets.user.geoportaldataviewer.server.GeoportalExporterActionServlet" />
<!-- Specify the app entry point class. --> <!-- Specify the app entry point class. -->
<entry-point <entry-point
class='org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewer' /> class='org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewer' />

View File

@ -26,7 +26,7 @@ body {
background-color: white; background-color: white;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
padding: 10px; padding: 10px;
border-radius: 10px; border-radius: 2px;
border: 1px solid #cccccc; border: 1px solid #cccccc;
bottom: 12px; bottom: 12px;
left: -50px; left: -50px;
@ -34,16 +34,11 @@ body {
max-width: 500px; max-width: 500px;
visibility: hidden; visibility: hidden;
padding-top: 20px; padding-top: 20px;
opacity: 0.9;
}
.ol-popup #pop-img {
max-height: 130px;
overflow-y: scroll;
} }
.ol-popup img { .ol-popup img {
width: 100%; width: 100%;
max-height: 200px;
} }
.ol-popup:after, .ol-popup:before { .ol-popup:after, .ol-popup:before {
@ -158,11 +153,6 @@ body {
padding-top: 1px; padding-top: 1px;
} }
.preset-location ul a {
margin: 5px !important;
}
.my-control-group .controls { .my-control-group .controls {
margin-left: 70px !important; margin-left: 70px !important;
} }
@ -200,7 +190,7 @@ body {
/*margin-top: 30px;*/ /*margin-top: 30px;*/
overflow-y: auto; overflow-y: auto;
transition: width 0.5s; transition: width 0.5s;
z-index: 950; z-index: 999;
} }
.overlay { .overlay {
@ -216,7 +206,7 @@ body {
} }
.inner-toolbar .btn-group { .inner-toolbar .btn-group {
margin-left: 2px !important; margin-left: 0px !important;
} }
.inner-toolbar .btn-link { .inner-toolbar .btn-link {
@ -363,16 +353,12 @@ body {
border-radius: 20px; border-radius: 20px;
} }
.layer-panel { .layers-panel {
margin-top: 43px; margin-top: 10px;
background-color: white; background-color: white;
opacity: 90%; opacity: 90%;
padding: 10px; padding: 10px;
max-width: 430px; width: 410px;
z-index: 500;
overflow-y: auto;
position: absolute;
left: 52px;
} }
.dand-layer { .dand-layer {
@ -435,7 +421,6 @@ body {
.map-layers-radio label { .map-layers-radio label {
margin-left: 5px; margin-left: 5px;
padding-top: 5px; padding-top: 5px;
font-weight: bold;
} }
@ -756,104 +741,6 @@ Table Of Contents (TOC)
padding: 20px; padding: 20px;
} }
/* OPEN COLLECTION UI */
.open-collection-style {
padding-left: 10px;
padding-right: 10px;
}
.open-collection-style > div {
border: 1px solid #ccc !important;
border-radius: 5px;
padding: 10px;
margin-bottom: 10px;
margin-top: 5px;
}
.layer-style-panel {
margin-left: 25px;
font-size: 13px;
color: gray;
}
.statistic-style-panel {
margin-left: 25px;
font-size: 13px;
color: gray;
font-weight: bold;
margin-top: -3px;
}
.layer-style-panel-table-legend table td {
padding-left: 5px;
}
/* CUSTOM OVERLAY UI */
.overlay-panel-style {
padding-left: 10px;
padding-right: 10px;
max-width: 350px;
}
.overlay-panel-style-description {
border: none !important;
white-space: pre-line;
padding: 10px 0px;
font-style: italic;
}
.overlay-panel-style > div {
border: 1px solid #ccc;
border-radius: 5px;
padding: 10px;
margin-bottom: 10px;
margin-top: 5px;
}
/* FILTER PANEL UI */
.filter-panel-style {
padding-left: 10px;
padding-right: 10px;
max-width: 350px;
}
.filter-panel-style .control-group {
margin-bottom: 5px !important;
}
.filter-panel-style select {
min-width: 310px;
}
.filter-panel-style-description {
border: none !important;
white-space: pre-line;
padding: 10px 0px;
font-style: italic;
}
.filter-panel-style > div {
border: 1px solid #ccc;
border-radius: 5px;
padding: 10px;
margin-bottom: 10px;
margin-top: 5px;
}
.filter-panel-style a {
float: right;
}
.filter-panel-style label {
font-weight: bold;
}
/* END CUSTOM OVERLAY UI */
.opacity-09 {
opacity: 0.9;
}
/****************************** /******************************
RESPONSIVE RESPONSIVE
@ -874,37 +761,10 @@ RESPONSIVE
} }
.details-panel { .details-panel {
width: 530px; width: 600px;
} }
} }
@media all and (max-width: 1601px) {
.layers-panel {
width: 350px;
}
.dand-layer {
width: 336px;
}
.thePopDataTable {
}
.search-facility {
max-width: 680px;
}
.search-field {
width: 97%;
}
.ol-popup {
min-width: 220px;
width: 220px;
}
.thePopDataTable tr:last-of-type {
display: none;
}
.layer-panel {
width: 355px;
}
}
@media all and (max-width: 1024px) { @media all and (max-width: 1024px) {
#timeline-data { #timeline-data {
width: 260px; width: 260px;
@ -915,27 +775,34 @@ RESPONSIVE
width: 400px; width: 400px;
} }
.search-facility { .search-facility {
/*width: 250px; width: 250px;
max-width: 300px;*/ max-width: 300px;
} }
.inner-toolbar { .inner-toolbar {
/*width: 100px;*/ width: 100px;
} }
} }
@media all and (max-height: 900px) { /* OPEN COLLECTION UI */
.ol-popup{ .open-collection-style {
min-width: 150px; padding-left: 10px;
max-width: 150px; padding-right: 10px;
max-height: 150px;
overflow-y: scroll;
}
.ol-popup img {
width: 100%;
max-width: 150px;
}
} }
/****************************** .open-collection-style > div {
END RESPONSIVE border: 1px solid #ccc !important;
*******************************/ border-radius: 5px;
padding: 10px;
margin-bottom: 10px;
margin-top: 5px;
}
.layer-style-panel {
margin-left: 25px;
font-size: 13px;
color: gray;
}
.layer-style-panel-table-legend table td {
padding-left: 5px;
}

View File

@ -10,10 +10,10 @@
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> <meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link <link
href="//cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@main/dist/en/v6.6.1/css/ol.css" href="//cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@main/dist/en/v6.4.3/css/ol.css"
rel="stylesheet" type="text/css"> rel="stylesheet" type="text/css">
<script <script
src="//cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@main/dist/en/v6.6.1/build/ol.js" src="//cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@main/dist/en/v6.4.3/build/ol.js"
type="text/javascript"></script> type="text/javascript"></script>
<link <link
@ -138,7 +138,6 @@
application to display correctly.</div> application to display correctly.</div>
</noscript> </noscript>
<div id="app-notifier" class="app-notifier"></div> <div id="app-notifier" class="app-notifier"></div>
<div id="layer-viewer" class="layer-panel"></div>
<div id="geoportal-data-viewer"></div> <div id="geoportal-data-viewer"></div>
<div class="timeline-container"> <div class="timeline-container">
<div id="timeline-data"></div> <div id="timeline-data"></div>

View File

@ -15,11 +15,11 @@
src='<%=request.getContextPath()%>/GeoportalDataViewer/js/bootstrap.min.js'></script> src='<%=request.getContextPath()%>/GeoportalDataViewer/js/bootstrap.min.js'></script>
<link <link
href="//cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@main/dist/en/v6.6.1/css/ol.css" href="//cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@main/dist/en/v6.4.3/css/ol.css"
rel="stylesheet" type="text/css"> rel="stylesheet" type="text/css">
<script <script
src="//cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@main/dist/en/v6.6.1/build/ol.js" src="//cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@main/dist/en/v6.4.3/build/ol.js"
type="text/javascript"></script> type="text/javascript"></script>
<link <link
@ -111,7 +111,6 @@
</script> </script>
<div id="app-notifier" class="app-notifier"></div> <div id="app-notifier" class="app-notifier"></div>
<div id="layer-viewer" class="layer-panel"></div>
<div id="geoportal-data-viewer"></div> <div id="geoportal-data-viewer"></div>
<div class="timeline-container"> <div class="timeline-container">
<div id="timeline-data"></div> <div id="timeline-data"></div>

View File

@ -16,16 +16,6 @@
<servlet-class>org.gcube.portlets.user.geoportaldataviewer.server.GeoportalDataViewerServiceImpl</servlet-class> <servlet-class>org.gcube.portlets.user.geoportaldataviewer.server.GeoportalDataViewerServiceImpl</servlet-class>
</servlet> </servlet>
<!-- <servlet> -->
<!-- <servlet-name>geoportalWaitingServerActionServlet</servlet-name> -->
<!-- <servlet-class>org.gcube.portlets.user.geoportaldataviewer.server.WatingServerActionServlet</servlet-class> -->
<!-- </servlet> -->
<servlet>
<servlet-name>geoportalExporterServerActionServlet</servlet-name>
<servlet-class>org.gcube.portlets.user.geoportaldataviewer.server.GeoportalExporterActionServlet</servlet-class>
</servlet>
<servlet> <servlet>
<servlet-name>mpformbuilderServlet</servlet-name> <servlet-name>mpformbuilderServlet</servlet-name>
<servlet-class>org.gcube.portlets.widgets.mpformbuilder.server.MetadataProfileFormBuilderServiceImpl</servlet-class> <servlet-class>org.gcube.portlets.widgets.mpformbuilder.server.MetadataProfileFormBuilderServiceImpl</servlet-class>
@ -42,14 +32,4 @@
<url-pattern>/GeoportalDataViewer/geoportaldataviewerservice</url-pattern> <url-pattern>/GeoportalDataViewer/geoportaldataviewerservice</url-pattern>
</servlet-mapping> </servlet-mapping>
<!-- <servlet-mapping> -->
<!-- <servlet-name>geoportalWaitingServerActionServlet</servlet-name> -->
<!-- <url-pattern>/GeoportalDataViewer/geoportaldataviewerwaitingservice</url-pattern> -->
<!-- </servlet-mapping> -->
<servlet-mapping>
<servlet-name>geoportalExporterServerActionServlet</servlet-name>
<url-pattern>/GeoportalDataViewer/geoportalexporterservice</url-pattern>
</servlet-mapping>
</web-app> </web-app>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -1,42 +0,0 @@
/**
*
*/
package org.gcube.portlets.user.geoportaldataviewer;
import java.io.IOException;
import java.io.InputStream;
import org.apache.commons.io.IOUtils;
import org.gcube.portlets.user.geoportaldataviewer.server.GeoportalExporterActionServlet;
/**
* The Class GeoportalExporterActionServletTest.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Apr 24, 2024
*/
public class GeoportalExporterActionServletTest {
/**
* The main method.
*
* @param args the arguments
*/
public static void main(String[] args) {
String url = "https://data.dev.d4science.org/geoportal/export/pdf/profiledConcessioni/661d2c6f8804530afb90b132";
String identity = "francesco.mangiacrapa";
String token = "";
System.out.println("Start");
InputStream response;
try {
response = GeoportalExporterActionServlet.performHttpRequestToSGService(url, identity, token);
System.out.println(IOUtils.toString(response));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("End");
}
}

View File

@ -36,11 +36,13 @@ import org.gcube.application.geoportalcommon.shared.geoportal.materialization.in
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV; import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
import org.gcube.application.geoportalcommon.shared.geoportal.project.TemporalReferenceDV; import org.gcube.application.geoportalcommon.shared.geoportal.project.TemporalReferenceDV;
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView; import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
import org.gcube.application.geoportaldatamapper.Geoportal_JSON_Mapper;
import org.gcube.application.geoportaldatamapper.shared.ProjectEdit;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portlets.user.geoportaldataviewer.server.Geoportal_JSON_Mapper;
import org.gcube.portlets.user.geoportaldataviewer.shared.ProjectEdit;
import org.json.JSONObject; import org.json.JSONObject;
import org.junit.Before;
import org.junit.Test;
/** /**
* The Class GeoportalViewer_Tests. * The Class GeoportalViewer_Tests.
@ -55,15 +57,15 @@ public class GeoportalViewer_Tests {
private ProjectsCaller clientProjects; private ProjectsCaller clientProjects;
private static String CONTEXT = "/gcube/devsec/devVRE"; //private static String CONTEXT = "/pred4s/preprod/preVRE";
// private static String CONTEXT = "/pred4s/preprod/preVRE"; private static String CONTEXT = "/d4science.research-infrastructures.eu/D4OS/GNA";
// private static String CONTEXT = "/d4science.research-infrastructures.eu/D4OS/GNA"; private static String TOKEN = ""; //GNA
private static String TOKEN = ""; // GNA
// private static String TOKEN = ""; // devVRE //private static String CONTEXT = "/gcube/devsec/devVRE";
//private static String TOKEN = ""; // devVRE
private static String PROFILE_ID = "profiledConcessioni"; private static String PROFILE_ID = "profiledConcessioni";
private static String PROJECT_ID = "63d011c4dcac4551b9a6b930"; private static String PROJECT_ID = "6388ea6ca1e60e66b7b584e0";
private static String USERNAME = "francesco.mangiacrapa"; private static String USERNAME = "francesco.mangiacrapa";
@ -72,7 +74,7 @@ public class GeoportalViewer_Tests {
* *
* @return the client * @return the client
*/ */
//@Before @Before
public void getClient() { public void getClient() {
// assumeTrue(GCubeTest.isTestInfrastructureEnabled()); // assumeTrue(GCubeTest.isTestInfrastructureEnabled());
ScopeProvider.instance.set(CONTEXT); ScopeProvider.instance.set(CONTEXT);
@ -101,7 +103,7 @@ public class GeoportalViewer_Tests {
} }
} }
// @Test //@Test
public void getLayersForId() { public void getLayersForId() {
System.out.println("getLayersForId [profileID: " + PROFILE_ID + ", projectID: " + PROJECT_ID + "] called"); System.out.println("getLayersForId [profileID: " + PROFILE_ID + ", projectID: " + PROJECT_ID + "] called");
@ -119,18 +121,17 @@ public class GeoportalViewer_Tests {
String materializationParentJSONPath = null; String materializationParentJSONPath = null;
if (accessPolicy.equals(ACCESS_POLICY.OPEN)) { if(accessPolicy.equals(ACCESS_POLICY.OPEN)) {
// Filtering for ACCESS_POLICY.OPEN when the username is not in session. IAM //Filtering for ACCESS_POLICY.OPEN when the username is not in session. IAM identity is running, no logged in user.
// identity is running, no logged in user. materializationParentJSONPath = String.format("%s..%s[?(@._access._policy=='%s')]", Geoportal_JSON_Mapper.JSON_$_POINTER,
materializationParentJSONPath = String.format("%s..%s[?(@._access._policy=='%s')]", Geoportal_JSON_Mapper.FILESET, accessPolicy);
Geoportal_JSON_Mapper.JSON_$_POINTER, Geoportal_JSON_Mapper.FILESET, accessPolicy); }else {
} else { //Accessing to all fileset (with any ACCESS_POLICY) when the user is logged in.
// Accessing to all fileset (with any ACCESS_POLICY) when the user is logged in.
materializationParentJSONPath = String.format("%s..%s", Geoportal_JSON_Mapper.JSON_$_POINTER, materializationParentJSONPath = String.format("%s..%s", Geoportal_JSON_Mapper.JSON_$_POINTER,
Geoportal_JSON_Mapper.FILESET); Geoportal_JSON_Mapper.FILESET);
} }
System.out.println("jsonPathQuery is: " + materializationParentJSONPath); System.out.println("jsonPathQuery is: "+materializationParentJSONPath);
// String materializationParentJSONPath = String.format("%s..%s", Geoportal_JSON_Mapper.JSON_$_POINTER, // String materializationParentJSONPath = String.format("%s..%s", Geoportal_JSON_Mapper.JSON_$_POINTER,
// Geoportal_JSON_Mapper.FILESET); // Geoportal_JSON_Mapper.FILESET);
@ -237,7 +238,7 @@ public class GeoportalViewer_Tests {
} }
} }
// @Test //@Test
public void testReadProjectEdit() { public void testReadProjectEdit() {
try { try {
@ -260,7 +261,7 @@ public class GeoportalViewer_Tests {
} }
} }
// @Test //@Test
public void testTemporalReference() { public void testTemporalReference() {
try { try {
ScopeProvider.instance.set(CONTEXT); ScopeProvider.instance.set(CONTEXT);
@ -269,9 +270,8 @@ public class GeoportalViewer_Tests {
Document temporalJsonTemplate = GeoportalClientCaller.useCaseDescriptors() Document temporalJsonTemplate = GeoportalClientCaller.useCaseDescriptors()
.readTemporalDimensionTemplate(theProject.getProfileID()); .readTemporalDimensionTemplate(theProject.getProfileID());
// String template = "{\"content\": \"$.nome\"," + "\"title\": \"$.nome\"," // String template = "{\"content\": \"$.nome\"," + "\"title\": \"$.nome\","
// + "\"start\" : \"$.dataInizioProgetto\"," + "\"end\" : // + "\"start\" : \"$.dataInizioProgetto\"," + "\"end\" : \"$.dataFineProgetto\"}";
// \"$.dataFineProgetto\"}";
if (temporalJsonTemplate != null) { if (temporalJsonTemplate != null) {
@ -292,12 +292,13 @@ public class GeoportalViewer_Tests {
} }
} }
// @Test
//@Test
public void getResultsWithSize() throws Exception { public void getResultsWithSize() throws Exception {
// List<Project> listOfProjects = client.getListForProfileID(PROFILE_ID); // List<Project> listOfProjects = client.getListForProfileID(PROFILE_ID);
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
System.out.println("start at: " + start); System.out.println("start at: "+start);
SearchingFilter filter = new SearchingFilter(); SearchingFilter filter = new SearchingFilter();
// Where Clause // Where Clause
@ -309,32 +310,32 @@ public class GeoportalViewer_Tests {
conditions.add(whereClause); conditions.add(whereClause);
filter.setConditions(conditions); filter.setConditions(conditions);
// NEED TO GET projections //NEED TO GET projections
// SETTING PROJECTION ONLY FOR PROEJCT ID //SETTING PROJECTION ONLY FOR PROEJCT ID
LinkedHashMap<String, Object> projectionForIDs = new LinkedHashMap<String, Object>(); LinkedHashMap<String, Object> projectionForIDs = new LinkedHashMap<String, Object>();
projectionForIDs.put(Project.ID, 1); projectionForIDs.put(Project.ID, 1);
filter.setProjection(projectionForIDs); filter.setProjection(projectionForIDs);
// LIMIT IS NULL MEANS THAT IT IS EQUAL TO NUMBER TOTAL OF DOCUMENTS //LIMIT IS NULL MEANS THAT IT IS EQUAL TO NUMBER TOTAL OF DOCUMENTS
Integer totalDocs = clientProjects.getTotalDocument(PROFILE_ID); Integer totalDocs = clientProjects.getTotalDocument(PROFILE_ID);
Iterator<Project> projects = clientProjects.queryOnMongo(PROFILE_ID, totalDocs, 0, null, filter); Iterator<Project> projects = clientProjects.queryOnMongo(PROFILE_ID, totalDocs, 0, null, filter);
// CALCULATING SIZE OF THE ITERATOR OF PROJECT IDs //CALCULATING SIZE OF THE ITERATOR OF PROJECT IDs
Iterable<Project> itP = () -> projects; Iterable<Project> itP = () -> projects;
Stream<Project> targetStream = StreamSupport.stream(itP.spliterator(), false); Stream<Project> targetStream = StreamSupport.stream(itP.spliterator(), false);
List<String> listProjectIDs = targetStream.map(Project::getId).collect(Collectors.toList()); List<String> listProjectIDs = targetStream.map(Project::getId).collect(Collectors.toList());
System.out.println("Total Ids are: " + listProjectIDs.size()); System.out.println("Total Ids are: "+listProjectIDs.size());
// listProjectIDs.stream().forEach(p -> System.out.println(p)); //listProjectIDs.stream().forEach(p -> System.out.println(p));
long end = System.currentTimeMillis(); long end = System.currentTimeMillis();
System.out.println("IDS returned in ms: " + (end - start)); System.out.println("IDS returned in ms: "+(end-start));
// RESETTIG FILTER AND PROJECT TO CLIENT QUERY //RESETTIG FILTER AND PROJECT TO CLIENT QUERY
LinkedHashMap<String, Object> projection = new LinkedHashMap<String, Object>(); LinkedHashMap<String, Object> projection = new LinkedHashMap<String, Object>();
// default // default
// PROJECTION //PROJECTION
projection.put(Project.ID, 1); projection.put(Project.ID, 1);
projection.put("_theDocument.nome", 1); projection.put("_theDocument.nome", 1);
projection.put("_profileID", 1); projection.put("_profileID", 1);
@ -352,20 +353,20 @@ public class GeoportalViewer_Tests {
projection.put("_theDocument.dataInizioProgetto", 1); projection.put("_theDocument.dataInizioProgetto", 1);
filter.setProjection(projection); filter.setProjection(projection);
// Integer totalDocs = client.getTotalDocument(PROFILE_ID);
//Integer totalDocs = client.getTotalDocument(PROFILE_ID);
Iterator<Project> itProjects = clientProjects.queryOnMongo(PROFILE_ID, totalDocs, 0, 50, filter); Iterator<Project> itProjects = clientProjects.queryOnMongo(PROFILE_ID, totalDocs, 0, 50, filter);
List<ResultDocumentDV> results = ConvertToDataValueObjectModel.toListResultDocument(itProjects); List<ResultDocumentDV> results = ConvertToDataValueObjectModel.toListResultDocument(itProjects);
int i = 0; int i = 0;
for (ResultDocumentDV projectDV : results) { for (ResultDocumentDV projectDV : results) {
System.out.println(++i + ") " + projectDV.getId() + " dataInizioProgetto: " System.out.println(++i + ") " + projectDV.getId() + " dataInizioProgetto: "+projectDV.getDocumentAsMap().get("dataInizioProgetto"));
+ projectDV.getDocumentAsMap().get("dataInizioProgetto"));
} }
System.out.println("Result listed has size: " + results.size()); System.out.println("Result listed has size: "+results.size());
end = System.currentTimeMillis(); end = System.currentTimeMillis();
System.out.println("Result listed in ms: " + (end - start)); System.out.println("Result listed in ms: "+(end-start));
} }

View File

@ -1,84 +0,0 @@
package org.gcube.portlets.user.geoportaldataviewer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.gcube.spatial.data.geoutility.GeoWmsServiceUtility;
import org.gcube.spatial.data.geoutility.bean.WmsParameters;
import org.gcube.spatial.data.geoutility.util.HttpRequestUtil;
import org.gcube.spatial.data.geoutility.wms.WmsUrlValidator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class WMSUrlValidatorTest.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jun 1, 2023
*/
public class WMSUrlValidatorTest {
/**
* The main method.
*
* @param args the arguments
*/
public static void main(String[] args) {
// String baseGeoserverUrl = "http://repoigg.services.iit.cnr.it:8080/geoserver/IGG/ows";
// String baseGeoserverUrl = "http://www.fao.org/figis/geoserver/species";
// String fullPath = "http://www.fao.org/figis/geoserver/species?SERVICE=WMS&BBOX=-176.0,-90.0,180.0,90&styles=Species_prob, puppa&layers=layerName&FORMAT=image/gif";
// String fullPath = "http://repoigg.services.iit.cnr.it:8080/geoserver/IGG/ows?service=wms&version=1.1.0&request=GetMap&layers==IGG:area_temp_1000&width=676&height=330&srs=EPSG:4326&crs=EPSG:4326&format=application/openlayers&bbox=-85.5,-180.0,90.0,180.0";
// String baseGeoserverUrl = "http://thredds-d-d4s.d4science.org/thredds/wms/public/netcdf/test20.nc";
// String fullPath = "http://thredds-d-d4s.d4science.org/thredds/wms/public/netcdf/test20.nc?service=wms&version=1.3.0&request=GetMap&layers=analyzed_field&bbox=-85.0,-180.0,85.0,180.0&styles=&width=640&height=480&srs=EPSG:4326&CRS=EPSG:4326&format=image/png&COLORSCALERANGE=auto";
// WmsUrlValidator validator = new WmsUrlValidator(baseGeoserverUrl, fullPath , "", false);
// logger.trace("base wms service url: "+validator.getBaseWmsServiceUrl());
// logger.trace("layer name: "+validator.getLayerName());
// logger.trace("full wms url: "+validator.getFullWmsUrlRequest(false, true));
// logger.trace("style: "+validator.getStyles());
// logger.trace("not standard parameter: "+validator.getWmsNotStandardParameters());
// String[] arrayStyle = validator.getStyles().split(",");
//
// if(arrayStyle!=null && arrayStyle.length>0){
//
// for (String style : arrayStyle) {
// if(style!=null && !style.isEmpty())
//
// System.out.println("Style: "+style.trim());
// }
// }
//
// String fullPath = "http://thredds-d-d4s.d4science.org/thredds/wms/public/netcdf/test20.nc?service=wms&version=1.3.0&request=GetMap&layers=analyzed_field&bbox=-85.0,-180.0,85.0,180.0&styles=&width=640&height=480&srs=EPSG:4326&CRS=EPSG:4326&format=image/png&COLORSCALERANGE=auto";
//
// WmsGeoExplorerUrlValidator validator = new WmsGeoExplorerUrlValidator("http://thredds-d-d4s.d4science.org/thredds/wms/public/netcdf/test20.nc", fullPath , "", false);
// validator.getFullWmsUrlRequest(false,true);
//
// System.out.println(validator.getWmsNoStandardParameters());
// System.out.println(validator.getMapWmsNoStandardParams());
// fullPath = WmsUrlValidator.setValueOfParameter(WmsParameters.STYLES, fullPath, "123", true);
//
// MapPreviewGenerator map = new MapPreviewGenerator();
// fullPath = map.buildWmsRequestMapPreview(fullPath, "-85.0,-180.0,85.0,180.0");
// System.out.println(fullPath);
String wmsRequest = "http://geoserver-dev.d4science-ii.research-infrastructures.eu/geoserver/wms?CRS=EPSG:4326&BBOX=-85.5,-180.0,90.0,180.0&VERSION=1.1.0&FORMAT=application/openlayers&SERVICE=wms&HEIGHT=330&LAYERS=aquamaps:lsoleasolea20130716162322254cest&REQUEST=GetMap&STYLES=Species_prob&SRS=EPSG:4326&WIDTH=676";
// String wmsRequest = "http://thredds-d-d4s.d4science.org/thredds/wms/public/netcdf/test20.nc?service=wms&version=1.3.0&request=GetMap&layers=analyzed_field&styles=&width=640&height=480&srs=EPSG:4326&CRS=EPSG:4326&format=image/png&COLORSCALERANGE=auto&bbox=-85.0,-180.0,85.0,180.0";
WmsUrlValidator wms;
try {
wms = new WmsUrlValidator(wmsRequest);
System.out.println("Returned wms: "+wms.toString());
}
catch (Exception e) {
e.printStackTrace();
}
}
}