From 8564db407923f90bc1f1f6110f798fb7b5d627d1 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Tue, 24 Nov 2020 12:26:38 +0100 Subject: [PATCH] added console.log to debug --- .../client/GeoportalDataViewerConstants.java | 24 ++ .../client/LayerManager.java | 305 +++++++++--------- .../client/gis/OpenLayerOSM.java | 1 + .../client/ui/GeonaDataViewMainPanel.ui.xml | 2 +- .../server/ConvertToDataViewModel.java | 14 +- 5 files changed, 192 insertions(+), 154 deletions(-) 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 aa15343..4a2c5ff 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 @@ -2,6 +2,13 @@ package org.gcube.portlets.user.geoportaldataviewer.client; import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayersMapParameters; +/** + * The Class GeoportalDataViewerConstants. + * + * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) + * + * Nov 24, 2020 + */ public class GeoportalDataViewerConstants { public static final String EPSG_4326 = "EPSG:4326"; @@ -18,6 +25,13 @@ public class GeoportalDataViewerConstants { public static final String GET_ZOOM = OpenLayersMapParameters.OL_MAP_PARAM.zoom.name(); public static final String GET_CENTER_MAP_TO_LONG_LAT = OpenLayersMapParameters.OL_MAP_PARAM.centermap.name(); + /** + * The Enum LayerType. + * + * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) + * + * Nov 24, 2020 + */ public enum LayerType {RASTER_BASELAYER, FEATURE_TYPE}; public static final int MAX_WFS_FEATURES = 3; // zero for no limit @@ -31,6 +45,16 @@ public class GeoportalDataViewerConstants { public static final int LIGHT_MAP_ITALY_FIT_ZOOM_ON = 5; public static final int MAP_ITALY_FIT_ZOOM_ON = 6; + + + /** + * Prints the. + * + * @param msg the msg + */ + public static native void print(String msg)/*-{ + console.log(msg); + }-*/; } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/LayerManager.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/LayerManager.java index 1c67c32..098c635 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/LayerManager.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/LayerManager.java @@ -137,175 +137,188 @@ public class LayerManager { @Override public void onFailure(Throwable caught) { + GeoportalDataViewerConstants.print("on Failure DataResult: "+caught.getMessage()); } @Override public void onSuccess(List listGeonaDataObjects) { - GWT.log("GeoNaDataObject's: "+listGeonaDataObjects); + try { - 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 features = geoNaDataObject.getFeatures(); - - //USING ONLY THE FIRST FEATURE IN THE LIST - if(features!=null && features.size()>0) { - feature = features.get(0); - Map> entries = feature.getMapProperties(); - - for (String key : entries.keySet()) { - String theValue = entries.get(key).get(0); - if(key.equalsIgnoreCase("nome")) { - flex.setHTML(0, 0, new HTML(theValue).toString()); - } - else if(key.equalsIgnoreCase("descrizione")) { - String reducedValue = theValue; - try { - reducedValue = StringUtil.ellipsize(theValue, 300); - GWT.log("reduced: "+reducedValue); - } catch (Exception e) { - GWT.log("error: "+e.getMessage()); - } - flex.setText(1, 0, reducedValue); - }else if(key.equalsIgnoreCase("date_scavo")) { - flex.setHTML(2, 0, new HTML(""+theValue).toString()+""); - } - } - - /*Scheduler.get().scheduleDeferred(new ScheduledCommand() { + 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 features = geoNaDataObject.getFeatures(); + + //USING ONLY THE FIRST FEATURE IN THE LIST + if(features!=null && features.size()>0) { + feature = features.get(0); + Map> entries = feature.getMapProperties(); - @Override - public void execute() { - List listConcessioni = entries.get("product_id"); - if(listConcessioni!=null && listConcessioni.size()>0) { - String concessioneId = listConcessioni.get(0); + for (String key : entries.keySet()) { + String theValue = entries.get(key).get(0); + if(key.equalsIgnoreCase("nome")) { + flex.setHTML(0, 0, new HTML(theValue).toString()); + } + else if(key.equalsIgnoreCase("descrizione")) { + String reducedValue = theValue; try { - Long theConcessioneId = Long.parseLong(concessioneId); - GeoportalDataViewerServiceAsync.Util.getInstance().getUploadedImagesForId("Concessione", theConcessioneId, 1, new AsyncCallback>() { - - @Override - public void onFailure(Throwable caught) { - // TODO Auto-generated method stub - - } - - @Override - public void onSuccess(List result) { - GWT.log("Loaded images: "+result); - - for (UploadedImageDV img : result) { - if(img.getListWsContent()!=null) { - WorkspaceContentDV wsContent = img.getListWsContent().get(img.getListWsContent().size()-1); - String theImgHTML = ""; - GWT.log("theImgHTML: "+theImgHTML); - flex.setHTML(flex.getRowCount()+1, 0, theImgHTML); - } + reducedValue = StringUtil.ellipsize(theValue, 300); + GWT.log("reduced: "+reducedValue); + } catch (Exception e) { + GWT.log("error: "+e.getMessage()); + } + flex.setText(1, 0, reducedValue); + }else if(key.equalsIgnoreCase("date_scavo")) { + flex.setHTML(2, 0, new HTML(""+theValue+"").toString()); + } + } + + /*Scheduler.get().scheduleDeferred(new ScheduledCommand() { + + @Override + public void execute() { + List listConcessioni = entries.get("product_id"); + if(listConcessioni!=null && listConcessioni.size()>0) { + String concessioneId = listConcessioni.get(0); + try { + Long theConcessioneId = Long.parseLong(concessioneId); + GeoportalDataViewerServiceAsync.Util.getInstance().getUploadedImagesForId("Concessione", theConcessioneId, 1, new AsyncCallback>() { + + @Override + public void onFailure(Throwable caught) { + // TODO Auto-generated method stub } - - } - }); - }catch (Exception e) { - // TODO: handle exception + + @Override + public void onSuccess(List result) { + GWT.log("Loaded images: "+result); + + for (UploadedImageDV img : result) { + if(img.getListWsContent()!=null) { + WorkspaceContentDV wsContent = img.getListWsContent().get(img.getListWsContent().size()-1); + String theImgHTML = ""; + GWT.log("theImgHTML: "+theImgHTML); + flex.setHTML(flex.getRowCount()+1, 0, theImgHTML); + } + + } + + } + }); + }catch (Exception e) { + // TODO: handle exception + } + } + + } + });*/ + + + if(geoNaDataObject.getMapImages()!=null) { + for (Long key : geoNaDataObject.getMapImages().keySet()) { + List listUI = geoNaDataObject.getMapImages().get(key); + GWT.log("Adding images: "+listUI); + if(listUI!=null) { + UploadedImageDV img = listUI.get(0); + if(img.getListWsContent()!=null) { + WorkspaceContentDV wsContent = img.getListWsContent().get(img.getListWsContent().size()-1); + String theImgHTML = ""; + 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(geoNaDataObject.getMapImages()!=null) { - for (Long key : geoNaDataObject.getMapImages().keySet()) { - List listUI = geoNaDataObject.getMapImages().get(key); - GWT.log("Adding images: "+listUI); - if(listUI!=null) { - UploadedImageDV img = listUI.get(0); - if(img.getListWsContent()!=null) { - WorkspaceContentDV wsContent = img.getListWsContent().get(img.getListWsContent().size()-1); - String theImgHTML = ""; - GWT.log("theImgHTML: "+theImgHTML); - flex.setHTML(flex.getRowCount()+1, 0, theImgHTML); - } + 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()); } } - featureFound = true; - //break; //Only the first one - } - - if(feature==null) - return; - - GWT.log("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() { + if(centerTo==null) + centerTo = queryEvent.getoLCoordinate(); + olMap.showPopup(vpPanel.toString(), centerTo); + + Scheduler.get().scheduleDeferred(new ScheduledCommand() { + @Override - public void onClick(ClickEvent event) { - ShowDetailsEvent toEvent = parseGeonaReferences(geoNaDataObject.getSourceLayerObject().getItemType(), theFeature); - applicationBus.fireEvent(toEvent); - + 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); + } + } + }); } }); } - - PointsPath path = feature.getGeometry().getPath(); - GWT.log("Points Path: "+path); - Coordinate centerTo = null; - 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()); - } - - if(centerTo==null) - centerTo = queryEvent.getoLCoordinate(); - - 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); - } - } - }); - } - }); + }catch (Exception e) { + GeoportalDataViewerConstants.print(e.getMessage()); } } }); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java index 1136c91..848da58 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java @@ -215,6 +215,7 @@ public abstract class OpenLayerOSM { public void showPopup(String html, Coordinate coordinate) { GWT.log("Showing popup on: "+coordinate); + GeoportalDataViewerConstants.print("Showing popup on: "+coordinate); Element elPopup = DOM.getElementById("popup"); elPopup.getStyle().setVisibility(Visibility.VISIBLE); if(popupOverlay==null) { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml index 35d0ae0..bf1b0d5 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml @@ -18,7 +18,7 @@ - Map Interaction + Map Interactions Use Shift+Drag to draw an extent for zoom in the Map Click on the Points shown on the Map to view their features diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConvertToDataViewModel.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConvertToDataViewModel.java index 0910f0b..b6949d6 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConvertToDataViewModel.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/ConvertToDataViewModel.java @@ -81,15 +81,15 @@ public class ConvertToDataViewModel { theConcessione.setLastUpdateUser(toUser(concessione.getLastUpdateUser())); theConcessione.setLicenzaID(concessione.getLicenzaID()); theConcessione.setNome(concessione.getNome()); - theConcessione.setParoleChiaveICCD(concessione.getParoleChiaveICCD()); - theConcessione.setParoleChiaveLibere(concessione.getParoleChiaveLibere()); + theConcessione.setParoleChiaveICCD(toListString(concessione.getParoleChiaveICCD())); + theConcessione.setParoleChiaveLibere(toListString(concessione.getParoleChiaveLibere())); theConcessione.setResponsabile(concessione.getResponsabile()); - theConcessione.setRisorseCorrelate(concessione.getRisorseCorrelate()); + theConcessione.setRisorseCorrelate(toListString(concessione.getRisorseCorrelate())); theConcessione.setSoggetto(concessione.getSoggetto()); theConcessione.setTitolareCopyright(concessione.getTitolareCopyright()); theConcessione.setTitolareLicenza(concessione.getTitolareLicenza()); - theConcessione.setTitolari(concessione.getTitolari()); + theConcessione.setTitolari(toListString(concessione.getTitolari())); theConcessione.setVersion(concessione.getVersion()); theConcessione.setRecordType(concessione.getRecordType().name()); @@ -199,7 +199,7 @@ public class ConvertToDataViewModel { theRelazioneDiScavo.setLicenseID(relazioneScavo.getLicenseID()); theRelazioneDiScavo.setPolicy(toPolicy(relazioneScavo.getPolicy())); //theRelazioneDiScavo.setRecord(recordDV); - theRelazioneDiScavo.setResponsabili(relazioneScavo.getResponsabili()); + theRelazioneDiScavo.setResponsabili(toListString(relazioneScavo.getResponsabili())); theRelazioneDiScavo.setSoggetto(relazioneScavo.getSoggetto()); theRelazioneDiScavo.setTitolo(relazioneScavo.getTitolo()); @@ -227,7 +227,7 @@ public class ConvertToDataViewModel { theUploadedImageDV.setLicenseID(uploadedImage.getLicenseID()); theUploadedImageDV.setPolicy(toPolicy(uploadedImage.getPolicy())); //theUploadedImageDV.setRecord(recordDV); - theUploadedImageDV.setResponsabili(uploadedImage.getResponsabili()); + theUploadedImageDV.setResponsabili(toListString(uploadedImage.getResponsabili())); theUploadedImageDV.setSoggetto(uploadedImage.getSoggetto()); theUploadedImageDV.setTitolo(uploadedImage.getTitolo()); @@ -284,7 +284,7 @@ public class ConvertToDataViewModel { theLayerConessione.setLayerName(layerConcessione.getLayerName()); theLayerConessione.setLayerID(layerConcessione.getLayerID()); theLayerConessione.setLayerUUID(layerConcessione.getLayerUUID()); - theLayerConessione.setAuthors(layerConcessione.getAuthors()); + theLayerConessione.setAuthors(toListString(layerConcessione.getAuthors())); BoundsMap bounds = toBoundMap(layerConcessione.getBbox()); theLayerConessione.setBbox(bounds); theLayerConessione.setCreationTime(toDateString(layerConcessione.getCreationTime()));