Moved to MongoConcessione-Client and mongoID

This commit is contained in:
Francesco Mangiacrapa 2021-07-30 14:57:08 +02:00
parent 4f3c299d11
commit 44134a4860
16 changed files with 627 additions and 552 deletions

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="src" output="target/geoportal-data-viewer-app-1.2.0-SNAPSHOT/WEB-INF/classes" path="src/main/java"> <classpathentry kind="src" output="target/geoportal-data-viewer-app-1.3.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes> <attributes>
<attribute name="optional" value="true"/> <attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry excluding="**" kind="src" output="target/geoportal-data-viewer-app-1.2.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources"> <classpathentry excluding="**" kind="src" output="target/geoportal-data-viewer-app-1.3.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
@ -36,5 +36,5 @@
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="lib" path="/home/francescomangiacrapa/.m2/repository/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar"/> <classpathentry kind="lib" path="/home/francescomangiacrapa/.m2/repository/javax/servlet/javax.servlet-api/3.1.0/javax.servlet-api-3.1.0.jar"/>
<classpathentry kind="output" path="target/geoportal-data-viewer-app-1.2.0-SNAPSHOT/WEB-INF/classes"/> <classpathentry kind="output" path="target/geoportal-data-viewer-app-1.3.0-SNAPSHOT/WEB-INF/classes"/>
</classpath> </classpath>

View File

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

View File

@ -1,13 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0"> <?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="geoportal-data-viewer-app-1.2.0-SNAPSHOT">
<wb-module deploy-name="geoportal-data-viewer-app-1.3.0-SNAPSHOT">
@ -15,7 +17,8 @@
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/> <wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
@ -23,7 +26,8 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/> <wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
@ -31,15 +35,18 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
@ -47,13 +54,15 @@
<property name="java-output-path" value="/geoportal-data-viewer-app/target/geoportal-data-viewer-app-0.0.1-SNAPSHOT/WEB-INF/classes"/> <property name="java-output-path" value="/geoportal-data-viewer-app/target/geoportal-data-viewer-app-0.0.1-SNAPSHOT/WEB-INF/classes"/>
<property name="context-root" value="geoportal-data-viewer-app"/> <property name="context-root" value="geoportal-data-viewer-app"/>
@ -61,7 +70,8 @@
</wb-module> </wb-module>

View File

