added console.log to debug

This commit is contained in:
Francesco Mangiacrapa 2020-11-24 12:26:38 +01:00
parent 609f38678e
commit 8564db4079
5 changed files with 192 additions and 154 deletions

View File

@ -2,6 +2,13 @@ package org.gcube.portlets.user.geoportaldataviewer.client;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayersMapParameters; 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 class GeoportalDataViewerConstants {
public static final String EPSG_4326 = "EPSG:4326"; 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_ZOOM = OpenLayersMapParameters.OL_MAP_PARAM.zoom.name();
public static final String GET_CENTER_MAP_TO_LONG_LAT = OpenLayersMapParameters.OL_MAP_PARAM.centermap.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 enum LayerType {RASTER_BASELAYER, FEATURE_TYPE};
public static final int MAX_WFS_FEATURES = 3; // zero for no limit 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 LIGHT_MAP_ITALY_FIT_ZOOM_ON = 5;
public static final int MAP_ITALY_FIT_ZOOM_ON = 6; 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);
}-*/;
} }

View File

@ -137,175 +137,188 @@ public class LayerManager {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
GeoportalDataViewerConstants.print("on Failure DataResult: "+caught.getMessage());
} }
@Override @Override
public void onSuccess(List<GeoNaSpatialQueryResult> listGeonaDataObjects) { public void onSuccess(List<GeoNaSpatialQueryResult> listGeonaDataObjects) {
GWT.log("GeoNaDataObject's: "+listGeonaDataObjects); try {
if(listGeonaDataObjects==null || listGeonaDataObjects.isEmpty()) GWT.log("GeoNaDataObject's: "+listGeonaDataObjects);
return; GeoportalDataViewerConstants.print("GeoNaDataObject's: "+listGeonaDataObjects);
FlexTable flex = new FlexTable(); if(listGeonaDataObjects==null || listGeonaDataObjects.isEmpty())
flex.setCellPadding(1); return;
flex.setCellSpacing(1);
flex.getElement().addClassName("popup-table"); FlexTable flex = new FlexTable();
boolean featureFound = false; flex.setCellPadding(1);
FeatureRow feature = null; flex.setCellSpacing(1);
flex.getElement().addClassName("popup-table");
//TODO SWTCH FOR EARCH ITEM TYPE boolean featureFound = false;
for (GeoNaSpatialQueryResult geoNaDataObject : listGeonaDataObjects) { FeatureRow feature = null;
List<FeatureRow> features = geoNaDataObject.getFeatures();
//TODO SWTCH FOR EARCH ITEM TYPE
//USING ONLY THE FIRST FEATURE IN THE LIST for (GeoNaSpatialQueryResult geoNaDataObject : listGeonaDataObjects) {
if(features!=null && features.size()>0) { List<FeatureRow> features = geoNaDataObject.getFeatures();
feature = features.get(0);
Map<String, List<String>> entries = feature.getMapProperties(); //USING ONLY THE FIRST FEATURE IN THE LIST
if(features!=null && features.size()>0) {
for (String key : entries.keySet()) { feature = features.get(0);
String theValue = entries.get(key).get(0); Map<String, List<String>> entries = feature.getMapProperties();
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("<code>"+theValue).toString()+"</code>");
}
}
/*Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override for (String key : entries.keySet()) {
public void execute() { String theValue = entries.get(key).get(0);
List<String> listConcessioni = entries.get("product_id"); if(key.equalsIgnoreCase("nome")) {
if(listConcessioni!=null && listConcessioni.size()>0) { flex.setHTML(0, 0, new HTML(theValue).toString());
String concessioneId = listConcessioni.get(0); }
else if(key.equalsIgnoreCase("descrizione")) {
String reducedValue = theValue;
try { try {
Long theConcessioneId = Long.parseLong(concessioneId); reducedValue = StringUtil.ellipsize(theValue, 300);
GeoportalDataViewerServiceAsync.Util.getInstance().getUploadedImagesForId("Concessione", theConcessioneId, 1, new AsyncCallback<List<UploadedImageDV>>() { GWT.log("reduced: "+reducedValue);
} catch (Exception e) {
@Override GWT.log("error: "+e.getMessage());
public void onFailure(Throwable caught) { }
// TODO Auto-generated method stub flex.setText(1, 0, reducedValue);
}else if(key.equalsIgnoreCase("date_scavo")) {
} flex.setHTML(2, 0, new HTML("<code>"+theValue+"</code>").toString());
}
@Override }
public void onSuccess(List<UploadedImageDV> result) {
GWT.log("Loaded images: "+result); /*Scheduler.get().scheduleDeferred(new ScheduledCommand() {
for (UploadedImageDV img : result) { @Override
if(img.getListWsContent()!=null) { public void execute() {
WorkspaceContentDV wsContent = img.getListWsContent().get(img.getListWsContent().size()-1); List<String> listConcessioni = entries.get("product_id");
String theImgHTML = "<img src=\""+wsContent.getLink()+"\"></img>"; if(listConcessioni!=null && listConcessioni.size()>0) {
GWT.log("theImgHTML: "+theImgHTML); String concessioneId = listConcessioni.get(0);
flex.setHTML(flex.getRowCount()+1, 0, theImgHTML); try {
} Long theConcessioneId = Long.parseLong(concessioneId);
GeoportalDataViewerServiceAsync.Util.getInstance().getUploadedImagesForId("Concessione", theConcessioneId, 1, new AsyncCallback<List<UploadedImageDV>>() {
@Override
public void onFailure(Throwable caught) {
// TODO Auto-generated method stub
} }
} @Override
}); public void onSuccess(List<UploadedImageDV> result) {
}catch (Exception e) { GWT.log("Loaded images: "+result);
// TODO: handle exception
for (UploadedImageDV img : result) {
if(img.getListWsContent()!=null) {
WorkspaceContentDV wsContent = img.getListWsContent().get(img.getListWsContent().size()-1);
String theImgHTML = "<img src=\""+wsContent.getLink()+"\"></img>";
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<UploadedImageDV> 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 = "<img src=\""+wsContent.getLink()+"\"></img>";
GWT.log("theImgHTML: "+theImgHTML);
GeoportalDataViewerConstants.print("The row are: "+flex.getRowCount());
flex.setHTML(flex.getRowCount()+1, 0, theImgHTML);
}
} }
} }
} }
});*/
featureFound = true;
//break; //Only the first one
}
if(feature==null)
if(geoNaDataObject.getMapImages()!=null) { return;
for (Long key : geoNaDataObject.getMapImages().keySet()) {
List<UploadedImageDV> listUI = geoNaDataObject.getMapImages().get(key); GWT.log("The selected Feature is: "+feature);
GWT.log("Adding images: "+listUI); GeoportalDataViewerConstants.print("The selected Feature is: "+feature);
if(listUI!=null) { FeatureRow theFeature = feature;
UploadedImageDV img = listUI.get(0); Button button = null;
if(img.getListWsContent()!=null) { if(!featureFound) {
WorkspaceContentDV wsContent = img.getListWsContent().get(img.getListWsContent().size()-1); flex.setHTML(0, 0, new HTML("No data available").toString());
String theImgHTML = "<img src=\""+wsContent.getLink()+"\"></img>"; }else {
GWT.log("theImgHTML: "+theImgHTML); button = new Button("Open Details");
flex.setHTML(flex.getRowCount()+1, 0, theImgHTML); 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; if(centerTo==null)
//break; //Only the first one centerTo = queryEvent.getoLCoordinate();
}
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() {
olMap.showPopup(vpPanel.toString(), centerTo);
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override @Override
public void onClick(ClickEvent event) { public void execute() {
ShowDetailsEvent toEvent = parseGeonaReferences(geoNaDataObject.getSourceLayerObject().getItemType(), theFeature); Element buttonElement = DOM.getElementById("open-details");
applicationBus.fireEvent(toEvent); 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) {
PointsPath path = feature.getGeometry().getPath(); GeoportalDataViewerConstants.print(e.getMessage());
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);
}
}
});
}
});
} }
} }
}); });

