From e9fff02e291dd2e6bc5cfde64ae854ca975a1557 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 11 Dec 2020 09:51:20 +0100 Subject: [PATCH] added check to skip coordinates of centroid on null --- .classpath | 8 ++++---- .settings/com.gwtplugins.gdt.eclipse.core.prefs | 2 +- .../client/GeoportalDataViewer.java | 15 ++++++++++----- .../client/GeoportalDataViewerConstants.java | 6 +++--- .../products/concessioni/ConcessioneView.java | 17 +++++++++++------ .../client/ui/util/CustomFlexTable.java | 11 +++++++++++ .../client/util/StringUtil.java | 1 - src/test/resources/.gitignore | 9 +++++++++ 8 files changed, 49 insertions(+), 20 deletions(-) diff --git a/.classpath b/.classpath index 2fe0d3a..2ac0cfd 100644 --- a/.classpath +++ b/.classpath @@ -1,12 +1,12 @@ - + - + @@ -35,6 +35,6 @@ - - + + diff --git a/.settings/com.gwtplugins.gdt.eclipse.core.prefs b/.settings/com.gwtplugins.gdt.eclipse.core.prefs index e75d335..96091f5 100644 --- a/.settings/com.gwtplugins.gdt.eclipse.core.prefs +++ b/.settings/com.gwtplugins.gdt.eclipse.core.prefs @@ -1,4 +1,4 @@ eclipse.preferences.version=1 -lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-viewer-app/target/geoportal-data-viewer-app-1.0.0-SNAPSHOT +lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-viewer-app/target/geoportal-data-viewer-app-1.0.0 warSrcDir=src/main/webapp warSrcDirIsOutput=false diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java index 02066d1..118963d 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java @@ -271,7 +271,7 @@ public class GeoportalDataViewer implements EntryPoint { } if(attempt>MAX_RETRY) { - GWT.log("cancelled timer"); + GWT.log("MAX_RETRY reached, cancelled timer"); this.cancel(); } @@ -317,10 +317,15 @@ public class GeoportalDataViewer implements EntryPoint { ConcessioneDV concessioneDV = (ConcessioneDV) record; Double x = concessioneDV.getCentroidLong(); Double y = concessioneDV.getCentroidLat(); - Coordinate transfCoord = MapUtils.transformCoordiante(new Coordinate(x, y), GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857); - GeoQuery select = olMapMng.toDataPointQuery(transfCoord); - //GeoportalDataViewerConstants.print("fireEvent QueryDataEvent"); - layerManager.getLayerManagerBus().fireEvent(new QueryDataEvent(select, transfCoord, record.getId(), true)); + GWT.log("X: "+x +", Y:"+y); + if(x!=null && y!=null) { + Coordinate transfCoord = MapUtils.transformCoordiante(new Coordinate(x, y), GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857); + GeoQuery select = olMapMng.toDataPointQuery(transfCoord); + //GeoportalDataViewerConstants.print("fireEvent QueryDataEvent"); + layerManager.getLayerManagerBus().fireEvent(new QueryDataEvent(select, transfCoord, record.getId(), true)); + }else { + GeoportalDataViewerConstants.printJs("I cannot select the point one or both coordiantes are null. X: "+x +", Y:"+y); + } } } } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java index 36df30a..9e83645 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java @@ -52,9 +52,9 @@ public class GeoportalDataViewerConstants { * * @param msg the msg */ -// public static native void print(String msg)/*-{ -// console.log("js console: "+msg); -// }-*/; + public static native void printJs(String msg)/*-{ + console.log("js console: "+msg); + }-*/; } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java index 33c88aa..2565782 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java @@ -301,12 +301,17 @@ public class ConcessioneView extends Composite { Coordinate centerCoordinate = OLFactory.createCoordinate(GeoportalDataViewerConstants.ITALY_CENTER_LONG, GeoportalDataViewerConstants.ITALY_CENTER_LAT); Coordinate transformedCenterCoordinate = MapUtils.transformCoordiante(centerCoordinate, GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857); MapView mapView = new MapView(transformedCenterCoordinate, GeoportalDataViewerConstants.LIGHT_MAP_ITALY_FIT_ZOOM_ON); - Coordinate coord = new Coordinate(concessioneDV.getCentroidLong(), concessioneDV.getCentroidLat()); - Coordinate transfCoord = MapUtils.transformCoordiante(coord, GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857); - //Coordinate invertedCoordinate = MapUtils.reverseCoordinate(coord); - boolean authenticatedUser = myLogin!=null?true:false; - mapView.addMarker(transfCoord, authenticatedUser); - mapViewPanel.add(mapView); + + if(concessioneDV!=null && concessioneDV.getCentroidLat()!=null && concessioneDV.getCentroidLong()!=null) { + Coordinate coord = new Coordinate(concessioneDV.getCentroidLong(), concessioneDV.getCentroidLat()); + Coordinate transfCoord = MapUtils.transformCoordiante(coord, GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857); + //Coordinate invertedCoordinate = MapUtils.reverseCoordinate(coord); + boolean authenticatedUser = myLogin!=null?true:false; + mapView.addMarker(transfCoord, authenticatedUser); + mapViewPanel.add(mapView); + }else if(concessioneDV!=null){ + GeoportalDataViewerConstants.printJs("I cannot add centroid as maker one or both coordinates are null. Lat: "+concessioneDV.getCentroidLong() +", Long:"+concessioneDV.getCentroidLat()); + } } private void addUploadedImages() { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/util/CustomFlexTable.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/util/CustomFlexTable.java index cc09c81..46f1d65 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/util/CustomFlexTable.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/util/CustomFlexTable.java @@ -36,6 +36,10 @@ public class CustomFlexTable extends FlexTable { */ public void addNextKeyValues(String key, List listValues, String separator) { GWT.log("adding key "+key +", values: "+listValues); + + if(key==null) + return; + Label keyLabel = new Label(key); int row = getRowCount() + 1; setWidget(row, 0, keyLabel); @@ -46,6 +50,9 @@ public class CustomFlexTable extends FlexTable { String valuesAsString = ""; for (String value : listValues) { String theValue = value; + if(theValue==null) + theValue = ""; + if(theValue.startsWith("http://") || (theValue.startsWith("https://"))){ theValue = ""+value+""; } @@ -63,6 +70,10 @@ public class CustomFlexTable extends FlexTable { * @param value the value */ public void addNextKeyValue(String key, String value) { + + if(key==null) + return; + Label keyLabel = new Label(key); // keyLabel.getElement().getStyle().setMarginRight(5, Unit.PX); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/util/StringUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/util/StringUtil.java index 8bbf883..8ed3a77 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/util/StringUtil.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/util/StringUtil.java @@ -6,7 +6,6 @@ package org.gcube.portlets.user.geoportaldataviewer.client.util; import java.util.Date; import com.google.gwt.i18n.client.DateTimeFormat; -import com.google.gwt.user.client.Window; /** * The Class StringUtil. diff --git a/src/test/resources/.gitignore b/src/test/resources/.gitignore index 42efabb..175eaa7 100644 --- a/src/test/resources/.gitignore +++ b/src/test/resources/.gitignore @@ -7,3 +7,12 @@ /d4science.research-infrastructures.eu.gcubekey /devVRE.gcubekey /gCubeApps.gcubekey +/CNR.it.gcubekey +/D4OS.gcubekey +/D4Research.gcubekey +/FARM.gcubekey +/ISTI.gcubekey +/OpenAIRE.gcubekey +/ParthenosVO.gcubekey +/SmartArea.gcubekey +/SoBigData.gcubekey