From 2536912982f89fc2c6c9691739711e9faf8e9d6d Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 13 Nov 2020 17:14:08 +0100 Subject: [PATCH] Added init stage with git and gid parameters --- .../client/GeoportalDataViewer.java | 97 +++++++------------ .../client/LayerManager.java | 2 + .../client/events/ShowDetailsEvent.java | 2 +- 3 files changed, 36 insertions(+), 65 deletions(-) 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 71694af..e24da4c 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 @@ -55,9 +55,9 @@ public class GeoportalDataViewer implements EntryPoint { private String paramWmsRequest; /** The param UUID. */ - private String paramUUID; + //private String paramUUID; - private String geonaItemType; + private String paramGeonaItemType; /** The param layer title. */ private String paramLayerTitle; @@ -67,7 +67,7 @@ public class GeoportalDataViewer implements EntryPoint { /** The layer manager. */ private LayerManager layerManager = new LayerManager(eventBus); - private String geonaItemID; + private String paramGeonaItemID; private GeoNaDataViewerProfile geonaDataViewerProfile; @@ -109,16 +109,23 @@ public class GeoportalDataViewer implements EntryPoint { // }); paramWmsRequest = Window.Location.getParameter(GeoportalDataViewerConstants.GET_WMS_PARAMETER); - geonaItemType = Window.Location.getParameter(GeoportalDataViewerConstants.GET_GEONA_ITEM_TYPE); - paramUUID = Window.Location.getParameter(GeoportalDataViewerConstants.GET_UUID_PARAMETER); - geonaItemID = Window.Location.getParameter(GeoportalDataViewerConstants.GET_GEONA_ITEM_ID); + paramGeonaItemType = Window.Location.getParameter(GeoportalDataViewerConstants.GET_GEONA_ITEM_TYPE); + //paramUUID = Window.Location.getParameter(GeoportalDataViewerConstants.GET_UUID_PARAMETER); + paramGeonaItemID = Window.Location.getParameter(GeoportalDataViewerConstants.GET_GEONA_ITEM_ID); paramLayerTitle = Window.Location.getParameter(GeoportalDataViewerConstants.GET_LAYER_TITLE); GWT.log(GeoportalDataViewerConstants.GET_WMS_PARAMETER + " = " + paramWmsRequest); - GWT.log(GeoportalDataViewerConstants.GET_GEONA_ITEM_TYPE + " = " + geonaItemType); - GWT.log(GeoportalDataViewerConstants.GET_GEONA_ITEM_ID + " = " + geonaItemID); - GWT.log(GeoportalDataViewerConstants.GET_UUID_PARAMETER + " = " + paramUUID); + GWT.log(GeoportalDataViewerConstants.GET_GEONA_ITEM_TYPE + " = " + paramGeonaItemType); + GWT.log(GeoportalDataViewerConstants.GET_GEONA_ITEM_ID + " = " + paramGeonaItemID); + //GWT.log(GeoportalDataViewerConstants.GET_UUID_PARAMETER + " = " + paramUUID); 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"); + } Scheduler.get().scheduleDeferred(new ScheduledCommand() { @@ -137,20 +144,31 @@ public class GeoportalDataViewer implements EntryPoint { geonaDataViewerProfile = profile; GWT.log("Profile: "+geonaDataViewerProfile); Iterator it; - if(geonaItemType==null) { + String theItemType = paramGeonaItemType; + if(theItemType==null) { it = geonaDataViewerProfile.getMapLayers().keySet().iterator(); it.hasNext(); - geonaItemType= it.next(); + theItemType= it.next(); } - LayerItem layerItem = geonaDataViewerProfile.getMapLayers().get(geonaItemType); + LayerItem layerItem = geonaDataViewerProfile.getMapLayers().get(theItemType); if(layerItem==null) { - Window.alert("Not detected any layer with type: "+geonaItemType); + Window.alert("Not detected any layer with type: "+theItemType); return; } + GWT.log("The layerItem is: "+layerItem); - layerManager.addLayer(geonaItemType, null, null, layerItem.getWmsLink(), false, false, null, true); + layerManager.addLayer(theItemType, null, null, layerItem.getWmsLink(), false, false, null, true); + + if(paramGeonaItemID!=null) { + if(paramGeonaItemType==null) { + Window.alert("Missing parameter "+GeoportalDataViewerConstants.GET_GEONA_ITEM_TYPE +" (GeoNa Data Type) where to search the item id: "+paramGeonaItemID); + return; + } + eventBus.fireEvent(new ShowDetailsEvent(paramGeonaItemType, new Long(paramGeonaItemID), null, null)); + } + } }); } @@ -163,56 +181,7 @@ public class GeoportalDataViewer implements EntryPoint { * Bind events. */ private void bindEvents() { -// eventBus.addHandler(ShowDetailsEvent.TYPE, new ShowDetailsEventHandler() { -// -// @Override -// public void onShowDetails(ShowDetailsEvent showDetailsEvent) { -// GWT.log("Fired event: "+showDetailsEvent); -// FeatureRow fRow = showDetailsEvent.getFeatureRow(); -// if(fRow!=null) { -// if(showDetailsEvent.getProductType().equals(ProductType.CONCESSIONE)) { -// List productIds = fRow.getMapProperties().get("product_id"); -// if(productIds!=null && productIds.size()>0) { -// long id = Long.parseLong(productIds.get(0)); -// String tabName = "Dettagli Prodotto"; -// List listName = fRow.getMapProperties().get("nome"); -// if(listName!=null && listName.size()>0) { -// tabName = listName.get(0); -// } -// -// boolean found = mainPanel.selectTabForProductId(id); -// GWT.log("Product with id: "+id+" found? "+found); -// if(!found) { -// -// final Tab theTab = mainPanel.addAsTab(tabName, true, null); -// GeoportalDataViewerServiceAsync.Util.getInstance().getConcessioneForId(id, new AsyncCallback() { -// -// @Override -// public void onFailure(Throwable caught) { -// Window.alert(caught.getMessage()); -// theTab.clear(); -// theTab.setIcon(IconType.WARNING_SIGN); -// theTab.add(new HTML(caught.getMessage())); -// -// } -// -// @Override -// public void onSuccess(ConcessioneDV result) { -// GWT.log("Showing: "+result); -// mainPanel.renderProductIntoTab(theTab, result); -// -// } -// }); -// }else -// Window.alert("No product id found"); -// } -// -// } -// } -// -// } -// }); - + eventBus.addHandler(ShowDetailsEvent.TYPE, new ShowDetailsEventHandler() { @Override 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 4c1ca20..211874e 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 @@ -145,6 +145,8 @@ public class LayerManager { flex.getElement().addClassName("popup-table"); boolean featureFound = false; FeatureRow feature = null; + + //TODO SWTCH FOR EARCH ITEM TYPE for (GeoNaDataObject geoNaDataObject : listGeonaDataObjects) { List features = geoNaDataObject.getFeatures(); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/ShowDetailsEvent.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/ShowDetailsEvent.java index e231c23..bbceac4 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/ShowDetailsEvent.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/ShowDetailsEvent.java @@ -28,7 +28,7 @@ public class ShowDetailsEvent extends GwtEvent { * @param itemName the item name * @param featureRow the feature row */ - public ShowDetailsEvent(String geonaItemType, long geonaID, String itemName, FeatureRow featureRow) { + public ShowDetailsEvent(String geonaItemType, Long geonaID, String itemName, FeatureRow featureRow) { this.geonaItemType = geonaItemType; this.geonaID = geonaID; this.itemName = itemName;