View File

@ -215,6 +215,7 @@ public abstract class OpenLayerOSM {
public void showPopup(String html, Coordinate coordinate) { public void showPopup(String html, Coordinate coordinate) {
GWT.log("Showing popup on: "+coordinate); GWT.log("Showing popup on: "+coordinate);
GeoportalDataViewerConstants.print("Showing popup on: "+coordinate);
Element elPopup = DOM.getElementById("popup"); Element elPopup = DOM.getElementById("popup");
elPopup.getStyle().setVisibility(Visibility.VISIBLE); elPopup.getStyle().setVisibility(Visibility.VISIBLE);
if(popupOverlay==null) { if(popupOverlay==null) {

View File

@ -18,7 +18,7 @@
<b:DropdownButton type="LINK" text=" " icon="INFO"> <b:DropdownButton type="LINK" text=" " icon="INFO">
<g:HTMLPanel ui:field="panelMI" <g:HTMLPanel ui:field="panelMI"
addStyleNames="info-interaction"> addStyleNames="info-interaction">
<g:Label>Map Interaction</g:Label> <g:Label>Map Interactions</g:Label>
<b:Paragraph><b:Icon type="CHECK_EMPTY"/> Use <code>Shift+Drag</code> to draw an extent for zoom in the Map</b:Paragraph> <b:Paragraph><b:Icon type="CHECK_EMPTY"/> Use <code>Shift+Drag</code> to draw an extent for zoom in the Map</b:Paragraph>
<b:Paragraph><b:Icon type="HAND_UP"/> Click on the Points shown on the Map to view their features</b:Paragraph> <b:Paragraph><b:Icon type="HAND_UP"/> Click on the Points shown on the Map to view their features</b:Paragraph>
</g:HTMLPanel> </g:HTMLPanel>

View File

@ -81,15 +81,15 @@ public class ConvertToDataViewModel {
theConcessione.setLastUpdateUser(toUser(concessione.getLastUpdateUser())); theConcessione.setLastUpdateUser(toUser(concessione.getLastUpdateUser()));
theConcessione.setLicenzaID(concessione.getLicenzaID()); theConcessione.setLicenzaID(concessione.getLicenzaID());
theConcessione.setNome(concessione.getNome()); theConcessione.setNome(concessione.getNome());
theConcessione.setParoleChiaveICCD(concessione.getParoleChiaveICCD()); theConcessione.setParoleChiaveICCD(toListString(concessione.getParoleChiaveICCD()));
theConcessione.setParoleChiaveLibere(concessione.getParoleChiaveLibere()); theConcessione.setParoleChiaveLibere(toListString(concessione.getParoleChiaveLibere()));
theConcessione.setResponsabile(concessione.getResponsabile()); theConcessione.setResponsabile(concessione.getResponsabile());
theConcessione.setRisorseCorrelate(concessione.getRisorseCorrelate()); theConcessione.setRisorseCorrelate(toListString(concessione.getRisorseCorrelate()));
theConcessione.setSoggetto(concessione.getSoggetto()); theConcessione.setSoggetto(concessione.getSoggetto());
theConcessione.setTitolareCopyright(concessione.getTitolareCopyright()); theConcessione.setTitolareCopyright(concessione.getTitolareCopyright());
theConcessione.setTitolareLicenza(concessione.getTitolareLicenza()); theConcessione.setTitolareLicenza(concessione.getTitolareLicenza());
theConcessione.setTitolari(concessione.getTitolari()); theConcessione.setTitolari(toListString(concessione.getTitolari()));
theConcessione.setVersion(concessione.getVersion()); theConcessione.setVersion(concessione.getVersion());
theConcessione.setRecordType(concessione.getRecordType().name()); theConcessione.setRecordType(concessione.getRecordType().name());
@ -199,7 +199,7 @@ public class ConvertToDataViewModel {
theRelazioneDiScavo.setLicenseID(relazioneScavo.getLicenseID()); theRelazioneDiScavo.setLicenseID(relazioneScavo.getLicenseID());
theRelazioneDiScavo.setPolicy(toPolicy(relazioneScavo.getPolicy())); theRelazioneDiScavo.setPolicy(toPolicy(relazioneScavo.getPolicy()));
//theRelazioneDiScavo.setRecord(recordDV); //theRelazioneDiScavo.setRecord(recordDV);
theRelazioneDiScavo.setResponsabili(relazioneScavo.getResponsabili()); theRelazioneDiScavo.setResponsabili(toListString(relazioneScavo.getResponsabili()));
theRelazioneDiScavo.setSoggetto(relazioneScavo.getSoggetto()); theRelazioneDiScavo.setSoggetto(relazioneScavo.getSoggetto());
theRelazioneDiScavo.setTitolo(relazioneScavo.getTitolo()); theRelazioneDiScavo.setTitolo(relazioneScavo.getTitolo());
@ -227,7 +227,7 @@ public class ConvertToDataViewModel {
theUploadedImageDV.setLicenseID(uploadedImage.getLicenseID()); theUploadedImageDV.setLicenseID(uploadedImage.getLicenseID());
theUploadedImageDV.setPolicy(toPolicy(uploadedImage.getPolicy())); theUploadedImageDV.setPolicy(toPolicy(uploadedImage.getPolicy()));
//theUploadedImageDV.setRecord(recordDV); //theUploadedImageDV.setRecord(recordDV);
theUploadedImageDV.setResponsabili(uploadedImage.getResponsabili()); theUploadedImageDV.setResponsabili(toListString(uploadedImage.getResponsabili()));
theUploadedImageDV.setSoggetto(uploadedImage.getSoggetto()); theUploadedImageDV.setSoggetto(uploadedImage.getSoggetto());
theUploadedImageDV.setTitolo(uploadedImage.getTitolo()); theUploadedImageDV.setTitolo(uploadedImage.getTitolo());
@ -284,7 +284,7 @@ public class ConvertToDataViewModel {
theLayerConessione.setLayerName(layerConcessione.getLayerName()); theLayerConessione.setLayerName(layerConcessione.getLayerName());
theLayerConessione.setLayerID(layerConcessione.getLayerID()); theLayerConessione.setLayerID(layerConcessione.getLayerID());
theLayerConessione.setLayerUUID(layerConcessione.getLayerUUID()); theLayerConessione.setLayerUUID(layerConcessione.getLayerUUID());
theLayerConessione.setAuthors(layerConcessione.getAuthors()); theLayerConessione.setAuthors(toListString(layerConcessione.getAuthors()));
BoundsMap bounds = toBoundMap(layerConcessione.getBbox()); BoundsMap bounds = toBoundMap(layerConcessione.getBbox());
theLayerConessione.setBbox(bounds); theLayerConessione.setBbox(bounds);
theLayerConessione.setCreationTime(toDateString(layerConcessione.getCreationTime())); theLayerConessione.setCreationTime(toDateString(layerConcessione.getCreationTime()));