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;
/**
* 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);
}-*/;
}

View File

@ -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<GeoNaSpatialQueryResult> 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<FeatureRow> features = geoNaDataObject.getFeatures();
//USING ONLY THE FIRST FEATURE IN THE LIST
if(features!=null && features.size()>0) {
feature = features.get(0);
Map<String, List<String>> 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("<code>"+theValue).toString()+"</code>");
}
}
/*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<FeatureRow> features = geoNaDataObject.getFeatures();
//USING ONLY THE FIRST FEATURE IN THE LIST
if(features!=null && features.size()>0) {
feature = features.get(0);
Map<String, List<String>> entries = feature.getMapProperties();
@Override
public void execute() {
List<String> 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<List<UploadedImageDV>>() {
@Override
public void onFailure(Throwable caught) {
// TODO Auto-generated method stub
}
@Override
public void onSuccess(List<UploadedImageDV> 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 = "<img src=\""+wsContent.getLink()+"\"></img>";
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("<code>"+theValue+"</code>").toString());
}
}
/*Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
List<String> 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<List<UploadedImageDV>>() {
@Override
public void onFailure(Throwable caught) {
// TODO Auto-generated method stub
}
}
});
}catch (Exception e) {
// TODO: handle exception
@Override
public void onSuccess(List<UploadedImageDV> 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 = "<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(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);
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());
}
}
});

View File

@ -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) {

View File

@ -18,7 +18,7 @@
<b:DropdownButton type="LINK" text=" " icon="INFO">
<g:HTMLPanel ui:field="panelMI"
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="HAND_UP"/> Click on the Points shown on the Map to view their features</b:Paragraph>
</g:HTMLPanel>

View File

@ -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()));