From 51a44a3e54675cfe59d7e9d173b0f376c8dd4651 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 17 Oct 2022 16:52:22 +0200 Subject: [PATCH] Created the ItemFieldsResponse --- .../client/GeoportalDataViewer.java | 31 +- .../client/GeoportalDataViewerService.java | 5 +- .../GeoportalDataViewerServiceAsync.java | 5 +- .../client/LayerManager.java | 6 +- .../collections/CloseCollectionEvent.java | 1 - .../client/ui/DetailsPanel.java | 2 - .../client/ui/GeonaDataViewMainPanel.java | 29 +- .../client/ui/GeonaDataViewMainPanel.ui.xml | 8 +- .../ui/cms/layers/LayersSectionViewer.java | 47 +- .../client/ui/cms/project/ProjectViewer.java | 70 +- .../ui/cms/project/ProjectViewer.ui.xml | 3 +- .../client/ui/cms/project/SectionViewer.java | 6 +- .../client/ui/gallery/ImagesGallery.java | 332 ++++----- .../products/concessioni/ConcessioneView.java | 666 +++++++++--------- .../server/GcubeProfilesPerUCDIdCache.java | 2 +- .../GeoportalDataViewerServiceImpl.java | 26 +- .../GeoportalServiceIdentityProxy.java | 16 + .../shared/ItemFieldsResponse.java | 49 ++ 18 files changed, 708 insertions(+), 596 deletions(-) create mode 100644 src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/ItemFieldsResponse.java diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java index d095be6..44c95c1 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java @@ -2,13 +2,11 @@ package org.gcube.portlets.user.geoportaldataviewer.client; 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.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV; -import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV; import org.gcube.application.geoportalcommon.shared.geoportal.materialization.IndexLayerDV; import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; @@ -37,6 +35,8 @@ import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowPopupOnCent import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowPopupOnCentroiEventHandler; 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; +import org.gcube.portlets.user.geoportaldataviewer.client.events.collections.CloseCollectionEventHandler; import org.gcube.portlets.user.geoportaldataviewer.client.events.collections.OpenCollectionEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.collections.OpenCollectionEventHandler; import org.gcube.portlets.user.geoportaldataviewer.client.gis.ExtentWrapped; @@ -46,6 +46,7 @@ import org.gcube.portlets.user.geoportaldataviewer.client.ui.GeonaDataViewMainPa import org.gcube.portlets.user.geoportaldataviewer.client.util.ControlledCallBack; import org.gcube.portlets.user.geoportaldataviewer.client.util.LoaderIcon; import org.gcube.portlets.user.geoportaldataviewer.shared.GCubeCollection; +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; @@ -136,27 +137,35 @@ public class GeoportalDataViewer implements EntryPoint { RootPanel.get(APP_DIV).add(loaderApp); GeoportalDataViewerServiceAsync.Util.getInstance() - .listOfFieldsForSearching(new AsyncCallback>>() { + .listOfFieldsForSearching(new AsyncCallback>() { @Override public void onFailure(Throwable caught) { - Window.alert(caught.getMessage()); + // TODO Auto-generated method stub } @Override - public void onSuccess(Map> mapOfSearchingFilterForUCD) { - GWT.log("listOfFieldsForSearching: " + mapOfSearchingFilterForUCD); + public void onSuccess(List itemFieldsResult) { + GWT.log("listOfFieldsForSearching: " + itemFieldsResult); mainPanel = new GeonaDataViewMainPanel(applicationBus, getClientHeight(), - mapOfSearchingFilterForUCD); + itemFieldsResult); RootPanel.get(APP_DIV).add(mainPanel); initApplication(); - } + } }); +// GWT.log("listOfFieldsForSearching: " + mapOfSearchingFilterForUCD); +// +// mainPanel = new GeonaDataViewMainPanel(applicationBus, getClientHeight(), +// mapOfSearchingFilterForUCD); +// RootPanel.get(APP_DIV).add(mainPanel); +// +// initApplication(); + } private void initApplication() { @@ -341,7 +350,7 @@ public class GeoportalDataViewer implements EntryPoint { @Override public void onOpenCollection(OpenCollectionEvent openCollectionEvent) { - GWT.log("Fired event: " + openCollectionEvent); + GWT.log("OpenCollectionEvent Fired event: " + openCollectionEvent); // Check if ID is available String collId = openCollectionEvent.getCollectionId(); ViewerConfiguration theConfig = GeoportalDataViewer.getStatus().getViewerConfig(); @@ -369,6 +378,10 @@ public class GeoportalDataViewer implements EntryPoint { } }); + applicationBus.addHandler(CloseCollectionEvent.TYPE, new CloseCollectionEventHandler() { + + }); + // applicationBus.addHandler(OpenCollectionEvent.TYPE, openCollectionEvent -> { // GWT.log("Fired event: " + openCollectionEvent); // // Check if ID is available diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java index 9e3893a..0bf3eb1 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java @@ -1,19 +1,18 @@ package org.gcube.portlets.user.geoportaldataviewer.client; import java.util.List; -import java.util.Map; import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData; import org.gcube.application.geoportalcommon.shared.SearchingFilter; -import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV; import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView; import org.gcube.application.geoportalcommon.shared.gis.BoundsMap; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV; import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult; +import org.gcube.portlets.user.geoportaldataviewer.shared.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.LayerObject; @@ -139,7 +138,7 @@ public interface GeoportalDataViewerService extends RemoteService { * @return the list * @throws Exception */ - Map> listOfFieldsForSearching() throws Exception; + List listOfFieldsForSearching() throws Exception; // /** // * Gets the list concessioni. diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java index 4226b55..d0a1092 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java @@ -1,19 +1,18 @@ package org.gcube.portlets.user.geoportaldataviewer.client; import java.util.List; -import java.util.Map; import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData; import org.gcube.application.geoportalcommon.shared.SearchingFilter; -import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV; import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView; import org.gcube.application.geoportalcommon.shared.gis.BoundsMap; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV; import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult; +import org.gcube.portlets.user.geoportaldataviewer.shared.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.LayerObject; @@ -66,7 +65,7 @@ public interface GeoportalDataViewerServiceAsync { void getListBaseLayers(AsyncCallback> callback); - void listOfFieldsForSearching(AsyncCallback>> callback); + void listOfFieldsForSearching(AsyncCallback> callback); // void getListConcessioni(Integer start, Integer limit, SearchingFilter filter, boolean reloadFromService, // AsyncCallback callback); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/LayerManager.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/LayerManager.java index d8e69fb..848b01a 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/LayerManager.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/LayerManager.java @@ -80,6 +80,7 @@ public class LayerManager { private Map mapDetailLayerObjects = new HashMap(); private Map mapBaseLayerObjects = new HashMap(); + private Map mapIndexLayerObjects = new HashMap(); private HandlerManager layerManagerBus = new HandlerManager(""); @@ -546,10 +547,7 @@ public class LayerManager { addLayer(LayerObjectType.INDEX_LAYER, null, null, layer.getLayer().getOgcLinks().get("wms"), false, false, null, false, null, null, null, null); - - // toLayerItem(null, null, null, null, null, false, false, false, null, null, - // false, null, false, null, null, null, null) - + } /** diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/collections/CloseCollectionEvent.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/collections/CloseCollectionEvent.java index 9a88e50..c8064cf 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/collections/CloseCollectionEvent.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/collections/CloseCollectionEvent.java @@ -17,7 +17,6 @@ public class CloseCollectionEvent extends GwtEvent @Override protected void dispatch(CloseCollectionEventHandler h) { - } public CloseCollectionEvent(String collectionId) { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/DetailsPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/DetailsPanel.java index 1d9b70f..f0eccc2 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/DetailsPanel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/DetailsPanel.java @@ -70,8 +70,6 @@ public class DetailsPanel extends Composite { detailsHTMLPanel.getParent().getElement().setScrollTop(0); } - //datailsContainerPanel.add(new ConcessioneView(geonaItemRef, result)); - datailsContainerPanel.add(new ProjectViewer(geonaItemRef, result)); showPanelDetails(); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java index 49ba81b..6efc3ef 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java @@ -3,12 +3,12 @@ package org.gcube.portlets.user.geoportaldataviewer.client.ui; import java.util.ArrayList; import java.util.Collection; import java.util.List; -import java.util.Map; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.SearchingFilter; import org.gcube.application.geoportalcommon.shared.SearchingFilter.ORDER; import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV; +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.GeoportalDataViewerConstants.MAP_PROJECTION; import org.gcube.portlets.user.geoportaldataviewer.client.events.ChangeMapLayerEvent; @@ -22,6 +22,7 @@ import org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.search.SearchFa 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.shared.GCubeCollection; +import org.gcube.portlets.user.geoportaldataviewer.shared.ItemFieldsResponse; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer; import com.github.gwtbootstrap.client.ui.Button; @@ -139,7 +140,7 @@ public class GeonaDataViewMainPanel extends Composite { public GeonaDataViewMainPanel(HandlerManager applicationBus, int mapHeight, - Map> mapOfSearchingFilterForUCD) { + List itemFieldsReponse) { initWidget(uiBinder.createAndBindUi(this)); this.applicationBus = applicationBus; mapPanel = new MapPanel(mapHeight + "px"); @@ -165,14 +166,14 @@ public class GeonaDataViewMainPanel extends Composite { linkPresetLocation.setCustomIconStyle(GNAIcons.CustomIconType.PRESET_LOCATION.get()); linkLayers.setCustomIconStyle(GNAIcons.CustomIconType.LAYERS.get()); - openCollectionDropDown.setCustomIconStyle(GNAIcons.CustomIconType.MAP.get()); + openCollectionDropDown.setIcon(IconType.COMPASS); SearchingFilter initialSortFilter = new SearchingFilter(); initialSortFilter.setOrder(ORDER.ASC); - for (final String profileID : mapOfSearchingFilterForUCD.keySet()) { + for (final ItemFieldsResponse ifResponse : itemFieldsReponse) { - List result = mapOfSearchingFilterForUCD.get(profileID); + List result = ifResponse.getListItemFields(); List displayFields = new ArrayList(); List searchByFields = new ArrayList(); List sortByFields = new ArrayList(); @@ -190,28 +191,29 @@ public class GeonaDataViewMainPanel extends Composite { } } - NavLink navLink = new NavLink(profileID); - navLink.setText(profileID); + final UseCaseDescriptorDV ucd = ifResponse.getUseCaseDescriptorDV(); + NavLink navLink = new NavLink(ifResponse.getUseCaseDescriptorDV().getName()); + //navLink.setText(ucd.getName()); navLink.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { searchFacilityPanel.clear(); - SearchFacilityUI searchFacility = new SearchFacilityUI(profileID, applicationBus, sortByFields, searchByFields, + SearchFacilityUI searchFacility = new SearchFacilityUI(ucd.getProfileID(), applicationBus, sortByFields, searchByFields, initialSortFilter); searchFacilityPanel.add(searchFacility); searchFacility.setSearchButton(searchFacilityButton); } }); - GWT.log("Added navLink for: " + profileID); + GWT.log("Added navLink for: " + ucd.getName()); navListSearch.add(navLink); } searchFacilityButton.setIcon(IconType.SEARCH); - if (mapOfSearchingFilterForUCD.size() == 0) { + if (itemFieldsReponse.size() == 0) { searchFacilityPanel.setVisible(false); searchFacilityButton.setVisible(false); } @@ -507,6 +509,13 @@ public class GeonaDataViewMainPanel extends Composite { openCollectionPanel.add(checkbox); } + if(collection!=null && collection.size()==1) { + CheckBox checkbox = (CheckBox) openCollectionPanel.getWidget(0); + checkbox.setValue(true, true); + String collectionID = checkbox.getId().replace("gcubeCollectionSelector_", ""); + applicationBus.fireEvent(new OpenCollectionEvent(collectionID)); + } + } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml index d0fea78..e285014 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml @@ -11,6 +11,12 @@ .font-weight-bold { font-weight: bold; } + + .open-collection-style { + padding-left: 15px; + padding-right: 15px; + } + @@ -37,7 +43,7 @@ - + () { @Override @@ -132,11 +137,10 @@ public class ProjectViewer extends Composite { public void onFailure(Throwable caught) { } }); - - + for (SectionView sectionView : projectView.getListSections()) { - - if(!sectionView.isEmpty()) { + + if (!sectionView.isEmpty()) { SectionViewer sectionViewer = new SectionViewer(sectionView); pageViewDetails.add(sectionViewer); } @@ -149,26 +153,24 @@ public class ProjectViewer extends Composite { MapView mapView = new MapView(transformedCenterCoordinate, GeoportalDataViewerConstants.LIGHT_MAP_ITALY_FIT_ZOOM_ON, "70%", "300px"); - Window.alert("addCentroidMap must be revisited"); - -// if (concessioneDV != null && concessioneDV.getCentroidLat() != null -// && concessioneDV.getCentroidLong() != null) { -// Coordinate coord = new Coordinate(concessioneDV.getCentroidLong(), concessioneDV.getCentroidLat()); -// Coordinate transfCoord = MapUtils.transformCoordiante(coord, MAP_PROJECTION.EPSG_4326.getName(), -// MAP_PROJECTION.EPSG_3857.getName()); -// // Coordinate invertedCoordinate = MapUtils.reverseCoordinate(coord); -// boolean authenticatedUser = myLogin != null ? true : false; -// mapView.addMarker(transfCoord, authenticatedUser); -// mapViewPanel.add(mapView); -// } else if (concessioneDV != null) { -// GeoportalDataViewerConstants -// .printJs("I cannot add centroid as maker one or both coordinates are null. Lat: " -// + concessioneDV.getCentroidLong() + ", Long:" + concessioneDV.getCentroidLat()); -// } + if (theProjectView != null && theProjectView.getCentroidLat() != null + && theProjectView.getCentroidLong() != null) { + Coordinate coord = new Coordinate(theProjectView.getCentroidLong(), theProjectView.getCentroidLat()); + Coordinate transfCoord = MapUtils.transformCoordiante(coord, MAP_PROJECTION.EPSG_4326.getName(), + MAP_PROJECTION.EPSG_3857.getName()); + // Coordinate invertedCoordinate = MapUtils.reverseCoordinate(coord); + boolean authenticatedUser = myLogin != null ? true : false; + mapView.addMarker(transfCoord, authenticatedUser); + centroidPanel.add(mapView); + } else if (theProjectView != null) { + GeoportalDataViewerConstants + .printJs("I cannot add centroid as maker one or both coordinates are null. Lat: " + + theProjectView.getCentroidLong() + ", Long:" + theProjectView.getCentroidLat()); + } } public ProjectView getProjectView() { - return projectView; + return theProjectView; } protected void setExpandViewButtonVisible(boolean bool) { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/project/ProjectViewer.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/project/ProjectViewer.ui.xml index fb161bf..0afaa83 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/project/ProjectViewer.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/project/ProjectViewer.ui.xml @@ -33,12 +33,13 @@ - Share Expand + \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/project/SectionViewer.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/project/SectionViewer.java index 49e2636..1c60d5a 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/project/SectionViewer.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/project/SectionViewer.java @@ -72,13 +72,13 @@ public class SectionViewer extends Composite { } else if (displayAsMapOfLayers) { GWT.log("displayAsMapOfLayers the: "+sectionView); for (SubDocumentView subDocumentView : subDocuments) { - String table = GeoportalDataViewerConstants.jsonToTableHTML(subDocumentView.getMetadataAsJSON()); - sectionPanelContainer.add(new HTML(table)); +// String table = GeoportalDataViewerConstants.jsonToTableHTML(subDocumentView.getMetadataAsJSON()); +// sectionPanelContainer.add(new HTML(table)); List layers = subDocumentView.getListLayers(); if (layers != null) { for (GCubeSDIViewerLayerDV gCubeLayer : layers) { - LayersSectionViewer layerSectionViewer = new LayersSectionViewer(gCubeLayer); + LayersSectionViewer layerSectionViewer = new LayersSectionViewer(gCubeLayer, subDocumentView); sectionPanelContainer.add(layerSectionViewer); //showLinkToDownloadWsContent(fileset.getName(), fileset.getListPayload()); } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/gallery/ImagesGallery.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/gallery/ImagesGallery.java index a16dea7..7e42b58 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/gallery/ImagesGallery.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/gallery/ImagesGallery.java @@ -1,166 +1,166 @@ -package org.gcube.portlets.user.geoportaldataviewer.client.ui.gallery; - -import java.util.List; - -import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceContentDV; -import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV; - -import com.google.gwt.core.client.JavaScriptObject; -import com.google.gwt.json.client.JSONArray; -import com.google.gwt.json.client.JSONObject; -import com.google.gwt.json.client.JSONString; -import com.google.gwt.user.client.Random; -import com.google.gwt.user.client.ui.HTMLPanel; - - -/** - * The Class ImagesSectionGallery. - * - * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) - * - * Jul 21, 2021 - */ -public class ImagesGallery { - - private HTMLPanel galleryPanel; - private List listImages; - private String galleryDivId; - - /** - * Show gallery. - * - * @param json_array_images the json array images - */ - private native void showGallery(JavaScriptObject json_array_images, String galleryDivId) /*-{ - - console.log("showing: " + json_array_images) - var waitForJQuery = setInterval( - function() { - if (typeof $wnd.$ != 'undefined') { - - $wnd - .$("#"+galleryDivId) - .nanogallery2( - { - thumbnailHeight : '200 XS150 SM150', // RESPONSIVE THUMBNAIL HEIGHT: default=200px, XS resolution=150px, SM resolution=150px - thumbnailWidth : '218 XS150 SM150', // RESPONSIVE THUMBNAIL WIDTH: auto - thumbnailAlignment : 'left', - thumbnailBorderHorizontal : 0, - thumbnailBorderVertical : 0, - thumbnailGutterWidth : '10 XS10 SM10', - thumbnailGutterHeight : '10 XS10 SM10', - - // THUMBNAIL TOOLS & LABEL - thumbnailLabel : { - display : true, - position : 'onBottom', - align : 'left' - }, - thumbnailToolbarImage : { - bottomLeft : 'display' - }, - // replace the default DISPLAY tool icon - icons : { - thumbnailDisplay : ' display' - }, - - // DISPLAY ANIMATION - galleryDisplayTransition : 'slideUp', - galleryDisplayTransitionDuration : 1000, - thumbnailDisplayTransition : 'scaleDown', - thumbnailDisplayTransitionDuration : 300, - thumbnailDisplayInterval : 50, - - // THUMBNAIL'S HOVER ANIMATION - //thumbnailBuildInit2 : 'tools_font-size_1.5em|title_font-size_1.5em', - thumbnailHoverEffect2 : 'imageScaleIn80|tools_opacity_0_1|tools_translateX_-30px_0px|title_opacity_1_0|title_translateX_0px_-30px', - touchAnimation : true, - touchAutoOpenDelay : 800, - - // GALLERY THEME - galleryTheme : { - thumbnail : { - borderRadius : '2px !important', - background : '#ffffff !important', - titleShadow : 'none !important', - titleColor : '#696969 !important', - labelBackground : '#f3f3f3 !important' - }, - thumbnailIcon : { - color : '#000', - shadow : 'none' - }, - }, - viewerToolbar : { - display : true, - standard : 'minimizeButton, label', - minimized : 'minimizeButton, label, fullscreenButton, downloadButton' - }, - viewerTools : { - topLeft : 'pageCounter', - topRight : 'playPauseButton, zoomButton, fullscreenButton, downloadButton, closeButton' - }, - - // DEEP LINKING - locationHash : false, - items : json_array_images - }) - - clearInterval(waitForJQuery); - } - }, 200); - - }-*/; - - /** - * Instantiates a new images gallery. - * - * @param immagini the immagini - */ - public ImagesGallery(List immagini) { - this.galleryDivId = "nanogallery"+Random.nextInt()+Random.nextInt(); - this.galleryPanel = new HTMLPanel("
"); - this.listImages = immagini; - } - - /** - * Gets the gallery panel. - * - * @return the gallery panel - */ - public HTMLPanel getGalleryPanel() { - return galleryPanel; - } - - /** - * Fill gallery. - */ - public void fillGallery() { - - JSONArray jsonArray = new JSONArray(); - int index = 0; - for (UploadedImageDV image : listImages) { - if(image.getListWsContent()!=null) { - for (WorkspaceContentDV imageContent : image.getListWsContent()) { - JSONObject json = new JSONObject(); - json.put("src", new JSONString(imageContent.getLink())); - json.put("srct", new JSONString(imageContent.getLink())); - List listAuthors = image.getResponsabili(); - String txtAuthors = listAuthors.size()>1 ? "Authors: ": "Author: "; - for (String author : listAuthors) { - txtAuthors+= " "+author +","; - } - txtAuthors = txtAuthors.substring(0,txtAuthors.length()-2); - String description = txtAuthors + ". ID Licenza: "+image.getLicenseID(); - json.put("title", new JSONString(image.getDidascalia())); - json.put("description", new JSONString(description)); - json.put("downloadURL", new JSONString(imageContent.getLink())); - jsonArray.set(index, json); - index++; - } - } - - } - showGallery(jsonArray.getJavaScriptObject(), galleryDivId); - } -} +//package org.gcube.portlets.user.geoportaldataviewer.client.ui.gallery; +// +//import java.util.List; +// +//import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceContentDV; +//import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV; +// +//import com.google.gwt.core.client.JavaScriptObject; +//import com.google.gwt.json.client.JSONArray; +//import com.google.gwt.json.client.JSONObject; +//import com.google.gwt.json.client.JSONString; +//import com.google.gwt.user.client.Random; +//import com.google.gwt.user.client.ui.HTMLPanel; +// +// +///** +// * The Class ImagesSectionGallery. +// * +// * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) +// * +// * Jul 21, 2021 +// */ +//public class ImagesGallery { +// +// private HTMLPanel galleryPanel; +// private List listImages; +// private String galleryDivId; +// +// /** +// * Show gallery. +// * +// * @param json_array_images the json array images +// */ +// private native void showGallery(JavaScriptObject json_array_images, String galleryDivId) /*-{ +// +// console.log("showing: " + json_array_images) +// var waitForJQuery = setInterval( +// function() { +// if (typeof $wnd.$ != 'undefined') { +// +// $wnd +// .$("#"+galleryDivId) +// .nanogallery2( +// { +// thumbnailHeight : '200 XS150 SM150', // RESPONSIVE THUMBNAIL HEIGHT: default=200px, XS resolution=150px, SM resolution=150px +// thumbnailWidth : '218 XS150 SM150', // RESPONSIVE THUMBNAIL WIDTH: auto +// thumbnailAlignment : 'left', +// thumbnailBorderHorizontal : 0, +// thumbnailBorderVertical : 0, +// thumbnailGutterWidth : '10 XS10 SM10', +// thumbnailGutterHeight : '10 XS10 SM10', +// +// // THUMBNAIL TOOLS & LABEL +// thumbnailLabel : { +// display : true, +// position : 'onBottom', +// align : 'left' +// }, +// thumbnailToolbarImage : { +// bottomLeft : 'display' +// }, +// // replace the default DISPLAY tool icon +// icons : { +// thumbnailDisplay : ' display' +// }, +// +// // DISPLAY ANIMATION +// galleryDisplayTransition : 'slideUp', +// galleryDisplayTransitionDuration : 1000, +// thumbnailDisplayTransition : 'scaleDown', +// thumbnailDisplayTransitionDuration : 300, +// thumbnailDisplayInterval : 50, +// +// // THUMBNAIL'S HOVER ANIMATION +// //thumbnailBuildInit2 : 'tools_font-size_1.5em|title_font-size_1.5em', +// thumbnailHoverEffect2 : 'imageScaleIn80|tools_opacity_0_1|tools_translateX_-30px_0px|title_opacity_1_0|title_translateX_0px_-30px', +// touchAnimation : true, +// touchAutoOpenDelay : 800, +// +// // GALLERY THEME +// galleryTheme : { +// thumbnail : { +// borderRadius : '2px !important', +// background : '#ffffff !important', +// titleShadow : 'none !important', +// titleColor : '#696969 !important', +// labelBackground : '#f3f3f3 !important' +// }, +// thumbnailIcon : { +// color : '#000', +// shadow : 'none' +// }, +// }, +// viewerToolbar : { +// display : true, +// standard : 'minimizeButton, label', +// minimized : 'minimizeButton, label, fullscreenButton, downloadButton' +// }, +// viewerTools : { +// topLeft : 'pageCounter', +// topRight : 'playPauseButton, zoomButton, fullscreenButton, downloadButton, closeButton' +// }, +// +// // DEEP LINKING +// locationHash : false, +// items : json_array_images +// }) +// +// clearInterval(waitForJQuery); +// } +// }, 200); +// +// }-*/; +// +// /** +// * Instantiates a new images gallery. +// * +// * @param immagini the immagini +// */ +// public ImagesGallery(List immagini) { +// this.galleryDivId = "nanogallery"+Random.nextInt()+Random.nextInt(); +// this.galleryPanel = new HTMLPanel("
"); +// this.listImages = immagini; +// } +// +// /** +// * Gets the gallery panel. +// * +// * @return the gallery panel +// */ +// public HTMLPanel getGalleryPanel() { +// return galleryPanel; +// } +// +// /** +// * Fill gallery. +// */ +// public void fillGallery() { +// +// JSONArray jsonArray = new JSONArray(); +// int index = 0; +// for (UploadedImageDV image : listImages) { +// if(image.getListWsContent()!=null) { +// for (WorkspaceContentDV imageContent : image.getListWsContent()) { +// JSONObject json = new JSONObject(); +// json.put("src", new JSONString(imageContent.getLink())); +// json.put("srct", new JSONString(imageContent.getLink())); +// List listAuthors = image.getResponsabili(); +// String txtAuthors = listAuthors.size()>1 ? "Authors: ": "Author: "; +// for (String author : listAuthors) { +// txtAuthors+= " "+author +","; +// } +// txtAuthors = txtAuthors.substring(0,txtAuthors.length()-2); +// String description = txtAuthors + ". ID Licenza: "+image.getLicenseID(); +// json.put("title", new JSONString(image.getDidascalia())); +// json.put("description", new JSONString(description)); +// json.put("downloadURL", new JSONString(imageContent.getLink())); +// jsonArray.set(index, json); +// index++; +// } +// } +// +// } +// showGallery(jsonArray.getJavaScriptObject(), galleryDivId); +// } +//} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java index 6610bf5..eb1d20e 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java @@ -1,333 +1,333 @@ -package org.gcube.portlets.user.geoportaldataviewer.client.ui.products.concessioni; - -import java.util.ArrayList; -import java.util.List; - -import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; -import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; -import org.gcube.application.geoportalcommon.shared.products.model.AbstractRelazioneScavoDV; -import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV; -import org.gcube.application.geoportalcommon.shared.products.model.RelazioneScavoDV; -import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV; -import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants; -import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION; -import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync; -import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils; -import org.gcube.portlets.user.geoportaldataviewer.client.ui.ModalWindow; -import org.gcube.portlets.user.geoportaldataviewer.client.ui.dialogs.DialogShareableLink; -import org.gcube.portlets.user.geoportaldataviewer.client.ui.gallery.ImagesGallery; -import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil; -import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.Location; -import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.PLACE; -import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.MapView; -import org.gcube.portlets.user.geoportaldataviewer.client.ui.util.CustomFlexTable; - -import com.github.gwtbootstrap.client.ui.Button; -import com.github.gwtbootstrap.client.ui.PageHeader; -import com.github.gwtbootstrap.client.ui.Paragraph; -import com.github.gwtbootstrap.client.ui.Thumbnails; -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.event.dom.client.ClickEvent; -import com.google.gwt.event.dom.client.ClickHandler; -import com.google.gwt.uibinder.client.UiBinder; -import com.google.gwt.uibinder.client.UiField; -import com.google.gwt.user.client.Window; -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.google.gwt.user.client.ui.Composite; -import com.google.gwt.user.client.ui.HTMLPanel; -import com.google.gwt.user.client.ui.Widget; - -import ol.Coordinate; - -public class ConcessioneView extends Composite { - - private static ConcessioneViewUiBinder uiBinder = GWT.create(ConcessioneViewUiBinder.class); - - interface ConcessioneViewUiBinder extends UiBinder { - } - - @UiField - PageHeader titolo; - - @UiField - Paragraph introduzione; - - @UiField - HTMLPanel concessioniPanel; - - @UiField - HTMLPanel relazioneScavoPanel; - - @UiField - HTMLPanel imagesPanel; - - @UiField - HTMLPanel pageViewDetails; - - @UiField - HTMLPanel mapViewPanel; - - @UiField - HTMLPanel posizionamentoAreaIndaginePanel; - - @UiField - HTMLPanel piantaFineScavoPanel; - - @UiField - Button shareButton; - - @UiField - Button expandButton; - - private ConcessioneDV concessioneDV; - - private Thumbnails thumbNails = new Thumbnails(); - - private CustomFlexTable customTable = new CustomFlexTable(); - - private GeoNaItemRef geonaItemRef; - - private String myLogin; - - private boolean viewImageButtonVisible = true; - - private boolean openImageButtonVisible = true; - - private ConcessioneView() { - initWidget(uiBinder.createAndBindUi(this)); - pageViewDetails.getElement().setId("page-view-details"); - } - - public ConcessioneView(GeoNaItemRef item, ConcessioneDV concDV) { - this(item, concDV, true, true); - } - - public ConcessioneView(GeoNaItemRef item, ConcessioneDV concDV, boolean viewImageButtonVisible, - boolean openImageButtonVisible) { - this(); - GWT.log("Rendering " + concDV.getNome()); - this.concessioneDV = concDV; - this.geonaItemRef = item; - this.viewImageButtonVisible = viewImageButtonVisible; - this.openImageButtonVisible = openImageButtonVisible; - - titolo.setText(concessioneDV.getNome()); - introduzione.setText(concessioneDV.getIntroduzione()); - - if (concessioneDV.getDataInizioProgetto() != null) { - customTable.addNextKeyValue("Data Inizio Progetto", - GeoportalDataViewerConstants.DT_FORMAT.format(concessioneDV.getDataInizioProgetto())); - } - - if (concessioneDV.getDataFineProgetto() != null) { - customTable.addNextKeyValue("Data Fine Progetto", - GeoportalDataViewerConstants.DT_FORMAT.format(concessioneDV.getDataFineProgetto())); - } - - if (concessioneDV.getParoleChiaveLibere() != null) { - customTable.addNextKeyValues("Parole chiave Libere", concessioneDV.getParoleChiaveLibere(), - GeoportalDataViewerConstants.NEW_LINE_BR); - } - - if (concessioneDV.getParoleChiaveICCD() != null) { - customTable.addNextKeyValues("Parole chiave Cronologia", concessioneDV.getParoleChiaveICCD(), - GeoportalDataViewerConstants.NEW_LINE_BR); - } - - if (concessioneDV.getAuthors() != null) { - customTable.addNextKeyValues("Staff", concessioneDV.getAuthors(), GeoportalDataViewerConstants.NEW_LINE_BR); - } - - if (concessioneDV.getContributore() != null) { - customTable.addNextKeyValue("Contributore", concessioneDV.getContributore()); - } - - if (concessioneDV.getEditore() != null) { - customTable.addNextKeyValue("Editore", concessioneDV.getEditore()); - } - - if (concessioneDV.getResponsabile() != null) { - customTable.addNextKeyValue("Responsabile", concessioneDV.getResponsabile()); - } - - if (concessioneDV.getRisorseCorrelate() != null) { - customTable.addNextKeyValues("Risorse Correlate", concessioneDV.getRisorseCorrelate(), - GeoportalDataViewerConstants.NEW_LINE_BR); - } - - if (concessioneDV.getTitolari() != null) { - customTable.addNextKeyValues("Titolari dei dati", concessioneDV.getTitolari(), - GeoportalDataViewerConstants.NEW_LINE_BR); - } - - if (concessioneDV.getSoggetto() != null) { - customTable.addNextKeyValues("Soggetti", concessioneDV.getSoggetto(), - GeoportalDataViewerConstants.NEW_LINE_BR); - } - - if (concessioneDV.getEditore() != null) { - customTable.addNextKeyValue("Editore", concessioneDV.getEditore()); - } - - if (concessioneDV.getFontiFinanziamento() != null) { - customTable.addNextKeyValues("Fonti di Finanziamento", concessioneDV.getFontiFinanziamento(), - GeoportalDataViewerConstants.NEW_LINE_BR); - } - - if (concessioneDV.getLicenzaID() != null) { - customTable.addNextKeyValue("ID Licenza", concessioneDV.getLicenzaID()); - } - - if (concessioneDV.getTitolariLicenza() != null) { - customTable.addNextKeyValues("Titolare Licenza", concessioneDV.getTitolariLicenza(), - GeoportalDataViewerConstants.NEW_LINE_BR); - } - - if (concessioneDV.getTitolariCopyright() != null) { - customTable.addNextKeyValues("Titolare Copyright", concessioneDV.getTitolariCopyright(), - GeoportalDataViewerConstants.NEW_LINE_BR); - } - - shareButton.setType(ButtonType.LINK); - shareButton.setIcon(IconType.SHARE); - shareButton.setTitle("Get a link to share with..."); - - shareButton.addClickHandler(new ClickHandler() { - - @Override - public void onClick(ClickEvent event) { - DialogShareableLink dg = new DialogShareableLink(geonaItemRef, null); - - } - }); - - expandButton.setType(ButtonType.LINK); - expandButton.setIcon(IconType.EXPAND); - expandButton.setTitle("Show this view in new Window"); - - expandButton.addClickHandler(new ClickHandler() { - - @Override - public void onClick(ClickEvent event) { - - ConcessioneView cv = new ConcessioneView(geonaItemRef, concessioneDV, false, openImageButtonVisible); - cv.setExpandViewButtonVisible(false); - int width = Window.getClientWidth() * 75 / 100; - int height = Window.getClientHeight() * 70 / 100; - ModalWindow mw = new ModalWindow(concessioneDV.getNome(), width, height); - mw.add(cv); - mw.setCaller(ConcessioneView.this); - // mw.setWidth(900); - mw.show(); - - } - }); - - concessioniPanel.add(customTable); - - GeoportalDataViewerServiceAsync.Util.getInstance().getMyLogin(new AsyncCallback() { - - @Override - public void onSuccess(String result) { - myLogin = result; - addCentroidMap(); - addRelazioneDiScavo(); - addPosizionamentoAreaIndagine(); - addPiantaFineScavo(); - } - - @Override - public void onFailure(Throwable caught) { - } - }); - - addUploadedImages(); - - } - - private void addPosizionamentoAreaIndagine() { - - LayerConcessioneDV layer = concessioneDV.getPosizionamentoScavo(); - if (layer == null) - return; - - posizionamentoAreaIndaginePanel.setVisible(true); - posizionamentoAreaIndaginePanel.add(new LayerConcessioneView(layer)); - } - - private void addPiantaFineScavo() { - - List listLayersDV = concessioneDV.getPianteFineScavo(); - - if (listLayersDV == null) - return; - - for (LayerConcessioneDV layerDV : listLayersDV) { - piantaFineScavoPanel.setVisible(true); - piantaFineScavoPanel.add(new LayerConcessioneView(layerDV)); - } - } - - private void addRelazioneDiScavo() { - - AbstractRelazioneScavoDV abstractRS = concessioneDV.getAbstractRelazioneScavo(); - RelazioneScavoDV relazioneScavo = concessioneDV.getRelazioneScavo(); - if (abstractRS == null && relazioneScavo==null) - return; - - relazioneScavoPanel.setVisible(true); - relazioneScavoPanel.add(new RelazioneScavoView(abstractRS, concessioneDV.getRelazioneScavo())); - } - - private void addCentroidMap() { - Location italyLocation = ExtentMapUtil.getLocation(PLACE.ITALY); - Coordinate transformedCenterCoordinate = italyLocation.getCoordinate(MAP_PROJECTION.EPSG_3857); - MapView mapView = new MapView(transformedCenterCoordinate, - GeoportalDataViewerConstants.LIGHT_MAP_ITALY_FIT_ZOOM_ON, "70%", "300px"); - - if (concessioneDV != null && concessioneDV.getCentroidLat() != null - && concessioneDV.getCentroidLong() != null) { - Coordinate coord = new Coordinate(concessioneDV.getCentroidLong(), concessioneDV.getCentroidLat()); - Coordinate transfCoord = MapUtils.transformCoordiante(coord, MAP_PROJECTION.EPSG_4326.getName(), - MAP_PROJECTION.EPSG_3857.getName()); - // Coordinate invertedCoordinate = MapUtils.reverseCoordinate(coord); - boolean authenticatedUser = myLogin != null ? true : false; - mapView.addMarker(transfCoord, authenticatedUser); - mapViewPanel.add(mapView); - } else if (concessioneDV != null) { - GeoportalDataViewerConstants - .printJs("I cannot add centroid as maker one or both coordinates are null. Lat: " - + concessioneDV.getCentroidLong() + ", Long:" + concessioneDV.getCentroidLat()); - } - } - - private void addUploadedImages() { - GWT.log("Managing immagini: " + concessioneDV.getImmaginiRappresentative()); - List immagini = concessioneDV.getImmaginiRappresentative(); - if (immagini != null && immagini.size() > 0) { - imagesPanel.setVisible(true); - - List immaginiToShow = new ArrayList(); - for (UploadedImageDV uploadedImageDV : immagini) { - immaginiToShow.add(uploadedImageDV); - } - - if (immaginiToShow.size() > 0) { - ImagesGallery gallery = new ImagesGallery(immaginiToShow); - imagesPanel.add(gallery.getGalleryPanel()); - gallery.fillGallery(); - } - } - } - - public ConcessioneDV getConcessioneDV() { - return concessioneDV; - } - - protected void setExpandViewButtonVisible(boolean bool) { - expandButton.setVisible(bool); - } - -} +//package org.gcube.portlets.user.geoportaldataviewer.client.ui.products.concessioni; +// +//import java.util.ArrayList; +//import java.util.List; +// +//import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; +//import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; +//import org.gcube.application.geoportalcommon.shared.products.model.AbstractRelazioneScavoDV; +//import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV; +//import org.gcube.application.geoportalcommon.shared.products.model.RelazioneScavoDV; +//import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV; +//import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants; +//import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION; +//import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync; +//import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils; +//import org.gcube.portlets.user.geoportaldataviewer.client.ui.ModalWindow; +//import org.gcube.portlets.user.geoportaldataviewer.client.ui.dialogs.DialogShareableLink; +//import org.gcube.portlets.user.geoportaldataviewer.client.ui.gallery.ImagesGallery; +//import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil; +//import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.Location; +//import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.PLACE; +//import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.MapView; +//import org.gcube.portlets.user.geoportaldataviewer.client.ui.util.CustomFlexTable; +// +//import com.github.gwtbootstrap.client.ui.Button; +//import com.github.gwtbootstrap.client.ui.PageHeader; +//import com.github.gwtbootstrap.client.ui.Paragraph; +//import com.github.gwtbootstrap.client.ui.Thumbnails; +//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.event.dom.client.ClickEvent; +//import com.google.gwt.event.dom.client.ClickHandler; +//import com.google.gwt.uibinder.client.UiBinder; +//import com.google.gwt.uibinder.client.UiField; +//import com.google.gwt.user.client.Window; +//import com.google.gwt.user.client.rpc.AsyncCallback; +//import com.google.gwt.user.client.ui.Composite; +//import com.google.gwt.user.client.ui.HTMLPanel; +//import com.google.gwt.user.client.ui.Widget; +// +//import ol.Coordinate; +// +//public class ConcessioneView extends Composite { +// +// private static ConcessioneViewUiBinder uiBinder = GWT.create(ConcessioneViewUiBinder.class); +// +// interface ConcessioneViewUiBinder extends UiBinder { +// } +// +// @UiField +// PageHeader titolo; +// +// @UiField +// Paragraph introduzione; +// +// @UiField +// HTMLPanel concessioniPanel; +// +// @UiField +// HTMLPanel relazioneScavoPanel; +// +// @UiField +// HTMLPanel imagesPanel; +// +// @UiField +// HTMLPanel pageViewDetails; +// +// @UiField +// HTMLPanel mapViewPanel; +// +// @UiField +// HTMLPanel posizionamentoAreaIndaginePanel; +// +// @UiField +// HTMLPanel piantaFineScavoPanel; +// +// @UiField +// Button shareButton; +// +// @UiField +// Button expandButton; +// +// private ConcessioneDV concessioneDV; +// +// private Thumbnails thumbNails = new Thumbnails(); +// +// private CustomFlexTable customTable = new CustomFlexTable(); +// +// private GeoNaItemRef geonaItemRef; +// +// private String myLogin; +// +// private boolean viewImageButtonVisible = true; +// +// private boolean openImageButtonVisible = true; +// +// private ConcessioneView() { +// initWidget(uiBinder.createAndBindUi(this)); +// pageViewDetails.getElement().setId("page-view-details"); +// } +// +// public ConcessioneView(GeoNaItemRef item, ConcessioneDV concDV) { +// this(item, concDV, true, true); +// } +// +// public ConcessioneView(GeoNaItemRef item, ConcessioneDV concDV, boolean viewImageButtonVisible, +// boolean openImageButtonVisible) { +// this(); +// GWT.log("Rendering " + concDV.getNome()); +// this.concessioneDV = concDV; +// this.geonaItemRef = item; +// this.viewImageButtonVisible = viewImageButtonVisible; +// this.openImageButtonVisible = openImageButtonVisible; +// +// titolo.setText(concessioneDV.getNome()); +// introduzione.setText(concessioneDV.getIntroduzione()); +// +// if (concessioneDV.getDataInizioProgetto() != null) { +// customTable.addNextKeyValue("Data Inizio Progetto", +// GeoportalDataViewerConstants.DT_FORMAT.format(concessioneDV.getDataInizioProgetto())); +// } +// +// if (concessioneDV.getDataFineProgetto() != null) { +// customTable.addNextKeyValue("Data Fine Progetto", +// GeoportalDataViewerConstants.DT_FORMAT.format(concessioneDV.getDataFineProgetto())); +// } +// +// if (concessioneDV.getParoleChiaveLibere() != null) { +// customTable.addNextKeyValues("Parole chiave Libere", concessioneDV.getParoleChiaveLibere(), +// GeoportalDataViewerConstants.NEW_LINE_BR); +// } +// +// if (concessioneDV.getParoleChiaveICCD() != null) { +// customTable.addNextKeyValues("Parole chiave Cronologia", concessioneDV.getParoleChiaveICCD(), +// GeoportalDataViewerConstants.NEW_LINE_BR); +// } +// +// if (concessioneDV.getAuthors() != null) { +// customTable.addNextKeyValues("Staff", concessioneDV.getAuthors(), GeoportalDataViewerConstants.NEW_LINE_BR); +// } +// +// if (concessioneDV.getContributore() != null) { +// customTable.addNextKeyValue("Contributore", concessioneDV.getContributore()); +// } +// +// if (concessioneDV.getEditore() != null) { +// customTable.addNextKeyValue("Editore", concessioneDV.getEditore()); +// } +// +// if (concessioneDV.getResponsabile() != null) { +// customTable.addNextKeyValue("Responsabile", concessioneDV.getResponsabile()); +// } +// +// if (concessioneDV.getRisorseCorrelate() != null) { +// customTable.addNextKeyValues("Risorse Correlate", concessioneDV.getRisorseCorrelate(), +// GeoportalDataViewerConstants.NEW_LINE_BR); +// } +// +// if (concessioneDV.getTitolari() != null) { +// customTable.addNextKeyValues("Titolari dei dati", concessioneDV.getTitolari(), +// GeoportalDataViewerConstants.NEW_LINE_BR); +// } +// +// if (concessioneDV.getSoggetto() != null) { +// customTable.addNextKeyValues("Soggetti", concessioneDV.getSoggetto(), +// GeoportalDataViewerConstants.NEW_LINE_BR); +// } +// +// if (concessioneDV.getEditore() != null) { +// customTable.addNextKeyValue("Editore", concessioneDV.getEditore()); +// } +// +// if (concessioneDV.getFontiFinanziamento() != null) { +// customTable.addNextKeyValues("Fonti di Finanziamento", concessioneDV.getFontiFinanziamento(), +// GeoportalDataViewerConstants.NEW_LINE_BR); +// } +// +// if (concessioneDV.getLicenzaID() != null) { +// customTable.addNextKeyValue("ID Licenza", concessioneDV.getLicenzaID()); +// } +// +// if (concessioneDV.getTitolariLicenza() != null) { +// customTable.addNextKeyValues("Titolare Licenza", concessioneDV.getTitolariLicenza(), +// GeoportalDataViewerConstants.NEW_LINE_BR); +// } +// +// if (concessioneDV.getTitolariCopyright() != null) { +// customTable.addNextKeyValues("Titolare Copyright", concessioneDV.getTitolariCopyright(), +// GeoportalDataViewerConstants.NEW_LINE_BR); +// } +// +// shareButton.setType(ButtonType.LINK); +// shareButton.setIcon(IconType.SHARE); +// shareButton.setTitle("Get a link to share with..."); +// +// shareButton.addClickHandler(new ClickHandler() { +// +// @Override +// public void onClick(ClickEvent event) { +// DialogShareableLink dg = new DialogShareableLink(geonaItemRef, null); +// +// } +// }); +// +// expandButton.setType(ButtonType.LINK); +// expandButton.setIcon(IconType.EXPAND); +// expandButton.setTitle("Show this view in new Window"); +// +// expandButton.addClickHandler(new ClickHandler() { +// +// @Override +// public void onClick(ClickEvent event) { +// +// ConcessioneView cv = new ConcessioneView(geonaItemRef, concessioneDV, false, openImageButtonVisible); +// cv.setExpandViewButtonVisible(false); +// int width = Window.getClientWidth() * 75 / 100; +// int height = Window.getClientHeight() * 70 / 100; +// ModalWindow mw = new ModalWindow(concessioneDV.getNome(), width, height); +// mw.add(cv); +// mw.setCaller(ConcessioneView.this); +// // mw.setWidth(900); +// mw.show(); +// +// } +// }); +// +// concessioniPanel.add(customTable); +// +// GeoportalDataViewerServiceAsync.Util.getInstance().getMyLogin(new AsyncCallback() { +// +// @Override +// public void onSuccess(String result) { +// myLogin = result; +// addCentroidMap(); +// addRelazioneDiScavo(); +// addPosizionamentoAreaIndagine(); +// addPiantaFineScavo(); +// } +// +// @Override +// public void onFailure(Throwable caught) { +// } +// }); +// +// addUploadedImages(); +// +// } +// +// private void addPosizionamentoAreaIndagine() { +// +// LayerConcessioneDV layer = concessioneDV.getPosizionamentoScavo(); +// if (layer == null) +// return; +// +// posizionamentoAreaIndaginePanel.setVisible(true); +// posizionamentoAreaIndaginePanel.add(new LayerConcessioneView(layer)); +// } +// +// private void addPiantaFineScavo() { +// +// List listLayersDV = concessioneDV.getPianteFineScavo(); +// +// if (listLayersDV == null) +// return; +// +// for (LayerConcessioneDV layerDV : listLayersDV) { +// piantaFineScavoPanel.setVisible(true); +// piantaFineScavoPanel.add(new LayerConcessioneView(layerDV)); +// } +// } +// +// private void addRelazioneDiScavo() { +// +// AbstractRelazioneScavoDV abstractRS = concessioneDV.getAbstractRelazioneScavo(); +// RelazioneScavoDV relazioneScavo = concessioneDV.getRelazioneScavo(); +// if (abstractRS == null && relazioneScavo==null) +// return; +// +// relazioneScavoPanel.setVisible(true); +// relazioneScavoPanel.add(new RelazioneScavoView(abstractRS, concessioneDV.getRelazioneScavo())); +// } +// +// private void addCentroidMap() { +// Location italyLocation = ExtentMapUtil.getLocation(PLACE.ITALY); +// Coordinate transformedCenterCoordinate = italyLocation.getCoordinate(MAP_PROJECTION.EPSG_3857); +// MapView mapView = new MapView(transformedCenterCoordinate, +// GeoportalDataViewerConstants.LIGHT_MAP_ITALY_FIT_ZOOM_ON, "70%", "300px"); +// +// if (concessioneDV != null && concessioneDV.getCentroidLat() != null +// && concessioneDV.getCentroidLong() != null) { +// Coordinate coord = new Coordinate(concessioneDV.getCentroidLong(), concessioneDV.getCentroidLat()); +// Coordinate transfCoord = MapUtils.transformCoordiante(coord, MAP_PROJECTION.EPSG_4326.getName(), +// MAP_PROJECTION.EPSG_3857.getName()); +// // Coordinate invertedCoordinate = MapUtils.reverseCoordinate(coord); +// boolean authenticatedUser = myLogin != null ? true : false; +// mapView.addMarker(transfCoord, authenticatedUser); +// mapViewPanel.add(mapView); +// } else if (concessioneDV != null) { +// GeoportalDataViewerConstants +// .printJs("I cannot add centroid as maker one or both coordinates are null. Lat: " +// + concessioneDV.getCentroidLong() + ", Long:" + concessioneDV.getCentroidLat()); +// } +// } +// +// private void addUploadedImages() { +// GWT.log("Managing immagini: " + concessioneDV.getImmaginiRappresentative()); +// List immagini = concessioneDV.getImmaginiRappresentative(); +// if (immagini != null && immagini.size() > 0) { +// imagesPanel.setVisible(true); +// +// List immaginiToShow = new ArrayList(); +// for (UploadedImageDV uploadedImageDV : immagini) { +// immaginiToShow.add(uploadedImageDV); +// } +// +// if (immaginiToShow.size() > 0) { +// ImagesGallery gallery = new ImagesGallery(immaginiToShow); +// imagesPanel.add(gallery.getGalleryPanel()); +// gallery.fillGallery(); +// } +// } +// } +// +// public ConcessioneDV getConcessioneDV() { +// return concessioneDV; +// } +// +// protected void setExpandViewButtonVisible(boolean bool) { +// expandButton.setVisible(bool); +// } +// +//} diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GcubeProfilesPerUCDIdCache.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GcubeProfilesPerUCDIdCache.java index 95532b9..b08232a 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GcubeProfilesPerUCDIdCache.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GcubeProfilesPerUCDIdCache.java @@ -57,7 +57,7 @@ public class GcubeProfilesPerUCDIdCache { RemovalListener>> removalListener = new RemovalListener>>() { public void onRemoval( RemovalNotification>> removal) { - LOG.debug("cache expired"); + LOG.info(GcubeProfilesPerUCDIdCache.class.getSimpleName() + " cache expired"); } }; diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java index dad8e72..4091b36 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java @@ -56,6 +56,7 @@ import org.gcube.portlets.user.geoportaldataviewer.server.util.ContextRequest; import org.gcube.portlets.user.geoportaldataviewer.server.util.SessionUtil; import org.gcube.portlets.user.geoportaldataviewer.shared.GCubeCollection; import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult; +import org.gcube.portlets.user.geoportaldataviewer.shared.ItemFieldsResponse; 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; @@ -786,7 +787,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme } @Override - public Map> listOfFieldsForSearching() throws Exception { + public List listOfFieldsForSearching() throws Exception { LOG.info("listOfFieldsForSearching called"); try { @@ -794,7 +795,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme // GNADataViewerConfigProfile profile = getGNADataVieweConfigProfile(); // return profile.getListItemFields(); - Map> map = new HashMap>(); + List listIFResponse = new ArrayList(); List handlersIds = Arrays.asList(GEOPORTAL_DATA_HANDLER.geoportal_data_list.getId()); List listUseCaseDescriptor; @@ -810,10 +811,10 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme listUseCaseDescriptor = new ArrayList(); } - List listUCDDV = new ArrayList(listUseCaseDescriptor.size()); + //List listUCDDV = new ArrayList(listUseCaseDescriptor.size()); for (UseCaseDescriptor ucd : listUseCaseDescriptor) { UseCaseDescriptorDV ucdDV = ConvertToDataValueObjectModel.toUseCaseDescriptorDV(ucd, null); - listUCDDV.add(ucdDV); + //listUCDDV.add(ucdDV); HandlerDeclarationDV dataListHandler = getHandlerDeclarationFor(ucdDV, GEOPORTAL_DATA_HANDLER.geoportal_data_list); @@ -821,8 +822,12 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme ConfigurationDV config = dataListHandler.getConfiguration(); switch (config.getConfigurationType()) { case item_fields: + ItemFieldsResponse ifResponse = new ItemFieldsResponse(); + ifResponse.setUseCaseDescriptorDV(ucdDV); List listItemFields = (List) config.getConfiguration(); - map.put(ucdDV.getProfileID(), listItemFields); + //map.put(ucdDV.getProfileID(), listItemFields); + ifResponse.setListItemFields(listItemFields); + listIFResponse.add(ifResponse); break; default: @@ -831,8 +836,8 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme } } - LOG.info("listOfFieldsForSearching returning: " + map); - return map; + LOG.info("listOfFieldsForSearching returning: " + listIFResponse); + return listIFResponse; } catch (Exception e) { LOG.error("Error on loading list of fields for searching: ", e); throw new Exception("Error occurred on loading list of fields for searching. Error: " + e.getMessage()); @@ -1062,8 +1067,11 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme LOG.info("Trying to get project for id " + profileID); - GeoportalServiceIdentityProxy cms = new GeoportalServiceIdentityProxy(this.getThreadLocalRequest()); - ProjectDV theProjectDV = cms.getProjectByID(profileID, projectID); + GeoportalServiceIdentityProxy geoIP = new GeoportalServiceIdentityProxy(this.getThreadLocalRequest()); + UseCaseDescriptorDV ucd = geoIP.getUCDByID(profileID); + ProjectDV theProjectDV = geoIP.getProjectByID(profileID, projectID); + + theProjectDV.setProfileName(ucd.getName()); ProjectView projectView = Geoportal_JSON_Mapper.loadProjectView(theProjectDV, scope, userName); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/GeoportalServiceIdentityProxy.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/GeoportalServiceIdentityProxy.java index 4f5e5e6..a84dbc3 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/GeoportalServiceIdentityProxy.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/GeoportalServiceIdentityProxy.java @@ -3,11 +3,14 @@ package org.gcube.portlets.user.geoportaldataviewer.server.mongoservice; import javax.servlet.http.HttpServletRequest; import org.gcube.application.geoportal.common.model.document.Project; +import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor; import org.gcube.application.geoportalcommon.ConvertToDataValueObjectModel; 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.shared.geoportal.project.ProjectDV; +import org.gcube.application.geoportalcommon.shared.geoportal.ucd.UseCaseDescriptorDV; import org.gcube.common.portal.PortalContext; import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentity.GcubeIdentity; import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentity.IAMClientIdentity; @@ -79,4 +82,17 @@ public class GeoportalServiceIdentityProxy { * gCubeIdentity.resetIdentity(); } */ } + + /** + * Gets the UCD by ID. + * + * @param profileID the profile ID + * @return the UCD by ID + * @throws Exception the exception + */ + public UseCaseDescriptorDV getUCDByID(String profileID) throws Exception { + UseCaseDescriptorCaller ucdCaller = GeoportalClientCaller.useCaseDescriptors(); + UseCaseDescriptor ucd = ucdCaller.getUCDForId(profileID); + return ConvertToDataValueObjectModel.toUseCaseDescriptorDV(ucd, null); + } } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/ItemFieldsResponse.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/ItemFieldsResponse.java new file mode 100644 index 0000000..258feab --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/shared/ItemFieldsResponse.java @@ -0,0 +1,49 @@ +package org.gcube.portlets.user.geoportaldataviewer.shared; + +import java.io.Serializable; +import java.util.List; + +import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV; +import org.gcube.application.geoportalcommon.shared.geoportal.ucd.UseCaseDescriptorDV; + +public class ItemFieldsResponse implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -8778792633248190350L; + UseCaseDescriptorDV useCaseDescriptorDV; + List listItemFields; + + public ItemFieldsResponse() { + + } + + public UseCaseDescriptorDV getUseCaseDescriptorDV() { + return useCaseDescriptorDV; + } + + public List getListItemFields() { + return listItemFields; + } + + public void setUseCaseDescriptorDV(UseCaseDescriptorDV useCaseDescriptorDV) { + this.useCaseDescriptorDV = useCaseDescriptorDV; + } + + public void setListItemFields(List listItemFields) { + this.listItemFields = listItemFields; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("ItemFieldsResponse [useCaseDescriptorDV="); + builder.append(useCaseDescriptorDV); + builder.append(", listItemFields="); + builder.append(listItemFields); + builder.append("]"); + return builder.toString(); + } + +}