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"?>
<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>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</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>
<attribute name="maven.pomderived" value="true"/>
</attributes>
@ -36,5 +36,5 @@
</attributes>
</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="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>

View File

@ -1,4 +1,4 @@
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
warSrcDirIsOutput=false

View File

@ -1,13 +1,15 @@
<?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"/>
@ -23,7 +26,8 @@
<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="/src/main/java"/>
<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="context-root" value="geoportal-data-viewer-app"/>
@ -61,7 +70,8 @@
</wb-module>

View File

@ -4,6 +4,11 @@
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).
## [v1.3.0-SNAPSHOT] - 2021-07-30
#### Enhancements
[#21890] Porting to ConcessioniManagerI and pass to mongoID
## [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
Moved to maven-portal-bom 3.6.3
## [v1.1.0] - 2020-12-21
#### Enhancements

View File

@ -14,7 +14,7 @@
<groupId>org.gcube.portlets.user</groupId>
<artifactId>geoportal-data-viewer-app</artifactId>
<packaging>war</packaging>
<version>1.2.0-SNAPSHOT</version>
<version>1.3.0-SNAPSHOT</version>
<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>

View File

@ -124,14 +124,14 @@ public class GeoportalDataViewer implements EntryPoint {
GWT.log(GeoportalDataViewerConstants.GET_LAYER_TITLE + " = " + paramLayerTitle);
// VALIDATING THE LONG FORMAT FOR GID
try {
if (paramGeonaItemID != null)
Long.parseLong(paramGeonaItemID);
} catch (Exception e) {
Window.alert("Bad format for parameter " + GeoportalDataViewerConstants.GET_GEONA_ITEM_ID
+ ". It must be a Long");
paramGeonaItemID = null;
}
// try {
// if (paramGeonaItemID != null)
// Long.parseLong(paramGeonaItemID);
// } catch (Exception e) {
// Window.alert("Bad format for parameter " + GeoportalDataViewerConstants.GET_GEONA_ITEM_ID
// + ". It must be a Long");
// paramGeonaItemID = null;
// }
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@ -177,7 +177,7 @@ public class GeoportalDataViewer implements EntryPoint {
+ paramGeonaItemID);
return;
}
GeoNaItemRef gir = new GeoNaItemRef(new Long(paramGeonaItemID), paramGeonaItemType);
GeoNaItemRef gir = new GeoNaItemRef(paramGeonaItemID, paramGeonaItemType);
applicationBus.fireEvent(new ShowDetailsEvent(gir, null, null));
}
@ -222,22 +222,22 @@ public class GeoportalDataViewer implements EntryPoint {
public void onShowDetails(ShowDetailsEvent 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");
return;
}
//TODO
boolean found = false;
GWT.log("Product with id: "+id+" found? "+found);
GWT.log("Product with id: "+geonaMongoId+" found? "+found);
if(!found) {
if(showDetailsEvent.getGeonaItemType().equalsIgnoreCase("Concessione")) {
GeoportalDataViewerServiceAsync.Util.getInstance().getConcessioneForId(id, new AsyncCallback<ConcessioneDV>() {
GeoportalDataViewerServiceAsync.Util.getInstance().getConcessioneForId(geonaMongoId, new AsyncCallback<ConcessioneDV>() {
@Override
public void onFailure(Throwable caught) {
@ -325,7 +325,7 @@ public class GeoportalDataViewer implements EntryPoint {
private void performWFSQueryOnCentroid(RecordDV record) {
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));
if(record instanceof ConcessioneDV) {
ConcessioneDV concessioneDV = (ConcessioneDV) record;
@ -337,7 +337,7 @@ public class GeoportalDataViewer implements EntryPoint {
GeoQuery select = olMapMng.toDataPointQuery(transfCoord);
GWT.log("GeoQuery: "+select);
//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 {
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)
*
* Nov 17, 2020
* Nov 17, 2020
*/
@RemoteServiceRelativePath("geoportaldataviewerservice")
public interface GeoportalDataViewerService extends RemoteService {
@ -28,7 +28,7 @@ public interface GeoportalDataViewerService extends RemoteService {
* Parses 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
* @throws Exception the exception
*/
@ -37,11 +37,11 @@ public interface GeoportalDataViewerService extends RemoteService {
/**
* Gets the data result.
*
* @param layerObjects the layer objects
* @param mapSrsName the map srs name
* @param mapBBOX the map BBOX
* @param layerObjects the layer objects
* @param mapSrsName the map srs name
* @param mapBBOX the map BBOX
* @param maxWFSFeature the max WFS feature
* @param zoomLevel the zoom level
* @param zoomLevel the zoom level
* @return the data result
*/
List<GeoNaSpatialQueryResult> getDataResult(List<LayerObject> layerObjects, String mapSrsName, BoundsMap mapBBOX,
@ -50,11 +50,11 @@ public interface GeoportalDataViewerService extends RemoteService {
/**
* Gets the concessione for id.
*
* @param id the id
* @param mongoId the mongo id
* @return the concessione for id
* @throws Exception the exception
*/
ConcessioneDV getConcessioneForId(Long id) throws Exception;
ConcessioneDV getConcessioneForId(String mongoId) throws Exception;
/**
* Gets the my login.
@ -84,12 +84,12 @@ public interface GeoportalDataViewerService extends RemoteService {
* Gets the uploaded images for id.
*
* @param itemType the item type
* @param id the id
* @param itemId the item id
* @param maxImages the max images
* @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.

View File

@ -38,7 +38,7 @@ public interface GeoportalDataViewerServiceAsync {
void getDataResult(List<LayerObject> layerObjects, String mapSrsName, BoundsMap mapBBOX, int maxWFSFeature, double zoomLevel,
AsyncCallback<List<GeoNaSpatialQueryResult>> callback);
void getConcessioneForId(Long id, AsyncCallback<ConcessioneDV> callback);
void getConcessioneForId(String mongoId, AsyncCallback<ConcessioneDV> callback);
void getMyLogin(AsyncCallback<String> callback);
@ -46,7 +46,7 @@ public interface GeoportalDataViewerServiceAsync {
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);

View File

@ -51,23 +51,20 @@ import com.google.gwt.user.client.ui.VerticalPanel;
import ol.Coordinate;
/**
* The Class LayerManager.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Oct 27, 2020
* Oct 27, 2020
*/
public class LayerManager {
/** The ol map. */
private OpenLayerOSM olMap;
private List<LayerObject> layerObjects = new ArrayList<LayerObject>();
private HandlerManager layerManagerBus = new HandlerManager("");
private HandlerManager applicationBus;
@ -81,312 +78,333 @@ public class LayerManager {
this.applicationBus = applicationBus;
bindEvents();
}
/**
* Bind events.
*/
private void bindEvents() {
layerManagerBus.addHandler(QueryDataEvent.TYPE, new QueryDataEventHandler() {
@Override
public void onQueryInteraction(final QueryDataEvent queryEvent) {
//GeoportalDataViewerConstants.print("fired QueryDataEvent: "+queryEvent.toString());
if(queryEvent.getGeoQuery()!=null) {
// GeoportalDataViewerConstants.print("fired QueryDataEvent:
// "+queryEvent.toString());
if (queryEvent.getGeoQuery() != null) {
GeoQuery selectDataInfo = queryEvent.getGeoQuery();
Long recordId = queryEvent.getRecordId();
GWT.log("("+selectDataInfo.getX1()+","+selectDataInfo.getY1()+")("+selectDataInfo.getX2()+","+selectDataInfo.getY2()+")");
for (LayerObject layerObj : layerObjects){
//TODO
String mongoItemId = queryEvent.getMongoItemId();
GWT.log("(" + selectDataInfo.getX1() + "," + selectDataInfo.getY1() + ")(" + selectDataInfo.getX2()
+ "," + selectDataInfo.getY2() + ")");
for (LayerObject layerObj : layerObjects) {
// TODO
isLayerVisible(layerObj.getLayerItem());
}
BoundsMap mapBBOX = new BoundsMap();
//THIS IS SHOULD BE CORRET, THE BOUND AND CRS ARE READ FROM MAP
/*mapBBOX.setCrs(olMap.getProjectionCode());
mapBBOX.setLowerLeftX(olMap.getExtent().getLowerLeftX());
mapBBOX.setLowerLeftY(olMap.getExtent().getLowerLeftY());
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
// THIS IS SHOULD BE CORRET, THE BOUND AND CRS ARE READ FROM MAP
/*
* mapBBOX.setCrs(olMap.getProjectionCode());
* mapBBOX.setLowerLeftX(olMap.getExtent().getLowerLeftX());
* mapBBOX.setLowerLeftY(olMap.getExtent().getLowerLeftY());
* 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
// double minX = olMap.getExtent().getLowerLeftX();
// double minY = olMap.getExtent().getLowerLeftY();
double minX = queryEvent.getGeoQuery().getX1();
double minY = queryEvent.getGeoQuery().getY1();
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.setLowerLeftY(centerCoordinate.getY());
// double maxX = olMap.getExtent().getUpperRightX();
// double maxY = olMap.getExtent().getUpperRightY();
double maxX = queryEvent.getGeoQuery().getX2();
double maxY = queryEvent.getGeoQuery().getY2();
centerCoordinate = new Coordinate(maxX,maxY);
centerCoordinate = olMap.transform(centerCoordinate, GeoportalDataViewerConstants.EPSG_3857, GeoportalDataViewerConstants.EPSG_4326);
centerCoordinate = new Coordinate(maxX, maxY);
centerCoordinate = olMap.transform(centerCoordinate, GeoportalDataViewerConstants.EPSG_3857,
GeoportalDataViewerConstants.EPSG_4326);
mapBBOX.setUpperRightX(centerCoordinate.getX());
mapBBOX.setUpperRightY(centerCoordinate.getY());
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
public void onFailure(Throwable caught) {
//GeoportalDataViewerConstants.print("on Failure DataResult: "+caught.getMessage());
}
GWT.log("Bounds is: " + mapBBOX);
GWT.log("MAX_WFS_FEATURES is: " + GeoportalDataViewerConstants.MAX_WFS_FEATURES);
// GeoportalDataViewerConstants.print("calling getDataResult");
@Override
public void onSuccess(List<GeoNaSpatialQueryResult> listGeonaDataObjects) {
GWT.log("GeoNaDataObject's: "+listGeonaDataObjects);
//GeoportalDataViewerConstants.print("GeoNaDataObject's: "+listGeonaDataObjects);
if(listGeonaDataObjects==null || listGeonaDataObjects.isEmpty())
return;
GeoportalDataViewerServiceAsync.Util.getInstance().getDataResult(layerObjects,
olMap.getProjectionCode(), mapBBOX, GeoportalDataViewerConstants.MAX_WFS_FEATURES,
olMap.getCurrentZoomLevel(), new AsyncCallback<List<GeoNaSpatialQueryResult>>() {
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();
@Override
public void onFailure(Throwable caught) {
// GeoportalDataViewerConstants.print("on Failure DataResult:
// "+caught.getMessage());
}
//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(recordId!=null) {
for (FeatureRow fRow : features) {
List<String> productIdLst = fRow.getMapProperties().get("product_id");
String thePID = productIdLst.get(0);
@Override
public void onSuccess(List<GeoNaSpatialQueryResult> listGeonaDataObjects) {
GWT.log("GeoNaDataObject's: " + listGeonaDataObjects);
// GeoportalDataViewerConstants.print("GeoNaDataObject's:
// "+listGeonaDataObjects);
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 {
long productId = Long.parseLong(thePID);
if(productId==recordId) {
feature = fRow;
GWT.log("Found recorId == product_id with id: "+productId);
break;
}
}catch (Exception e) {
// TODO: handle exception
descrizione = StringUtil.ellipsize(descrizione, 100);
GWT.log("reduced: " + descrizione);
} catch (Exception e) {
GWT.log("error: " + e.getMessage());
}
// 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 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) {
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:"";
GWT.log("The selected Feature is: " + feature);
// GeoportalDataViewerConstants.print("The selected Feature is: "+feature);
FeatureRow theFeature = feature;
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:"";
}else if(key.equalsIgnoreCase("date_scavo")) {
date = theValue!=null?theValue:"";
}
}
//GeoportalDataViewerConstants.print("0: "+nome);
flex.setHTML(0, 0, new HTML(nome).toString());
try {
descrizione = StringUtil.ellipsize(descrizione, 100);
GWT.log("reduced: "+descrizione);
} catch (Exception e) {
GWT.log("error: "+e.getMessage());
}
//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);
VerticalPanel vpPanel = new VerticalPanel();
vpPanel.add(flex);
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());
}
}
}
featureFound = true;
//break; //Only the first one
}
if(feature==null)
return;
GWT.log("The selected Feature is: "+feature);
//GeoportalDataViewerConstants.print("The selected Feature is: "+feature);
FeatureRow theFeature = feature;
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);
}
VerticalPanel vpPanel = new VerticalPanel();
vpPanel.add(flex);
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);
}
}
});
}
});
}
}
//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() {
@Override
public void onLayerRendered(AddedLayerToMapEvent addedLayerToMapEvent) {
GWT.log("Fired into layerManagerBus "+addedLayerToMapEvent);
GWT.log("Fired into layerManagerBus " + addedLayerToMapEvent);
applicationBus.fireEvent(addedLayerToMapEvent);
}
});
layerManagerBus.addHandler(ZoomOutOverMinimumEvent.TYPE, new ZoomOutOverMinimumEventHandler() {
@Override
public void onZoomOut(ZoomOutOverMinimumEvent zoomOutEvent) {
GWT.log("Fired into layerManagerBus "+zoomOutEvent);
GWT.log("Fired into layerManagerBus " + zoomOutEvent);
applicationBus.fireEvent(zoomOutEvent);
}
});
}
/**
* Parses the geona references.
*
* @param itemType the item type
* @param fRow the f row
* @param fRow the f row
* @return the show details event
*/
private ShowDetailsEvent parseGeonaReferences(String itemType, FeatureRow fRow) {
if(fRow==null)
if (fRow == null)
return null;
List<String> productIds = fRow.getMapProperties().get("product_id");
if(productIds!=null && productIds.size()>0) {
long id = Long.parseLong(productIds.get(0));
if (productIds != null && productIds.size() > 0) {
String productId = productIds.get(0);
String itemName = "Dettagli Prodotto";
List<String> listName = fRow.getMapProperties().get("nome");
if(listName!=null && listName.size()>0) {
if (listName != null && listName.size() > 0) {
itemName = listName.get(0);
}
return new ShowDetailsEvent(itemType, id, itemName, fRow);
return new ShowDetailsEvent(itemType, productId, itemName, fRow);
}
return null;
}
/**
* Adds the layer.
*
* @param geonaItemType the geona item type
* @param layerTitle the layer title
* @param layerName the layer name
* @param wmsLink the wms link
* @param isBase the is base
* @param geonaItemType the geona item type
* @param layerTitle the layer title
* @param layerName the layer name
* @param wmsLink the wms link
* @param isBase the is base
* @param displayInLayerSwitcher the display in layer switcher
* @param UUID the uuid
* @param onTop the on top
* @param UUID the uuid
* @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();
//
@ -395,54 +413,65 @@ public class LayerManager {
// else
// 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);
GeoportalDataViewerServiceAsync.Util.getInstance().parseWmsRequest(wmsLink, layerName, new AsyncCallback<GeoInformationForWMSRequest>() {
GeoportalDataViewerServiceAsync.Util.getInstance().parseWmsRequest(wmsLink, layerName,
new AsyncCallback<GeoInformationForWMSRequest>() {
@Override
public void onFailure(Throwable caught) {
@Override
public void onFailure(Throwable caught) {
Window.alert(caught.getMessage());
}
Window.alert(caught.getMessage());
}
@Override
public void onSuccess(GeoInformationForWMSRequest 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());
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());
LayerObject lo = new LayerObject();
lo.setLayerItem(layerItem);
lo.setItemType(geonaItemType);
layerObjects.add(lo);
olMap.addWMSLayer(layerItem);
}
});
@Override
public void onSuccess(GeoInformationForWMSRequest 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());
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());
LayerObject lo = new LayerObject();
lo.setLayerItem(layerItem);
lo.setItemType(geonaItemType);
layerObjects.add(lo);
olMap.addWMSLayer(layerItem);
}
});
}
/**
* To layer item.
*
* @param layerType the layer type
* @param layerTitle the layer title
* @param layerName the layer name
* @param layerURL the layer URL
* @param mapServerHost the map server host
* @param isExternal the is external
* @param isBase the is base
* @param layerType the layer type
* @param layerTitle the layer title
* @param layerName the layer name
* @param layerURL the layer URL
* @param mapServerHost the map server host
* @param isExternal the is external
* @param isBase the is base
* @param displayInLayerSwitcher the display in layer switcher
* @param styles the styles
* @param wmsLink the wms link
* @param onTop the on top
* @param wmsNotStandardParams the wms not standard params
* @param isNcWms the is nc wms
* @param UUID the uuid
* @param zAxis the z axis
* @param styles the styles
* @param wmsLink the wms link
* @param onTop the on top
* @param wmsNotStandardParams the wms not standard params
* @param isNcWms the is nc wms
* @param UUID the uuid
* @param zAxis the z axis
* @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");
LayerItem layerItem = new LayerItem();
@ -451,7 +480,7 @@ public class LayerManager {
layerItem.setName(layerName);
layerItem.setUrl(layerURL);
layerItem.setMapServerHost(mapServerHost);
//l.setExternal(isExternal);
// l.setExternal(isExternal);
layerItem.setOpacity(1d);
layerItem.setBuffer(2);
layerItem.setWmsLink(wmsLink);
@ -462,53 +491,53 @@ public class LayerManager {
switch (layerType) {
//TODO IMPLEMENT THIS CASE
case RASTER_BASELAYER:
// TODO IMPLEMENT THIS CASE
case RASTER_BASELAYER:
// l.setHasLegend(false);
layerItem.setBaseLayer(true);
layerItem.setTrasparent(false);
layerItem.setClickData(false);
break;
layerItem.setBaseLayer(true);
layerItem.setTrasparent(false);
layerItem.setClickData(false);
break;
case FEATURE_TYPE:
case FEATURE_TYPE:
//CASE FEATURE TYPE
layerItem.setBaseLayer(false);
layerItem.setClickData(true);
layerItem.setTrasparent(true);
break;
// CASE FEATURE TYPE
layerItem.setBaseLayer(false);
layerItem.setClickData(true);
layerItem.setTrasparent(true);
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.setDefaultStyle(styles.get(0));
layerItem.setStyle(styles.get(0));
layerItem.setStyles(styles);
}else{
} else {
String style = URLUtil.getValueOfParameter("styles", wmsLink);
if(style!=null){ //CASE OF STYLE ="";
//TENTATIVE TO GET LEGEND
if (style != null) { // CASE OF STYLE ="";
// TENTATIVE TO GET LEGEND
layerItem.setHasLegend(true);
}
}
GWT.log("Built layer: "+layerItem);
GWT.log("Built layer: " + layerItem);
return layerItem;
}
/**
* Checks if is layer visible.
*
* @param layerItem the layer item
* @return true, if is layer visible
*/
public boolean isLayerVisible(LayerItem layerItem){
public boolean isLayerVisible(LayerItem layerItem) {
return olMap.isLayerVisible(layerItem.getName());
}
/**
* Sets the ol map.
*

View File

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

View File

@ -9,15 +9,15 @@ import com.google.gwt.event.shared.GwtEvent;
/**
* 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 static Type<ShowDetailsEventHandler> TYPE = new Type<ShowDetailsEventHandler>();
private String geonaItemType;
private FeatureRow featureRow;
private Long geonaID;
private String geonaMongoID;
private String itemName;
@ -25,13 +25,13 @@ public class ShowDetailsEvent extends GwtEvent<ShowDetailsEventHandler> {
* Instantiates a new show details event.
*
* @param geonaItemType the geona item type
* @param geonaID the geona ID
* @param geonaMongoID the geona mongo ID
* @param itemName the item name
* @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.geonaID = geonaID;
this.geonaMongoID = geonaMongoID;
this.itemName = itemName;
this.featureRow = featureRow;
@ -47,7 +47,7 @@ public class ShowDetailsEvent extends GwtEvent<ShowDetailsEventHandler> {
*/
public ShowDetailsEvent(GeoNaItemRef gir, String itemName, FeatureRow featureRow) {
this.geonaItemType = gir.getItemType();
this.geonaID = gir.getItemId();
this.geonaMongoID = gir.getItemId();
this.itemName = itemName;
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() {
return geonaID;
public String getGeonaMongoID() {
return geonaMongoID;
}
/**
@ -125,7 +125,7 @@ public class ShowDetailsEvent extends GwtEvent<ShowDetailsEventHandler> {
* @return the geona item ref
*/
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.setEditore(concessione.getEditore());
theConcessione.setFontiFinanziamento(concessione.getFontiFinanziamento());
theConcessione.setId(concessione.getId());
theConcessione.setItemId(concessione.getMongo_id());
theConcessione.setNome(concessione.getNome());
theConcessione.setIntroduzione(concessione.getIntroduzione());

View File

@ -1,12 +1,14 @@
package org.gcube.portlets.user.geoportaldataviewer.server;
import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.statefulMongoConcessioni;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
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.UploadedImage;
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.GeoNaItemRef;
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.server.gis.FeatureParser;
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)
*
* Nov 12, 2020
* Nov 12, 2020
*/
@SuppressWarnings("serial")
public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet implements
GeoportalDataViewerService {
public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet implements GeoportalDataViewerService {
public static final String PRODUCT_ID = "product_id";
/** The Constant LOG. */
private static final Logger LOG = LoggerFactory.getLogger(GeoportalDataViewerServiceImpl.class);
@ -57,7 +61,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
* Parses 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
* @throws Exception the exception
*/
@ -65,17 +69,17 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
public GeoInformationForWMSRequest parseWmsRequest(String wmsRequest, String layerName) throws Exception {
return loadGeoInfoForWmsRequest(wmsRequest, layerName);
}
/**
* Load geo info for wms request.
*
* @param wmsLink the wms link
* @param wmsLink the wms link
* @param layerName the layer name
* @return the geo information for WMS request
* @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 {
WMSUrlValidator validator = new WMSUrlValidator(wmsLink, layerName);
String wmsServiceHost = validator.getWmsServiceHost();
@ -83,30 +87,33 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
layerName = validator.getLayerName();
String versionWms = validator.getValueOfParsedWMSParameter(WmsParameters.VERSION);
String crs = validator.getValueOfParsedWMSParameter(WmsParameters.CRS);
//
//
HashMap<String, String> mapWmsNotStandard = new HashMap<String, String>();
if(validator.getMapWmsNoStandardParams()!=null){
if (validator.getMapWmsNoStandardParams() != null) {
mapWmsNotStandard.putAll(validator.getMapWmsNoStandardParams());
}
//
//
GeoNcWMSMetadataUtility geoGS = new GeoNcWMSMetadataUtility(validWMSRequest, 4000);
//STYLES
LayerStyles layerStyle = geoGS.loadStyles();
Map<String,String> mapNcWmsStyles = layerStyle.getMapNcWmsStyles()==null?new HashMap<String, String>(1):layerStyle.getMapNcWmsStyles();
// STYLES
LayerStyles layerStyle = geoGS.loadStyles();
Map<String, String> mapNcWmsStyles = layerStyle.getMapNcWmsStyles() == null ? new HashMap<String, String>(1)
: layerStyle.getMapNcWmsStyles();
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());
//ZAxis
// ZAxis
LayerZAxis layerZAxis = geoGS.loadZAxis();
//MAP ZAXIS INTO GWT-SERIALIZABLE OBJECT
ZAxis zAxis = layerZAxis!=null?new ZAxis(layerZAxis.getUnits(), layerZAxis.isPositive(), layerZAxis.getValues()):null;
// MAP ZAXIS INTO GWT-SERIALIZABLE OBJECT
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);
}
catch (Exception e) {
String msg = "An error occurred during wms request validation for layer: "+layerName;
LOG.error(msg,e);
return new GeoInformationForWMSRequest(wmsServiceHost, validWMSRequest, layerName, versionWms, crs,
mapWmsNotStandard, styles, styles.isNcWms(), zAxis);
} catch (Exception e) {
String msg = "An error occurred during wms request validation for layer: " + layerName;
LOG.error(msg, e);
throw new Exception(msg);
}
}
@ -114,83 +121,88 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
/**
* Gets the data result.
*
* @param layerObjects the layer objects
* @param mapSrsName the map srs name
* @param selectBBOX the select BBOX
* @param layerObjects the layer objects
* @param mapSrsName the map srs name
* @param selectBBOX the select BBOX
* @param maxWFSFeature the max WFS feature
* @param zoomLevel the zoom level
* @param zoomLevel the zoom level
* @return the data result
*/
@Override
public List<GeoNaSpatialQueryResult> getDataResult(List<LayerObject> layerObjects, String mapSrsName, BoundsMap selectBBOX,
int maxWFSFeature, double zoomLevel) {
public List<GeoNaSpatialQueryResult> getDataResult(List<LayerObject> layerObjects, String mapSrsName,
BoundsMap selectBBOX, int maxWFSFeature, double zoomLevel) {
LOG.info("getDataResult called");
List<GeoNaSpatialQueryResult> listDAO = new ArrayList<GeoNaSpatialQueryResult>(layerObjects.size());
for (LayerObject layerObject : layerObjects) {
GeoNaSpatialQueryResult geoDAO = new GeoNaSpatialQueryResult();
List<FeatureRow> features = FeatureParser.getWFSFeatures(layerObject.getLayerItem(), mapSrsName, selectBBOX, maxWFSFeature);
LOG.debug("For layer name: "+layerObject.getLayerItem().getName() +" got features: "+features);
List<FeatureRow> features = FeatureParser.getWFSFeatures(layerObject.getLayerItem(), mapSrsName, selectBBOX,
maxWFSFeature);
LOG.debug("For layer name: " + layerObject.getLayerItem().getName() + " got features: " + features);
geoDAO.setFeatures(features);
for (FeatureRow fRow : features) {
if(fRow.getMapProperties()!=null) {
if (fRow.getMapProperties() != null) {
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);
try {
long theConcessionID = Long.parseLong(cId);
List<UploadedImageDV> listUI = getUploadedImagesForId("Concessione", theConcessionID, 1);
Map<Long, List<UploadedImageDV>> mapImages = new LinkedHashMap<Long, List<UploadedImageDV>>();
mapImages.put(theConcessionID, listUI);
List<UploadedImageDV> listUI = getUploadedImagesForId("Concessione", cId, 1);
Map<String, List<UploadedImageDV>> mapImages = new LinkedHashMap<String, List<UploadedImageDV>>();
mapImages.put(cId, listUI);
geoDAO.setMapImages(mapImages);
}catch (Exception e) {
LOG.warn("Error on loading uploaded images for concessione: "+cId, e);
} catch (Exception e) {
LOG.warn("Error on loading uploaded images for concessione: " + cId, e);
}
}
}
}
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);
}
LOG.info("returning "+listDAO+" geona data objects");
LOG.info("returning " + listDAO + " geona data objects");
return listDAO;
}
/**
* 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
* @throws Exception the exception
*/
@Override
public List<UploadedImageDV> getUploadedImagesForId(String itemType, Long id, int maxImages) throws Exception{
LOG.info("getUploadedImagesForId [id: "+id+", itemType: "+itemType+"] called");
if(itemType==null)
public List<UploadedImageDV> getUploadedImagesForId(String itemType, String itemId, int maxImages)
throws Exception {
LOG.info("getUploadedImagesForId [itemId: " + itemId + ", itemType: " + itemType + "] called");
if (itemType == null)
throw new Exception("Invalid parameter. The itemType is null");
if(id==null)
throw new Exception("Invalid parameter. The Id is null");
if (itemId == null)
throw new Exception("Invalid parameter. The itemId is null");
List<UploadedImageDV> listUI = null;
try {
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
if(itemType.equalsIgnoreCase("concessione")) {
LOG.info("Trying to get concessione for id "+id);
ConcessioniManager concessioniManager = new ConcessioniManager();
Concessione concessione = concessioniManager.getById(id+"");
if (itemType.equalsIgnoreCase("concessione")) {
LOG.info("Trying to get concessione for id " + itemId);
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
SessionUtil.getCurrentToken(this.getThreadLocalRequest(), true);
ConcessioniManagerI concessioniManager = statefulMongoConcessioni().build();
Concessione concessione = concessioniManager.getById(itemId);
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();
if (images != null) {
listUI = new ArrayList<UploadedImageDV>();
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));
listUI.add(ui);
}
LOG.info("For id "+id+", got "+listUI.size() +" image/s");
LOG.info("For id " + itemId + ", got " + listUI.size() + " image/s");
}
}else
throw new Exception("Concessione with id: "+id +" not available");
} else
throw new Exception("Concessione with id '" + itemId + "' not available");
}
return listUI;
}catch (Exception e) {
String erroMsg = UploadedImage.class.getSimpleName() +" not available for "+Concessione.class.getSimpleName() +" with id "+id;
LOG.error(erroMsg,e);
} catch (Exception e) {
String erroMsg = UploadedImage.class.getSimpleName() + " not available for "
+ Concessione.class.getSimpleName() + " with id " + itemId;
LOG.error(erroMsg, e);
throw new Exception(erroMsg);
}
}
/**
* Gets the concessione for id.
*
* @param id the id
* @param mongoId the mongo id
* @return the concessione for id
* @throws Exception the exception
*/
@Override
public ConcessioneDV getConcessioneForId(Long id) throws Exception{
LOG.info("getConcessioneForId "+id+ " called");
public ConcessioneDV getConcessioneForId(String mongoId) throws Exception {
LOG.info("getConcessioneForId " + mongoId + " called");
ConcessioneDV concessionDV = null;
if(id==null)
throw new Exception("Invalid parameter. The Id is null");
if (mongoId == null)
throw new Exception("Invalid parameter. The itemId is null");
try {
LOG.info("Trying to get record for id "+id);
LOG.info("Trying to get record for id " + mongoId);
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
Concessione concessione = new ConcessioniManager().getById(id+"");
LOG.info("Got concessione for id "+id);
if(concessione !=null) {
SessionUtil.getCurrentToken(this.getThreadLocalRequest(), true);
// Obtain the client
ConcessioniManagerI manager = statefulMongoConcessioni().build();
Concessione concessione = manager.getById(mongoId);
LOG.info("Got concessione for mongoId " + mongoId);
if (concessione != null) {
concessionDV = ConvertToDataViewModel.toConcessione(concessione);
}
if(concessionDV==null)
throw new Exception("Concessione with id: "+id +" not available");
LOG.debug("For id "+id+" returning "+ConcessioneDV.class.getSimpleName()+": "+concessionDV);
if (concessionDV == null)
throw new Exception("Concessione with id '" + mongoId + "' not available");
LOG.debug("For id " + mongoId + " returning " + ConcessioneDV.class.getSimpleName() + ": " + concessionDV);
return concessionDV;
}catch (Exception e) {
String erroMsg = Concessione.class.getSimpleName() +" with id "+id+" not available";
LOG.error(erroMsg,e);
} catch (Exception e) {
String erroMsg = Concessione.class.getSimpleName() + " with id '" + mongoId + "' not available";
LOG.error(erroMsg, e);
throw new Exception(erroMsg);
}
}
/**
* Gets the parameters from URL.
*
* @param theURL the the URL
* @param theURL the the URL
* @param parameters the parameters
* @return a map with couple (paramKey, paramValue)
*/
public Map<String, String> getParametersFromURL(String theURL, List<String> parameters) {
if (theURL == null)
@ -275,30 +290,29 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
String paramValue = URLParserUtil.extractValueOfParameterFromURL(paramKey, theURL);
hashParameters.put(paramKey, paramValue);
}
return hashParameters;
}
/**
* Gets the my login.
*
* @return the my login
*/
@Override
public String getMyLogin(){
public String getMyLogin() {
try {
GCubeUser user = SessionUtil.getCurrentUser(this.getThreadLocalRequest());
if(user==null)
if (user == null)
return null;
return user.getUsername();
}catch (Exception e) {
} catch (Exception e) {
LOG.warn("Error on getting the login, am I out of portal? Returning null");
return null;
}
}
/**
* Gets the layer for type.
*
@ -307,31 +321,31 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
* @throws Exception the exception
*/
@Override
public GeoInformationForWMSRequest getLayerForType(String layerType) throws Exception{
LOG.info("Called getLayerForType for:"+layerType);
if(layerType==null || layerType.isEmpty())
public GeoInformationForWMSRequest getLayerForType(String layerType) throws Exception {
LOG.info("Called getLayerForType for:" + layerType);
if (layerType == null || layerType.isEmpty())
throw new Exception("The input parameter layerType is null or empty");
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
GeoNaDataViewerProfileReader gdvp = new GeoNaDataViewerProfileReader("geoportal-data-viewer-app");
GeoNaDataViewerProfile profile = gdvp.readProfileFromInfrastrucure();
LOG.info("Read profile: "+profile);
LOG.info("Read profile: " + profile);
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);
if(layer==null || layer.getWmsLink()==null)
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 == null || layer.getWmsLink() == null)
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");
return parseWmsRequest(layer.getWmsLink(), null);
}
/**
* Gets the geo na data view profile.
@ -340,17 +354,16 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
* @throws Exception the exception
*/
@Override
public GeoNaDataViewerProfile getGeoNaDataViewProfile() throws Exception{
public GeoNaDataViewerProfile getGeoNaDataViewProfile() throws Exception {
LOG.info("getGeoNaDataViewProfile called");
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
GeoportalCommon gc = new GeoportalCommon();
org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile profile = gc.getGeoNaDataViewProfile(null);
LOG.info("Returning profile: "+profile);
LOG.info("Returning profile: " + profile);
return profile;
}
@Override
public GeoNaItemRef getPublicLinksFor(GeoNaItemRef item) throws Exception {
LOG.info("getPublicLinksFor called for: " + item);
@ -359,25 +372,26 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
if (item == 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");
if(item.getItemType()==null)
if (item.getItemType() == null)
throw new Exception("Bad request, the item type is null");
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
GeoportalCommon gc = new GeoportalCommon();
return gc.getPublicLinksFor(item);
} catch (Exception 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 {
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.HttpSession;
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.urlshortener.UrlShortener;
@ -20,19 +21,18 @@ import org.slf4j.LoggerFactory;
import com.liferay.portal.service.UserLocalServiceUtil;
/**
* The Class SessionUtil.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Oct 20, 2020
* Oct 20, 2020
*/
public class SessionUtil {
/** The log. */
private static Logger LOG = LoggerFactory.getLogger(SessionUtil.class);
public static final String URL_SHORTENER_SERVICE = "URL_SHORTENER_SERVICE";
/**
@ -44,20 +44,18 @@ public class SessionUtil {
try {
UserLocalServiceUtil.getService();
return true;
}catch (Exception ex) {
} catch (Exception ex) {
LOG.warn("Development Mode ON");
return false;
}
}
/**
* Checks if is session expired.
*
* @param httpServletRequest
* the http servlet request
* @param httpServletRequest the http servlet request
* @return true, if is session expired
* @throws Exception
* the exception
* @throws Exception the exception
*/
public static boolean isSessionExpired(HttpServletRequest httpServletRequest) throws Exception {
LOG.trace("workspace session validating...");
@ -70,9 +68,9 @@ public class SessionUtil {
* @param request the request
* @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!");
PortalContext pContext = PortalContext.getConfiguration();
@ -84,36 +82,60 @@ public class SessionUtil {
/**
* Retrieve the current scope by using the portal manager.
*
* @param request the request
* @param request the request
* @param setInThread the set in thread
* @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!");
PortalContext pContext = PortalContext.getConfiguration();
String context = pContext.getCurrentScope(request);
LOG.debug("Returning context " + context);
if(context != null && setInThread)
if (context != null && setInThread)
ScopeProvider.instance.set(context);
LOG.debug("Returning context " + 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.
*
* @param scope the scope
* @return the group from scope
* @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!!");
GroupManager gm = new LiferayGroupManager();
@ -122,7 +144,6 @@ public class SessionUtil {
}
/**
* Gets the url shortener.
*
@ -142,7 +163,7 @@ public class SessionUtil {
}
} 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;

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.products.model.UploadedImageDV;
/**
* 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 {
@ -23,8 +24,8 @@ public class GeoNaSpatialQueryResult implements Serializable {
private static final long serialVersionUID = 3513120677727206958L;
private List<FeatureRow> features;
private LayerObject sourceLayerObject;
// Map with couple (id concessione, list of uplaoded Images for the concessione)
private Map<Long, List<UploadedImageDV>> mapImages = null;
// Map with couple (mongoId concessione, list of uplaoded Images for the concessione)
private Map<String, List<UploadedImageDV>> mapImages = null;
/**
* Instantiates a new geo na data object.
@ -74,7 +75,7 @@ public class GeoNaSpatialQueryResult implements Serializable {
*
* @return the map images
*/
public Map<Long, List<UploadedImageDV>> getMapImages() {
public Map<String, List<UploadedImageDV>> getMapImages() {
return mapImages;
}
@ -83,10 +84,15 @@ public class GeoNaSpatialQueryResult implements Serializable {
*
* @param mapImages the map images
*/
public void setMapImages(Map<Long, List<UploadedImageDV>> mapImages) {
public void setMapImages(Map<String, List<UploadedImageDV>> mapImages) {
this.mapImages = mapImages;
}
/**
* To string.
*
* @return the string
*/
@Override
public String toString() {
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 {
/**
*
*/
private static final long serialVersionUID = 2913726613820175679L;
/** The id. */
private Long id;
/** The mongo id **/
private String itemId;
/** The record type. */
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() {
return id;
public String getItemId() {
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) {
this.id = id;
public void setItemId(String itemId) {
this.itemId = itemId;
}
/**
@ -262,8 +261,8 @@ public abstract class RecordDV implements Serializable, IsSerializable {
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("RecordDV [id=");
builder.append(id);
builder.append("RecordDV [itemId=");
builder.append(itemId);
builder.append(", recordType=");
builder.append(recordType);
builder.append(", version=");
@ -288,4 +287,6 @@ public abstract class RecordDV implements Serializable, IsSerializable {
return builder.toString();
}
}