diff --git a/.classpath b/.classpath
index e34d66e..d4c3ec2 100644
--- a/.classpath
+++ b/.classpath
@@ -1,12 +1,12 @@
-
+
-
+
@@ -35,5 +35,5 @@
-
+
diff --git a/.settings/com.gwtplugins.gdt.eclipse.core.prefs b/.settings/com.gwtplugins.gdt.eclipse.core.prefs
index 8e0f42e..f6e2e3f 100644
--- a/.settings/com.gwtplugins.gdt.eclipse.core.prefs
+++ b/.settings/com.gwtplugins.gdt.eclipse.core.prefs
@@ -1,4 +1,4 @@
eclipse.preferences.version=1
-lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-viewer-app/target/geoportal-data-viewer-app-2.4.0
+lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-viewer-app/target/geoportal-data-viewer-app-3.0.0-SNAPSHOT
warSrcDir=src/main/webapp
warSrcDirIsOutput=false
diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component
index 052cbcb..321953b 100644
--- a/.settings/org.eclipse.wst.common.component
+++ b/.settings/org.eclipse.wst.common.component
@@ -1,5 +1,5 @@
-
+
@@ -17,8 +17,14 @@
-
-
+
+
+
+
+
+
+
+
@@ -37,7 +43,10 @@
-
+
+
+
+
@@ -56,7 +65,10 @@
-
+
+
+
+
@@ -75,7 +87,10 @@
-
+
+
+
+
@@ -94,7 +109,10 @@
-
+
+
+
+
@@ -113,7 +131,10 @@
-
+
+
+
+
@@ -132,7 +153,10 @@
-
+
+
+
+
@@ -151,7 +175,10 @@
-
+
+
+
+
@@ -170,7 +197,10 @@
-
+
+
+
+
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c80c64e..60c9c15 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,12 +4,14 @@
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-10-11
+
+- [#23940] Passed to CMS-UCD
+
## [v2.4.1-SNAPSHOT] - 2022-09-28
-
- [#23906] Tested building on jenkins with JDK_11
-
## [v2.4.0] - 2022-09-07
#### Enhancement
diff --git a/pom.xml b/pom.xml
index 2444f39..89c084c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -14,7 +14,7 @@
org.gcube.portlets.user
geoportal-data-viewer-app
war
- 2.4.1-SNAPSHOT
+ 3.0.0-SNAPSHOT
GeoPortal Data Viewer App
The GeoPortal Data Viewer App is an application to access, discovery and navigate the GeoNa products by a Web-Map Interface
@@ -157,40 +157,46 @@
-
-
- org.gcube.common
- metadata-profile-discovery
- [1.0.0-SNAPSHOT, 1.1.0-SNAPSHOT)
-
-
- org.gcube.application
- geoportal-data-common
- [1.0.0-SNAPSHOT, 1.5.0-SNAPSHOT)
- compile
-
-
- org.gcube.application
- geoportal-client
- [1.0.0, 1.1.0-SNAPSHOT)
+ org.gcube.portlets.widgets
+ metadata-profile-form-builder-widget
+ [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)
compile
+
- org.gcube.resources.discovery
- ic-client
+ com.fasterxml.jackson.core
+ jackson-core
- org.ow2.asm
- asm
+ com.fasterxml.jackson.core
+ jackson-databind
- javax.servlet
- servlet-api
+ de.grundid.opendatalab
+ geojson-jackson
-
+
+
+ org.gcube.application
+ geoportal-data-common
+ [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)
+ compile
+
+
+ com.jayway.jsonpath
+ json-path
+ 2.7.0
+ compile
+
+
+
+ com.google.guava
+ guava
+
org.gcube.common
@@ -221,6 +227,7 @@
provided
+
junit
junit
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 664bfdd..5736727 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
@@ -1,17 +1,17 @@
package org.gcube.portlets.user.geoportaldataviewer.client;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
-import org.gcube.application.geoportalcommon.shared.ItemField;
import org.gcube.application.geoportalcommon.shared.LayerItem;
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.view.ProjectView;
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
import org.gcube.application.geoportalcommon.shared.products.model.RecordDV;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION;
@@ -55,7 +55,6 @@ import com.google.gwt.core.client.ScriptInjector;
import com.google.gwt.event.logical.shared.ResizeEvent;
import com.google.gwt.event.logical.shared.ResizeHandler;
import com.google.gwt.event.shared.HandlerManager;
-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.HTML;
@@ -112,9 +111,9 @@ public class GeoportalDataViewer implements EntryPoint {
private static List listBaseMapLayers = null;
- private List displayFields = new ArrayList();
- private List sortByFields = new ArrayList();
- private List searchByFields = new ArrayList();
+ private List displayFields = new ArrayList();
+ private List sortByFields = new ArrayList();
+ private List searchByFields = new ArrayList();
/**
* This is the entry point method.
@@ -135,7 +134,7 @@ public class GeoportalDataViewer implements EntryPoint {
RootPanel.get(APP_DIV).add(loaderApp);
- GeoportalDataViewerServiceAsync.Util.getInstance().listOfFieldsForSearching(new AsyncCallback>() {
+ GeoportalDataViewerServiceAsync.Util.getInstance().listOfFieldsForSearching(new AsyncCallback>() {
@Override
public void onFailure(Throwable caught) {
@@ -144,10 +143,10 @@ public class GeoportalDataViewer implements EntryPoint {
}
@Override
- public void onSuccess(List result) {
+ public void onSuccess(List result) {
GWT.log("Loaded item fields: "+result);
- for (ItemField itemField : result) {
+ for (ItemFieldDV itemField : result) {
if(itemField.isDisplayAsResult()) {
displayFields.add(itemField);
}
@@ -165,7 +164,9 @@ public class GeoportalDataViewer implements EntryPoint {
GWT.log("List display fields: "+result);
SearchingFilter initialSortFilter = new SearchingFilter();
initialSortFilter.setOrder(ORDER.ASC);
- initialSortFilter.setOrderByFields(Arrays.asList(new ItemField("Name", Arrays.asList("name"), true, true, true)));
+
+ //TODO MUST BE REVISITED
+ //initialSortFilter.setOrderByFields(Arrays.asList(new ItemField("Name", Arrays.asList("name"), true, true, true)));
mainPanel = new GeonaDataViewMainPanel(applicationBus, getClientHeight(),sortByFields,searchByFields,initialSortFilter);
RootPanel.get(APP_DIV).add(mainPanel);
@@ -263,7 +264,10 @@ public class GeoportalDataViewer implements EntryPoint {
geonaDataViewerProfile = profile;
GWT.log("Profile: " + geonaDataViewerProfile);
Iterator it;
- String theItemType = paramGeonaItemType;
+
+
+
+ String theItemType = null;
if (theItemType == null) {
it = geonaDataViewerProfile.getMapLayers().keySet().iterator();
it.hasNext();
@@ -272,10 +276,10 @@ public class GeoportalDataViewer implements EntryPoint {
LayerItem layerItem = geonaDataViewerProfile.getMapLayers().get(theItemType);
- if (layerItem == null) {
- Window.alert("Not detected any layer with type: " + theItemType);
- return;
- }
+// if (layerItem == null) {
+// Window.alert("Not detected any layer with type: " + theItemType);
+// return;
+// }
GWT.log("ON module load The layerItem is: " + layerItem);
String layerName = URLUtil.getValueOfParameter("layers", layerItem.getWmsLink());
@@ -333,39 +337,55 @@ public class GeoportalDataViewer implements EntryPoint {
public void onShowDetails(ShowDetailsEvent showDetailsEvent) {
GWT.log("Fired event: " + showDetailsEvent);
- String geonaMongoId = showDetailsEvent.getGeonaMongoID();
+ String projectID = showDetailsEvent.getGeonaMongoID();
+ String profileID = showDetailsEvent.getGeonaItemType();
- if (geonaMongoId == null) {
+ if (projectID == null) {
Window.alert("Item Id not found");
return;
}
// TODO
boolean found = false;
- GWT.log("Product with id: " + geonaMongoId + " found? " + found);
+ GWT.log("Product with id: " + projectID + " found? " + found);
+
+
+ GeoportalDataViewerServiceAsync.Util.getInstance().getProjectViewForId(profileID, projectID, new AsyncCallback() {
- if (!found) {
-
- if (showDetailsEvent.getGeonaItemType().equalsIgnoreCase("Concessione")) {
-
- GeoportalDataViewerServiceAsync.Util.getInstance().getConcessioneForId(geonaMongoId,
- new AsyncCallback() {
-
- @Override
- public void onFailure(Throwable caught) {
- Window.alert(caught.getMessage());
- mainPanel.hidePanelDetails();
-
- }
-
- @Override
- public void onSuccess(ConcessioneDV concessioneDV) {
- GWT.log("Showing: " + concessioneDV);
- mainPanel.showAsDetails(concessioneDV, showDetailsEvent.getGeonaItemRef());
- }
- });
+ @Override
+ public void onFailure(Throwable caught) {
+ // TODO Auto-generated method stub
+
}
- }
+
+ @Override
+ public void onSuccess(ProjectView result) {
+ mainPanel.showAsDetails(result, showDetailsEvent.getGeonaItemRef());
+ }
+ });
+
+// if (!found) {
+//
+// if (showDetailsEvent.getGeonaItemType().equalsIgnoreCase("Concessione")) {
+//
+// GeoportalDataViewerServiceAsync.Util.getInstance().getConcessioneForId(geonaMongoId,
+// new AsyncCallback() {
+//
+// @Override
+// public void onFailure(Throwable caught) {
+// Window.alert(caught.getMessage());
+// mainPanel.hidePanelDetails();
+//
+// }
+//
+// @Override
+// public void onSuccess(ConcessioneDV concessioneDV) {
+// GWT.log("Showing: " + concessioneDV);
+// mainPanel.showAsDetails(concessioneDV, showDetailsEvent.getGeonaItemRef());
+// }
+// });
+// }
+// }
}
});
@@ -378,6 +398,8 @@ public class GeoportalDataViewer implements EntryPoint {
try {
+ GWT.log("onLayerRendered Timer PART MUST BE REVISITED");
+ /*
attempt = 0;
if (paramGeonaItemID != null) {
@@ -388,6 +410,10 @@ public class GeoportalDataViewer implements EntryPoint {
public void run() {
attempt++;
GWT.log("waiting get record: " + attempt);
+
+
+
+
RecordDV record = mainPanel.getDisplayedRecord();
if (record != null) {
this.cancel();
@@ -404,11 +430,12 @@ public class GeoportalDataViewer implements EntryPoint {
};
timer.scheduleRepeating(1000);
- }
+ }
+ */
} catch (Exception e) {
// TODO: handle exception
}
-
+
LAYER_TYPE layerType = addedLayerToMapEvent.getLayerType();
if (layerType != null) {
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java
index 5f7b211..bd6dc11 100644
--- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java
@@ -106,5 +106,72 @@ public class GeoportalDataViewerConstants {
public static native String toJsonObj(Object object)/*-{
return JSON.stringify(object);
}-*/;
+
+
+ /**
+ * Json to HTML.
+ *
+ * @param jsonTxt the json txt
+ * @return the string
+ */
+ public static native String jsonToTableHTML(String jsonTxt)/*-{
+ try {
+ var jsonObj = JSON.parse(jsonTxt);
+
+ if (jsonObj.length == undefined)
+ jsonObj = [ jsonObj ]
+ //console.log(jsonObj.length)
+
+ // EXTRACT VALUE FOR HTML HEADER.
+ var col = [];
+ for (var i = 0; i < jsonObj.length; i++) {
+ for ( var key in jsonObj[i]) {
+ //console.log('key json' +key)
+ if (col.indexOf(key) === -1) {
+ col.push(key);
+ }
+ }
+ }
+
+ // CREATE DYNAMIC TABLE.
+ var table = document.createElement("table");
+ try {
+ table.classList.add("my-html-table");
+
+ } catch (e) {
+ console.log('invalid css add', e);
+ }
+
+ // ADD JSON DATA TO THE TABLE AS ROWS.
+ for (var i = 0; i < col.length; i++) {
+ tr = table.insertRow(-1);
+ var firstCell = tr.insertCell(-1);
+ //firstCell.style.cssText="font-weight: bold; text-align: center; vertical-align: middle;";
+ firstCell.innerHTML = col[i];
+ for (var j = 0; j < jsonObj.length; j++) {
+ var tabCell = tr.insertCell(-1);
+ var theValue = jsonObj[j][col[i]];
+ //console.log("the value: "+theValue);
+ if (Object.prototype.toString.call(theValue) === '[object Array]') {
+ var formattedValueArray = "";
+ for (var k = 0; k < theValue.length; k++) {
+ var theValueArray = theValue[k];
+ //console.log(theValueArray);
+ formattedValueArray += theValueArray + "
";
+ }
+ tabCell.innerHTML = formattedValueArray;
+ } else {
+ tabCell.innerHTML = theValue;
+ }
+ }
+ }
+
+ return table.outerHTML;
+ } catch (e) {
+ console.log('invalid json', e);
+ return jsonTxt;
+ }
+
+ }-*/;
}
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 bba187a..879b077 100644
--- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerService.java
@@ -4,9 +4,10 @@ import java.util.List;
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
-import org.gcube.application.geoportalcommon.shared.ItemField;
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;
@@ -136,7 +137,7 @@ public interface GeoportalDataViewerService extends RemoteService {
* @return the list
* @throws Exception
*/
- List listOfFieldsForSearching() throws Exception;
+ List listOfFieldsForSearching() throws Exception;
/**
* Gets the list concessioni.
@@ -151,4 +152,14 @@ public interface GeoportalDataViewerService extends RemoteService {
ResultSetPaginatedData getListConcessioni(Integer start, Integer limit, SearchingFilter filter,
boolean reloadFromService) throws Exception;
+ /**
+ * Gets the project view for id.
+ *
+ * @param profileID the profile ID
+ * @param projectID the project ID
+ * @return the project view for id
+ * @throws Exception the exception
+ */
+ ProjectView getProjectViewForId(String profileID, String projectID) throws Exception;
+
}
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java
index 143455e..e640956 100644
--- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerServiceAsync.java
@@ -4,9 +4,10 @@ import java.util.List;
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
-import org.gcube.application.geoportalcommon.shared.ItemField;
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;
@@ -63,9 +64,11 @@ 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);
+ void getProjectViewForId(String profileID, String projectID, AsyncCallback callback);
+
}
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 94b16cb..1d9b70f 100644
--- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/DetailsPanel.java
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/DetailsPanel.java
@@ -1,10 +1,9 @@
package org.gcube.portlets.user.geoportaldataviewer.client.ui;
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
-import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
-import org.gcube.application.geoportalcommon.shared.products.model.RecordDV;
+import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ClosedViewDetailsEvent;
-import org.gcube.portlets.user.geoportaldataviewer.client.ui.products.concessioni.ConcessioneView;
+import org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.project.ProjectViewer;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
@@ -33,7 +32,7 @@ public class DetailsPanel extends Composite {
@UiField
HTMLPanel detailsHTMLPanel;
- private RecordDV displayedRecord = null;
+ private ProjectView displayedProject = null;
private HandlerManager applicationBus;
@@ -63,15 +62,17 @@ public class DetailsPanel extends Composite {
}
- public void showDetailsFor(ConcessioneDV cdv, GeoNaItemRef geonaItemRef) {
- this.displayedRecord = cdv;
+ public void showDetailsFor(ProjectView result, GeoNaItemRef geonaItemRef) {
+ this.displayedProject = result;
datailsContainerPanel.clear();
if(detailsHTMLPanel.getParent()!=null) {
detailsHTMLPanel.getParent().getElement().setScrollTop(0);
}
- datailsContainerPanel.add(new ConcessioneView(geonaItemRef, cdv));
+ //datailsContainerPanel.add(new ConcessioneView(geonaItemRef, result));
+
+ datailsContainerPanel.add(new ProjectViewer(geonaItemRef, result));
showPanelDetails();
}
@@ -80,13 +81,13 @@ public class DetailsPanel extends Composite {
}
public void hidePanelDetails() {
- this.displayedRecord = null;
+ this.displayedProject = null;
datailsContainerPanel.clear();
detailsHTMLPanel.setVisible(false);
}
- public RecordDV getDisplayedRecord() {
- return displayedRecord;
+ public ProjectView getDisplayedProject() {
+ return displayedProject;
}
}
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 37803a9..70e25ea 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,10 +3,9 @@ package org.gcube.portlets.user.geoportaldataviewer.client.ui;
import java.util.List;
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
-import org.gcube.application.geoportalcommon.shared.ItemField;
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
-import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
-import org.gcube.application.geoportalcommon.shared.products.model.RecordDV;
+import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
+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;
import org.gcube.portlets.user.geoportaldataviewer.client.events.MapExtentToEvent;
@@ -91,25 +90,25 @@ public class GeonaDataViewMainPanel extends Composite {
@UiField
Button linkLayers;
-
+
@UiField
DropdownButton searchFacilityButton;
@UiField
ScrollPanel overlayLayersPanel;
-
+
@UiField
ScrollPanel searchFacilityPanel;
@UiField
HTMLPanel panelAttribution;
-
+
@UiField
HTMLPanel panelBaseLayers;
-
+
@UiField
DropdownButton linkMap;
-
+
@UiField
DropdownButton linkPresetLocation;
@@ -118,18 +117,20 @@ public class GeonaDataViewMainPanel extends Composite {
private OpenLayerMap map;
private HandlerManager applicationBus;
-
+
private SearchFacilityUI searchFacility;
-
-
+
/**
* Instantiates a new geona data view main panel.
*
- * @param applicationBus the application bus
- * @param mapHeight the map height
+ * @param applicationBus the application bus
+ * @param mapHeight the map height
+ * @param sortByFields the sort by fields
+ * @param searchForFields the search for fields
+ * @param initialSortFilter the initial sort filter
*/
- public GeonaDataViewMainPanel(HandlerManager applicationBus, int mapHeight, List sortByFields,
- List searchForFields, SearchingFilter initialSortFilter) {
+ public GeonaDataViewMainPanel(HandlerManager applicationBus, int mapHeight, List sortByFields,
+ List searchForFields, SearchingFilter initialSortFilter) {
initWidget(uiBinder.createAndBindUi(this));
this.applicationBus = applicationBus;
mapPanel = new MapPanel(mapHeight + "px");
@@ -150,11 +151,11 @@ public class GeonaDataViewMainPanel extends Composite {
worldImg.getElement().getStyle().setPaddingLeft(20, Unit.PX);
extentToEarth.getElement().appendChild(worldImg.getElement());
extentToEarth.setWidth("140px");
-
+
linkMap.setCustomIconStyle(GNAIcons.CustomIconType.MAP.get());
linkPresetLocation.setCustomIconStyle(GNAIcons.CustomIconType.PRESET_LOCATION.get());
linkLayers.setCustomIconStyle(GNAIcons.CustomIconType.LAYERS.get());
-
+
searchFacility = new SearchFacilityUI(applicationBus, sortByFields, searchForFields, initialSortFilter);
searchFacility.setSearchButton(searchFacilityButton);
searchFacilityButton.setIcon(IconType.SEARCH);
@@ -164,16 +165,19 @@ public class GeonaDataViewMainPanel extends Composite {
@Override
public void execute() {
searchFacilityPanel.getElement().getParentElement().getStyle().setOpacity(0.9);
-
+
}
-
+
});
-
+
// layersDDB.setToggle(true);
bindEvents();
}
-
+
+ /**
+ * Bind events.
+ */
private void bindEvents() {
linkLayers.addClickHandler(new ClickHandler() {
@@ -190,17 +194,17 @@ public class GeonaDataViewMainPanel extends Composite {
}
}
});
-
+
searchFacilityButton.addDomHandler(new ClickHandler() {
-
+
@Override
public void onClick(ClickEvent event) {
- //event.preventDefault();
+ // event.preventDefault();
event.stopPropagation();
-
+
}
}, ClickEvent.getType());
-
+
}
/**
@@ -217,6 +221,9 @@ public class GeonaDataViewMainPanel extends Composite {
}
+ /**
+ * Sets the overlay panel max height.
+ */
private void setOverlayPanelMaxHeight() {
String overlMH = mapPanel.getOffsetHeight() - 130 + "px";
@@ -311,11 +318,11 @@ public class GeonaDataViewMainPanel extends Composite {
/**
* Show as details.
*
- * @param concessioneDV the concessione DV
- * @param geonaItemRef the geona item ref
+ * @param result the result
+ * @param geonaItemRef the geona item ref
*/
- public void showAsDetails(ConcessioneDV concessioneDV, GeoNaItemRef geonaItemRef) {
- detailsPanel.showDetailsFor(concessioneDV, geonaItemRef);
+ public void showAsDetails(ProjectView result, GeoNaItemRef geonaItemRef) {
+ detailsPanel.showDetailsFor(result, geonaItemRef);
}
@@ -327,13 +334,14 @@ public class GeonaDataViewMainPanel extends Composite {
}
+
/**
- * Gets the displyed record.
+ * Gets the displayed record.
*
- * @return the displyed record
+ * @return the displayed record
*/
- public RecordDV getDisplayedRecord() {
- return detailsPanel.getDisplayedRecord();
+ public ProjectView getDisplayedRecord() {
+ return detailsPanel.getDisplayedProject();
}
/**
@@ -361,6 +369,9 @@ public class GeonaDataViewMainPanel extends Composite {
// layersDDBClickEvent();
}
+ /**
+ * Layers DDB click event.
+ */
private void layersDDBClickEvent() {
linkLayers.fireEvent(new GwtEvent() {
@Override
@@ -386,6 +397,11 @@ public class GeonaDataViewMainPanel extends Composite {
// layersDDBClickEvent();
}
+ /**
+ * Sets the map attribution.
+ *
+ * @param attribution the new map attribution
+ */
public void setMapAttribution(String attribution) {
panelAttribution.clear();
Label label = new Label("Base Map Credits");
@@ -393,39 +409,43 @@ public class GeonaDataViewMainPanel extends Composite {
panelAttribution.add(label);
panelAttribution.add(p);
}
-
+
+ /**
+ * Sets the base layers.
+ *
+ * @param listBaseLayers the new base layers
+ */
public void setBaseLayers(List listBaseLayers) {
-
- if(listBaseLayers==null)
+
+ if (listBaseLayers == null)
return;
-
+
int i = 0;
for (BaseMapLayer baseMapLayer : listBaseLayers) {
-
+
RadioButton radio = new RadioButton("base-layer");
radio.setText(baseMapLayer.getName());
- if(i==0) {
+ if (i == 0) {
radio.setValue(true, false);
}
-
+
radio.addValueChangeHandler(new ValueChangeHandler() {
-
+
@Override
public void onValueChange(ValueChangeEvent event) {
applicationBus.fireEvent(new ChangeMapLayerEvent(baseMapLayer));
-
+
}
});
-
+
SimplePanel sp = new SimplePanel(radio);
sp.getElement().addClassName("form-inline");
sp.getElement().addClassName("map-layers-radio");
panelBaseLayers.add(sp);
i++;
}
-
+
}
-
}
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/SearchFacilityUI.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/SearchFacilityUI.java
index d89d048..83d3066 100644
--- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/SearchFacilityUI.java
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/SearchFacilityUI.java
@@ -6,21 +6,15 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
-import org.gcube.application.geoportalcommon.shared.ItemField;
import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData;
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
import org.gcube.application.geoportalcommon.shared.SearchingFilter.LOGICAL_OP;
import org.gcube.application.geoportalcommon.shared.SearchingFilter.ORDER;
import org.gcube.application.geoportalcommon.shared.WhereClause;
-import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
-import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
+import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync;
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.util.LoaderIcon;
-import org.gcube.portlets.user.geoportaldataviewer.client.util.StringUtil;
import com.github.gwtbootstrap.client.ui.Alert;
import com.github.gwtbootstrap.client.ui.Button;
@@ -30,7 +24,6 @@ import com.github.gwtbootstrap.client.ui.NavLink;
import com.github.gwtbootstrap.client.ui.TextBox;
import com.github.gwtbootstrap.client.ui.constants.AlertType;
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.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
@@ -44,7 +37,6 @@ 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.HTML;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.HorizontalPanel;
@@ -85,9 +77,9 @@ public class SearchFacilityUI extends Composite {
@UiField
HorizontalPanel toogleSortBy;
- private List searchForFields;
+ private List searchForFields;
- private List sortByFields;
+ private List sortByFields;
private SearchingFilter currentSortFilter;
@@ -117,7 +109,7 @@ public class SearchFacilityUI extends Composite {
* @param searchForFields the search for fields
* @param initialSortFilter the initial sort filter
*/
- public SearchFacilityUI(HandlerManager appManagerBus, List sortByFields, List searchForFields,
+ public SearchFacilityUI(HandlerManager appManagerBus, List sortByFields, List searchForFields,
SearchingFilter initialSortFilter) {
initWidget(uiBinder.createAndBindUi(this));
this.searchForFields = searchForFields;
@@ -140,7 +132,7 @@ public class SearchFacilityUI extends Composite {
* @param direction the direction
* @return the string
*/
- private String toLabelFilter(ItemField itemField, ORDER direction) {
+ private String toLabelFilter(ItemFieldDV itemField, ORDER direction) {
String labelFilter = itemField.getDisplayName() + LABEL_FILTER_SEPARATOR + direction.name();
return labelFilter;
}
@@ -150,7 +142,7 @@ public class SearchFacilityUI extends Composite {
*/
private void bindEvents() {
- for (ItemField record_FIELD : sortByFields) {
+ for (ItemFieldDV record_FIELD : sortByFields) {
if(record_FIELD.isSortable()) {
String labelASC = toLabelFilter(record_FIELD, ORDER.ASC);
String labelDESC = toLabelFilter(record_FIELD, ORDER.DESC);
@@ -169,7 +161,7 @@ public class SearchFacilityUI extends Composite {
}
});
- for (ItemField record_FIELD : searchForFields) {
+ for (ItemFieldDV record_FIELD : searchForFields) {
GWT.log("search for: "+record_FIELD);
if(record_FIELD.isSearchable()) {
listBoxSearchFor.addItem(record_FIELD.getDisplayName());
@@ -264,7 +256,11 @@ public class SearchFacilityUI extends Composite {
@Override
public void onSuccess(ResultSetPaginatedData result) {
+ Window.alert("searchConcessioni must be revisited");
+ /*
appManagerBus.fireEvent(new SearchPerformedEvent(result.getData(),false));
+
+
setSearchEnabled(true);
latestResult = result;
@@ -306,7 +302,7 @@ public class SearchFacilityUI extends Composite {
}
i = 1;
- for (ConcessioneDV concessione : result.getData()) {
+ for (DocumentDV concessione : result.getData()) {
int j = -1;
NavLink locateOnMap = new NavLink("Show");
@@ -344,32 +340,13 @@ public class SearchFacilityUI extends Composite {
ft.setWidget(i, ++j, new HTML(toDisplayList(concessione.getParoleChiaveICCD())));
}
-
-// List listImg = concessione.getImmaginiRappresentative();
-// GWT.log(listImg.toString());
-// boolean imagePreviewFound = false;
-// if (listImg != null && listImg.size() > 0) {
-//
-// UploadedImageDV uImg = listImg.get(0);
-//
-// if (uImg != null && uImg.getListWsContent() != null
-// && uImg.getListWsContent().size() > 0) {
-// WorkspaceContentDV wsc = uImg.getListWsContent().get(0);
-// String image = "";
-// ft.setWidget(i, 2, new HTML(image));
-// imagePreviewFound = true;
-// }
-// }
-//
-// if (!imagePreviewFound) {
-// ft.setWidget(i, 2, new Image(GNAImages.ICONS.italyIcon()));
-// }
+
i++;
}
panelResults.add(ft);
+ */
}
});
@@ -421,8 +398,8 @@ public class SearchFacilityUI extends Composite {
SearchingFilter sortFilter = null;
try {
- ItemField recordField = null;
- for (ItemField value : sortByFields) {
+ ItemFieldDV recordField = null;
+ for (ItemFieldDV value : sortByFields) {
if (array[0].equalsIgnoreCase(value.getDisplayName())) {
recordField = value;
break;
@@ -451,7 +428,7 @@ public class SearchFacilityUI extends Composite {
List listOfSeachingFields = new ArrayList();
- for (ItemField recordField : searchForFields) {
+ for (ItemFieldDV recordField : searchForFields) {
if (recordField.getDisplayName().equals(listBoxSearchFor.getSelectedValue())) {
listOfSeachingFields = recordField.getJsonFields();
continue;
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/gallery/ImagesSectionGallery.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/gallery/ImagesSectionGallery.java
new file mode 100644
index 0000000..7105c2f
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/gallery/ImagesSectionGallery.java
@@ -0,0 +1,201 @@
+package org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.gallery;
+
+import java.util.Set;
+
+import org.gcube.application.geoportalcommon.shared.geoportal.view.FilesetDV;
+import org.gcube.application.geoportalcommon.shared.geoportal.view.PayloadDV;
+import org.gcube.application.geoportalcommon.shared.geoportal.view.SectionView;
+import org.gcube.application.geoportalcommon.shared.geoportal.view.SubDocumentView;
+
+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.JSONParser;
+import com.google.gwt.json.client.JSONString;
+import com.google.gwt.json.client.JSONValue;
+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 ImagesSectionGallery {
+
+ private HTMLPanel galleryPanel;
+ private String galleryDivId;
+ private SectionView sectionView;
+
+ /**
+ * Show gallery.
+ *
+ * @param json_array_images the json array images
+ * @param galleryDivId the gallery div id
+ */
+ 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 section gallery.
+ *
+ * @param sectionView the section view
+ */
+ public ImagesSectionGallery(SectionView sectionView) {
+ this.galleryDivId = "nanogallery" + Random.nextInt() + Random.nextInt();
+ this.galleryPanel = new HTMLPanel("");
+ this.sectionView = sectionView;
+ }
+
+ /**
+ * 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 (SubDocumentView subdoc : sectionView.getListSubDocuments()) {
+ JSONValue meta = JSONParser.parseStrict(subdoc.getMetadataAsJSON());
+
+ for (FilesetDV image : subdoc.getListImages()) {
+ if (image.getListPayload() != null) {
+ for (PayloadDV payloadDV : image.getListPayload()) {
+ JSONObject json = new JSONObject();
+ json.put("src", new JSONString(payloadDV.getLink()));
+ json.put("srct", new JSONString(payloadDV.getLink()));
+ json.put("downloadURL", new JSONString(payloadDV.getLink()));
+ json.put("title", new JSONString(getFirstValueOfJSON(meta)));
+ json.put("description", new JSONString(meta.toString()));
+ jsonArray.set(index, json);
+ index++;
+ }
+
+ }
+
+ }
+ }
+
+ showGallery(jsonArray.getJavaScriptObject(), galleryDivId);
+ }
+
+ /**
+ * Gets the first value of JSON.
+ *
+ * @param metadata the metadata
+ * @return the first value of JSON
+ */
+ public String getFirstValueOfJSON(JSONValue metadata) {
+
+ String value = "";
+
+ if (metadata == null)
+ return value;
+
+ if (metadata.isArray() != null) {
+ JSONArray array = (JSONArray) metadata;
+ for (int i = 0; i < array.size(); i++) {
+ JSONObject object = (JSONObject) array.get(i);
+ Set set = object.keySet();
+ value = object.get(set.iterator().next()).toString();
+ }
+ } else if (metadata.isObject() != null) {
+ JSONObject object = (JSONObject) metadata;
+ Set set = object.keySet();
+ value = object.get(set.iterator().next()).toString();
+ } else if (metadata.isString() != null) {
+ value = metadata.toString();
+ }
+
+ return value;
+ }
+}
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/project/ProjectViewer.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/project/ProjectViewer.java
new file mode 100644
index 0000000..a779604
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/project/ProjectViewer.java
@@ -0,0 +1,176 @@
+package org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.project;
+
+import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
+import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
+import org.gcube.application.geoportalcommon.shared.geoportal.view.SectionView;
+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.ui.dialogs.DialogShareableLink;
+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.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 ProjectViewer extends Composite {
+
+ private static ProjectViewerUiBinder uiBinder = GWT.create(ProjectViewerUiBinder.class);
+
+ interface ProjectViewerUiBinder extends UiBinder {
+ }
+
+ @UiField
+ PageHeader title;
+
+ @UiField
+ HTMLPanel pageViewDetails;
+
+ @UiField
+ Button shareButton;
+
+ @UiField
+ Button expandButton;
+
+ private ProjectView projectView;
+
+ private CustomFlexTable customTable = new CustomFlexTable();
+
+ private GeoNaItemRef geonaItemRef;
+
+ private String myLogin;
+
+ private boolean viewImageButtonVisible = true;
+
+ private boolean openImageButtonVisible = true;
+
+ private ProjectViewer() {
+ initWidget(uiBinder.createAndBindUi(this));
+ pageViewDetails.getElement().setId("page-view-details");
+ }
+
+ public ProjectViewer(GeoNaItemRef item, ProjectView projectView) {
+ this(item, projectView, true, true);
+ }
+
+ public ProjectViewer(GeoNaItemRef item, ProjectView projectView, boolean viewImageButtonVisible,
+ boolean openImageButtonVisible) {
+ this();
+ GWT.log("Rendering " + projectView.getTheProjectDV().getId());
+ this.projectView = projectView;
+ this.geonaItemRef = item;
+ this.viewImageButtonVisible = viewImageButtonVisible;
+ this.openImageButtonVisible = openImageButtonVisible;
+
+ title.setText("Project: "+projectView.getTheProjectDV().getProfileID());
+
+ 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) {
+ Window.alert("Expand must be revisited");
+ /*
+ ProjectViewer cv = new ProjectViewer(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(ProjectViewer.this);
+ // mw.setWidth(900);
+ mw.show();
+ */
+
+ }
+ });
+
+
+
+ GeoportalDataViewerServiceAsync.Util.getInstance().getMyLogin(new AsyncCallback() {
+
+ @Override
+ public void onSuccess(String result) {
+ myLogin = result;
+ addCentroidMap();
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ }
+ });
+
+
+ for (SectionView sectionView : projectView.getListSections()) {
+
+ SectionViewer sectionViewer = new SectionViewer(sectionView);
+ pageViewDetails.add(sectionViewer);
+ }
+ }
+
+ 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");
+
+ 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());
+// }
+ }
+
+ public ProjectView getProjectView() {
+ return projectView;
+ }
+
+ protected void setExpandViewButtonVisible(boolean bool) {
+ expandButton.setVisible(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
new file mode 100644
index 0000000..fb161bf
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/project/ProjectViewer.ui.xml
@@ -0,0 +1,44 @@
+
+
+
+
+ .margin-left-10 {
+ margin-left: 10px;
+ }
+
+ .font-size-h1-22 h1 {
+ font-size: 22px;
+ }
+
+ .align-to-right {
+ right: 20px;
+ position: absolute;
+ }
+
+ .the-title h1 {
+ font-size: 28px;
+ }
+
+ .margin-bottom-10 {
+ margin-bottom: 10px;
+ }
+
+ .width-100 {
+ width: 100%;
+ }
+
+
+
+
+
+
+
+ Share
+ Expand
+
+
+
\ No newline at end of file
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/project/RecordView.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/project/RecordView.ui.xml
new file mode 100644
index 0000000..01f5816
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/project/RecordView.ui.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
\ 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
new file mode 100644
index 0000000..d53b19f
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/project/SectionViewer.java
@@ -0,0 +1,65 @@
+package org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.project;
+
+import java.util.List;
+
+import org.gcube.application.geoportalcommon.shared.geoportal.view.SectionView;
+import org.gcube.application.geoportalcommon.shared.geoportal.view.SubDocumentView;
+import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
+import org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.gallery.ImagesSectionGallery;
+
+import com.github.gwtbootstrap.client.ui.PageHeader;
+import com.google.gwt.core.client.GWT;
+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.HTML;
+import com.google.gwt.user.client.ui.HTMLPanel;
+import com.google.gwt.user.client.ui.Widget;
+
+public class SectionViewer extends Composite {
+
+ private static SectionViewerUiBinder uiBinder = GWT.create(SectionViewerUiBinder.class);
+
+ interface SectionViewerUiBinder extends UiBinder {
+ }
+
+ private SectionView sectionView;
+
+ @UiField
+ HTMLPanel sectionPanelContainer;
+
+ @UiField
+ PageHeader sectionTitle;
+
+ public SectionViewer(SectionView sectionView) {
+ initWidget(uiBinder.createAndBindUi(this));
+ this.sectionView = sectionView;
+
+ List subDocuments = sectionView.getListSubDocuments();
+
+ sectionTitle.setTitle(sectionView.getSectionTitle());
+ sectionTitle.setText(sectionView.getSectionTitle());
+
+ boolean displayAsGallery = false;
+ for (SubDocumentView subDocumentView : subDocuments) {
+ if (subDocumentView.getListImages() != null && subDocumentView.getListImages().size() > 0) {
+ displayAsGallery = true;
+ break;
+ }
+ }
+
+ //Displaying the whole section as a Gallery
+ if (displayAsGallery) {
+ ImagesSectionGallery sectionGallery = new ImagesSectionGallery(sectionView);
+ sectionPanelContainer.add(sectionGallery.getGalleryPanel());
+ sectionGallery.fillGallery();
+ } else {
+ for (SubDocumentView subDocumentView : subDocuments) {
+ String table = GeoportalDataViewerConstants.jsonToTableHTML(subDocumentView.getMetadataAsJSON());
+ sectionPanelContainer.add(new HTML(table));
+ }
+ }
+
+ }
+
+}
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/project/SectionViewer.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/project/SectionViewer.ui.xml
new file mode 100644
index 0000000..0ebc229
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/cms/project/SectionViewer.ui.xml
@@ -0,0 +1,38 @@
+
+
+
+
+ .margin-left-10 {
+ margin-left: 10px;
+ }
+
+ .font-size-h1-22 h1 {
+ font-size: 22px;
+ }
+
+ .align-to-right {
+ right: 20px;
+ position: absolute;
+ }
+
+ .the-title h1 {
+ font-size: 28px;
+ }
+
+ .margin-bottom-10 {
+ margin-bottom: 10px;
+ }
+
+ .width-100 {
+ width: 100%;
+ }
+
+
+
+
+
+
+
\ No newline at end of file
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 b226ec3..a16dea7 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
@@ -14,7 +14,7 @@ import com.google.gwt.user.client.ui.HTMLPanel;
/**
- * The Class ImagesGallery.
+ * The Class ImagesSectionGallery.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GcubeProfilesMetadataForUCD.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GcubeProfilesMetadataForUCD.java
new file mode 100644
index 0000000..4c1c242
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GcubeProfilesMetadataForUCD.java
@@ -0,0 +1,68 @@
+package org.gcube.portlets.user.geoportaldataviewer.server;
+
+import java.io.Serializable;
+import java.util.List;
+
+import org.gcube.application.geoportalcommon.shared.geoportal.config.GcubeProfileDV;
+import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean;
+
+public class GcubeProfilesMetadataForUCD implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -8953445402356442872L;
+ private String profileID;
+ private GcubeProfileDV gcubeProfile;
+ private List listMetadataProfileBean;
+
+ public GcubeProfilesMetadataForUCD() {
+
+ }
+
+ public GcubeProfilesMetadataForUCD(String profileID, GcubeProfileDV gcubeProfile,
+ List listMetadataProfileBean) {
+
+ this.profileID = profileID;
+ this.gcubeProfile = gcubeProfile;
+ this.listMetadataProfileBean = listMetadataProfileBean;
+ }
+
+ public String getProfileID() {
+ return profileID;
+ }
+
+ public GcubeProfileDV getGcubeProfile() {
+ return gcubeProfile;
+ }
+
+ public List getListMetadataProfileBean() {
+ return listMetadataProfileBean;
+ }
+
+ public void setProfileID(String profileID) {
+ this.profileID = profileID;
+ }
+
+ public void setGcubeProfile(GcubeProfileDV gcubeProfile) {
+ this.gcubeProfile = gcubeProfile;
+ }
+
+ public void setListMetadataProfileBean(List 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();
+ }
+
+}
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerHttpSessionListener.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerHttpSessionListener.java
new file mode 100644
index 0000000..de8f29e
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerHttpSessionListener.java
@@ -0,0 +1,26 @@
+package org.gcube.portlets.user.geoportaldataviewer.server;
+
+import javax.servlet.annotation.WebListener;
+import javax.servlet.http.HttpSessionEvent;
+import javax.servlet.http.HttpSessionListener;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@WebListener
+public class GeoportalDataViewerHttpSessionListener implements HttpSessionListener {
+
+ private static final Logger LOG = LoggerFactory.getLogger(GeoportalDataViewerHttpSessionListener.class);
+
+ @Override
+ public void sessionDestroyed(HttpSessionEvent event) {
+ LOG.info("sessionDestroyed called");
+ }
+
+ @Override
+ public void sessionCreated(HttpSessionEvent arg0) {
+ LOG.info("sessionCreated called. Session id is: "+arg0.getSession().getId());
+
+ new GeoportalDataViewerServiceImpl().preloadgCubeProfilesForUCDs();
+ }
+}
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 345e0e2..15fb98f 100644
--- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/GeoportalDataViewerServiceImpl.java
@@ -10,31 +10,43 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
-import org.gcube.application.geoportal.common.model.legacy.Concessione;
-import org.gcube.application.geoportal.common.model.legacy.LayerConcessione;
-import org.gcube.application.geoportal.common.model.legacy.UploadedImage;
-import org.gcube.application.geoportalcommon.ConvertToDataViewModel;
+import org.bson.Document;
+import org.gcube.application.geoportal.client.utils.Serialization;
+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.GeoportalCommon;
-import org.gcube.application.geoportalcommon.MongoServiceCommon;
+import org.gcube.application.geoportalcommon.geoportal.GeoportalClientCaller;
+import org.gcube.application.geoportalcommon.geoportal.UseCaseDescriptorCaller;
+import org.gcube.application.geoportalcommon.geoportal.access.GeportalCheckAccessPolicy;
+import org.gcube.application.geoportalcommon.geoportal.serdes.Payload;
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
-import org.gcube.application.geoportalcommon.shared.ItemField;
import org.gcube.application.geoportalcommon.shared.LayerItem;
import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData;
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
+import org.gcube.application.geoportalcommon.shared.geoportal.ConfigurationDV;
+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.config.ItemFieldDV;
+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.ucd.GEOPORTAL_DATA_HANDLER;
+import org.gcube.application.geoportalcommon.shared.geoportal.ucd.HandlerDeclarationDV;
+import org.gcube.application.geoportalcommon.shared.geoportal.view.FilesetDV;
+import org.gcube.application.geoportalcommon.shared.geoportal.view.PayloadDV;
+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.application.geoportalcommon.shared.products.BaseConcessioneDV;
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
-import org.gcube.application.geoportalcommon.shared.products.model.AbstractRelazioneScavoDV;
import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV;
-import org.gcube.application.geoportalcommon.shared.products.model.RelazioneScavoDV;
import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV;
import org.gcube.application.geoportalcommon.util.URLParserUtil;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerService;
import org.gcube.portlets.user.geoportaldataviewer.server.gis.FeatureParser;
import org.gcube.portlets.user.geoportaldataviewer.server.gis.WMSUrlValidator;
-import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.ConcessioniMongoServiceIdentityProxy;
-import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accesspolicy.GeoNACheckAccessPolicy;
+import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.GeoportalServiceIdentityProxy;
import org.gcube.portlets.user.geoportaldataviewer.server.util.SessionUtil;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
@@ -44,15 +56,25 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformation
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.Styles;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.ZAxis;
import org.gcube.portlets.user.urlshortener.UrlShortener;
+import org.gcube.portlets.widgets.mpformbuilder.server.MetadataProfileFormBuilderServiceImpl;
+import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetaDataProfileBean;
+import org.gcube.portlets.widgets.mpformbuilder.shared.metadata.MetadataFieldWrapper;
import org.gcube.spatial.data.geoutility.GeoNcWMSMetadataUtility;
import org.gcube.spatial.data.geoutility.bean.LayerStyles;
import org.gcube.spatial.data.geoutility.bean.LayerZAxis;
import org.gcube.spatial.data.geoutility.bean.WmsParameters;
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
+import org.json.JSONArray;
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.google.gwt.user.server.rpc.RemoteServiceServlet;
+import com.jayway.jsonpath.JsonPath;
+import com.jayway.jsonpath.spi.json.JsonOrgJsonProvider;
/**
* The server side implementation of the RPC service.
@@ -70,6 +92,38 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
private static final String CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE = "MAP_IMAGE_PREVIEW_FOR_CONCESSIONE";
+ public static final String JSON_$_POINTER = "$";
+
+ public static enum COMMON_IMAGES_FORMAT {
+ gif, png, jpeg, jpg, bmp, tif, tiff, svg, avif, webp
+ }
+
+ public static class ImageDetector {
+
+ private static String[] getNames(Class extends Enum>> e) {
+ return Arrays.stream(e.getEnumConstants()).map(Enum::name).toArray(String[]::new);
+ }
+
+ public static List listFormatImages;
+
+ static {
+
+ String[] arrayImgs = ImageDetector.getNames(COMMON_IMAGES_FORMAT.class);
+ listFormatImages = Arrays.asList(arrayImgs);
+
+ }
+
+ public static boolean isImage(String mimeType) {
+ if (mimeType == null || mimeType.isEmpty())
+ return false;
+
+ String inputImageFormat = mimeType.replaceAll("image/", "");
+
+ return listFormatImages.contains(inputImageFormat);
+ }
+
+ }
+
/**
* Gets the GNA data viewe config profile.
*
@@ -221,83 +275,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
return getUploadedImagesForId(this.getThreadLocalRequest(), itemType, itemId, maxImages);
}
- /**
- * Gets the layers for id.
- *
- * @param itemType the item type
- * @param itemId the item id
- * @return the layers for id
- * @throws Exception the exception
- */
- @Override
- public List getLayersForId(String itemType, String itemId) throws Exception {
- LOG.info("getLayersForId [itemId: " + itemId + ", itemType: " + itemType + "] called");
- if (itemType == null)
- throw new Exception("Invalid parameter. The itemType is null");
-
- if (itemId == null)
- throw new Exception("Invalid parameter. The itemId is null");
-
- List listLayers = null;
-
- try {
-
- SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
- String userName = null;
- try {
- userName = SessionUtil.getCurrentUser(this.getThreadLocalRequest()).getUsername();
- } catch (Exception e) {
- LOG.info("User not found in session, the userName for cecking policy will be null");
- }
-
- if (itemType.equalsIgnoreCase("concessione")) {
-
- LOG.info("Trying to get concessione for id " + itemId);
- ConcessioniMongoServiceIdentityProxy cms = new ConcessioniMongoServiceIdentityProxy(
- this.getThreadLocalRequest());
- Concessione concessione = cms.getItemById(itemId);
-
- BaseConcessioneDV baseConcessione = ConvertToDataViewModel.toBaseConcessione(concessione);
- if (concessione != null) {
- LOG.info("For id " + itemId + ", got concessione " + concessione.getNome() + " from service");
- listLayers = new ArrayList();
- if (concessione.getPianteFineScavo() != null) {
-
- for (LayerConcessione lc : concessione.getPianteFineScavo()) {
- if (GeoNACheckAccessPolicy.isAccessible(lc.getPolicy().name(), userName)) {
- listLayers.add(ConvertToDataViewModel.toLayerConcessione(lc, baseConcessione));
- }
- }
-
- LayerConcessione lcPosizionamento = concessione.getPosizionamentoScavo();
-
- if (lcPosizionamento != null) {
-
- if (GeoNACheckAccessPolicy.isAccessible(lcPosizionamento.getPolicy().name(), userName)) {
-
- LayerConcessioneDV thePosizScavo = ConvertToDataViewModel
- .toLayerConcessione(lcPosizionamento, baseConcessione);
- if (thePosizScavo != null)
- listLayers.add(thePosizScavo);
- }
- }
-
- }
-
- } else
- throw new Exception("Concessione with id '" + itemId + "' not available");
- }
- LOG.info("For id " + itemId + ", returning " + listLayers.size() + " layer/s");
- return listLayers;
-
- } catch (Exception e) {
- String erroMsg = "Layers are not available for " + Concessione.class.getSimpleName() + " with id " + itemId;
- LOG.error(erroMsg, e);
- throw new Exception(erroMsg);
- }
-
- }
/**
* Gets the concessione for id.
@@ -310,6 +288,8 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
public ConcessioneDV getConcessioneForId(String mongoId) throws Exception {
LOG.info("getConcessioneForId " + mongoId + " called");
+ throw new Exception("getConcessioneForId must be removed!");
+ /*
ConcessioneDV concessionDV = null;
if (mongoId == null)
@@ -318,8 +298,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
try {
LOG.info("Trying to get record for id " + mongoId);
- ConcessioniMongoServiceIdentityProxy cms = new ConcessioniMongoServiceIdentityProxy(
- this.getThreadLocalRequest());
+ GeoportalServiceIdentityProxy cms = new GeoportalServiceIdentityProxy(this.getThreadLocalRequest());
Concessione concessione = cms.getItemById(mongoId);
LOG.info("Got concessione for mongoId: " + mongoId);
@@ -414,7 +393,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
LOG.error(erroMsg, e);
throw new Exception(erroMsg);
}
-
+ */
}
/**
@@ -648,7 +627,9 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
String itemId, Integer maxImages) throws Exception {
LOG.info("getUploadedImagesForId [itemId: " + itemId + ", itemType: " + itemType + "] called");
- if (itemType == null)
+ throw new Exception("getUploadedImagesForId must be revisited");
+
+ /*if (itemType == null)
throw new Exception("Invalid parameter. The itemType is null");
if (itemId == null)
@@ -661,7 +642,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
if (itemType.equalsIgnoreCase("concessione")) {
LOG.info("Trying to get concessione for id " + itemId);
- ConcessioniMongoServiceIdentityProxy cms = new ConcessioniMongoServiceIdentityProxy(httpServletRequest);
+ GeoportalServiceIdentityProxy cms = new GeoportalServiceIdentityProxy(httpServletRequest);
Concessione concessione = cms.getItemById(itemId);
if (concessione != null) {
LOG.info("For id " + itemId + ", got concessione " + concessione.getNome() + " from service");
@@ -687,7 +668,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
+ Concessione.class.getSimpleName() + " with id " + itemId;
LOG.error(erroMsg, e);
throw new Exception(erroMsg);
- }
+ }*/
}
@@ -717,13 +698,51 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
* @throws Exception the exception
*/
@Override
- public List listOfFieldsForSearching() throws Exception {
+ public List listOfFieldsForSearching() throws Exception {
LOG.info("listOfFieldsForSearching called");
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
GNADataViewerConfigProfile profile = getGNADataVieweConfigProfile();
return profile.getListItemFields();
}
+
+ /**
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ * NEW CODE HERE
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+
+
+
+
+
+
+
/**
* Gets the list concessioni.
*
@@ -740,18 +759,22 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
LOG.info("getListConcessioni called wit start: " + start + ", limit: " + limit + ", filter: " + filter);
try {
- // setting identity as D4S User or KC client
- new ConcessioniMongoServiceIdentityProxy(this.getThreadLocalRequest());
- SessionUtil.getCurrentContext(getThreadLocalRequest(), true);
- MongoServiceCommon serviceCommon = new MongoServiceCommon();
- // TODO MUST BE REPLACED BY COUNT
- List listOfConcessioni = SessionUtil.getListOfConcessioni(getThreadLocalRequest(),
- reloadFromService);
- int listConcessioniSize = listOfConcessioni.size();
- ResultSetPaginatedData searchedData = serviceCommon.queryOnMongo(listConcessioniSize, start, limit, filter,
- "concessione");
- return searchedData;
+ throw new Exception("getListConcessioni must be revisited!!!!");
+ /*
+ *
+ * // setting identity as D4S User or KC client new
+ * GeoportalServiceIdentityProxy(this.getThreadLocalRequest());
+ * SessionUtil.getCurrentContext(getThreadLocalRequest(), true);
+ * MongoServiceCommon serviceCommon = new MongoServiceCommon(); // TODO MUST BE
+ * REPLACED BY COUNT List listOfConcessioni =
+ * SessionUtil.getListOfConcessioni(getThreadLocalRequest(), reloadFromService);
+ * int listConcessioniSize = listOfConcessioni.size();
+ *
+ * ResultSetPaginatedData searchedData =
+ * serviceCommon.queryOnMongo(listConcessioniSize, start, limit, filter,
+ * "concessione"); return searchedData;
+ */
} catch (Exception e) {
LOG.error("Error on loading paginated and filtered list of concessioni: ", e);
@@ -760,4 +783,519 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
}
+ /**
+ * Preloadg cube profiles for UC ds.
+ */
+ public void preloadgCubeProfilesForUCDs() {
+ LOG.info("preloadgCubeProfilesForUCDs called");
+ try {
+
+ String currentContext = SessionUtil.getCurrentContext(getThreadLocalRequest(), true);
+ LOG.info("preloadgCubeProfilesForUCDs context: "+currentContext);
+ UseCaseDescriptorCaller clientUCD = GeoportalClientCaller.useCaseDescriptors();
+ SessionUtil.getCurrentContext(getThreadLocalRequest(), true);
+ List 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 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 listGcubeProfiles = (List) config.getConfiguration();
+ LOG.debug("List of GcubeProfileDV are: " + listGcubeProfiles);
+
+ List listProfilesBean = new ArrayList();
+ // Loading Metadata Profile from IS
+ MetadataProfileFormBuilderServiceImpl metaProfileBUilder = new MetadataProfileFormBuilderServiceImpl();
+
+ LinkedHashMap> linkedMap_UCDId_gCubeProfiles = new LinkedHashMap>();
+ for (GcubeProfileDV gcubeProfileDV : listGcubeProfiles) {
+ String context = SessionUtil.getCurrentContext(getThreadLocalRequest(), true);
+ GcubeProfilesMetadataForUCD gCubeProfileMetadataForUCD = new GcubeProfilesMetadataForUCD();
+ List listProfiles = metaProfileBUilder.getProfilesInTheScopeForName(context,
+ 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);
+
+ for (String key : linkedMap_UCDId_gCubeProfiles.keySet()) {
+ LOG.debug("For key '" + key + "' got profiles: " + linkedMap_UCDId_gCubeProfiles.get(key));
+ }
+
+ SessionUtil.setMap_UCDId_gCubeProfiles(getThreadLocalRequest(), profileID,
+ linkedMap_UCDId_gCubeProfiles);
+ }
+
+ } catch (Exception e) {
+ String erroMsg = "Error occurred on preloadgCubeProfilesForUCDs: ";
+ LOG.error(erroMsg, e);
+ }
+ }
+
+
+
+ /**
+ * Gets the layers for id.
+ *
+ * @param itemType the item type
+ * @param itemId the item id
+ * @return the layers for id
+ * @throws Exception the exception
+ */
+ @Override
+ public List getLayersForId(String itemType, String itemId) throws Exception {
+ LOG.info("getLayersForId [itemId: " + itemId + ", itemType: " + itemType + "] called");
+
+ throw new Exception("getLayersForId must be revisited!!!");
+
+ /*
+ * if (itemType == null) throw new
+ * Exception("Invalid parameter. The itemType is null");
+ *
+ * if (itemId == null) throw new
+ * Exception("Invalid parameter. The itemId is null");
+ *
+ * List listLayers = null;
+ *
+ * try {
+ *
+ * SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); String
+ * userName = null; try { userName =
+ * SessionUtil.getCurrentUser(this.getThreadLocalRequest()).getUsername(); }
+ * catch (Exception e) { LOG.
+ * info("User not found in session, the userName for cecking policy will be null"
+ * ); }
+ *
+ * if (itemType.equalsIgnoreCase("concessione")) {
+ *
+ * LOG.info("Trying to get concessione for id " + itemId);
+ * GeoportalServiceIdentityProxy cms = new
+ * GeoportalServiceIdentityProxy(this.getThreadLocalRequest()); Concessione
+ * concessione = cms.getItemById(itemId);
+ *
+ * BaseConcessioneDV baseConcessione =
+ * ConvertToDataViewModel.toBaseConcessione(concessione); if (concessione !=
+ * null) { LOG.info("For id " + itemId + ", got concessione " +
+ * concessione.getNome() + " from service"); listLayers = new
+ * ArrayList(); if (concessione.getPianteFineScavo() !=
+ * null) {
+ *
+ * for (LayerConcessione lc : concessione.getPianteFineScavo()) { if
+ * (GeoNACheckAccessPolicy.isAccessible(lc.getPolicy().name(), userName)) {
+ * listLayers.add(ConvertToDataViewModel.toLayerConcessione(lc,
+ * baseConcessione)); } }
+ *
+ * LayerConcessione lcPosizionamento = concessione.getPosizionamentoScavo();
+ *
+ * if (lcPosizionamento != null) {
+ *
+ * if (GeoNACheckAccessPolicy.isAccessible(lcPosizionamento.getPolicy().name(),
+ * userName)) {
+ *
+ * LayerConcessioneDV thePosizScavo = ConvertToDataViewModel
+ * .toLayerConcessione(lcPosizionamento, baseConcessione); if (thePosizScavo !=
+ * null) listLayers.add(thePosizScavo); } }
+ *
+ * }
+ *
+ * } else throw new Exception("Concessione with id '" + itemId +
+ * "' not available"); } LOG.info("For id " + itemId + ", returning " +
+ * listLayers.size() + " layer/s"); return listLayers;
+ *
+ * } catch (Exception e) { String erroMsg = "Layers are not available for " +
+ * Concessione.class.getSimpleName() + " with id " + itemId; LOG.error(erroMsg,
+ * e); throw new Exception(erroMsg); }
+ *
+ */
+
+ }
+
+ /**
+ * Gets the project view for id.
+ *
+ * @param profileID the profile ID
+ * @param projectID the project ID
+ * @return the project view for id
+ * @throws Exception the exception
+ */
+ @Override
+ public ProjectView getProjectViewForId(String profileID, String projectID) throws Exception {
+ LOG.info("getProjectForId profileID: " + profileID + ", projectID: " + projectID + "called");
+
+ if (profileID == null || projectID == null)
+ throw new Exception("Invalid parameter. Either profileID or projectID is null");
+
+ try {
+
+ SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
+ String userName = null;
+ try {
+ userName = SessionUtil.getCurrentUser(this.getThreadLocalRequest()).getUsername();
+ } catch (Exception e) {
+ LOG.info("User not found in session, the userName for cecking policy will be null");
+ }
+
+ LOG.info("Trying to get project for id " + profileID);
+
+ GeoportalServiceIdentityProxy cms = new GeoportalServiceIdentityProxy(this.getThreadLocalRequest());
+ ProjectDV theProjectDV = cms.getProjectByID(profileID, projectID);
+
+ 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> linkedMap_UCDId_gCubeProfiles = SessionUtil
+ .getMap_UCDId_gCubeProfiles(getThreadLocalRequest(), profileID);
+
+ if(linkedMap_UCDId_gCubeProfiles==null) {
+ preloadgCubeProfilesForUCDs();
+ linkedMap_UCDId_gCubeProfiles = SessionUtil
+ .getMap_UCDId_gCubeProfiles(getThreadLocalRequest(), profileID);
+ }
+
+ // NO UCD defined, applyong 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();
+ subDocumentView.setMetadataAsJSON(theProjectDV.getTheDocument().getDocumentAsJSON());
+ sectionView.addSubDocument(subDocumentView);
+ projectView.addSectionView(sectionView);
+ }
+
+ List listProfilesBean = linkedMap_UCDId_gCubeProfiles.get(profileID);
+
+ 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 = JsonPath.compile(sectionJSONPath);
+ Object data = theSectionJsonPath.read(theWholeProjectAsJSON, configuration);
+
+ 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 listBSONDocument = new ArrayList();
+ 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 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 filePaths = gcubeProfileDV.getFilePaths();
+
+ // READING fileset* field ACCORDING TO filePaths OF THE 'gcubeProfiles' CONFIG
+ if (filePaths != null) {
+ String fromSectionDocJSON = fromSectionDoc.toJson();
+ List listFiles = new ArrayList();
+ List listImages = new ArrayList();
+ for (FilePathDV filePath : filePaths) {
+
+ String filesetJSONPath = String.format("%s.%s", JSON_$_POINTER, filePath.getFieldName());
+ List 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);
+ }
+ }
+
+ }
+ subDocumentView.setListFiles(listFiles);
+ subDocumentView.setListImages(listImages);
+ }
+
+ sectionView.addSubDocument(subDocumentView);
+
+ }
+
+ projectView.addSectionView(sectionView);
+ }
+
+// 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);
+// }
+// }
+// }
+// i++;
+// }
+//
+// }
+ return projectView;
+
+ } catch (Exception e) {
+ String erroMsg = "Error occurred on creating projectView for id: " + projectID;
+ LOG.error(erroMsg, e);
+ throw new Exception(erroMsg);
+ }
+
+ }
+
+ /**
+ * Read payloads for fileset.
+ *
+ * @param filesetJSONPath the fileset JSON path
+ * @param sectionJSONDocument the section JSON document
+ * @return the list
+ */
+ private List readPayloadsForFileset(String filesetJSONPath, String sectionJSONDocument) {
+ LOG.debug("readPayloadsForFileset called");
+
+ List listPayloads = new ArrayList();
+ 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.error("Error on reading the JSON Path {} in the doc {} ", _payloadsJSONPath, sectionJSONDocument);
+ e.printStackTrace();
+ }
+
+ return listPayloads;
+
+ }
+
+ /**
+ * 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 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 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;
+ }
+
+ /**
+ * Pretty print JSON.
+ *
+ * @param jsonString the json string
+ * @return the string
+ */
+ private String prettyPrintJSON(String jsonString) {
+
+ Gson gson = new GsonBuilder().setPrettyPrinting().create();
+ JsonObject jsonObject = new JsonParser().parse(jsonString).getAsJsonObject();
+ return gson.toJson(jsonObject);
+ }
+
+ /**
+ * Sanitize document value.
+ *
+ * @param toDoc the to doc
+ * @param fieldLabel the field label
+ * @param theObjectFieldValue the the object field value
+ * @return the document
+ */
+ private 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;
+ }
+
}
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/ConcessioniMongoService.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/ConcessioniMongoService.java
index 2d1dc18..eab41d3 100644
--- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/ConcessioniMongoService.java
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/ConcessioniMongoService.java
@@ -1,66 +1,66 @@
-package org.gcube.portlets.user.geoportaldataviewer.server.mongoservice;
-
-import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.statefulMongoConcessioni;
-
-import org.gcube.application.geoportal.client.legacy.ConcessioniManagerI;
-import org.gcube.application.geoportal.common.model.legacy.Concessione;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * The Class ConcessioniMongoService.
- *
- * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
- *
- * Sep 23, 2021
- */
-public class ConcessioniMongoService {
-
- private static final Logger LOG = LoggerFactory.getLogger(ConcessioniMongoService.class);
-
- /**
- * Instantiates a new concessioni mongo service.
- */
- protected ConcessioniMongoService() {
- }
-
- /**
- * Gets the item by id.
- *
- * @param mongoItemId the mongo item id
- * @return the item by id
- * @throws Exception the exception
- */
- protected Concessione getItemById(String mongoItemId) throws Exception {
- LOG.info("called getItemById: " + mongoItemId);
- ConcessioniManagerI concessioniManager = statefulMongoConcessioni().build();
- // Returning item by Id
- return concessioniManager.getById(mongoItemId);
- }
-
-
- /**
- * To concessione.
- *
- * @param jsonString the json string
- * @return the concessione
- */
- protected Concessione toConcessione(String jsonString) {
- LOG.info("toConcessione called");
- try {
- return org.gcube.application.geoportal.client.utils.Serialization.read(jsonString, Concessione.class);
- } catch (Exception e) {
- LOG.warn("Error on serializing: ", e);
- return null;
- }
- }
-
- /*
- * For testing public Concessione iamClientGetItemBy(HttpServletRequest request,
- * String mongoItemId, String clientId, String secret) throws Exception { String
- * scope = SessionUtil.getCurrentContext(request, true); return
- * iamClientGetItemBy(scope, mongoItemId, clientId, secret); }
- */
-
-}
+//package org.gcube.portlets.user.geoportaldataviewer.server.mongoservice;
+//
+//import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.statefulMongoConcessioni;
+//
+//import org.gcube.application.geoportal.client.legacy.ConcessioniManagerI;
+//import org.gcube.application.geoportal.common.model.legacy.Concessione;
+//import org.slf4j.Logger;
+//import org.slf4j.LoggerFactory;
+//
+//
+///**
+// * The Class ConcessioniMongoService.
+// *
+// * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
+// *
+// * Sep 23, 2021
+// */
+//public class ConcessioniMongoService {
+//
+// private static final Logger LOG = LoggerFactory.getLogger(ConcessioniMongoService.class);
+//
+// /**
+// * Instantiates a new concessioni mongo service.
+// */
+// protected ConcessioniMongoService() {
+// }
+//
+// /**
+// * Gets the item by id.
+// *
+// * @param mongoItemId the mongo item id
+// * @return the item by id
+// * @throws Exception the exception
+// */
+// protected Concessione getItemById(String mongoItemId) throws Exception {
+// LOG.info("called getItemById: " + mongoItemId);
+// ConcessioniManagerI concessioniManager = statefulMongoConcessioni().build();
+// // Returning item by Id
+// return concessioniManager.getById(mongoItemId);
+// }
+//
+//
+// /**
+// * To concessione.
+// *
+// * @param jsonString the json string
+// * @return the concessione
+// */
+// protected Concessione toConcessione(String jsonString) {
+// LOG.info("toConcessione called");
+// try {
+// return org.gcube.application.geoportal.client.utils.Serialization.read(jsonString, Concessione.class);
+// } catch (Exception e) {
+// LOG.warn("Error on serializing: ", e);
+// return null;
+// }
+// }
+//
+// /*
+// * For testing public Concessione iamClientGetItemBy(HttpServletRequest request,
+// * String mongoItemId, String clientId, String secret) throws Exception { String
+// * scope = SessionUtil.getCurrentContext(request, true); return
+// * iamClientGetItemBy(scope, mongoItemId, clientId, secret); }
+// */
+//
+//}
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/ConcessioniMongoServiceIdentityProxy.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/ConcessioniMongoServiceIdentityProxy.java
deleted file mode 100644
index 5fd7bb7..0000000
--- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/ConcessioniMongoServiceIdentityProxy.java
+++ /dev/null
@@ -1,80 +0,0 @@
-package org.gcube.portlets.user.geoportaldataviewer.server.mongoservice;
-
-import javax.servlet.http.HttpServletRequest;
-
-import org.gcube.application.geoportal.common.model.legacy.Concessione;
-import org.gcube.common.portal.PortalContext;
-import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentity.GcubeIdentity;
-import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentity.IAMClientIdentity;
-import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentity.UserIdentity;
-import org.gcube.portlets.user.geoportaldataviewer.server.util.SessionUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * The Class ConcessioniMongoServiceIdentityProxy.
- *
- * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
- *
- * Sep 23, 2021
- */
-public class ConcessioniMongoServiceIdentityProxy {
-
- private static final Logger LOG = LoggerFactory.getLogger(ConcessioniMongoServiceIdentityProxy.class);
-
- private GcubeIdentity gCubeIdentity;
-
-
- /**
- * Instantiates a new concessioni mongo service proxy.
- *
- * @param request the request
- * @throws Exception the exception
- */
- public ConcessioniMongoServiceIdentityProxy(HttpServletRequest request) throws Exception {
- SessionUtil.getCurrentContext(request, true);
- PortalContext pContext = PortalContext.getConfiguration();
- String username = null;
- try {
- username = pContext.getCurrentUser(request).getUsername();
- if(username==null || username.isEmpty())
- throw new Exception("Invalid username");
- }catch (Exception e) {
- LOG.info("Username not detected in session");
- username = null; //to be sure that is null and not empty string
- }
- if (username != null) {
- LOG.info("User detected, using its identity");
- gCubeIdentity = new UserIdentity();
- } else {
- LOG.info("User not detected, using IAM Client identity");
- gCubeIdentity = new IAMClientIdentity();
- }
-
- gCubeIdentity.setIdentity(request);
- }
-
-
- /**
- * Gets the item by id.
- *
- * @param mongoItemId the mongo item id
- * @return the item by id
- * @throws Exception the exception
- */
- public Concessione getItemById(String mongoItemId) throws Exception {
-
- try {
- // Obtain the client
- ConcessioniMongoService concessioniManager = new ConcessioniMongoService();
- // Returning item by Id
- return concessioniManager.getItemById(mongoItemId);
- }catch(Exception e) {
- LOG.error("Error on reading itemById: "+mongoItemId, e);
- throw(e);
- }finally {
- gCubeIdentity.resetIdentity();
- }
- }
-}
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/GeoportalServiceIdentityProxy.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/GeoportalServiceIdentityProxy.java
new file mode 100644
index 0000000..4f5e5e6
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/mongoservice/GeoportalServiceIdentityProxy.java
@@ -0,0 +1,82 @@
+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.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.shared.geoportal.project.ProjectDV;
+import org.gcube.common.portal.PortalContext;
+import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentity.GcubeIdentity;
+import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentity.IAMClientIdentity;
+import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentity.UserIdentity;
+import org.gcube.portlets.user.geoportaldataviewer.server.util.SessionUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The Class GeoportalServiceIdentityProxy.
+ *
+ * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
+ *
+ * Sep 23, 2021
+ */
+public class GeoportalServiceIdentityProxy {
+
+ private static final Logger LOG = LoggerFactory.getLogger(GeoportalServiceIdentityProxy.class);
+
+ private GcubeIdentity gCubeIdentity;
+
+ /**
+ * Instantiates a new concessioni mongo service proxy.
+ *
+ * @param request the request
+ * @throws Exception the exception
+ */
+ public GeoportalServiceIdentityProxy(HttpServletRequest request) throws Exception {
+ SessionUtil.getCurrentContext(request, true);
+ PortalContext pContext = PortalContext.getConfiguration();
+ String username = null;
+ try {
+ username = pContext.getCurrentUser(request).getUsername();
+ if (username == null || username.isEmpty())
+ throw new Exception("Invalid username");
+ } catch (Exception e) {
+ LOG.info("Username not detected in session");
+ username = null; // to be sure that is null and not empty string
+ }
+ if (username != null) {
+ LOG.info("User detected, using its identity");
+ gCubeIdentity = new UserIdentity();
+ } else {
+ LOG.info("User not detected, using IAM Client identity");
+ gCubeIdentity = new IAMClientIdentity();
+ }
+
+ gCubeIdentity.setIdentity(request);
+ }
+
+ /**
+ * Gets the project by ID.
+ *
+ * @param profileID the profile ID
+ * @param projectID the project ID
+ * @return the project by ID
+ * @throws Exception the exception
+ */
+ public ProjectDV getProjectByID(String profileID, String projectID) throws Exception {
+ ProjectsCaller clientPrj = GeoportalClientCaller.projects();
+ Project theProject = clientPrj.getProjectByID(profileID, projectID);
+ ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(true);
+ return ConvertToDataValueObjectModel.toProjectDV(theProject, projectBuilder);
+ /*
+ * try { // Obtain the client ConcessioniMongoService concessioniManager = new
+ * ConcessioniMongoService(); // Returning item by Id return
+ * concessioniManager.getItemById(mongoItemId); }catch(Exception e) {
+ * LOG.error("Error on reading itemById: "+mongoItemId, e); throw(e); }finally {
+ * gCubeIdentity.resetIdentity(); }
+ */
+ }
+}
diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/SessionUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/SessionUtil.java
index 118cf7a..f14cfb8 100644
--- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/SessionUtil.java
+++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/SessionUtil.java
@@ -3,21 +3,19 @@
*/
package org.gcube.portlets.user.geoportaldataviewer.server.util;
-import java.util.ArrayList;
-import java.util.Iterator;
+import java.util.LinkedHashMap;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.gcube.application.geoportal.common.model.legacy.Concessione;
-import org.gcube.application.geoportal.common.rest.MongoConcessioni;
-import org.gcube.application.geoportalcommon.MongoServiceCommon;
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.portal.PortalContext;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portlets.user.geoportaldataviewer.server.GNABaseMapsResourceReader;
+import org.gcube.portlets.user.geoportaldataviewer.server.GcubeProfilesMetadataForUCD;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
import org.gcube.portlets.user.urlshortener.UrlShortener;
import org.gcube.vomanagement.usermanagement.GroupManager;
@@ -39,6 +37,8 @@ import com.liferay.portal.service.UserLocalServiceUtil;
* Oct 20, 2020
*/
public class SessionUtil {
+
+ private static final String MAP_UCD_ID_TO_GCUBE_PROFILES = "MAP_UCD_ID_TO_GCUBE_PROFILES";
/** The log. */
private static Logger LOG = LoggerFactory.getLogger(SessionUtil.class);
@@ -181,6 +181,24 @@ public class SessionUtil {
return shortener;
}
+
+
+ public static LinkedHashMap> getMap_UCDId_gCubeProfiles(
+ HttpServletRequest httpServletRequest, String profileID) {
+
+ HttpSession session = httpServletRequest.getSession();
+ return (LinkedHashMap>) session
+ .getAttribute(MAP_UCD_ID_TO_GCUBE_PROFILES +"_"+profileID);
+
+ }
+
+ public static void setMap_UCDId_gCubeProfiles(HttpServletRequest httpServletRequest,
+ String profileID, LinkedHashMap> map) {
+
+ HttpSession session = httpServletRequest.getSession();
+ session.setAttribute(MAP_UCD_ID_TO_GCUBE_PROFILES +"_"+profileID, map);
+
+ }
/**
* Gets the GNA base maps.
@@ -218,7 +236,8 @@ public class SessionUtil {
boolean reloadFromService) throws Exception {
HttpSession session = httpServletRequest.getSession();
List listOfConcessioni = (List) session.getAttribute(LIST_OF_CONCESSIONI);
-
+ throw new Exception("getListConcessioni must be revisited!!!!");
+ /*
// setting null to force reloading from service
if (reloadFromService)
listOfConcessioni = null;
@@ -241,11 +260,14 @@ public class SessionUtil {
// 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;
+
+ */
}
/**
diff --git a/src/main/webapp/GeoportalDataViewer.css b/src/main/webapp/GeoportalDataViewer.css
index f7ce891..e29ca97 100644
--- a/src/main/webapp/GeoportalDataViewer.css
+++ b/src/main/webapp/GeoportalDataViewer.css
@@ -510,4 +510,21 @@ body {
padding-right: 5px;
cursor: pointer;
}
+
+.my-html-table {
+ padding: 5px;
+ margin-left: 10px;
+ margin-bottom: 10px;
+ margin-right: 5px;
+}
+
+.my-html-table td {
+ padding: 5px 0;
+}
+
+.my-html-table td:first-child {
+ color: gray;
+ padding-right: 15px;
+ width: 120px;
+}
\ No newline at end of file
diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml
index c66589b..d239f5b 100644
--- a/src/main/webapp/WEB-INF/web.xml
+++ b/src/main/webapp/WEB-INF/web.xml
@@ -1,5 +1,6 @@
-
@@ -15,9 +16,25 @@
org.gcube.portlets.user.geoportaldataviewer.server.GeoportalDataViewerServiceImpl
+
+ mpformbuilderServlet
+ org.gcube.portlets.widgets.mpformbuilder.server.MetadataProfileFormBuilderServiceImpl
+
+
+
+ mpformbuilderServlet
+ /GeoportalDataViewer/mpformbuilderservice
+
+
+
geoportalDataViewerServlet
/GeoportalDataViewer/geoportaldataviewerservice
+
+
+ org.gcube.portlets.user.geoportaldataviewer.server.GeoportalDataViewerHttpSessionListener
+
+
diff --git a/src/test/java/org/gcube/portlets/user/geoportaldataviewer/ConcessioneReader.java b/src/test/java/org/gcube/portlets/user/geoportaldataviewer/ConcessioneReader.java
index dce5720..d897e28 100644
--- a/src/test/java/org/gcube/portlets/user/geoportaldataviewer/ConcessioneReader.java
+++ b/src/test/java/org/gcube/portlets/user/geoportaldataviewer/ConcessioneReader.java
@@ -1,11 +1,5 @@
package org.gcube.portlets.user.geoportaldataviewer;
-import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.statefulMongoConcessioni;
-
-import org.gcube.application.geoportal.client.legacy.ConcessioniManagerI;
-import org.gcube.application.geoportal.common.model.legacy.Concessione;
-import org.gcube.application.geoportalcommon.ConvertToDataViewModel;
-import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.scope.api.ScopeProvider;
@@ -27,7 +21,7 @@ public class ConcessioneReader {
public void readConcessione() throws Exception {
System.out.println("getConcessioneForId " + mongoConcessioneID + "called");
- ConcessioneDV concessionDV = null;
+ /*ConcessioneDV concessionDV = null;
if (mongoConcessioneID == null)
throw new Exception("Invalid parameter. The Id is null");
@@ -54,7 +48,7 @@ public class ConcessioneReader {
} catch (Exception e) {
String erroMsg = Concessione.class.getSimpleName() + " with id " + mongoConcessioneID + " not available";
throw new Exception(erroMsg);
- }
+ }*/
}
}
diff --git a/src/test/java/org/gcube/portlets/user/geoportaldataviewer/IAMClient.java b/src/test/java/org/gcube/portlets/user/geoportaldataviewer/IAMClient.java
index b45ae06..6c4a6c9 100644
--- a/src/test/java/org/gcube/portlets/user/geoportaldataviewer/IAMClient.java
+++ b/src/test/java/org/gcube/portlets/user/geoportaldataviewer/IAMClient.java
@@ -25,7 +25,7 @@ public class IAMClient {
System.out.println("Read credentials: " + credentials);
Concessione concessione;
try {
-// concessione = new ConcessioniMongoServiceIdentityProxy();
+// concessione = new GeoportalServiceIdentityProxy();
// System.out.println("Get concessione: " + concessione);
} catch (Exception e) {