Rafactor on Class

Added Styles class to serialization

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/gis-viewer@124135 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2016-02-12 15:44:26 +00:00
parent 99c0c33a80
commit bd602f9fba
6 changed files with 186 additions and 40 deletions

View File

@ -10,9 +10,9 @@ import java.util.Map;
import org.gcube.portlets.user.gisviewer.client.commons.beans.DataResult;
import org.gcube.portlets.user.gisviewer.client.commons.beans.ExportFormat;
import org.gcube.portlets.user.gisviewer.client.commons.beans.GeoInformationForWMSRequest;
import org.gcube.portlets.user.gisviewer.client.commons.beans.GeoserverItem;
import org.gcube.portlets.user.gisviewer.client.commons.beans.GisViewerBaseLayerInterface;
import org.gcube.portlets.user.gisviewer.client.commons.beans.GisViewerWmsValidParameters;
import org.gcube.portlets.user.gisviewer.client.commons.beans.LayerItem;
import org.gcube.portlets.user.gisviewer.client.commons.beans.LayerItemsResult;
import org.gcube.portlets.user.gisviewer.client.commons.beans.MapViewInfo;
@ -459,7 +459,7 @@ implements ToolbarHandler, DataPanelHandler, LayersPanelHandler, CqlFilterHandle
final LayerType featureType = isBase?LayerType.RASTER_BASELAYER:LayerType.FEATURE_TYPE;
// Info.display("Adding Layer", layerName);
GisViewer.service.parseWmsRequest(wmsRequest, layerName, new AsyncCallback<GisViewerWmsValidParameters>() {
GisViewer.service.parseWmsRequest(wmsRequest, layerName, new AsyncCallback<GeoInformationForWMSRequest>() {
@Override
public void onFailure(Throwable caught) {
@ -471,13 +471,13 @@ implements ToolbarHandler, DataPanelHandler, LayersPanelHandler, CqlFilterHandle
}
@Override
public void onSuccess(GisViewerWmsValidParameters result) {
public void onSuccess(GeoInformationForWMSRequest result) {
if(westPanel.isMasked())
westPanel.unmask();
if(layersPanel.isMasked())
layersPanel.unmask();
addLayerByWms(featureType, layerTitle, layerName, result.getBaseWmsServiceHost(), true, isBase, displayInLayerSwitcher, (ArrayList<String>) result.getStyles(), result.getWmsRequest(), false, result.getMapWMSNoStandard(), result.isNcWMS(), UUID, result.getZAxis());
addLayerByWms(featureType, layerTitle, layerName, result.getBaseWmsServiceHost(), true, isBase, displayInLayerSwitcher, (ArrayList<String>) result.getStyles().getGeoStyles(), result.getWmsRequest(), false, result.getMapWMSNoStandard(), result.isNcWMS(), UUID, result.getZAxis());
}
});
}

View File

@ -5,7 +5,7 @@ import java.util.List;
import org.gcube.portlets.user.gisviewer.client.commons.beans.DataResult;
import org.gcube.portlets.user.gisviewer.client.commons.beans.GisViewerBaseLayerInterface;
import org.gcube.portlets.user.gisviewer.client.commons.beans.GisViewerWmsValidParameters;
import org.gcube.portlets.user.gisviewer.client.commons.beans.GeoInformationForWMSRequest;
import org.gcube.portlets.user.gisviewer.client.commons.beans.LayerItem;
import org.gcube.portlets.user.gisviewer.client.commons.beans.LayerItemsResult;
import org.gcube.portlets.user.gisviewer.client.commons.beans.Property;
@ -120,6 +120,6 @@ public interface GisViewerService extends RemoteService {
* @return the gis viewer wms valid parameters
* @throws Exception the exception
*/
GisViewerWmsValidParameters parseWmsRequest(String wmsRequest, String layerName) throws Exception;
GeoInformationForWMSRequest parseWmsRequest(String wmsRequest, String layerName) throws Exception;
}

View File

@ -5,7 +5,7 @@ import java.util.List;
import org.gcube.portlets.user.gisviewer.client.commons.beans.DataResult;
import org.gcube.portlets.user.gisviewer.client.commons.beans.GisViewerBaseLayerInterface;
import org.gcube.portlets.user.gisviewer.client.commons.beans.GisViewerWmsValidParameters;
import org.gcube.portlets.user.gisviewer.client.commons.beans.GeoInformationForWMSRequest;
import org.gcube.portlets.user.gisviewer.client.commons.beans.LayerItem;
import org.gcube.portlets.user.gisviewer.client.commons.beans.LayerItemsResult;
import org.gcube.portlets.user.gisviewer.client.commons.beans.Property;
@ -117,7 +117,7 @@ public interface GisViewerServiceAsync {
* @param callback the callback
*/
void parseWmsRequest(String wmsRequest, String layerName,
AsyncCallback<GisViewerWmsValidParameters> callback);
AsyncCallback<GeoInformationForWMSRequest> callback);
/**
* Gets the gcube security token.

View File

@ -5,66 +5,63 @@ package org.gcube.portlets.user.gisviewer.client.commons.beans;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
/**
* The Class GisViewerWmsValidParameters.
* The Class GeoInformationForWMSRequest.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Jan 28, 2016
* Feb 12, 2016
*/
public class GisViewerWmsValidParameters implements Serializable{
public class GeoInformationForWMSRequest implements Serializable{
/**
*
*/
private static final long serialVersionUID = 8871057872297550295L;
private String baseWmsServiceHost;
private String wmsRequest;
private String layerName;
private String versionWMS;
private String crs;
private HashMap<String, String> mapWMSNoStandard;
private List<String> styles;
private HashMap<String, String> mapWMSNoStandardParams;
private Styles styles;
private boolean isNcWMS;
private ZAxis zAxis;
/**
* Instantiates a new gis viewer wms valid parameters.
*/
public GisViewerWmsValidParameters() {
// TODO Auto-generated constructor stub
/**
* Instantiates a new geo information for wms request.
*/
public GeoInformationForWMSRequest() {
}
/**
* Instantiates a new gis viewer wms valid parameters.
* Instantiates a new geo information for wms request.
*
* @param baseWmsServiceHost the base wms service host
* @param wmsRequest the wms request
* @param layerName the layer name
* @param versionWms the version wms
* @param crs the crs
* @param mapWmsNotStandard the map wms not standard
* @param styles the styles
* @param isNcWms the is nc wms
* @param mapWmsNoStandard the map wms not standard
* @param styles the layer styles
* @param zAxis the z axis
*/
public GisViewerWmsValidParameters(String baseWmsServiceHost, String wmsRequest, String layerName, String versionWms, String crs, HashMap<String, String> mapWmsNotStandard, List<String> styles, boolean isNcWms, ZAxis zAxis) {
public GeoInformationForWMSRequest(String baseWmsServiceHost, String wmsRequest, String layerName, String versionWms, String crs, HashMap<String, String> mapWmsNoStandard, Styles styles, ZAxis zAxis) {
this.baseWmsServiceHost = baseWmsServiceHost;
this.wmsRequest = wmsRequest;
this.layerName = layerName;
this.versionWMS = versionWms;
this.crs = crs;
this.mapWMSNoStandard = mapWmsNotStandard;
this.mapWMSNoStandardParams = mapWmsNoStandard;
this.styles = styles;
this.isNcWMS = isNcWms;
this.zAxis = zAxis;
}
/**
* Gets the z axis.
*
* @return the zAxis
*/
public ZAxis getZAxis() {
@ -73,6 +70,8 @@ public class GisViewerWmsValidParameters implements Serializable{
}
/**
* Sets the z axis.
*
* @param zAxis the zAxis to set
*/
public void setZAxis(ZAxis zAxis) {
@ -142,7 +141,7 @@ public class GisViewerWmsValidParameters implements Serializable{
*/
public HashMap<String, String> getMapWMSNoStandard() {
return mapWMSNoStandard;
return mapWMSNoStandardParams;
}
@ -151,7 +150,7 @@ public class GisViewerWmsValidParameters implements Serializable{
*
* @return the styles
*/
public List<String> getStyles() {
public Styles getStyles() {
return styles;
}
@ -230,7 +229,7 @@ public class GisViewerWmsValidParameters implements Serializable{
*/
public void setMapWMSNoStandard(HashMap<String, String> mapWMSNoStandard) {
this.mapWMSNoStandard = mapWMSNoStandard;
this.mapWMSNoStandardParams = mapWMSNoStandard;
}
@ -239,7 +238,7 @@ public class GisViewerWmsValidParameters implements Serializable{
*
* @param styles the styles to set
*/
public void setStyles(List<String> styles) {
public void setStyles(Styles styles) {
this.styles = styles;
}
@ -255,6 +254,7 @@ public class GisViewerWmsValidParameters implements Serializable{
this.isNcWMS = isNcWMS;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@ -262,7 +262,7 @@ public class GisViewerWmsValidParameters implements Serializable{
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("GisViewerWmsValidParameters [baseWmsServiceHost=");
builder.append("GeoInformationForWMSRequest [baseWmsServiceHost=");
builder.append(baseWmsServiceHost);
builder.append(", wmsRequest=");
builder.append(wmsRequest);
@ -272,8 +272,8 @@ public class GisViewerWmsValidParameters implements Serializable{
builder.append(versionWMS);
builder.append(", crs=");
builder.append(crs);
builder.append(", mapWMSNoStandard=");
builder.append(mapWMSNoStandard);
builder.append(", mapWMSNoStandardParams=");
builder.append(mapWMSNoStandardParams);
builder.append(", styles=");
builder.append(styles);
builder.append(", isNcWMS=");
@ -283,4 +283,6 @@ public class GisViewerWmsValidParameters implements Serializable{
builder.append("]");
return builder.toString();
}
}

View File

@ -0,0 +1,126 @@
/**
*
*/
package org.gcube.portlets.user.gisviewer.client.commons.beans;
import java.util.List;
import java.util.Map;
import com.google.gwt.user.client.rpc.IsSerializable;
/**
* The Class LayerStyles.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Feb 10, 2016
*/
public class Styles implements IsSerializable{
private List<String> geoStyles;
private Map<String, String> mapNcWmsStyles;
boolean isNcWms = false;
/**
* Instantiates a new layer styles.
*/
public Styles() {
}
/**
* Instantiates a new layer styles.
*
* @param geoStyles the geo styles
* @param mapNcWmsStyles the map nc wms styles
* @param isNcWms the is nc wms
*/
public Styles(List<String> geoStyles, Map<String, String> mapNcWmsStyles,boolean isNcWms) {
this.geoStyles = geoStyles;
this.mapNcWmsStyles = mapNcWmsStyles;
this.isNcWms = isNcWms;
}
/**
* Gets the geo styles.
*
* @return the geoStyles
*/
public List<String> getGeoStyles() {
return geoStyles;
}
/**
* Gets the map nc wms styles.
*
* @return the mapNcWmsStyles
*/
public Map<String, String> getMapNcWmsStyles() {
return mapNcWmsStyles;
}
/**
* Checks if is nc wms.
*
* @return the isNcWms
*/
public boolean isNcWms() {
return isNcWms;
}
/**
* Sets the geo styles.
*
* @param geoStyles the geoStyles to set
*/
public void setGeoStyles(List<String> geoStyles) {
this.geoStyles = geoStyles;
}
/**
* Sets the map nc wms styles.
*
* @param mapNcWmsStyles the mapNcWmsStyles to set
*/
public void setMapNcWmsStyles(Map<String, String> mapNcWmsStyles) {
this.mapNcWmsStyles = mapNcWmsStyles;
}
/**
* Sets the nc wms.
*
* @param isNcWms the isNcWms to set
*/
public void setNcWms(boolean isNcWms) {
this.isNcWms = isNcWms;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("Styles [geoStyles=");
builder.append(geoStyles);
builder.append(", mapNcWmsStyles=");
builder.append(mapNcWmsStyles);
builder.append(", isNcWms=");
builder.append(isNcWms);
builder.append("]");
return builder.toString();
}
}

View File

@ -19,11 +19,12 @@ import org.gcube.common.geoserverinterface.bean.LayerRest;
import org.gcube.portlets.user.gisviewer.client.Constants;
import org.gcube.portlets.user.gisviewer.client.GisViewerService;
import org.gcube.portlets.user.gisviewer.client.commons.beans.DataResult;
import org.gcube.portlets.user.gisviewer.client.commons.beans.GeoInformationForWMSRequest;
import org.gcube.portlets.user.gisviewer.client.commons.beans.GisViewerBaseLayerInterface;
import org.gcube.portlets.user.gisviewer.client.commons.beans.GisViewerWmsValidParameters;
import org.gcube.portlets.user.gisviewer.client.commons.beans.LayerItem;
import org.gcube.portlets.user.gisviewer.client.commons.beans.LayerItemsResult;
import org.gcube.portlets.user.gisviewer.client.commons.beans.Property;
import org.gcube.portlets.user.gisviewer.client.commons.beans.Styles;
import org.gcube.portlets.user.gisviewer.client.commons.beans.TransectParameters;
import org.gcube.portlets.user.gisviewer.client.commons.beans.WebFeatureTable;
import org.gcube.portlets.user.gisviewer.client.commons.beans.WmsRequest;
@ -123,9 +124,23 @@ public abstract class GisViewerServiceImpl extends RemoteServiceServlet implemen
return result;
}
/* (non-Javadoc)
* @see org.gcube.portlets.user.gisviewer.client.GisViewerService#parseWmsRequest(java.lang.String, java.lang.String)
*/
@Override
public GisViewerWmsValidParameters parseWmsRequest(String wmsRequest, String layerName) throws Exception{
public GeoInformationForWMSRequest parseWmsRequest(String wmsRequest, String layerName) throws Exception{
return loadGeoInfoForWmsRequest(wmsRequest, layerName);
}
/**
* Load geo info for wms request.
*
* @param wmsRequest the wms request
* @param layerName the layer name
* @return the gis viewer wms valid parameters
* @throws Exception the exception
*/
public static GeoInformationForWMSRequest loadGeoInfoForWmsRequest(String wmsRequest, String layerName) throws Exception{
try {
GisViewerWMSUrlValidator validator = new GisViewerWMSUrlValidator(wmsRequest, layerName);
String wmsServiceHost = validator.getWmsServiceHost();
@ -145,11 +160,14 @@ public abstract class GisViewerServiceImpl extends RemoteServiceServlet implemen
LayerStyles layerStyle = geoGS.loadStyles();
Map<String,String> mapNcWmsStyles = layerStyle.getMapNcWmsStyles()==null?new HashMap<String, String>(1):layerStyle.getMapNcWmsStyles();
mapWmsNotStandard.putAll(mapNcWmsStyles);
//MAP STYLES INTO GWT-SERIALIZABLE OBJECT
Styles styles = new Styles(layerStyle.getGeoStyles(), layerStyle.getMapNcWmsStyles(), layerStyle.isNcWms());
//ZAxis
LayerZAxis layerZAxis = geoGS.loadZAxis();
//MAP ZAXIS INTO GWT-SERIALIZABLE OBJECT
ZAxis zAxis = layerZAxis!=null?new ZAxis(layerZAxis.getUnits(), layerZAxis.isPositive(), layerZAxis.getValues()):null;
return new GisViewerWmsValidParameters(wmsServiceHost, validWMSRequest, layerName, versionWms, crs, mapWmsNotStandard, layerStyle.getGeoStyles(), layerStyle.isNcWms(), zAxis);
return new GeoInformationForWMSRequest(wmsServiceHost, validWMSRequest, layerName, versionWms, crs, mapWmsNotStandard, styles, zAxis);
}
catch (Exception e) {
String msg = "An error occurred during wms request validation for layer: "+layerName;