@ -4,6 +4,11 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v1.3.0-SNAPSHOT] - 2021-07-30
#### Enhancements
[#21890] Porting to ConcessioniManagerI and pass to mongoID
## [v1.2.0-SNAPSHOT] - 2021-07-19 ## [v1.2.0-SNAPSHOT] - 2021-07-19
@ -12,6 +17,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
[#21847] Integrated with an Image and LighBox gallery for images [#21847] Integrated with an Image and LighBox gallery for images
Moved to maven-portal-bom 3.6.3 Moved to maven-portal-bom 3.6.3
## [v1.1.0] - 2020-12-21 ## [v1.1.0] - 2020-12-21
#### Enhancements #### Enhancements

View File

@ -14,7 +14,7 @@
<groupId>org.gcube.portlets.user</groupId> <groupId>org.gcube.portlets.user</groupId>
<artifactId>geoportal-data-viewer-app</artifactId> <artifactId>geoportal-data-viewer-app</artifactId>
<packaging>war</packaging> <packaging>war</packaging>
<version>1.2.0-SNAPSHOT</version> <version>1.3.0-SNAPSHOT</version>
<name>GeoPortal Data Viewer App</name> <name>GeoPortal Data Viewer App</name>
<description>The GeoPortal Data Viewer App is an application to access, discovery and navigate the GeoNa products by a Web-Map Interface</description> <description>The GeoPortal Data Viewer App is an application to access, discovery and navigate the GeoNa products by a Web-Map Interface</description>

View File

@ -124,14 +124,14 @@ public class GeoportalDataViewer implements EntryPoint {
GWT.log(GeoportalDataViewerConstants.GET_LAYER_TITLE + " = " + paramLayerTitle); GWT.log(GeoportalDataViewerConstants.GET_LAYER_TITLE + " = " + paramLayerTitle);
// VALIDATING THE LONG FORMAT FOR GID // VALIDATING THE LONG FORMAT FOR GID
try { // try {
if (paramGeonaItemID != null) // if (paramGeonaItemID != null)
Long.parseLong(paramGeonaItemID); // Long.parseLong(paramGeonaItemID);
} catch (Exception e) { // } catch (Exception e) {
Window.alert("Bad format for parameter " + GeoportalDataViewerConstants.GET_GEONA_ITEM_ID // Window.alert("Bad format for parameter " + GeoportalDataViewerConstants.GET_GEONA_ITEM_ID
+ ". It must be a Long"); // + ". It must be a Long");
paramGeonaItemID = null; // paramGeonaItemID = null;
} // }
Scheduler.get().scheduleDeferred(new ScheduledCommand() { Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@ -177,7 +177,7 @@ public class GeoportalDataViewer implements EntryPoint {
+ paramGeonaItemID); + paramGeonaItemID);
return; return;
} }
GeoNaItemRef gir = new GeoNaItemRef(new Long(paramGeonaItemID), paramGeonaItemType); GeoNaItemRef gir = new GeoNaItemRef(paramGeonaItemID, paramGeonaItemType);
applicationBus.fireEvent(new ShowDetailsEvent(gir, null, null)); applicationBus.fireEvent(new ShowDetailsEvent(gir, null, null));
} }
@ -222,22 +222,22 @@ public class GeoportalDataViewer implements EntryPoint {
public void onShowDetails(ShowDetailsEvent showDetailsEvent) { public void onShowDetails(ShowDetailsEvent showDetailsEvent) {
GWT.log("Fired event: "+showDetailsEvent); GWT.log("Fired event: "+showDetailsEvent);
Long id = showDetailsEvent.getGeonaID(); String geonaMongoId = showDetailsEvent.getGeonaMongoID();
if(id==null) { if(geonaMongoId==null) {
Window.alert("Item Id not found"); Window.alert("Item Id not found");
return; return;
} }
//TODO //TODO
boolean found = false; boolean found = false;
GWT.log("Product with id: "+id+" found? "+found); GWT.log("Product with id: "+geonaMongoId+" found? "+found);
if(!found) { if(!found) {
if(showDetailsEvent.getGeonaItemType().equalsIgnoreCase("Concessione")) { if(showDetailsEvent.getGeonaItemType().equalsIgnoreCase("Concessione")) {
GeoportalDataViewerServiceAsync.Util.getInstance().getConcessioneForId(id, new AsyncCallback<ConcessioneDV>() { GeoportalDataViewerServiceAsync.Util.getInstance().getConcessioneForId(geonaMongoId, new AsyncCallback<ConcessioneDV>() {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
@ -325,7 +325,7 @@ public class GeoportalDataViewer implements EntryPoint {
private void performWFSQueryOnCentroid(RecordDV record) { private void performWFSQueryOnCentroid(RecordDV record) {
if(record!=null) { if(record!=null) {
GWT.log("record instanceof ConcessioneDV: " +(record instanceof ConcessioneDV)); GWT.log("record instanceof ConcessioneDV: " +(record instanceof ConcessioneDV) +" with mongo item id: "+record.getItemId());
//GeoportalDataViewerConstants.print("record instanceof ConcessioneDV: " +(record instanceof ConcessioneDV)); //GeoportalDataViewerConstants.print("record instanceof ConcessioneDV: " +(record instanceof ConcessioneDV));
if(record instanceof ConcessioneDV) { if(record instanceof ConcessioneDV) {
ConcessioneDV concessioneDV = (ConcessioneDV) record; ConcessioneDV concessioneDV = (ConcessioneDV) record;
@ -337,7 +337,7 @@ public class GeoportalDataViewer implements EntryPoint {
GeoQuery select = olMapMng.toDataPointQuery(transfCoord); GeoQuery select = olMapMng.toDataPointQuery(transfCoord);
GWT.log("GeoQuery: "+select); GWT.log("GeoQuery: "+select);
//GeoportalDataViewerConstants.print("fireEvent QueryDataEvent"); //GeoportalDataViewerConstants.print("fireEvent QueryDataEvent");
layerManager.getLayerManagerBus().fireEvent(new QueryDataEvent(select, transfCoord, record.getId(), true)); layerManager.getLayerManagerBus().fireEvent(new QueryDataEvent(select, transfCoord, record.getItemId(), true));
}else { }else {
GeoportalDataViewerConstants.printJs("I cannot select the point one or both coordiantes are null. X: "+x +", Y:"+y); GeoportalDataViewerConstants.printJs("I cannot select the point one or both coordiantes are null. X: "+x +", Y:"+y);
} }

View File

@ -19,7 +19,7 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
* *
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* *
* Nov 17, 2020 * Nov 17, 2020
*/ */
@RemoteServiceRelativePath("geoportaldataviewerservice") @RemoteServiceRelativePath("geoportaldataviewerservice")
public interface GeoportalDataViewerService extends RemoteService { public interface GeoportalDataViewerService extends RemoteService {
@ -28,7 +28,7 @@ public interface GeoportalDataViewerService extends RemoteService {
* Parses the wms request. * Parses the wms request.
* *
* @param wmsRequest the wms request * @param wmsRequest the wms request
* @param layerName the layer name * @param layerName the layer name
* @return the geo information for WMS request * @return the geo information for WMS request
* @throws Exception the exception * @throws Exception the exception
*/ */
@ -37,11 +37,11 @@ public interface GeoportalDataViewerService extends RemoteService {
/** /**
* Gets the data result. * Gets the data result.
* *
* @param layerObjects the layer objects * @param layerObjects the layer objects
* @param mapSrsName the map srs name * @param mapSrsName the map srs name
* @param mapBBOX the map BBOX * @param mapBBOX the map BBOX
* @param maxWFSFeature the max WFS feature * @param maxWFSFeature the max WFS feature
* @param zoomLevel the zoom level * @param zoomLevel the zoom level
* @return the data result * @return the data result
*/ */
List<GeoNaSpatialQueryResult> getDataResult(List<LayerObject> layerObjects, String mapSrsName, BoundsMap mapBBOX, List<GeoNaSpatialQueryResult> getDataResult(List<LayerObject> layerObjects, String mapSrsName, BoundsMap mapBBOX,
@ -50,11 +50,11 @@ public interface GeoportalDataViewerService extends RemoteService {
/** /**
* Gets the concessione for id. * Gets the concessione for id.
* *
* @param id the id * @param mongoId the mongo id
* @return the concessione for id * @return the concessione for id
* @throws Exception the exception * @throws Exception the exception
*/ */
ConcessioneDV getConcessioneForId(Long id) throws Exception; ConcessioneDV getConcessioneForId(String mongoId) throws Exception;
/** /**
* Gets the my login. * Gets the my login.
@ -84,12 +84,12 @@ public interface GeoportalDataViewerService extends RemoteService {
* Gets the uploaded images for id. * Gets the uploaded images for id.
* *
* @param itemType the item type * @param itemType the item type
* @param id the id * @param itemId the item id
* @param maxImages the max images * @param maxImages the max images
* @return the uploaded images for id * @return the uploaded images for id
* @throws Exception the exception * @throws Exception
*/ */
List<UploadedImageDV> getUploadedImagesForId(String itemType, Long id, int maxImages) throws Exception; List<UploadedImageDV> getUploadedImagesForId(String itemType, String itemId, int maxImages) throws Exception;
/** /**
* Gets the public links for. * Gets the public links for.

View File

@ -38,7 +38,7 @@ public interface GeoportalDataViewerServiceAsync {
void getDataResult(List<LayerObject> layerObjects, String mapSrsName, BoundsMap mapBBOX, int maxWFSFeature, double zoomLevel, void getDataResult(List<LayerObject> layerObjects, String mapSrsName, BoundsMap mapBBOX, int maxWFSFeature, double zoomLevel,
AsyncCallback<List<GeoNaSpatialQueryResult>> callback); AsyncCallback<List<GeoNaSpatialQueryResult>> callback);
void getConcessioneForId(Long id, AsyncCallback<ConcessioneDV> callback); void getConcessioneForId(String mongoId, AsyncCallback<ConcessioneDV> callback);
void getMyLogin(AsyncCallback<String> callback); void getMyLogin(AsyncCallback<String> callback);
@ -46,7 +46,7 @@ public interface GeoportalDataViewerServiceAsync {
void getGeoNaDataViewProfile(AsyncCallback<GeoNaDataViewerProfile> callback); void getGeoNaDataViewProfile(AsyncCallback<GeoNaDataViewerProfile> callback);
void getUploadedImagesForId(String itemType, Long id, int maxImages, AsyncCallback<List<UploadedImageDV>> callback); void getUploadedImagesForId(String itemType, String itemId, int maxImages, AsyncCallback<List<UploadedImageDV>> callback);
void getPublicLinksFor(GeoNaItemRef item, AsyncCallback<GeoNaItemRef> asyncCallback); void getPublicLinksFor(GeoNaItemRef item, AsyncCallback<GeoNaItemRef> asyncCallback);

View File

@ -51,23 +51,20 @@ import com.google.gwt.user.client.ui.VerticalPanel;
import ol.Coordinate; import ol.Coordinate;
/** /**
* The Class LayerManager. * The Class LayerManager.
* *
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* *
* Oct 27, 2020 * Oct 27, 2020
*/ */
public class LayerManager { public class LayerManager {
/** The ol map. */ /** The ol map. */
private OpenLayerOSM olMap; private OpenLayerOSM olMap;
private List<LayerObject> layerObjects = new ArrayList<LayerObject>(); private List<LayerObject> layerObjects = new ArrayList<LayerObject>();
private HandlerManager layerManagerBus = new HandlerManager(""); private HandlerManager layerManagerBus = new HandlerManager("");
private HandlerManager applicationBus; private HandlerManager applicationBus;
@ -81,312 +78,333 @@ public class LayerManager {
this.applicationBus = applicationBus; this.applicationBus = applicationBus;
bindEvents(); bindEvents();
} }
/** /**
* Bind events. * Bind events.
*/ */
private void bindEvents() { private void bindEvents() {
layerManagerBus.addHandler(QueryDataEvent.TYPE, new QueryDataEventHandler() { layerManagerBus.addHandler(QueryDataEvent.TYPE, new QueryDataEventHandler() {
@Override @Override
public void onQueryInteraction(final QueryDataEvent queryEvent) { public void onQueryInteraction(final QueryDataEvent queryEvent) {
//GeoportalDataViewerConstants.print("fired QueryDataEvent: "+queryEvent.toString()); // GeoportalDataViewerConstants.print("fired QueryDataEvent:
// "+queryEvent.toString());
if(queryEvent.getGeoQuery()!=null) {
if (queryEvent.getGeoQuery() != null) {
GeoQuery selectDataInfo = queryEvent.getGeoQuery(); GeoQuery selectDataInfo = queryEvent.getGeoQuery();
Long recordId = queryEvent.getRecordId(); String mongoItemId = queryEvent.getMongoItemId();
GWT.log("("+selectDataInfo.getX1()+","+selectDataInfo.getY1()+")("+selectDataInfo.getX2()+","+selectDataInfo.getY2()+")"); GWT.log("(" + selectDataInfo.getX1() + "," + selectDataInfo.getY1() + ")(" + selectDataInfo.getX2()
+ "," + selectDataInfo.getY2() + ")");
for (LayerObject layerObj : layerObjects){
//TODO for (LayerObject layerObj : layerObjects) {
// TODO
isLayerVisible(layerObj.getLayerItem()); isLayerVisible(layerObj.getLayerItem());
} }
BoundsMap mapBBOX = new BoundsMap(); BoundsMap mapBBOX = new BoundsMap();
//THIS IS SHOULD BE CORRET, THE BOUND AND CRS ARE READ FROM MAP // THIS IS SHOULD BE CORRET, THE BOUND AND CRS ARE READ FROM MAP
/*mapBBOX.setCrs(olMap.getProjectionCode()); /*
mapBBOX.setLowerLeftX(olMap.getExtent().getLowerLeftX()); * mapBBOX.setCrs(olMap.getProjectionCode());
mapBBOX.setLowerLeftY(olMap.getExtent().getLowerLeftY()); * mapBBOX.setLowerLeftX(olMap.getExtent().getLowerLeftX());
mapBBOX.setUpperRightX(olMap.getExtent().getUpperRightX()); * mapBBOX.setLowerLeftY(olMap.getExtent().getLowerLeftY());
mapBBOX.setUpperRightY(olMap.getExtent().getUpperRightY()); * mapBBOX.setUpperRightX(olMap.getExtent().getUpperRightX());
*/ * mapBBOX.setUpperRightY(olMap.getExtent().getUpperRightY());
*/
//THE FOLLOWING SHOULD BE NOT NEEDED BUT THE GETFEATURE WITH EPSG_3857 SEEMS NOT WORK IN OUR GEOSERVER
// THE FOLLOWING SHOULD BE NOT NEEDED BUT THE GETFEATURE WITH EPSG_3857 SEEMS
// NOT WORK IN OUR GEOSERVER
// double minX = olMap.getExtent().getLowerLeftX(); // double minX = olMap.getExtent().getLowerLeftX();
// double minY = olMap.getExtent().getLowerLeftY(); // double minY = olMap.getExtent().getLowerLeftY();
double minX = queryEvent.getGeoQuery().getX1(); double minX = queryEvent.getGeoQuery().getX1();
double minY = queryEvent.getGeoQuery().getY1(); double minY = queryEvent.getGeoQuery().getY1();
Coordinate centerCoordinate = new Coordinate(minX, minY); Coordinate centerCoordinate = new Coordinate(minX, minY);
centerCoordinate = olMap.transform(centerCoordinate, GeoportalDataViewerConstants.EPSG_3857, GeoportalDataViewerConstants.EPSG_4326); centerCoordinate = olMap.transform(centerCoordinate, GeoportalDataViewerConstants.EPSG_3857,
GeoportalDataViewerConstants.EPSG_4326);
mapBBOX.setLowerLeftX(centerCoordinate.getX()); mapBBOX.setLowerLeftX(centerCoordinate.getX());
mapBBOX.setLowerLeftY(centerCoordinate.getY()); mapBBOX.setLowerLeftY(centerCoordinate.getY());
// double maxX = olMap.getExtent().getUpperRightX(); // double maxX = olMap.getExtent().getUpperRightX();
// double maxY = olMap.getExtent().getUpperRightY(); // double maxY = olMap.getExtent().getUpperRightY();
double maxX = queryEvent.getGeoQuery().getX2(); double maxX = queryEvent.getGeoQuery().getX2();
double maxY = queryEvent.getGeoQuery().getY2(); double maxY = queryEvent.getGeoQuery().getY2();
centerCoordinate = new Coordinate(maxX,maxY); centerCoordinate = new Coordinate(maxX, maxY);
centerCoordinate = olMap.transform(centerCoordinate, GeoportalDataViewerConstants.EPSG_3857, GeoportalDataViewerConstants.EPSG_4326); centerCoordinate = olMap.transform(centerCoordinate, GeoportalDataViewerConstants.EPSG_3857,
GeoportalDataViewerConstants.EPSG_4326);
mapBBOX.setUpperRightX(centerCoordinate.getX()); mapBBOX.setUpperRightX(centerCoordinate.getX());
mapBBOX.setUpperRightY(centerCoordinate.getY()); mapBBOX.setUpperRightY(centerCoordinate.getY());
mapBBOX.setCrs(GeoportalDataViewerConstants.EPSG_4326); mapBBOX.setCrs(GeoportalDataViewerConstants.EPSG_4326);
GWT.log("Bounds is: "+mapBBOX);
GWT.log("MAX_WFS_FEATURES is: "+GeoportalDataViewerConstants.MAX_WFS_FEATURES);
//GeoportalDataViewerConstants.print("calling getDataResult");
GeoportalDataViewerServiceAsync.Util.getInstance().getDataResult(layerObjects, olMap.getProjectionCode(), mapBBOX, GeoportalDataViewerConstants.MAX_WFS_FEATURES, olMap.getCurrentZoomLevel(), new AsyncCallback<List<GeoNaSpatialQueryResult>>() {
@Override GWT.log("Bounds is: " + mapBBOX);
public void onFailure(Throwable caught) { GWT.log("MAX_WFS_FEATURES is: " + GeoportalDataViewerConstants.MAX_WFS_FEATURES);
//GeoportalDataViewerConstants.print("on Failure DataResult: "+caught.getMessage()); // GeoportalDataViewerConstants.print("calling getDataResult");
}
@Override GeoportalDataViewerServiceAsync.Util.getInstance().getDataResult(layerObjects,
public void onSuccess(List<GeoNaSpatialQueryResult> listGeonaDataObjects) { olMap.getProjectionCode(), mapBBOX, GeoportalDataViewerConstants.MAX_WFS_FEATURES,
olMap.getCurrentZoomLevel(), new AsyncCallback<List<GeoNaSpatialQueryResult>>() {
GWT.log("GeoNaDataObject's: "+listGeonaDataObjects);
//GeoportalDataViewerConstants.print("GeoNaDataObject's: "+listGeonaDataObjects);
if(listGeonaDataObjects==null || listGeonaDataObjects.isEmpty())
return;
FlexTable flex = new FlexTable(); @Override
flex.setCellPadding(1); public void onFailure(Throwable caught) {
flex.setCellSpacing(1); // GeoportalDataViewerConstants.print("on Failure DataResult:
flex.getElement().addClassName("popup-table"); // "+caught.getMessage());
boolean featureFound = false; }
FeatureRow feature = null;
//TODO SWTCH FOR EARCH ITEM TYPE
for (GeoNaSpatialQueryResult geoNaDataObject : listGeonaDataObjects) {
List<FeatureRow> features = geoNaDataObject.getFeatures();
//USING ONLY THE FIRST FEATURE IN THE LIST @Override
if(features!=null && features.size()>0) { public void onSuccess(List<GeoNaSpatialQueryResult> listGeonaDataObjects) {
//I need to show exaclty the feature with produc_id == recordId GWT.log("GeoNaDataObject's: " + listGeonaDataObjects);
if(recordId!=null) { // GeoportalDataViewerConstants.print("GeoNaDataObject's:
for (FeatureRow fRow : features) { // "+listGeonaDataObjects);
List<String> productIdLst = fRow.getMapProperties().get("product_id");
String thePID = productIdLst.get(0); if (listGeonaDataObjects == null || listGeonaDataObjects.isEmpty())
return;
FlexTable flex = new FlexTable();
flex.setCellPadding(1);
flex.setCellSpacing(1);
flex.getElement().addClassName("popup-table");
boolean featureFound = false;
FeatureRow feature = null;
// TODO SWTCH FOR EARCH ITEM TYPE
for (GeoNaSpatialQueryResult geoNaDataObject : listGeonaDataObjects) {
List<FeatureRow> features = geoNaDataObject.getFeatures();
// USING ONLY THE FIRST FEATURE IN THE LIST
if (features != null && features.size() > 0) {
// I need to show exaclty the feature with produc_id == recordId
if (mongoItemId != null) {
for (FeatureRow fRow : features) {
List<String> productIdLst = fRow.getMapProperties()
.get("product_id");
String theProductId = productIdLst.get(0);
try {
//long productId = Long.parseLong(thePID);
if (theProductId == mongoItemId) {
feature = fRow;
GWT.log("Found recorId == product_id with id: "
+ theProductId);
break;
}
} catch (Exception e) {
// TODO: handle exception
}
}
}
// If recordId not passed, I'm using the first feature returned
if (mongoItemId == null) {
feature = features.get(0);
} else {
// the recordId to show has been passed but not found into list of
// FeatureRow
if (feature == null) {
return;
}
}
Map<String, List<String>> entries = feature.getMapProperties();
String nome = "";
String descrizione = "";
String date = "";
for (String key : entries.keySet()) {
String theValue = entries.get(key).get(0);
if (key.equalsIgnoreCase("nome")) {
nome = theValue != null ? theValue : "";
} else if (key.equalsIgnoreCase("descrizione")) {
descrizione = theValue != null ? theValue : "";
} else if (key.equalsIgnoreCase("date_scavo")) {
date = theValue != null ? theValue : "";
}
}
// GeoportalDataViewerConstants.print("0: "+nome);
flex.setHTML(0, 0, new HTML(nome).toString());
try { try {
long productId = Long.parseLong(thePID); descrizione = StringUtil.ellipsize(descrizione, 100);
if(productId==recordId) { GWT.log("reduced: " + descrizione);
feature = fRow; } catch (Exception e) {
GWT.log("Found recorId == product_id with id: "+productId); GWT.log("error: " + e.getMessage());
break;
}
}catch (Exception e) {
// TODO: handle exception
} }
// GeoportalDataViewerConstants.print("1: "+descrizione);
flex.setText(1, 0, descrizione);
// GeoportalDataViewerConstants.print("2: "+date);
date = StringUtil.formatDate(date);
flex.setHTML(2, 0, new HTML("<code>" + date + "</code>").toString());
if (geoNaDataObject.getMapImages() != null) {
for (String key : geoNaDataObject.getMapImages().keySet()) {
List<UploadedImageDV> listUI = geoNaDataObject.getMapImages()
.get(key);
GWT.log("Adding images: " + listUI);
if (listUI != null && listUI.size() > 0) {
UploadedImageDV img = listUI.get(0);
if (img.getListWsContent() != null) {
WorkspaceContentDV wsContent = img.getListWsContent()
.get(img.getListWsContent().size() - 1);
String theImgHTML = "<img src=\"" + wsContent.getLink()
+ "\"></img>";
GWT.log("theImgHTML: " + theImgHTML);
// GeoportalDataViewerConstants.print("The row are:
// "+flex.getRowCount());
flex.setHTML(flex.getRowCount() + 1, 0, theImgHTML);
}
}
}
}
featureFound = true;
// break; //Only the first one
} }
}
if (feature == null)
//If recordId not passed, I'm using the first feature returned
if(recordId==null) {
feature = features.get(0);
}else {
//the recordId to show has been passed but not found into list of FeatureRow
if(feature==null) {
return; return;
}
}
Map<String, List<String>> entries = feature.getMapProperties();
String nome = "";
String descrizione = "";
String date = "";
for (String key : entries.keySet()) { GWT.log("The selected Feature is: " + feature);
String theValue = entries.get(key).get(0); // GeoportalDataViewerConstants.print("The selected Feature is: "+feature);
if(key.equalsIgnoreCase("nome")) { FeatureRow theFeature = feature;
nome = theValue!=null?theValue:""; Button button = null;
if (!featureFound) {
flex.setHTML(0, 0, new HTML("No data available").toString());
} else {
button = new Button("Open Details");
button.getElement().setId("open-details");
button.setType(ButtonType.LINK);
} }
else if(key.equalsIgnoreCase("descrizione")) {
descrizione = theValue!=null?theValue:""; VerticalPanel vpPanel = new VerticalPanel();
}else if(key.equalsIgnoreCase("date_scavo")) { vpPanel.add(flex);
date = theValue!=null?theValue:"";
} if (button != null) {
} vpPanel.add(button);
button.setType(ButtonType.LINK);
//GeoportalDataViewerConstants.print("0: "+nome); button.addClickHandler(new ClickHandler() {
flex.setHTML(0, 0, new HTML(nome).toString());
try { @Override
descrizione = StringUtil.ellipsize(descrizione, 100); public void onClick(ClickEvent event) {
GWT.log("reduced: "+descrizione); ShowDetailsEvent toEvent = parseGeonaReferences(
} catch (Exception e) { geoNaDataObject.getSourceLayerObject().getItemType(),
GWT.log("error: "+e.getMessage()); theFeature);
} applicationBus.fireEvent(toEvent);
//GeoportalDataViewerConstants.print("1: "+descrizione);
flex.setText(1, 0, descrizione);
//GeoportalDataViewerConstants.print("2: "+date);
date = StringUtil.formatDate(date);
flex.setHTML(2, 0, new HTML("<code>"+date+"</code>").toString());
if(geoNaDataObject.getMapImages()!=null) {
for (Long key : geoNaDataObject.getMapImages().keySet()) {
List<UploadedImageDV> listUI = geoNaDataObject.getMapImages().get(key);
GWT.log("Adding images: "+listUI);
if(listUI!=null && listUI.size()>0) {
UploadedImageDV img = listUI.get(0);
if(img.getListWsContent()!=null) {
WorkspaceContentDV wsContent = img.getListWsContent().get(img.getListWsContent().size()-1);
String theImgHTML = "<img src=\""+wsContent.getLink()+"\"></img>";
GWT.log("theImgHTML: "+theImgHTML);
//GeoportalDataViewerConstants.print("The row are: "+flex.getRowCount());
flex.setHTML(flex.getRowCount()+1, 0, theImgHTML);
} }
});
}
Coordinate centerTo = null;
if (feature.getGeometry() != null) {
PointsPath path = feature.getGeometry().getPath();
GWT.log("Points Path: " + path);
if (path != null && path.getCoordinates() != null
&& path.getCoordinates().length > 0) {
org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.Coordinate center = path
.getCoordinates()[0];
centerTo = new Coordinate(center.getX(), center.getY());
} }
} }
}
// fallback
featureFound = true; if (centerTo == null)
//break; //Only the first one centerTo = queryEvent.getOnFailureCenterTo();
}
olMap.showPopup(vpPanel.toString(), centerTo);
if(feature==null)
return; Scheduler.get().scheduleDeferred(new ScheduledCommand() {
GWT.log("The selected Feature is: "+feature); @Override
//GeoportalDataViewerConstants.print("The selected Feature is: "+feature); public void execute() {
FeatureRow theFeature = feature; Element buttonElement = DOM.getElementById("open-details");
Button button = null; Event.sinkEvents(buttonElement, Event.ONCLICK);
if(!featureFound) { Event.setEventListener(buttonElement, new EventListener() {
flex.setHTML(0, 0, new HTML("No data available").toString());
}else { @Override
button = new Button("Open Details"); public void onBrowserEvent(Event event) {
button.getElement().setId("open-details"); if (Event.ONCLICK == event.getTypeInt()) {
button.setType(ButtonType.LINK); ShowDetailsEvent toEvent = parseGeonaReferences(
} geoNaDataObject.getSourceLayerObject()
.getItemType(),
VerticalPanel vpPanel = new VerticalPanel(); theFeature);
vpPanel.add(flex); applicationBus.fireEvent(toEvent);
}
if(button!=null) { }
vpPanel.add(button); });
button.setType(ButtonType.LINK); }
button.addClickHandler(new ClickHandler() { });
@Override
public void onClick(ClickEvent event) {
ShowDetailsEvent toEvent = parseGeonaReferences(geoNaDataObject.getSourceLayerObject().getItemType(), theFeature);
applicationBus.fireEvent(toEvent);
}
});
}
Coordinate centerTo = null;
if(feature.getGeometry()!=null) {
PointsPath path = feature.getGeometry().getPath();
GWT.log("Points Path: "+path);
if(path!=null && path.getCoordinates()!=null && path.getCoordinates().length>0) {
org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.Coordinate center = path.getCoordinates()[0];
centerTo = new Coordinate(center.getX(), center.getY());
} }
} }
});
//fallback
if(centerTo==null)
centerTo = queryEvent.getOnFailureCenterTo();
olMap.showPopup(vpPanel.toString(), centerTo);
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
Element buttonElement = DOM.getElementById("open-details");
Event.sinkEvents(buttonElement, Event.ONCLICK);
Event.setEventListener(buttonElement, new EventListener() {
@Override
public void onBrowserEvent(Event event) {
if(Event.ONCLICK == event.getTypeInt()) {
ShowDetailsEvent toEvent = parseGeonaReferences(geoNaDataObject.getSourceLayerObject().getItemType(), theFeature);
applicationBus.fireEvent(toEvent);
}
}
});
}
});
}
}
});
} }
} }
}); });
layerManagerBus.addHandler(AddedLayerToMapEvent.TYPE, new AddedLayerToMapEventHandler() { layerManagerBus.addHandler(AddedLayerToMapEvent.TYPE, new AddedLayerToMapEventHandler() {
@Override @Override
public void onLayerRendered(AddedLayerToMapEvent addedLayerToMapEvent) { public void onLayerRendered(AddedLayerToMapEvent addedLayerToMapEvent) {
GWT.log("Fired into layerManagerBus "+addedLayerToMapEvent); GWT.log("Fired into layerManagerBus " + addedLayerToMapEvent);
applicationBus.fireEvent(addedLayerToMapEvent); applicationBus.fireEvent(addedLayerToMapEvent);
} }
}); });
layerManagerBus.addHandler(ZoomOutOverMinimumEvent.TYPE, new ZoomOutOverMinimumEventHandler() { layerManagerBus.addHandler(ZoomOutOverMinimumEvent.TYPE, new ZoomOutOverMinimumEventHandler() {
@Override @Override
public void onZoomOut(ZoomOutOverMinimumEvent zoomOutEvent) { public void onZoomOut(ZoomOutOverMinimumEvent zoomOutEvent) {
GWT.log("Fired into layerManagerBus "+zoomOutEvent); GWT.log("Fired into layerManagerBus " + zoomOutEvent);
applicationBus.fireEvent(zoomOutEvent); applicationBus.fireEvent(zoomOutEvent);
} }
}); });
} }
/** /**
* Parses the geona references. * Parses the geona references.
* *
* @param itemType the item type * @param itemType the item type
* @param fRow the f row * @param fRow the f row
* @return the show details event * @return the show details event
*/ */
private ShowDetailsEvent parseGeonaReferences(String itemType, FeatureRow fRow) { private ShowDetailsEvent parseGeonaReferences(String itemType, FeatureRow fRow) {
if(fRow==null) if (fRow == null)
return null; return null;
List<String> productIds = fRow.getMapProperties().get("product_id"); List<String> productIds = fRow.getMapProperties().get("product_id");
if(productIds!=null && productIds.size()>0) { if (productIds != null && productIds.size() > 0) {
long id = Long.parseLong(productIds.get(0)); String productId = productIds.get(0);
String itemName = "Dettagli Prodotto"; String itemName = "Dettagli Prodotto";
List<String> listName = fRow.getMapProperties().get("nome"); List<String> listName = fRow.getMapProperties().get("nome");
if(listName!=null && listName.size()>0) { if (listName != null && listName.size() > 0) {
itemName = listName.get(0); itemName = listName.get(0);
} }
return new ShowDetailsEvent(itemType, id, itemName, fRow); return new ShowDetailsEvent(itemType, productId, itemName, fRow);
} }
return null; return null;
} }
/** /**
* Adds the layer. * Adds the layer.
* *
* @param geonaItemType the geona item type * @param geonaItemType the geona item type
* @param layerTitle the layer title * @param layerTitle the layer title
* @param layerName the layer name * @param layerName the layer name
* @param wmsLink the wms link * @param wmsLink the wms link
* @param isBase the is base * @param isBase the is base
* @param displayInLayerSwitcher the display in layer switcher * @param displayInLayerSwitcher the display in layer switcher
* @param UUID the uuid * @param UUID the uuid
* @param onTop the on top * @param onTop the on top
*/ */
public void addLayer(final String geonaItemType, final String layerTitle, final String layerName, final String wmsLink, final boolean isBase,final boolean displayInLayerSwitcher, final String UUID, final boolean onTop) { public void addLayer(final String geonaItemType, final String layerTitle, final String layerName,
final String wmsLink, final boolean isBase, final boolean displayInLayerSwitcher, final String UUID,
final boolean onTop) {
// final LayoutContainer westPanel = (LayoutContainer) layersPanel.getParent(); // final LayoutContainer westPanel = (LayoutContainer) layersPanel.getParent();
// //
@ -395,54 +413,65 @@ public class LayerManager {
// else // else
// layersPanel.mask("Adding..."+layerName, "x-mask-loading"); // layersPanel.mask("Adding..."+layerName, "x-mask-loading");
final LayerType featureType = isBase?LayerType.RASTER_BASELAYER:LayerType.FEATURE_TYPE; final LayerType featureType = isBase ? LayerType.RASTER_BASELAYER : LayerType.FEATURE_TYPE;
// Info.display("Adding Layer", layerName); // Info.display("Adding Layer", layerName);
GeoportalDataViewerServiceAsync.Util.getInstance().parseWmsRequest(wmsLink, layerName, new AsyncCallback<GeoInformationForWMSRequest>() { GeoportalDataViewerServiceAsync.Util.getInstance().parseWmsRequest(wmsLink, layerName,
new AsyncCallback<GeoInformationForWMSRequest>() {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
Window.alert(caught.getMessage()); Window.alert(caught.getMessage());
} }
@Override @Override
public void onSuccess(GeoInformationForWMSRequest geoInfoWMS) { public void onSuccess(GeoInformationForWMSRequest geoInfoWMS) {
GWT.log("Parsed WMS Request returned: "+geoInfoWMS); GWT.log("Parsed WMS Request returned: " + geoInfoWMS);
//ddLayerByWms(featureType, layerTitle, result.getLayerName(), result.getWmsRequest(), result.getBaseWmsServiceHost(), true, isBase, displayInLayerSwitcher, (ArrayList<String>) result.getStyles().getGeoStyles(), result.getWmsRequest(), false, result.getMapWMSNoStandard(), result.isNcWMS(), UUID, result.getZAxis()); // ddLayerByWms(featureType, layerTitle, result.getLayerName(),
// result.getWmsRequest(), result.getBaseWmsServiceHost(), true, isBase,
LayerItem layerItem = toLayerItem(featureType, layerTitle, geoInfoWMS.getLayerName(), geoInfoWMS.getWmsRequest(), geoInfoWMS.getBaseWmsServiceHost(), true, isBase, displayInLayerSwitcher, (ArrayList<String>) geoInfoWMS.getStyles().getGeoStyles(), geoInfoWMS.getWmsRequest(), false, geoInfoWMS.getMapWMSNoStandard(), geoInfoWMS.isNcWMS(), UUID, geoInfoWMS.getZAxis()); // displayInLayerSwitcher, (ArrayList<String>)
LayerObject lo = new LayerObject(); // result.getStyles().getGeoStyles(), result.getWmsRequest(), false,
lo.setLayerItem(layerItem); // result.getMapWMSNoStandard(), result.isNcWMS(), UUID, result.getZAxis());
lo.setItemType(geonaItemType);
layerObjects.add(lo); LayerItem layerItem = toLayerItem(featureType, layerTitle, geoInfoWMS.getLayerName(),
olMap.addWMSLayer(layerItem); geoInfoWMS.getWmsRequest(), geoInfoWMS.getBaseWmsServiceHost(), true, isBase,
} displayInLayerSwitcher, (ArrayList<String>) geoInfoWMS.getStyles().getGeoStyles(),
}); geoInfoWMS.getWmsRequest(), false, geoInfoWMS.getMapWMSNoStandard(),
geoInfoWMS.isNcWMS(), UUID, geoInfoWMS.getZAxis());
LayerObject lo = new LayerObject();
lo.setLayerItem(layerItem);
lo.setItemType(geonaItemType);
layerObjects.add(lo);
olMap.addWMSLayer(layerItem);
}
});
} }
/** /**
* To layer item. * To layer item.
* *
* @param layerType the layer type * @param layerType the layer type
* @param layerTitle the layer title * @param layerTitle the layer title
* @param layerName the layer name * @param layerName the layer name
* @param layerURL the layer URL * @param layerURL the layer URL
* @param mapServerHost the map server host * @param mapServerHost the map server host
* @param isExternal the is external * @param isExternal the is external
* @param isBase the is base * @param isBase the is base
* @param displayInLayerSwitcher the display in layer switcher * @param displayInLayerSwitcher the display in layer switcher
* @param styles the styles * @param styles the styles
* @param wmsLink the wms link * @param wmsLink the wms link
* @param onTop the on top * @param onTop the on top
* @param wmsNotStandardParams the wms not standard params * @param wmsNotStandardParams the wms not standard params
* @param isNcWms the is nc wms * @param isNcWms the is nc wms
* @param UUID the uuid * @param UUID the uuid
* @param zAxis the z axis * @param zAxis the z axis
* @return the layer item * @return the layer item
*/ */
private LayerItem toLayerItem(LayerType layerType, String layerTitle, String layerName, String layerURL, String mapServerHost, boolean isExternal, boolean isBase, boolean displayInLayerSwitcher, ArrayList<String> styles, String wmsLink, boolean onTop, HashMap<String, String> wmsNotStandardParams, boolean isNcWms, String UUID, ZAxis zAxis) { private LayerItem toLayerItem(LayerType layerType, String layerTitle, String layerName, String layerURL,
String mapServerHost, boolean isExternal, boolean isBase, boolean displayInLayerSwitcher,
ArrayList<String> styles, String wmsLink, boolean onTop, HashMap<String, String> wmsNotStandardParams,
boolean isNcWms, String UUID, ZAxis zAxis) {
// GWT.log("Add addLayerByWms 1"); // GWT.log("Add addLayerByWms 1");
LayerItem layerItem = new LayerItem(); LayerItem layerItem = new LayerItem();
@ -451,7 +480,7 @@ public class LayerManager {
layerItem.setName(layerName); layerItem.setName(layerName);
layerItem.setUrl(layerURL); layerItem.setUrl(layerURL);
layerItem.setMapServerHost(mapServerHost); layerItem.setMapServerHost(mapServerHost);
//l.setExternal(isExternal); // l.setExternal(isExternal);
layerItem.setOpacity(1d); layerItem.setOpacity(1d);
layerItem.setBuffer(2); layerItem.setBuffer(2);
layerItem.setWmsLink(wmsLink); layerItem.setWmsLink(wmsLink);
@ -462,53 +491,53 @@ public class LayerManager {
switch (layerType) { switch (layerType) {
//TODO IMPLEMENT THIS CASE // TODO IMPLEMENT THIS CASE
case RASTER_BASELAYER: case RASTER_BASELAYER:
// l.setHasLegend(false); // l.setHasLegend(false);
layerItem.setBaseLayer(true); layerItem.setBaseLayer(true);
layerItem.setTrasparent(false); layerItem.setTrasparent(false);
layerItem.setClickData(false); layerItem.setClickData(false);
break; break;
case FEATURE_TYPE: case FEATURE_TYPE:
//CASE FEATURE TYPE // CASE FEATURE TYPE
layerItem.setBaseLayer(false); layerItem.setBaseLayer(false);
layerItem.setClickData(true); layerItem.setClickData(true);
layerItem.setTrasparent(true); layerItem.setTrasparent(true);
break; break;
} }
GWT.log("styles "+styles); GWT.log("styles " + styles);
if(styles!=null && styles.size()>0){ if (styles != null && styles.size() > 0) {
layerItem.setHasLegend(true); layerItem.setHasLegend(true);
layerItem.setDefaultStyle(styles.get(0)); layerItem.setDefaultStyle(styles.get(0));
layerItem.setStyle(styles.get(0)); layerItem.setStyle(styles.get(0));
layerItem.setStyles(styles); layerItem.setStyles(styles);
}else{ } else {
String style = URLUtil.getValueOfParameter("styles", wmsLink); String style = URLUtil.getValueOfParameter("styles", wmsLink);
if(style!=null){ //CASE OF STYLE =""; if (style != null) { // CASE OF STYLE ="";
//TENTATIVE TO GET LEGEND // TENTATIVE TO GET LEGEND
layerItem.setHasLegend(true); layerItem.setHasLegend(true);
} }
} }
GWT.log("Built layer: "+layerItem); GWT.log("Built layer: " + layerItem);
return layerItem; return layerItem;
} }
/** /**
* Checks if is layer visible. * Checks if is layer visible.
* *
* @param layerItem the layer item * @param layerItem the layer item
* @return true, if is layer visible * @return true, if is layer visible
*/ */
public boolean isLayerVisible(LayerItem layerItem){ public boolean isLayerVisible(LayerItem layerItem) {
return olMap.isLayerVisible(layerItem.getName()); return olMap.isLayerVisible(layerItem.getName());
} }
/** /**
* Sets the ol map. * Sets the ol map.
* *

View File

@ -11,28 +11,27 @@ import ol.Coordinate;
* *
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* *
* Oct 29, 2020 * Oct 29, 2020
*/ */
public class QueryDataEvent extends GwtEvent<QueryDataEventHandler> { public class QueryDataEvent extends GwtEvent<QueryDataEventHandler> {
public static Type<QueryDataEventHandler> TYPE = new Type<QueryDataEventHandler>(); public static Type<QueryDataEventHandler> TYPE = new Type<QueryDataEventHandler>();
private GeoQuery select; private GeoQuery select;
private Coordinate onFailureCenterTo; private Coordinate onFailureCenterTo;
private Long recordId; private String mongoItemId;
private boolean onInit; private boolean onInit;
/** /**
* Instantiates a new query data event. * Instantiates a new query data event.
* *
* @param select the select * @param select the select
* @param onFailureCenterTo the on failure center to * @param onFailureCenterTo the on failure center to
* @param recordId the record id * @param mongoItemId the mongo item id
* @param onInit the on init * @param onInit the on init
*/ */
public QueryDataEvent(GeoQuery select, Coordinate onFailureCenterTo, Long recordId, boolean onInit) { public QueryDataEvent(GeoQuery select, Coordinate onFailureCenterTo, String mongoItemId, boolean onInit) {
this.select = select; this.select = select;
this.onFailureCenterTo = onFailureCenterTo; this.onFailureCenterTo = onFailureCenterTo;
this.recordId = recordId; this.mongoItemId = mongoItemId;
this.onInit = onInit; this.onInit = onInit;
} }
@ -45,15 +44,9 @@ public class QueryDataEvent extends GwtEvent<QueryDataEventHandler> {
public Type<QueryDataEventHandler> getAssociatedType() { public Type<QueryDataEventHandler> getAssociatedType() {
return TYPE; return TYPE;
} }
public String getMongoItemId() {
/** return mongoItemId;
* Gets the record id.
*
* @return the record id
*/
public Long getRecordId() {
return recordId;
} }
/** /**
@ -64,6 +57,7 @@ public class QueryDataEvent extends GwtEvent<QueryDataEventHandler> {
public boolean isOnInit() { public boolean isOnInit() {
return onInit; return onInit;
} }
/** /**
* Dispatch. * Dispatch.
* *
@ -74,7 +68,7 @@ public class QueryDataEvent extends GwtEvent<QueryDataEventHandler> {
handler.onQueryInteraction(this); handler.onQueryInteraction(this);
} }
/** /**
* Gets the geo query. * Gets the geo query.
* *
@ -83,8 +77,7 @@ public class QueryDataEvent extends GwtEvent<QueryDataEventHandler> {
public GeoQuery getGeoQuery() { public GeoQuery getGeoQuery() {
return select; return select;
} }
public Coordinate getOnFailureCenterTo() { public Coordinate getOnFailureCenterTo() {
return onFailureCenterTo; return onFailureCenterTo;
} }
@ -96,17 +89,12 @@ public class QueryDataEvent extends GwtEvent<QueryDataEventHandler> {
builder.append(select); builder.append(select);
builder.append(", onFailureCenterTo="); builder.append(", onFailureCenterTo=");
builder.append(onFailureCenterTo); builder.append(onFailureCenterTo);
builder.append(", recordId="); builder.append(", mongoItemId=");
builder.append(recordId); builder.append(mongoItemId);
builder.append(", onInit="); builder.append(", onInit=");
builder.append(onInit); builder.append(onInit);
builder.append("]"); builder.append("]");
return builder.toString(); return builder.toString();
} }
} }

View File

@ -9,15 +9,15 @@ import com.google.gwt.event.shared.GwtEvent;
/** /**
* The Class ShowDetailsEvent. * The Class ShowDetailsEvent.
* *
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
* *
* Nov 13, 2020 * Jul 30, 2021
*/ */
public class ShowDetailsEvent extends GwtEvent<ShowDetailsEventHandler> { public class ShowDetailsEvent extends GwtEvent<ShowDetailsEventHandler> {
public static Type<ShowDetailsEventHandler> TYPE = new Type<ShowDetailsEventHandler>(); public static Type<ShowDetailsEventHandler> TYPE = new Type<ShowDetailsEventHandler>();
private String geonaItemType; private String geonaItemType;
private FeatureRow featureRow; private FeatureRow featureRow;
private Long geonaID; private String geonaMongoID;
private String itemName; private String itemName;
@ -25,13 +25,13 @@ public class ShowDetailsEvent extends GwtEvent<ShowDetailsEventHandler> {
* Instantiates a new show details event. * Instantiates a new show details event.
* *
* @param geonaItemType the geona item type * @param geonaItemType the geona item type
* @param geonaID the geona ID * @param geonaMongoID the geona mongo ID
* @param itemName the item name * @param itemName the item name
* @param featureRow the feature row * @param featureRow the feature row
*/ */
public ShowDetailsEvent(String geonaItemType, Long geonaID, String itemName, FeatureRow featureRow) { public ShowDetailsEvent(String geonaItemType, String geonaMongoID, String itemName, FeatureRow featureRow) {
this.geonaItemType = geonaItemType; this.geonaItemType = geonaItemType;
this.geonaID = geonaID; this.geonaMongoID = geonaMongoID;
this.itemName = itemName; this.itemName = itemName;
this.featureRow = featureRow; this.featureRow = featureRow;
@ -47,7 +47,7 @@ public class ShowDetailsEvent extends GwtEvent<ShowDetailsEventHandler> {
*/ */
public ShowDetailsEvent(GeoNaItemRef gir, String itemName, FeatureRow featureRow) { public ShowDetailsEvent(GeoNaItemRef gir, String itemName, FeatureRow featureRow) {
this.geonaItemType = gir.getItemType(); this.geonaItemType = gir.getItemType();
this.geonaID = gir.getItemId(); this.geonaMongoID = gir.getItemId();
this.itemName = itemName; this.itemName = itemName;
this.featureRow = featureRow; this.featureRow = featureRow;
} }
@ -92,12 +92,12 @@ public class ShowDetailsEvent extends GwtEvent<ShowDetailsEventHandler> {
} }
/** /**
* Gets the geona ID. * Gets the geona mongo ID.
* *
* @return the geona ID * @return the geona mongo ID
*/ */
public Long getGeonaID() { public String getGeonaMongoID() {
return geonaID; return geonaMongoID;
} }
/** /**
@ -125,7 +125,7 @@ public class ShowDetailsEvent extends GwtEvent<ShowDetailsEventHandler> {
* @return the geona item ref * @return the geona item ref
*/ */
public GeoNaItemRef getGeonaItemRef() { public GeoNaItemRef getGeonaItemRef() {
return new GeoNaItemRef(geonaID, geonaItemType); return new GeoNaItemRef(geonaMongoID, geonaItemType);
} }

View File

@ -75,7 +75,7 @@ public class ConvertToDataViewModel {
theConcessione.setDescrizioneContenuto(concessione.getDescrizioneContenuto()); theConcessione.setDescrizioneContenuto(concessione.getDescrizioneContenuto());
theConcessione.setEditore(concessione.getEditore()); theConcessione.setEditore(concessione.getEditore());
theConcessione.setFontiFinanziamento(concessione.getFontiFinanziamento()); theConcessione.setFontiFinanziamento(concessione.getFontiFinanziamento());
theConcessione.setId(concessione.getId()); theConcessione.setItemId(concessione.getMongo_id());
theConcessione.setNome(concessione.getNome()); theConcessione.setNome(concessione.getNome());
theConcessione.setIntroduzione(concessione.getIntroduzione()); theConcessione.setIntroduzione(concessione.getIntroduzione());

View File

@ -1,12 +1,14 @@
package org.gcube.portlets.user.geoportaldataviewer.server; package org.gcube.portlets.user.geoportaldataviewer.server;
import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.statefulMongoConcessioni;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.gcube.application.geoportal.client.legacy.ConcessioniManager; import org.gcube.application.geoportal.client.legacy.ConcessioniManagerI;
import org.gcube.application.geoportal.common.model.legacy.Concessione; import org.gcube.application.geoportal.common.model.legacy.Concessione;
import org.gcube.application.geoportal.common.model.legacy.UploadedImage; import org.gcube.application.geoportal.common.model.legacy.UploadedImage;
import org.gcube.application.geoportalcommon.GeoNaDataViewerProfileReader; import org.gcube.application.geoportalcommon.GeoNaDataViewerProfileReader;
@ -14,6 +16,9 @@ import org.gcube.application.geoportalcommon.GeoportalCommon;
import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile; import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile;
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef; import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
import org.gcube.application.geoportalcommon.shared.LayerItem; import org.gcube.application.geoportalcommon.shared.LayerItem;
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.client.GeoportalDataViewerService; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerService;
import org.gcube.portlets.user.geoportaldataviewer.server.gis.FeatureParser; import org.gcube.portlets.user.geoportaldataviewer.server.gis.FeatureParser;
import org.gcube.portlets.user.geoportaldataviewer.server.gis.WMSUrlValidator; import org.gcube.portlets.user.geoportaldataviewer.server.gis.WMSUrlValidator;
@ -43,12 +48,11 @@ import com.google.gwt.user.server.rpc.RemoteServiceServlet;
* *
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* *
* Nov 12, 2020 * Nov 12, 2020
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet implements public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet implements GeoportalDataViewerService {
GeoportalDataViewerService {
public static final String PRODUCT_ID = "product_id"; public static final String PRODUCT_ID = "product_id";
/** The Constant LOG. */ /** The Constant LOG. */
private static final Logger LOG = LoggerFactory.getLogger(GeoportalDataViewerServiceImpl.class); private static final Logger LOG = LoggerFactory.getLogger(GeoportalDataViewerServiceImpl.class);
@ -57,7 +61,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
* Parses the wms request. * Parses the wms request.
* *
* @param wmsRequest the wms request * @param wmsRequest the wms request
* @param layerName the layer name * @param layerName the layer name
* @return the geo information for WMS request * @return the geo information for WMS request
* @throws Exception the exception * @throws Exception the exception
*/ */
@ -65,17 +69,17 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
public GeoInformationForWMSRequest parseWmsRequest(String wmsRequest, String layerName) throws Exception { public GeoInformationForWMSRequest parseWmsRequest(String wmsRequest, String layerName) throws Exception {
return loadGeoInfoForWmsRequest(wmsRequest, layerName); return loadGeoInfoForWmsRequest(wmsRequest, layerName);
} }
/** /**
* Load geo info for wms request. * Load geo info for wms request.
* *
* @param wmsLink the wms link * @param wmsLink the wms link
* @param layerName the layer name * @param layerName the layer name
* @return the geo information for WMS request * @return the geo information for WMS request
* @throws Exception the exception * @throws Exception the exception
*/ */
public static GeoInformationForWMSRequest loadGeoInfoForWmsRequest(String wmsLink, String layerName) throws Exception{ public static GeoInformationForWMSRequest loadGeoInfoForWmsRequest(String wmsLink, String layerName)
throws Exception {
try { try {
WMSUrlValidator validator = new WMSUrlValidator(wmsLink, layerName); WMSUrlValidator validator = new WMSUrlValidator(wmsLink, layerName);
String wmsServiceHost = validator.getWmsServiceHost(); String wmsServiceHost = validator.getWmsServiceHost();
@ -83,30 +87,33 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
layerName = validator.getLayerName(); layerName = validator.getLayerName();
String versionWms = validator.getValueOfParsedWMSParameter(WmsParameters.VERSION); String versionWms = validator.getValueOfParsedWMSParameter(WmsParameters.VERSION);
String crs = validator.getValueOfParsedWMSParameter(WmsParameters.CRS); String crs = validator.getValueOfParsedWMSParameter(WmsParameters.CRS);
// //
HashMap<String, String> mapWmsNotStandard = new HashMap<String, String>(); HashMap<String, String> mapWmsNotStandard = new HashMap<String, String>();
if(validator.getMapWmsNoStandardParams()!=null){ if (validator.getMapWmsNoStandardParams() != null) {
mapWmsNotStandard.putAll(validator.getMapWmsNoStandardParams()); mapWmsNotStandard.putAll(validator.getMapWmsNoStandardParams());
} }
// //
GeoNcWMSMetadataUtility geoGS = new GeoNcWMSMetadataUtility(validWMSRequest, 4000); GeoNcWMSMetadataUtility geoGS = new GeoNcWMSMetadataUtility(validWMSRequest, 4000);
//STYLES // STYLES
LayerStyles layerStyle = geoGS.loadStyles(); LayerStyles layerStyle = geoGS.loadStyles();
Map<String,String> mapNcWmsStyles = layerStyle.getMapNcWmsStyles()==null?new HashMap<String, String>(1):layerStyle.getMapNcWmsStyles(); Map<String, String> mapNcWmsStyles = layerStyle.getMapNcWmsStyles() == null ? new HashMap<String, String>(1)
: layerStyle.getMapNcWmsStyles();
mapWmsNotStandard.putAll(mapNcWmsStyles); mapWmsNotStandard.putAll(mapNcWmsStyles);
//MAP STYLES INTO GWT-SERIALIZABLE OBJECT // MAP STYLES INTO GWT-SERIALIZABLE OBJECT
Styles styles = new Styles(layerStyle.getGeoStyles(), layerStyle.getMapNcWmsStyles(), layerStyle.isNcWms()); Styles styles = new Styles(layerStyle.getGeoStyles(), layerStyle.getMapNcWmsStyles(), layerStyle.isNcWms());
//ZAxis // ZAxis
LayerZAxis layerZAxis = geoGS.loadZAxis(); LayerZAxis layerZAxis = geoGS.loadZAxis();
//MAP ZAXIS INTO GWT-SERIALIZABLE OBJECT // MAP ZAXIS INTO GWT-SERIALIZABLE OBJECT
ZAxis zAxis = layerZAxis!=null?new ZAxis(layerZAxis.getUnits(), layerZAxis.isPositive(), layerZAxis.getValues()):null; ZAxis zAxis = layerZAxis != null
? new ZAxis(layerZAxis.getUnits(), layerZAxis.isPositive(), layerZAxis.getValues())
: null;
return new GeoInformationForWMSRequest(wmsServiceHost, validWMSRequest, layerName, versionWms, crs, mapWmsNotStandard, styles, styles.isNcWms(), zAxis); return new GeoInformationForWMSRequest(wmsServiceHost, validWMSRequest, layerName, versionWms, crs,
} mapWmsNotStandard, styles, styles.isNcWms(), zAxis);
catch (Exception e) { } catch (Exception e) {
String msg = "An error occurred during wms request validation for layer: "+layerName; String msg = "An error occurred during wms request validation for layer: " + layerName;
LOG.error(msg,e); LOG.error(msg, e);
throw new Exception(msg); throw new Exception(msg);
} }
} }
@ -114,83 +121,88 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
/** /**
* Gets the data result. * Gets the data result.
* *
* @param layerObjects the layer objects * @param layerObjects the layer objects
* @param mapSrsName the map srs name * @param mapSrsName the map srs name
* @param selectBBOX the select BBOX * @param selectBBOX the select BBOX
* @param maxWFSFeature the max WFS feature * @param maxWFSFeature the max WFS feature
* @param zoomLevel the zoom level * @param zoomLevel the zoom level
* @return the data result * @return the data result
*/ */
@Override @Override
public List<GeoNaSpatialQueryResult> getDataResult(List<LayerObject> layerObjects, String mapSrsName, BoundsMap selectBBOX, public List<GeoNaSpatialQueryResult> getDataResult(List<LayerObject> layerObjects, String mapSrsName,
int maxWFSFeature, double zoomLevel) { BoundsMap selectBBOX, int maxWFSFeature, double zoomLevel) {
LOG.info("getDataResult called"); LOG.info("getDataResult called");
List<GeoNaSpatialQueryResult> listDAO = new ArrayList<GeoNaSpatialQueryResult>(layerObjects.size()); List<GeoNaSpatialQueryResult> listDAO = new ArrayList<GeoNaSpatialQueryResult>(layerObjects.size());
for (LayerObject layerObject : layerObjects) { for (LayerObject layerObject : layerObjects) {
GeoNaSpatialQueryResult geoDAO = new GeoNaSpatialQueryResult(); GeoNaSpatialQueryResult geoDAO = new GeoNaSpatialQueryResult();
List<FeatureRow> features = FeatureParser.getWFSFeatures(layerObject.getLayerItem(), mapSrsName, selectBBOX, maxWFSFeature); List<FeatureRow> features = FeatureParser.getWFSFeatures(layerObject.getLayerItem(), mapSrsName, selectBBOX,
LOG.debug("For layer name: "+layerObject.getLayerItem().getName() +" got features: "+features); maxWFSFeature);
LOG.debug("For layer name: " + layerObject.getLayerItem().getName() + " got features: " + features);
geoDAO.setFeatures(features); geoDAO.setFeatures(features);
for (FeatureRow fRow : features) { for (FeatureRow fRow : features) {
if(fRow.getMapProperties()!=null) { if (fRow.getMapProperties() != null) {
List<String> concessioneIds = fRow.getMapProperties().get("product_id"); List<String> concessioneIds = fRow.getMapProperties().get("product_id");
if(concessioneIds!=null && concessioneIds.size()>0) { if (concessioneIds != null && concessioneIds.size() > 0) {
String cId = concessioneIds.get(0); String cId = concessioneIds.get(0);
try { try {
long theConcessionID = Long.parseLong(cId); List<UploadedImageDV> listUI = getUploadedImagesForId("Concessione", cId, 1);
List<UploadedImageDV> listUI = getUploadedImagesForId("Concessione", theConcessionID, 1); Map<String, List<UploadedImageDV>> mapImages = new LinkedHashMap<String, List<UploadedImageDV>>();
Map<Long, List<UploadedImageDV>> mapImages = new LinkedHashMap<Long, List<UploadedImageDV>>(); mapImages.put(cId, listUI);
mapImages.put(theConcessionID, listUI);
geoDAO.setMapImages(mapImages); geoDAO.setMapImages(mapImages);
}catch (Exception e) { } catch (Exception e) {
LOG.warn("Error on loading uploaded images for concessione: "+cId, e); LOG.warn("Error on loading uploaded images for concessione: " + cId, e);
} }
} }
} }
} }
geoDAO.setSourceLayerObject(layerObject); geoDAO.setSourceLayerObject(layerObject);
LOG.info("For layer name: "+layerObject.getLayerItem().getName() +" got "+features.size()+" feature/s"); LOG.info("For layer name: " + layerObject.getLayerItem().getName() + " got " + features.size()
+ " feature/s");
listDAO.add(geoDAO); listDAO.add(geoDAO);
} }
LOG.info("returning "+listDAO+" geona data objects"); LOG.info("returning " + listDAO + " geona data objects");
return listDAO; return listDAO;
} }
/** /**
* Gets the uploaded images for id. * Gets the uploaded images for id.
* *
* @param id the id * @param itemType the item type
* @param itemId the item id. It is the mongoId
* @param maxImages the max images
* @return the uploaded images for id * @return the uploaded images for id
* @throws Exception the exception * @throws Exception the exception
*/ */
@Override @Override
public List<UploadedImageDV> getUploadedImagesForId(String itemType, Long id, int maxImages) throws Exception{ public List<UploadedImageDV> getUploadedImagesForId(String itemType, String itemId, int maxImages)
LOG.info("getUploadedImagesForId [id: "+id+", itemType: "+itemType+"] called"); throws Exception {
LOG.info("getUploadedImagesForId [itemId: " + itemId + ", itemType: " + itemType + "] called");
if(itemType==null)
if (itemType == null)
throw new Exception("Invalid parameter. The itemType is null"); throw new Exception("Invalid parameter. The itemType is null");
if(id==null) if (itemId == null)
throw new Exception("Invalid parameter. The Id is null"); throw new Exception("Invalid parameter. The itemId is null");
List<UploadedImageDV> listUI = null; List<UploadedImageDV> listUI = null;
try { try {
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
if(itemType.equalsIgnoreCase("concessione")) { if (itemType.equalsIgnoreCase("concessione")) {
LOG.info("Trying to get concessione for id "+id); LOG.info("Trying to get concessione for id " + itemId);
ConcessioniManager concessioniManager = new ConcessioniManager(); SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
Concessione concessione = concessioniManager.getById(id+""); SessionUtil.getCurrentToken(this.getThreadLocalRequest(), true);
ConcessioniManagerI concessioniManager = statefulMongoConcessioni().build();
Concessione concessione = concessioniManager.getById(itemId);
if (concessione != null) { if (concessione != null) {
LOG.info("For id "+id+", got concessione "+concessione.getNome() +" from service"); LOG.info("For id " + itemId + ", got concessione " + concessione.getNome() + " from service");
List<UploadedImage> images = concessione.getImmaginiRappresentative(); List<UploadedImage> images = concessione.getImmaginiRappresentative();
if (images != null) { if (images != null) {
listUI = new ArrayList<UploadedImageDV>(); listUI = new ArrayList<UploadedImageDV>();
int max = maxImages < images.size() ? maxImages : images.size(); int max = maxImages < images.size() ? maxImages : images.size();
@ -198,70 +210,73 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
UploadedImageDV ui = ConvertToDataViewModel.toUploadedImage(images.get(i)); UploadedImageDV ui = ConvertToDataViewModel.toUploadedImage(images.get(i));
listUI.add(ui); listUI.add(ui);
} }
LOG.info("For id "+id+", got "+listUI.size() +" image/s"); LOG.info("For id " + itemId + ", got " + listUI.size() + " image/s");
} }
}else } else
throw new Exception("Concessione with id: "+id +" not available"); throw new Exception("Concessione with id '" + itemId + "' not available");
} }
return listUI; return listUI;
}catch (Exception e) { } catch (Exception e) {
String erroMsg = UploadedImage.class.getSimpleName() +" not available for "+Concessione.class.getSimpleName() +" with id "+id; String erroMsg = UploadedImage.class.getSimpleName() + " not available for "
LOG.error(erroMsg,e); + Concessione.class.getSimpleName() + " with id " + itemId;
LOG.error(erroMsg, e);
throw new Exception(erroMsg); throw new Exception(erroMsg);
} }
} }
/** /**
* Gets the concessione for id. * Gets the concessione for id.
* *
* @param id the id * @param mongoId the mongo id
* @return the concessione for id * @return the concessione for id
* @throws Exception the exception * @throws Exception the exception
*/ */
@Override @Override
public ConcessioneDV getConcessioneForId(Long id) throws Exception{ public ConcessioneDV getConcessioneForId(String mongoId) throws Exception {
LOG.info("getConcessioneForId "+id+ " called"); LOG.info("getConcessioneForId " + mongoId + " called");
ConcessioneDV concessionDV = null; ConcessioneDV concessionDV = null;
if(id==null) if (mongoId == null)
throw new Exception("Invalid parameter. The Id is null"); throw new Exception("Invalid parameter. The itemId is null");
try { try {
LOG.info("Trying to get record for id "+id); LOG.info("Trying to get record for id " + mongoId);
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
Concessione concessione = new ConcessioniManager().getById(id+""); SessionUtil.getCurrentToken(this.getThreadLocalRequest(), true);
LOG.info("Got concessione for id "+id); // Obtain the client
if(concessione !=null) { ConcessioniManagerI manager = statefulMongoConcessioni().build();
Concessione concessione = manager.getById(mongoId);
LOG.info("Got concessione for mongoId " + mongoId);
if (concessione != null) {
concessionDV = ConvertToDataViewModel.toConcessione(concessione); concessionDV = ConvertToDataViewModel.toConcessione(concessione);
} }
if(concessionDV==null) if (concessionDV == null)
throw new Exception("Concessione with id: "+id +" not available"); throw new Exception("Concessione with id '" + mongoId + "' not available");
LOG.debug("For id "+id+" returning "+ConcessioneDV.class.getSimpleName()+": "+concessionDV); LOG.debug("For id " + mongoId + " returning " + ConcessioneDV.class.getSimpleName() + ": " + concessionDV);
return concessionDV; return concessionDV;
}catch (Exception e) { } catch (Exception e) {
String erroMsg = Concessione.class.getSimpleName() +" with id "+id+" not available"; String erroMsg = Concessione.class.getSimpleName() + " with id '" + mongoId + "' not available";
LOG.error(erroMsg,e); LOG.error(erroMsg, e);
throw new Exception(erroMsg); throw new Exception(erroMsg);
} }
} }
/** /**
* Gets the parameters from URL. * Gets the parameters from URL.
* *
* @param theURL the the URL * @param theURL the the URL
* @param parameters the parameters * @param parameters the parameters
* @return a map with couple (paramKey, paramValue) * @return a map with couple (paramKey, paramValue)
*/ */
public Map<String, String> getParametersFromURL(String theURL, List<String> parameters) { public Map<String, String> getParametersFromURL(String theURL, List<String> parameters) {
if (theURL == null) if (theURL == null)
@ -275,30 +290,29 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
String paramValue = URLParserUtil.extractValueOfParameterFromURL(paramKey, theURL); String paramValue = URLParserUtil.extractValueOfParameterFromURL(paramKey, theURL);
hashParameters.put(paramKey, paramValue); hashParameters.put(paramKey, paramValue);
} }
return hashParameters; return hashParameters;
} }
/** /**
* Gets the my login. * Gets the my login.
* *
* @return the my login * @return the my login
*/ */
@Override @Override
public String getMyLogin(){ public String getMyLogin() {
try { try {
GCubeUser user = SessionUtil.getCurrentUser(this.getThreadLocalRequest()); GCubeUser user = SessionUtil.getCurrentUser(this.getThreadLocalRequest());
if(user==null) if (user == null)
return null; return null;
return user.getUsername(); return user.getUsername();
}catch (Exception e) { } catch (Exception e) {
LOG.warn("Error on getting the login, am I out of portal? Returning null"); LOG.warn("Error on getting the login, am I out of portal? Returning null");
return null; return null;
} }
} }
/** /**
* Gets the layer for type. * Gets the layer for type.
* *
@ -307,31 +321,31 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
* @throws Exception the exception * @throws Exception the exception
*/ */
@Override @Override
public GeoInformationForWMSRequest getLayerForType(String layerType) throws Exception{ public GeoInformationForWMSRequest getLayerForType(String layerType) throws Exception {
LOG.info("Called getLayerForType for:"+layerType); LOG.info("Called getLayerForType for:" + layerType);
if(layerType==null || layerType.isEmpty()) if (layerType == null || layerType.isEmpty())
throw new Exception("The input parameter layerType is null or empty"); throw new Exception("The input parameter layerType is null or empty");
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
GeoNaDataViewerProfileReader gdvp = new GeoNaDataViewerProfileReader("geoportal-data-viewer-app"); GeoNaDataViewerProfileReader gdvp = new GeoNaDataViewerProfileReader("geoportal-data-viewer-app");
GeoNaDataViewerProfile profile = gdvp.readProfileFromInfrastrucure(); GeoNaDataViewerProfile profile = gdvp.readProfileFromInfrastrucure();
LOG.info("Read profile: "+profile); LOG.info("Read profile: " + profile);
String lowerLayerType = layerType.toLowerCase(); String lowerLayerType = layerType.toLowerCase();
LOG.info("Reading map layers for type:"+lowerLayerType); LOG.info("Reading map layers for type:" + lowerLayerType);
LayerItem layer = profile.getMapLayers().get(lowerLayerType); LayerItem layer = profile.getMapLayers().get(lowerLayerType);
if(layer==null || layer.getWmsLink()==null) if (layer == null || layer.getWmsLink() == null)
throw new Exception("The layer type "+lowerLayerType+" has not been found. Please check your input parameter"); throw new Exception(
"The layer type " + lowerLayerType + " has not been found. Please check your input parameter");
if(layer.getWmsLink()==null)
throw new Exception("The layer type "+lowerLayerType+" has not a WMS Link associated. Please check your input parameter"); if (layer.getWmsLink() == null)
throw new Exception("The layer type " + lowerLayerType
+ " has not a WMS Link associated. Please check your input parameter");
return parseWmsRequest(layer.getWmsLink(), null); return parseWmsRequest(layer.getWmsLink(), null);
} }
/** /**
* Gets the geo na data view profile. * Gets the geo na data view profile.
@ -340,17 +354,16 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
* @throws Exception the exception * @throws Exception the exception
*/ */
@Override @Override
public GeoNaDataViewerProfile getGeoNaDataViewProfile() throws Exception{ public GeoNaDataViewerProfile getGeoNaDataViewProfile() throws Exception {
LOG.info("getGeoNaDataViewProfile called"); LOG.info("getGeoNaDataViewProfile called");
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
GeoportalCommon gc = new GeoportalCommon(); GeoportalCommon gc = new GeoportalCommon();
org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile profile = gc.getGeoNaDataViewProfile(null); org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile profile = gc.getGeoNaDataViewProfile(null);
LOG.info("Returning profile: "+profile); LOG.info("Returning profile: " + profile);
return profile; return profile;
} }
@Override @Override
public GeoNaItemRef getPublicLinksFor(GeoNaItemRef item) throws Exception { public GeoNaItemRef getPublicLinksFor(GeoNaItemRef item) throws Exception {
LOG.info("getPublicLinksFor called for: " + item); LOG.info("getPublicLinksFor called for: " + item);
@ -359,25 +372,26 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
if (item == null) if (item == null)
throw new Exception("Bad request, the item is null"); throw new Exception("Bad request, the item is null");
if(item.getItemId()==null) if (item.getItemId() == null)
throw new Exception("Bad request, the item id is null"); throw new Exception("Bad request, the item id is null");
if(item.getItemType()==null) if (item.getItemType() == null)
throw new Exception("Bad request, the item type is null"); throw new Exception("Bad request, the item type is null");
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true); SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
GeoportalCommon gc = new GeoportalCommon(); GeoportalCommon gc = new GeoportalCommon();
return gc.getPublicLinksFor(item); return gc.getPublicLinksFor(item);
} catch (Exception e) { } catch (Exception e) {
LOG.error("Error on getPublicLinksFor for: " + item, e); LOG.error("Error on getPublicLinksFor for: " + item, e);
throw new Exception("Share link not available for this item. Try later or contact the support. Error: "+e.getMessage()); throw new Exception("Share link not available for this item. Try later or contact the support. Error: "
+ e.getMessage());
} }
} }
public boolean isSessionExpired() throws Exception { public boolean isSessionExpired() throws Exception {
return SessionUtil.isSessionExpired(this.getThreadLocalRequest()); return SessionUtil.isSessionExpired(this.getThreadLocalRequest());
} }
} }

View File

@ -6,6 +6,7 @@ package org.gcube.portlets.user.geoportaldataviewer.server.util;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.portal.PortalContext; import org.gcube.common.portal.PortalContext;
import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portlets.user.urlshortener.UrlShortener; import org.gcube.portlets.user.urlshortener.UrlShortener;
@ -20,19 +21,18 @@ import org.slf4j.LoggerFactory;
import com.liferay.portal.service.UserLocalServiceUtil; import com.liferay.portal.service.UserLocalServiceUtil;
/** /**
* The Class SessionUtil. * The Class SessionUtil.
* *
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* *
* Oct 20, 2020 * Oct 20, 2020
*/ */
public class SessionUtil { public class SessionUtil {
/** The log. */ /** The log. */
private static Logger LOG = LoggerFactory.getLogger(SessionUtil.class); private static Logger LOG = LoggerFactory.getLogger(SessionUtil.class);
public static final String URL_SHORTENER_SERVICE = "URL_SHORTENER_SERVICE"; public static final String URL_SHORTENER_SERVICE = "URL_SHORTENER_SERVICE";
/** /**
@ -44,20 +44,18 @@ public class SessionUtil {
try { try {
UserLocalServiceUtil.getService(); UserLocalServiceUtil.getService();
return true; return true;
}catch (Exception ex) { } catch (Exception ex) {
LOG.warn("Development Mode ON"); LOG.warn("Development Mode ON");
return false; return false;
} }
} }
/** /**
* Checks if is session expired. * Checks if is session expired.
* *
* @param httpServletRequest * @param httpServletRequest the http servlet request
* the http servlet request
* @return true, if is session expired * @return true, if is session expired
* @throws Exception * @throws Exception the exception
* the exception
*/ */
public static boolean isSessionExpired(HttpServletRequest httpServletRequest) throws Exception { public static boolean isSessionExpired(HttpServletRequest httpServletRequest) throws Exception {
LOG.trace("workspace session validating..."); LOG.trace("workspace session validating...");
@ -70,9 +68,9 @@ public class SessionUtil {
* @param request the request * @param request the request
* @return a GcubeUser object * @return a GcubeUser object
*/ */
public static GCubeUser getCurrentUser(HttpServletRequest request){ public static GCubeUser getCurrentUser(HttpServletRequest request) {
if(request == null) if (request == null)
throw new IllegalArgumentException("HttpServletRequest is null!"); throw new IllegalArgumentException("HttpServletRequest is null!");
PortalContext pContext = PortalContext.getConfiguration(); PortalContext pContext = PortalContext.getConfiguration();
@ -84,36 +82,60 @@ public class SessionUtil {
/** /**
* Retrieve the current scope by using the portal manager. * Retrieve the current scope by using the portal manager.
* *
* @param request the request * @param request the request
* @param setInThread the set in thread * @param setInThread the set in thread
* @return a GcubeUser object * @return a GcubeUser object
*/ */
public static String getCurrentContext(HttpServletRequest request, boolean setInThread){ public static String getCurrentContext(HttpServletRequest request, boolean setInThread) {
if(request == null) if (request == null)
throw new IllegalArgumentException("HttpServletRequest is null!"); throw new IllegalArgumentException("HttpServletRequest is null!");
PortalContext pContext = PortalContext.getConfiguration(); PortalContext pContext = PortalContext.getConfiguration();
String context = pContext.getCurrentScope(request); String context = pContext.getCurrentScope(request);
LOG.debug("Returning context " + context);
if(context != null && setInThread) if (context != null && setInThread)
ScopeProvider.instance.set(context); ScopeProvider.instance.set(context);
LOG.debug("Returning context " + context);
return context; return context;
} }
/**
* Retrieve the current scope by using the portal manager.
*
* @param request the request
* @param setInThread the set in thread
* @return a GcubeUser object
*/
public static String getCurrentToken(HttpServletRequest request, boolean setInThread) {
if (request == null)
throw new IllegalArgumentException("HttpServletRequest is null!");
PortalContext pContext = PortalContext.getConfiguration();
String scope = pContext.getCurrentScope(request);
GCubeUser user = pContext.getCurrentUser(request);
String token = PortalContext.getConfiguration().getCurrentUserToken(scope, user.getUsername());
if (token != null && setInThread)
SecurityTokenProvider.instance.set(token);
LOG.debug("Returning token " + token.substring(1, 10) + "MASKED_TOKEN");
return token;
}
/** /**
* Retrieve the group given the scope. * Retrieve the group given the scope.
* *
* @param scope the scope * @param scope the scope
* @return the group from scope * @return the group from scope
* @throws UserManagementSystemException the user management system exception * @throws UserManagementSystemException the user management system exception
* @throws GroupRetrievalFault the group retrieval fault * @throws GroupRetrievalFault the group retrieval fault
*/ */
public static GCubeGroup getGroupFromScope(String scope) throws UserManagementSystemException, GroupRetrievalFault{ public static GCubeGroup getGroupFromScope(String scope) throws UserManagementSystemException, GroupRetrievalFault {
if(scope == null || scope.isEmpty()) if (scope == null || scope.isEmpty())
throw new IllegalArgumentException("Scope is missing here!!"); throw new IllegalArgumentException("Scope is missing here!!");
GroupManager gm = new LiferayGroupManager(); GroupManager gm = new LiferayGroupManager();
@ -122,7 +144,6 @@ public class SessionUtil {
} }
/** /**
* Gets the url shortener. * Gets the url shortener.
* *
@ -142,7 +163,7 @@ public class SessionUtil {
} }
} catch (Exception e) { } catch (Exception e) {
LOG.warn("Error occurred when instancing the "+UrlShortener.class.getSimpleName(), e); LOG.warn("Error occurred when instancing the " + UrlShortener.class.getSimpleName(), e);
} }
return shortener; return shortener;

View File

@ -8,12 +8,13 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.FeatureRow; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.FeatureRow;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.UploadedImageDV; import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.UploadedImageDV;
/** /**
* The Class GeoNaSpatialQueryResult. * The Class GeoNaSpatialQueryResult.
* *
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
* *
* Nov 17, 2020 * Jul 30, 2021
*/ */
public class GeoNaSpatialQueryResult implements Serializable { public class GeoNaSpatialQueryResult implements Serializable {
@ -23,8 +24,8 @@ public class GeoNaSpatialQueryResult implements Serializable {
private static final long serialVersionUID = 3513120677727206958L; private static final long serialVersionUID = 3513120677727206958L;
private List<FeatureRow> features; private List<FeatureRow> features;
private LayerObject sourceLayerObject; private LayerObject sourceLayerObject;
// Map with couple (id concessione, list of uplaoded Images for the concessione) // Map with couple (mongoId concessione, list of uplaoded Images for the concessione)
private Map<Long, List<UploadedImageDV>> mapImages = null; private Map<String, List<UploadedImageDV>> mapImages = null;
/** /**
* Instantiates a new geo na data object. * Instantiates a new geo na data object.
@ -74,7 +75,7 @@ public class GeoNaSpatialQueryResult implements Serializable {
* *
* @return the map images * @return the map images
*/ */
public Map<Long, List<UploadedImageDV>> getMapImages() { public Map<String, List<UploadedImageDV>> getMapImages() {
return mapImages; return mapImages;
} }
@ -83,10 +84,15 @@ public class GeoNaSpatialQueryResult implements Serializable {
* *
* @param mapImages the map images * @param mapImages the map images
*/ */
public void setMapImages(Map<Long, List<UploadedImageDV>> mapImages) { public void setMapImages(Map<String, List<UploadedImageDV>> mapImages) {
this.mapImages = mapImages; this.mapImages = mapImages;
} }
/**
* To string.
*
* @return the string
*/
@Override @Override
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();

View File

@ -13,14 +13,13 @@ import com.google.gwt.user.client.rpc.IsSerializable;
*/ */
public abstract class RecordDV implements Serializable, IsSerializable { public abstract class RecordDV implements Serializable, IsSerializable {
/** /**
* *
*/ */
private static final long serialVersionUID = 2913726613820175679L; private static final long serialVersionUID = 2913726613820175679L;
/** The id. */ /** The mongo id **/
private Long id; private String itemId;
/** The record type. */ /** The record type. */
private String recordType; private String recordType;
@ -62,21 +61,21 @@ public abstract class RecordDV implements Serializable, IsSerializable {
} }
/** /**
* Gets the id. * Gets the item id.
* *
* @return the id * @return the item id
*/ */
public Long getId() { public String getItemId() {
return id; return itemId;
} }
/** /**
* Sets the id. * Sets the item id.
* *
* @param id the new id * @param itemId the new item id
*/ */
public void setId(Long id) { public void setItemId(String itemId) {
this.id = id; this.itemId = itemId;
} }
/** /**
@ -262,8 +261,8 @@ public abstract class RecordDV implements Serializable, IsSerializable {
@Override @Override
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("RecordDV [id="); builder.append("RecordDV [itemId=");
builder.append(id); builder.append(itemId);
builder.append(", recordType="); builder.append(", recordType=");
builder.append(recordType); builder.append(recordType);
builder.append(", version="); builder.append(", version=");
@ -288,4 +287,6 @@ public abstract class RecordDV implements Serializable, IsSerializable {
return builder.toString(); return builder.toString();
} }
} }