starting get concessione for id

This commit is contained in:
francesco 2020-11-02 18:18:03 +01:00
parent b62bcaed5b
commit ed61ffde87
5 changed files with 97 additions and 67 deletions

View File

@ -10,6 +10,7 @@ import org.gcube.portlets.user.geoportaldataviewer.client.events.QueryDataEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.QueryDataEventHandler; import org.gcube.portlets.user.geoportaldataviewer.client.events.QueryDataEventHandler;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerOSM; import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerOSM;
import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil; import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil;
import org.gcube.portlets.user.geoportaldataviewer.shared.FeatureRow;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaDataObject; import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaDataObject;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoInformationForWMSRequest; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoInformationForWMSRequest;
@ -119,20 +120,30 @@ public class LayerManager {
flex.setCellPadding(1); flex.setCellPadding(1);
flex.setCellSpacing(1); flex.setCellSpacing(1);
flex.getElement().addClassName("popup-table"); flex.getElement().addClassName("popup-table");
boolean featureFound = false;
for (GeoNaDataObject geoNaDataObject : result) { for (GeoNaDataObject geoNaDataObject : result) {
Map<String, List<String>> entries = geoNaDataObject.getDataEntryFields(); List<FeatureRow> features = geoNaDataObject.getFeatures();
for (String key : entries.keySet()) { if(features!=null && features.size()>0) {
if(key.equalsIgnoreCase("nome")) { Map<String, List<String>> entries = features.get(0).getMapProperties();
flex.setHTML(0, 0, new HTML(entries.get(key).get(0)).toString());
} for (String key : entries.keySet()) {
else if(key.equalsIgnoreCase("descrizione")) { if(key.equalsIgnoreCase("nome")) {
flex.setText(1, 0, entries.get(key).get(0)); flex.setHTML(0, 0, new HTML(entries.get(key).get(0)).toString());
}else if(key.equalsIgnoreCase("date_scavo")) { }
flex.setHTML(2, 0, new HTML("<code>"+entries.get(key).get(0)).toString()+"</code>"); else if(key.equalsIgnoreCase("descrizione")) {
flex.setText(1, 0, entries.get(key).get(0));
}else if(key.equalsIgnoreCase("date_scavo")) {
flex.setHTML(2, 0, new HTML("<code>"+entries.get(key).get(0)).toString()+"</code>");
}
} }
featureFound = true;
break; //Only the first one
} }
break; //Only the first one }
if(!featureFound) {
flex.setHTML(0, 0, new HTML("No data available").toString());
} }
olMap.showPopup(flex.toString(), queryEvent.getoLCoordinate()); olMap.showPopup(flex.toString(), queryEvent.getoLCoordinate());

View File

@ -11,12 +11,14 @@ import org.gcube.application.geoportal.model.concessioni.Concessione;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerService; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerService;
import org.gcube.portlets.user.geoportaldataviewer.server.gis.FeatureParser; import org.gcube.portlets.user.geoportaldataviewer.server.gis.FeatureParser;
import org.gcube.portlets.user.geoportaldataviewer.server.gis.WMSUrlValidator; import org.gcube.portlets.user.geoportaldataviewer.server.gis.WMSUrlValidator;
import org.gcube.portlets.user.geoportaldataviewer.shared.FeatureRow;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaDataObject; import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaDataObject;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoInformationForWMSRequest; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoInformationForWMSRequest;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.Styles; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.Styles;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.ZAxis; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.ZAxis;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.ConcessioneDV;
import org.gcube.spatial.data.geoutility.GeoNcWMSMetadataUtility; import org.gcube.spatial.data.geoutility.GeoNcWMSMetadataUtility;
import org.gcube.spatial.data.geoutility.bean.LayerStyles; import org.gcube.spatial.data.geoutility.bean.LayerStyles;
import org.gcube.spatial.data.geoutility.bean.LayerZAxis; import org.gcube.spatial.data.geoutility.bean.LayerZAxis;
@ -33,6 +35,7 @@ import com.google.gwt.user.server.rpc.RemoteServiceServlet;
public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet implements public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet implements
GeoportalDataViewerService { GeoportalDataViewerService {
public static final String PRODUCT_ID = "product_id";
/** The Constant LOG. */ /** The Constant LOG. */
private static final Logger LOG = LoggerFactory.getLogger(GeoportalDataViewerServiceImpl.class); private static final Logger LOG = LoggerFactory.getLogger(GeoportalDataViewerServiceImpl.class);
@ -84,18 +87,42 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
} }
} }
/* (non-Javadoc) /*
* @see org.gcube.portlets.user.gisviewer.client.GisViewerService#getDataResult(java.util.List, java.lang.String, int) * (non-Javadoc)
*
* @see
* org.gcube.portlets.user.gisviewer.client.GisViewerService#getDataResult(java.
* util.List, java.lang.String, int)
*/ */
@Override @Override
public List<GeoNaDataObject> getDataResult(List<LayerItem> layerItems, String mapSrsName, BoundsMap selectBBOX, int maxWFSFeature, double zoomLevel) { public List<GeoNaDataObject> getDataResult(List<LayerItem> layerItems, String mapSrsName, BoundsMap selectBBOX,
int maxWFSFeature, double zoomLevel) {
LOG.info("getDataResult called"); LOG.info("getDataResult called");
List<GeoNaDataObject> result = FeatureParser.getDataResults(layerItems, mapSrsName, selectBBOX, maxWFSFeature); List<GeoNaDataObject> result = FeatureParser.getDataResults(layerItems, mapSrsName, selectBBOX, maxWFSFeature);
for (GeoNaDataObject geoNaDataObject : result) {
List<FeatureRow> features = geoNaDataObject.getFeatures();
for (FeatureRow feature : features) {
List<String> theProductIds = feature.getMapProperties().get(PRODUCT_ID);
try {
if (theProductIds != null && theProductIds.size() > 0) {
String theProductID = theProductIds.get(0);
LOG.info("Found: "+PRODUCT_ID + " loading "+ConcessioneDV.class.getSimpleName());
long productID = Long.parseLong(theProductID);
ConcessioneDV concessioneDV = getConcessioneForId(productID);
geoNaDataObject.setConcessioneDV(concessioneDV);
LOG.debug("Added "+ConcessioneDV.class.getSimpleName()+" as "+concessioneDV);
}
} catch (Exception e) {
LOG.error("Error:", e);
}
}
}
return result; return result;
} }
private ConcessioneDV getConcessioneForId(Long id) throws Exception{
private void getConcessioneForId(Long id) throws Exception{
LOG.info(""); LOG.info("");
if(id==null) if(id==null)
@ -109,12 +136,15 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
Concessione concessione = null; Concessione concessione = null;
if(record !=null && record instanceof Concessione) { if(record !=null && record instanceof Concessione) {
concessione = (Concessione) record; concessione = (Concessione) record;
return ConvertToDataViewModel.toConcessione(concessione);
}else }else
throw new Exception("No Concessione with id: "+id+" is available"); throw new Exception("No Concessione with id '"+id+"' is available");
}catch (Exception e) { }catch (Exception e) {
// TODO: handle exception String erroMsg = Concessione.class.getSimpleName() +" with id "+id+" not available";
LOG.error(erroMsg,e);
throw new Exception(erroMsg);
} }
} }

