added WMS request

This commit is contained in:
francesco 2020-10-27 16:04:34 +01:00
parent dc4778aca1
commit f9bab75d98
21 changed files with 2859 additions and 231 deletions

66
pom.xml
View File

@ -48,29 +48,29 @@
</developers>
<dependencyManagement>
<!-- <dependencies> -->
<!-- <dependency> -->
<!-- <groupId>org.gcube.distribution</groupId> -->
<!-- <artifactId>maven-portal-bom</artifactId> -->
<!-- <version>3.6.0</version> -->
<!-- <type>pom</type> -->
<!-- <scope>import</scope> -->
<!-- <exclusions> -->
<!-- <exclusion> -->
<!-- <groupId>com.google.gwt</groupId> -->
<!-- <artifactId>gwt-user</artifactId> -->
<!-- </exclusion> -->
<!-- <exclusion> -->
<!-- <groupId>com.google.gwt</groupId> -->
<!-- <artifactId>gwt-servlet</artifactId> -->
<!-- </exclusion> -->
<!-- <exclusion> -->
<!-- <groupId>com.google.gwt</groupId> -->
<!-- <artifactId>gwt-dev</artifactId> -->
<!-- </exclusion> -->
<!-- </exclusions> -->
<!-- </dependency> -->
<!-- </dependencies> -->
<!-- <dependencies> -->
<!-- <dependency> -->
<!-- <groupId>org.gcube.distribution</groupId> -->
<!-- <artifactId>maven-portal-bom</artifactId> -->
<!-- <version>3.6.0</version> -->
<!-- <type>pom</type> -->
<!-- <scope>import</scope> -->
<!-- <exclusions> -->
<!-- <exclusion> -->
<!-- <groupId>com.google.gwt</groupId> -->
<!-- <artifactId>gwt-user</artifactId> -->
<!-- </exclusion> -->
<!-- <exclusion> -->
<!-- <groupId>com.google.gwt</groupId> -->
<!-- <artifactId>gwt-servlet</artifactId> -->
<!-- </exclusion> -->
<!-- <exclusion> -->
<!-- <groupId>com.google.gwt</groupId> -->
<!-- <artifactId>gwt-dev</artifactId> -->
<!-- </exclusion> -->
<!-- </exclusions> -->
<!-- </dependency> -->
<!-- </dependencies> -->
</dependencyManagement>
<dependencies>
@ -96,20 +96,6 @@
<groupId>com.github.tdesjardins</groupId>
<artifactId>gwt-ol3</artifactId>
<version>8.0.0-gwt2_9</version>
<!-- <exclusions> -->
<!-- <exclusion> -->
<!-- <groupId>com.google.gwt</groupId> -->
<!-- <artifactId>gwt-user</artifactId> -->
<!-- </exclusion> -->
<!-- <exclusion> -->
<!-- <groupId>com.google.gwt</groupId> -->
<!-- <artifactId>gwt-servlet</artifactId> -->
<!-- </exclusion> -->
<!-- <exclusion> -->
<!-- <groupId>com.google.gwt</groupId> -->
<!-- <artifactId>gwt-dev</artifactId> -->
<!-- </exclusion> -->
<!-- </exclusions> -->
</dependency>
<dependency>
<groupId>com.github.gwtbootstrap</groupId>
@ -118,6 +104,12 @@
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.gcube.spatial.data</groupId>
<artifactId>geo-utility</artifactId>
<version>[1.0.0,2.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.gcube.common.portal</groupId>
<artifactId>portal-manager</artifactId>

View File

@ -1,7 +1,8 @@
package org.gcube.portlets.user.geoportaldataviewer.client;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OsmExample;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerOSM;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.GeonaDataViewMainPanel;
import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
@ -10,74 +11,104 @@ import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.event.logical.shared.ResizeEvent;
import com.google.gwt.event.logical.shared.ResizeHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.RootPanel;
// TODO: Auto-generated Javadoc
/**
* Entry point classes define <code>onModuleLoad()</code>.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Oct 27, 2020
*/
public class GeoportalDataViewer implements EntryPoint {
/**
* The message displayed to the user when the server cannot be reached or
* returns an error.
*/
private static final String SERVER_ERROR = "An error occurred while "
+ "attempting to contact the server. Please check your network "
+ "connection and try again.";
/**
* The message displayed to the user when the server cannot be reached or
* returns an error.
*/
private static final String SERVER_ERROR = "An error occurred while "
+ "attempting to contact the server. Please check your network " + "connection and try again.";
/**
* Create a remote service proxy to talk to the server-side Greeting service.
*/
private final GeoportalDataViewerServiceAsync greetingService = GWT.create(GeoportalDataViewerService.class);
public final static String APP_DIV = "geoportal-data-viewer";
/** The Constant APP_DIV. */
public final static String APP_DIV = "geoportal-data-viewer";
private boolean initialized = false;
private OsmExample osmExample = null;
private GeonaDataViewMainPanel mainPanel;
/**
* This is the entry point method.
*/
public void onModuleLoad() {
mainPanel = new GeonaDataViewMainPanel();
/** The ol map. */
private OpenLayerOSM olMap = null;
/** The main panel. */
private GeonaDataViewMainPanel mainPanel;
/** The param wms request. */
private String paramWmsRequest;
RootPanel.get(APP_DIV).add(mainPanel);
/** The param UUID. */
private String paramUUID;
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
osmExample = new OsmExample(mainPanel.getMapPanel().getElement().getId());
mainPanel.setMap(osmExample);
}
});
/** The param layer title. */
private String paramLayerTitle;
Window.addResizeHandler(new ResizeHandler() {
@Override
public void onResize(ResizeEvent event) {
GWT.log("onWindowResized width: "+event.getWidth()+" height: "+event.getHeight());
mainPanel.setMapHeight(event.getHeight()-200);
/** The layer manager. */
private LayerManager layerManager;
/**
* This is the entry point method.
*/
public void onModuleLoad() {
mainPanel = new GeonaDataViewMainPanel();
RootPanel.get(APP_DIV).add(mainPanel);
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
olMap = new OpenLayerOSM(mainPanel.getMapPanel().getElement().getId());
layerManager = new LayerManager(olMap);
mainPanel.setMap(olMap);
}
});
Window.addResizeHandler(new ResizeHandler() {
@Override
public void onResize(ResizeEvent event) {
GWT.log("onWindowResized width: " + event.getWidth() + " height: " + event.getHeight());
mainPanel.setMapHeight(event.getHeight() - 200);
}
});
paramWmsRequest = Window.Location.getParameter(GeoportalDataViewerConstants.GET_WMS_PARAMETER);
paramUUID = Window.Location.getParameter(GeoportalDataViewerConstants.GET_UUID_PARAMETER);
paramLayerTitle = Window.Location.getParameter(GeoportalDataViewerConstants.GET_LAYER_TITLE);
GWT.log(GeoportalDataViewerConstants.GET_WMS_PARAMETER + " = " + paramWmsRequest);
GWT.log(GeoportalDataViewerConstants.GET_UUID_PARAMETER + " = " + paramUUID);
GWT.log(GeoportalDataViewerConstants.GET_LAYER_TITLE + " = " + paramLayerTitle);
if (paramWmsRequest != null && !paramWmsRequest.isEmpty()) {
try {
//wmsRequestConverter.addRequestToGisViewer(paramWmsRequest, paramLayerTitle, paramUUID);
//FIND BASE URL
int indexStart = paramWmsRequest.indexOf("?");
String url;
if(indexStart>=0){
url = paramWmsRequest.substring(0, indexStart); //get only base uri
url = url.trim(); //string trim
}else{
Window.alert("Bad wms request '?' not found!");
// throw new Exception("Bad server request '?' not found!");
}
String layerName = URLUtil.getValueOfParameter("layers", paramWmsRequest);
String displayName = paramLayerTitle==null || paramLayerTitle.isEmpty()?layerName:paramLayerTitle;
layerManager.addLayerByWmsRequest(displayName, layerName, paramWmsRequest, false, false, paramUUID, true);
} catch (Exception e) {
GWT.log("An error occurred on adding wmsrequest :" + paramWmsRequest);
e.printStackTrace();
}
}
});
greetingService.greetServer("SERVICE IMPL", new AsyncCallback<String>() {
@Override
public void onSuccess(String result) {
}
@Override
public void onFailure(Throwable caught) {
}
});
}
}
}

View File

@ -1,10 +1,21 @@
package org.gcube.portlets.user.geoportaldataviewer.client;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayersMapParameters;
public class GeoportalDataViewerConstants {
public static final String EPSG_4326 = "EPSG:4326";
public static final String EPSG_3857 = "EPSG:3857";
public static final String MAP_DIV = "map";
public static final String GET_WMS_PARAMETER = "wmsrequest";
public static final String GET_UUID_PARAMETER = "uuid";
public static final String GET_LAYER_TITLE = "layertitle";
public static final String GET_MAX_ZOOM_LEVEL = OpenLayersMapParameters.OL_MAP_PARAM.maxzoomlevel.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 enum LayerType {RASTER_BASELAYER, FEATURE_TYPE};
}

View File

@ -1,5 +1,7 @@
package org.gcube.portlets.user.geoportaldataviewer.client;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoInformationForWMSRequest;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@ -8,5 +10,7 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
*/
@RemoteServiceRelativePath("geoportaldataviewerservice")
public interface GeoportalDataViewerService extends RemoteService {
String greetServer(String name) throws IllegalArgumentException;
GeoInformationForWMSRequest parseWmsRequest(String wmsRequest, String layerName) throws Exception;
}

