Compare commits

...

115 Commits

Author SHA1 Message Date
Francesco Mangiacrapa 52ea4f5130 reverted to v3.6.0 2024-04-30 11:20:02 +02:00
Francesco Mangiacrapa 66d1baa4ee just to rebuild v3.6.0-SNAPSHOT 2024-04-30 11:13:10 +02:00
Francesco Mangiacrapa 8a3c4437a0 just to rebuild the SNAPSHOT 2024-04-30 11:10:54 +02:00
Francesco Mangiacrapa 8cf6d178b1 geoportal-data-mapper range updated at [1.0.1-SNAPSHOT, 2.0.0-SNAPSHOT) 2023-09-14 16:41:58 +02:00
Francesco Mangiacrapa 0733a62801 removed -SNAPSHOT 2023-09-11 15:08:50 +02:00
Francesco Mangiacrapa dea11a7b95 Merge pull request 'feature_25598' (!17) from feature_25598 into master
Reviewed-on: #17
2023-09-11 15:06:52 +02:00
Francesco Mangiacrapa b3555f4d98 improved CSS 2023-09-11 11:21:02 +02:00
Francesco Mangiacrapa eb92bc685c added -SNAPSHOT 2023-09-11 10:55:34 +02:00
Francesco Mangiacrapa 3099a31e32 Showing basic statistics (i.e. "X project published") via
'countByPhase'method [#25598]
2023-09-11 10:48:34 +02:00
Francesco Mangiacrapa 5cef21b4f0 Update README 2023-09-06 17:15:42 +02:00
Francesco Mangiacrapa e94532f04f removed -SNAPSHOT to be released 2023-09-05 15:20:17 +02:00
Francesco Mangiacrapa b57091278e Merge pull request 'gui_optimization_25461' (!16) from gui_optimization_25461 into master
Reviewed-on: #16
2023-09-05 15:16:50 +02:00
Francesco Mangiacrapa 5cde386089 moved details-panel at z-index: 950. Required for screen < 900px in
width (e.g. tablet)
2023-09-04 11:16:40 +02:00
Francesco Mangiacrapa ba9c8aee78 Using the latest libraries version: gwt-ol.v8.4.1 (with
openlayers.v6.6.1) and gwt.v2.10
2023-08-31 17:21:15 +02:00
Francesco Mangiacrapa 8967184d3c Optimized the UI for screen size 1200x1200 2023-08-31 15:17:21 +02:00
Francesco Mangiacrapa 6338792427 UI optimized for less than 1600w screen resolution 2023-08-29 14:41:32 +02:00
Francesco Mangiacrapa 34f2ba4c7e Media with max-width 2048px the details-panel has width 530px 2023-07-31 12:37:31 +02:00
Francesco Mangiacrapa 6c5c584c0f bug fixing #25293 2023-07-31 12:15:06 +02:00
Francesco Mangiacrapa 4d87eaf5a2 Updated README 2023-07-25 11:36:59 +02:00
Francesco Mangiacrapa 1781488971 Update 'README.md' 2023-07-12 23:43:33 +02:00
Francesco Mangiacrapa a399dbb912 Updated README 2023-07-08 18:38:23 +02:00
Francesco Mangiacrapa dd056fdc9e Updated README 2023-07-08 18:37:50 +02:00
Francesco Mangiacrapa d0271d662c Updated README 2023-07-08 18:36:28 +02:00
Francesco Mangiacrapa d5f2bf9a67 Updated README 2023-07-08 18:35:59 +02:00
Francesco Mangiacrapa a6ac952994 removed -SNAPSHOT to be released 2023-06-15 11:57:14 +02:00
Francesco Mangiacrapa 7383b01aa9 Fixed an issue regarding the set Layer Style facility, #25066?#note-7.
Moved to -SNAPSHOT
2023-06-15 11:56:46 +02:00
Francesco Mangiacrapa 9d92b14378 removed -SNAPSHOT to be released 2023-06-09 13:55:13 +02:00
Francesco Mangiacrapa 23feb1a3c8 Setting initial layer opacity at 0.8 2023-06-09 13:54:45 +02:00
Francesco Mangiacrapa b7885b3b72 removed -SNAPSHOT to be released 2023-06-09 11:08:42 +02:00
Francesco Mangiacrapa 0093af4cdf Added -SNAPSHOT and maven-parent 1.2.0 2023-06-09 11:07:43 +02:00
Francesco Mangiacrapa 412878f323 Removed -SNAPSHOT to be released 2023-06-09 10:45:05 +02:00
Francesco Mangiacrapa bb33754558 Merge pull request 'task_25066' (!15) from task_25066 into master
Reviewed-on: #15
2023-06-09 10:37:45 +02:00
Francesco Mangiacrapa 3644685fe5 Improved search facility 2023-06-09 10:28:46 +02:00
Francesco Mangiacrapa 6361c1c0b9 #25074 cross-filtering completed 2023-06-08 17:03:42 +02:00
Francesco Mangiacrapa a7680ffb46 Added "Fit map to Extent" facility 2023-06-07 14:26:57 +02:00
Francesco Mangiacrapa 1002111ca8 Fixing label 2023-06-06 14:50:06 +02:00
Francesco Mangiacrapa f3e3ca5eb9 Updated label and css 2023-06-06 14:38:30 +02:00
Francesco Mangiacrapa e76448d10a Updated border radius 2023-06-06 12:04:25 +02:00
Francesco Mangiacrapa e73c3a0202 Improved CQL filtering. Now is working in combination with SEARCH and
CROSS_Filtering
2023-06-06 11:49:31 +02:00
Francesco Mangiacrapa a28d2433a0 Passing WFS requests from the servlet due to CORS issue, see
#25074?#note-7
2023-06-05 16:54:40 +02:00
Francesco Mangiacrapa 36bfcd2b9e Added WFS cross filtering results 2023-06-01 16:26:34 +02:00
Francesco Mangiacrapa dcca1afba1 fixed cross filtering select 2023-05-31 17:15:04 +02:00
Francesco Mangiacrapa 33d6dbc89f Applied CQL_Filter for cross filtering 2023-05-31 17:02:03 +02:00
Francesco Mangiacrapa 9d48e78fac in progress cross filtering 2023-05-26 17:49:59 +02:00
Francesco Mangiacrapa a208b37791 in progress cross-filtering 2023-05-26 14:45:47 +02:00
Francesco Mangiacrapa 16d9feffe0 Implement generic method to load grouped configured layers for Overlay
and Cross-Filtering facilities
2023-05-25 11:28:25 +02:00
Francesco Mangiacrapa d1ec08c70f added comments 2023-05-19 15:12:46 +02:00
Francesco Mangiacrapa b3dd9126b9 Fixing layer order 2023-05-19 14:59:55 +02:00
Francesco Mangiacrapa f86988f8c7 Improved Overlay Custom Layer Panel and CSS 2023-05-15 17:11:37 +02:00
Francesco Mangiacrapa 7dc1343f1b Supported the grouped custom layers [#25110] 2023-05-15 16:19:40 +02:00
Francesco Mangiacrapa 647ddfb2d8 Added constant 2023-05-12 11:12:39 +02:00
Francesco Mangiacrapa 16eb79cf32 Updated README 2023-05-12 10:45:44 +02:00
Francesco Mangiacrapa f104c100d8 removed -SNAPSHOT to be released 2023-05-11 15:55:46 +02:00
Francesco Mangiacrapa 2cdc97e70d Merge pull request 'task_24166' (!14) from task_24166 into master
Reviewed-on: #14
2023-05-11 15:53:48 +02:00
Francesco Mangiacrapa 18fe9c40ea Added -SNAPSHOT 2023-05-11 15:53:08 +02:00
Francesco Mangiacrapa c4e9ca93b6 removed -SNAPSHOT to be released 2023-05-11 15:16:28 +02:00
Francesco Mangiacrapa 293bfabfa8 Removed unused cache. Updated pom 2023-05-08 11:37:27 +02:00
Francesco Mangiacrapa d0be59234a Updated README. Fixed pom 2023-05-05 17:40:55 +02:00
Francesco Mangiacrapa 9d059ca4e9 Passed to the geoportal-data-mapper component [#24978] 2023-05-05 17:23:11 +02:00
Francesco Mangiacrapa 2d4bfbee38 Starting integration of the geoportal-data-mapper library 2023-04-13 11:46:17 +02:00
Francesco Mangiacrapa 031ba50a03 Upgraded maven-portal-bom version at 3.7.0 2023-04-04 14:56:37 +02:00
Francesco Mangiacrapa ad7de9f7dc removed -SNAPSHOT to be released 2023-03-30 16:36:19 +02:00
Francesco Mangiacrapa e09bb18614 Improved css 2023-03-30 16:21:49 +02:00
Francesco Mangiacrapa 60f4569518 updated css 2023-03-30 15:13:22 +02:00
Francesco Mangiacrapa 675f23d1ac updated css 2023-03-30 12:43:45 +02:00
Francesco Mangiacrapa 4a44835356 Just including new dependencies 2023-03-30 12:10:29 +02:00
Francesco Mangiacrapa 5ec86d1a8d removed -SNAPSHOT to be released 2023-02-20 15:39:04 +01:00
Francesco Mangiacrapa 9581d3ce73 fixing issues #24632 2023-02-20 15:22:51 +01:00
Francesco Mangiacrapa 2b6272dd60 Fixed fit to Extent on features loaded end 2023-02-07 15:25:53 +01:00
Francesco Mangiacrapa 003590f46e removed -SNAPSHOT to be released 2023-02-03 15:25:28 +01:00
Francesco Mangiacrapa f1fde26359 Merge pull request 'task_24532' (!13) from task_24532 into master
Reviewed-on: #13
2023-02-03 15:24:09 +01:00
Francesco Mangiacrapa 872caa7137 updated CHANGELOG 2023-02-03 15:23:33 +01:00
Francesco Mangiacrapa ff3a7461df Added warning message on broken link 2023-02-03 14:19:33 +01:00
Francesco Mangiacrapa 1a6c9b074d Set Highlight to Light yellow4 2023-02-03 12:28:26 +01:00
Francesco Mangiacrapa 88c986a478 Updated 2023-02-03 11:54:40 +01:00
Francesco Mangiacrapa 06d88b4033 #24432 Done 2023-02-03 11:53:37 +01:00
Francesco Mangiacrapa b5e6afb6ce Moved to red highlight 2023-01-31 15:59:32 +01:00
Francesco Mangiacrapa 657da72da6 Done #24506. Removed -SNAPSHOT to be released 2023-01-31 15:35:37 +01:00
Francesco Mangiacrapa 14bb068b2e Added images 2023-01-31 15:34:04 +01:00
Francesco Mangiacrapa d81ca374dc Merged with branch `locate_layer_geometry` 2023-01-31 15:24:45 +01:00
Francesco Mangiacrapa 5221d2a6b5 Displaying an Alert if an error occurs on adding a layer to Map (#24471) 2023-01-25 10:46:17 +01:00
Francesco Mangiacrapa 69e5216645 commented console.log. Added MaxLenght to CQL Filter 2023-01-24 10:23:37 +01:00
Francesco Mangiacrapa 0d4428e341 Made the code "more robust" (adding some try/catch and checking null
value)
2023-01-19 11:35:50 +01:00
Francesco Mangiacrapa 3c12d6a841 Fixing #24432 GWT serialization 2023-01-17 17:02:23 +01:00
Francesco Mangiacrapa 9a7edeada1 Added Comparable for sorting the UCD names 2023-01-16 14:08:23 +01:00
Francesco Mangiacrapa f9ea07ee00 Merge pull request 'Added Layer Style and Show Legend facilities' (!11) from layer_style_and_legend into master
Reviewed-on: #11
2023-01-16 11:37:58 +01:00
Francesco Mangiacrapa 5a5178c459 Added Layer Style and Show Legend facilities 2023-01-16 11:37:06 +01:00
Francesco Mangiacrapa 8d47db8e83 Fixing issue - files/images duplicated reading the section 2023-01-12 16:56:26 +01:00
Francesco Mangiacrapa dc439a2637 removed -SNAPSHOT to be released 2023-01-12 11:54:42 +01:00
Francesco Mangiacrapa f46fff44ba Merge pull request 'animated_map' (!10) from animated_map into master
Reviewed-on: #10
2023-01-12 11:40:23 +01:00
Francesco Mangiacrapa 268a5eb614 #24404, done 2023-01-12 11:00:09 +01:00
Francesco Mangiacrapa 047db1e848 Added access policy filtering on reading layers for project ID 2023-01-11 17:12:19 +01:00
Francesco Mangiacrapa acc6be29d8 #24390 workaround applied on checking the access policy 2023-01-11 12:21:32 +01:00
Francesco Mangiacrapa 5e45322051 On init - centering the map on the project without centroid feature 2023-01-10 14:36:37 +01:00
Francesco Mangiacrapa cef3b61800 Renamed "Go to Layers" to "Zoom to Layers" 2023-01-09 15:29:01 +01:00
Francesco Mangiacrapa cb99242958 Managing visibility of "Go to Layers" 2022-12-22 16:38:43 +01:00
Francesco Mangiacrapa 67b93db8af Improved UI experience adding several animations on interaction with the
map
2022-12-22 11:59:07 +01:00
Francesco Mangiacrapa 78e939c787 Updated the release date 2022-12-21 11:14:51 +01:00
Francesco Mangiacrapa 307c1245b8 Removed -SNAPSHOT to be RELEASED 2022-12-21 11:12:48 +01:00
Francesco Mangiacrapa c8ad962dfe improved behaviour on searching stage 2022-12-21 11:00:12 +01:00
Francesco Mangiacrapa 474832a663 Updated README 2022-12-15 17:51:02 +01:00
Francesco Mangiacrapa 7211ddaeaf bug fixing issue on displaying automatically the layers 2022-12-15 17:47:44 +01:00
Francesco Mangiacrapa 143e79388d Reduced the bounding box when resolving share link 2022-12-15 15:54:54 +01:00
Francesco Mangiacrapa b53fe20a6f Fix - reduced the bounding boxing when resolving a project by share link 2022-12-15 15:39:08 +01:00
Francesco Mangiacrapa b797a9fd8d #24300 Done. Improved the GUI of the search functionality when multiple
collections are available.
2022-12-14 15:46:20 +01:00
Francesco Mangiacrapa 78cc536f54 Bug fixing pagination on start index (but it is not used at the moment) 2022-11-29 15:46:43 +01:00
Francesco Mangiacrapa 491e9a258b moved two logs at DEBUG 2022-11-29 12:35:30 +01:00
Francesco Mangiacrapa b1a09b39e3 revisited the searching result phrase 2022-11-29 10:46:07 +01:00
Francesco Mangiacrapa 4b13d849a5 Added earth spinner with transparent background 2022-11-29 09:45:35 +01:00
Francesco Mangiacrapa 4b838b2263 commented Tests 2022-11-28 17:52:09 +01:00
Francesco Mangiacrapa 0233bf73ab Updated settings 2022-11-28 17:47:51 +01:00
Francesco Mangiacrapa c9ac22c74e Merge pull request 'update_facility' (!9) from update_facility into master
Reviewed-on: #9
2022-11-28 17:45:17 +01:00
Francesco Mangiacrapa 6b3ceadec5 Merge pull request 'update_facility' (!8) from update_facility into master
Reviewed-on: #8
2022-11-21 16:45:28 +01:00
Francesco Mangiacrapa 1555018334 removed -SNAPSHOT to be released 2022-11-17 12:29:41 +01:00
Francesco Mangiacrapa 643562bc26 Merge pull request '#24136 Integrated the temporal dimension on the front-end side' (!7) from update_facility into master
Reviewed-on: #7
2022-11-17 12:02:31 +01:00
89 changed files with 5970 additions and 2775 deletions

View File

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

View File

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

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
@ -34,8 +34,140 @@
<wb-module deploy-name="geoportal-data-viewer-app-3.0.0-SNAPSHOT">
<wb-module deploy-name="geoportal-data-viewer-app-3.6.0">
@ -71,7 +203,73 @@
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
@ -107,7 +305,73 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
@ -143,7 +407,73 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
@ -179,7 +509,45 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<dependent-module archiveName="geoportal-data-mapper-1.1.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-data-mapper/geoportal-data-mapper">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="uri-resolver-manager-1.8.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/uri-resolver-manager/uri-resolver-manager">
<dependency-type>uses</dependency-type>
</dependent-module>
@ -214,8 +582,6 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
@ -251,7 +617,73 @@
<property name="java-output-path" value="/geoportal-data-viewer-app/target/geoportal-data-viewer-app-0.0.1-SNAPSHOT/WEB-INF/classes"/>
@ -287,7 +719,73 @@
<property name="context-root" value="geoportal-data-viewer-app"/>
@ -323,7 +821,73 @@
</wb-module>

View File

@ -4,7 +4,62 @@
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).
## [v3.0.0-SNAPSHOT] - 2022-11-09
## [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
#### Fixes
- [#24432] Reverting serialization LinkedHashMap<String, String> to LinkedHashMap<String, Object>.
- Improved Alert UX in case of broken shared link
- Moved to gwt 2.9.0
## [v3.2.0] - 2023-01-31
#### Enhancements
- [#24506] Added facility: Locate/Highlight the Layer on the Map
## [v3.1.0] - 2023-01-12
#### Enhancements
- [#24300] Improved the GUI of the search functionality when multiple collections are available
- [#24404] Improved the handlers of events: Search, Locate
- Improved the user experience providing an animated map and zoom to layers facility
#### Fixes
- Reduced the BBOX when resolving a project by share link
- GNA Project binding with automatically adding of the layers to Map
- [#24390] Read the access policy from the fileset json section
- [#24432] Fixing serialization issue using LinkedHashMap<String, String> instead of LinkedHashMap<String, Object>
## [v3.0.0] - 2022-11-28
- [#23940] Passed to CMS-UCD
- [#23941] Implemented and integrated the DTO Project/Document per UCD config and gCube Metadata Profiles

View File

@ -1,6 +1,6 @@
# GeoPortal Data Viewer App
The GeoPortal Data Viewer App is an application to access, discovery and navigate the Geoportal projects/documents by a Web-Map Interface
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.
## Built With
@ -13,12 +13,40 @@ The GeoPortal Data Viewer App is an application to access, discovery and navigat
* 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.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)
* 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
* 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
N/A
Geoportal Service Documentation is available at [gCube CMS Suite](https://geoportal.d4science.org/geoportal-service/docs/index.html)
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

49
pom.xml
View File

@ -7,22 +7,23 @@
<parent>
<artifactId>maven-parent</artifactId>
<groupId>org.gcube.tools</groupId>
<version>1.1.0</version>
<version>1.2.0</version>
<relativePath />
</parent>
<groupId>org.gcube.portlets.user</groupId>
<artifactId>geoportal-data-viewer-app</artifactId>
<packaging>war</packaging>
<version>3.0.0-SNAPSHOT</version>
<version>3.6.0</version>
<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>
<properties>
<!-- Convenience property to set the GWT version -->
<gwt.version>2.9.0</gwt.version>
<gwt.version>2.10.0</gwt.version>
<gwt.compiler.style>PRETTY</gwt.compiler.style>
<gson.version>2.6.2</gson.version>
<gwt.ol.version>8.4.1</gwt.ol.version>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
<!-- GWT 2.9 support 8, 9 and 11 -->
<maven.compiler.source>1.8</maven.compiler.source>
@ -55,7 +56,7 @@
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>maven-portal-bom</artifactId>
<version>3.7.0-SNAPSHOT</version>
<version>3.7.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
@ -64,13 +65,6 @@
<dependencies>
<!-- <dependency> -->
<!-- <groupId>javax.servlet</groupId> -->
<!-- <artifactId>javax.servlet-api</artifactId> -->
<!-- <version>3.1.0</version> -->
<!-- <scope>provided</scope> -->
<!-- </dependency> -->
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
@ -109,7 +103,7 @@
<dependency>
<groupId>com.github.tdesjardins</groupId>
<artifactId>gwt-ol3</artifactId>
<version>8.1.0-gwt2_9</version>
<version>${gwt.ol.version}</version>
</dependency>
<dependency>
<groupId>com.github.gwtbootstrap</groupId>
@ -142,13 +136,6 @@
<artifactId>usermanagement-core</artifactId>
<scope>provided</scope>
</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 -->
<dependency>
<groupId>org.projectlombok</groupId>
@ -157,30 +144,12 @@
<scope>provided</scope>
</dependency>
<!-- END -->
<dependency>
<groupId>org.gcube.portlets.widgets</groupId>
<artifactId>metadata-profile-form-builder-widget</artifactId>
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
<groupId>org.gcube.application</groupId>
<artifactId>geoportal-data-mapper</artifactId>
<version>[1.0.1-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<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>
<groupId>org.gcube.application</groupId>
<artifactId>geoportal-data-common</artifactId>

View File

@ -1,14 +1,22 @@
package org.gcube.portlets.user.geoportaldataviewer.client;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences;
import org.gcube.application.geoportalcommon.shared.geoportal.geojson.GeoJSON;
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.project.ProjectDV;
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.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MapEventType;
@ -17,6 +25,8 @@ 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.LAYER_TYPE;
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.ChangeMapLayerEventHandler;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ClosedViewDetailsEvent;
@ -25,18 +35,25 @@ 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.SwapLayer;
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.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.SearchPerformedEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.SearchPerformedEventHandler;
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.ShowDetailsEventHandler;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowPopupOnCentroiEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowPopupOnCentroiEventHandler;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowPopupOnCentroidEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowPopupOnCentroidEventHandler;
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.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.ZoomOutOverMinimumEventHandler;
import org.gcube.portlets.user.geoportaldataviewer.client.events.collections.CloseCollectionEvent;
@ -46,9 +63,11 @@ 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.MapUtils;
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.ui.GeonaDataViewMainPanel;
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.LoaderIcon;
import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil;
@ -57,7 +76,9 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.ItemFieldsResponse;
import org.gcube.portlets.user.geoportaldataviewer.shared.ViewerConfiguration;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
import com.github.gwtbootstrap.client.ui.Modal;
import com.github.gwtbootstrap.client.ui.Popover;
import com.github.gwtbootstrap.client.ui.constants.Placement;
import com.google.gwt.core.client.EntryPoint;
@ -78,6 +99,7 @@ import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;
import ol.Coordinate;
import ol.Feature;
/**
* Entry point classes define <code>onModuleLoad()</code>.
@ -89,6 +111,8 @@ import ol.Coordinate;
public class GeoportalDataViewer implements EntryPoint {
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";
@ -138,6 +162,11 @@ public class GeoportalDataViewer implements EntryPoint {
private boolean initApplication;
// A cache (Layer_ID, GeoJSON) of layer features loaded via GetFeature Request
private HashMap<String, String> layerFeaturesCache = new HashMap<String, String>();
private ViewerConfiguration viewerConfiguration;
/**
* This is the entry point method.
*/
@ -166,6 +195,7 @@ public class GeoportalDataViewer implements EntryPoint {
public void onFailure(Throwable caught) {
RootPanel.get(APP_DIV).remove(loaderApp);
Window.alert(caught.getMessage());
RootPanel.get(APP_DIV).setHeight("800px");
RootPanel.get(APP_DIV).add(getGeneralErrorPanel());
}
@ -182,6 +212,9 @@ public class GeoportalDataViewer implements EntryPoint {
}
/**
* Inits the application.
*/
private void initApplication() {
initApplication = true;
@ -208,6 +241,7 @@ public class GeoportalDataViewer implements EntryPoint {
@Override
public void onSuccess(ViewerConfiguration result) {
super.onSuccess(result);
viewerConfiguration = result;
GWT.log("Received init config : " + result);
GWT.log("Loading base layers, count : " + result.getBaseLayers().size());
@ -231,10 +265,20 @@ public class GeoportalDataViewer implements EntryPoint {
"//cdnjs.cloudflare.com/ajax/libs/nanogallery2/3.0.5/jquery.nanogallery2.min.js")
.setWindow(ScriptInjector.TOP_WINDOW).inject();
if (result.getAvailableCollections() == null
|| result.getAvailableCollections().size() == 0) {
RootPanel.get(APP_DIV).remove(loaderApp);
Window.alert("No available collection in this context");
RootPanel.get(APP_DIV).add(getGeneralErrorPanel());
return;
}
GWT.log("Loading collections, count " + result.getAvailableCollections().size());
mainPanel.setAvailableCollections(result.getAvailableCollections().values(),
paramGeonaItemType);
ArrayList<GCubeCollection> listColl = new ArrayList<GCubeCollection>();
listColl.addAll(result.getAvailableCollections().values());
Collections.sort(listColl);
mainPanel.setAvailableCollections(listColl, paramGeonaItemType);
if (paramGeonaItemID != null) {
if (paramGeonaItemType == null) {
@ -246,11 +290,14 @@ public class GeoportalDataViewer implements EntryPoint {
}
GeoportalItemReferences gir = new GeoportalItemReferences(paramGeonaItemID,
paramGeonaItemType);
applicationBus.fireEvent(new ShowDetailsEvent(gir, null, true));
applicationBus.fireEvent(
new ShowDetailsEvent(gir, null, true, true, EVENT_SOURCE.LOCATE_ON_INIT));
}
mainPanel.openCollectionMenu();
loadConfigureduGroupedLayersForUCD();
GWT.log("DONE INIT LOAD");
}
@ -271,10 +318,91 @@ public class GeoportalDataViewer implements EntryPoint {
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.
*
* @return the status
*/
public static ViewerStatus getStatus() {
return viewerStatus;
}
/**
* Gets the list base map layers.
*
* @return the list base map layers
*/
public static List<BaseMapLayer> getListBaseMapLayers() {
return listBaseMapLayers;
}
@ -288,9 +416,15 @@ public class GeoportalDataViewer implements EntryPoint {
int height = rootHeight;
mainPanel.setPanelsHeight(height);
GWT.log("Set height: " + height);
mainPanel.setPanelsWidth(Window.getClientWidth());
}
/**
* Gets the client height.
*
* @return the client height
*/
public int getClientHeight() {
RootPanel principalDiv = RootPanel.get(APP_DIV);
int topBorder = principalDiv.getAbsoluteTop();
@ -316,7 +450,7 @@ public class GeoportalDataViewer implements EntryPoint {
if (!ucdIds.contains(collId)) {
GWT.log("!! Collection " + collId + " is not available");
Window.alert("Collection " + collId + " is not found.");
Window.alert("Collection " + collId + " not found.");
} else {
GCubeCollection toOpen = theConfig.getAvailableCollections().get(collId);
@ -388,14 +522,37 @@ public class GeoportalDataViewer implements EntryPoint {
boolean found = false;
GWT.log("Product with id: " + projectID + " found? " + found);
final EVENT_SOURCE sourceEvent = showDetailsEvent.getSourceEvent();
if (!sourceEvent.equals(EVENT_SOURCE.LOCATE_FROM_TIMELINE)) {
timelineMS.hideTimelineProjectRelations();
}
if (sourceEvent.equals(EVENT_SOURCE.LOCATE_SEARCHED)) {
layerManager.removeAllDetailLayers();
}
GeoportalDataViewerServiceAsync.Util.getInstance().getProjectViewForId(profileID, projectID,
new AsyncCallback<ProjectView>() {
@Override
public void onFailure(Throwable caught) {
Window.alert(caught.getMessage());
// Window.alert(caught.getMessage());
mainPanel.hidePanelDetails();
Modal errorModal = new Modal(true, true);
errorModal.setCloseVisible(true);
errorModal.setTitle("Oops...");
Image geoportalError = new Image(GNAImages.ICONS.warningError());
FlowPanel errorPanelMsg = new FlowPanel();
errorPanelMsg.getElement().addClassName("general_warning");
errorPanelMsg.add(geoportalError);
errorPanelMsg.add(new HTML("D4S GeoPortal"));
HTML erroMessage = new HTML(
"Oops something went wrong, either the project does not exist or it has not been published yet");
errorPanelMsg.add(erroMessage);
errorModal.add(errorPanelMsg);
errorModal.show();
}
@Override
@ -409,6 +566,25 @@ public class GeoportalDataViewer implements EntryPoint {
GWT.log("LoadTimelineRelationships is true and the project has Relationships");
timelineMS.showTimelineProjectRelations(result.getTheProjectDV(), false);
}
if (sourceEvent != null) {
switch (sourceEvent) {
case LOCATE_FROM_TIMELINE:
case LOCATE_SEARCHED: {
applicationBus.fireEvent(new ShowPopupOnCentroidEvent(result));
break;
}
case LOCATE_ON_INIT: {
applicationBus.fireEvent(new ShowPopupOnCentroidEvent(result));
layerManager.fireGoToLayers();
break;
}
default:
break;
}
}
}
});
@ -423,63 +599,6 @@ public class GeoportalDataViewer implements EntryPoint {
GWT.log("Fired AddedLayerToMapEvent " + addedLayerToMapEvent.getLayerItem() + "layer type: "
+ addedLayerToMapEvent.getLayerType());
try {
attempt = 0;
if (paramGeonaItemID != null && initApplication) { // waiting for record retrieved by service before
// calling the WFS
// forcing once at init time
initApplication = false;
final int MAX_RETRY = 15;
Timer timer = new com.google.gwt.user.client.Timer() {
@Override
public void run() {
attempt++;
GWT.log("waiting get record: " + attempt);
ProjectView record = mainPanel.getDisplayedProject();
if (record != null) {
this.cancel();
GWT.log("cancelled timer");
GeoJSON spatialReference = record.getTheProjectDV().getSpatialReference();
if (spatialReference == null) {
GWT.log("No spatial reference found, cancelling timer");
this.cancel();
}
try {
ExtentWrapped ew = new ExtentWrapped(spatialReference.getBbox().getMinX(),
spatialReference.getBbox().getMinY(),
spatialReference.getBbox().getMaxX(),
spatialReference.getBbox().getMaxY());
Coordinate centerCoordinate = ew.getCenter();
performWFSQueryOnCentroid(record.getTheProjectDV().getId(),
centerCoordinate.getX(), centerCoordinate.getY());
} catch (Exception e) {
GWT.log("Error on calculating center of the extent " + e.getMessage());
}
}
if (attempt > MAX_RETRY) {
GWT.log("MAX_RETRY reached, cancelled timer");
this.cancel();
}
}
};
timer.scheduleRepeating(1000);
}
} catch (Exception e) {
// TODO: handle exception
}
LAYER_TYPE layerType = addedLayerToMapEvent.getLayerType();
if (layerType != null) {
@ -556,7 +675,7 @@ public class GeoportalDataViewer implements EntryPoint {
applicationBus.addHandler(DoActionOnDetailLayersEvent.TYPE, new DoActionOnDetailLayersEventHandler() {
@Override
public void onDoActionOnDetailLayers(DoActionOnDetailLayersEvent doLayerActionEvent) {
public void onDoActionOnDetailLayers(final DoActionOnDetailLayersEvent doLayerActionEvent) {
DO_LAYER_ACTION doAction = doLayerActionEvent.getDoAction();
GWT.log("event: " + doAction);
@ -583,6 +702,56 @@ public class GeoportalDataViewer implements EntryPoint {
doLayerActionEvent.getVisibility());
break;
case LOCATE_LAYER:
final LayerItem layerItem = doLayerActionEvent.getLayerItem();
boolean layerHighlighted = olMap.areLayerFeaturesAsHighlight(layerItem);
if (layerHighlighted) {
doLayerActionEvent.getSourceEventUI().setVisibleLoaderFeatures(false, null);
olMap.removeLayerFeaturesAsHighlight(layerItem.getName());
return;
}
final String geoJSONFeatures = layerFeaturesCache.get(layerItem.getName());
if (geoJSONFeatures == null) {
GeoportalDataViewerServiceAsync.Util.getInstance().getWFSResponse(layerItem,
olMap.getProjectionCode(), null, 0, "json", new AsyncCallback<String>() {
@Override
public void onFailure(Throwable caught) {
doLayerActionEvent.getSourceEventUI().setVisibleLoaderFeatures(false, null);
}
@Override
public void onSuccess(String geoJSONFeaturesResp) {
doLayerActionEvent.getSourceEventUI().setVisibleLoaderFeatures(false, null);
if (geoJSONFeaturesResp != null && !geoJSONFeaturesResp.isEmpty()) {
layerFeaturesCache.put(layerItem.getName(), geoJSONFeaturesResp);
GWT.log("GeoJSON: " + geoJSONFeaturesResp);
showLayerFeatures(layerItem, geoJSONFeaturesResp,
doLayerActionEvent.getLayerObject().getProjectDV());
}
}
});
} else {
doLayerActionEvent.getSourceEventUI().setVisibleLoaderFeatures(false, null);
showLayerFeatures(layerItem, geoJSONFeatures,
doLayerActionEvent.getLayerObject().getProjectDV());
}
break;
default:
break;
@ -591,6 +760,24 @@ 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() {
@Override
@ -614,18 +801,23 @@ public class GeoportalDataViewer implements EntryPoint {
}
});
applicationBus.addHandler(ShowPopupOnCentroiEvent.TYPE, new ShowPopupOnCentroiEventHandler() {
applicationBus.addHandler(ShowPopupOnCentroidEvent.TYPE, new ShowPopupOnCentroidEventHandler() {
@Override
public void onShowPopup(ShowPopupOnCentroiEvent showPopupOnCentroiEvent) {
public void onShowPopup(ShowPopupOnCentroidEvent showPopupOnCentroiEvent) {
GWT.log("ShowPopupOnCentroidEvent: " + showPopupOnCentroiEvent);
// Showing popup after clicking on map
if (showPopupOnCentroiEvent.getProfileID() != null && showPopupOnCentroiEvent.getProjectID() != null) {
GWT.log("ShowPopupOnCentroiEvent: " + showPopupOnCentroiEvent);
Coordinate transfCoord = MapUtils
.geoJSONTToBBoxCenter(showPopupOnCentroiEvent.getSpatialReference(), null, null);
Coordinate transfCoord = MapUtils.geoJSONToBBOXCenter(showPopupOnCentroiEvent.getSpatialReference(),
null, null);
performWFSQueryOnCentroid(showPopupOnCentroiEvent.getProjectID(), transfCoord.getX(),
transfCoord.getY());
// Showing popup after locate on Map
} else if (showPopupOnCentroiEvent.getProjectView() != null) {
layerManager.showPopupInfoForCentroidLayer(showPopupOnCentroiEvent.getProjectView());
}
}
@ -639,14 +831,15 @@ public class GeoportalDataViewer implements EntryPoint {
if (searchPerformedEvent != null) {
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();
ViewerConfiguration viewerConfig = GeoportalDataViewer.getStatus().getViewerConfig();
String layerName = null;
try {
GCubeCollection toOpen = viewerConfig.getAvailableCollections().get(searchPerformedEvent.getProfileID());
GCubeCollection toOpen = viewerConfig.getAvailableCollections()
.get(searchPerformedEvent.getProfileID());
// Check if indexes is empty
if (toOpen.getIndexes() == null || toOpen.getIndexes().isEmpty()) {
GWT.log("SearchPerformedEvent Unexpected empty indexes in collection " + toOpen);
@ -656,46 +849,149 @@ public class GeoportalDataViewer implements EntryPoint {
// For now we just take the first - only 1 is expected
IndexLayerDV layer = toOpen.getIndexes().get(0);
// Open Index Layer
String wmsLink = layer.getLayer().getOgcLinks().get("wms");
layerName = URLUtil.extractValueOfParameterFromURL("layers", wmsLink);
}catch (Exception e) {
} catch (Exception e) {
// TODO: handle exception
}
String setCqlFilter = null; //default
if (result != null && result.size() > 0) {
String newCqlFilter = null; // default
if (layerName == null) {
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(";
for (String projectId : result) {
cqlFilter += "'" + projectId + "',";
}
cqlFilter = cqlFilter.substring(0, cqlFilter.length() - 1) + ")";
setCqlFilter = cqlFilter;
olMapMng.getOLMap().setCQLFilterToWMSLayer(firstWMSKey, cqlFilter);
newCqlFilter = olMapMng.getOLMap().setCQLFilterToWMSLayer(CQL_FACILITY_ORIGIN.SEARCH, layerName,
cqlFilter);
} else {
olMapMng.getOLMap().setCQLFilterToWMSLayer(firstWMSKey, null);
setCqlFilter = null; //is already null
newCqlFilter = olMapMng.getOLMap().setCQLFilterToWMSLayer(CQL_FACILITY_ORIGIN.SEARCH, layerName,
null);
}
if (searchPerformedEvent.isSearchReset()) {
olMapMng.getOLMap().setCQLFilterToWMSLayer(firstWMSKey, null);
setCqlFilter = null; //is already null
newCqlFilter = olMapMng.getOLMap().setCQLFilterToWMSLayer(CQL_FACILITY_ORIGIN.SEARCH, layerName,
null);
}
if(layerName!=null)
layerManager.setCQLForLayerToIndexLayer(layerName, setCqlFilter);
GWT.log("New CQL Filter is: " + newCqlFilter);
// Resetting CQL Filter
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);
}
}
}
});
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;
}
}
}
}
});
}
/**
* Sets the.
*
* @param json the json
* @return the object
*/
public static native Object toJSON(String json) /*-{
var jsonObj = JSON.parse(json);
//console.log("jsonObj: "+jsonObj);
return jsonObj;
}-*/;
// /**
// * Handler popu closer.
// * Handler popup closer.
// *
// * @param divId the div id
// * @param overlayId the overlay id
@ -711,6 +1007,13 @@ public class GeoportalDataViewer implements EntryPoint {
//
// }-*/;
/**
* Perform WFS query on centroid.
*
* @param projectID the project ID
* @param centroidLong the centroid long
* @param centroidLat the centroid lat
*/
private void performWFSQueryOnCentroid(String projectID, Double centroidLong, Double centroidLat) {
GWT.log("Perform performWFSQueryOnCentroid: " + projectID + " long: " + centroidLong + ", lat: " + centroidLat);
if (projectID != null) {
@ -735,6 +1038,13 @@ public class GeoportalDataViewer implements EntryPoint {
}
}
/**
* Show popover.
*
* @param w the w
* @param message the message
* @param heading the heading
*/
public static void showPopover(final Widget w, String message, String heading) {
final Popover popover = new Popover();
@ -756,6 +1066,11 @@ public class GeoportalDataViewer implements EntryPoint {
timer.schedule(3000);
}
/**
* Gets the general error panel.
*
* @return the general error panel
*/
private FlowPanel getGeneralErrorPanel() {
Image geoportalError = new Image(GNAImages.ICONS.geoportaServiceError());
FlowPanel errorPanelMsg = new FlowPanel();
@ -768,4 +1083,19 @@ public class GeoportalDataViewer implements EntryPoint {
return errorPanelMsg;
}
/**
* Show layer features.
*
* @param layerItem the layer item
* @param geoJSONFeatures the geo JSON features
* @param projectDV the project DV
*/
private void showLayerFeatures(LayerItem layerItem, String geoJSONFeatures, ProjectDV projectDV) {
Feature[] features = OLGeoJSONUtil.readGeoJsonFeatures(MAP_PROJECTION.EPSG_4326, geoJSONFeatures);
GWT.log("features: " + features);
olMapMng.getOLMap().addLayerFeaturesAsHighlight(layerItem, features, true);
}
}

View File

@ -14,6 +14,8 @@ import com.google.gwt.i18n.client.DateTimeFormat;
* Nov 24, 2020
*/
public class GeoportalDataViewerConstants {
public static final int TABLET_WIDTH = 1601;
public static final String MAP_DIV = "map";
@ -25,7 +27,10 @@ public class GeoportalDataViewerConstants {
public static final String GET_MAX_ZOOM_LEVEL = OpenLayersMapParameters.OL_MAP_PARAM.maxzoomlevel.name();
public static final String GET_ZOOM = OpenLayersMapParameters.OL_MAP_PARAM.zoom.name();
public static final String GET_CENTER_MAP_TO_LONG_LAT = OpenLayersMapParameters.OL_MAP_PARAM.centermap.name();
public static 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 enum MapEventType {
@ -34,6 +39,32 @@ public class GeoportalDataViewerConstants {
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.
*
@ -73,10 +104,6 @@ public class GeoportalDataViewerConstants {
}
public enum RECORD_TYPE {
CONCESSIONE
}
public static final double ITALY_CENTER_LONG = 12.45;
public static final double ITALY_CENTER_LAT = 42.98;
@ -91,7 +118,7 @@ public class GeoportalDataViewerConstants {
* @param msg the msg
*/
public static native void printJs(String msg)/*-{
console.log("js console: " + msg);
//console.log("js console: " + msg);
}-*/;
/**
@ -100,7 +127,7 @@ public class GeoportalDataViewerConstants {
* @param msg the msg
*/
public static native void printJsObj(Object object)/*-{
console.log("js obj: " + JSON.stringify(object, null, 4));
//console.log("js obj: " + JSON.stringify(object, null, 4));
}-*/;
/**
@ -156,7 +183,8 @@ public class GeoportalDataViewerConstants {
var tabCell = tr.insertCell(-1);
var theValue = jsonObj[j][col[i]];
//console.log("the value: "+theValue);
if (Object.prototype.toString.call(theValue) === '[object Array]') {
if (theValue !== null
&& Object.prototype.toString.call(theValue) === '[object Array]') {
var formattedValueArray = "";
for (var k = 0; k < theValue.length; k++) {
var theValueArray = theValue[k];

View File

@ -2,12 +2,16 @@ package org.gcube.portlets.user.geoportaldataviewer.client;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences;
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.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.gis.BoundsMap;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult;
@ -15,6 +19,7 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.ItemFieldsResponse;
import org.gcube.portlets.user.geoportaldataviewer.shared.ResultSetPaginatedDataIDs;
import org.gcube.portlets.user.geoportaldataviewer.shared.ViewerConfiguration;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformationForWMSRequest;
@ -179,4 +184,49 @@ public interface GeoportalDataViewerService extends RemoteService {
*/
GeoJSON getSpatialReference(String profileID, String projectID);
/**
* Gets the WFS request.
*
* @param layerItem the layer item
* @param mapSrsName the map srs name
* @param mapBBOX the map BBOX
* @param maxFeatures the max features. If 0 means all feature
* @param outputFormat the output format
* @return the WFS request
*/
String getWFSRequest(LayerItem layerItem, String mapSrsName, BoundsMap mapBBOX, int maxFeatures,
String outputFormat);
/**
* Gets the WFS response.
*
* @param layerItem the layer item
* @param mapSrsName the map srs name
* @param mapBBOX the map BBOX
* @param maxFeatures the max features
* @param outputFormat the output format
* @return the WFS response
*/
String getWFSResponse(LayerItem layerItem, String mapSrsName, BoundsMap mapBBOX, int maxFeatures,
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);
}

View File

@ -2,12 +2,16 @@ package org.gcube.portlets.user.geoportaldataviewer.client;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences;
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.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.gis.BoundsMap;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult;
@ -15,6 +19,7 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.ItemFieldsResponse;
import org.gcube.portlets.user.geoportaldataviewer.shared.ResultSetPaginatedDataIDs;
import org.gcube.portlets.user.geoportaldataviewer.shared.ViewerConfiguration;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformationForWMSRequest;
@ -75,4 +80,17 @@ public interface GeoportalDataViewerServiceAsync {
void getSpatialReference(String profileID, String projectID, AsyncCallback<GeoJSON> callback);
void getWFSRequest(LayerItem layerItem, String mapSrsName, BoundsMap mapBBOX, int maxFeatures, String outputFormat,
AsyncCallback<String> callback);
void getWFSResponse(LayerItem layerItem, String mapSrsName, BoundsMap mapBBOX, int maxFeatures, String outputFormat,
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);
}

View File

@ -11,11 +11,16 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
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.IndexLayerDV;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.FilesetDV;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.PayloadDV;
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
import org.gcube.application.geoportalcommon.shared.geoportal.project.TemporalReferenceDV;
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.SubDocumentView;
import org.gcube.application.geoportalcommon.shared.gis.BoundsMap;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.LayerType;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION;
@ -25,6 +30,7 @@ import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMap
import org.gcube.portlets.user.geoportaldataviewer.client.events.QueryDataEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.QueryDataEventHandler;
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.ZoomOutOverMinimumEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ZoomOutOverMinimumEventHandler;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.ExtentWrapped;
@ -52,6 +58,7 @@ import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.dom.client.Style.Visibility;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.shared.HandlerManager;
@ -62,6 +69,7 @@ import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.EventListener;
import com.google.gwt.user.client.Random;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.FlexTable;
@ -86,6 +94,9 @@ import ol.geom.Geometry;
*/
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. */
private OpenLayerMap olMap;
@ -149,6 +160,9 @@ public class LayerManager {
mapBBOX.setCrs(MAP_PROJECTION.EPSG_4326.getName());
GWT.log("Bounds is: " + mapBBOX);
GWT.log("Bounds to" + MAP_PROJECTION.EPSG_4326.getName() + " Long/Lat: " + mapBBOX.getLowerLeftY()
+ "," + mapBBOX.getLowerLeftX() + "," + mapBBOX.getUpperRightY() + ","
+ mapBBOX.getUpperRightX());
GWT.log("MAX_WFS_FEATURES is: " + GeoportalDataViewerConstants.MAX_WFS_FEATURES);
// GeoportalDataViewerConstants.print("calling getDataResult");
@ -187,14 +201,24 @@ public class LayerManager {
@Override
public void onSuccess(List<GeoNaSpatialQueryResult> listGeonaDataObjects) {
GWT.log("GeoNaDataObject's is/are " + listGeonaDataObjects.size());
if (listGeonaDataObjects == null || listGeonaDataObjects.isEmpty())
if (listGeonaDataObjects == null)
return;
List<FeatureRow> theFeatures = null;
GWT.log("GeoNaDataObject's is/are " + listGeonaDataObjects.size());
MapEventType sourceEvent = queryEvent.getSourceMapEventType();
GWT.log("sourceEvent is: " + sourceEvent);
if (sourceEvent.equals(MapEventType.ADDED_CENTROID_LAYER_TO_MAP)
&& (listGeonaDataObjects.size() == 0)) {
// here the centroid is not available
// GeoportalDataViewer.showPopover(RootPanel.get(GeoportalDataViewer.APP_NOTIFIER),
// "No centroid available for the selected project",
// "Project without a centroid");
olMap.setCenter(queryEvent.getQueryClickExtent().getCenter());
return;
}
List<FeatureRow> theFeatures = null;
// TODO SWTCH FOR EARCH ITEM TYPE
for (final GeoNaSpatialQueryResult geoNaDataObject : listGeonaDataObjects) {
@ -246,6 +270,12 @@ public class LayerManager {
// list of
// FeatureRow
if (theFeatures == null || theFeatures.isEmpty()) {
// means that another version of the project has been passed without
// features
// stored into centroid layers.
// so centering the map on the centroid passed into query and stored
// into project metadata
olMap.setCenter(queryEvent.getQueryClickExtent().getCenter());
return;
}
}
@ -385,6 +415,7 @@ public class LayerManager {
public void removeAllDetailLayers() {
mapOtherLayerObjects.clear();
olMap.removeAllDetailLayers();
olMap.removeAllLayerFeaturesAsHighlight();
overlayLayerManager.resetLayers();
}
@ -404,7 +435,7 @@ public class LayerManager {
String productId = productIds.get(0);
LayerObjectType layerObjectType = layerObject.getType();
return new ShowDetailsEvent(layerObjectType != null ? layerObjectType.name() : null,
layerObject.getProfileID(), productId, fRow, true);
layerObject.getProfileID(), productId, fRow, true, EVENT_SOURCE.OPEN_DETAILS);
}
return null;
@ -440,19 +471,20 @@ public class LayerManager {
/**
* Adds the layer.
*
* @param lot the lot
* @param layerTitle the layer title
* @param layerName the layer name
* @param wmsLink the wms link
* @param isBase the is base
* @param displayInLayerSwitcher the display in layer switcher
* @param UUID the uuid
* @param asDetailLayer the as detail layer
* @param minResolution the min resolution
* @param maxResolution the max resolution
* @param profileID the profile ID
* @param projectID the project ID
* @param projectDV the project DV
* @param lot the lot
* @param layerTitle the layer title
* @param layerName the layer name
* @param wmsLink the wms link
* @param isBase the is base
* @param displayInLayerSwitcher the display in layer switcher
* @param UUID the uuid
* @param asDetailLayer the as detail layer
* @param minResolution the min resolution
* @param maxResolution the max resolution
* @param profileID the profile ID
* @param projectID the project ID
* @param projectDV the project DV
* @param notifyLayerAlreadyAdded the notify layer already added
*/
private void addLayer(final LayerObjectType lot, final String layerTitle, final String layerName,
final String wmsLink, final boolean isBase, final boolean displayInLayerSwitcher, final String UUID,
@ -483,7 +515,7 @@ public class LayerManager {
GWT.log("Parsed WMS Request returned: " + geoInfoWMS);
LayerItem layerItem = toLayerItem(featureType, layerTitle, geoInfoWMS.getLayerName(),
geoInfoWMS.getWmsRequest(), geoInfoWMS.getBaseWmsServiceHost(), true, isBase,
geoInfoWMS.getWmsRequest(), geoInfoWMS.getServiceEndPoint(), true, isBase,
displayInLayerSwitcher, (ArrayList<String>) geoInfoWMS.getStyles().getGeoStyles(),
geoInfoWMS.getWmsRequest(), false, geoInfoWMS.getMapWMSNoStandard(),
geoInfoWMS.isNcWMS(), UUID, geoInfoWMS.getZAxis(), minResolution, maxResolution);
@ -495,6 +527,10 @@ public class LayerManager {
lo.setProfileID(profileID);
lo.setProjectDV(projectDV);
GWT.log("LayerObject ID is: " + lo.getProjectID());
if (lo.getProjectDV() != null)
GWT.log("LayerObject into ProjectDV is: " + lo.getProjectDV().getId());
String layerNameKey = layerItem.getName();
LayerObject theLo;
@ -517,7 +553,7 @@ public class LayerManager {
theLo = lo;
mapOtherLayerObjects.put(layerNameKey, theLo);
GWT.log("PROJECT_LAYER mapOtherLayerObjects is: " + mapOtherLayerObjects);
olMap.addWMSDetailLayer(layerItem);
olMap.addWMSDetailLayer(layerItem, GeoportalDataViewerConstants.INITIAL_LAYER_OPACITY);
overlayLayerManager.addLayerItem(theLo);
} else {
GWT.log("Skipping " + lo.getType() + " layer " + theLo.getLayerItem().getName()
@ -536,14 +572,18 @@ public class LayerManager {
}
});
}
/**
* Sets the CQL for layer to index layer.
*
* @param layerName the layer name
* @param cqlFilter the cql filter
*/
public void setCQLForLayerToIndexLayer(String layerName, String cqlFilter) {
LayerObject theLo = mapIndexLayerObjects.get(layerName);
if(theLo!=null) {
boolean isCQLFilter = cqlFilter!=null;
if (theLo != null) {
theLo.getLayerItem().setCqlFilter(cqlFilter);
theLo.getLayerItem().setCqlFilterAvailable(isCQLFilter);
}
}
@ -552,7 +592,6 @@ public class LayerManager {
*
* @param layer the layer
* @param profileID the profile ID
* @param projectDV the project DV
*/
public void addIndexLayer(IndexLayerDV layer, String profileID) {
GWT.log("Adding index layer: " + layer);
@ -563,6 +602,11 @@ public class LayerManager {
}
/**
* Removes the index layer.
*
* @param layer the layer
*/
public void removeIndexLayer(IndexLayerDV layer) {
String wmsLink = layer.getLayer().getOgcLinks().get("wms");
@ -714,7 +758,7 @@ public class LayerManager {
});
}
});
// //Ordering for temporal dimension
// try {
// Collections.sort(listGeoNaDataObject, new TemporalComparatorUtil());
@ -763,7 +807,8 @@ public class LayerManager {
TemporalReferenceDV tempRef = projectDV.getTemporalReference();
if (tempRef != null) {
flowPanel.add(new HTML(ProjectUtil.toHTMLCode(tempRef)));
if(tempRef.getStart()!=null || tempRef.getEnd()!=null)
flowPanel.add(new HTML(ProjectUtil.toHTMLCode(tempRef)));
}
Button buttOpenProject = new Button("Open Project");
@ -787,8 +832,9 @@ public class LayerManager {
@Override
public void onBrowserEvent(Event event) {
if (Event.ONCLICK == event.getTypeInt()) {
applicationBus.fireEvent(new ShowDetailsEvent(lo.getType().name(),
lo.getProfileID(), newProjectID, null, true));
applicationBus.fireEvent(
new ShowDetailsEvent(lo.getType().name(), lo.getProfileID(),
newProjectID, null, true, EVENT_SOURCE.OPEN_PROJECTS));
}
}
@ -868,13 +914,217 @@ public class LayerManager {
/**
* Show popup info for centroid layer.
*
* @param projectView the project view
*/
public void showPopupInfoForCentroidLayer(ProjectView projectView) {
GWT.log("showPopupInfoForCentroidLayer for projectView: " + projectView);
FlexTable flex = new FlexTable();
flex.setCellPadding(1);
flex.setCellSpacing(1);
flex.getElement().addClassName("popup-table");
VerticalPanel vpPanel = new VerticalPanel();
vpPanel.add(flex);
final ProjectDV projectDV = projectView.getTheProjectDV();
FlexTable intFlex = new FlexTable();
intFlex.setCellPadding(1);
intFlex.setCellSpacing(1);
if (projectDV.getTheDocument() != null) {
LinkedHashMap<String, Object> map = projectDV.getTheDocument().getDocumentAsMap();
// my-html-table
// intFlex.getElement().addClassName("my-html-table");
int i = 0;
for (String key : map.keySet()) {
try {
Object theValue = map.get(key);
String toStringValue = theValue + "";
// intFlex.setHTML(i, 0, key);
intFlex.setHTML(intFlex.getRowCount() + 1, 0, "<span title='" + toStringValue + "'>"
+ StringUtil.ellipsize(toStringValue, 100) + "</span>");
i++;
// showing the first two fields returned into document
if (i == 2)
break;
} catch (Exception e) {
// TODO: handle exception
}
}
flex.setHTML(flex.getRowCount() + 1, 0, intFlex.getElement().getString());
}
TemporalReferenceDV tempRef = projectDV.getTemporalReference();
GWT.log("Temporal reference is: "+tempRef);
if (tempRef != null) {
if(tempRef.getStart()!=null || tempRef.getEnd()!=null)
flex.setHTML(flex.getRowCount() + 1, 0, ProjectUtil.toHTMLCode(tempRef));
}
List<SectionView> selections = projectView.getListSections();
boolean firstImageFound = false;
for (SectionView sectionView : selections) {
List<SubDocumentView> subDocuments = sectionView.getListSubDocuments();
for (SubDocumentView subDoc : subDocuments) {
List<FilesetDV> images = subDoc.getListImages();
if (images != null && images.size() > 0) {
for (FilesetDV fileset : images) {
List<PayloadDV> payloads = fileset.getListPayload();
if (payloads != null && payloads.size() > 0) {
PayloadDV img = payloads.get(0);
if (img != null && img.getLink() != null) {
String theImgHTML = "<div id='pop-img'><img src=\"" + img.getLink() + "\"></img></div>";
GWT.log("theImgHTML: " + theImgHTML);
flex.setHTML(flex.getRowCount() + 1, 0, theImgHTML);
firstImageFound = true;
break;
}
}
}
}
if (firstImageFound)
break;
}
if (firstImageFound)
break;
}
Button buttonOpenDtl = new Button("Open Details");
buttonOpenDtl.getElement().setId("open-details");
buttonOpenDtl.setType(ButtonType.LINK);
buttonOpenDtl.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
GWT.log("Open Details clicked");
ShowDetailsEvent toEvent = new ShowDetailsEvent(LayerObjectType.INDEX_LAYER.name(),
projectDV.getProfileID(), projectDV.getId(), null, true, EVENT_SOURCE.OPEN_DETAILS);
applicationBus.fireEvent(toEvent);
}
});
final Button buttonViewLayers = new Button(ZOOM_TO_LAYERS_LABEL);
buttonViewLayers.getElement().setId("go-to-layers");
buttonViewLayers.getElement().setTitle(ZOOM_TO_LAYERS_TITLE);
buttonViewLayers.setType(ButtonType.LINK);
if (olMap.getCurrentZoomLevel() >= OLMapManager.LAYER_DETAIL_MAX_RESOLUTION) {
buttonViewLayers.setVisible(false);
}
buttonViewLayers.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
GWT.log("View Layers clicked");
fireGoToLayers();
buttonViewLayers.setVisible(false);
}
});
FlowPanel flow = new FlowPanel();
flow.add(buttonOpenDtl);
flow.add(buttonViewLayers);
vpPanel.add(flow);
Coordinate positionTo = null;
GeoJSON spatialReference = projectDV.getSpatialReference();
if (spatialReference == null) {
return;
}
try {
ExtentWrapped ew = new ExtentWrapped(spatialReference.getBbox().getMinX(),
spatialReference.getBbox().getMinY(), spatialReference.getBbox().getMaxX(),
spatialReference.getBbox().getMaxY());
positionTo = MapUtils.transformCoordiante(ew.getCenter(), MAP_PROJECTION.EPSG_4326.getName(),
MAP_PROJECTION.EPSG_3857.getName());
} catch (Exception e) {
GWT.log("Error on calculating center of the extent " + e.getMessage());
}
// fallback
if (positionTo == null)
return;
final Coordinate centerTo = positionTo;
new Timer() {
@Override
public void run() {
olMap.showPopup(vpPanel.toString(), centerTo);
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
Element buttonElement = DOM.getElementById("open-details");
Event.sinkEvents(buttonElement, Event.ONCLICK);
Event.setEventListener(buttonElement, new EventListener() {
@Override
public void onBrowserEvent(Event event) {
if (Event.ONCLICK == event.getTypeInt()) {
ShowDetailsEvent toEvent = new ShowDetailsEvent(LayerObjectType.INDEX_LAYER.name(),
projectDV.getProfileID(), projectDV.getId(), null, true,
EVENT_SOURCE.OPEN_DETAILS);
applicationBus.fireEvent(toEvent);
}
}
});
}
});
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
Element buttonElement = DOM.getElementById("go-to-layers");
Event.sinkEvents(buttonElement, Event.ONCLICK);
Event.setEventListener(buttonElement, new EventListener() {
@Override
public void onBrowserEvent(Event event) {
if (Event.ONCLICK == event.getTypeInt()) {
// buttonElement.setAttribute("visible", "none");
// buttonElement.getStyle().setVisibility(Visibility.HIDDEN);
fireGoToLayers();
}
}
});
}
});
}
}.schedule(OpenLayerMap.SET_CENTER_ANIMATED_DURATION + 100);
olMap.setCenter(centerTo);
}
/**
* Show popup info for centroid layer after clicking on map
*
* @param geoNaDataObject the geo na data object
* @param feature the feature
* @param onFailureCenterTo the on failure center to
*/
public void showPopupInfoForCentroidLayer(GeoNaSpatialQueryResult geoNaDataObject, FeatureRow feature,
Coordinate onFailureCenterTo) {
GWT.log("showPopupInfoForCentroidLayer showing feature: " + feature);
GWT.log("showPopupInfoForCentroidLayer showing layerObject: " + geoNaDataObject.getSourceLayerObject());
@ -885,12 +1135,6 @@ public class LayerManager {
VerticalPanel vpPanel = new VerticalPanel();
vpPanel.add(flex);
if (feature == null) {
flex.setHTML(0, 0, new HTML("No data available").toString());
olMap.showPopup(vpPanel.toString(), onFailureCenterTo);
return;
}
ProjectDV projectDV = geoNaDataObject.getSourceLayerObject().getProjectDV();
if (projectDV != null) {
@ -898,6 +1142,7 @@ public class LayerManager {
FlexTable intFlex = new FlexTable();
intFlex.setCellPadding(1);
intFlex.setCellSpacing(1);
intFlex.getElement().addClassName("thePopDataTable");
if (projectDV.getTheDocument() != null) {
LinkedHashMap<String, Object> map = projectDV.getTheDocument().getDocumentAsMap();
// my-html-table
@ -921,14 +1166,11 @@ public class LayerManager {
TemporalReferenceDV tempRef = projectDV.getTemporalReference();
if (tempRef != null) {
flex.setHTML(flex.getRowCount() + 1, 0, ProjectUtil.toHTMLCode(tempRef));
if(tempRef.getStart()!=null || tempRef.getEnd()!=null)
flex.setHTML(flex.getRowCount() + 1, 0, ProjectUtil.toHTMLCode(tempRef));
}
}
// Showing properties belonging to centroid layer, ignoring this
// Map<String, List<String>> entries = feature.getMapProperties();
if (geoNaDataObject.getMapImages() != null) {
for (String key : geoNaDataObject.getMapImages().keySet()) {
List<PayloadDV> listUI = geoNaDataObject.getMapImages().get(key);
@ -936,7 +1178,7 @@ public class LayerManager {
if (listUI != null && listUI.size() > 0) {
PayloadDV img = listUI.get(0);
if (img != null && img.getLink() != null) {
String theImgHTML = "<img src=\"" + img.getLink() + "\"></img>";
String theImgHTML = "<div id='pop-img'><img src=\"" + img.getLink() + "\"></img></div>";
GWT.log("theImgHTML: " + theImgHTML);
// GeoportalDataViewerConstants.print("The row are:
// "+flex.getRowCount());
@ -947,103 +1189,185 @@ public class LayerManager {
}
GWT.log("The selected Feature is: " + feature);
// GeoportalDataViewerConstants.print("The selected Feature is: "+feature);
FeatureRow theFeature = feature;
Button button = new Button("Open Details");
button.getElement().setId("open-details");
button.setType(ButtonType.LINK);
Button buttonOpenDtl = new Button("Open Details");
buttonOpenDtl.getElement().setId("open-details");
buttonOpenDtl.setType(ButtonType.LINK);
if (button != null) {
vpPanel.add(button);
button.setType(ButtonType.LINK);
button.addClickHandler(new ClickHandler() {
buttonOpenDtl.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
ShowDetailsEvent toEvent = parseGeonaReferences(geoNaDataObject.getSourceLayerObject(), theFeature);
applicationBus.fireEvent(toEvent);
}
});
}
Coordinate centerTo = null;
GWT.log("geometry is: " + feature.getGeometry());
if (feature.getGeometry() != null) {
GWT.log("trasforming geometry: " + feature.getGeometry().getToJSONObject());
Geometry geom = new GeoJson().readGeometry(feature.getGeometry().getToJSONObject(), null);
// POINT
if (geom.getType().equalsIgnoreCase("Point")) {
GWT.log("geometry: is a point");
String coordinateJSON = feature.getGeometry().getCoordinatesJSON();
JSONArray centerJSON = (JSONArray) JSONParser.parseStrict(coordinateJSON);
// Coordinate center = OLFactory.createCoordinate(
// new Double(centerJSON.get(0).toString()),
// new Double(centerJSON.get(1).toString()));
Coordinate center = new Coordinate(new Double(centerJSON.get(0).toString()),
new Double(centerJSON.get(1).toString()));
if (feature.getCrsName() != null && feature.getCrsName().endsWith(MAP_PROJECTION.EPSG_4326.getId())) {
center = MapUtils.transformCoordiante(center, MAP_PROJECTION.EPSG_4326.getName(),
MAP_PROJECTION.EPSG_3857.getName());
}
centerTo = center;
} else {
Extent geomExtent = geom.getExtent();
Coordinate lower = OLFactory.createCoordinate(geomExtent.getLowerLeftX(), geomExtent.getLowerLeftY());
Coordinate upper = OLFactory.createCoordinate(geomExtent.getUpperRightX(), geomExtent.getUpperRightY());
Coordinate lowerCoord = lower;
Coordinate upperCoord = upper;
if (feature.getCrsName() != null && feature.getCrsName().endsWith(MAP_PROJECTION.EPSG_4326.getId())) {
lowerCoord = MapUtils.transformCoordiante(lower, MAP_PROJECTION.EPSG_4326.getName(),
MAP_PROJECTION.EPSG_3857.getName());
upperCoord = MapUtils.transformCoordiante(upper, MAP_PROJECTION.EPSG_4326.getName(),
MAP_PROJECTION.EPSG_3857.getName());
}
ExtentWrapped ew = new ExtentWrapped(lowerCoord.getX(), lowerCoord.getY(), upperCoord.getX(),
upperCoord.getY());
centerTo = new Coordinate(ew.getCenter().getX(), ew.getCenter().getY());
@Override
public void onClick(ClickEvent event) {
GWT.log("Open Details clicked");
fireOpenDetails(geoNaDataObject.getSourceLayerObject(), theFeature);
}
GWT.log("center is: " + centerTo);
});
final Button buttonViewLayers = new Button(ZOOM_TO_LAYERS_LABEL);
buttonViewLayers.getElement().setId("go-to-layers");
buttonViewLayers.getElement().setTitle(ZOOM_TO_LAYERS_TITLE);
buttonViewLayers.setType(ButtonType.LINK);
if (olMap.getCurrentZoomLevel() >= OLMapManager.LAYER_DETAIL_MAX_RESOLUTION) {
buttonViewLayers.setVisible(false);
}
buttonViewLayers.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
GWT.log("View Layers clicked");
fireGoToLayers();
buttonViewLayers.setVisible(false);
}
});
FlowPanel flow = new FlowPanel();
flow.add(buttonOpenDtl);
flow.add(buttonViewLayers);
vpPanel.add(flow);
Coordinate positionTo = null;
if (feature == null) {
positionTo = onFailureCenterTo;
} else {
GWT.log("geometry is: " + feature.getGeometry());
if (feature.getGeometry() != null) {
GWT.log("trasforming geometry: " + feature.getGeometry().getToJSONObject());
Geometry geom = new GeoJson().readGeometry(feature.getGeometry().getToJSONObject(), null);
// POINT
if (geom.getType().equalsIgnoreCase("Point")) {
GWT.log("geometry: is a point");
String coordinateJSON = feature.getGeometry().getCoordinatesJSON();
JSONArray centerJSON = (JSONArray) JSONParser.parseStrict(coordinateJSON);
Coordinate center = new Coordinate(new Double(centerJSON.get(0).toString()),
new Double(centerJSON.get(1).toString()));
if (feature.getCrsName() != null
&& feature.getCrsName().endsWith(MAP_PROJECTION.EPSG_4326.getId())) {
center = MapUtils.transformCoordiante(center, MAP_PROJECTION.EPSG_4326.getName(),
MAP_PROJECTION.EPSG_3857.getName());
}
positionTo = center;
} else {
Extent geomExtent = geom.getExtent();
Coordinate lower = OLFactory.createCoordinate(geomExtent.getLowerLeftX(),
geomExtent.getLowerLeftY());
Coordinate upper = OLFactory.createCoordinate(geomExtent.getUpperRightX(),
geomExtent.getUpperRightY());
Coordinate lowerCoord = lower;
Coordinate upperCoord = upper;
if (feature.getCrsName() != null
&& feature.getCrsName().endsWith(MAP_PROJECTION.EPSG_4326.getId())) {
lowerCoord = MapUtils.transformCoordiante(lower, MAP_PROJECTION.EPSG_4326.getName(),
MAP_PROJECTION.EPSG_3857.getName());
upperCoord = MapUtils.transformCoordiante(upper, MAP_PROJECTION.EPSG_4326.getName(),
MAP_PROJECTION.EPSG_3857.getName());
}
ExtentWrapped ew = new ExtentWrapped(lowerCoord.getX(), lowerCoord.getY(), upperCoord.getX(),
upperCoord.getY());
positionTo = new Coordinate(ew.getCenter().getX(), ew.getCenter().getY());
}
GWT.log("positionTo is: " + positionTo);
}
}
// fallback
if (centerTo == null)
centerTo = onFailureCenterTo;
if (positionTo == null)
positionTo = onFailureCenterTo;
olMap.showPopup(vpPanel.toString(), centerTo);
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
final Coordinate centerTo = positionTo;
new Timer() {
@Override
public void execute() {
Element buttonElement = DOM.getElementById("open-details");
Event.sinkEvents(buttonElement, Event.ONCLICK);
Event.setEventListener(buttonElement, new EventListener() {
public void run() {
olMap.showPopup(vpPanel.toString(), centerTo);
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void onBrowserEvent(Event event) {
if (Event.ONCLICK == event.getTypeInt()) {
ShowDetailsEvent toEvent = parseGeonaReferences(geoNaDataObject.getSourceLayerObject(),
theFeature);
applicationBus.fireEvent(toEvent);
}
public void execute() {
Element buttonElement = DOM.getElementById("open-details");
Event.sinkEvents(buttonElement, Event.ONCLICK);
Event.setEventListener(buttonElement, new EventListener() {
@Override
public void onBrowserEvent(Event event) {
if (Event.ONCLICK == event.getTypeInt()) {
fireOpenDetails(geoNaDataObject.getSourceLayerObject(), theFeature);
}
}
});
}
});
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
Element buttonElement = DOM.getElementById("go-to-layers");
Event.sinkEvents(buttonElement, Event.ONCLICK);
Event.setEventListener(buttonElement, new EventListener() {
@Override
public void onBrowserEvent(Event event) {
if (Event.ONCLICK == event.getTypeInt()) {
// buttonElement.setAttribute("visible", "none");
// buttonElement.getStyle().setVisibility(Visibility.HIDDEN);
fireGoToLayers();
}
}
});
}
});
}
});
}.schedule(OpenLayerMap.SET_CENTER_ANIMATED_DURATION + 100);
olMap.setCenter(centerTo);
}
/**
* Fire go to layers.
*/
protected void fireGoToLayers() {
int zoomValue = (int) (OLMapManager.LAYER_DETAIL_MAX_RESOLUTION + 0.1);
olMap.setZoom(zoomValue);
try {
Element buttonElement = DOM.getElementById("go-to-layers");
buttonElement.getStyle().setVisibility(Visibility.HIDDEN);
} catch (Exception e) {
// TODO: handle exception
}
}
/**
* Fire open details.
*
* @param layerObject the layer object
* @param theFeature the the feature
*/
protected void fireOpenDetails(LayerObject layerObject, FeatureRow theFeature) {
ShowDetailsEvent toEvent = parseGeonaReferences(layerObject, theFeature);
applicationBus.fireEvent(toEvent);
}
/**

View File

@ -166,15 +166,16 @@ public class OLMapManager {
// geoWidth = (bboxWidth / w) * (14 / 2);
geoWidth = (bboxWidth / w) * (16 / 2);
} else {
// data point selection for coordinate loaded from concessione
geoWidth = (bboxWidth / w) * (2);
// data point selection for coordinate loaded from the centroid
geoWidth = (bboxWidth / w) / 60;
GWT.log("geo width: "+geoWidth);
}
double x1 = Math.min(lon + geoWidth, lon - geoWidth);
double x2 = Math.max(lon + geoWidth, lon - geoWidth);
double y1 = Math.min(lat + geoWidth, lat - geoWidth);
double y2 = Math.max(lat + geoWidth, lat - geoWidth);
// GWT.log("("+x1+","+y1+")("+x2+","+y2+")");
//GWT.log("("+x1+","+y1+")("+x2+","+y2+")");
GeoQuery select = new GeoQuery(x1, y1, x2, y2, TYPE.POINT);
return select;

View File

@ -26,8 +26,9 @@ public class OverlayLayerManager {
this.applicationBus = applicationBus;
}
void addLayerItem(LayerObject lo) {
public void addLayerItem(LayerObject lo) {
GWT.log("Adding LayerObject having project: "+lo.getProjectDV());
GWT.log("Adding LayerObject having project id: "+lo.getProjectDV().getId());
ArrayList<DragDropLayer> listDDLayers = mapCollectionsPerProfileID.get(lo.getProfileID());

View File

@ -0,0 +1,72 @@
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

@ -0,0 +1,20 @@
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,6 +1,8 @@
package org.gcube.portlets.user.geoportaldataviewer.client.events;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.dandd.DragDropLayer;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject;
import com.google.gwt.event.shared.GwtEvent;
@ -22,7 +24,7 @@ public class DoActionOnDetailLayersEvent extends GwtEvent<DoActionOnDetailLayers
* Oct 12, 2021
*/
public static enum DO_LAYER_ACTION {
VISIBILITY, SWAP, OPACITY
VISIBILITY, SWAP, OPACITY, LOCATE_LAYER
}
private DO_LAYER_ACTION doAction;
@ -31,29 +33,31 @@ public class DoActionOnDetailLayersEvent extends GwtEvent<DoActionOnDetailLayers
private boolean visibility;
private SwapLayer sourceLayerSwap;
private SwapLayer targetLayerSwap;
private LayerObject layerObject;
private DragDropLayer sourceEventUI;
/**
* The Class SwapLayer.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Oct 15, 2021
* Oct 15, 2021
*/
public static class SwapLayer{
public static class SwapLayer {
private LayerItem layerItem;
private int position;
/**
* Instantiates a new swap layer.
*
* @param layerItem the layer item
* @param position the position
* @param position the position
*/
public SwapLayer(LayerItem layerItem, int position){
public SwapLayer(LayerItem layerItem, int position) {
this.layerItem = layerItem;
this.position = position;
}
/**
* Gets the layer item.
*
@ -62,7 +66,7 @@ public class DoActionOnDetailLayersEvent extends GwtEvent<DoActionOnDetailLayers
public LayerItem getLayerItem() {
return layerItem;
}
/**
* Gets the position.
*
@ -76,11 +80,14 @@ public class DoActionOnDetailLayersEvent extends GwtEvent<DoActionOnDetailLayers
/**
* Instantiates a new do action on detail layers event.
*
* @param action the action
* @param layerItem the layer item
* @param action the action
* @param layerItem the layer item
* @param layerObject the layer object
* @param layerObject the layer object
*/
public DoActionOnDetailLayersEvent(DO_LAYER_ACTION action, LayerItem layerItem) {
public DoActionOnDetailLayersEvent(DO_LAYER_ACTION action, LayerItem layerItem, LayerObject layerObject) {
this.layerItem = layerItem;
this.layerObject = layerObject;
this.doAction = action;
}
@ -135,6 +142,24 @@ public class DoActionOnDetailLayersEvent extends GwtEvent<DoActionOnDetailLayers
}
/**
* Gets the layer object.
*
* @return the layer object
*/
public LayerObject getLayerObject() {
return layerObject;
}
/**
* Sets the layer object.
*
* @param layerObject the new layer object
*/
public void setLayerObject(LayerObject layerObject) {
this.layerObject = layerObject;
}
/**
* Gets the do action.
*
@ -189,6 +214,25 @@ public class DoActionOnDetailLayersEvent extends GwtEvent<DoActionOnDetailLayers
return visibility;
}
/**
* Sets the UI event source.
*
* @param sourceEventUI the new UI event source
*/
public void setUIEventSource(DragDropLayer sourceEventUI) {
this.sourceEventUI = sourceEventUI;
}
/**
* Gets the source event UI.
*
* @return the source event UI
*/
public DragDropLayer getSourceEventUI() {
return sourceEventUI;
}
/**
* To string.
*

View File

@ -0,0 +1,52 @@
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

@ -0,0 +1,20 @@
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,83 +1,83 @@
package org.gcube.portlets.user.geoportaldataviewer.client.events;
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.RECORD_TYPE;
import com.google.gwt.event.shared.GwtEvent;
/**
* The Class GetListOfRecordsEvent.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Dec 7, 2021
*/
public class GetListOfRecordsEvent extends GwtEvent<GetListOfRecordsEventHandler> {
/** The type. */
public static Type<GetListOfRecordsEventHandler> TYPE = new Type<GetListOfRecordsEventHandler>();
private RECORD_TYPE recordType;
private SearchingFilter sortFilter;
/**
* Instantiates a new cancel upload event.
*
* @param recordType the record type
* @param sortFilter the sort filter
*/
public GetListOfRecordsEvent(RECORD_TYPE recordType, SearchingFilter sortFilter) {
this.recordType = recordType;
this.sortFilter = sortFilter;
}
/**
* Gets the associated type.
*
* @return the associated type
*/
/*
* (non-Javadoc)
*
* @see com.google.gwt.event.shared.GwtEvent#getAssociatedType()
*/
@Override
public Type<GetListOfRecordsEventHandler> getAssociatedType() {
return TYPE;
}
/**
* Dispatch.
*
* @param handler the handler
*/
/*
* (non-Javadoc)
*
* @see
* com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.
* EventHandler)
*/
@Override
protected void dispatch(GetListOfRecordsEventHandler handler) {
handler.onGetList(this);
}
/**
* Gets the record type.
*
* @return the record type
*/
public RECORD_TYPE getRecordType() {
return recordType;
}
/**
* Gets the sort filter.
*
* @return the sort filter
*/
public SearchingFilter getSortFilter() {
return sortFilter;
}
}
//package org.gcube.portlets.user.geoportaldataviewer.client.events;
//
//import org.gcube.application.geoportalcommon.shared.SearchingFilter;
//import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.RECORD_TYPE;
//
//import com.google.gwt.event.shared.GwtEvent;
//
///**
// * The Class GetListOfRecordsEvent.
// *
// * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
// *
// * Dec 7, 2021
// */
//public class GetListOfRecordsEvent extends GwtEvent<GetListOfRecordsEventHandler> {
//
// /** The type. */
// public static Type<GetListOfRecordsEventHandler> TYPE = new Type<GetListOfRecordsEventHandler>();
// private RECORD_TYPE recordType;
// private SearchingFilter sortFilter;
//
// /**
// * Instantiates a new cancel upload event.
// *
// * @param recordType the record type
// * @param sortFilter the sort filter
// */
// public GetListOfRecordsEvent(RECORD_TYPE recordType, SearchingFilter sortFilter) {
// this.recordType = recordType;
// this.sortFilter = sortFilter;
// }
//
// /**
// * Gets the associated type.
// *
// * @return the associated type
// */
// /*
// * (non-Javadoc)
// *
// * @see com.google.gwt.event.shared.GwtEvent#getAssociatedType()
// */
// @Override
// public Type<GetListOfRecordsEventHandler> getAssociatedType() {
// return TYPE;
// }
//
// /**
// * Dispatch.
// *
// * @param handler the handler
// */
// /*
// * (non-Javadoc)
// *
// * @see
// * com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.
// * EventHandler)
// */
// @Override
// protected void dispatch(GetListOfRecordsEventHandler handler) {
// handler.onGetList(this);
// }
//
// /**
// * Gets the record type.
// *
// * @return the record type
// */
// public RECORD_TYPE getRecordType() {
// return recordType;
// }
//
// /**
// * Gets the sort filter.
// *
// * @return the sort filter
// */
// public SearchingFilter getSortFilter() {
// return sortFilter;
// }
//
//}

View File

@ -1,22 +1,22 @@
package org.gcube.portlets.user.geoportaldataviewer.client.events;
import com.google.gwt.event.shared.EventHandler;
/**
* The Interface GetListOfRecordsEventHandler.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Aug 4, 2021
*/
public interface GetListOfRecordsEventHandler extends EventHandler {
/**
* On get list.
*
* @param getListOfRecordsEvent the get list of records event
*/
void onGetList(GetListOfRecordsEvent getListOfRecordsEvent);
}
//package org.gcube.portlets.user.geoportaldataviewer.client.events;
//
//import com.google.gwt.event.shared.EventHandler;
//
//
///**
// * The Interface GetListOfRecordsEventHandler.
// *
// * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
// *
// * Aug 4, 2021
// */
//public interface GetListOfRecordsEventHandler extends EventHandler {
//
//
// /**
// * On get list.
// *
// * @param getListOfRecordsEvent the get list of records event
// */
// void onGetList(GetListOfRecordsEvent getListOfRecordsEvent);
//}

View File

@ -0,0 +1,92 @@
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

@ -0,0 +1,20 @@
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

@ -20,6 +20,19 @@ public class ShowDetailsEvent extends GwtEvent<ShowDetailsEventHandler> {
private String profileID;
private String projectID;
private boolean loadTimelineRelationships;
private boolean isEventFromTimeline;
private EVENT_SOURCE sourceEvent;
/**
* The Enum EVENT_SOURCE.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Dec 22, 2022
*/
public static enum EVENT_SOURCE {
LOCATE_ON_INIT, OPEN_DETAILS, OPEN_PROJECTS, LOCATE_SEARCHED, LOCATE_FROM_TIMELINE, GO_TO_LAYERS
}
/**
* Instantiates a new show details event.
@ -29,14 +42,16 @@ public class ShowDetailsEvent extends GwtEvent<ShowDetailsEventHandler> {
* @param projectID the project ID
* @param featureRow the feature row
* @param loadTimelineRelationships the load timeline relationships
* @param sourceEvent the source event
*/
public ShowDetailsEvent(String layerObjectType, String profileID, String projectID, FeatureRow featureRow,
boolean loadTimelineRelationships) {
boolean loadTimelineRelationships, EVENT_SOURCE sourceEvent) {
this.layerObjectType = layerObjectType;
this.profileID = profileID;
this.projectID = projectID;
this.featureRow = featureRow;
this.loadTimelineRelationships = loadTimelineRelationships;
this.sourceEvent = sourceEvent;
}
/**
@ -45,13 +60,43 @@ public class ShowDetailsEvent extends GwtEvent<ShowDetailsEventHandler> {
* @param gir the gir
* @param featureRow the feature row
* @param loadTimelineRelationships the load timeline relationships
* @param sourceEvent the source event
*/
public ShowDetailsEvent(GeoportalItemReferences gir, FeatureRow featureRow, boolean loadTimelineRelationships) {
public ShowDetailsEvent(GeoportalItemReferences gir, FeatureRow featureRow, boolean loadTimelineRelationships,
boolean goToLayers, EVENT_SOURCE sourceEvent) {
this.layerObjectType = gir.getLayerObjectType();
this.profileID = gir.getProfileID();
this.projectID = gir.getProjectID();
this.featureRow = featureRow;
this.loadTimelineRelationships = loadTimelineRelationships;
this.sourceEvent = sourceEvent;
}
/**
* Event from timeline.
*
* @param bool the bool
*/
public void setEventFromTimeline(boolean bool) {
this.isEventFromTimeline = bool;
}
/**
* Checks if is event from timeline.
*
* @return true, if is event from timeline
*/
public boolean isEventFromTimeline() {
return isEventFromTimeline;
}
/**
* Gets the source event.
*
* @return the source event
*/
public EVENT_SOURCE getSourceEvent() {
return sourceEvent;
}
/**
@ -138,11 +183,6 @@ public class ShowDetailsEvent extends GwtEvent<ShowDetailsEventHandler> {
return new GeoportalItemReferences(projectID, profileID, layerObjectType);
}
/**
* To string.
*
* @return the string
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
@ -158,6 +198,10 @@ public class ShowDetailsEvent extends GwtEvent<ShowDetailsEventHandler> {
builder.append(projectID);
builder.append(", loadTimelineRelationships=");
builder.append(loadTimelineRelationships);
builder.append(", isEventFromTimeline=");
builder.append(isEventFromTimeline);
builder.append(", sourceEvent=");
builder.append(sourceEvent);
builder.append("]");
return builder.toString();
}

View File

@ -1,81 +0,0 @@
package org.gcube.portlets.user.geoportaldataviewer.client.events;
import org.gcube.application.geoportalcommon.shared.geoportal.geojson.GeoJSON;
import com.google.gwt.event.shared.GwtEvent;
/**
* The Class ShowDetailsEvent.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jul 30, 2021
*/
public class ShowPopupOnCentroiEvent extends GwtEvent<ShowPopupOnCentroiEventHandler> {
public static Type<ShowPopupOnCentroiEventHandler> TYPE = new Type<ShowPopupOnCentroiEventHandler>();
private String profileID;
private String projectID;
private GeoJSON spatialReference;
/**
* Instantiates a new show details event.
*
* @param geonaItemType the geona item type
* @param geonaMongoID the geona mongo ID
* @param itemName the item name
* @param featureRow the feature row
*/
public ShowPopupOnCentroiEvent(String profileID, String projectID, GeoJSON spatialReference) {
this.profileID = profileID;
this.projectID = projectID;
this.spatialReference = spatialReference;
}
/**
* Gets the associated type.
*
* @return the associated type
*/
@Override
public Type<ShowPopupOnCentroiEventHandler> getAssociatedType() {
return TYPE;
}
/**
* Dispatch.
*
* @param handler the handler
*/
@Override
protected void dispatch(ShowPopupOnCentroiEventHandler handler) {
handler.onShowPopup(this);
}
public String getProfileID() {
return profileID;
}
public String getProjectID() {
return projectID;
}
public GeoJSON getSpatialReference() {
return spatialReference;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("ShowPopupOnCentroiEvent [profileID=");
builder.append(profileID);
builder.append(", projectID=");
builder.append(projectID);
builder.append(", spatialReference=");
builder.append(spatialReference);
builder.append("]");
return builder.toString();
}
}

View File

@ -0,0 +1,122 @@
package org.gcube.portlets.user.geoportaldataviewer.client.events;
import org.gcube.application.geoportalcommon.shared.geoportal.geojson.GeoJSON;
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
import com.google.gwt.event.shared.GwtEvent;
/**
* The Class ShowPopupOnCentroidEvent.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jan 12, 2023
*/
public class ShowPopupOnCentroidEvent extends GwtEvent<ShowPopupOnCentroidEventHandler> {
public static Type<ShowPopupOnCentroidEventHandler> TYPE = new Type<ShowPopupOnCentroidEventHandler>();
private String profileID;
private String projectID;
private GeoJSON spatialReference;
private ProjectView projectView;
/**
* Instantiates a new show popup on centroid event.
*
* @param profileID the profile ID
* @param projectID the project ID
* @param spatialReference the spatial reference
*/
public ShowPopupOnCentroidEvent(String profileID, String projectID, GeoJSON spatialReference) {
this.profileID = profileID;
this.projectID = projectID;
this.spatialReference = spatialReference;
}
/**
* Instantiates a new show popup on centroid event.
*
* @param projectView the project view
*/
public ShowPopupOnCentroidEvent(ProjectView projectView) {
this.projectView = projectView;
}
/**
* Gets the associated type.
*
* @return the associated type
*/
@Override
public Type<ShowPopupOnCentroidEventHandler> getAssociatedType() {
return TYPE;
}
/**
* Dispatch.
*
* @param handler the handler
*/
@Override
protected void dispatch(ShowPopupOnCentroidEventHandler handler) {
handler.onShowPopup(this);
}
/**
* Gets the profile ID.
*
* @return the profile ID
*/
public String getProfileID() {
return profileID;
}
/**
* Gets the project ID.
*
* @return the project ID
*/
public String getProjectID() {
return projectID;
}
/**
* Gets the spatial reference.
*
* @return the spatial reference
*/
public GeoJSON getSpatialReference() {
return spatialReference;
}
/**
* Gets the project view.
*
* @return the project view
*/
public ProjectView getProjectView() {
return projectView;
}
/**
* To string.
*
* @return the string
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("ShowPopupOnCentroidEvent [profileID=");
builder.append(profileID);
builder.append(", projectID=");
builder.append(projectID);
builder.append(", spatialReference=");
builder.append(spatialReference);
builder.append(", projectView=");
builder.append(projectView);
builder.append("]");
return builder.toString();
}
}

View File

@ -2,20 +2,19 @@ package org.gcube.portlets.user.geoportaldataviewer.client.events;
import com.google.gwt.event.shared.EventHandler;
/**
* The Interface ShowPopupOnCentroiEventHandler.
* The Interface ShowPopupOnCentroidEventHandler.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Dec 10, 2021
* Jan 12, 2023
*/
public interface ShowPopupOnCentroiEventHandler extends EventHandler {
public interface ShowPopupOnCentroidEventHandler extends EventHandler {
/**
* On show popup.
*
* @param showPopupOnCentroiEvent the show popup on centroi event
*/
void onShowPopup(ShowPopupOnCentroiEvent showPopupOnCentroiEvent);
void onShowPopup(ShowPopupOnCentroidEvent showPopupOnCentroiEvent);
}

View File

@ -0,0 +1,134 @@
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

@ -0,0 +1,20 @@
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);
}
/**
* @param coordinate coordinate to check.
* @return true if the passed coordinate is contained or on the edge of the
* extent.
*/
@JsOverlay
public final Coordinate getCenter() {
return getCenter((ol.Extent) this);
}
// /**
// * @param coordinate coordinate to check.
// * @return true if the passed coordinate is contained or on the edge of the
// * extent.
// */
// @JsOverlay
// public final Coordinate getCenter() {
// return getCenter((ol.Extent) this);
// }
@JsMethod(name = "getCenter", namespace = PACKAGE_EXTENT)
private static native Coordinate getCenter(Extent extent);

View File

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

View File

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

View File

@ -1,6 +1,7 @@
package org.gcube.portlets.user.geoportaldataviewer.client.gis;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
@ -8,6 +9,7 @@ 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.LAYER_TYPE;
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.LayerItem;
@ -35,7 +37,10 @@ import ol.Overlay;
import ol.OverlayOptions;
import ol.Size;
import ol.View;
import ol.ViewFitOptions;
import ol.ViewOptions;
import ol.animation.AnimationOptions;
import ol.color.Color;
import ol.event.EventListener;
import ol.geom.Geometry;
import ol.interaction.Draw;
@ -61,6 +66,11 @@ import ol.source.Source;
import ol.source.Vector;
import ol.source.Xyz;
import ol.source.XyzOptions;
import ol.style.Fill;
import ol.style.FillOptions;
import ol.style.Stroke;
import ol.style.StrokeOptions;
import ol.style.Style;
/**
* The Class OpenLayerMap.
@ -71,8 +81,29 @@ import ol.source.XyzOptions;
*/
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
public static final int SET_CENTER_ANIMATED_DURATION = 500;
public static final int ZOOM_ANIMATED_DURATION = 3000;
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.
*
@ -136,8 +167,12 @@ public abstract class OpenLayerMap {
private LinkedHashMap<String, Image> wmsDetailsLayerMap;
private LinkedHashMap<String, Image> wmsGroupedCustomLayerMap;
private LinkedHashMap<String, Image> wmsLayerMap;
private LinkedHashMap<String, ol.layer.Vector> vectorLayersHighlighted = new LinkedHashMap<String, ol.layer.Vector>();
private Layer baseLayerTile;
private LayerOrder layerOrder = new LayerOrder();
@ -297,7 +332,13 @@ public abstract class OpenLayerMap {
* @param centerCoordinate the new center
*/
public void setCenter(Coordinate centerCoordinate) {
view.setCenter(centerCoordinate);
AnimationOptions animations = new AnimationOptions();
animations.setCenter(centerCoordinate);
animations.setDuration(SET_CENTER_ANIMATED_DURATION);
view.animate(animations);
// view.setCenter(centerCoordinate);
}
/**
@ -306,7 +347,11 @@ public abstract class OpenLayerMap {
* @param zoom the new zoom
*/
public void setZoom(int zoom) {
view.setZoom(zoom);
AnimationOptions animations = new AnimationOptions();
animations.setDuration(ZOOM_ANIMATED_DURATION);
animations.setZoom(zoom);
view.animate(animations);
// view.setZoom(zoom);
}
/**
@ -322,7 +367,7 @@ public abstract class OpenLayerMap {
elPopup.getStyle().setVisibility(Visibility.VISIBLE);
if (popupOverlay == null) {
popupOverlay = addOverlay(elPopup);
addPopupCloserHandelr(popupOverlay);
addPopupCloserHandler(popupOverlay);
}
Element popContent = DOM.getElementById("popup-content");
popContent.setInnerHTML(html);
@ -340,11 +385,11 @@ public abstract class OpenLayerMap {
}
/**
* Adds the popup closer handelr.
* Adds the popup closer handler.
*
* @param popupOverlay the popup overlay
*/
private void addPopupCloserHandelr(Overlay popupOverlay) {
private void addPopupCloserHandler(Overlay popupOverlay) {
Element elPopupCloser = DOM.getElementById("popup-closer");
Event.sinkEvents(elPopupCloser, Event.ONCLICK);
Event.setEventListener(elPopupCloser, new com.google.gwt.user.client.EventListener() {
@ -392,11 +437,9 @@ public abstract class OpenLayerMap {
if (layer == null) {
ImageWmsParams imageWMSParams = OLFactory.createOptions();
imageWMSParams.setLayers(layerItem.getName());
// imageWMSParams.set("CQL_FILTER", "product_id
// IN('6165b07202ad3d60e1d26f42','6166ff8002ad3d60e1d26fb7')");
ImageWmsOptions imageWMSOptions = OLFactory.createOptions();
imageWMSOptions.setUrl(layerItem.getMapServerHost());
imageWMSOptions.setUrl(layerItem.getMapServerEndpoint());
imageWMSOptions.setParams(imageWMSParams);
// imageWMSOptions.setRatio(1.5f);
@ -430,39 +473,63 @@ public abstract class OpenLayerMap {
}
public void setCQLFilterToWMSLayer(String key, String cqlFilterExpression) {
GWT.log("Getting key: " + key);
GWT.log("Setting CQL FILTER: " + cqlFilterExpression);
Image wmsLayer = wmsLayerMap.get(key);
/**
* Sets the CQL filter to WMS layer.
*
* @param origin the origin
* @param layerName the key
* @param newCQLFilterExpression the cql filter expression
* @return the new CQL Filter
*/
public String setCQLFilterToWMSLayer(CQL_FACILITY_ORIGIN origin, String layerName, String newCQLFilterExpression) {
GWT.log("Getting key (layerName): " + layerName);
GWT.log("Adding CQL FILTER: " + newCQLFilterExpression);
Image wmsLayer = wmsLayerMap.get(layerName);
GWT.log("WMS layer is: " + wmsLayer);
// map.removeLayer(wmsLayer);
ImageWms imageWMSSource = wmsLayer.getSource();
ImageWmsParams imageWMSParams = imageWMSSource.getParams();
if (cqlFilterExpression == null) {
imageWMSParams.delete("CQL_FILTER");
} else {
imageWMSParams.set("CQL_FILTER", cqlFilterExpression);
// Setting new CQL filter for Origin
cqlFilterMap.put(origin, newCQLFilterExpression);
String setCQLFilter = "";
// 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);
wmsLayer.setSource(imageWMSSource);
// map.addLayer(wmsLayer);
wmsLayer.changed();
GWT.log("returning " + CQL_FILTER_PARAMETER + ": " + setCQLFilter);
return setCQLFilter;
}
/**
* Adds the WMS detail layer.
*
* @param layerItem the layer item
* @param layerItem the layer item
* @param initialOpacity the initial opacity
*/
public synchronized void addWMSDetailLayer(LayerItem layerItem) {
public void addWMSDetailLayer(LayerItem layerItem, double initialOpacity) {
if (wmsDetailsLayerMap == null)
wmsDetailsLayerMap = new LinkedHashMap<String, Image>();
@ -477,7 +544,7 @@ public abstract class OpenLayerMap {
imageWMSParams.setLayers(layerItem.getName());
ImageWmsOptions imageWMSOptions = OLFactory.createOptions();
imageWMSOptions.setUrl(layerItem.getMapServerHost());
imageWMSOptions.setUrl(layerItem.getMapServerEndpoint());
imageWMSOptions.setParams(imageWMSParams);
// imageWMSOptions.setRatio(1.5f);
@ -496,6 +563,7 @@ public abstract class OpenLayerMap {
Image wmsLayer = new Image(layerOptions);
int zIndex = layerOrder.getOffset(LayerOrder.LAYER_TYPE.WMS_DETAIL) + wmsDetailsLayerMap.size() + 1;
wmsLayer.setZIndex(zIndex);
wmsLayer.setOpacity(initialOpacity);
map.addLayer(wmsLayer);
wmsDetailsLayerMap.put(key, wmsLayer);
@ -507,12 +575,65 @@ 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.
*
* @param layerName the layer name
*/
public void removeWMSLayer(String layerName) {
GWT.log("Removing layerName: " + layerName + " from map: " + wmsLayerMap);
// NOT NEEDED ANYMORE.. I'M USING MIN/MAX LAYER RESOLUTION
if (wmsLayerMap == null)
@ -533,8 +654,6 @@ public abstract class OpenLayerMap {
*/
public void removeAllDetailLayers() {
// NOT NEEDED ANYMORE.. I'M USING MIN/MAX LAYER RESOLUTION
if (wmsDetailsLayerMap == null)
return;
@ -549,6 +668,24 @@ public abstract class OpenLayerMap {
}
/**
* Removes the all layer features as highlight.
*/
public void removeAllLayerFeaturesAsHighlight() {
if (vectorLayersHighlighted == null)
return;
GWT.log("Removing vectorLayersHighlighted: " + vectorLayersHighlighted.keySet() + " from map");
for (String layerName : vectorLayersHighlighted.keySet()) {
removeLayerFeaturesAsHighlight(layerName);
}
vectorLayersHighlighted.clear();
}
/**
* Adds the vector.
*
@ -559,12 +696,12 @@ public abstract class OpenLayerMap {
VectorLayerOptions vectorLayerOptions = new VectorLayerOptions();
vectorLayerOptions.setMap(map);
// Style style = new Style();
// FillOptions fillOptions = new FillOptions();
// Color color = new Color(0, 0, 255, 1.0);
// fillOptions.setColor(color);
// Fill fill = new Fill(fillOptions);
// style.setFill(fill);
Style style = new Style();
FillOptions fillOptions = new FillOptions();
Color color = new Color(0, 0, 255, 1.0);
fillOptions.setColor(color);
Fill fill = new Fill(fillOptions);
style.setFill(fill);
FeatureOptions featureOptions = new FeatureOptions();
featureOptions.setGeometry(geometry);
@ -576,12 +713,102 @@ public abstract class OpenLayerMap {
ol.layer.Vector vector = OLFactory.createVector(vectorLayerOptions);
int zIndex = layerOrder.getOffset(LayerOrder.LAYER_TYPE.VECTOR) + 1;
int zIndex = layerOrder.getOffset(LayerOrder.LAYER_TYPE.VECTOR) + 1000;
vector.setZIndex(zIndex);
map.addLayer(vector);
}
/**
* Adds the vector.
*
* @param layerItem the layer item
* @param features the features
* @param fitMapToFeaturesExtent the fit map to features extent
*/
public void addLayerFeaturesAsHighlight(LayerItem layerItem, Feature[] features, boolean fitMapToFeaturesExtent) {
removeLayerFeaturesAsHighlight(layerItem.getName());
Style style = new Style();
StrokeOptions strokeOptions = new StrokeOptions();
strokeOptions.setColor(new Color(255, 69, 0, 0.8));
strokeOptions.setWidth(5);
Stroke stroke = new Stroke(strokeOptions);
stroke.setWidth(2);
style.setStroke(stroke);
Vector vectorSource = OLFactory.createVectorSource();
EventListener<ol.events.Event> listenerE = new EventListener<ol.events.Event>() {
@Override
public void onEvent(ol.events.Event event) {
ol.Extent theExtent = vectorSource.getExtent();
// GWT.log(theExtent.toString());
map.getView().fit(theExtent);
}
};
if (fitMapToFeaturesExtent)
vectorSource.addChangeListener(listenerE);
vectorSource.addFeatures(features);
// GWT.log("features: " + features);
VectorLayerOptions vectorLayerOptions = new VectorLayerOptions();
vectorLayerOptions.setSource(vectorSource);
vectorLayerOptions.setStyle(style);
// GWT.log("vectorLayerOptions: " + vectorLayerOptions);
ol.layer.Vector vector = OLFactory.createVector(vectorLayerOptions);
// vector.setStyle(style);
vector.setVisible(true);
vector.setZIndex(5000);
vectorLayersHighlighted.put(layerItem.getName(), vector);
map.addLayer(vector);
}
/**
* Are layer features A as highlight.
*
* @param layerItem the layer item
* @return true, if successful
*/
public boolean areLayerFeaturesAsHighlight(LayerItem layerItem) {
return vectorLayersHighlighted.get(layerItem.getName()) != null;
}
/**
* Removes the layer features A as highlight.
*
* @param layerName the layer name
* @return true, if successful
*/
public boolean removeLayerFeaturesAsHighlight(String layerName) {
try {
ol.layer.Vector vl = vectorLayersHighlighted.get(layerName);
if (vl != null) {
map.removeLayer(vl);
vectorLayersHighlighted.remove(layerName);
return true;
}
} catch (Exception e) {
}
return false;
}
/**
* Adds the point vector source.
*
@ -903,6 +1130,23 @@ public abstract class OpenLayerMap {
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.
*
@ -912,7 +1156,21 @@ public abstract class OpenLayerMap {
public void setWMSDetailLayerOpacity(LayerItem layerItem, double opacity) {
String key = layerItem.getName();
Image layer = wmsDetailsLayerMap.get(key);
layer.setOpacity(opacity);
if (layer != null)
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);
}
/**
@ -952,4 +1210,17 @@ public abstract class OpenLayerMap {
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

@ -47,13 +47,22 @@ public interface GNAImages extends ClientBundle {
@Source("layer_invisible.png")
ImageResource layerInvisible();
@Source("locate.png")
ImageResource locate();
@Source("locate_none.png")
ImageResource locateNone();
@Source("spinner_earth.gif")
ImageResource spinnerEarth();
@Source("spinner_clock.gif")
ImageResource spinnerClock();
@Source("geoporta_error.png")
@Source("geoportal_error.png")
ImageResource geoportaServiceError();
@Source("warning_error.png")
ImageResource warningError();
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

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

View File

@ -8,36 +8,48 @@ import java.util.List;
import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences;
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
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.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.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.GisToolbarFacilities;
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.MapExtentToEvent;
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.gis.OpenLayerMap;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.GNAIcons;
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.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.map.ExtentMapUtil;
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.ItemFieldsResponse;
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.CheckBox;
import com.github.gwtbootstrap.client.ui.DropdownButton;
import com.github.gwtbootstrap.client.ui.ListBox;
import com.github.gwtbootstrap.client.ui.NavLink;
import com.github.gwtbootstrap.client.ui.NavList;
import com.github.gwtbootstrap.client.ui.Paragraph;
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.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.Style.Unit;
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.logical.shared.ValueChangeEvent;
@ -48,10 +60,13 @@ import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Image;
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.RootPanel;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;
@ -65,6 +80,10 @@ import com.google.gwt.user.client.ui.Widget;
*/
public class GeonaDataViewMainPanel extends Composite {
private static final String PLACEHOLDER_SELECT_SEARCH_IN = "Select Collection...";
private static GeonaDataViewMainPanelUiBinder uiBinder = GWT.create(GeonaDataViewMainPanelUiBinder.class);
/**
@ -107,6 +126,18 @@ public class GeonaDataViewMainPanel extends Composite {
@UiField
DropdownButton openCollectionDropDown;
@UiField
DropdownButton linkCustomOverlayLayers;
@UiField
DropdownButton linkCrossFilteringLayers;
@UiField
HTMLPanel panelCustomOverlayLayers;
@UiField
HTMLPanel panelCrossFilteringLayers;
@UiField
HTMLPanel openCollectionPanel;
@ -114,10 +145,12 @@ public class GeonaDataViewMainPanel extends Composite {
DropdownButton searchFacilityButton;
@UiField
NavList navListSearch;
ListBox navListSearch;
@UiField
ScrollPanel overlayLayersPanel;
//@UiField
//ScrollPanel overlayLayersPanel;
RootPanel overlayLayersPanel = RootPanel.get(GeoportalDataViewer.DIV_LAYER_VIEW);
@UiField
ScrollPanel searchFacilityPanel;
@ -142,6 +175,10 @@ public class GeonaDataViewMainPanel extends Composite {
private HashMap<String, List<CheckBox>> mapCollectionCheckBoxes;
private SearchFacilityUI currentSearchFacility;
private HashMap<String, ItemFieldsResponse> mapItemFieldsForUCD = new HashMap<String, ItemFieldsResponse>();
public GeonaDataViewMainPanel(HandlerManager applicationBus, int mapHeight,
List<ItemFieldsResponse> itemFieldsReponse) {
initWidget(uiBinder.createAndBindUi(this));
@ -149,6 +186,7 @@ public class GeonaDataViewMainPanel extends Composite {
mapPanel = new MapPanel(mapHeight + "px");
detailsPanel.setHeight(mapHeight + "px");
detailsPanel.setApplicationBus(applicationBus);
overlayLayersPanel.setVisible(false);
mainContainerPanel.add(mapPanel);
bindHandlers();
dataPointSelection.setIcon(IconType.SCREENSHOT);
@ -165,59 +203,73 @@ public class GeonaDataViewMainPanel extends Composite {
extentToEarth.getElement().appendChild(worldImg.getElement());
extentToEarth.setWidth("140px");
linkMap.setCustomIconStyle(GNAIcons.CustomIconType.MAP.get());
// linkMap.setCustomIconStyle(GNAIcons.CustomIconType.MAP.get());
linkPresetLocation.setCustomIconStyle(GNAIcons.CustomIconType.PRESET_LOCATION.get());
linkLayers.setCustomIconStyle(GNAIcons.CustomIconType.LAYERS.get());
openCollectionDropDown.setIcon(IconType.COMPASS);
mapItemFieldsForUCD.clear();
SearchingFilter initialSortFilter = new SearchingFilter();
initialSortFilter.setOrder(ORDER.ASC);
for (final ItemFieldsResponse ifResponse : itemFieldsReponse) {
navListSearch.addItem(PLACEHOLDER_SELECT_SEARCH_IN, PLACEHOLDER_SELECT_SEARCH_IN);
List<ItemFieldDV> result = ifResponse.getListItemFields();
List<ItemFieldDV> displayFields = new ArrayList<ItemFieldDV>();
List<ItemFieldDV> searchByFields = new ArrayList<ItemFieldDV>();
List<ItemFieldDV> sortByFields = new ArrayList<ItemFieldDV>();
for (ItemFieldDV itemField : result) {
if (itemField.isDisplayAsResult()) {
displayFields.add(itemField);
}
navListSearch.getElement().getFirstChildElement().setAttribute("disabled", "disabled");
if (itemField.isSearchable()) {
searchByFields.add(itemField);
}
for (final ItemFieldsResponse itemFieldResp : itemFieldsReponse) {
if (itemField.isSortable()) {
sortByFields.add(itemField);
}
}
UseCaseDescriptorDV ucd = itemFieldResp.getUseCaseDescriptorDV();
mapItemFieldsForUCD.put(ucd.getId(), itemFieldResp);
GWT.log("Added navLink for: " + ucd.getName());
navListSearch.addItem(ucd.getName(), ucd.getProfileID());
}
final UseCaseDescriptorDV ucd = ifResponse.getUseCaseDescriptorDV();
NavLink navLink = new NavLink(ifResponse.getUseCaseDescriptorDV().getName());
// navLink.setText(ucd.getName());
navLink.addClickHandler(new ClickHandler() {
navListSearch.addChangeHandler(new ChangeHandler() {
private SearchFacilityUI currentSearchFacility;
private SearchFacilityUI currentSearchFacility;
@Override
public void onClick(ClickEvent event) {
if (this.currentSearchFacility != null)
this.currentSearchFacility.resetCurrentSearch();
@Override
public void onChange(ChangeEvent event) {
if (this.currentSearchFacility != null)
this.currentSearchFacility.resetCurrentSearch();
String ucdProfileID = navListSearch.getValue(navListSearch.getSelectedIndex());
GWT.log("UCD ProfileID selected: " + ucdProfileID);
if (ucdProfileID.compareTo(PLACEHOLDER_SELECT_SEARCH_IN) != 0) {
searchFacilityPanel.clear();
this.currentSearchFacility = new SearchFacilityUI(ucd.getProfileID(), applicationBus, displayFields,
ItemFieldsResponse itemFieldResp = mapItemFieldsForUCD.get(ucdProfileID);
List<ItemFieldDV> result = itemFieldResp.getListItemFields();
List<ItemFieldDV> displayFields = new ArrayList<ItemFieldDV>();
List<ItemFieldDV> searchByFields = new ArrayList<ItemFieldDV>();
List<ItemFieldDV> sortByFields = new ArrayList<ItemFieldDV>();
for (ItemFieldDV itemField : result) {
if (itemField.isDisplayAsResult()) {
displayFields.add(itemField);
}
if (itemField.isSearchable()) {
searchByFields.add(itemField);
}
if (itemField.isSortable()) {
sortByFields.add(itemField);
}
}
this.currentSearchFacility = new SearchFacilityUI(ucdProfileID, applicationBus, displayFields,
sortByFields, searchByFields, initialSortFilter);
searchFacilityPanel.add(currentSearchFacility);
currentSearchFacility.setSearchButton(searchFacilityButton);
}
});
GWT.log("Added navLink for: " + ucd.getName());
navListSearch.add(navLink);
}
}
});
searchFacilityButton.setIcon(IconType.SEARCH);
@ -230,15 +282,24 @@ public class GeonaDataViewMainPanel extends Composite {
@Override
public void execute() {
searchFacilityPanel.getElement().getParentElement().getStyle().setOpacity(0.9);
searchFacilityPanel.getElement().getParentElement().addClassName("opacity-09");
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);
bindEvents();
}
/**
@ -280,6 +341,26 @@ public class GeonaDataViewMainPanel extends Composite {
}
}, 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());
}
/**
@ -295,6 +376,27 @@ public class GeonaDataViewMainPanel extends Composite {
setOverlayPanelMaxHeight();
}
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.
@ -499,44 +601,22 @@ public class GeonaDataViewMainPanel extends Composite {
for (GCubeCollection coll : collection) {
GWT.log("Found available collection " + coll);
String label = coll.getUcd().getName();
final String collectionID = coll.getUcd().getId(); // collectionID == UCD_Id
CheckBox checkbox = new CheckBox(label);
checkbox.setId("gcubeCollectionSelector_" + collectionID);
LayerCollectionPanel lcp = new LayerCollectionPanel(coll, applicationBus);
checkbox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
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());
if (event.getValue()) {
// OPEN COLLECTION
applicationBus.fireEvent(new OpenCollectionEvent(collectionID));
} else {
// CLOSE COLLECTION
applicationBus.fireEvent(new CloseCollectionEvent(collectionID));
}
}
});
openCollectionPanel.add(checkbox);
openCollectionPanel.add(lcp);
List<CheckBox> listCollections = mapCollectionCheckBoxes.get(collectionID);
if (listCollections == null)
listCollections = new ArrayList<CheckBox>();
listCollections.add(checkbox);
listCollections.add(lcp.getCheckbox());
mapCollectionCheckBoxes.put(collectionID, listCollections);
// Opening All Collections if openCollectionID is null
if (openCollectionID == null) {
checkbox.setValue(true, true);
lcp.getCheckbox().setValue(true, true);
// String collectionID = checkbox.getId().replace("gcubeCollectionSelector_",
// "");
GWT.log("Opening the collection: " + collectionID);
@ -600,4 +680,107 @@ 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

@ -17,6 +17,14 @@
padding-right: 15px;
}
.margin-left-top-5 {
margin-left: 5px;
margin-top: 5px;
}
.margin-left-5 {
margin-left: 5px;
}
</ui:style>
<g:HTMLPanel ui:field="mainHTMLPanel">
<g:HTMLPanel ui:field="mainContainerPanel">
@ -41,25 +49,39 @@
</g:HTMLPanel>
</g:HTMLPanel>
</b:DropdownButton>
<b:DropdownButton type="LINK"
text="Open Collection" ui:field="openCollectionDropDown">
<g:HTMLPanel ui:field="openCollectionPanel" addStyleNames="{style.open-collection-style}">
<b:DropdownButton type="LINK" text="Collection"
ui:field="openCollectionDropDown">
<g:HTMLPanel ui:field="openCollectionPanel"
addStyleNames="open-collection-style">
</g:HTMLPanel>
</b:DropdownButton>
<b:DropdownButton type="LINK"
title="Select the Map" text="Map" ui:field="linkMap">
<b:DropdownButton type="LINK" text="Map" ui:field="linkMap" icon="GLOBE">
<g:HTMLPanel ui:field="panelBaseLayers">
</g:HTMLPanel>
</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"
ui:field="searchFacilityButton">
<b:NavList ui:field="navListSearch"></b:NavList>
<g:FlowPanel addStyleNames="search-field">
<g:HorizontalPanel>
<b:Label type="INFO">Search in </b:Label>
<b:ListBox title="Search in the Collection..."
ui:field="navListSearch">
</b:ListBox>
</g:HorizontalPanel>
</g:FlowPanel>
<g:ScrollPanel ui:field="searchFacilityPanel"
addStyleNames="search-facility"></g:ScrollPanel>
</b:DropdownButton>
<b:DropdownButton type="LINK"
title="Center Map to Location" text="Preset Location"
ui:field="linkPresetLocation">
<b:DropdownButton type="LINK" text="Preset Location"
ui:field="linkPresetLocation" addStyleNames="preset-location">
<b:Nav>
<b:Button type="LINK" ui:field="extentToItaly"
text="Italy" title="Center to Italy"></b:Button>
@ -83,8 +105,8 @@
text="Remove Query" visible="false"></b:Button>
<b:Button type="LINK" text="Layers" ui:field="linkLayers">
</b:Button>
<g:ScrollPanel ui:field="overlayLayersPanel"
addStyleNames="layers-panel" visible="false"></g:ScrollPanel>
<!-- <g:ScrollPanel ui:field="overlayLayersPanel"
addStyleNames="layers-panel" visible="false"></g:ScrollPanel> -->
</g:HTMLPanel>
</g:HTMLPanel>
<c:DetailsPanel ui:field="detailsPanel"

View File

@ -49,7 +49,7 @@ public class ImagesSectionGallery {
*/
private native void showGallery(JavaScriptObject json_array_images, String galleryDivId) /*-{
console.log("showing: " + json_array_images)
//console.log("showing: " + json_array_images)
var waitForJQuery = setInterval(
function() {
if (typeof $wnd.$ != 'undefined') {

View File

@ -100,26 +100,37 @@ public class LayersSectionViewer extends Composite {
GWT.log("mapServerHost: " + mapServerHost);
BBOXDV bbox = layer.getBbox();
try {
if(bbox!=null) {
if(!GWT.isProdMode()) {
GWT.log("bbox: " + bbox);
if (bbox != null) {
if (!GWT.isProdMode()) {
GWT.log("bbox: " + bbox);
// GWT.log("bbox keys: " + bbox.keySet());
// GWT.log("bbox values: " + bbox.values());
GWT.log("minX: " + bbox.getMinX());
GWT.log("minY: " + bbox.getMinY());
GWT.log("maxX: " + bbox.getMaxX());
GWT.log("maxY: " + bbox.getMaxY());
GWT.log("minX: " + bbox.getMinX());
GWT.log("minY: " + bbox.getMinY());
GWT.log("maxX: " + bbox.getMaxX());
GWT.log("maxY: " + bbox.getMaxY());
}
BoundsMap bounds = new BoundsMap(bbox.getMinX(), bbox.getMinY(), bbox.getMaxX(), bbox.getMaxY(), "");
GWT.log("bounds: " + bounds);
mapView.addWMSLayer(mapServerHost, layerName, bounds);
} else {
Alert alert = new Alert();
alert.setType(AlertType.ERROR);
alert.setText("No BBOX found for this layer");
alert.setClose(false);
layerPanel.add(alert);
}
BoundsMap bounds = new BoundsMap(bbox.getMinX(), bbox.getMinY(), bbox.getMaxX(), bbox.getMaxY(), "");
GWT.log("bounds: " + bounds);
mapView.addWMSLayer(mapServerHost, layerName, bounds);
}else {
} catch (Exception e) {
Alert alert = new Alert();
alert.setType(AlertType.ERROR);
alert.setText("No BBOX found for this layer");
alert.setHTML("Error on adding the layer to Map. Please check its WMS link: <br/>"+layer.getWMSLink());
alert.getElement().getStyle().setProperty("wordBreak", "break-all");
alert.setClose(false);
layerPanel.add(alert);
}
@ -138,18 +149,6 @@ public class LayersSectionViewer extends Composite {
@Override
public void onClick(ClickEvent event) {
// DOWNLOAD only the layer by Geoserver
/*
* Map<String, String> mapLayerURLs =
* mapView.getLightOLSM().getLayerURLsProperty(); Collection<String> layerURLs =
* mapLayerURLs.values(); ArrayList<String> layers = new
* ArrayList<String>(layerURLs); exportPDF(layers.get(0)); String layerURL =
* mapLayerURLs.get(layerDV.getLayerName()); GWT.log("layerDV name is: " +
* layerDV.getLayerName()); if (layerURL != null) Window.open(layerURL,
* "_blank", null);
*/
downloadAttempt++;
if (downloadAttempt > 3) {
@ -160,7 +159,6 @@ public class LayersSectionViewer extends Composite {
// DOWNLOAD the OSM + layer by canvas
downloadMap(mapView.getLightOLM().getMap(), mapView.getPanelMapElementId(), htmlLinkId, filename,
mimeType);
// mapExport(mapView.getLightOLSM().getMap(), mapView.getPanelMapElementId());
}
});
@ -189,7 +187,7 @@ public class LayersSectionViewer extends Composite {
*/
public static native void downloadMap(ol.Map map, String mapPanelId, String linkId, String filename,
String mimeType)/*-{
console.log("map: " + map);
//console.log("map: " + map);
map.once('rendercomplete', function() {
var mapCanvas = $doc.createElement('canvas');

View File

@ -304,7 +304,7 @@ public class ProjectViewer extends Composite {
GeoJSON spatialReference = theProjectView.getTheProjectDV().getSpatialReference();
Coordinate transfCoord = MapUtils.geoJSONTToBBoxCenter(spatialReference, MAP_PROJECTION.EPSG_4326.getName(),
Coordinate transfCoord = MapUtils.geoJSONToBBOXCenter(spatialReference, MAP_PROJECTION.EPSG_4326.getName(),
MAP_PROJECTION.EPSG_3857.getName());
if (transfCoord != null) {

View File

@ -23,6 +23,7 @@
color: white;
padding: 10px 10px;
font-size: 14px;
padding-left: 40px;
}
.width-100 {

View File

@ -17,6 +17,8 @@ import com.github.gwtbootstrap.client.ui.PageHeader;
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
@ -42,74 +44,93 @@ public class SectionViewer extends Composite {
public SectionViewer(SectionView sectionView, String topTargetId) {
initWidget(uiBinder.createAndBindUi(this));
this.sectionView = sectionView;
List<SubDocumentView> subDocuments = sectionView.getListSubDocuments();
sectionTitle.setTitle(sectionView.getSectionTitle());
sectionTitle.setText(sectionView.getSectionTitle());
if (subDocuments == null)
return;
Button goToTop = new Button("");
goToTop.setType(ButtonType.LINK);
goToTop.setIcon(IconType.DOUBLE_ANGLE_UP);
goToTop.setHref("#"+topTargetId);
goToTop.setHref("#" + topTargetId);
goToTop.setTitle("Go to top");
goToTop.getElement().setClassName("go-top-right");
sectionTitle.add(goToTop);
boolean displayAsGallery = false;
for (SubDocumentView subDocumentView : subDocuments) {
if (subDocumentView.getListImages() != null && subDocumentView.getListImages().size() > 0) {
displayAsGallery = true;
break;
}
}
boolean displayAsMapOfLayers = false;
for (SubDocumentView subDocumentView : subDocuments) {
if (subDocumentView.getListLayers() != null && subDocumentView.getListLayers().size() > 0) {
displayAsMapOfLayers = true;
break;
}
}
// Displaying the whole section as a Gallery
if (displayAsGallery) {
GWT.log("displayAsGallery the: "+sectionView);
ImagesSectionGallery sectionGallery = new ImagesSectionGallery(sectionView);
sectionPanelContainer.add(sectionGallery.getGalleryPanel());
sectionGallery.fillGallery();
// Displaying the whole section as a Map of Layers
} else if (displayAsMapOfLayers) {
GWT.log("displayAsMapOfLayers the: "+sectionView);
try {
for (SubDocumentView subDocumentView : subDocuments) {
if (subDocumentView.getListImages() != null && subDocumentView.getListImages().size() > 0) {
GWT.log("Section with images: " + subDocumentView.getListImages());
displayAsGallery = true;
break;
}
}
boolean displayAsMapOfLayers = false;
for (SubDocumentView subDocumentView : subDocuments) {
if (subDocumentView.getListLayers() != null && subDocumentView.getListLayers().size() > 0) {
GWT.log("Section with layers: " + subDocumentView.getListImages());
displayAsMapOfLayers = true;
break;
}
}
// Displaying the whole section as a Gallery
if (displayAsGallery) {
GWT.log("displayAsGallery the: " + sectionView);
ImagesSectionGallery sectionGallery = new ImagesSectionGallery(sectionView);
sectionPanelContainer.add(sectionGallery.getGalleryPanel());
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
sectionGallery.fillGallery();
}
});
// Displaying the whole section as a Map of Layers
} else if (displayAsMapOfLayers) {
GWT.log("displayAsMapOfLayers the: " + sectionView);
for (SubDocumentView subDocumentView : subDocuments) {
// String table = GeoportalDataViewerConstants.jsonToTableHTML(subDocumentView.getMetadataAsJSON());
// sectionPanelContainer.add(new HTML(table));
List<GCubeSDIViewerLayerDV> layers = subDocumentView.getListLayers();
if (layers != null) {
for (GCubeSDIViewerLayerDV gCubeLayer : layers) {
LayersSectionViewer layerSectionViewer = new LayersSectionViewer(gCubeLayer, subDocumentView);
sectionPanelContainer.add(layerSectionViewer);
//showLinkToDownloadWsContent(fileset.getName(), fileset.getListPayload());
List<GCubeSDIViewerLayerDV> layers = subDocumentView.getListLayers();
if (layers != null) {
for (GCubeSDIViewerLayerDV gCubeLayer : layers) {
LayersSectionViewer layerSectionViewer = new LayersSectionViewer(gCubeLayer,
subDocumentView);
sectionPanelContainer.add(layerSectionViewer);
// showLinkToDownloadWsContent(fileset.getName(), fileset.getListPayload());
}
}
}
}
}else {
GWT.log("displaying default the: "+sectionView);
for (SubDocumentView subDocumentView : subDocuments) {
String table = GeoportalDataViewerConstants.jsonToTableHTML(subDocumentView.getMetadataAsJSON());
sectionPanelContainer.add(new HTML(table));
List<FilesetDV> files = subDocumentView.getListFiles();
if (files != null) {
for (FilesetDV fileset : files) {
showLinkToDownloadWsContent(fileset.getName(), fileset.getListPayload());
} else {
GWT.log("displaying default the: " + sectionView);
for (SubDocumentView subDocumentView : subDocuments) {
String table = GeoportalDataViewerConstants.jsonToTableHTML(subDocumentView.getMetadataAsJSON());
sectionPanelContainer.add(new HTML(table));
List<FilesetDV> files = subDocumentView.getListFiles();
if (files != null) {
for (FilesetDV fileset : files) {
showLinkToDownloadWsContent(fileset.getGcubeProfileFieldName(), fileset.getListPayload());
}
}
}
}
} catch (Exception e) {
GWT.log("Error on rendering the section: "+e.getMessage());
}
}

View File

@ -59,9 +59,8 @@ public class TimelineManagerStatus {
RootPanel.get(GeoportalDataViewer.DIV_TIMELINE_DATA).setVisible(true);
timelineStatus.getTimelineRP().setTimelineContainerVisible(true);
}
public void hideTimelineProjectRelations() {
GWT.log("hideTimelineProjectRelations");
RootPanel.get(GeoportalDataViewer.DIV_TIMELINE_DATA).setVisible(false);

View File

@ -3,11 +3,10 @@ package org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.project.relati
import java.util.List;
import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences;
import org.gcube.application.geoportalcommon.shared.geoportal.geojson.GeoJSON;
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
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.ShowPopupOnCentroiEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowDetailsEvent.EVENT_SOURCE;
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.util.LoaderIcon;
@ -129,7 +128,9 @@ public class TimelineRelationPanel extends Composite {
public void setTimelineContainerVisible(boolean bool) {
timelineContainer.setVisible(bool);
}
/*
* Called when a project (box) is clicked into Timeline
*/
private void setSelectedProject(String theComposedProjectID) {
this.selectedTimelineProjectID = theComposedProjectID;
//selectedTimelineProjectID is the couple ProfileID,ProjectID
@ -143,30 +144,12 @@ public class TimelineRelationPanel extends Composite {
final String thePofileID = references[0];
final String theProjectID = references[1];
GeoportalItemReferences gir = new GeoportalItemReferences(theProjectID, thePofileID);
ShowDetailsEvent showDetailsEvent = new ShowDetailsEvent(gir, null, false);
GWT.log("fireEvetn: " + showDetailsEvent);
ShowDetailsEvent showDetailsEvent = new ShowDetailsEvent(gir, null, false, false,
EVENT_SOURCE.LOCATE_FROM_TIMELINE);
showDetailsEvent.setEventFromTimeline(true);
GWT.log("fireEvent: " + showDetailsEvent);
applicationBus.fireEvent(showDetailsEvent);
GeoportalDataViewerServiceAsync.Util.getInstance().getSpatialReference(thePofileID, theProjectID,
new AsyncCallback<GeoJSON>() {
@Override
public void onFailure(Throwable caught) {
// TODO Auto-generated method stub
}
@Override
public void onSuccess(GeoJSON spatialReference) {
if (spatialReference != null) {
applicationBus.fireEvent(
new ShowPopupOnCentroiEvent(thePofileID, theProjectID, spatialReference));
}
}
});
}
public String getSelectedProjectID() {
@ -175,19 +158,19 @@ public class TimelineRelationPanel extends Composite {
public static native String instanceTimeline(String idDivContainer, JSONArray jsonItems,
TimelineRelationPanel instance) /*-{
console.log('showTimeline_instanceTimeline for json items: '
+ jsonItems);
console.log('showing timeline');
//console.log('showTimeline_instanceTimeline for json items: '+jsonItems);
console.log("showTimeline_template: " + $wnd.templateHandlebars);
//console.log("showTimeline_template: " + $wnd.templateHandlebars);
// DOM element where the Timeline will be attached
var container = $doc.getElementById(idDivContainer);
console.log("showTimeline_container: " + container);
//console.log("showTimeline_container: " + container);
var myArray = $wnd.JSON.parse(jsonItems);
console.log("showTimeline_jsonItems: " + myArray);
//console.log("showTimeline_jsonItems: " + myArray);
var container = $doc.getElementById(idDivContainer);

View File

@ -15,11 +15,12 @@ import org.gcube.application.geoportalcommon.shared.WhereClause;
import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV;
import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV;
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.events.ClosedViewDetailsEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.SearchPerformedEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowDetailsEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowPopupOnCentroiEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowDetailsEvent.EVENT_SOURCE;
import org.gcube.portlets.user.geoportaldataviewer.client.util.LoaderIcon;
import org.gcube.portlets.user.geoportaldataviewer.client.util.StringUtil;
import org.gcube.portlets.user.geoportaldataviewer.shared.ResultSetPaginatedDataIDs;
@ -61,8 +62,6 @@ import com.google.gwt.user.client.ui.Widget;
*/
public class SearchFacilityUI extends Composite {
private static final int SEARCHING_LIMIT_RESULTS_TO = 50;
private static SearchFacilityPanelUiBinder uiBinder = GWT.create(SearchFacilityPanelUiBinder.class);
protected static final int MIN_LENGHT_SERCHING_STRING = 3;
@ -127,6 +126,7 @@ public class SearchFacilityUI extends Composite {
*
* @param profileID the profile ID
* @param appManagerBus the app manager bus
* @param displayByFields the display by fields
* @param sortByFields the sort by fields
* @param searchForFields the search for fields
* @param initialSortFilter the initial sort filter
@ -237,6 +237,9 @@ public class SearchFacilityUI extends Composite {
}
/**
* Reset current search.
*/
public void resetCurrentSearch() {
searchField.setText("");
resetSearch.setVisible(false);
@ -268,8 +271,9 @@ public class SearchFacilityUI extends Composite {
panelResults.clear();
panelResults.add(new HTML("<hr>"));
panelResults.add(new LoaderIcon("Searching..."));
GeoportalDataViewerServiceAsync.Util.getInstance().getListProjects(profileID, 0, SEARCHING_LIMIT_RESULTS_TO,
filter, false, new AsyncCallback<ResultSetPaginatedDataIDs>() {
GeoportalDataViewerServiceAsync.Util.getInstance().getListProjects(profileID, 0,
GeoportalDataViewerConstants.SEARCH_LIMIT_RESULTS_TO_MAXIMUM, filter, false,
new AsyncCallback<ResultSetPaginatedDataIDs>() {
@Override
public void onFailure(Throwable caught) {
@ -286,7 +290,8 @@ public class SearchFacilityUI extends Composite {
@Override
public void onSuccess(ResultSetPaginatedDataIDs result) {
appManagerBus.fireEvent(new SearchPerformedEvent(profileID, result.getResultSetProjectIDs(), false));
appManagerBus
.fireEvent(new SearchPerformedEvent(profileID, result.getResultSetProjectIDs(), false));
setSearchEnabled(true);
latestResult = result;
@ -304,18 +309,19 @@ public class SearchFacilityUI extends Composite {
String message = "";
if (allItems > returnedItems) {
message = "Too many results found. Below are " + returnedItems + " out of " + allItems
+ " results";
} else if (returnedItems>0){
message = "Your query returns too many results (" + allItems
+ "). Please find below the top " + returnedItems + ".<br>";
} else if (returnedItems > 0) {
message = "Found " + returnedItems;
message += returnedItems > 0 ? " items" : " item";
message += returnedItems > 0 ? " projects" : " project";
message += ".";
}
if (returnedItems>0) {
message += ". Projects (with a centroid) matching your search are shown on the Map";
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";
}
HTML resultMessage = new HTML(message);
resultMessage.getElement().addClassName("search_result_msg");
@ -353,11 +359,12 @@ public class SearchFacilityUI extends Composite {
public void onClick(ClickEvent event) {
GeoportalItemReferences gir = new GeoportalItemReferences(resultDoc.getProjectID(),
profileID);
//here
// here
appManagerBus.fireEvent(new ClosedViewDetailsEvent());
appManagerBus.fireEvent(new ShowDetailsEvent(gir, null, true));
appManagerBus.fireEvent(new ShowPopupOnCentroiEvent(profileID,
resultDoc.getProjectID(), resultDoc.getSpatialReference()));
appManagerBus.fireEvent(
new ShowDetailsEvent(gir, null, true, true, EVENT_SOURCE.LOCATE_SEARCHED));
// appManagerBus.fireEvent(new ShowPopupOnCentroidEvent(profileID,
// resultDoc.getProjectID(), resultDoc.getSpatialReference()));
}
});

View File

@ -0,0 +1,672 @@
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

@ -0,0 +1,28 @@
<!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

@ -0,0 +1,278 @@
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

@ -0,0 +1,29 @@
<!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

@ -2,6 +2,7 @@ package org.gcube.portlets.user.geoportaldataviewer.client.ui.dandd;
import java.util.LinkedHashMap;
import org.gcube.application.geoportalcommon.shared.geoportal.geojson.GeoJSON;
import org.gcube.application.geoportalcommon.shared.geoportal.project.TemporalReferenceDV;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync;
import org.gcube.portlets.user.geoportaldataviewer.client.events.DoActionOnDetailLayersEvent;
@ -9,6 +10,7 @@ import org.gcube.portlets.user.geoportaldataviewer.client.events.DoActionOnDetai
import org.gcube.portlets.user.geoportaldataviewer.client.events.DoActionOnDetailLayersEvent.SwapLayer;
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.util.LoaderIcon;
import org.gcube.portlets.user.geoportaldataviewer.client.util.StringUtil;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject;
@ -19,6 +21,7 @@ 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.dom.client.Element;
import com.google.gwt.dom.client.Style.FontWeight;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
@ -32,21 +35,33 @@ import com.google.gwt.event.dom.client.DropEvent;
import com.google.gwt.event.dom.client.DropHandler;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
public class DragDropLayer extends FlowPanel {
private static final String _22PX = "22px";
private static DragDropLayer dragging = null;
private static DragDropLayer draggingTarget = null;
final boolean droppable;
private Label labelLayerName;
private Image imgLayerVisible = new Image(GNAImages.ICONS.layerVisible());
private Image imgLayerInvisible = new Image(GNAImages.ICONS.layerInvisible());
private Image imgLocate = new Image(GNAImages.ICONS.locate());
private Image imgLocateNone = new Image(GNAImages.ICONS.locateNone());
private boolean locateEnabled = false;
private HTML buttonLocate = new HTML();
private DragDropLayer INSTANCE = this;
private LoaderIcon loaderIcon = new LoaderIcon("Loading features", null);
private Button draggableButton = new Button();
private HandlerManager applicationBus;
private LayerObject layerObject;
@ -61,35 +76,54 @@ public class DragDropLayer extends FlowPanel {
this.layerItem = layerObject.getLayerItem();
GWT.log("DragDropLayer for projectDV: " + layerObject.getProjectDV());
String referProject = "Project ID: " + layerObject.getProjectDV().getId();
// Checking the spatial reference
if (layerObject.getProjectDV() != null && layerObject.getProjectDV().getSpatialReference() == null) {
GeoportalDataViewerServiceAsync.Util.getInstance().getSpatialReference(layerObject.getProfileID(),
layerObject.getProjectID(), new AsyncCallback<GeoJSON>() {
@Override
public void onFailure(Throwable caught) {
// TODO Auto-generated method stub
}
@Override
public void onSuccess(GeoJSON result) {
if (result != null)
layerObject.getProjectDV().setSpatialReference(result);
}
});
}
String referProjectID = "Project ID: " + layerObject.getProjectDV().getId();
labelProject = new com.google.gwt.user.client.ui.Label("");
labelProject.setTitle(referProject);
labelProject.setTitle(referProjectID);
GeoportalDataViewerServiceAsync.Util.getInstance().getEntrySetsDocumentForProjectID(
layerObject.getProjectDV().getProfileID(), layerObject.getProjectDV().getId(), 1,
new AsyncCallback<LinkedHashMap<String, Object>>() {
@Override
public void onSuccess(LinkedHashMap<String, Object> result) {
String referProject = "";
String realProjectName = "";
if (result != null) {
for (String key : result.keySet()) {
result.get(key);
//referProject = key + ": " + result.get(key);
referProject = result.get(key)+"";
realProjectName = result.get(key)+"";
break;
}
}
if (referProject != null && !referProject.isEmpty()) {
labelProject.setText(StringUtil.ellipsize(referProject, 40));
labelProject.setTitle(referProject);
if (realProjectName != null && !realProjectName.isEmpty()) {
labelProject.setText(StringUtil.ellipsize(realProjectName, 40));
labelProject.setTitle(realProjectName);
}
}
@Override
public void onFailure(Throwable caught) {
labelProject.setText(StringUtil.ellipsize(referProject, 40));
labelProject.setTitle(referProject);
labelProject.setTitle("Error on reading the project name");
}
});
@ -120,26 +154,57 @@ public class DragDropLayer extends FlowPanel {
RangeSlider rs = new RangeSlider(applicationBus, layerItem);
rs.getElement().addClassName("range-slider");
FlexTable ft = new FlexTable();
ft.setWidget(0, 0, draggableButton);
// FlexTable ft = new FlexTable();
// ft.setWidget(0, 0, draggableButton);
draggableButton.setTitle("Drag and Drop me up or down to change my position on the Map");
imgLayerVisible.getElement().addClassName("layer-visibility-st");
imgLayerInvisible.getElement().addClassName("layer-visibility-st");
imgLocate.setWidth(_22PX);
imgLocate.setHeight(_22PX);
imgLocateNone.setWidth(_22PX);
imgLocateNone.setHeight(_22PX);
imgLocate.getElement().addClassName("layer-visibility-st");
imgLocateNone.getElement().addClassName("layer-visibility-st");
setLocateEnabledButtonImage();
setLayerVisibilityButtonImage();
// labelLayerName.getElement().getStyle().setMarginLeft(10, Unit.PX);
ft.setWidget(0, 1, buttonLayerVisibility);
ft.setWidget(0, 2, labelProject);
VerticalPanel vp = new VerticalPanel();
VerticalPanel vpInner = new VerticalPanel();
HorizontalPanel hp0 = new HorizontalPanel();
HorizontalPanel hpFunct = new HorizontalPanel();
vpInner.getElement().getStyle().setMarginLeft(47, Unit.PX);
hp0.add(draggableButton);
labelProject.getElement().getStyle().setMarginLeft(10, Unit.PX);
labelProject.getElement().getStyle().setFontWeight(FontWeight.BOLD);
hp0.add(labelProject);
hpFunct.add(buttonLayerVisibility);
hpFunct.add(buttonLocate);
hpFunct.add(loaderIcon);
setVisibleLoaderFeatures(false, null);
if(layerObject.getProjectDV().getTemporalReference()!=null) {
TemporalReferenceDV tempRef = layerObject.getProjectDV().getTemporalReference();
ft.setWidget(ft.getRowCount()+1, 2, new HTML(ProjectUtil.toHTMLCode(tempRef)));
if(tempRef.getStart()!=null || tempRef.getEnd()!=null)
vpInner.add(new HTML(ProjectUtil.toHTMLCode(tempRef)));
}
ft.setWidget(ft.getRowCount()+1, 2, labelLayerName);
ft.setWidget(ft.getRowCount()+1, 2, new SimplePanel(rs));
add(ft);
vpInner.add(labelLayerName);
// vpInner.add(new SimplePanel(rs));
vp.add(hp0);
hpFunct.getElement().getStyle().setMarginTop(5, Unit.PX);
vpInner.add(hpFunct);
vpInner.add(new SimplePanel(rs));
vp.add(vpInner);
add(vp);
// add(ft);
draggableButton.setIcon(IconType.MOVE);
buttonLayerVisibility.addClickHandler(new ClickHandler() {
@ -148,20 +213,48 @@ public class DragDropLayer extends FlowPanel {
public void onClick(ClickEvent event) {
layerVisibility = !layerVisibility;
setLayerVisibilityButtonImage();
DoActionOnDetailLayersEvent dae = new DoActionOnDetailLayersEvent(DO_LAYER_ACTION.VISIBILITY,
layerItem);
DoActionOnDetailLayersEvent dae = new DoActionOnDetailLayersEvent(DO_LAYER_ACTION.VISIBILITY, layerItem,
layerObject);
dae.setVisibility(layerVisibility);
applicationBus.fireEvent(dae);
}
});
buttonLocate.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
locateEnabled = !locateEnabled;
setLocateEnabledButtonImage();
DoActionOnDetailLayersEvent dae = new DoActionOnDetailLayersEvent(DO_LAYER_ACTION.LOCATE_LAYER,
layerItem, layerObject);
dae.setUIEventSource(INSTANCE);
setVisibleLoaderFeatures(true, null);
applicationBus.fireEvent(dae);
}
});
}
private void setLayerVisibilityButtonImage() {
buttonLayerVisibility.getElement().removeAllChildren();
if (layerVisibility) {
buttonLayerVisibility.getElement().appendChild(imgLayerVisible.getElement());
buttonLayerVisibility.setTitle("Hide the layer");
} else {
buttonLayerVisibility.getElement().appendChild(imgLayerInvisible.getElement());
buttonLayerVisibility.setTitle("Show the layer");
}
}
private void setLocateEnabledButtonImage() {
buttonLocate.getElement().removeAllChildren();
if (locateEnabled) {
buttonLocate.getElement().appendChild(imgLocate.getElement());
buttonLocate.setTitle("Unselect the layer features");
} else {
buttonLocate.getElement().appendChild(imgLocateNone.getElement());
buttonLocate.setTitle("Highlight the layer features");
}
}
@ -227,7 +320,7 @@ public class DragDropLayer extends FlowPanel {
tree.insert(source, targetIndex);
// target.setState(true);
DoActionOnDetailLayersEvent actionSwapLayers = new DoActionOnDetailLayersEvent(
DO_LAYER_ACTION.SWAP, layerItem);
DO_LAYER_ACTION.SWAP, layerItem, layerObject);
SwapLayer swapLS = new DoActionOnDetailLayersEvent.SwapLayer(dragging.getLayerItem(),
sourceIndex);
SwapLayer swapLT = new DoActionOnDetailLayersEvent.SwapLayer(draggingTarget.getLayerItem(),
@ -246,4 +339,17 @@ public class DragDropLayer extends FlowPanel {
return layerItem;
}
/**
* Sets the visible loader features.
*
* @param bool the bool
* @param msg the msg
*/
public void setVisibleLoaderFeatures(boolean bool, String msg) {
loaderIcon.setVisible(bool);
if(msg!=null)
loaderIcon.setText(msg);
}
}

View File

@ -1,5 +1,6 @@
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.DO_LAYER_ACTION;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
@ -38,8 +39,8 @@ public class RangeSlider extends Composite {
sliderId = "slider-" + Random.nextInt();
theSlider.addClassName("slider");
theSlider.setId(sliderId);
theSlider.setTitle("Set opacity of "+layer.getName());
theSlider.setTitle("Set opacity of the layer");
theSlider.setPropertyObject("value", GeoportalDataViewerConstants.INITIAL_LAYER_OPACITY*100);
bindEvents();
}
@ -54,11 +55,11 @@ public class RangeSlider extends Composite {
if (Event.ONMOUSEUP == event.getTypeInt()) {
GWT.log("Event.ONMOUSEUP");
DoActionOnDetailLayersEvent actionChangeOpacity = new DoActionOnDetailLayersEvent(
DO_LAYER_ACTION.OPACITY, layer);
DO_LAYER_ACTION.OPACITY, layer, null);
int value = Integer.parseInt((String) theSlider.getPropertyObject("value"));
//GWT.log("opacity int value: "+value);
double opacity = (double) ((double) value/100);
GWT.log("opacity double value: "+opacity);
// GWT.log("opacity int value: "+value);
double opacity = (double) ((double) value / 100);
GWT.log("opacity double value: " + opacity);
actionChangeOpacity.setOpacity(opacity);
applicationBus.fireEvent(actionChangeOpacity);
}

View File

@ -396,7 +396,7 @@ public class DialogShareableLink extends Composite {
private native void copyToClipboard(String myDivId) /*-{
var copyText = $doc.getElementById(myDivId);
console.log("text copied is :" + copyText.value);
//console.log("text copied is :" + copyText.value);
copyText.select();
//For mobile devices
copyText.setSelectionRange(0, 99999);

View File

@ -0,0 +1,359 @@
package org.gcube.portlets.user.geoportaldataviewer.client.ui.layercollection;
import java.util.HashMap;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.IndexLayerDV;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewer;
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.OpenCollectionEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil;
import org.gcube.portlets.user.geoportaldataviewer.shared.GCubeCollection;
import org.gcube.portlets.user.geoportaldataviewer.shared.ViewerConfiguration;
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 LayerCollectionPanel.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* May 15, 2023
*/
public class LayerCollectionPanel extends Composite {
public static String COLORSCALERANGE = "COLORSCALERANGE";
@UiField
HTMLPanel basePanel;
@UiField
HTMLPanel stylePanel;
@UiField
HTMLPanel styleListPanel;
@UiField
HTMLPanel statisticPanel;
@UiField
Button buttonLegend;
@UiField
ScrollPanel legendPanel;
private CheckBox checkbox;
private GeoInformationForWMSRequest geoInformation;
private static LayerCollectionPanelUiBinder uiBinder = GWT.create(LayerCollectionPanelUiBinder.class);
private ListBox listBoxStyles = new ListBox();
private String layerName;
private GCubeCollection gcubeCollection;
private HandlerManager applicationBus;
/**
* The Interface LayerCollectionPanelUiBinder.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jan 16, 2023
*/
interface LayerCollectionPanelUiBinder extends UiBinder<Widget, LayerCollectionPanel> {
}
/**
* Instantiates a new layer collection panel.
*
* @param coll the coll
* @param applicationBus the application bus
*/
public LayerCollectionPanel(final GCubeCollection coll, HandlerManager applicationBus) {
initWidget(uiBinder.createAndBindUi(this));
this.applicationBus = applicationBus;
buttonLegend.setType(ButtonType.LINK);
legendPanel.setVisible(false);
statisticPanel.setVisible(false);
GWT.log("Found available collection " + coll);
String label = coll.getUcd().getName();
final String collectionID = coll.getUcd().getId(); // collectionID == UCD_Id
checkbox = new CheckBox(label);
checkbox.setId("gcubeCollectionSelector_" + collectionID);
checkbox.getElement().getStyle().setFontWeight(FontWeight.BOLD);
checkbox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
GWT.log("Collection selector flag changed to value : " + event.toDebugString());
GWT.log("Collection ID is : " + collectionID + ", event value: " + event.getValue());
if (event.getValue()) {
// OPEN COLLECTION
applicationBus.fireEvent(new OpenCollectionEvent(collectionID));
enableLayerStyle(true);
} else {
// CLOSE COLLECTION
hideStyleLegend();
resetLayerStyle();
enableLayerStyle(false);
applicationBus.fireEvent(new CloseCollectionEvent(collectionID));
}
}
});
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();
final GCubeCollection toOpen = theConfig.getAvailableCollections().get(collectionID);
// Check if indexes is empty
if (toOpen.getIndexes() == null || toOpen.getIndexes().isEmpty()) {
GWT.log("Unexpected empty indexes in collection " + toOpen);
Window.alert("Cannot open collection index layer for " + toOpen.getUcd().getName() + ".");
return;
}
this.gcubeCollection = toOpen;
// TODO Get Default Index Layer
// For now we just take the first - only 1 is expected
IndexLayerDV layer = toOpen.getIndexes().get(0);
// Open Index Layer
HashMap<String, String> ogcLinks = layer.getLayer().getOgcLinks();
final String wmsLink = ogcLinks.get("wms");
this.layerName = URLUtil.getValueOfParameter("layers", wmsLink);
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);
}
}
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()) {
hideStyleLegend();
} else {
legendPanel.setVisible(true);
loadLegend(wmsLink);
}
}
});
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.
*
* @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

@ -0,0 +1,25 @@
<!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;
}
</ui:style>
<g:HTMLPanel>
<g:HTMLPanel ui:field="basePanel">
</g:HTMLPanel>
<g:HTMLPanel ui:field="statisticPanel" addStyleNames="statistic-style-panel">
</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

@ -0,0 +1,59 @@
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

@ -1,7 +1,7 @@
package org.gcube.portlets.user.geoportaldataviewer.client.util;
/**
* The Class URLUtil.
* The Class HTTPRequestUtil.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
@ -35,6 +35,20 @@ public class URLUtil {
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.
*

View File

@ -0,0 +1,50 @@
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

@ -1,68 +0,0 @@
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

@ -1,162 +0,0 @@
/**
*
*/
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

@ -27,6 +27,7 @@ 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.RelationshipNavigationObject;
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.rest.Projects;
import org.gcube.application.geoportalcommon.ConvertToDataValueObjectModel;
@ -35,32 +36,47 @@ import org.gcube.application.geoportalcommon.ProjectDVBuilder;
import org.gcube.application.geoportalcommon.geoportal.GeoportalClientCaller;
import org.gcube.application.geoportalcommon.geoportal.ProjectsCaller;
import org.gcube.application.geoportalcommon.geoportal.UseCaseDescriptorCaller;
import org.gcube.application.geoportalcommon.geoportal.access.GeportalCheckAccessPolicy;
import org.gcube.application.geoportalcommon.geoportal.access.GeportalCheckAccessPolicy.ACCESS_POLICY;
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences;
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
import org.gcube.application.geoportalcommon.shared.geoportal.ConfigurationDV;
import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV;
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.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.materialization.GCubeSDILayer;
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.innerobject.PayloadDV;
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.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.HandlerDeclarationDV;
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.UseCaseDescriptorDV;
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
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.geoportaldatamapper.GcubeProfilesPerUCDIdCache;
import org.gcube.application.geoportaldatamapper.Geoportal_JSON_Mapper;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
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.GisMakers;
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.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.TemporalComparatorUtil;
import org.gcube.portlets.user.geoportaldataviewer.shared.GCubeCollection;
@ -70,6 +86,7 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.ResultSetPaginatedData
import org.gcube.portlets.user.geoportaldataviewer.shared.ViewerConfiguration;
import org.gcube.portlets.user.geoportaldataviewer.shared.faults.ControlledError;
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.LayerObject;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObjectType;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.FeatureRow;
@ -110,6 +127,52 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
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.
*
@ -200,7 +263,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
public GeoInformationForWMSRequest loadGeoInfoForWmsRequest(String wmsLink, String layerName) throws Exception {
try {
WMSUrlValidator validator = new WMSUrlValidator(wmsLink, layerName);
String wmsServiceHost = validator.getWmsServiceHost();
String wmsServiceServiceEndpoint = validator.getWmsServiceEndPoint();
String validWMSRequest = validator.parseWMSRequest(true, true);
layerName = validator.getLayerName();
String versionWms = validator.getValueOfParsedWMSParameter(WmsParameters.VERSION);
@ -227,8 +290,8 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
? new ZAxis(layerZAxis.getUnits(), layerZAxis.isPositive(), layerZAxis.getValues())
: null;
return new GeoInformationForWMSRequest(wmsServiceHost, validWMSRequest, layerName, versionWms, crs,
mapWmsNotStandard, styles, styles.isNcWms(), zAxis);
return new GeoInformationForWMSRequest(wmsServiceServiceEndpoint, validWMSRequest, layerName, versionWms,
crs, mapWmsNotStandard, styles, styles.isNcWms(), zAxis);
} catch (Exception e) {
String msg = "An error occurred during wms request validation for layer: " + layerName;
LOG.error(msg, e);
@ -318,9 +381,9 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
if (item.getProfileID() == null)
throw new Exception("Bad request, the profileID is null");
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
String gcubeScope = SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
GeoportalCommon gc = new GeoportalCommon();
return gc.getPublicLinksFor(item, true);
return gc.getPublicLinksFor(gcubeScope, item, true);
} catch (Exception e) {
LOG.error("Error on getPublicLinksFor for: " + item, e);
@ -345,7 +408,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
* @param layerObjects the layer objects
* @param mapSrsName the map srs name
* @param selectBBOX the select BBOX
* @param maxWFSFeature the max WFS feature
* @param maxWFSFeature the max WFS feature. If 0 means all feature
* @param zoomLevel the zoom level
* @return the WFS features
*/
@ -434,50 +497,53 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
try {
LOG.debug("Checking configuration for collection " + u.getId());
SessionUtil.addCollectionToSession(getThreadLocalRequest(), u);
Projects<Project> p = projects(u.getId()).build();
UseCaseDescriptorDV ucd = ConvertToDataValueObjectModel.toUseCaseDescriptorDV(u, null);
UseCaseDescriptorDV ucdDV = ConvertToDataValueObjectModel.toUseCaseDescriptorDV(u, null);
Configuration ucdConfig = p.getConfiguration();
GCubeCollection coll = new GCubeCollection();
coll.setUcd(ucd);
coll.setUcd(ucdDV);
// TODO TO Check index flag should be in configuration or evaluated according to
// user credentials
String indexFlag = "public"; // default
CENTROID_LAYER_INDEX_FLAG setIndexFlag = null;
GeoportalServiceIdentityProxy gsp = getGeoportalServiceProxy();
if (gsp.isUser()) {
indexFlag = "internal";
LOG.info("user logged - using indexFlag: " + indexFlag);
setIndexFlag = CENTROID_LAYER_INDEX_FLAG.PRIVATE;
LOG.info("user logged - using indexFlag: " + setIndexFlag);
} else if (gsp.isIAMClient()) {
indexFlag = "public";
LOG.info("user not logged - using indexFlag: " + indexFlag);
setIndexFlag = CENTROID_LAYER_INDEX_FLAG.PUBLIC;
LOG.info("user not logged - using indexFlag: " + setIndexFlag);
}
// TODO constant
coll.setIndexes(new ArrayList());
LOG.debug(
"Checking if " + u.getId() + " is GIS Indexed. Index flag needed is " + indexFlag);
LOG.debug("Checking if " + u.getId() + " is GIS Indexed. Index flag needed is '"
+ setIndexFlag + "'");
IndexLayerDV toAdd = getLayerIndex(ucdConfig, setIndexFlag);
if (toAdd != null) {
coll.getIndexes().add(toAdd);
}
for (Index index : ucdConfig.getIndexes()) {
try {
IndexLayerDV toAdd = ConvertToDataValueObjectModel.convert(index);
if (toAdd.getFlag().equals(indexFlag)) {
coll.getIndexes().add(toAdd);
}
} catch (Exception e) {
LOG.debug("Skipping invalid index ", e);
} catch (Throwable t) {
LOG.error("Unable to check index ", t);
// Using the public centroid layer as default
if (coll.getIndexes().isEmpty()) {
LOG.info("No available GIS Index for collection " + coll.getUcd().getName()
+ " with flag " + setIndexFlag.getId());
setIndexFlag = CENTROID_LAYER_INDEX_FLAG.PUBLIC;
LOG.info("Prevent fallback - getting the GIS index with flag '" + setIndexFlag.getId()
+ "' available");
toAdd = getLayerIndex(ucdConfig, setIndexFlag);
if (toAdd != null) {
coll.getIndexes().add(toAdd);
}
}
// Return only if gis indexed
if (coll.getIndexes().isEmpty())
LOG.info("No available GIS Index for collection " + coll.getUcd().getName());
else
if (!coll.getIndexes().isEmpty())
config.getAvailableCollections().put(coll.getUcd().getId(), coll);
} catch (Throwable t) {
@ -497,6 +563,201 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
}.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;
}
// public Map<String, List<GroupedLayersDV>> getAvaiableCrossFilteringLayers() {
//
// Map<String, List<GroupedLayersDV>> mapProfileIDOvelayLayers = new LinkedHashMap<>();
//
// // Reading UCDs Collections from the session
// Map<String, UseCaseDescriptor> ucdCollections = SessionUtil.getAvailableCollections(getThreadLocalRequest());
//
// for (String profileId : ucdCollections.keySet()) {
//
// UseCaseDescriptor u = ucdCollections.get(profileId);
//
// // Loading geoportal_grouped_overlay_layers if exists
// GEOPORTAL_DATA_HANDLER theHandler = GEOPORTAL_DATA_HANDLER.geoportal_grouped_cross_filtering;
// List<HandlerDeclaration> handlers = u.getHandlersByType(theHandler.getType());
//
// if (handlers != null && handlers.size() > 0) {
// // Loading Handler gcube_profiles
// HandlerDeclaration handler = handlers.get(0);
// List<GroupedLayersDV> listGroupedCustomLayers = null;
// try {
//
// HandlerDeclarationDV handlerDV = ConvertToDataValueObjectModel.toHandlerDeclarationDV(handler, u,
// GEOPORTAL_CONFIGURATION_TYPE.grouped_overlay_layers);
//
// if (handler != null) {
// ConfigurationDV<?> config = handlerDV.getConfiguration();
// switch (config.getConfigurationType()) {
// case grouped_overlay_layers:
// listGroupedCustomLayers = (List<GroupedLayersDV>) config.getConfiguration();
// break;
// default:
// break;
// }
// }
// } catch (Exception e) {
// LOG.error("Error on loading {} config for ucd Id {}. Returning null",
// GEOPORTAL_CONFIGURATION_TYPE.grouped_overlay_layers, u.getId());
// }
//
// mapProfileIDOvelayLayers.put(profileId, listGroupedCustomLayers);
// } else {
// LOG.warn("No handler " + theHandler + "found into UCD " + u.getId() + ", continue...");
// mapProfileIDOvelayLayers.put(profileId, null);
// }
// }
//
// return mapProfileIDOvelayLayers;
//
// }
/**
* 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.
*
@ -603,7 +864,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
*/
@Override
protected void onBeforeRequestDeserialized(String serializedRequest) {
LOG.info("onBeforeRequestDeserialized called");
LOG.debug("onBeforeRequestDeserialized called");
String scope = "";
try {
@ -642,7 +903,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
// Saving client PROJECTION
LinkedHashMap<String, Object> originalProjection = filter.getProjection();
// Setting PROJECTION ONLY FOR PROEJCT ID
LinkedHashMap<String, Object> projectionForIDs = new LinkedHashMap<String, Object>();
projectionForIDs.put(Project.ID, 1);
@ -662,26 +923,26 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
LOG.info("Total Docs read from config: " + totalProjectForProfile);
// FIRST QUERY TO RETRIEVE IDs
// LIMIT IS NULL MEANS THAT IT IS EQUAL TO NUMBER TOTAL OF DOCUMENTS
final Iterator<Project> projectsIDs = client.queryOnMongo(theProfileID, totalProjectForProfile, start, null,
// LIMIT IS NULL AND START = 0 MEANS THAT IT IS EQUAL TO NUMBER TOTAL OF
// DOCUMENTS
final Iterator<Project> projectsIDs = client.queryOnMongo(theProfileID, totalProjectForProfile, 0, null,
filter);
//Getting the Project IDs from the Iterable
// Getting the Project IDs from the Iterable
Iterable<Project> itP = () -> projectsIDs;
Stream<Project> targetStream = StreamSupport.stream(itP.spliterator(), false);
List<String> listProjectIDs = targetStream.map(Project::getId).collect(Collectors.toList());
searchedDataIDs.setResultSetProjectIDs(listProjectIDs);
//Total number of Projects are exactly listProjectIDs.size()
// Total number of Projects are exactly listProjectIDs.size()
int totalItems = listProjectIDs.size();
searchedDataIDs.setTotalItems(totalItems);
LOG.info("Total IDs read from query: " + totalItems);
//NOW PERFORMING THE (REAL) SECOND QUERY FROM CLIENT
// NOW PERFORMING THE (REAL) SECOND QUERY FROM CLIENT
// SETTING ORIGINAL PROJECTION FROM CLIENT
filter.setProjection(originalProjection);
// LIMIT IS FROM CLIENT
Iterator<Project> projects = client.queryOnMongo(theProfileID, totalItems, start, limit,
filter);
Iterator<Project> projects = client.queryOnMongo(theProfileID, totalItems, start, limit, filter);
searchedDataIDs.setClientStartIndex(start);
searchedDataIDs.setLimit(limit);
@ -749,24 +1010,39 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
try {
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
String username = null;
try {
SessionUtil.getCurrentUser(this.getThreadLocalRequest()).getUsername();
username = SessionUtil.getCurrentUser(this.getThreadLocalRequest()).getUsername();
} catch (Exception e) {
LOG.info("User not found in session, the userName for cecking policy will be null");
LOG.info("User not found in session, the userName for checking the policy will be null");
}
LOG.info("Trying to get project for id " + profileID);
LOG.trace("Trying to get project for id " + projectID);
new GeoportalServiceIdentityProxy(this.getThreadLocalRequest());
Project theProject = GeoportalClientCaller.projects().getProjectByID(profileID, projectID);
String jsonDocument = theProject.getTheDocument().toJson();
LOG.trace("JSON Project is: " + jsonDocument);
String materializationParentJSONPath = String.format("%s..%s", Geoportal_JSON_Mapper.JSON_$_POINTER,
Geoportal_JSON_Mapper.FILESET);
LOG.debug("Checking access policy for the layer...");
ACCESS_POLICY accessPolicy = GeportalCheckAccessPolicy.accessPolicyFromSessionLogin(username);
LOG.info("Access policy for discovering the layers is: " + accessPolicy);
listLayers = Geoportal_JSON_Mapper.readGcubeSDILayersForFileset(materializationParentJSONPath,
jsonDocument);
String filesetParentJSONPath = null;
// (see ticket #24390)
if (accessPolicy.equals(ACCESS_POLICY.OPEN)) {
// Filtering for ACCESS_POLICY.OPEN from the fileset when the username is not in
// session. IAM
// identity is running, no logged in user.
filesetParentJSONPath = String.format("%s..%s[?(@._access._policy=='%s')]",
Geoportal_JSON_Mapper.JSON_$_POINTER, Geoportal_JSON_Mapper.FILESET, accessPolicy);
} else {
// Accessing to all fileset (with any ACCESS_POLICY) when the user is logged in.
filesetParentJSONPath = String.format("%s..%s", Geoportal_JSON_Mapper.JSON_$_POINTER,
Geoportal_JSON_Mapper.FILESET);
}
listLayers = Geoportal_JSON_Mapper.readGcubeSDILayersForFileset(filesetParentJSONPath, jsonDocument);
LOG.info("For projectID " + projectID + ", returning " + listLayers.size() + " layer/s");
return listLayers;
@ -807,7 +1083,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
try {
SessionUtil.getCurrentUser(this.getThreadLocalRequest()).getUsername();
} catch (Exception e) {
LOG.info("User not found in session, the userName for cecking policy will be null");
LOG.info("User not found in session, the userName for checking the policy will be null");
}
LOG.info("Trying to get project for id " + profileID);
@ -856,7 +1132,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
try {
userName = SessionUtil.getCurrentUser(this.getThreadLocalRequest()).getUsername();
} catch (Exception e) {
LOG.info("User not found in session, the userName for cecking policy will be null");
LOG.info("User not found in session, the userName for checking the policy will be null");
}
LOG.info("Trying to get project for id " + profileID);
@ -878,8 +1154,10 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
theProjectDV.setProfileName(ucd.getName());
TemporalReferenceDV temporalReference = temporalReferenceForProject(theProject);
if (temporalReference == null)
temporalReference = new TemporalReferenceDV();
theProjectDV.setTemporalReference(temporalReference);
ProjectView projectView = Geoportal_JSON_Mapper.loadProjectView(theProjectDV, scope, userName);
@ -920,7 +1198,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
try {
userName = SessionUtil.getCurrentUser(this.getThreadLocalRequest()).getUsername();
} catch (Exception e) {
LOG.info("User not found in session, the userName for cecking policy will be null");
LOG.info("User not found in session, the userName for checking the policy will be null");
}
LOG.info("Trying to get project for id " + profileID);
@ -972,9 +1250,15 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
@Override
public List<GeoNaSpatialQueryResult> getDataResult(List<LayerObject> layerObjects, String mapSrsName,
BoundsMap selectBBOX, int maxWFSFeature, double zoomLevel) throws Exception {
LOG.info("getDataResult called for layerObjects: " + layerObjects);
LOG.info("getDataResult called");
for (LayerObject layerObject : layerObjects) {
LOG.info("ProfileID: " + layerObject.getProfileID() + ", ProjectID: " + layerObject.getProjectID()
+ ", TYPE: " + layerObject.getType());
}
if (LOG.isDebugEnabled()) {
LOG.info("getDataResult parmeters layerObjects: " + layerObjects,
LOG.debug("getDataResult parmeters layerObjects: " + layerObjects,
", mapSrsName: " + mapSrsName + ", selectBBOX: " + selectBBOX + ", maxWFSFeature: " + maxWFSFeature
+ ", zoomLevel: " + zoomLevel);
}
@ -1000,8 +1284,11 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
switch (layerObject.getType()) {
case INDEX_LAYER: {
// Expected 1 feature
// Expected more than 1 feature for the BBOX of the Map
FeatureRow fRow = features.get(0);
// using only the first feature returned from BBOX of the Map
// when querying the centroid layers
geoDAO.setFeatures(Arrays.asList(fRow));
if (fRow.getMapProperties() != null) {
List<String> productIDs = fRow.getMapProperties()
.get(GeoportalDataViewerConstants.PROJECT_ID_KEY_FEATURE);
@ -1129,10 +1416,11 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
}
LOG.info("returning " + listDAO.size() + " geona data objects");
if(LOG.isDebugEnabled())
LOG.info("returning " + listDAO + " geona data objects");
if (LOG.isDebugEnabled()) {
LOG.debug("returning " + listDAO + " geona data objects");
}
return listDAO;
}
@ -1241,7 +1529,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
break;
Entry<String, Object> entry = entrySetsIt.next();
documentAsMap.put(entry.getKey(), entry.getValue());
documentAsMap.put(entry.getKey(), entry.getValue() != null ? entry.getValue().toString() : null);
i++;
}
@ -1511,4 +1799,83 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
return null;
}
/**
* Gets the WFS request.
*
* @param layerItem the layer item
* @param mapSrsName the map srs name
* @param mapBBOX the map BBOX
* @param maxFeatures the max features. If 0 means all feature
* @param outputFormat the output format
* @return the WFS request
*/
@Override
public String getWFSRequest(LayerItem layerItem, String mapSrsName, BoundsMap mapBBOX, int maxFeatures,
String outputFormat) {
LOG.info("getWFSRequest called");
if (LOG.isDebugEnabled()) {
LOG.debug("getWFSRequest parameters layerItem name: " + layerItem.getName(), ", mapSrsName: " + mapSrsName
+ ", mapBBOX: " + mapBBOX + ", maxFeatures: " + maxFeatures + ", outputFormat: " + outputFormat);
}
String url = GisMakers.buildWFSFeatureQuery(layerItem, mapSrsName, mapBBOX, maxFeatures, outputFormat);
LOG.info("returning WFSRequest: " + 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.
*
* @param layerItem the layer item
* @param mapSrsName the map srs name
* @param mapBBOX the map BBOX
* @param maxFeatures the max features
* @param outputFormat the output format
* @return the WFS response
*/
@Override
public String getWFSResponse(LayerItem layerItem, String mapSrsName, BoundsMap mapBBOX, int maxFeatures,
String outputFormat) {
LOG.info("getWFSResponse called");
if (LOG.isDebugEnabled()) {
LOG.debug("getWFSResponse parameters layerItem name: " + layerItem.getName(), ", mapSrsName: " + mapSrsName
+ ", mapBBOX: " + mapBBOX + ", maxFeatures: " + maxFeatures + ", outputFormat: " + outputFormat);
}
String url = getWFSRequest(layerItem, mapSrsName, mapBBOX, maxFeatures, outputFormat);
return HTTPRequestUtil.getResponse(url);
}
@Override
public Integer getCountFor(String profileID, String phase, String status) {
LOG.debug("getCountFor profileID: " + profileID + ", phase: " + phase + ", status: " + status + "called");
Integer integer = null;
try {
new GeoportalServiceIdentityProxy(this.getThreadLocalRequest());
integer = GeoportalClientCaller.projects().getCountByPhaseFor(profileID, phase, status);
LOG.info("getCountFor profileID: " + profileID + ", phase: " + phase + ", status: " + status
+ " returning: " + integer);
} catch (Exception e) {
LOG.error("Error occurred in getCountFor for profileID: " + profileID, e);
}
return integer;
}
}

View File

@ -1,973 +0,0 @@
package org.gcube.portlets.user.geoportaldataviewer.server;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.function.Function;
import org.bson.Document;
import org.gcube.application.geoportal.client.utils.Serialization;
import org.gcube.application.geoportal.common.model.document.access.Access;
import org.gcube.application.geoportal.common.model.document.access.AccessPolicy;
import org.gcube.application.geoportalcommon.ConvertToDataValueObjectModel;
import org.gcube.application.geoportalcommon.geoportal.access.GeportalCheckAccessPolicy;
import org.gcube.application.geoportalcommon.geoportal.serdes.Payload;
import org.gcube.application.geoportalcommon.shared.geoportal.config.FilePathDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.GcubeProfileDV;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.GCubeSDIViewerLayerDV;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.BBOXDV;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.FilesetDV;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.PayloadDV;
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_CONFIGURATION_TYPE;
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.SubDocumentView;
import org.gcube.portlets.user.geoportaldataviewer.server.GeoportalDataViewerServiceImpl.ImageDetector;
import org.gcube.portlets.user.geoportaldataviewer.server.util.URLParserUtil;
import org.gcube.portlets.user.geoportaldataviewer.shared.MetaDataProfileBeanExt;
import org.gcube.portlets.user.geoportaldataviewer.shared.ProjectEdit;
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean;
import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetadataFieldWrapper;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.jayway.jsonpath.JsonPath;
import com.jayway.jsonpath.spi.json.JsonOrgJsonProvider;
/**
* The Class Geoportal_JSON_Mapper.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Oct 24, 2022
*/
public class Geoportal_JSON_Mapper {
public static final String _PAYLOADS = "_payloads";
public static final String _MATERIALIZATIONS = "_materializations";
private static final Logger LOG = LoggerFactory.getLogger(Geoportal_JSON_Mapper.class);
public static final String FILESET = "fileset";
public static final String _OGC_LINKS = "_ogcLinks";
public static final String _BBOX = "_bbox";
public static final String _TYPE = "_type";
public static final String JSON_$_POINTER = "$";
public static final String _THEDOCUMENT = "_theDocument";
public static ProjectEdit loadProjectEdit(ProjectDV theProjectDV, String scope, String username) throws Exception {
String theWholeProjectAsJSON = theProjectDV.getTheDocument().getDocumentAsJSON();
LOG.debug("theProjectDV as JSON: " + theWholeProjectAsJSON);
LOG.debug("theProjectDV as MAP: " + theProjectDV.getTheDocument().getDocumentAsMap());
ProjectEdit projectView = new ProjectEdit();
projectView.setTheProjectDV(theProjectDV);
LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>> linkedMap_UCDId_gCubeProfiles = GcubeProfilesPerUCDIdCache
.get(scope);
// NO UCD defined, applying default
if (linkedMap_UCDId_gCubeProfiles.size() == 0) {
LOG.warn("No " + GEOPORTAL_CONFIGURATION_TYPE.gcube_profiles + " found in the UCD");
LOG.info("Applying default business logic to display the project");
SectionView sectionView = new SectionView();
sectionView.setSectionTitle("Document");
Document sectionDoc = Document.parse(theProjectDV.getTheDocument().getDocumentAsJSON());
// Creating one Project with one SectionView and SubDocumentView
String wholeSectionDoc = sectionDoc.toJson();
List<FilesetDV> listFiles = new ArrayList<FilesetDV>();
// Reading Fileset _payloads
String filesetJSONPath = String.format("%s.%s", JSON_$_POINTER, FILESET);
List<Payload> listPayloads = readPayloadsForFileset(filesetJSONPath, wholeSectionDoc);
FilesetDV filesetDV = new FilesetDV();
filesetDV.setName(FILESET);
for (Payload payload : listPayloads) {
PayloadDV payloadDV = ConvertToDataValueObjectModel.toPayloadDV(payload);
filesetDV.addPayloadDV(payloadDV);
listFiles.add(filesetDV);
}
}
List<GcubeProfilesMetadataForUCD> listProfilesBean = linkedMap_UCDId_gCubeProfiles
.get(theProjectDV.getProfileID());
com.jayway.jsonpath.Configuration configuration = com.jayway.jsonpath.Configuration.builder()
.jsonProvider(new JsonOrgJsonProvider()).build();
//LinkedHashMap<Integer, MetaDataProfileBeanExt> mapOfProfilesBeanExt = new LinkedHashMap<Integer, MetaDataProfileBeanExt>();
ArrayList<MetaDataProfileBeanExt> listOfProfilesBeanExt = new ArrayList<MetaDataProfileBeanExt>();
// Reading the Project according to list of Profile defined in the UCD
for (GcubeProfilesMetadataForUCD gcubeProfileMetaForUCD : listProfilesBean) {
GcubeProfileDV gcubeProfileDV = gcubeProfileMetaForUCD.getGcubeProfile();
// SectionView sectionView = new SectionView();
// sectionView.setSectionTitle(gcubeProfileDV.getSectionTitle());
System.out.println("\n\n##### Sto creando la sezione: "+gcubeProfileDV.getSectionTitle());
LOG.debug("\n\nThe profile is: " + gcubeProfileDV);
// Building JSON/section full PATH and section name
String sectionJSONPath = "";
String parentPathFromProfile = gcubeProfileDV.getParentName() == null ? "" : gcubeProfileDV.getParentName();
String theSectionName = gcubeProfileDV.getSectionName();
if (theSectionName.compareTo(JSON_$_POINTER) == 0 || theSectionName.compareTo(JSON_$_POINTER + ".") == 0) {
sectionJSONPath = JSON_$_POINTER;
theSectionName = "";
} else {
sectionJSONPath = String.format("%s%s",
parentPathFromProfile.endsWith(".") ? parentPathFromProfile : parentPathFromProfile + ".",
theSectionName);
}
LOG.debug("The sectionJSONPath is: " + sectionJSONPath);
JsonPath theSectionJsonPath = null;
Object data = null;
try {
theSectionJsonPath = JsonPath.compile(sectionJSONPath);
data = theSectionJsonPath.read(theWholeProjectAsJSON, configuration);
} catch (Exception e) {
LOG.warn("Error on searching the section " + sectionJSONPath + " in the JSON Project: "
+ theWholeProjectAsJSON);
continue;
}
LOG.debug("Data is instace of: " + data.getClass());
LOG.debug("data to string: " + data.toString());
// Splitting the General Document in bson.Document according to list of
// GcubeProfiles
List<Document> listBSONDocument = new ArrayList<Document>();
if (data instanceof org.json.JSONObject) {
String jsonString = data.toString();
LOG.debug("the JSON to string: " + jsonString);
Document sectionDoc = Document.parse(jsonString);
listBSONDocument.add(sectionDoc);
} else if (data instanceof org.json.JSONArray) {
org.json.JSONArray dataArray = (org.json.JSONArray) data;
for (int i = 0; i < dataArray.length(); i++) {
String jsonString = dataArray.get(i).toString();
LOG.debug("the array " + i + " JSON to string: " + jsonString);
Document sectionDoc = Document.parse(jsonString);
listBSONDocument.add(sectionDoc);
}
}
LOG.debug("Result for " + gcubeProfileDV.getSectionName() + " is: " + listBSONDocument);
List<MetaDataProfileBean> theProfileBeans = gcubeProfileMetaForUCD.getListMetadataProfileBean();
MetaDataProfileBean theProfileBean = theProfileBeans.get(0);
// For each bson.Document filling the MetaDataProfileBean and its file
for (int i = 0; i < listBSONDocument.size(); i++) {
System.out.println("DOCUMENT number "+i+ " of the section: "+theProfileBean.getTitle());
MetaDataProfileBeanExt theProfileBeanExt = new MetaDataProfileBeanExt();
theProfileBeanExt.setCategories(theProfileBean.getCategories());
theProfileBeanExt.setTitle(theProfileBean.getTitle());
theProfileBeanExt.setType(theProfileBean.getType());
// System.out.println("\nPRINTING PROJECT VIEW ON START: ");
// for (int j = 0; j < listOfProfilesBeanExt.size(); j++) {
// MetaDataProfileBeanExt metaDataProfileBeanExt = listOfProfilesBeanExt.get(j);
// System.out.println("MetaDataProfileBeanExt index: " + j + " "+metaDataProfileBeanExt.getType() +" "+metaDataProfileBeanExt.hashCode());
// int z = 0;
// for (MetadataFieldWrapper mfw : metaDataProfileBeanExt.getMetadataFields()) {
// System.out.println("\t MetadataFieldWrapper index: " + z++ + " " + mfw);
// }
// }
Document fromSectionDoc = listBSONDocument.get(i);
LOG.debug("\n\nNew section DOC for index " + i + " is: " + new JSONObject(fromSectionDoc.toJson()).toString(2));
//Creating the corresponding MetaDataProfileBeanExt for each section
//Reading policy and license statically
//eg. "_access":{"_policy":"OPEN","_license":"CC0-1.0"}}
Document docAccess = null;
Access access = null;
try {
docAccess = fromSectionDoc.get("_access", Document.class);
System.out.println("docAccess is: "+docAccess);
access = new Access();
access.setPolicy(AccessPolicy.valueOf(docAccess.getString("_policy")));
access.setLicense(docAccess.getString("_license"));
// Access. access.get("_policy");
// access.get("_license");
System.out.println("access is: "+access);
}catch (Exception e) {
e.printStackTrace();
}
//List<MetadataFieldWrapper> copyOfMetadataFields = new ArrayList<MetadataFieldWrapper>(theProfileBean.getMetadataFields());
//int forIndex = 0;
List<MetadataFieldWrapper> cloneListOfMFW = cloneList(theProfileBean.getMetadataFields());
for (MetadataFieldWrapper metadataField : cloneListOfMFW) {
String theFieldName = metadataField.getFieldId() != null ? metadataField.getFieldId()
: metadataField.getFieldName();
LOG.debug("reading theFieldName: " + theFieldName);
Object theOBJFieldValue = fromSectionDoc.get(theFieldName);
metadataField.setCurrentValue(theOBJFieldValue+"");
if(access!=null) {
if(theFieldName.equalsIgnoreCase("policy")) {
metadataField.setCurrentValue(access.getPolicy().name());
}else if(theFieldName.equalsIgnoreCase("licenseID")) {
metadataField.setCurrentValue(access.getLicense());
}
}
//copyOfMetadataFields.set(forIndex++, metadataField);
}
LOG.debug("Before assigning it Metadata fields are: "+cloneListOfMFW);
theProfileBeanExt.setMetadataFields(new ArrayList<MetadataFieldWrapper>(cloneListOfMFW));
LOG.debug("Metadata fields are: "+theProfileBeanExt.getMetadataFields());
// Reading filePaths
List<FilePathDV> filePaths = gcubeProfileDV.getFilePaths();
List<GCubeSDIViewerLayerDV> listLayers = new ArrayList<GCubeSDIViewerLayerDV>();
// READING fileset* field ACCORDING TO filePaths OF THE 'gcubeProfiles' CONFIG
if (filePaths != null) {
String fromSectionDocJSON = fromSectionDoc.toJson();
List<FilesetDV> listFiles = new ArrayList<FilesetDV>();
// List<GCubeSDIViewerLayerDV> listLayers = new ArrayList<GCubeSDIViewerLayerDV>();
for (FilePathDV filePath : filePaths) {
// Reading Fileset _payloads
String filesetJSONPath = String.format("%s.%s", JSON_$_POINTER, filePath.getFieldName());
List<Payload> listPayloads = readPayloadsForFileset(filesetJSONPath, fromSectionDocJSON);
FilesetDV filesetDV = new FilesetDV();
filesetDV.setName(filePath.getGcubeProfileFieldName());
for (Payload payload : listPayloads) {
PayloadDV payloadDV = ConvertToDataValueObjectModel.toPayloadDV(payload);
filesetDV.addPayloadDV(payloadDV);
listFiles.add(filesetDV);
}
// Reading Fileset _materializations
//listLayers = readGcubeSDILayersForFileset(filesetJSONPath, fromSectionDocJSON);
//theProfileBeanExt.set
}
theProfileBeanExt.setListFileset(listFiles);
}
System.out.println("\nputting theProfileBeanExt: "+theProfileBeanExt);
listOfProfilesBeanExt.add(theProfileBeanExt);
// System.out.println("\nPRINTING PROJECT VIEW ON END: ");
// for (int j = 0; j < listOfProfilesBeanExt.size(); j++) {
// MetaDataProfileBeanExt metaDataProfileBeanExt = listOfProfilesBeanExt.get(j);
// System.out.println("MetaDataProfileBeanExt index: " + j + " "+metaDataProfileBeanExt.getType() +" "+metaDataProfileBeanExt.hashCode());
// int z = 0;
// for (MetadataFieldWrapper mfw : metaDataProfileBeanExt.getMetadataFields()) {
// System.out.println("\t MetadataFieldWrapper index: " + z++ + " " + mfw);
// }
// }
//
// System.out.println(listProfileBeansExt.get(listProfileBeansExt.size()-1));
//Geoportal_JSON_Mapper.prettyPrintProjectEdit(projectView);
}
}
projectView.setTheProfileBeans(listOfProfilesBeanExt);
//Geoportal_JSON_Mapper.prettyPrintProjectEdit(projectView);
return projectView;
}
public static List<MetadataFieldWrapper> cloneList(List<MetadataFieldWrapper> list) {
List<MetadataFieldWrapper> listCloned = new ArrayList<MetadataFieldWrapper>(list.size());
Function<MetadataFieldWrapper, MetadataFieldWrapper> cloneWrapper = (mfw) -> {
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());
return newMfw;
};
for (MetadataFieldWrapper item : list) {
MetadataFieldWrapper cloned = cloneWrapper.apply(item);
listCloned.add(cloned);
}
return listCloned;
}
/**
* Load project view.
*
* @param theProjectDV the the project DV
* @param scope the scope
* @param username the username
* @return the project view
* @throws Exception the exception
*/
public static ProjectView loadProjectView(ProjectDV theProjectDV, String scope, String username) throws Exception {
String theWholeProjectAsJSON = theProjectDV.getTheDocument().getDocumentAsJSON();
LOG.debug("theProjectDV as JSON: " + theWholeProjectAsJSON);
LOG.debug("theProjectDV as MAP: " + theProjectDV.getTheDocument().getDocumentAsMap());
ProjectView projectView = new ProjectView();
projectView.setTheProjectDV(theProjectDV);
LinkedHashMap<String, List<GcubeProfilesMetadataForUCD>> linkedMap_UCDId_gCubeProfiles = GcubeProfilesPerUCDIdCache
.get(scope);
// NO UCD defined, applying default
if (linkedMap_UCDId_gCubeProfiles.size() == 0) {
LOG.warn("No " + GEOPORTAL_CONFIGURATION_TYPE.gcube_profiles + " found in the UCD");
LOG.info("Applying default business logic to display the project");
SectionView sectionView = new SectionView();
sectionView.setSectionTitle("Document");
SubDocumentView subDocumentView = new SubDocumentView();
Document sectionDoc = Document.parse(theProjectDV.getTheDocument().getDocumentAsJSON());
boolean isAccessibleSection = isAccessibleSectionAccordingToPolicy(sectionDoc, JSON_$_POINTER, username);
// If is accessible
if (isAccessibleSection) {
// Creating one Project with one SectionView and SubDocumentView
String wholeSectionDoc = sectionDoc.toJson();
subDocumentView.setMetadataAsJSON(wholeSectionDoc);
List<FilesetDV> listFiles = new ArrayList<FilesetDV>();
List<FilesetDV> listImages = new ArrayList<FilesetDV>();
List<GCubeSDIViewerLayerDV> listLayers = new ArrayList<GCubeSDIViewerLayerDV>();
// Reading Fileset _payloads
String filesetJSONPath = String.format("%s.%s", JSON_$_POINTER, FILESET);
List<Payload> listPayloads = readPayloadsForFileset(filesetJSONPath, wholeSectionDoc);
FilesetDV filesetDV = new FilesetDV();
filesetDV.setName(FILESET);
for (Payload payload : listPayloads) {
PayloadDV payloadDV = ConvertToDataValueObjectModel.toPayloadDV(payload);
filesetDV.addPayloadDV(payloadDV);
boolean isImage = ImageDetector.isImage(payload.getMimetype());
if (isImage) {
listImages.add(filesetDV);
} else {
listFiles.add(filesetDV);
}
}
subDocumentView.setListImages(listImages);
subDocumentView.setListFiles(listFiles);
// Reading Fileset _materializations / layers
listLayers = readGcubeSDILayersForFileset(filesetJSONPath, wholeSectionDoc);
subDocumentView.setListLayers(listLayers);
sectionView.addSubDocument(subDocumentView);
projectView.addSectionView(sectionView);
}
}
List<GcubeProfilesMetadataForUCD> listProfilesBean = linkedMap_UCDId_gCubeProfiles
.get(theProjectDV.getProfileID());
com.jayway.jsonpath.Configuration configuration = com.jayway.jsonpath.Configuration.builder()
.jsonProvider(new JsonOrgJsonProvider()).build();
// Reading the Project according to list of Profile defined in the UCD
for (GcubeProfilesMetadataForUCD gcubeProfileMetaForUCD : listProfilesBean) {
GcubeProfileDV gcubeProfileDV = gcubeProfileMetaForUCD.getGcubeProfile();
SectionView sectionView = new SectionView();
sectionView.setSectionTitle(gcubeProfileDV.getSectionTitle());
LOG.debug("\n\nThe profile is: " + gcubeProfileDV);
// Building JSON/section full PATH and section name
String sectionJSONPath = "";
String parentPathFromProfile = gcubeProfileDV.getParentName() == null ? "" : gcubeProfileDV.getParentName();
String theSectionName = gcubeProfileDV.getSectionName();
if (theSectionName.compareTo(JSON_$_POINTER) == 0 || theSectionName.compareTo(JSON_$_POINTER + ".") == 0) {
sectionJSONPath = JSON_$_POINTER;
theSectionName = "";
} else {
sectionJSONPath = String.format("%s%s",
parentPathFromProfile.endsWith(".") ? parentPathFromProfile : parentPathFromProfile + ".",
theSectionName);
}
LOG.debug("The sectionJSONPath is: " + sectionJSONPath);
JsonPath theSectionJsonPath = null;
Object data = null;
try {
theSectionJsonPath = JsonPath.compile(sectionJSONPath);
data = theSectionJsonPath.read(theWholeProjectAsJSON, configuration);
} catch (Exception e) {
LOG.warn("Error on searching the section " + sectionJSONPath + " in the JSON Project: "
+ theWholeProjectAsJSON);
continue;
}
LOG.debug("Data is instace of: " + data.getClass());
LOG.debug("data to string: " + data.toString());
// Splitting the General Document in bson.Document according to list of
// GcubeProfiles
List<Document> listBSONDocument = new ArrayList<Document>();
if (data instanceof org.json.JSONObject) {
String jsonString = data.toString();
LOG.debug("the JSON to string: " + jsonString);
Document sectionDoc = Document.parse(jsonString);
boolean isAccessibleSection = isAccessibleSectionAccordingToPolicy(sectionDoc, sectionJSONPath,
username);
if (isAccessibleSection) {
listBSONDocument.add(sectionDoc);
}
} else if (data instanceof org.json.JSONArray) {
org.json.JSONArray dataArray = (org.json.JSONArray) data;
for (int i = 0; i < dataArray.length(); i++) {
String jsonString = dataArray.get(i).toString();
LOG.debug("the array " + i + " JSON to string: " + jsonString);
Document sectionDoc = Document.parse(jsonString);
boolean isAccessibleSection = isAccessibleSectionAccordingToPolicy(sectionDoc, sectionJSONPath,
username);
if (isAccessibleSection) {
listBSONDocument.add(sectionDoc);
}
}
}
LOG.debug("Result for " + gcubeProfileDV.getSectionName() + " is: " + listBSONDocument);
List<MetaDataProfileBean> theProfileBeans = gcubeProfileMetaForUCD.getListMetadataProfileBean();
MetaDataProfileBean theProfileBean = theProfileBeans.get(0);
// For each bson.Document creating the SubDocumentView
for (int i = 0; i < listBSONDocument.size(); i++) {
Document fromSectionDoc = listBSONDocument.get(i);
SubDocumentView subDocumentView = new SubDocumentView();
Document toSectionDoc = new Document();
// Filling the SubDocumentView metadata with the metadataField.getFieldName()
// read from the Profile
for (MetadataFieldWrapper metadataField : theProfileBean.getMetadataFields()) {
String theFieldName = metadataField.getFieldId() != null ? metadataField.getFieldId()
: metadataField.getFieldName();
LOG.debug("reading theFieldName: " + theFieldName);
Object theOBJFieldValue = fromSectionDoc.get(theFieldName);
// NB: Using ALWAYS THE metadataField.getFieldName() as LABEL
toSectionDoc = sanitizeDocumentValue(toSectionDoc, metadataField.getFieldName(), theOBJFieldValue);
}
String subToJSON = toSectionDoc.toJson();
LOG.debug("theSubSetionDoc is: " + subToJSON);
subDocumentView.setMetadataAsJSON(toSectionDoc.toJson());
// Reading filePaths
List<FilePathDV> filePaths = gcubeProfileDV.getFilePaths();
// READING fileset* field ACCORDING TO filePaths OF THE 'gcubeProfiles' CONFIG
if (filePaths != null) {
String fromSectionDocJSON = fromSectionDoc.toJson();
List<FilesetDV> listFiles = new ArrayList<FilesetDV>();
List<FilesetDV> listImages = new ArrayList<FilesetDV>();
List<GCubeSDIViewerLayerDV> listLayers = new ArrayList<GCubeSDIViewerLayerDV>();
for (FilePathDV filePath : filePaths) {
// Reading Fileset _payloads
String filesetJSONPath = String.format("%s.%s", JSON_$_POINTER, filePath.getFieldName());
List<Payload> listPayloads = readPayloadsForFileset(filesetJSONPath, fromSectionDocJSON);
FilesetDV filesetDV = new FilesetDV();
filesetDV.setName(filePath.getGcubeProfileFieldName());
for (Payload payload : listPayloads) {
PayloadDV payloadDV = ConvertToDataValueObjectModel.toPayloadDV(payload);
filesetDV.addPayloadDV(payloadDV);
boolean isImage = ImageDetector.isImage(payload.getMimetype());
if (isImage) {
listImages.add(filesetDV);
} else {
listFiles.add(filesetDV);
}
}
// Reading Fileset _materializations
listLayers = readGcubeSDILayersForFileset(filesetJSONPath, fromSectionDocJSON);
}
subDocumentView.setListFiles(listFiles);
subDocumentView.setListImages(listImages);
subDocumentView.setListLayers(listLayers);
}
sectionView.addSubDocument(subDocumentView);
}
projectView.addSectionView(sectionView);
}
return projectView;
}
/**
* Read payloads for fileset.
*
* @param filesetJSONPath the fileset JSON path
* @param sectionJSONDocument the section JSON document
* @return the list
*/
public static List<Payload> readPayloadsForFileset(String filesetJSONPath, String sectionJSONDocument) {
LOG.debug("readPayloadsForFileset called");
List<Payload> listPayloads = new ArrayList<Payload>();
String _payloadsJSONPath = String.format("%s.%s", filesetJSONPath, _PAYLOADS);
try {
com.jayway.jsonpath.Configuration configuration = com.jayway.jsonpath.Configuration.builder()
.jsonProvider(new JsonOrgJsonProvider()).build();
LOG.info("Reading sectionPath at {} into section document {}", _payloadsJSONPath, sectionJSONDocument);
JsonPath theSectionPolycJsonPath = JsonPath.compile(_payloadsJSONPath);
Object _payloads = theSectionPolycJsonPath.read(sectionJSONDocument, configuration).toString();
if (_payloads instanceof String) {
String toStringPayloads = (String) _payloads;
LOG.trace("The _payloads is a String {}", toStringPayloads);
JSONArray jsonArray = new JSONArray(toStringPayloads);
for (int i = 0; i < jsonArray.length(); i++) {
Payload payloadDV = Serialization.read(jsonArray.getJSONObject(i).toString(), Payload.class);
listPayloads.add(payloadDV);
}
}
LOG.info("returning list of payloads {}", listPayloads);
} catch (Exception e) {
LOG.warn("Error on reading the JSON Path " + _payloadsJSONPath + " in the doc " + sectionJSONDocument, e);
}
return listPayloads;
}
/**
* Read images for fileset.
*
* @param parentJSONPath the parent JSON path
* @param sectionJSONDocument the section JSON document
* @param limitToFirstOneFound the limit to first one found
* @return the list
*/
public static List<PayloadDV> readImagesForFileset(String parentJSONPath, String sectionJSONDocument,
boolean limitToFirstOneFound) {
LOG.debug("readImagesForFileset called");
List<PayloadDV> listImages = new ArrayList<PayloadDV>();
com.jayway.jsonpath.Configuration config = com.jayway.jsonpath.Configuration.builder()
.jsonProvider(new JsonOrgJsonProvider()).build();
// Reading Fileset _payloads
String filesetJSONPath = String.format("%s.%s", parentJSONPath, _PAYLOADS);
LOG.info("Reading sectionPath {} into section document {}", filesetJSONPath, sectionJSONDocument);
JsonPath theSectionPolycJsonPath = JsonPath.compile(filesetJSONPath);
Object _filesets = theSectionPolycJsonPath.read(sectionJSONDocument, config);
List<Payload> payloads = new ArrayList<Payload>();
List<Payload> listPayloads = recursiveFetchingPayloads(config, _filesets, payloads);
for (Payload payload : listPayloads) {
boolean isImage = ImageDetector.isImage(payload.getMimetype());
if (isImage) {
PayloadDV payloadDV = ConvertToDataValueObjectModel.toPayloadDV(payload);
listImages.add(payloadDV);
if (limitToFirstOneFound && listImages.size() == 1)
return listImages;
}
}
LOG.debug("readImagesForFileset returning listOfImages: " + listImages);
return listImages;
}
/**
* Read gcube SDI layers for fileset.
*
* @param materializationParentJSONPath the materialization parent JSON path
* @param sectionJSONDocument the section JSON document
* @return the list
*/
public static List<GCubeSDIViewerLayerDV> readGcubeSDILayersForFileset(String materializationParentJSONPath,
String sectionJSONDocument) {
LOG.debug("readGcubeSDILayersForFileset called");
List<GCubeSDIViewerLayerDV> listSDILayers = new ArrayList<GCubeSDIViewerLayerDV>();
String _materializationsJSONPath = String.format("%s.%s", materializationParentJSONPath, _MATERIALIZATIONS);
try {
com.jayway.jsonpath.Configuration configurationJSONSmart = com.jayway.jsonpath.Configuration.builder()
.jsonProvider(new JsonOrgJsonProvider()).build();
LOG.info("Reading sectionPath {} into section document {}", _materializationsJSONPath, sectionJSONDocument);
JsonPath theSectionPolycJsonPath = JsonPath.compile(_materializationsJSONPath);
Object _materializations = theSectionPolycJsonPath.read(sectionJSONDocument, configurationJSONSmart);
LOG.trace("_materializations.class(): " + _materializations.getClass());
listSDILayers = recursiveFetchingLayers(configurationJSONSmart, _materializations, listSDILayers);
} catch (Exception e) {
LOG.warn("Error on reading the JSON Path " + _materializationsJSONPath + " in the doc "
+ sectionJSONDocument, e);
}
LOG.info("returning list of layers {}", listSDILayers);
return listSDILayers;
}
/**
* Recursive fetching layers.
*
* @param config the config
* @param objectJSON the object JSON
* @param listSDILayers the list SDI layers
* @return the list
*/
private static List<GCubeSDIViewerLayerDV> recursiveFetchingLayers(com.jayway.jsonpath.Configuration config,
Object objectJSON, List<GCubeSDIViewerLayerDV> listSDILayers) {
if (objectJSON == null)
return listSDILayers;
if (objectJSON instanceof JSONArray) {
JSONArray theJsonArray = (JSONArray) objectJSON;
LOG.trace("jsonArray: " + theJsonArray.toString(3));
for (int i = 0; i < theJsonArray.length(); i++) {
recursiveFetchingLayers(config, theJsonArray.get(i), listSDILayers);
}
} else if (objectJSON instanceof JSONObject) {
JSONObject theJsonObject = (JSONObject) objectJSON;
LOG.trace("theJSONObject: " + theJsonObject.toString(3));
GCubeSDIViewerLayerDV gsdiLayer = converLayer(config, theJsonObject);
listSDILayers.add(gsdiLayer);
}
return listSDILayers;
}
/**
* Recursive fetching payloads.
*
* @param config the config
* @param objectJSON the object JSON
* @param payloads the payloads
* @return the list
*/
public static List<Payload> recursiveFetchingPayloads(com.jayway.jsonpath.Configuration config, Object objectJSON,
List<Payload> payloads) {
LOG.debug("recursiveFetchingPayloads called");
if (objectJSON == null)
return payloads;
if (objectJSON instanceof JSONArray) {
JSONArray theJsonArray = (JSONArray) objectJSON;
LOG.trace("jsonArray: " + theJsonArray.toString(3));
for (int i = 0; i < theJsonArray.length(); i++) {
payloads = recursiveFetchingPayloads(config, theJsonArray.get(i), payloads);
}
} else if (objectJSON instanceof JSONObject) {
JSONObject toStringPayloads = (JSONObject) objectJSON;
LOG.trace("The _payloads is a String {}", toStringPayloads.toString(3));
Payload payload;
try {
payload = Serialization.read(toStringPayloads.toString(), Payload.class);
payloads.add(payload);
} catch (Exception e) {
LOG.warn("Error on converting the JSON Boject " + toStringPayloads + "as "
+ Payload.class.getSimpleName() + e.getMessage());
}
}
return payloads;
}
/**
* Conver layer.
*
* @param config the config
* @param thJsonObject the th json object
* @return the g cube SDI viewer layer DV
*/
// TODO THIS PART SHOULD BE REVISITED/OPTIMIZED
private static GCubeSDIViewerLayerDV converLayer(com.jayway.jsonpath.Configuration config,
JSONObject thJsonObject) {
LOG.debug("converLayer called for " + thJsonObject);
GCubeSDIViewerLayerDV gsdiLayer = new GCubeSDIViewerLayerDV();
try {
String theType = thJsonObject.getString(_TYPE);
gsdiLayer.setType(theType);
LOG.debug(_TYPE + " is: " + theType);
} catch (Exception e) {
LOG.warn("No " + _TYPE + " found", e);
}
String toSerializeJSONOBJ = thJsonObject.toString();
String jsonPath = null;
try {
jsonPath = String.format("%s.%s", JSON_$_POINTER, _BBOX);
HashMap<String, Object> bbox = JsonPath.using(config).parse(toSerializeJSONOBJ).read(jsonPath,
HashMap.class);
BBOXDV bboxDV = new BBOXDV(bbox);
gsdiLayer.setBbox(bboxDV);
LOG.debug(_BBOX + " is: " + bboxDV);
} catch (Exception e) {
LOG.warn(jsonPath + " error: ", e);
}
try {
jsonPath = String.format("%s.%s", JSON_$_POINTER, _OGC_LINKS);
String jsonString = JsonPath.using(config).parse(toSerializeJSONOBJ).read(jsonPath).toString();
Gson gson = new Gson();
HashMap<String, String> map = gson.fromJson(jsonString, HashMap.class);
gsdiLayer.setOgcLinks(map);
LOG.debug(_OGC_LINKS + " are: " + map);
} catch (Exception e) {
LOG.warn(jsonPath + " error: ", e);
}
try {
String wmsLink = gsdiLayer.getWMSLink();
if (wmsLink != null) {
String layerName = URLParserUtil.extractValueOfParameterFromURL("layers", wmsLink);
gsdiLayer.setLayerName(layerName);
}
} catch (Exception e) {
LOG.warn(jsonPath + " error: ", e);
}
LOG.debug("converLayer returning: " + gsdiLayer);
return gsdiLayer;
}
/**
* Checks if is accessible section according to policy.
*
* @param section the section
* @param sectionJSONPath the section JSON path
* @param myLogin the my login
* @return true, if is accessible section according to policy
*/
private static boolean isAccessibleSectionAccordingToPolicy(Document section, String sectionJSONPath,
String myLogin) {
LOG.debug("isAccessibleSectionAccordingToPolicy called");
boolean isAccessible = true;
// Skipping the root, going to check the access_policy of subsections
if (sectionJSONPath.compareTo(JSON_$_POINTER) != 0) {
isAccessible = checkAccessPolicy(section.toJson(), myLogin);
}
return isAccessible;
}
/**
* Check access policy.
*
* @param sectionDocumentJSON the section document JSON
* @param myLogin the my login
* @return true, if successful
*/
private static boolean checkAccessPolicy(String sectionDocumentJSON, String myLogin) {
LOG.debug("checkAccessPolicy called");
// CHECKING THE POLICY
String accessPolicyPath = JSON_$_POINTER + "._access._policy";
boolean isAccessible = true;
try {
com.jayway.jsonpath.Configuration configuration = com.jayway.jsonpath.Configuration.builder()
.jsonProvider(new JsonOrgJsonProvider()).build();
LOG.info("Reading access policy at {} into section document {}", accessPolicyPath, sectionDocumentJSON);
JsonPath theSectionPolycJsonPath = JsonPath.compile(accessPolicyPath);
String _policy = theSectionPolycJsonPath.read(sectionDocumentJSON, configuration).toString();
LOG.info("The section {} has policy {}", accessPolicyPath, _policy);
isAccessible = GeportalCheckAccessPolicy.isAccessible(_policy, myLogin);
} catch (Exception e) {
LOG.error(accessPolicyPath + " not found. Check OK");
}
LOG.info("Is the section {} accessible? {}", sectionDocumentJSON, isAccessible);
return isAccessible;
}
/**
* Sanitize document value.
*
* @param toDoc the to doc
* @param fieldLabel the field label
* @param theObjectFieldValue the the object field value
* @return the document
*/
private static Document sanitizeDocumentValue(Document toDoc, String fieldLabel, Object theObjectFieldValue) {
if (theObjectFieldValue != null) {
if (theObjectFieldValue instanceof String) {
String toString = (String) theObjectFieldValue;
if (toString != null && !toString.isEmpty()) {
toDoc.append(fieldLabel, theObjectFieldValue);
} else {
LOG.debug("Skipping String field " + fieldLabel + " its value is null or empty");
}
} else if (theObjectFieldValue instanceof ArrayList) {
ArrayList toArrayList = (ArrayList) theObjectFieldValue;
if (toArrayList != null && !toArrayList.isEmpty()) {
toDoc.append(fieldLabel, theObjectFieldValue);
} else {
LOG.debug("Skipping ArrayList field " + fieldLabel + " its value is null or empty");
}
} else {
toDoc.append(fieldLabel, theObjectFieldValue);
}
} else {
LOG.debug("Skipping field " + fieldLabel + " its value is null or empty");
}
return toDoc;
}
/**
* Pretty print JSON.
*
* @param jsonString the json string
* @return the string
*/
private static String prettyPrintJSON(String jsonString) {
Gson gson = new GsonBuilder().setPrettyPrinting().create();
JsonObject jsonObject = new JsonParser().parse(jsonString).getAsJsonObject();
return gson.toJson(jsonObject);
}
/**
* Pretty print project view.
*
* @param projectView the project view
*/
public static void prettyPrintProjectView(ProjectView projectView) {
for (SectionView section : projectView.getListSections()) {
System.out.println("\n\n###### Section Title: " + section.getSectionTitle() + " ######");
int i = 1;
for (SubDocumentView subDocument : section.getListSubDocuments()) {
System.out.println("## " + SubDocumentView.class.getSimpleName() + " n." + i);
System.out.println("***** Metadata");
System.out.println(prettyPrintJSON(subDocument.getMetadataAsJSON()));
System.out.println("***** Files");
if (subDocument.getListFiles() != null) {
for (FilesetDV filesetDV : subDocument.getListFiles()) {
System.out.println("******* File Fileset name: " + filesetDV.getName());
for (PayloadDV payload : filesetDV.getListPayload()) {
System.out.println("********* Payload: " + payload);
}
}
}
System.out.println("***** Images");
if (subDocument.getListImages() != null) {
for (FilesetDV filesetDV : subDocument.getListImages()) {
System.out.println("******* Image Fileset name: " + filesetDV.getName());
for (PayloadDV payload : filesetDV.getListPayload()) {
System.out.println("********* Payload: " + payload);
}
}
}
System.out.println("***** Layers");
if (subDocument.getListLayers() != null) {
for (GCubeSDIViewerLayerDV layer : subDocument.getListLayers()) {
System.out.println("******* Layer type: " + layer.getType());
System.out.println("******* Layer: " + layer);
}
}
i++;
}
}
}
/**
* Pretty print project view.
*
* @param projectView the project view
*/
public static void prettyPrintProjectEdit(ProjectEdit projectEdit) {
for (MetaDataProfileBeanExt mpb : projectEdit.getTheProfileBeans()) {
System.out.println("\n\n###### Title: " + mpb.getTitle() + " - Type: " + mpb.getType() + " ######");
int i = 1;
for (MetadataFieldWrapper fieldWrapper : mpb.getMetadataFields()) {
System.out.println("## " + MetadataFieldWrapper.class.getSimpleName() + " n." + i);
System.out.println("***** Metadata");
// System.out.println(mfw);
System.out.println("\tfieldId: " + fieldWrapper.getFieldId() + ", fieldName: "
+ fieldWrapper.getFieldName() + ", CurrentValue: " + fieldWrapper.getCurrentValue());
i++;
}
i = 1;
System.out.println("***** Files");
for (FilesetDV fileSet : mpb.getListFileset()) {
System.out.println("## " + FilesetDV.class.getSimpleName() + " n." + i);
System.out.println(fileSet);
i++;
}
}
}
}

View File

@ -4,6 +4,7 @@ import org.gcube.application.geoportalcommon.shared.gis.BoundsMap;
import org.gcube.application.geoportalcommon.util.URLParserUtil;
import org.gcube.portlets.user.geoportaldataviewer.server.gis.MapServerRecognize.SERVERTYPE;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.WFSGetFeature;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -57,15 +58,18 @@ public class GisMakers {
* @param outputFormat the output format
* @return the string
*/
public static String buildWFSFeatureQuery(LayerItem layerItem, String mapSrsName, BoundsMap mapBBOX, int maxFeatures, String outputFormat) {
public static String buildWFSFeatureQuery(LayerItem layerItem, String mapSrsName, BoundsMap mapBBOX,
int maxFeatures, String outputFormat) {
String link = layerItem.getMapServerHost();
LOG.debug("Map server host URL: " + link);
String link = layerItem.getMapServerEndpoint();
LOG.debug("Map server endpoint: " + link);
LOG.debug("CQL filter is: " + layerItem.getCqlFilter());
LOG.debug("MAX FEATURES: " + maxFeatures);
LOG.debug("BBOX: " + mapBBOX);
LOG.debug("Output Format: " + outputFormat);
String outputformat = null;
String boundingBox = "";
String boundingBox = null;
// CASE MAP SERVER
SERVERTYPE mapserverType = MapServerRecognize.recongnize(layerItem);
@ -76,7 +80,9 @@ public class GisMakers {
if (mapserverType.equals(SERVERTYPE.MAPSERVER)) {
LOG.debug("wms url contains wxs is a map server? no appending /wfs ");
outputformat = MapServerRecognize.outputFormatRecognize(SERVERTYPE.MAPSERVER, outputFormat);
boundingBox = BBOX_FORMAT(COORDINATE_FORMAT.YX, ",",mapBBOX.getLowerLeftX(),mapBBOX.getLowerLeftY(),mapBBOX.getUpperRightX(),mapBBOX.getUpperRightY()); // USE AXIS XY
if (mapBBOX != null)
boundingBox = BBOX_FORMAT(COORDINATE_FORMAT.YX, ",", mapBBOX.getLowerLeftX(),
mapBBOX.getLowerLeftY(), mapBBOX.getUpperRightX(), mapBBOX.getUpperRightY()); // USE AXIS XY
// DEBUG
LOG.debug("SERVERTYPE.MAPSERVER outputformat: " + outputformat);
LOG.debug("SERVERTYPE.MAPSERVER srsName: " + mapSrsName);
@ -86,7 +92,9 @@ public class GisMakers {
link += link.endsWith("wfs") ? "" : "/wfs";
outputformat = MapServerRecognize.outputFormatRecognize(SERVERTYPE.GEOSEVER, outputFormat);
mapSrsName = "urn:x-ogc:def:crs:"+mapSrsName;
boundingBox = BBOX_FORMAT(COORDINATE_FORMAT.YX, ",",mapBBOX.getLowerLeftX(),mapBBOX.getLowerLeftY(),mapBBOX.getUpperRightX(),mapBBOX.getUpperRightY()); // USE AXIS XY
if (mapBBOX != null)
boundingBox = BBOX_FORMAT(COORDINATE_FORMAT.YX, ",", mapBBOX.getLowerLeftX(),
mapBBOX.getLowerLeftY(), mapBBOX.getUpperRightX(), mapBBOX.getUpperRightY()); // USE AXIS XY
// DEBUG
LOG.debug("SERVERTYPE.GEOSEVER outputformat: " + outputformat);
LOG.debug("SERVERTYPE.GEOSEVER srsName: " + mapSrsName);
@ -98,15 +106,22 @@ public class GisMakers {
// + (outputformat == null ? "" : "&OUTPUTFORMAT=" + outputformat);
//
link += "?"+
URLParserUtil.addParameterToQueryString(WFSGetFeature.SERVICE.getParameter(), WFSGetFeature.SERVICE.getValue(), false, true)+
URLParserUtil.addParameterToQueryString(WFSGetFeature.VERSION.getParameter(), WFSGetFeature.VERSION.getValue(), false, true)+
URLParserUtil.addParameterToQueryString(WFSGetFeature.REQUEST.getParameter(), WFSGetFeature.REQUEST.getValue(), false, true)+
URLParserUtil.addParameterToQueryString(WFSGetFeature.SRSNAME.getParameter(), mapSrsName, false, true)+
URLParserUtil.addParameterToQueryString(WFSGetFeature.TYPENAME.getParameter(), layerItem.getName(), false, true)+
(maxFeatures == 0 ? "" : URLParserUtil.addParameterToQueryString(WFSGetFeature.MAXFEATURES.getParameter(), maxFeatures+"", false, true))+
(outputformat == null ? "" : URLParserUtil.addParameterToQueryString(WFSGetFeature.OUTPUTFORMAT.getParameter(), outputformat, false, false));
link += "?"
+ URLParserUtil.addParameterToQueryString(WFSGetFeature.SERVICE.getParameter(),
WFSGetFeature.SERVICE.getValue(), false, true)
+ URLParserUtil.addParameterToQueryString(WFSGetFeature.VERSION.getParameter(),
WFSGetFeature.VERSION.getValue(), false, true)
+ URLParserUtil.addParameterToQueryString(WFSGetFeature.REQUEST.getParameter(),
WFSGetFeature.REQUEST.getValue(), false, true)
+ URLParserUtil.addParameterToQueryString(WFSGetFeature.SRSNAME.getParameter(), mapSrsName, false, true)
+ URLParserUtil.addParameterToQueryString(WFSGetFeature.TYPENAME.getParameter(), layerItem.getName(),
false, true)
+ (maxFeatures == 0 ? ""
: URLParserUtil.addParameterToQueryString(WFSGetFeature.MAXFEATURES.getParameter(),
maxFeatures + "", false, true))
+ (outputformat == null ? ""
: URLParserUtil.addParameterToQueryString(WFSGetFeature.OUTPUTFORMAT.getParameter(),
outputformat, false, false));
if (layerItem.getCqlFilter() != null && !layerItem.getCqlFilter().isEmpty()) {
if (layerItem.getCqlFilter().contains("BBOX("+GEOM_NAME_BOUNDED+"")) {
@ -114,7 +129,8 @@ public class GisMakers {
link += "&" + CQL_FILTER_PARAMETER + "=" + layerItem.getCqlFilter();
} else {
// I NEED TO ENCODE THE BBOX INTO CQL FILTERING,
String cqlFilterValue = "BBOX("+GEOM_NAME_BOUNDED+"," + boundingBox + ")" + " AND " + layerItem.getCqlFilter();
String cqlFilterValue = "BBOX(" + GEOM_NAME_BOUNDED + "," + boundingBox + ")" + " AND "
+ layerItem.getCqlFilter();
link += "&" + CQL_FILTER_PARAMETER + "=" + cqlFilterValue;
}
@ -181,7 +197,8 @@ public class GisMakers {
* @param separator the separator
* @return the string
*/
public static String BBOX_FORMAT(COORDINATE_FORMAT format, String separator, double lowerLeftX, double lowerLeftY, double upperRightX, double upperRightY) {
public static String BBOX_FORMAT(COORDINATE_FORMAT format, String separator, double lowerLeftX, double lowerLeftY,
double upperRightX, double upperRightY) {
if(format==null)
format = COORDINATE_FORMAT.XY;
@ -191,25 +208,11 @@ public class GisMakers {
switch (format) {
case XY:
return String.format("%s%s%s%s%s%s%s",
String.valueOf(lowerLeftX),
separator,
String.valueOf(lowerLeftY),
separator,
String.valueOf(upperRightX),
separator,
String.valueOf(upperRightY)
);
return String.format("%s%s%s%s%s%s%s", String.valueOf(lowerLeftX), separator, String.valueOf(lowerLeftY),
separator, String.valueOf(upperRightX), separator, String.valueOf(upperRightY));
case YX:
return String.format("%s%s%s%s%s%s%s",
String.valueOf(lowerLeftY),
separator,
String.valueOf(lowerLeftX),
separator,
String.valueOf(upperRightY),
separator,
String.valueOf(upperRightX)
);
return String.format("%s%s%s%s%s%s%s", String.valueOf(lowerLeftY), separator, String.valueOf(lowerLeftX),
separator, String.valueOf(upperRightY), separator, String.valueOf(upperRightX));
}
return null;

View File

@ -12,12 +12,10 @@ import org.gcube.spatial.data.geoutility.wms.WmsUrlValidator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* 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 {
@ -26,7 +24,7 @@ public class WMSUrlValidator {
private static final String OWS = "ows";
private HashMap<String, String> parametersValue = new HashMap<String, String>();
private String wmsRequestURI;
private String wmsServiceHost;
private String wmsServiceEndPoint;
private String layerName;
private String wmsNoStandardParameters = "";
@ -35,100 +33,95 @@ public class WMSUrlValidator {
private static final Logger LOG = LoggerFactory.getLogger(WMSUrlValidator.class);
/**
* Instantiates a new WMS url validator.
*
* @param wmsRequest the wms request
* @param wmsRequest the wms request
* @param inputLayerName the input layer name
* @throws Exception the exception
*/
public WMSUrlValidator(String wmsRequest, String inputLayerName) throws Exception{
LOG.debug("WMSURLValidator wmsRequest: "+wmsRequest);
LOG.debug("WMSURLValidator layerName: "+inputLayerName);
public WMSUrlValidator(String wmsRequest, String inputLayerName) throws Exception {
LOG.debug("WMSURLValidator wmsRequest: " + wmsRequest);
LOG.debug("WMSURLValidator layerName: " + inputLayerName);
if(wmsRequest==null || wmsRequest.isEmpty())
if (wmsRequest == null || wmsRequest.isEmpty())
throw new Exception("WMS request is null or empty");
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 {
//VALIDATE WMS SERVICE FOR WEB MAP SERVER
if(!HttpRequestUtil.urlExists(this.wmsServiceHost, true)){
LOG.info("baseWmsServiceUrl: "+wmsServiceHost +" is not a geoserver, setting as input base wms server: "+baseWmsService);
this.wmsServiceHost = baseWmsService;
// VALIDATE WMS SERVICE FOR WEB MAP SERVER
if (!HttpRequestUtil.urlExists(this.wmsServiceEndPoint, true)) {
LOG.warn("baseWmsServiceUrl: " + wmsServiceEndPoint + " is not valid URL!!");
this.wmsServiceEndPoint = readWMSServiceEndpoint;
}
} catch (Exception e) {
LOG.error("error on validating geoserver wms service: "+e);
LOG.info("setting baseWmsService as input base wms server: "+baseWmsService);
this.wmsServiceHost = baseWmsService;
LOG.error("Error on validating the endpoint: " + this.wmsServiceEndPoint, e);
boolean isOwsService = GeoWmsServiceUtility.isOWSSerice(this.wmsRequestURI);
LOG.info("Retrying by appending suffix WMS or WFS...");
this.wmsServiceEndPoint = appendWmsServiceToBaseUrl(readWMSServiceEndpoint, isOwsService);
}
//VALIDATION FOR THREDDS - FIND LAYER NAME INTO WMS PATH
if(this.layerName==null || this.layerName.isEmpty()){
// VALIDATION FOR THREDDS - FIND LAYER NAME INTO WMS PATH
if (this.layerName == null || this.layerName.isEmpty()) {
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");
}
LOG.info("WMSURLValidator found endpoint: " + wmsServiceEndPoint);
parametersValue.put(WmsParameters.LAYERS.getParameter(), this.layerName);
}
/**
* Append wms service to base url.
*
* @param url the url
* @param url the url
* @param isOwsServer the is ows server
* @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;
if(url.lastIndexOf("/") != url.length()){
url+="/";
if (url.lastIndexOf("/") != url.length()) {
url += "/";
}
if(isOwsServer)
return url+=OWS;
if (isOwsServer)
return url += OWS;
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}.
*
* @param returnEmptyParameter if true the wms url returned contains also wms parameter with empty value, none otherwise.
* and mandatory wms parameters that does not found are filled with empty values
* @param returnEmptyParameter if true the wms url returned contains also
* wms parameter with empty value, none
* otherwise. and mandatory wms parameters
* that does not found are filled with empty
* values
* @param fillEmptyParameterAsDefault the fill empty parameter as default
* @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);
String fullWmsUrlBuilded;
@ -138,106 +131,108 @@ public class WMSUrlValidator {
parametersValue.putAll(urlValidator.getMapWmsParameters());
String ln = parametersValue.get(WmsParameters.LAYERS.name());
LOG.debug("Comparing layer name from Wms request: "+ln +", with OnLineResource layerName: "+this.layerName);
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.debug("Comparing layer name from Wms request: " + ln + ", with OnLineResource layerName: "
+ this.layerName);
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);
parametersValue.put(WmsParameters.LAYERS.getParameter(), this.layerName);
urlValidator.getMapWmsParameters().put(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);
urlValidator.getMapWmsParameters().put(
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);
}
// logger.trace("parametersValue: "+parametersValue);
mapWmsNoStandardParams = new HashMap<String, String>(urlValidator.getMapWmsNoStandardParams().size());
mapWmsNoStandardParams.putAll(urlValidator.getMapWmsNoStandardParams());
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;
}
LOG.trace("GisViewerWMSUrlValidator parseWMSRequest returning full wms url: "+fullWmsUrlBuilded);
LOG.trace("GisViewerWMSUrlValidator parseWMSRequest returning full wms url: " + fullWmsUrlBuilded);
return fullWmsUrlBuilded;
}
/**
* Gets the web map server host.
*
* @param wmsRequest the wms request
* @return the web map server host, (geoserver URI or the wmsRequest substring from start to index of '?' char (if exists))
* @return the web map server host, (geoserver URI or the wmsRequest substring
* from start to index of '?' char (if exists))
*/
public WebMapServerHost getWebMapServerHost(String wmsRequest){
public WebMapServerHost getWebMapServerHost(String wmsRequest) {
WebMapServerHost webMapServerHost = new WebMapServerHost();
if(wmsRequest==null)
return webMapServerHost; //uri is empty
if (wmsRequest == null)
return webMapServerHost; // uri is empty
int end = wmsRequest.toLowerCase().lastIndexOf("?");
if(end==-1){
LOG.trace("char ? not found in geoserver uri, return: "+wmsRequest);
return webMapServerHost; //uri is empty
if (end == -1) {
LOG.trace("char ? not found in geoserver uri, return: " + wmsRequest);
return webMapServerHost; // uri is empty
}
String webMapServerBaseURL = wmsRequest.substring(0, wmsRequest.toLowerCase().lastIndexOf("?"));
int index = webMapServerBaseURL.lastIndexOf(GEOSERVER);
if(index>-1){ //FOUND the string GEOSERVER into URL
LOG.trace("found geoserver string: "+GEOSERVER+" in "+webMapServerBaseURL);
if (index > -1) { // FOUND the string GEOSERVER into URL
LOG.trace("found geoserver string: " + GEOSERVER + " in " + webMapServerBaseURL);
//THERE IS SCOPE?
// THERE IS SCOPE?
int lastSlash = webMapServerBaseURL.lastIndexOf("/");
int includeGeoserverString = index+GEOSERVER.length();
int endUrl = lastSlash>includeGeoserverString?lastSlash:includeGeoserverString;
LOG.trace("indexs - lastSlash: ["+lastSlash+"], includeGeoserverString: ["+includeGeoserverString+"], endUrl: ["+endUrl+"]");
int startScope = includeGeoserverString+1<endUrl?includeGeoserverString+1:endUrl; //INCLUDE SLASH
int includeGeoserverString = index + GEOSERVER.length();
int endUrl = lastSlash > includeGeoserverString ? lastSlash : includeGeoserverString;
LOG.trace("indexs - lastSlash: [" + lastSlash + "], includeGeoserverString: [" + includeGeoserverString
+ "], endUrl: [" + endUrl + "]");
int startScope = includeGeoserverString + 1 < endUrl ? includeGeoserverString + 1 : endUrl; // INCLUDE SLASH
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.setScope(scope);
return webMapServerHost;
}else{
LOG.trace("the string 'geoserver' not found in "+webMapServerBaseURL);
} else {
LOG.trace("the string 'geoserver' not found in " + webMapServerBaseURL);
// GET LAST INDEX OF '/' AND CONCATENATE GEOSERVER
String urlConn = webMapServerBaseURL.substring(0, webMapServerBaseURL.lastIndexOf("/"))+GEOSERVER;
LOG.trace("tentative concatenating string 'geoserver' at http url "+urlConn);
String urlConn = webMapServerBaseURL.substring(0, webMapServerBaseURL.lastIndexOf("/")) + GEOSERVER;
LOG.trace("tentative concatenating string 'geoserver' at http url " + urlConn);
try {
if(HttpRequestUtil.urlExists(urlConn, false)){
LOG.trace("url: "+urlConn+" - open a connection, return "+urlConn);
if (HttpRequestUtil.urlExists(urlConn, false)) {
LOG.trace("url: " + urlConn + " - open a connection, return " + urlConn);
webMapServerHost.setHost(urlConn);
return webMapServerHost;
}
else
LOG.trace("url: "+urlConn+" - not open a connection");
} else
LOG.trace("url: " + urlConn + " - not open a connection");
} 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);
LOG.trace("url connection, returned: "+uriWithoutParameters);
LOG.trace("url connection, returned: " + uriWithoutParameters);
webMapServerHost.setHost(uriWithoutParameters);
return webMapServerHost;
}
}
/**
* Gets the wms service host.
* Gets the wms service end point.
*
* @return the wms service host
* @return the wms service end point
*/
public String getWmsServiceHost() {
public String getWmsServiceEndPoint() {
return wmsServiceHost;
return wmsServiceEndPoint;
}
/**
@ -260,42 +255,40 @@ public class WMSUrlValidator {
return wmsNoStandardParameters;
}
/**
* Gets the value of parsed wms parameter.
*
* @param parameter the parameter
* @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());
}
/**
* Gets the value of parameter.
*
* @param wmsParam the wms param
* @param wmsParam the wms param
* @param wmsUrlParameters the wms url parameters
* @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);
}
/**
* Sets the value of parameter.
*
* @param wmsParam the wms param
* @param wmsParam the wms param
* @param wmsUrlParameters the wms url parameters
* @param newValue the new value
* @param addIfNotExists the add if not exists
* @param newValue the new value
* @param addIfNotExists the add if not exists
* @return the string
*/
public static String setValueOfParameter(WmsParameters wmsParam, String wmsUrlParameters, String newValue, boolean addIfNotExists){
public static String setValueOfParameter(WmsParameters wmsParam, String wmsUrlParameters, String newValue,
boolean addIfNotExists) {
return WmsUrlValidator.setValueOfParameter(wmsParam, wmsUrlParameters, newValue, addIfNotExists);
}
@ -309,8 +302,6 @@ public class WMSUrlValidator {
return layerName;
}
/**
* Gets the styles as list.
*
@ -321,18 +312,17 @@ public class WMSUrlValidator {
List<String> listStyles = new ArrayList<String>();
String styles = getValueOfParsedWMSParameter(WmsParameters.STYLES);
if(styles!=null && !styles.isEmpty()){
if (styles != null && !styles.isEmpty()) {
String[] arrayStyle = styles.split(",");
for (String style : arrayStyle) {
if(style!=null && !style.isEmpty())
if (style != null && !style.isEmpty())
listStyles.add(style);
}
}
return listStyles;
}
/**
* Gets the map wms no standard params.
*
@ -342,63 +332,4 @@ public class WMSUrlValidator {
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

@ -1,66 +0,0 @@
//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

@ -1,93 +0,0 @@
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

@ -0,0 +1,69 @@
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,7 +3,9 @@
*/
package org.gcube.portlets.user.geoportaldataviewer.server.util;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
@ -51,6 +53,8 @@ public class SessionUtil {
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";
/**
* Checks if is into portal.
*
@ -134,10 +138,12 @@ public class SessionUtil {
GCubeUser user = pContext.getCurrentUser(request);
String token = PortalContext.getConfiguration().getCurrentUserToken(scope, user.getUsername());
if (token != null && setInThread)
SecurityTokenProvider.instance.set(token);
if (token != null) {
LOG.debug("Returning token " + token.substring(1, 10) + "_MASKED_TOKEN_");
if (setInThread)
SecurityTokenProvider.instance.set(token);
}
LOG.debug("Returning token " + token.substring(1, 10) + "_MASKED_TOKEN_");
return token;
}
@ -271,33 +277,6 @@ public class SessionUtil {
HttpSession session = httpServletRequest.getSession();
List<Concessione> listOfConcessioni = (List<Concessione>) session.getAttribute(LIST_OF_CONCESSIONI);
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;
*
*/
}
/**
@ -350,4 +329,20 @@ 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);
}
}

View File

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

View File

@ -1,40 +1,37 @@
package org.gcube.portlets.user.geoportaldataviewer.shared;
import java.io.Serializable;
import java.util.List;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.IndexLayerDV;
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.UseCaseDescriptorDV;
public class GCubeCollection implements Serializable, Comparable<GCubeCollection> {
public class GCubeCollection implements Serializable {
/**
/**
*
*/
private static final long serialVersionUID = -3915546050671671465L;
private UseCaseDescriptorDV ucd;
private List<IndexLayerDV> indexes;
public GCubeCollection() {
private List<IndexLayerDV> indexes;
public GCubeCollection() {
}
public UseCaseDescriptorDV getUcd() {
return ucd;
}
public List<IndexLayerDV> getIndexes() {
public List<IndexLayerDV> getIndexes() {
return indexes;
}
public void setUcd(UseCaseDescriptorDV ucd) {
public void setUcd(UseCaseDescriptorDV ucd) {
this.ucd = ucd;
}
public void setIndexes(List<IndexLayerDV> indexes) {
public void setIndexes(List<IndexLayerDV> indexes) {
this.indexes = indexes;
}
@ -42,6 +39,24 @@ public class GCubeCollection implements Serializable {
public String toString() {
return "GCubeCollection [ucd=" + ucd + ", indexes=" + indexes + "]";
}
@Override
public int compareTo(GCubeCollection o) {
if (this == null || this.ucd == null)
return 1;
if (o == null || o.getUcd() == null)
return -1;
if (this.ucd.getName() == null)
return 1;
if (o.getUcd().getName() == null)
return -1;
return this.getUcd().getName().compareTo(o.getUcd().getName());
}
}

View File

@ -26,7 +26,6 @@ public class GeoNaSpatialQueryResult implements Serializable {
// Map with couple (mongoId concessione, list of uploaded GNAImages for the
// concessione)
private Map<String, List<PayloadDV>> mapImages = null;
// private ProjectDV projectDV;
/**
* Instantiates a new geo na data object.
@ -35,15 +34,6 @@ public class GeoNaSpatialQueryResult implements Serializable {
}
// public void setProjectDV(ProjectDV projectDV) {
// this.projectDV = projectDV;
//
// }
//
// public ProjectDV getProjectDV() {
// return projectDV;
// }
/**
* Gets the features.
*

View File

@ -8,12 +8,13 @@ import org.gcube.application.geoportalcommon.shared.geoportal.ucd.UseCaseDescrip
public class ItemFieldsResponse implements Serializable {
/**
*
*/
private static final long serialVersionUID = -8778792633248190350L;
UseCaseDescriptorDV useCaseDescriptorDV;
List<ItemFieldDV> listItemFields;
private static final long serialVersionUID = -6723902864074541278L;
private UseCaseDescriptorDV useCaseDescriptorDV;
private List<ItemFieldDV> listItemFields;
public ItemFieldsResponse() {

View File

@ -1,131 +0,0 @@
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

@ -1,50 +0,0 @@
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

@ -0,0 +1,16 @@
package org.gcube.portlets.user.geoportaldataviewer.shared.gis;
import java.io.Serializable;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Data
public class DisplayCategory implements Serializable {
String title;
String description;
}

View File

@ -23,7 +23,6 @@ import com.google.gwt.core.client.GWT;
*/
public class LayerItem implements Serializable, Cloneable {
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 1664082688635256899L;
@ -37,7 +36,7 @@ public class LayerItem implements Serializable, Cloneable {
private String url;
/** The base map server URL. */
private String mapServerHost;
private String mapServerEndpoint;
/** The style. */
private String style;
@ -102,9 +101,6 @@ public class LayerItem implements Serializable, Cloneable {
/** The server wms request. */
public String wmsLink;
/** The cql filter available. */
private boolean cqlFilterAvailable = false;
/** The uuid. */
private String UUID;
@ -722,7 +718,7 @@ public class LayerItem implements Serializable, Cloneable {
public String getCqlFilter() {
return cqlFilter;
}
/**
* Sets the cql filter.
*
@ -756,16 +752,7 @@ public class LayerItem implements Serializable, Cloneable {
* @return true, if is cql filter available
*/
public boolean isCqlFilterAvailable() {
return cqlFilterAvailable;
}
/**
* Sets the cql filter available.
*
* @param cqlFilterAvailable the new cql filter available
*/
public void setCqlFilterAvailable(boolean cqlFilterAvailable) {
this.cqlFilterAvailable = cqlFilterAvailable;
return (cqlFilter != null) && (!cqlFilter.isEmpty());
}
/**
@ -787,21 +774,21 @@ public class LayerItem implements Serializable, Cloneable {
}
/**
* Gets the map server host.
* Gets the map server endpoint.
*
* @return the map server host
* @return the map server endpoint
*/
public String getMapServerHost() {
return mapServerHost;
public String getMapServerEndpoint() {
return mapServerEndpoint;
}
/**
* Sets the map server host.
*
* @param mapServerHost the new map server host
* @param mapServerEndpoint the new map server host
*/
public void setMapServerHost(String mapServerHost) {
this.mapServerHost = mapServerHost;
public void setMapServerHost(String mapServerEndpoint) {
this.mapServerEndpoint = mapServerEndpoint;
}
/**
@ -908,8 +895,8 @@ public class LayerItem implements Serializable, Cloneable {
builder.append(title);
builder.append(", url=");
builder.append(url);
builder.append(", mapServerHost=");
builder.append(mapServerHost);
builder.append(", mapServerEndpoint=");
builder.append(mapServerEndpoint);
builder.append(", style=");
builder.append(style);
builder.append(", isTrasparent=");
@ -952,8 +939,6 @@ public class LayerItem implements Serializable, Cloneable {
builder.append(isNcWms);
builder.append(", wmsLink=");
builder.append(wmsLink);
builder.append(", cqlFilterAvailable=");
builder.append(cqlFilterAvailable);
builder.append(", UUID=");
builder.append(UUID);
builder.append(", zAxis=");
@ -968,7 +953,6 @@ public class LayerItem implements Serializable, Cloneable {
return builder.toString();
}
/**
* To layer item.
*
@ -991,9 +975,8 @@ public class LayerItem implements Serializable, Cloneable {
* @param maxResolution the max resolution
* @return the layer item
*/
// TODO Constructor from IndexLayerDV, GCUBESDILAeryDV or direct info
// 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,

View File

@ -29,7 +29,6 @@ public class LayerObject implements Serializable {
private ProjectDV projectDV;
public LayerObject() {
super();
}
public LayerObject(LayerObjectType type, LayerItem item) {

View File

@ -0,0 +1,13 @@
package org.gcube.portlets.user.geoportaldataviewer.shared.gis;
import java.util.Map;
public class OverlayWMSLayer {
private String title;
private String name;
private String wmsServiceBaseURL;
private boolean display;
private Map<String, String> mapProperties;
}

View File

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

View File

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

View File

@ -26,7 +26,7 @@ body {
background-color: white;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
padding: 10px;
border-radius: 2px;
border-radius: 10px;
border: 1px solid #cccccc;
bottom: 12px;
left: -50px;
@ -34,11 +34,16 @@ body {
max-width: 500px;
visibility: hidden;
padding-top: 20px;
opacity: 0.9;
}
.ol-popup #pop-img {
max-height: 130px;
overflow-y: scroll;
}
.ol-popup img {
width: 100%;
max-height: 200px;
}
.ol-popup:after, .ol-popup:before {
@ -153,6 +158,11 @@ body {
padding-top: 1px;
}
.preset-location ul a {
margin: 5px !important;
}
.my-control-group .controls {
margin-left: 70px !important;
}
@ -190,7 +200,7 @@ body {
/*margin-top: 30px;*/
overflow-y: auto;
transition: width 0.5s;
z-index: 999;
z-index: 950;
}
.overlay {
@ -206,7 +216,7 @@ body {
}
.inner-toolbar .btn-group {
margin-left: 0px !important;
margin-left: 2px !important;
}
.inner-toolbar .btn-link {
@ -353,16 +363,23 @@ body {
border-radius: 20px;
}
.layers-panel {
margin-top: 10px;
.layer-panel {
margin-top: 43px;
background-color: white;
opacity: 90%;
padding: 10px;
width: 410px;
max-width: 430px;
z-index: 500;
overflow-y: auto;
position: absolute;
left: 52px;
}
.dand-layer {
width: 400px;
border: 1px solid #ccc !important;
padding: 5px 0px;
border-radius: 5px;
}
.range-slider {
@ -418,6 +435,7 @@ body {
.map-layers-radio label {
margin-left: 5px;
padding-top: 5px;
font-weight: bold;
}
@ -488,6 +506,22 @@ body {
width: 250px !important;
}
.search-field {
margin: 5px;
background-color: #f9f9f9;
padding: 5px;
}
.search-field div {
margin-left: 5px;
}
.search-field select {
margin-left: 8px;
width: 505px !important;
margin-bottom: 0px;
}
.table-results {
table-layout: fixed;
/*width: 600px;*/
@ -701,11 +735,11 @@ Table Of Contents (TOC)
text-align: center;
font-size: 20px;
margin: 0;
position: absolute;
top: 50%;
position: absolute;
top: 50%;
width: 100%;
-ms-transform: translateY(-50%);
transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}
.general_error div {
@ -713,6 +747,114 @@ Table Of Contents (TOC)
}
.general_warning {
text-align: center;
font-size: 20px;
}
.general_warning div {
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
*******************************/
@ -732,10 +874,37 @@ RESPONSIVE
}
.details-panel {
width: 600px;
width: 530px;
}
}
@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) {
#timeline-data {
width: 260px;
@ -746,10 +915,27 @@ RESPONSIVE
width: 400px;
}
.search-facility {
width: 250px;
max-width: 300px;
/*width: 250px;
max-width: 300px;*/
}
.inner-toolbar {
width: 100px;
/*width: 100px;*/
}
}
@media all and (max-height: 900px) {
.ol-popup{
min-width: 150px;
max-width: 150px;
max-height: 150px;
overflow-y: scroll;
}
.ol-popup img {
width: 100%;
max-width: 150px;
}
}
/******************************
END RESPONSIVE
*******************************/

View File

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

View File

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

View File

@ -22,10 +22,12 @@ import org.gcube.application.geoportalcommon.ProjectDVBuilder;
import org.gcube.application.geoportalcommon.geoportal.GeoportalClientCaller;
import org.gcube.application.geoportalcommon.geoportal.ProjectsCaller;
import org.gcube.application.geoportalcommon.geoportal.UseCaseDescriptorCaller;
import org.gcube.application.geoportalcommon.geoportal.access.GeportalCheckAccessPolicy;
import org.gcube.application.geoportalcommon.geoportal.access.GeportalCheckAccessPolicy.ACCESS_POLICY;
import org.gcube.application.geoportalcommon.geoportal.util.GisUtil;
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
import org.gcube.application.geoportalcommon.shared.WhereClause;
import org.gcube.application.geoportalcommon.shared.SearchingFilter.LOGICAL_OP;
import org.gcube.application.geoportalcommon.shared.WhereClause;
import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV;
import org.gcube.application.geoportalcommon.shared.geoportal.geojson.Crs;
import org.gcube.application.geoportalcommon.shared.geoportal.geojson.GeoJSON;
@ -34,13 +36,11 @@ 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.TemporalReferenceDV;
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.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.junit.Before;
import org.junit.Test;
/**
* The Class GeoportalViewer_Tests.
@ -55,14 +55,15 @@ public class GeoportalViewer_Tests {
private ProjectsCaller clientProjects;
private static String CONTEXT = "/pred4s/preprod/preVRE";
private static String TOKEN = "5c3c7551-870d-4259-bd77-a7e603fe4949-980114272"; //preVRE
private static String CONTEXT = "/gcube/devsec/devVRE";
// private static String CONTEXT = "/pred4s/preprod/preVRE";
// private static String CONTEXT = "/d4science.research-infrastructures.eu/D4OS/GNA";
private static String TOKEN = ""; // GNA
//private static String CONTEXT = "/gcube/devsec/devVRE";
//private static String TOKEN = ""; // devVRE
// private static String TOKEN = ""; // devVRE
private static String PROFILE_ID = "profiledConcessioni";
private static String PROJECT_ID = "637ceb4d21dd0d6fb9f24706";
private static String PROJECT_ID = "63d011c4dcac4551b9a6b930";
private static String USERNAME = "francesco.mangiacrapa";
@ -71,7 +72,7 @@ public class GeoportalViewer_Tests {
*
* @return the client
*/
@Before
//@Before
public void getClient() {
// assumeTrue(GCubeTest.isTestInfrastructureEnabled());
ScopeProvider.instance.set(CONTEXT);
@ -80,7 +81,7 @@ public class GeoportalViewer_Tests {
clientProjects = GeoportalClientCaller.projects();
}
// @Test
//@Test
public void getProjectViewForID() {
try {
@ -114,9 +115,26 @@ public class GeoportalViewer_Tests {
String jsonDocument = project.getTheDocument().toJson();
System.out.println("JSON Project is: " + jsonDocument);
String materializationParentJSONPath = String.format("%s..%s", Geoportal_JSON_Mapper.JSON_$_POINTER,
Geoportal_JSON_Mapper.FILESET);
ACCESS_POLICY accessPolicy = GeportalCheckAccessPolicy.accessPolicyFromSessionLogin(null);
String materializationParentJSONPath = null;
if (accessPolicy.equals(ACCESS_POLICY.OPEN)) {
// Filtering for ACCESS_POLICY.OPEN when the username is not in session. IAM
// identity is running, no logged in user.
materializationParentJSONPath = String.format("%s..%s[?(@._access._policy=='%s')]",
Geoportal_JSON_Mapper.JSON_$_POINTER, Geoportal_JSON_Mapper.FILESET, accessPolicy);
} else {
// Accessing to all fileset (with any ACCESS_POLICY) when the user is logged in.
materializationParentJSONPath = String.format("%s..%s", Geoportal_JSON_Mapper.JSON_$_POINTER,
Geoportal_JSON_Mapper.FILESET);
}
System.out.println("jsonPathQuery is: " + materializationParentJSONPath);
// String materializationParentJSONPath = String.format("%s..%s", Geoportal_JSON_Mapper.JSON_$_POINTER,
// Geoportal_JSON_Mapper.FILESET);
//
listLayers = Geoportal_JSON_Mapper.readGcubeSDILayersForFileset(materializationParentJSONPath,
jsonDocument);
@ -219,7 +237,7 @@ public class GeoportalViewer_Tests {
}
}
@Test
// @Test
public void testReadProjectEdit() {
try {
@ -242,7 +260,7 @@ public class GeoportalViewer_Tests {
}
}
//@Test
// @Test
public void testTemporalReference() {
try {
ScopeProvider.instance.set(CONTEXT);
@ -251,8 +269,9 @@ public class GeoportalViewer_Tests {
Document temporalJsonTemplate = GeoportalClientCaller.useCaseDescriptors()
.readTemporalDimensionTemplate(theProject.getProfileID());
// String template = "{\"content\": \"$.nome\"," + "\"title\": \"$.nome\","
// + "\"start\" : \"$.dataInizioProgetto\"," + "\"end\" : \"$.dataFineProgetto\"}";
// String template = "{\"content\": \"$.nome\"," + "\"title\": \"$.nome\","
// + "\"start\" : \"$.dataInizioProgetto\"," + "\"end\" :
// \"$.dataFineProgetto\"}";
if (temporalJsonTemplate != null) {
@ -272,14 +291,13 @@ public class GeoportalViewer_Tests {
e.printStackTrace();
}
}
@Test
// @Test
public void getResultsWithSize() throws Exception {
// List<Project> listOfProjects = client.getListForProfileID(PROFILE_ID);
long start = System.currentTimeMillis();
System.out.println("start at: "+start);
System.out.println("start at: " + start);
SearchingFilter filter = new SearchingFilter();
// Where Clause
@ -291,32 +309,32 @@ public class GeoportalViewer_Tests {
conditions.add(whereClause);
filter.setConditions(conditions);
//NEED TO GET projections
//SETTING PROJECTION ONLY FOR PROEJCT ID
// NEED TO GET projections
// SETTING PROJECTION ONLY FOR PROEJCT ID
LinkedHashMap<String, Object> projectionForIDs = new LinkedHashMap<String, Object>();
projectionForIDs.put(Project.ID, 1);
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);
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;
Stream<Project> targetStream = StreamSupport.stream(itP.spliterator(), false);
List<String> listProjectIDs = targetStream.map(Project::getId).collect(Collectors.toList());
System.out.println("Total Ids are: "+listProjectIDs.size());
//listProjectIDs.stream().forEach(p -> System.out.println(p));
System.out.println("Total Ids are: " + listProjectIDs.size());
// listProjectIDs.stream().forEach(p -> System.out.println(p));
long end = System.currentTimeMillis();
System.out.println("IDS returned in ms: "+(end-start));
//RESETTIG FILTER AND PROJECT TO CLIENT QUERY
System.out.println("IDS returned in ms: " + (end - start));
// RESETTIG FILTER AND PROJECT TO CLIENT QUERY
LinkedHashMap<String, Object> projection = new LinkedHashMap<String, Object>();
// default
//PROJECTION
// PROJECTION
projection.put(Project.ID, 1);
projection.put("_theDocument.nome", 1);
projection.put("_profileID", 1);
@ -334,21 +352,21 @@ public class GeoportalViewer_Tests {
projection.put("_theDocument.dataInizioProgetto", 1);
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);
List<ResultDocumentDV> results = ConvertToDataValueObjectModel.toListResultDocument(itProjects);
int i = 0;
for (ResultDocumentDV projectDV : results) {
System.out.println(++i + ") " + projectDV.getId() + " dataInizioProgetto: "+projectDV.getDocumentAsMap().get("dataInizioProgetto"));
System.out.println(++i + ") " + projectDV.getId() + " 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();
System.out.println("Result listed in ms: "+(end-start));
System.out.println("Result listed in ms: " + (end - start));
}
}

View File

@ -0,0 +1,84 @@
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();
}
}
}