View File

@ -64,9 +64,7 @@ public class FeatureParser {
List<FeatureRow> rows = getWFSFeatureProperties(layerItem, mapSrsName, selectBBOX, maxWFSFeature); List<FeatureRow> rows = getWFSFeatureProperties(layerItem, mapSrsName, selectBBOX, maxWFSFeature);
GeoNaDataObject gdo = new GeoNaDataObject(); GeoNaDataObject gdo = new GeoNaDataObject();
gdo.setLayerItem(layerItem); gdo.setLayerItem(layerItem);
for (FeatureRow featureRow : rows) { gdo.setFeatures(rows);
gdo.setDataEntryFields(featureRow.getMapProperties());
}
listGeonaDO.add(gdo); listGeonaDO.add(gdo);
} }
return listGeonaDO; return listGeonaDO;
@ -127,8 +125,7 @@ public class FeatureParser {
}catch (Exception e) { }catch (Exception e) {
LOG.warn("Unable to read the field 'crs'"); LOG.warn("Unable to read the field 'crs'");
} }
LOG.info("Features are: "+features.length()); LOG.info("Features are: "+features.length());
for (int i=0; i<features.length(); i++) { for (int i=0; i<features.length(); i++) {

View File

@ -5,6 +5,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.ConcessioneDV;
/** /**
@ -21,9 +22,10 @@ public class GeoNaDataObject implements Serializable{
*/ */
private static final long serialVersionUID = 5566069859060851625L; private static final long serialVersionUID = 5566069859060851625L;
/** The form data entry fields. */ /** The form data entry fields. */
private Map<String, List<String>> dataEntryFields; private List<FeatureRow> features;
private String geonaDataType; private String productType; //e.g. "Concessioni"
private LayerItem layerItem; private LayerItem layerItem;
private ConcessioneDV concessioneDV;
/** /**
* Instantiates a new geo na data object. * Instantiates a new geo na data object.
@ -32,34 +34,22 @@ public class GeoNaDataObject implements Serializable{
} }
/** public List<FeatureRow> getFeatures() {
* Gets the data entry fields. return features;
*
* @return the data entry fields
*/
public Map<String, List<String>> getDataEntryFields() {
return dataEntryFields;
} }
/** public void setFeatures(List<FeatureRow> features) {
* Sets the data entry fields. this.features = features;
*
* @param dataEntryFields the data entry fields
*/
public void setDataEntryFields(Map<String, List<String>> dataEntryFields) {
this.dataEntryFields = dataEntryFields;
} }
/** public String getProductType() {
* Gets the geona data type. return productType;
*
* @return the geona data type
*/
public String getGeonaDataType() {
return geonaDataType;
} }
public void setProductType(String productType) {
this.productType = productType;
}
public LayerItem getLayerItem() { public LayerItem getLayerItem() {
return layerItem; return layerItem;
} }
@ -68,27 +58,28 @@ public class GeoNaDataObject implements Serializable{
this.layerItem = layerItem; this.layerItem = layerItem;
} }
/** public ConcessioneDV getConcessioneDV() {
* Sets the geona data type. return concessioneDV;
* }
* @param geonaDataType the new geona data type
*/ public void setConcessioneDV(ConcessioneDV concessioneDV) {
public void setGeonaDataType(String geonaDataType) { this.concessioneDV = concessioneDV;
this.geonaDataType = geonaDataType;
} }
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override @Override
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("GeoNaFormDataObject [dataEntryFields="); builder.append("GeoNaDataObject [features=");
builder.append(dataEntryFields); builder.append(features);
builder.append(", geonaDataType="); builder.append(", productType=");
builder.append(geonaDataType); builder.append(productType);
builder.append(", layerItem=");
builder.append(layerItem);
builder.append(", concessioneDV=");
builder.append(concessioneDV);
builder.append("]"); builder.append("]");
return builder.toString(); return builder.toString();
} }
} }

View File

@ -11,8 +11,12 @@ import java.io.Serializable;
*/ */
public class FeatureGeometry implements Serializable{ public class FeatureGeometry implements Serializable{
String type; /**
String coordinates; *
*/
private static final long serialVersionUID = 6251162740446739453L;
private String type;
private String coordinates;
public FeatureGeometry() { public FeatureGeometry() {
} }
@ -49,8 +53,5 @@ public class FeatureGeometry implements Serializable{
builder.append("]"); builder.append("]");
return builder.toString(); return builder.toString();
} }
} }