View File

@ -1,17 +1,13 @@
package org.gcube.portlets.user.geoportaldataviewer.client;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoInformationForWMSRequest;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
public interface GeoportalDataViewerServiceAsync
{
/**
* GWT-RPC service asynchronous (client-side) interface
* @see org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerService
*/
void greetServer( java.lang.String name, AsyncCallback<java.lang.String> callback );
/**
* Utility class to get the RPC Async interface from client-side code
@ -34,4 +30,6 @@ public interface GeoportalDataViewerServiceAsync
// Utility class should not be instantiated
}
}
void parseWmsRequest(String wmsRequest, String layerName, AsyncCallback<GeoInformationForWMSRequest> callback);
}

View File

@ -0,0 +1,185 @@
package org.gcube.portlets.user.geoportaldataviewer.client;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.LayerType;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerOSM;
import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil;
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.ZAxis;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
/**
* The Class LayerManager.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Oct 27, 2020
*/
public class LayerManager {
/** The ol map. */
private OpenLayerOSM olMap;
/** The layer items. */
private List<LayerItem> layerItems = new ArrayList<LayerItem>();
/**
* Instantiates a new layer manager.
*
* @param olMap the ol map
*/
public LayerManager(OpenLayerOSM olMap) {
this.olMap = olMap;
}
/**
* Adds the layer by wms.
*
* @param layerTitle the layer title
* @param layerName the layer name
* @param wmsRequest the wms request
* @param isBase the is base
* @param UUID the uuid
*/
public void addLayerByWms(String layerTitle, String layerName, String wmsRequest, boolean isBase, String UUID) {
boolean displayInLayerSwitcher = false;
if(isBase)
displayInLayerSwitcher = true;
addLayerByWmsRequest(layerTitle, layerName, wmsRequest, isBase, displayInLayerSwitcher, UUID, true);
}
/**
* Adds the layer by wms request.
*
* @param layerTitle the layer title
* @param layerName the layer name
* @param wmsRequest the wms request
* @param isBase the is base
* @param displayInLayerSwitcher the display in layer switcher
* @param UUID the uuid
* @param onTop the on top
*/
public void addLayerByWmsRequest(final String layerTitle, final String layerName, final String wmsRequest, final boolean isBase,final boolean displayInLayerSwitcher, final String UUID, final boolean onTop) {
// final LayoutContainer westPanel = (LayoutContainer) layersPanel.getParent();
//
// if(layersPanel.getLayerItems().size()==0)
// westPanel.mask("Adding..."+layerName, "x-mask-loading");
// else
// layersPanel.mask("Adding..."+layerName, "x-mask-loading");
final LayerType featureType = isBase?LayerType.RASTER_BASELAYER:LayerType.FEATURE_TYPE;
// Info.display("Adding Layer", layerName);
GeoportalDataViewerServiceAsync.Util.getInstance().parseWmsRequest(wmsRequest, layerName, new AsyncCallback<GeoInformationForWMSRequest>() {
@Override
public void onFailure(Throwable caught) {
Window.alert(caught.getMessage());
}
@Override
public void onSuccess(GeoInformationForWMSRequest result) {
GWT.log("Add Layer By WMS: "+result.getMapWMSNoStandard() + ", and isNCWMS? "+result.isNcWMS());
addLayerByWms(featureType, layerTitle, layerName, result.getWmsRequest(), result.getBaseWmsServiceHost(), true, isBase, displayInLayerSwitcher, (ArrayList<String>) result.getStyles().getGeoStyles(), result.getWmsRequest(), false, result.getMapWMSNoStandard(), result.isNcWMS(), UUID, result.getZAxis());
}
});
}
/**
* Adds the layer by wms.
*
* @param layerType the layer type
* @param layerTitle the layer title
* @param layerName the layer name
* @param layerURL the layer URL
* @param mapServerHost the map server host
* @param isExternal the is external
* @param isBase the is base
* @param displayInLayerSwitcher the display in layer switcher
* @param styles the styles
* @param serverWmsRequest the server wms request
* @param onTop the on top
* @param wmsNotStandardParams the wms not standard params
* @param isNcWms the is nc wms
* @param UUID the uuid
* @param zAxis the z axis
*/
private void addLayerByWms(LayerType layerType, String layerTitle, String layerName, String layerURL, String mapServerHost, boolean isExternal, boolean isBase, boolean displayInLayerSwitcher, ArrayList<String> styles, String serverWmsRequest, boolean onTop, HashMap<String, String> wmsNotStandardParams, boolean isNcWms, String UUID, ZAxis zAxis) {
// GWT.log("Add addLayerByWms 1");
LayerItem l = new LayerItem();
l.setBaseLayer(isBase);
l.setTitle(layerTitle);
l.setName(layerName);
l.setUrl(layerURL);
l.setMapServerHost(mapServerHost);
//l.setExternal(isExternal);
l.setOpacity(1d);
l.setBuffer(2);
l.setServerWmsRequest(serverWmsRequest);
l.setWmsNotStandardParams(wmsNotStandardParams);
l.setNcWms(isNcWms);
l.setUUID(UUID);
l.setZAxis(zAxis);
switch (layerType) {
//TODO IMPLEMENT THIS CASE
case RASTER_BASELAYER:
// l.setHasLegend(false);
l.setBaseLayer(true);
l.setTrasparent(false);
l.setClickData(false);
break;
case FEATURE_TYPE:
//CASE FEATURE TYPE
l.setBaseLayer(false);
l.setClickData(true);
l.setTrasparent(true);
break;
}
GWT.log("styles "+styles);
if(styles!=null && styles.size()>0){
l.setHasLegend(true);
l.setDefaultStyle(styles.get(0));
l.setStyle(styles.get(0));
l.setStyles(styles);
}else{
String style = URLUtil.getValueOfParameter("styles", serverWmsRequest);
if(style!=null){ //CASE OF STYLE ="";
//TENTATIVE TO GET LEGEND
l.setHasLegend(true);
}
}
GWT.log("Built layer: "+l);
layerItems.add(l);
olMap.addWMSLayer(l.getMapServerHost(), layerName);
// openLayersMap.addLayerItemByWms(l, displayInLayerSwitcher);
// layersPanel.addLayerItems(layerItems, onTop);
// layersPanel.updateLayersOrder();
}
}

View File

@ -1,11 +1,12 @@
package org.gcube.portlets.user.geoportaldataviewer.client.gis;
import java.net.MalformedURLException;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.Window;
import ol.Collection;
import ol.Coordinate;
@ -38,26 +39,44 @@ import ol.source.Osm;
import ol.source.Vector;
import ol.source.XyzOptions;
// TODO: Auto-generated Javadoc
/**
* Example with OSM layer and tile debug layer.
*
* @author Tino Desjardins
* The Class OpenLayerOSM.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Oct 27, 2020
*/
public class OsmExample {
public class OpenLayerOSM {
/** The map. */
private Map map;
/** The view. */
private View view;
/** The view options. */
private ViewOptions viewOptions = OLFactory.createOptions();
/** The projection options. */
private ProjectionOptions projectionOptions = OLFactory.createOptions();
/** The point draw. */
private Draw pointDraw;
/** The popup overlay. */
private Overlay popupOverlay;
/**
* Instantiates a new open layer OSM.
*
* @param divTargetId the div target id
*/
/* (non-Javadoc)
* @see de.desjardins.ol3.demo.client.example.Example#show()
*/
public OsmExample(String divTargetId) {
public OpenLayerOSM(String divTargetId) {
// create a OSM-layer
XyzOptions osmSourceOptions = OLFactory.createOptions();
@ -67,22 +86,7 @@ public class OsmExample {
osmLayerOptions.setSource(osmSource);
Tile osmLayer = new Tile(osmLayerOptions);
// create debug layer
// TileDebugOptions tileDebugOptions = OLFactory.createOptions();
// tileDebugOptions.setProjection(GeoportalDataViewerConstants.EPSG_4326);
// tileDebugOptions.setTileGrid(osmSource.getTileGrid());
//TileDebug tileDebugSource = new TileDebug(tileDebugOptions);
LayerOptions tileDebugLayerOptions = OLFactory.createOptions();
//tileDebugLayerOptions.setSource(tileDebugSource);
//Tile tileDebugLayer = new Tile(tileDebugLayerOptions);
// create a projection
projectionOptions.setCode(GeoportalDataViewerConstants.EPSG_3857);
projectionOptions.setUnits("m");
@ -101,7 +105,6 @@ public class OsmExample {
view.setCenter(transformedCenterCoordinate);
view.setZoom(5);
// create the map
MapOptions mapOptions = OLFactory.createOptions();
mapOptions.setTarget(divTargetId);
@ -142,9 +145,13 @@ public class OsmExample {
map.addInteraction(new KeyboardPan());
map.addInteraction(new KeyboardZoom());
addWMSLayer();
}
/**
* Adds the popup closer handelr.
*
* @param popupOverlay the popup overlay
*/
private void addPopupCloserHandelr(Overlay popupOverlay) {
Element elPopupCloser = DOM.getElementById("popup-closer");
Event.sinkEvents(elPopupCloser, Event.ONCLICK);
@ -160,6 +167,12 @@ public class OsmExample {
});
}
/**
* Handler popu closer.
*
* @param divId the div id
* @param overlayId the overlay id
*/
public static native void handlerPopuCloser(String divId, String overlayId) /*-{
var closer = $doc.getElementById(divId);
var overlay = $doc.getElementById(overlayId);
@ -171,13 +184,17 @@ public class OsmExample {
}-*/;
public void addWMSLayer() {
/**
* Adds the WMS layer.
* @throws MalformedURLException
*/
public void addWMSLayer(String mapServerHost, String layerName) {
ImageWmsParams imageWMSParams = OLFactory.createOptions();
imageWMSParams.setLayers("concessioni_conf:centroids_concessioni");
imageWMSParams.setLayers(layerName);
ImageWmsOptions imageWMSOptions = OLFactory.createOptions();
imageWMSOptions.setUrl("https://geona-proto.d4science.org/geoserver/concessioni_conf/wms");
imageWMSOptions.setUrl(mapServerHost);
imageWMSOptions.setParams(imageWMSParams);
//imageWMSOptions.setRatio(1.5f);
@ -194,6 +211,11 @@ public class OsmExample {
}
/**
* Adds the point vector source.
*
* @return the draw
*/
public Draw addPointVectorSource() {
if(pointDraw==null)
initPointInteraction();
@ -202,6 +224,9 @@ public class OsmExample {
return pointDraw;
}
/**
* Inits the point interaction.
*/
private void initPointInteraction() {
Vector vectorSource = new Vector();
DrawOptions drawOptions = new DrawOptions();
@ -213,10 +238,18 @@ public class OsmExample {
pointDraw = new Draw(drawOptions);
}
/**
* Removes the interaction.
*
* @param interaction the interaction
*/
public void removeInteraction(Interaction interaction) {
map.removeInteraction(interaction);
}
/**
* Removes the interactions.
*/
public void removeInteractions() {
Collection<Interaction> interactions = map.getInteractions();
if(interactions!=null) {
@ -228,6 +261,11 @@ public class OsmExample {
}
}
/**
* Adds the extent interaction.
*
* @return the extent
*/
public Extent addExtentInteraction() {
ExtentOptions extentOptions = new ExtentOptions();
extentOptions.setWrapX(false);
@ -241,6 +279,12 @@ public class OsmExample {
}
/**
* Adds the overlay.
*
* @param element the element
* @return the overlay
*/
private Overlay addOverlay(Element element) {
/**
* Create an overlay to anchor the popup to the map.

View File

@ -0,0 +1,56 @@
package org.gcube.portlets.user.geoportaldataviewer.client.gis;
import java.util.HashMap;
import java.util.Map;
/**
* The Class OpenLayersMapParameters.
*
* @author Francesco Mangiacrapa at ISTI-CNR Pisa (Italy)
* May 7, 2020
*/
public class OpenLayersMapParameters {
private Map<String,String> mapToInitOLMap = new HashMap<String, String>();
public enum OL_MAP_PARAM {maxzoomlevel,zoom,centermap}
/**
* Instantiates a new gis viewer map parameters.
*/
public OpenLayersMapParameters() {
}
/**
* Adds the parameter.
*
* @param key the key
* @param value the value
*/
public void addParameter(String key, String value) {
mapToInitOLMap.put(key, value);
}
/**
* Adds the parameter.
*
* @param key the key
* @param value the value
*/
public void addParameter(OL_MAP_PARAM key, String value) {
if(key!=null)
mapToInitOLMap.put(key.name(), value);
}
/**
* Gets the pameter.
*
* @param key the key
* @return the pameter
*/
public String getPameter(String key) {
return mapToInitOLMap.get(key);
}
}

View File

@ -1,6 +1,6 @@
package org.gcube.portlets.user.geoportaldataviewer.client.ui;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OsmExample;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerOSM;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.Tab;
@ -30,7 +30,7 @@ public class GeonaDataViewMainPanel extends Composite {
private MapPanel mapPanel;
private OsmExample map;
private OpenLayerOSM map;
public GeonaDataViewMainPanel() {
initWidget(uiBinder.createAndBindUi(this));
@ -51,7 +51,7 @@ public class GeonaDataViewMainPanel extends Composite {
return mapPanel;
}
public void setMap(OsmExample map) {
public void setMap(OpenLayerOSM map) {
this.map = map;
}

View File

@ -0,0 +1,31 @@
package org.gcube.portlets.user.geoportaldataviewer.client.util;
public class URLUtil {
/**
* Gets the value of parameter.
*
* @param paramName the param name
* @param url the url
* @return the value of parameter
*/
public static String getValueOfParameter(String paramName, String url) {
// logger.trace("finding: "+wmsParam +" into "+url);
int index = url.toLowerCase().indexOf(paramName.toLowerCase()+"="); //ADDING CHAR "=" IN TAIL TO BE SECURE IT IS A PARAMETER
// logger.trace("start index of "+wmsParam+ " is: "+index);
String value = "";
if(index > -1){
int start = index + paramName.length()+1; //add +1 for char '='
String sub = url.substring(start, url.length());
int indexOfSeparator = sub.indexOf("&");
int end = indexOfSeparator!=-1?indexOfSeparator:sub.length();
value = sub.substring(0, end);
}else
return null;
// logger.trace("return value: "+value);
return value;
}
}

View File

@ -1,7 +1,19 @@
package org.gcube.portlets.user.geoportaldataviewer.server;
import java.util.HashMap;
import java.util.Map;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerService;
import org.gcube.portlets.user.geoportaldataviewer.shared.FieldVerifier;
import org.gcube.portlets.user.geoportaldataviewer.server.gis.WMSUrlValidator;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoInformationForWMSRequest;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.Styles;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.ZAxis;
import org.gcube.spatial.data.geoutility.GeoNcWMSMetadataUtility;
import org.gcube.spatial.data.geoutility.bean.LayerStyles;
import org.gcube.spatial.data.geoutility.bean.LayerZAxis;
import org.gcube.spatial.data.geoutility.bean.WmsParameters;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
@ -11,26 +23,9 @@ import com.google.gwt.user.server.rpc.RemoteServiceServlet;
@SuppressWarnings("serial")
public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet implements
GeoportalDataViewerService {
public String greetServer(String input) throws IllegalArgumentException {
// Verify that the input is valid.
if (!FieldVerifier.isValidName(input)) {
// If the input is not valid, throw an IllegalArgumentException back to
// the client.
throw new IllegalArgumentException(
"Name must be at least 4 characters long");
}
String serverInfo = getServletContext().getServerInfo();
String userAgent = getThreadLocalRequest().getHeader("User-Agent");
// Escape data from the client to avoid cross-site script vulnerabilities.
input = escapeHtml(input);
userAgent = escapeHtml(userAgent);
return "Hello, " + input + "!<br><br>I am running " + serverInfo
+ ".<br><br>It looks like you are using:<br>" + userAgent;
}
/** The Constant LOG. */
private static final Logger LOG = LoggerFactory.getLogger(GeoportalDataViewerServiceImpl.class);
/**
* Escape an html string. Escaping data received from the client helps to
@ -46,4 +41,52 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
return html.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(
">", "&gt;");
}
@Override
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 {
WMSUrlValidator validator = new WMSUrlValidator(wmsRequest, layerName);
String wmsServiceHost = validator.getWmsServiceHost();
String validWMSRequest = validator.parseWMSRequest(true, true);
layerName = validator.getLayerName();
String versionWms = validator.getValueOfParsedWMSParameter(WmsParameters.VERSION);
String crs = validator.getValueOfParsedWMSParameter(WmsParameters.CRS);
//
HashMap<String, String> mapWmsNotStandard = new HashMap<String, String>();
if(validator.getMapWmsNoStandardParams()!=null){
mapWmsNotStandard.putAll(validator.getMapWmsNoStandardParams());
}
//
GeoNcWMSMetadataUtility geoGS = new GeoNcWMSMetadataUtility(validWMSRequest, 4000);
//STYLES
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 GeoInformationForWMSRequest(wmsServiceHost, validWMSRequest, layerName, versionWms, crs, mapWmsNotStandard, styles, styles.isNcWms(), zAxis);
}
catch (Exception e) {
String msg = "An error occurred during wms request validation for layer: "+layerName;
LOG.error(msg,e);
throw new Exception(msg);
}
}
}

View File

@ -0,0 +1,402 @@
package org.gcube.portlets.user.geoportaldataviewer.server.gis;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.gcube.spatial.data.geoutility.GeoWmsServiceUtility;
import org.gcube.spatial.data.geoutility.bean.WmsParameters;
import org.gcube.spatial.data.geoutility.util.HttpRequestUtil;
import org.gcube.spatial.data.geoutility.wms.WmsUrlValidator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class GisViewerWMSUrlValidator.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Jan 28, 2016
*/
public class WMSUrlValidator {
public static final String GEOSERVER = "/geoserver";
private static final String WMS = "wms";
private static final String OWS = "ows";
private HashMap<String, String> parametersValue = new HashMap<String, String>();
private String wmsRequestURI;
private String wmsServiceHost;
private String layerName;
private String wmsNoStandardParameters = "";
private Map<String, String> mapWmsNoStandardParams;
private WmsUrlValidator urlValidator;
private static final Logger LOG = LoggerFactory.getLogger(WMSUrlValidator.class);
/**
* Instantiates a new gis viewer wms url validator.
*
* @param wmsRequest the full url
* @param layerName the layer name
* @throws Exception the exception
*/
public WMSUrlValidator(String wmsRequest, String layerName) throws Exception{
if(wmsRequest==null || wmsRequest.isEmpty())
throw new Exception("WMS request is null or empty");
this.wmsRequestURI = wmsRequest.trim();
boolean isOwsService = GeoWmsServiceUtility.isOWSSerice(this.wmsRequestURI);
WebMapServerHost webMapServerHost;
//IS WMS?
if(GeoWmsServiceUtility.isWMSService(wmsRequestURI)){
LOG.trace("found "+GeoWmsServiceUtility.SERVICE_WMS+" in wms request: "+wmsRequestURI);
webMapServerHost = getWebMapServerHost(wmsRequestURI);
}else
throw new Exception("WMS service not found for layer: "+layerName);
//VALIDATION WMS
String baseWmsService = webMapServerHost.getHost();
//IS OWS OR WMS?
this.wmsServiceHost = appendWmsServiceToBaseUrl(wmsRequest.substring(0, wmsRequest.indexOf("?")),isOwsService);
this.layerName = layerName;
try {
//VALIDATE WMS SERVICE FOR WEB MAP SERVER
if(!HttpRequestUtil.urlExists(this.wmsServiceHost, true)){
LOG.info("baseWmsServiceUrl: "+wmsServiceHost +" is not a geoserver, setting as input base wms server: "+baseWmsService);
this.wmsServiceHost = baseWmsService;
}
} catch (Exception e) {
LOG.error("error on validating geoserver wms service: "+e);
LOG.info("setting baseWmsService as input base wms server: "+baseWmsService);
this.wmsServiceHost = baseWmsService;
}
//VALIDATION FOR THREDDS - FIND LAYER NAME INTO WMS PATH
if(this.layerName==null || this.layerName.isEmpty()){
this.layerName = WmsUrlValidator.getValueOfParameter(WmsParameters.LAYERS, wmsRequest);
if(this.layerName==null || layerName.isEmpty())
throw new Exception("Layer name is null or empty");
}
parametersValue.put(WmsParameters.LAYERS.getParameter(), this.layerName);
}
/**
* Append wms service to base url.
*
* @param url the url
* @param isOwsServer the is ows server
* @return the string
*/
public String appendWmsServiceToBaseUrl(String url, boolean isOwsServer){
if(url.contains("/"+WMS) || url.contains("/"+OWS))
return url;
if(url.lastIndexOf("/") != url.length()){
url+="/";
}
if(isOwsServer)
return url+=OWS;
else
return url+=WMS;
}
/**
* Method: getFullWmsUrlRequest
* Create a correct wms url request
* Returns:
* {String}.
*
* @param returnEmptyParameter if true the wms url returned contains also wms parameter with empty value, none otherwise.
* and mandatory wms parameters that does not found are filled with empty values
* @param fillEmptyParameterAsDefault the fill empty parameter as default
* @return a correct wms url request in formatted string like this:
* "wmsserver?key1=value1&key2=value2&key3=value3"
*/
public String parseWMSRequest(boolean returnEmptyParameter, boolean fillEmptyParameterAsDefault){
urlValidator = new org.gcube.spatial.data.geoutility.wms.WmsUrlValidator(wmsRequestURI);
String fullWmsUrlBuilded;
try {
fullWmsUrlBuilded = urlValidator.parseWmsRequest(returnEmptyParameter, fillEmptyParameterAsDefault);
parametersValue.putAll(urlValidator.getMapWmsParameters());
String ln = parametersValue.get(WmsParameters.LAYERS.name());
LOG.debug("Comparing layer name from Wms request: "+ln +", with OnLineResource layerName: "+this.layerName);
if(ln==null || ln.isEmpty() || ln.compareTo(this.layerName)!=0){
LOG.info("Layer name into wms request is different to OnLineResource layers name, replacing layer name: "+this.layerName);
parametersValue.put(WmsParameters.LAYERS.getParameter(), this.layerName);
urlValidator.getMapWmsParameters().put(org.gcube.spatial.data.geoutility.bean.WmsParameters.LAYERS.getParameter(), this.layerName);
fullWmsUrlBuilded = org.gcube.spatial.data.geoutility.wms.WmsUrlValidator.setValueOfParameter(org.gcube.spatial.data.geoutility.bean.WmsParameters.LAYERS, fullWmsUrlBuilded, this.layerName, true);
}
// logger.trace("parametersValue: "+parametersValue);
mapWmsNoStandardParams = new HashMap<String, String>(urlValidator.getMapWmsNoStandardParams().size());
mapWmsNoStandardParams.putAll(urlValidator.getMapWmsNoStandardParams());
wmsNoStandardParameters = urlValidator.getWmsNoStandardParameters();
}
catch (Exception e) {
LOG.error("An error occurred during wms uri build, returning uri: "+wmsRequestURI, e);
fullWmsUrlBuilded = wmsRequestURI;
}
LOG.trace("GisViewerWMSUrlValidator parseWMSRequest returning full wms url: "+fullWmsUrlBuilded);
return fullWmsUrlBuilded;
}
/**
* Gets the web map server host.
*
* @param wmsRequest the wms request
* @return the web map server host, (geoserver URI or the wmsRequest substring from start to index of '?' char (if exists))
*/
public WebMapServerHost getWebMapServerHost(String wmsRequest){
WebMapServerHost webMapServerHost = new WebMapServerHost();
if(wmsRequest==null)
return webMapServerHost; //uri is empty
int end = wmsRequest.toLowerCase().lastIndexOf("?");
if(end==-1){
LOG.trace("char ? not found in geoserver uri, return: "+wmsRequest);
return webMapServerHost; //uri is empty
}
String webMapServerBaseURL = wmsRequest.substring(0, wmsRequest.toLowerCase().lastIndexOf("?"));
int index = webMapServerBaseURL.lastIndexOf(GEOSERVER);
if(index>-1){ //FOUND the string GEOSERVER into URL
LOG.trace("found geoserver string: "+GEOSERVER+" in "+webMapServerBaseURL);
//THERE IS SCOPE?
int lastSlash = webMapServerBaseURL.lastIndexOf("/");
int includeGeoserverString = index+GEOSERVER.length();
int endUrl = lastSlash>includeGeoserverString?lastSlash:includeGeoserverString;
LOG.trace("indexs - lastSlash: ["+lastSlash+"], includeGeoserverString: ["+includeGeoserverString+"], endUrl: ["+endUrl+"]");
int startScope = includeGeoserverString+1<endUrl?includeGeoserverString+1:endUrl; //INCLUDE SLASH
String scope = webMapServerBaseURL.substring(startScope, endUrl);
LOG.trace("geoserver url include scope: "+webMapServerBaseURL.substring(includeGeoserverString, endUrl));
webMapServerHost.setHost(webMapServerBaseURL.substring(0, endUrl));
webMapServerHost.setScope(scope);
return webMapServerHost;
}else{
LOG.trace("the string 'geoserver' not found in "+webMapServerBaseURL);
// GET LAST INDEX OF '/' AND CONCATENATE GEOSERVER
String urlConn = webMapServerBaseURL.substring(0, webMapServerBaseURL.lastIndexOf("/"))+GEOSERVER;
LOG.trace("tentative concatenating string 'geoserver' at http url "+urlConn);
try {
if(HttpRequestUtil.urlExists(urlConn, false)){
LOG.trace("url: "+urlConn+" - open a connection, return "+urlConn);
webMapServerHost.setHost(urlConn);
return webMapServerHost;
}
else
LOG.trace("url: "+urlConn+" - not open a connection");
} catch (Exception e) {
LOG.error("url connection is wrong at :"+urlConn);
}
String uriWithoutParameters = wmsRequest.substring(0, end);
LOG.trace("url connection, returned: "+uriWithoutParameters);
webMapServerHost.setHost(uriWithoutParameters);
return webMapServerHost;
}
}
/**
* Gets the wms service host.
*
* @return the wms service host
*/
public String getWmsServiceHost() {
return wmsServiceHost;
}
/**
* Gets the url validator.
*
* @return the urlValidator
*/
public org.gcube.spatial.data.geoutility.wms.WmsUrlValidator getUrlValidator() {
return urlValidator;
}
/**
* Gets the wms no standard parameters.
*
* @return the wms no standard parameters
*/
public String getWmsNoStandardParameters() {
return wmsNoStandardParameters;
}
/**
* Gets the value of parsed wms parameter.
*
* @param parameter the parameter
* @return the value of parsed wms parameter parsed from wms request.
*/
public String getValueOfParsedWMSParameter(WmsParameters parameter){
return parametersValue.get(parameter.getParameter());
}
/**
* Gets the value of parameter.
*
* @param wmsParam the wms param
* @param wmsUrlParameters the wms url parameters
* @return the value of parameter
*/
public static String getValueOfParameter(WmsParameters wmsParam, String wmsUrlParameters){
return WmsUrlValidator.getValueOfParameter(wmsParam, wmsUrlParameters);
}
/**
* Sets the value of parameter.
*
* @param wmsParam the wms param
* @param wmsUrlParameters the wms url parameters
* @param newValue the new value
* @param addIfNotExists the add if not exists
* @return the string
*/
public static String setValueOfParameter(WmsParameters wmsParam, String wmsUrlParameters, String newValue, boolean addIfNotExists){
return WmsUrlValidator.setValueOfParameter(wmsParam, wmsUrlParameters, newValue, addIfNotExists);
}
/**
* Gets the layer name.
*
* @return the layer name
*/
public String getLayerName() {
return layerName;
}
/**
* Gets the styles as list.
*
* @return the styles as list
*/
public List<String> getStylesAsList() {
List<String> listStyles = new ArrayList<String>();
String styles = getValueOfParsedWMSParameter(WmsParameters.STYLES);
if(styles!=null && !styles.isEmpty()){
String[] arrayStyle = styles.split(",");
for (String style : arrayStyle) {
if(style!=null && !style.isEmpty())
listStyles.add(style);
}
}
return listStyles;
}
/**
* Gets the map wms no standard params.
*
* @return the map wms no standard params
*/
public Map<String, String> getMapWmsNoStandardParams() {
return mapWmsNoStandardParams;
}
/**
* The main method.
*
* @param args the arguments
*/
public static void main(String[] args) {
// String baseGeoserverUrl = "http://repoigg.services.iit.cnr.it:8080/geoserver/IGG/ows";
// String baseGeoserverUrl = "http://www.fao.org/figis/geoserver/species";
// String fullPath = "http://www.fao.org/figis/geoserver/species?SERVICE=WMS&BBOX=-176.0,-90.0,180.0,90&styles=Species_prob, puppa&layers=layerName&FORMAT=image/gif";
// String fullPath = "http://repoigg.services.iit.cnr.it:8080/geoserver/IGG/ows?service=wms&version=1.1.0&request=GetMap&layers==IGG:area_temp_1000&width=676&height=330&srs=EPSG:4326&crs=EPSG:4326&format=application/openlayers&bbox=-85.5,-180.0,90.0,180.0";
// String baseGeoserverUrl = "http://thredds-d-d4s.d4science.org/thredds/wms/public/netcdf/test20.nc";
// String fullPath = "http://thredds-d-d4s.d4science.org/thredds/wms/public/netcdf/test20.nc?service=wms&version=1.3.0&request=GetMap&layers=analyzed_field&bbox=-85.0,-180.0,85.0,180.0&styles=&width=640&height=480&srs=EPSG:4326&CRS=EPSG:4326&format=image/png&COLORSCALERANGE=auto";
// WmsUrlValidator validator = new WmsUrlValidator(baseGeoserverUrl, fullPath , "", false);
// logger.trace("base wms service url: "+validator.getBaseWmsServiceUrl());
// logger.trace("layer name: "+validator.getLayerName());
// logger.trace("full wms url: "+validator.getFullWmsUrlRequest(false, true));
// logger.trace("style: "+validator.getStyles());
// logger.trace("not standard parameter: "+validator.getWmsNotStandardParameters());
// String[] arrayStyle = validator.getStyles().split(",");
//
// if(arrayStyle!=null && arrayStyle.length>0){
//
// for (String style : arrayStyle) {
// if(style!=null && !style.isEmpty())
//
// System.out.println("Style: "+style.trim());
// }
// }
//
// String fullPath = "http://thredds-d-d4s.d4science.org/thredds/wms/public/netcdf/test20.nc?service=wms&version=1.3.0&request=GetMap&layers=analyzed_field&bbox=-85.0,-180.0,85.0,180.0&styles=&width=640&height=480&srs=EPSG:4326&CRS=EPSG:4326&format=image/png&COLORSCALERANGE=auto";
//
// WmsGeoExplorerUrlValidator validator = new WmsGeoExplorerUrlValidator("http://thredds-d-d4s.d4science.org/thredds/wms/public/netcdf/test20.nc", fullPath , "", false);
// validator.getFullWmsUrlRequest(false,true);
//
// System.out.println(validator.getWmsNoStandardParameters());
// System.out.println(validator.getMapWmsNoStandardParams());
// fullPath = WmsUrlValidator.setValueOfParameter(WmsParameters.STYLES, fullPath, "123", true);
//
// MapPreviewGenerator map = new MapPreviewGenerator();
// fullPath = map.buildWmsRequestMapPreview(fullPath, "-85.0,-180.0,85.0,180.0");
// System.out.println(fullPath);
String wmsRequest = "http://geoserver-dev.d4science-ii.research-infrastructures.eu/geoserver/wms?CRS=EPSG:4326&BBOX=-85.5,-180.0,90.0,180.0&VERSION=1.1.0&FORMAT=application/openlayers&SERVICE=wms&HEIGHT=330&LAYERS=aquamaps:lsoleasolea20130716162322254cest&REQUEST=GetMap&STYLES=Species_prob&SRS=EPSG:4326&WIDTH=676";
// String wmsRequest = "http://thredds-d-d4s.d4science.org/thredds/wms/public/netcdf/test20.nc?service=wms&version=1.3.0&request=GetMap&layers=analyzed_field&styles=&width=640&height=480&srs=EPSG:4326&CRS=EPSG:4326&format=image/png&COLORSCALERANGE=auto&bbox=-85.0,-180.0,85.0,180.0";
WmsUrlValidator wms;
try {
wms = new WmsUrlValidator(wmsRequest);
System.out.println("Returned wms: "+wms.toString());
}
catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,85 @@
/**
*
*/
package org.gcube.portlets.user.geoportaldataviewer.server.gis;
/**
* The Class GeoserverBaseUri.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Jan 28, 2016
*/
public class WebMapServerHost {
private String host = "";
private String scope = "";
/**
* Instantiates a new geoserver base uri.
*/
public WebMapServerHost() {
}
/**
* Instantiates a new geoserver base uri.
*
* @param host the base url
* @param scope the scope
*/
public WebMapServerHost(String host, String scope) {
this.host = host;
this.scope = scope;
}
/**
* @return the host
*/
public String getHost() {
return host;
}
/**
* @return the scope
*/
public String getScope() {
return scope;
}
/**
* @param host the host to set
*/
public void setHost(String host) {
this.host = host;
}
/**
* @param scope the scope to set
*/
public void setScope(String scope) {
this.scope = scope;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("WebMapServerHost [host=");
builder.append(host);
builder.append(", scope=");
builder.append(scope);
builder.append("]");
return builder.toString();
}
}

View File

@ -1,42 +0,0 @@
package org.gcube.portlets.user.geoportaldataviewer.shared;
/**
* <p>
* FieldVerifier validates that the name the user enters is valid.
* </p>
* <p>
* This class is in the <code>shared</code> packing because we use it in both
* the client code and on the server. On the client, we verify that the name is
* valid before sending an RPC request so the user doesn't have to wait for a
* network round trip to get feedback. On the server, we verify that the name is
* correct to ensure that the input is correct regardless of where the RPC
* originates.
* </p>
* <p>
* When creating a class that is used on both the client and the server, be sure
* that all code is translatable and does not use native JavaScript. Code that
* is note translatable (such as code that interacts with a database or the file
* system) cannot be compiled into client side JavaScript. Code that uses native
* JavaScript (such as Widgets) cannot be run on the server.
* </p>
*/
public class FieldVerifier {
/**
* Verifies that the specified name is valid for our service.
*
* In this example, we only require that the name is at least four
* characters. In your application, you can use more complex checks to ensure
* that usernames, passwords, email addresses, URLs, and other fields have the
* proper syntax.
*
* @param name the name to validate
* @return true if valid, false if invalid
*/
public static boolean isValidName(String name) {
if (name == null) {
return false;
}
return name.length() > 3;
}
}

View File

@ -0,0 +1,156 @@
package org.gcube.portlets.user.geoportaldataviewer.shared.gis;
import java.io.Serializable;
/**
* The Class BoundsMap.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Oct 27, 2020
*/
public class BoundsMap implements Serializable{
/**
*
*/
private static final long serialVersionUID = 69005924452960006L;
/** The lower left X. */
private double lowerLeftX = 0.0;
/** The lower left Y. */
private double lowerLeftY = 0.0;
/** The upper right X. */
private double upperRightX = 0.0;
/** The upper right Y. */
private double upperRightY = 0.0;
/** The crs. */
private String crs = "";
/**
* Instantiates a new bounds map.
*/
public BoundsMap() {
}
/**
* Instantiates a new bounds map.
*
* @param lowerLeftX the lower left X
* @param lowerLeftY the lower left Y
* @param upperRightX the upper right X
* @param upperRightY the upper right Y
* @param crs the crs
*/
public BoundsMap(double lowerLeftX, double lowerLeftY, double upperRightX,
double upperRightY, String crs) {
super();
this.lowerLeftX = lowerLeftX;
this.lowerLeftY = lowerLeftY;
this.upperRightX = upperRightX;
this.upperRightY = upperRightY;
this.crs = crs;
}
/**
* Gets the lower left X.
*
* @return the lower left X
*/
public double getLowerLeftX() {
return lowerLeftX;
}
/**
* Sets the lower left X.
*
* @param lowerLeftX the new lower left X
*/
public void setLowerLeftX(double lowerLeftX) {
this.lowerLeftX = lowerLeftX;
}
/**
* Gets the lower left Y.
*
* @return the lower left Y
*/
public double getLowerLeftY() {
return lowerLeftY;
}
/**
* Sets the lower left Y.
*
* @param lowerLeftY the new lower left Y
*/
public void setLowerLeftY(double lowerLeftY) {
this.lowerLeftY = lowerLeftY;
}
/**
* Gets the upper right X.
*
* @return the upper right X
*/
public double getUpperRightX() {
return upperRightX;
}
/**
* Sets the upper right X.
*
* @param upperRightX the new upper right X
*/
public void setUpperRightX(double upperRightX) {
this.upperRightX = upperRightX;
}
/**
* Gets the upper right Y.
*
* @return the upper right Y
*/
public double getUpperRightY() {
return upperRightY;
}
/**
* Sets the upper right Y.
*
* @param upperRightY the new upper right Y
*/
public void setUpperRightY(double upperRightY) {
this.upperRightY = upperRightY;
}
/**
* Gets the crs.
*
* @return the crs
*/
public String getCrs() {
return crs;
}
/**
* Sets the crs.
*
* @param crs the new crs
*/
public void setCrs(String crs) {
this.crs = crs;
}
@Override
public String toString() {
return "BoundsMap [lowerLeftX=" + lowerLeftX + ", lowerLeftY=" + lowerLeftY + ", upperRightX=" + upperRightX
+ ", upperRightY=" + upperRightY + ", crs=" + crs + "]";
}
}

View File

@ -0,0 +1,296 @@
package org.gcube.portlets.user.geoportaldataviewer.shared.gis;
import java.io.Serializable;
import java.util.HashMap;
/**
* The Class GeoInformationForWMSRequest.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Oct 27, 2020
*/
public class GeoInformationForWMSRequest implements Serializable {
/** The Constant serialVersionUID. */
private static final long serialVersionUID = -6846636281073641003L;
/** The base wms service host. */
private String baseWmsServiceHost;
/** The wms request. */
private String wmsRequest;
/** The layer name. */
private String layerName;
/** The version WMS. */
private String versionWMS;
/** The crs. */
private String crs;
/** The map WMS no standard params. */
private HashMap<String, String> mapWMSNoStandardParams;
/** The styles. */
private Styles styles;
/** The is nc WMS. */
// TODO TO BE REMOVED
private boolean isNcWMS;
/** The z axis. */
private ZAxis zAxis;
/**
* Instantiates a new geo information for wms request.
*/
public GeoInformationForWMSRequest() {
}
/**
* 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 mapWmsNoStandard the map wms not standard
* @param styles the layer styles
* @param isNcWMS the is nc WMS
* @param zAxis the z axis
*/
public GeoInformationForWMSRequest(String baseWmsServiceHost, String wmsRequest, String layerName,
String versionWms, String crs, HashMap<String, String> mapWmsNoStandard, Styles styles, boolean isNcWMS,
ZAxis zAxis) {
this.baseWmsServiceHost = baseWmsServiceHost;
this.wmsRequest = wmsRequest;
this.layerName = layerName;
this.versionWMS = versionWms;
this.crs = crs;
this.mapWMSNoStandardParams = mapWmsNoStandard;
this.styles = styles;
this.zAxis = zAxis;
this.isNcWMS = isNcWMS;
}
/**
* Gets the z axis.
*
* @return the zAxis
*/
public ZAxis getZAxis() {
return zAxis;
}
/**
* Sets the z axis.
*
* @param zAxis the zAxis to set
*/
public void setZAxis(ZAxis zAxis) {
this.zAxis = zAxis;
}
/**
* Gets the base wms service host.
*
* @return the baseWmsServiceHost
*/
public String getBaseWmsServiceHost() {
return baseWmsServiceHost;
}
/**
* Gets the wms request.
*
* @return the wmsRequest
*/
public String getWmsRequest() {
return wmsRequest;
}
/**
* Gets the layer name.
*
* @return the layerName
*/
public String getLayerName() {
return layerName;
}
/**
* Gets the version wms.
*
* @return the versionWMS
*/
public String getVersionWMS() {
return versionWMS;
}
/**
* Gets the crs.
*
* @return the crs
*/
public String getCrs() {
return crs;
}
/**
* Gets the map wms no standard.
*
* @return the mapWMSNoStandard
*/
public HashMap<String, String> getMapWMSNoStandard() {
return mapWMSNoStandardParams;
}
/**
* Gets the styles.
*
* @return the styles
*/
public Styles getStyles() {
return styles;
}
/**
* Checks if is nc wms.
*
* @return the isNcWMS
*/
public boolean isNcWMS() {
return isNcWMS;
}
/**
* Sets the base wms service host.
*
* @param baseWmsServiceHost the baseWmsServiceHost to set
*/
public void setBaseWmsServiceHost(String baseWmsServiceHost) {
this.baseWmsServiceHost = baseWmsServiceHost;
}
/**
* Sets the wms request.
*
* @param wmsRequest the wmsRequest to set
*/
public void setWmsRequest(String wmsRequest) {
this.wmsRequest = wmsRequest;
}
/**
* Sets the layer name.
*
* @param layerName the layerName to set
*/
public void setLayerName(String layerName) {
this.layerName = layerName;
}
/**
* Sets the version wms.
*
* @param versionWMS the versionWMS to set
*/
public void setVersionWMS(String versionWMS) {
this.versionWMS = versionWMS;
}
/**
* Sets the crs.
*
* @param crs the crs to set
*/
public void setCrs(String crs) {
this.crs = crs;
}
/**
* Sets the map wms no standard.
*
* @param mapWMSNoStandard the mapWMSNoStandard to set
*/
public void setMapWMSNoStandard(HashMap<String, String> mapWMSNoStandard) {
this.mapWMSNoStandardParams = mapWMSNoStandard;
}
/**
* Sets the styles.
*
* @param styles the styles to set
*/
public void setStyles(Styles styles) {
this.styles = styles;
}
/**
* Sets the nc wms.
*
* @param isNcWMS the isNcWMS to set
*/
public void setNcWMS(boolean isNcWMS) {
this.isNcWMS = isNcWMS;
}
/**
* To string.
*
* @return the string
*/
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("GeoInformationForWMSRequest [baseWmsServiceHost=");
builder.append(baseWmsServiceHost);
builder.append(", wmsRequest=");
builder.append(wmsRequest);
builder.append(", layerName=");
builder.append(layerName);
builder.append(", versionWMS=");
builder.append(versionWMS);
builder.append(", crs=");
builder.append(crs);
builder.append(", mapWMSNoStandardParams=");
builder.append(mapWMSNoStandardParams);
builder.append(", styles=");
builder.append(styles);
builder.append(", isNcWMS=");
builder.append(isNcWMS);
builder.append(", zAxis=");
builder.append(zAxis);
builder.append("]");
return builder.toString();
}
}

View File

@ -0,0 +1,918 @@
package org.gcube.portlets.user.geoportaldataviewer.shared.gis;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
// TODO: Auto-generated Javadoc
/**
* The Class LayerItem.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Oct 27, 2020
*/
public class LayerItem implements Serializable, Cloneable {
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 1664082688635256899L;
/** The name. */
private String name;
/** The title. */
private String title = null;
/** The url. */
private String url;
/** The base map server URL. */
private String mapServerHost;
/** The style. */
private String style;
/** The is trasparent. */
private boolean isTrasparent;
/** The is base layer. */
private boolean isBaseLayer;
/** The is feature type. */
private boolean isFeatureType;
/** The buffer. */
private int buffer = 0;
/** The has legend. */
private boolean hasLegend;
/** The is visible. */
private boolean isVisible;
/** The is on map. */
private boolean isOnMap;
/** The click data. */
private boolean clickData;
/** The max extent. */
private BoundsMap maxExtent;
/** The default style. */
private String defaultStyle = "";
/** The opacity. */
private double opacity = -1;
/** The styles. */
private ArrayList<String> styles = new ArrayList<String>();
/** The properties. */
private List<Property> properties = new ArrayList<Property>();
/** The data store. */
private String dataStore;
/** The cql filter. */
private String cqlFilter;
/** The id. */
private long id;
/** The order. */
private long order;
/** The wms not standard params. */
private Map<String, String> wmsNotStandardParams = null;
/** The is nc wms. */
private boolean isNcWms = false;
/** The server wms request. */
public String serverWmsRequest;
/** The cql filter available. */
private boolean cqlFilterAvailable = false;
/** The uuid. */
private String UUID;
/** The z axis. */
private ZAxis zAxis = null;
/** The z axis selected. */
private Double zAxisSelected = null;
/** The Constant FLOAT_TYPE. */
public static final String FLOAT_TYPE = "xsd:float";
/** The Constant INT_TYPE. */
public static final String INT_TYPE = "xsd:int";
/**
* Instantiates a new layer item.
*/
public LayerItem() {
}
/**
* Checks if is checks for legend.
*
* @return true, if is checks for legend
*/
public boolean isHasLegend() {
return hasLegend;
}
/**
* Sets the checks for legend.
*
* @param hasLegend the new checks for legend
*/
public void setHasLegend(boolean hasLegend) {
this.hasLegend = hasLegend;
}
/**
* Gets the max extent.
*
* @return the max extent
*/
public BoundsMap getMaxExtent() {
return maxExtent;
}
/**
* Sets the max extent.
*
* @param maxExtent the new max extent
*/
public void setMaxExtent(BoundsMap maxExtent) {
this.maxExtent = maxExtent;
}
/**
* Sets the max extent.
*
* @param lowerLeftX the lower left x
* @param lowerLeftY the lower left y
* @param upperRightX the upper right x
* @param upperRightY the upper right y
* @param crs the crs
*/
public void setMaxExtent(double lowerLeftX, double lowerLeftY, double upperRightX, double upperRightY, String crs) {
this.maxExtent = new BoundsMap(lowerLeftX, lowerLeftY, upperRightX, upperRightY, crs);
}
/**
* Checks if is feature type.
*
* @return true, if is feature type
*/
public boolean isFeatureType() {
return isFeatureType;
}
/**
* Sets the feature type.
*
* @param isFeatureType the new feature type
*/
public void setFeatureType(boolean isFeatureType) {
this.isFeatureType = isFeatureType;
}
/**
* Gets the name.
*
* @return the name
*/
public String getName() {
return name;
}
/**
* Sets the name.
*
* @param name the new name
*/
public void setName(String name) {
this.name = name;
}
/**
* Gets the url.
*
* @return the url
*/
public String getUrl() {
return url;
}
/**
* Sets the url.
*
* @param url the new url
*/
public void setUrl(String url) {
this.url = url;
}
/**
* Gets the style.
*
* @return the style
*/
public String getStyle() {
return style;
}
/**
* Sets the style.
*
* @param style the new style
*/
public void setStyle(String style) {
this.style = style;
}
/**
* Checks if is trasparent.
*
* @return true, if is trasparent
*/
public boolean isTrasparent() {
return isTrasparent;
}
/**
* Sets the trasparent.
*
* @param isTrasparent the new trasparent
*/
public void setTrasparent(boolean isTrasparent) {
this.isTrasparent = isTrasparent;
}
/**
* Checks if is base layer.
*
* @return true, if is base layer
*/
public boolean isBaseLayer() {
return isBaseLayer;
}
/**
* Sets the base layer.
*
* @param isBaseLayer the new base layer
*/
public void setBaseLayer(boolean isBaseLayer) {
this.isBaseLayer = isBaseLayer;
}
/**
* Gets the buffer.
*
* @return the buffer
*/
public int getBuffer() {
return buffer;
}
/**
* Sets the buffer.
*
* @param buffer the new buffer
*/
public void setBuffer(int buffer) {
this.buffer = buffer;
}
/**
* Checks if is visible.
*
* @return true, if is visible
*/
public boolean isVisible() {
return isVisible;
}
/**
* Sets the visible.
*
* @param isVisible the new visible
*/
public void setVisible(boolean isVisible) {
this.isVisible = isVisible;
}
/**
* Checks if is on map.
*
* @return true, if is on map
*/
public boolean isOnMap() {
return isOnMap;
}
/**
* Sets the on map.
*
* @param isOnMap the new on map
*/
public void setOnMap(boolean isOnMap) {
this.isOnMap = isOnMap;
}
/**
* Checks if is click data.
*
* @return true, if is click data
*/
public boolean isClickData() {
return clickData;
}
/**
* Sets the click data.
*
* @param clickData the new click data
*/
public void setClickData(boolean clickData) {
this.clickData = clickData;
}
/**
* Gets the default style.
*
* @return the default style
*/
public String getDefaultStyle() {
return defaultStyle;
}
/**
* Sets the default style.
*
* @param defaultStyle the new default style
*/
public void setDefaultStyle(String defaultStyle) {
this.defaultStyle = defaultStyle;
}
/**
* Gets the styles.
*
* @return the styles
*/
public ArrayList<String> getStyles() {
return styles;
}
/**
* Sets the styles.
*
* @param styles the new styles
*/
public void setStyles(ArrayList<String> styles) {
this.styles = styles;
}
/**
* Gets the opacity.
*
* @return the opacity
*/
public double getOpacity() {
return opacity;
}
/**
* Sets the opacity.
*
* @param opacity the new opacity
*/
public void setOpacity(double opacity) {
this.opacity = opacity;
}
// @Override
/**
* Clone.
*
* @return the layer item
*/
/*
* (non-Javadoc)
*
* @see java.lang.Object#clone()
*/
public LayerItem clone() {
LayerItem ele = new LayerItem();
ele.setBaseLayer(this.isBaseLayer);
ele.setClickData(this.clickData);
ele.setBuffer(this.buffer);
ele.setDefaultStyle(this.defaultStyle);
ele.setHasLegend(this.hasLegend);
ele.setMaxExtent(maxExtent);
ele.setName(this.name);
ele.setOnMap(this.isOnMap);
ele.setOpacity(this.opacity);
ele.setStyle(this.style);
ele.setStyles(this.styles);
ele.setTrasparent(this.isTrasparent);
ele.setUrl(this.url);
ele.setVisible(this.isVisible);
ele.setProperties(this.getProperties());
ele.setWmsNotStandardParams(this.wmsNotStandardParams);
// ele.setUUID(this.UUID);
return ele;
}
/**
* Checks if is nc wms.
*
* @return the isNcWms
*/
public boolean isNcWms() {
return isNcWms;
}
/**
* Sets the nc wms.
*
* @param isNcWms the isNcWms to set
*/
public void setNcWms(boolean isNcWms) {
this.isNcWms = isNcWms;
}
/**
* Gets the properties.
*
* @return the properties
*/
public List<Property> getProperties() {
return properties;
}
/**
* Sets the properties.
*
* @param properties the new properties
*/
public void setProperties(List<Property> properties) {
this.properties = properties;
}
// search a float property in the layer's feature type
/**
* Contains property.
*
* @param propertyName the property name
* @return true, if successful
*/
public boolean containsProperty(String propertyName) {
boolean contains = false;
for (Property p : properties) {
if (p.getName().equals(propertyName) && (p.getType().equals(FLOAT_TYPE) || p.getType().equals(INT_TYPE))) {
contains = true;
}
}
return contains;
}
// search a property in the layer's feature type, giving property name and
// property type
/**
* Contains property.
*
* @param propertyName the property name
* @param propertyType the property type
* @return true, if successful
*/
public boolean containsProperty(String propertyName, String propertyType) {
if (properties == null) {
return false;
}
boolean contains = false;
for (Property p : properties) {
if (p.getName().equals(propertyName) && p.getType().equals(propertyType)) {
contains = true;
}
}
return contains;
}
// search a property in the layer's feature type, giving a property object
/**
* Contains property.
*
* @param property the property
* @return true, if successful
*/
public boolean containsProperty(Property property) {
if (properties == null) {
return false;
}
boolean contains = false;
for (Property p : properties) {
if (p.getName().equals(property.getName()) && p.getType().equals(property.getType())) {
contains = true;
}
}
return contains;
}
// search for float Property objects belongs to the layer
/**
* Gets the all float properties.
*
* @return the all float properties
*/
public List<Property> getAllFloatProperties() {
if (properties == null) {
return null;
}
List<Property> floatProperties = new ArrayList<Property>();
for (Property p : properties) {
if (p.getType().equals(FLOAT_TYPE)) {
floatProperties.add(p);
}
}
return floatProperties;
}
// search for float Property names belongs to the layer
/**
* Gets the all float property names.
*
* @return the all float property names
*/
public List<String> getAllFloatPropertyNames() {
if (properties == null) {
return null;
}
List<String> floatPropertyNames = new ArrayList<String>();
for (Property p : properties) {
if (p.getType().equals(FLOAT_TYPE)) {
floatPropertyNames.add(p.getName());
}
}
return floatPropertyNames;
}
// get the first float Property names belongs to the layer
/**
* Gets the first float property name.
*
* @return the first float property name
*/
public String getFirstFloatPropertyName() {
if (properties == null) {
return null;
}
for (Property p : properties) {
if (p.getType().equals(FLOAT_TYPE)) {
return p.getName();
}
}
return null;
}
/**
* Sets the z axis selected.
*
* @param value the new z axis selected
*/
public void setZAxisSelected(Double value) {
this.zAxisSelected = value;
}
/**
* Gets the z axis selected.
*
* @return the zAxisSelected
*/
public Double getZAxisSelected() {
return zAxisSelected;
}
/**
* Sets the list z axis.
*
* @param zAxis the new list z axis
*/
public void setZAxis(ZAxis zAxis) {
this.zAxis = zAxis;
}
/**
* Gets the list z axis.
*
* @return the zAxis
*/
public ZAxis getZAxis() {
return zAxis;
}
/**
* Sets the data store.
*
* @param dataStore the new data store
*/
public void setDataStore(String dataStore) {
this.dataStore = dataStore;
}
/**
* Gets the data store.
*
* @return the data store
*/
public String getDataStore() {
return dataStore;
}
/**
* Sets the title.
*
* @param title the new title
*/
public void setTitle(String title) {
this.title = title;
}
/**
* Gets the title.
*
* @return the title
*/
public String getTitle() {
return title;
}
/**
* Gets the id.
*
* @return the id
*/
public long getId() {
return id;
}
/**
* Sets the id.
*
* @param id the new id
*/
public void setId(long id) {
this.id = id;
}
/**
* Sets the order.
*
* @param order the new order
*/
public void setOrder(long order) {
this.order = order;
}
/**
* Gets the order.
*
* @return the order
*/
public long getOrder() {
return order;
}
/**
* Gets the cql filter.
*
* @return the cql filter
*/
public String getCqlFilter() {
return cqlFilter;
}
/**
* Sets the cql filter.
*
* @param cqlFilter the new cql filter
*/
public void setCqlFilter(String cqlFilter) {
this.cqlFilter = cqlFilter;
}
/**
* Sets the uuid.
*
* @param uUID the new uuid
*/
public void setUUID(String uUID) {
this.UUID = uUID;
}
/**
* Gets the uuid.
*
* @return the uUID
*/
public String getUUID() {
return UUID;
}
/**
* Checks if is cql filter available.
*
* @return true, if is cql filter available
*/
public boolean isCqlFilterAvailable() {
return cqlFilterAvailable;
}
/**
* Sets the cql filter available.
*
* @param cqlFilterAvailable the new cql filter available
*/
public void setCqlFilterAvailable(boolean cqlFilterAvailable) {
this.cqlFilterAvailable = cqlFilterAvailable;
}
/**
* Gets the server wms request.
*
* @return the server wms request
*/
public String getServerWmsRequest() {
return serverWmsRequest;
}
/**
* Sets the server wms request.
*
* @param serverWmsRequest the new server wms request
*/
public void setServerWmsRequest(String serverWmsRequest) {
this.serverWmsRequest = serverWmsRequest;
}
/**
* Gets the map server host.
*
* @return the map server host
*/
public String getMapServerHost() {
return mapServerHost;
}
/**
* Sets the map server host.
*
* @param mapServerHost the new map server host
*/
public void setMapServerHost(String mapServerHost) {
this.mapServerHost = mapServerHost;
}
/**
* Gets the wms not standard params.
*
* @return the wmsNotStandardParams
*/
public Map<String, String> getWmsNotStandardParams() {
return wmsNotStandardParams;
}
/**
* Sets the wms not standard params.
*
* @param wmsNotStandardParams the wmsNotStandardParams to set
*/
public void setWmsNotStandardParams(Map<String, String> wmsNotStandardParams) {
this.wmsNotStandardParams = wmsNotStandardParams;
}
/**
* Gets the z axis.
*
* @return the z axis
*/
public ZAxis getzAxis() {
return zAxis;
}
/**
* Sets the z axis.
*
* @param zAxis the new z axis
*/
public void setzAxis(ZAxis zAxis) {
this.zAxis = zAxis;
}
/**
* Gets the z axis selected.
*
* @return the z axis selected
*/
public Double getzAxisSelected() {
return zAxisSelected;
}
/**
* Sets the z axis selected.
*
* @param zAxisSelected the new z axis selected
*/
public void setzAxisSelected(Double zAxisSelected) {
this.zAxisSelected = zAxisSelected;
}
/**
* To string.
*
* @return the string
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("LayerItem [name=");
builder.append(name);
builder.append(", title=");
builder.append(title);
builder.append(", url=");
builder.append(url);
builder.append(", mapServerHost=");
builder.append(mapServerHost);
builder.append(", style=");
builder.append(style);
builder.append(", isTrasparent=");
builder.append(isTrasparent);
builder.append(", isBaseLayer=");
builder.append(isBaseLayer);
builder.append(", isFeatureType=");
builder.append(isFeatureType);
builder.append(", buffer=");
builder.append(buffer);
builder.append(", hasLegend=");
builder.append(hasLegend);
builder.append(", isVisible=");
builder.append(isVisible);
builder.append(", isOnMap=");
builder.append(isOnMap);
builder.append(", clickData=");
builder.append(clickData);
builder.append(", maxExtent=");
builder.append(maxExtent);
builder.append(", defaultStyle=");
builder.append(defaultStyle);
builder.append(", opacity=");
builder.append(opacity);
builder.append(", styles=");
builder.append(styles);
builder.append(", properties=");
builder.append(properties);
builder.append(", dataStore=");
builder.append(dataStore);
builder.append(", cqlFilter=");
builder.append(cqlFilter);
builder.append(", id=");
builder.append(id);
builder.append(", order=");
builder.append(order);
builder.append(", wmsNotStandardParams=");
builder.append(wmsNotStandardParams);
builder.append(", isNcWms=");
builder.append(isNcWms);
builder.append(", serverWmsRequest=");
builder.append(serverWmsRequest);
builder.append(", cqlFilterAvailable=");
builder.append(cqlFilterAvailable);
builder.append(", UUID=");
builder.append(UUID);
builder.append(", zAxis=");
builder.append(zAxis);
builder.append(", zAxisSelected=");
builder.append(zAxisSelected);
builder.append("]");
return builder.toString();
}
}

View File

@ -0,0 +1,188 @@
package org.gcube.portlets.user.geoportaldataviewer.shared.gis;
import java.io.Serializable;
// TODO: Auto-generated Javadoc
/**
* The Class Property.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Oct 27, 2020
*/
public class Property implements Serializable {
/**
*
*/
private static final long serialVersionUID = 8289583721513187916L;
/** The name. */
private String name;
/** The type. */
private String type;
/** The nillable. */
private boolean nillable=true;
/** The max occours. */
private int maxOccours=1;
/** The min occours. */
private int minOccours=0;
/**
* Instantiates a new property.
*/
public Property() {
super();
}
/**
* Instantiates a new property.
*
* @param name the name
* @param type the type
* @param nillable the nillable
* @param maxOccours the max occours
* @param minOccours the min occours
*/
public Property(String name, String type, boolean nillable,
int maxOccours, int minOccours) {
super();
this.name = name;
this.type = type;
this.nillable = nillable;
this.maxOccours = maxOccours;
this.minOccours = minOccours;
}
/**
* Instantiates a new property.
*
* @param name the name
* @param type the type
*/
public Property(String name, String type) {
super();
this.name = name;
this.type = type;
}
/**
* Gets the name.
*
* @return the name
*/
public String getName() {
return name;
}
/**
* Sets the name.
*
* @param name the new name
*/
public void setName(String name) {
this.name = name;
}
/**
* Gets the type.
*
* @return the type
*/
public String getType() {
return type;
}
/**
* Sets the type.
*
* @param type the new type
*/
public void setType(String type) {
this.type = type;
}
/**
* Checks if is nillable.
*
* @return true, if is nillable
*/
public boolean isNillable() {
return nillable;
}
/**
* Sets the nillable.
*
* @param nillable the new nillable
*/
public void setNillable(boolean nillable) {
this.nillable = nillable;
}
/**
* Gets the max occours.
*
* @return the max occours
*/
public int getMaxOccours() {
return maxOccours;
}
/**
* Sets the max occours.
*
* @param maxOccours the new max occours
*/
public void setMaxOccours(int maxOccours) {
this.maxOccours = maxOccours;
}
/**
* Gets the min occours.
*
* @return the min occours
*/
public int getMinOccours() {
return minOccours;
}
/**
* Sets the min occours.
*
* @param minOccours the new min occours
*/
public void setMinOccours(int minOccours) {
this.minOccours = minOccours;
}
/**
* To string.
*
* @return the string
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("Property [name=");
builder.append(name);
builder.append(", type=");
builder.append(type);
builder.append(", nillable=");
builder.append(nillable);
builder.append(", maxOccours=");
builder.append(maxOccours);
builder.append(", minOccours=");
builder.append(minOccours);
builder.append("]");
return builder.toString();
}
}

View File

@ -0,0 +1,126 @@
/**
*
*/
package org.gcube.portlets.user.geoportaldataviewer.shared.gis;
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

@ -0,0 +1,140 @@
/**
*
*/
package org.gcube.portlets.user.geoportaldataviewer.shared.gis;
import java.io.Serializable;
import java.util.List;
// TODO: Auto-generated Javadoc
/**
* The Class ZAxis.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Oct 27, 2020
*/
public class ZAxis implements Serializable{
/**
*
*/
private static final long serialVersionUID = -1669690469240944967L;
/** The units. */
private String units;
/** The positive. */
private boolean positive;
/** The values. */
private List<Double> values;
/**
* Instantiates a new layer z axis.
*/
public ZAxis() {
}
/**
* Instantiates a new layer z axis.
*
* @param units the units
* @param positive the positive
* @param values the values
*/
public ZAxis(String units, boolean positive, List<Double> values) {
this.units = units;
this.positive = positive;
this.values = values;
}
/**
* Gets the units.
*
* @return the units
*/
public String getUnits() {
return units;
}
/**
* Checks if is positive.
*
* @return the positive
*/
public boolean isPositive() {
return positive;
}
/**
* Gets the values.
*
* @return the values
*/
public List<Double> getValues() {
return values;
}
/**
* Sets the units.
*
* @param units the units to set
*/
public void setUnits(String units) {
this.units = units;
}
/**
* Sets the positive.
*
* @param positive the positive to set
*/
public void setPositive(boolean positive) {
this.positive = positive;
}
/**
* Sets the values.
*
* @param values the values to set
*/
public void setValues(List<Double> values) {
this.values = values;
}
/**
* To string.
*
* @return the string
*/
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("ZAxis [units=");
builder.append(units);
builder.append(", positive=");
builder.append(positive);
builder.append(", values=");
builder.append(values);
builder.append("]");
return builder.toString();
}
}

View File

@ -1,10 +1,6 @@
package org.gcube.portlets.user.geoportaldataviewer.client;
import org.gcube.portlets.user.geoportaldataviewer.shared.FieldVerifier;
import com.google.gwt.core.client.GWT;
import com.google.gwt.junit.client.GWTTestCase;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
/**
* GWT JUnit <b>integration</b> tests must extend GWTTestCase.
@ -29,12 +25,6 @@ public class GwtTestGeoportalDataViewer extends GWTTestCase {
* Tests the FieldVerifier.
*/
public void testFieldVerifier() {
assertFalse(FieldVerifier.isValidName(null));
assertFalse(FieldVerifier.isValidName(""));
assertFalse(FieldVerifier.isValidName("a"));
assertFalse(FieldVerifier.isValidName("ab"));
assertFalse(FieldVerifier.isValidName("abc"));
assertTrue(FieldVerifier.isValidName("abcd"));
}
/**
@ -42,33 +32,7 @@ public class GwtTestGeoportalDataViewer extends GWTTestCase {
* GreetingService and verify the response.
*/
public void testGreetingService() {
// Create the service that we will test.
GeoportalDataViewerServiceAsync greetingService = GWT.create(GeoportalDataViewerService.class);
ServiceDefTarget target = (ServiceDefTarget) greetingService;
target.setServiceEntryPoint(GWT.getModuleBaseURL() + "GeoportalDataViewer/greet");
// Since RPC calls are asynchronous, we will need to wait for a response
// after this test method returns. This line tells the test runner to wait
// up to 10 seconds before timing out.
delayTestFinish(10000);
// Send a request to the server.
greetingService.greetServer("GWT User", new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
// The request resulted in an unexpected error.
fail("Request failure: " + caught.getMessage());
}
public void onSuccess(String result) {
// Verify that the response is correct.
assertTrue(result.startsWith("Hello, GWT User!"));
// Now that we have received a response, we need to tell the test runner
// that the test is complete. You must call finishTest() after an
// asynchronous test finishes successfully, or the test will time out.
finishTest();
}
});
}