Implmented Feature #5148

Updated pom version at 4.0.0

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/gis-viewer@131798 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2016-09-26 14:24:30 +00:00
parent 9abf094aa3
commit 2b86a8a0d3
9 changed files with 507 additions and 777 deletions

View File

@ -1,7 +1,12 @@
<ReleaseNotes>
<Changeset component="org.gcube.portlets-user.GISViewer.4-0-0"
date="2016-09-26">
<Change>[Feature #5148] Removed dependency 'geoserverinterface' and changed interface
</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.GISViewer.3-10-2"
date="2016-09-16">
<Change>[Release #5037] Fixed Etics dependency
<Change>[Release #5037] Fixed Etics dependency
</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.GISViewer.3-10-1"

50
pom.xml
View File

@ -10,7 +10,7 @@
<groupId>org.gcube.portlets.user</groupId>
<artifactId>gis-viewer</artifactId>
<version>3.10.2-SNAPSHOT</version>
<version>4.0.0-SNAPSHOT</version>
<name>GIS Viewer Widget</name>
<description>
GWT Widget application to access GIS Data
@ -58,30 +58,30 @@
<version>2.2.5</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>geoserverinterface</artifactId>
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>servlet-api</artifactId>
<groupId>javax.servlet</groupId>
</exclusion>
<exclusion>
<artifactId>dom</artifactId>
<groupId>org.w3c</groupId>
</exclusion>
<exclusion>
<artifactId>xml-apis</artifactId>
<groupId>xml-apis</groupId>
</exclusion>
<exclusion>
<artifactId>common-utils-encryption</artifactId>
<groupId>org.gcube.core</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- <dependency> -->
<!-- <groupId>org.gcube.common</groupId> -->
<!-- <artifactId>geoserverinterface</artifactId> -->
<!-- <version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version> -->
<!-- <scope>compile</scope> -->
<!-- <exclusions> -->
<!-- <exclusion> -->
<!-- <artifactId>servlet-api</artifactId> -->
<!-- <groupId>javax.servlet</groupId> -->
<!-- </exclusion> -->
<!-- <exclusion> -->
<!-- <artifactId>dom</artifactId> -->
<!-- <groupId>org.w3c</groupId> -->
<!-- </exclusion> -->
<!-- <exclusion> -->
<!-- <artifactId>xml-apis</artifactId> -->
<!-- <groupId>xml-apis</groupId> -->
<!-- </exclusion> -->
<!-- <exclusion> -->
<!-- <artifactId>common-utils-encryption</artifactId> -->
<!-- <groupId>org.gcube.core</groupId> -->
<!-- </exclusion> -->
<!-- </exclusions> -->
<!-- </dependency> -->
<dependency>
<groupId>org.gcube.core</groupId>

View File

@ -4,17 +4,16 @@ import com.extjs.gxt.ui.client.widget.Info;
import com.extjs.gxt.ui.client.widget.MessageBox;
import com.google.gwt.core.client.GWT;
/**
* The Class Constants.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Jan 5, 2016
* Sep 26, 2016
*/
public class Constants {
public static String VERSION = "3.10.2";
public static String defaultGroup= "group45be7606f-4add-4636-ad14-f353163d0bd3";
public static String defaultGroup2 = "groupTemplate";
public static String VERSION = "4.0.0";
public static String GCUBE_TOKEN = "d7a4076c-e8c1-42fe-81e0-bdecb1e8074a"; //A STATIC GCUBE TOKEN FOR TEST
public static final Float DEFAULT_XY_WPS_RESOLUTION = new Float(0.5);

View File

@ -1,11 +1,8 @@
package org.gcube.portlets.user.gisviewer.client;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.gcube.portlets.user.gisviewer.client.commons.beans.GisViewerBaseLayerInterface;
import org.gcube.portlets.user.gisviewer.client.commons.beans.LayerItem;
import org.gcube.portlets.user.gisviewer.client.resources.Resources;
import com.extjs.gxt.ui.client.event.BoxComponentEvent;
@ -15,16 +12,17 @@ import com.extjs.gxt.ui.client.widget.Window;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.google.gwt.core.client.GWT;
/**
* The Class GisViewer.
*
* @author Ceras
* updated by
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Nov 27, 2015
* Sep 26, 2016
*/
public class GisViewer extends Window {
public GisViewerPanel gg;
private boolean first = true;
public static Resources resources = GWT.create(Resources.class);
public static GisViewerServiceAsync service = (GisViewerServiceAsync) GWT.create(GisViewerService.class);
@ -77,81 +75,6 @@ public class GisViewer extends Window {
gg.addBaseLayersToOLM(layers);
}
/**
* Adds the layers by names.
*
* @param layerNames the layer names
*/
public void addLayersByNames(String ... layerNames) {
gg.addLayersByLayerNames(Arrays.asList(layerNames));
}
/**
* Adds the layers by names.
*
* @param layerNames the layer names
*/
public void addLayersByNames(List<String> layerNames) {
gg.addLayersByLayerNames(layerNames);
}
/**
* Adds the layer by name.
*
* @param layerName the layer name
*/
public void addLayerByName(String layerName) {
List<String> layerNames = new ArrayList<String>();
layerNames.add(layerName);
gg.addLayersByLayerNames(layerNames);
}
/**
* Adds the layers by layer items.
*
* @param layerItems the layer items
*/
public void addLayersByLayerItems(List<LayerItem> layerItems) {
gg.addLayersByLayerItems(layerItems);
}
/**
* Adds the layer by layer item.
*
* @param layerItem the layer item
*/
public void addLayerByLayerItem(LayerItem layerItem) {
gg.addLayerByLayerItem(layerItem);
}
/**
* Adds the group.
*
* @param groupName the group name
*/
public void addGroup(String groupName) {
gg.addGroupByGroupName(groupName);
}
/**
* Adds the layers by layer items to top.
*
* @param layerItems the layer items
*/
public void addLayersByLayerItemsToTop(List<LayerItem> layerItems) {
gg.addLayersByLayerItemsToTop(layerItems);
}
/**
* Adds the layer by layer item to top.
*
* @param layerItem the layer item
*/
public void addLayerByLayerItemToTop(LayerItem layerItem) {
gg.addLayerByLayerItemToTop(layerItem);
}
/**
* Removes the all layers.
*/
@ -160,20 +83,34 @@ public class GisViewer extends Window {
}
/**
* 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;
gg.addLayerByWmsRequest(layerTitle, layerName, wmsRequest, isBase, displayInLayerSwitcher, UUID, true);
}
/**
* Adds the layer by wms.
*
* @param title the title
* @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 isNcWMS the is nc wms
* @param UUID the uuid
*/
public void addLayerByWms(String title, String layerName, String wmsRequest, boolean isBase, boolean displayInLayerSwitcher, boolean isNcWMS, String UUID) {
gg.addLayerByWms(title, layerName, wmsRequest, isBase, displayInLayerSwitcher, UUID);
public void addLayerByWms(String layerTitle, String layerName, String wmsRequest) {
gg.addLayerByWmsRequest(layerTitle, layerName, wmsRequest, false, false, null, true);
}
/* (non-Javadoc)

View File

@ -2,7 +2,6 @@ package org.gcube.portlets.user.gisviewer.client;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@ -14,7 +13,6 @@ import org.gcube.portlets.user.gisviewer.client.commons.beans.GeoInformationForW
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.LayerItem;
import org.gcube.portlets.user.gisviewer.client.commons.beans.LayerItemsResult;
import org.gcube.portlets.user.gisviewer.client.commons.beans.MapViewInfo;
import org.gcube.portlets.user.gisviewer.client.commons.beans.TransectParameters;
import org.gcube.portlets.user.gisviewer.client.commons.beans.WebFeatureTable;
@ -69,8 +67,8 @@ import com.google.gwt.user.client.ui.Label;
/**
* The Class GisViewerPanel.
* @author Ceras
* updated by Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Sep 28, 2015
* @author updated by Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Sep 26, 2016
*/
public class GisViewerPanel extends LayoutContainer
implements ToolbarHandler, DataPanelHandler, LayersPanelHandler, CqlFilterHandler, OpenLayersHandler {
@ -186,13 +184,6 @@ implements ToolbarHandler, DataPanelHandler, LayersPanelHandler, CqlFilterHandle
}
getTransectUrl();
if (parameters.getOpeningGroup()!=null) {
addGroupByGroupName(parameters.getOpeningGroup());
}
else if (parameters.getOpeningLayers()!=null) {
addLayersByLayerNames(parameters.getOpeningLayers());
}
};
/**
@ -233,161 +224,6 @@ implements ToolbarHandler, DataPanelHandler, LayersPanelHandler, CqlFilterHandle
});
}
/**
* Adds the group by group name.
*
* @param groupName the group name
*/
public void addGroupByGroupName(final String groupName) {
waitMessage(true);
gisViewerServiceAsync.getGroupsInfo(groupName, new AsyncCallback<LayerItemsResult>() {
@Override
public void onSuccess(LayerItemsResult result) {
waitMessage(false);
if (!result.getStatus().equals("")) {
MessageBox.alert("Error", result.getStatus(), null);
}
if (result.getLayerItemsSize()!=0) {
List<LayerItem> layerItems = result.getLayerItems();
addLayersOnMap(layerItems, false);
showLayer(layerItems.get(layerItems.size()-1)); // show last layer
}
}
@Override
public void onFailure(Throwable caught) {
waitMessage(false);
Window.alert("The layers doesn't exist");
}
});
}
/**
* Adds the layers by layer names.
*
* @param layerNames the layer names
*/
public void addLayersByLayerNames(String ... layerNames) {
addLayersByLayerNames(Arrays.asList(layerNames));
}
/**
* Adds the layers by layer names.
*
* @param layerNames the layer names
*/
public void addLayersByLayerNames(List<String> layerNames) {
addLayersByLayerNames(layerNames, false);
}
/**
* Adds the layers by layer names to top.
*
* @param layerNames the layer names
*/
public void addLayersByLayerNamesToTop(final List<String> layerNames) {
addLayersByLayerNames(layerNames, true);
}
/**
* Adds the layers by layer items.
*
* @param layerItems the layer items
*/
public void addLayersByLayerItems(List<LayerItem> layerItems) {
addLayersByLayerItems(layerItems, false);
}
/**
* Adds the layer by layer item.
*
* @param layerItem the layer item
*/
public void addLayerByLayerItem(LayerItem layerItem) {
List<LayerItem> layerItems = new ArrayList<LayerItem>();
layerItems.add(layerItem);
addLayersByLayerItems(layerItems, false);
}
/**
* Adds the layers by layer items to top.
*
* @param layerItems the layer items
*/
public void addLayersByLayerItemsToTop(List<LayerItem> layerItems) {
addLayersByLayerItems(layerItems, true);
}
/**
* Adds the layer by layer item to top.
*
* @param layerItem the layer item
*/
public void addLayerByLayerItemToTop(LayerItem layerItem) {
List<LayerItem> layerItems = new ArrayList<LayerItem>();
layerItems.add(layerItem);
addLayersByLayerItems(layerItems, true);
}
/**
* Adds the layers by layer names.
*
* @param layerNames the layer names
* @param toTop the to top
*/
private void addLayersByLayerNames(final List<String> layerNames, final boolean toTop) {
waitMessage(true);
gisViewerServiceAsync.getLayersInfo(layerNames, new AsyncCallback<LayerItemsResult>() {
@Override
public void onSuccess(LayerItemsResult result) {
waitMessage(false);
if (!result.getStatus().equals("")) {
MessageBox.alert("Error", result.getStatus(), null);
}
if (result.getLayerItemsSize()!=0) {
addLayersOnMap(result.getLayerItems(), toTop);
}
}
@Override
public void onFailure(Throwable caught) {
waitMessage(false);
Window.alert("The layers doesn't exist");
}
});
}
/**
* Adds the layers by layer items.
*
* @param layerItems the layer items
* @param onTop the on top
*/
private void addLayersByLayerItems(List<LayerItem> layerItems, final boolean onTop) {
waitMessage(true);
gisViewerServiceAsync.getLayersInfoByLayerItems(layerItems, new AsyncCallback<LayerItemsResult>() {
@Override
public void onSuccess(LayerItemsResult result) {
waitMessage(false);
if (!result.getStatus().equals("")) {
MessageBox.alert("Error", result.getStatus(), null);
}
if (result.getLayerItemsSize()!=0) {
addLayersOnMap(result.getLayerItems(), onTop);
}
}
@Override
public void onFailure(Throwable caught) {
waitMessage(false);
Window.alert("The layers doesn't exist");
}
});
}
/**
* Adds the layer by wms.
*
@ -397,7 +233,8 @@ implements ToolbarHandler, DataPanelHandler, LayersPanelHandler, CqlFilterHandle
* @param isBase the is base
* @param displayInLayerSwitcher the display in layer switcher
* @param UUID the uuid
* {@link #addLayerByWmsRequest(LayerType, String, String, String, boolean, boolean, String, boolean)}
*
* {use @link {@link GisViewerPanel#addLayerByWmsRequest(String, String, String, boolean, boolean, String, boolean)}}
*/
@Deprecated
public void addLayerByWms(String layerTitle, String layerName, String wmsRequest, boolean isBase, boolean displayInLayerSwitcher, String UUID) {
@ -423,9 +260,6 @@ implements ToolbarHandler, DataPanelHandler, LayersPanelHandler, CqlFilterHandle
}
}
/**
* Adds the layer by wms request.
*
@ -1093,15 +927,6 @@ implements ToolbarHandler, DataPanelHandler, LayersPanelHandler, CqlFilterHandle
return geoserverItems;
}
/**
* Adds the group.
*
* @param groupName the group name
*/
public void addGroup(String groupName) {
this.addGroupByGroupName(groupName);
}
/* (non-Javadoc)
* @see org.gcube.portlets.user.gisviewer.client.layerspanel.LayersPanelHandler#updateLayersOrder()
*/

View File

@ -1,79 +1,75 @@
package org.gcube.portlets.user.gisviewer.client;
import java.util.Arrays;
import java.util.List;
public class GisViewerParameters {
/**
* The Class GisViewerParameters.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Sep 26, 2016
*/
public class GisViewerParameters {
private String projection = null;
private String openingGroup = null;
private List<String> openingLayers = null;
private GisViewerSaveHandler gisViewerSaveHandler = null;
private DataPanelOpenListener dataPanelOpenHandler = null;
private boolean openDataPanelAtStart = Constants.geoWindowDataPanelOpenedAtStart;
//protected static GisViewerParameters instance = new GisViewerParameters();
// public static GisViewerParameters getInstance() {
// return instance;
// }
public GisViewerParameters(){
}
/**
* @param projection
* @param groupName
* @param layers
* @param gisViewerSaveHandler
* Instantiates a new gis viewer parameters.
*/
public GisViewerParameters(String projection, String openingGroup, List<String> openingLayers, GisViewerSaveHandler gisViewerSaveHandler) {
public GisViewerParameters(){
}
/**
* Instantiates a new gis viewer parameters.
*
* @param projection the projection
* @param gisViewerSaveHandler the gis viewer save handler
*/
public GisViewerParameters(String projection, GisViewerSaveHandler gisViewerSaveHandler) {
this.projection = projection;
this.openingGroup = openingGroup;
this.openingLayers = openingLayers;
this.gisViewerSaveHandler = gisViewerSaveHandler;
}
/**
* Sets the projection.
*
* @param projection the new projection
*/
public void setProjection(String projection) {
this.projection = projection;
}
public void setOpeningGroup(String groupName) {
this.openingGroup = groupName;
}
public void setOpeningLayers(List<String> layers) {
this.openingLayers = layers;
}
public void setOpeningLayers(String[] layers) {
this.openingLayers = Arrays.asList(layers);
}
/**
* Gets the projection.
*
* @return the projection
*/
public String getProjection() {
return projection;
}
public String getOpeningGroup() {
return this.openingGroup;
}
public List<String> getOpeningLayers() {
return this.openingLayers;
}
/**
* Sets the gis viewer save handler.
*
* @param gisViewerSaveHandler the new gis viewer save handler
*/
public void setGisViewerSaveHandler(GisViewerSaveHandler gisViewerSaveHandler) {
this.gisViewerSaveHandler = gisViewerSaveHandler;
}
/**
* Gets the gis viewer save handler.
*
* @return the gis viewer save handler
*/
public GisViewerSaveHandler getGisViewerSaveHandler() {
return gisViewerSaveHandler;
}
/**
* Checks if is open data panel at start.
*
* @return the openDataPanelAtStart
*/
public boolean isOpenDataPanelAtStart() {
@ -81,20 +77,26 @@ public class GisViewerParameters {
}
/**
* Sets the open data panel at start.
*
* @param openDataPanelAtStart the openDataPanelAtStart to set
*/
public void setOpenDataPanelAtStart(boolean openDataPanelAtStart) {
this.openDataPanelAtStart = openDataPanelAtStart;
}
/**
* Sets the data panel open listener.
*
* @param dataPanelOpenHandler the dataPanelOpenHandler to set
*/
public void setDataPanelOpenListener(DataPanelOpenListener dataPanelOpenHandler) {
this.dataPanelOpenHandler = dataPanelOpenHandler;
}
/**
* Gets the data panel open handler.
*
* @return the dataPanelOpenHandler
*/
public DataPanelOpenListener getDataPanelOpenHandler() {

View File

@ -7,7 +7,6 @@ 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.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.TransectParameters;
import org.gcube.portlets.user.gisviewer.client.commons.beans.WebFeatureTable;
@ -40,30 +39,6 @@ public interface GisViewerService extends RemoteService {
*/
List<DataResult> getDataResult(List<String> urls);
/**
* Gets the groups info.
*
* @param groupName the group name
* @return the groups info
*/
LayerItemsResult getGroupsInfo(String groupName);
/**
* Gets the layers info.
*
* @param layersName the layers name
* @return the layers info
*/
LayerItemsResult getLayersInfo(List<String> layersName);
/**
* Gets the layers info by layer items.
*
* @param layerItems the layer items
* @return the layers info by layer items
*/
LayerItemsResult getLayersInfoByLayerItems(List<LayerItem> layerItems);
/**
* Added by Francesco M. 10/09/2013
*

View File

@ -7,7 +7,6 @@ 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.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.TransectParameters;
import org.gcube.portlets.user.gisviewer.client.commons.beans.WebFeatureTable;
@ -33,32 +32,32 @@ public interface GisViewerServiceAsync {
*/
public void getDataResult(List<String> urls, AsyncCallback<List<DataResult>> callback);
/**
* Gets the groups info.
*
* @param groupName the group name
* @param callback the callback
* @return the groups info
*/
public void getGroupsInfo(String groupName, AsyncCallback<LayerItemsResult> callback);
// /**
// * Gets the groups info.
// *
// * @param groupName the group name
// * @param callback the callback
// * @return the groups info
// */
// public void getGroupsInfo(String groupName, AsyncCallback<LayerItemsResult> callback);
/**
* Gets the layers info.
*
* @param layersName the layers name
* @param callback the callback
* @return the layers info
*/
public void getLayersInfo(List<String> layersName, AsyncCallback<LayerItemsResult> callback);
/**
* Gets the layers info by layer items.
*
* @param layerItems the layer items
* @param asyncCallback the async callback
* @return the layers info by layer items
*/
public void getLayersInfoByLayerItems(List<LayerItem> layerItems, AsyncCallback<LayerItemsResult> asyncCallback);
// /**
// * Gets the layers info.
// *
// * @param layersName the layers name
// * @param callback the callback
// * @return the layers info
// */
// public void getLayersInfo(List<String> layersName, AsyncCallback<LayerItemsResult> callback);
//
// /**
// * Gets the layers info by layer items.
// *
// * @param layerItems the layer items
// * @param asyncCallback the async callback
// * @return the layers info by layer items
// */
// public void getLayersInfoByLayerItems(List<LayerItem> layerItems, AsyncCallback<LayerItemsResult> asyncCallback);
/**
* Gets the transect parameters.

View File

@ -6,30 +6,18 @@ import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
import org.gcube.common.geoserverinterface.GeoCaller;
import org.gcube.common.geoserverinterface.GeoCaller.FILTER_TYPE;
import org.gcube.common.geoserverinterface.GeonetworkCommonResourceInterface.GeoserverMethodResearch;
import org.gcube.common.geoserverinterface.GeoserverCaller;
import org.gcube.common.geoserverinterface.bean.CoverageTypeRest;
import org.gcube.common.geoserverinterface.bean.CswLayersResult;
import org.gcube.common.geoserverinterface.bean.FeatureTypeRest;
import org.gcube.common.geoserverinterface.bean.GroupRest;
import org.gcube.common.geoserverinterface.bean.LayerCsw;
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.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;
import org.gcube.portlets.user.gisviewer.client.commons.beans.ZAxis;
import org.gcube.portlets.user.gisviewer.client.commons.utils.URLMakers;
import org.gcube.portlets.user.gisviewer.server.datafeature.ClickDataParser;
import org.gcube.portlets.user.gisviewer.server.datafeature.FeatureParser;
import org.gcube.portlets.user.gisviewer.server.datafeature.FeatureTypeParser;
@ -51,8 +39,8 @@ public abstract class GisViewerServiceImpl extends RemoteServiceServlet implemen
private static final long serialVersionUID = -2481133840394575925L;
private static Logger logger = Logger.getLogger(GisViewerServiceImpl.class);
protected static final boolean BASE_LAYER = true;
protected static final GeoserverMethodResearch researchMethod = GeoserverMethodResearch.MOSTUNLOAD;
private Map<String, GeoCaller> geoCallersMap = new HashMap<String, GeoCaller>();
// protected static final GeoserverMethodResearch researchMethod = GeoserverMethodResearch.MOSTUNLOAD;
// private Map<String, GeoCaller> geoCallersMap = new HashMap<String, GeoCaller>();
/**
* Gets the parameters.
@ -76,38 +64,38 @@ public abstract class GisViewerServiceImpl extends RemoteServiceServlet implemen
*/
public abstract String getGcubeSecurityToken();
/**
* Gets the geo caller.
*
* @return the geo caller
* @throws Exception the exception
*/
protected GeoCaller getGeoCaller() throws Exception {
GisViewerServiceParameters parameters = getParameters();
String geoserverUrl = parameters.getGeoServerUrl();
String geonetworkUrl = parameters.getGeoNetworkUrl();
String gnUser = parameters.getGeoNetworkUser();
String gnPwd = parameters.getGeoNetworkPwd();
String gsUser = parameters.getGeoServerUser();
String gsPwd = parameters.getGeoServerPwd();
GeoCaller geoCaller = geoCallersMap.get(geonetworkUrl);
if (geoCaller!=null) {
logger.debug("-----------GEOCALLER FOUND IN MAP");
return geoCaller;
} else {
logger.debug("-----------GEOCALLER NOT FOUND IN MAP, ADDED...");
try {
geoCaller = new GeoCaller(geonetworkUrl, gnUser, gnPwd, geoserverUrl, gsUser, gsPwd, researchMethod);
geoCallersMap.put(geonetworkUrl, geoCaller);
return geoCaller;
} catch (Exception e) {
throw new Exception("Error initializing the GeoCaller", e);
}
}
}
// /**
// * Gets the geo caller.
// *
// * @return the geo caller
// * @throws Exception the exception
// */
// protected GeoCaller getGeoCaller() throws Exception {
// GisViewerServiceParameters parameters = getParameters();
// String geoserverUrl = parameters.getGeoServerUrl();
// String geonetworkUrl = parameters.getGeoNetworkUrl();
// String gnUser = parameters.getGeoNetworkUser();
// String gnPwd = parameters.getGeoNetworkPwd();
// String gsUser = parameters.getGeoServerUser();
// String gsPwd = parameters.getGeoServerPwd();
//
// GeoCaller geoCaller = geoCallersMap.get(geonetworkUrl);
//
// if (geoCaller!=null) {
// logger.debug("-----------GEOCALLER FOUND IN MAP");
// return geoCaller;
// } else {
// logger.debug("-----------GEOCALLER NOT FOUND IN MAP, ADDED...");
// try {
// geoCaller = new GeoCaller(geonetworkUrl, gnUser, gnPwd, geoserverUrl, gsUser, gsPwd, researchMethod);
// geoCallersMap.put(geonetworkUrl, geoCaller);
// return geoCaller;
// } catch (Exception e) {
// throw new Exception("Error initializing the GeoCaller", e);
// }
// }
//
// }
/* (non-Javadoc)
* @see org.gcube.portlets.user.gisviewer.client.GisViewerService#getDataResult(java.util.List)
@ -176,153 +164,153 @@ public abstract class GisViewerServiceImpl extends RemoteServiceServlet implemen
}
}
/* (non-Javadoc)
* @see org.gcube.portlets.user.gisviewer.client.GisViewerService#getGroupsInfo(java.lang.String)
*/
@Override
public LayerItemsResult getGroupsInfo(String groupName) {
// search of geoserver that contains the group
String gsUrl=null;
try {
GeoCaller geoCaller = getGeoCaller();
gsUrl = geoCaller.getGeoServerForGroup(groupName);
if (gsUrl==null)
return null;
// /* (non-Javadoc)
// * @see org.gcube.portlets.user.gisviewer.client.GisViewerService#getGroupsInfo(java.lang.String)
// */
// @Override
// public LayerItemsResult getGroupsInfo(String groupName) {
// // search of geoserver that contains the group
// String gsUrl=null;
// try {
// GeoCaller geoCaller = getGeoCaller();
// gsUrl = geoCaller.getGeoServerForGroup(groupName);
// if (gsUrl==null)
// return null;
//
// //FIXME manage the exception
// GisViewerServiceParameters parameters = getParameters();
// String gsUser = parameters.getGeoServerUser();
// String gsPwd = parameters.getGeoServerPwd();
//
// // connecting to the geoserver found
// GeoserverCaller geoserverCaller = new GeoserverCaller(gsUrl, gsUser, gsPwd);
// GroupRest groupRest = geoserverCaller.getLayerGroup(groupName);
//
// return getLayersInfo(groupRest.getLayers());
//
// } catch (Exception e) {
// logger.error("gisViewer EXCEPTION: Error in getGroupInfo. Message=\""+e.getMessage()+"\"");
// logger.error("geoserver_url="+gsUrl);
// logger.error("Stacktrace: ",e);
// return null;
// }
// }
//FIXME manage the exception
GisViewerServiceParameters parameters = getParameters();
String gsUser = parameters.getGeoServerUser();
String gsPwd = parameters.getGeoServerPwd();
// connecting to the geoserver found
GeoserverCaller geoserverCaller = new GeoserverCaller(gsUrl, gsUser, gsPwd);
GroupRest groupRest = geoserverCaller.getLayerGroup(groupName);
return getLayersInfo(groupRest.getLayers());
} catch (Exception e) {
logger.error("gisViewer EXCEPTION: Error in getGroupInfo. Message=\""+e.getMessage()+"\"");
logger.error("geoserver_url="+gsUrl);
logger.error("Stacktrace: ",e);
return null;
}
}
/* (non-Javadoc)
* @see org.gcube.portlets.user.gisviewer.client.GisViewerService#getLayersInfo(java.util.List)
*/
@Override
public LayerItemsResult getLayersInfo(List<String> layersName) {
LayerItemsResult layerItemsResult = new LayerItemsResult();
Map<String, GeoserverCaller> geoserverCallers = new HashMap<String, GeoserverCaller>();
int countVisible=0, n=layersName.size();
for (String layerName: layersName) {
try {
GeoCaller geoCaller = getGeoCaller();
CswLayersResult cswLayerResult = geoCaller.getLayersFromCsw(null, 1, 10, false, true, FILTER_TYPE.ANY_TEXT, layerName);
if (cswLayerResult.getLayers().size()==0)
layerItemsResult.addStatusMessage("- Layer \""+layerName+"\" not found.");
else {
LayerCsw layerCsw = null;
for (LayerCsw l: cswLayerResult.getLayers()) {
String[] split = l.getName().split(":");
if (l.getName().contentEquals(layerName) || split.length>1 && layerName.contentEquals(split[1])) {
layerCsw = l;
break;
}
}
if (layerCsw==null)
layerCsw = cswLayerResult.getLayers().get(0);
String gsUrl = URLMakers.getGeoserverUrlFromWmsUrl(layerCsw.getGeoserverUrl());
// String gsGwcUrl = URLMakers.getGeoserverGwcUrl(gsUrl);
String gsWmsUrl = URLMakers.getGeoserverWmsUrl(gsUrl);
GeoserverCaller geoserverCaller;
if ((geoserverCaller = geoserverCallers.get(gsUrl))==null) {
GisViewerServiceParameters parameters = getParameters();
String gsUser = parameters.getGeoServerUser();
String gsPwd = parameters.getGeoServerPwd();
geoserverCaller = new GeoserverCaller(gsUrl, gsUser, gsPwd);
geoserverCallers.put(gsUrl, geoserverCaller);
}
LayerItem layerItem = new LayerItem();
layerItem.setName(layerName);
layerItem.setTitle(layerCsw.getTitle());
layerItem.setLayer(layerCsw.getName());
layerItem.setVisible(countVisible++>n-3);
layerItem.setUrl(gsWmsUrl);
layerItem.setGeoserverUrl(gsUrl);
layerItem.setGeoserverWmsUrl(gsWmsUrl);
LayerRest layerRest = geoserverCaller.getLayer(layerName);
// set the dataStore
layerItem.setDataStore(layerRest.getDatastore());
layerItem.setDefaultStyle(layerRest.getDefaultStyle());
layerItem.setStyle(layerRest.getDefaultStyle());
layerItem.setBuffer(2);
if (layerRest.getType().contentEquals("RASTER")) {
CoverageTypeRest coverageTypeRest = geoserverCaller.getCoverageType(
layerRest.getWorkspace(),
layerRest.getCoveragestore(),
layerName);
layerItem.setMaxExtent(coverageTypeRest.getLatLonBoundingBox().getMinx(),
coverageTypeRest.getLatLonBoundingBox().getMiny(),
coverageTypeRest.getLatLonBoundingBox().getMaxx(),
coverageTypeRest.getLatLonBoundingBox().getMaxy(),
coverageTypeRest.getLatLonBoundingBox().getCrs());
layerItem.setHasLegend(false);
layerItem.setBaseLayer(BASE_LAYER);
layerItem.setTrasparent(false);
layerItem.setClickData(false);
} else {
FeatureTypeRest featureTypeRest = geoserverCaller.getFeatureType(layerRest.getWorkspace(),
layerRest.getDatastore(),
layerName);
layerItem.setMaxExtent(featureTypeRest.getLatLonBoundingBox().getMinx(),
featureTypeRest.getLatLonBoundingBox().getMiny(),
featureTypeRest.getLatLonBoundingBox().getMaxx(),
featureTypeRest.getLatLonBoundingBox().getMaxy(),
featureTypeRest.getLatLonBoundingBox().getCrs());
layerItem.setBaseLayer(false);
layerItem.setClickData(true);
layerItem.setStyles(layerRest.getStyles());
layerItem.setHasLegend(true);
layerItem.setTrasparent(true);
}
// set layer properties info
List<Property> properties = FeatureTypeParser.getProperties(gsUrl, layerItem.getLayer());
layerItem.setProperties(properties);
// set opacity
setDefaultOpacity(layerItem);
layerItemsResult.addLayerItem(layerItem);
}
} catch (Exception e) {
e.printStackTrace();
layerItemsResult.addStatusMessage("- Layer \""+layerName+"\" not found.");
}
}
boolean isBaseLayer = false;
for (LayerItem l: layerItemsResult.getLayerItems()) {
if (!isBaseLayer) isBaseLayer = l.isBaseLayer();
}
if (!isBaseLayer && layerItemsResult.getLayerItemsSize() > 0) {
layerItemsResult.getLayerItems().get(0).setBaseLayer(BASE_LAYER);
}
return layerItemsResult;
}
// /* (non-Javadoc)
// * @see org.gcube.portlets.user.gisviewer.client.GisViewerService#getLayersInfo(java.util.List)
// */
// @Override
// public LayerItemsResult getLayersInfo(List<String> layersName) {
// LayerItemsResult layerItemsResult = new LayerItemsResult();
//
// Map<String, GeoserverCaller> geoserverCallers = new HashMap<String, GeoserverCaller>();
// int countVisible=0, n=layersName.size();
//
// for (String layerName: layersName) {
// try {
// GeoCaller geoCaller = getGeoCaller();
//
// CswLayersResult cswLayerResult = geoCaller.getLayersFromCsw(null, 1, 10, false, true, FILTER_TYPE.ANY_TEXT, layerName);
// if (cswLayerResult.getLayers().size()==0)
// layerItemsResult.addStatusMessage("- Layer \""+layerName+"\" not found.");
// else {
// LayerCsw layerCsw = null;
// for (LayerCsw l: cswLayerResult.getLayers()) {
// String[] split = l.getName().split(":");
// if (l.getName().contentEquals(layerName) || split.length>1 && layerName.contentEquals(split[1])) {
// layerCsw = l;
// break;
// }
// }
// if (layerCsw==null)
// layerCsw = cswLayerResult.getLayers().get(0);
// String gsUrl = URLMakers.getGeoserverUrlFromWmsUrl(layerCsw.getGeoserverUrl());
//// String gsGwcUrl = URLMakers.getGeoserverGwcUrl(gsUrl);
// String gsWmsUrl = URLMakers.getGeoserverWmsUrl(gsUrl);
//
// GeoserverCaller geoserverCaller;
// if ((geoserverCaller = geoserverCallers.get(gsUrl))==null) {
// GisViewerServiceParameters parameters = getParameters();
// String gsUser = parameters.getGeoServerUser();
// String gsPwd = parameters.getGeoServerPwd();
// geoserverCaller = new GeoserverCaller(gsUrl, gsUser, gsPwd);
// geoserverCallers.put(gsUrl, geoserverCaller);
// }
//
// LayerItem layerItem = new LayerItem();
// layerItem.setName(layerName);
// layerItem.setTitle(layerCsw.getTitle());
// layerItem.setLayer(layerCsw.getName());
// layerItem.setVisible(countVisible++>n-3);
// layerItem.setUrl(gsWmsUrl);
// layerItem.setGeoserverUrl(gsUrl);
// layerItem.setGeoserverWmsUrl(gsWmsUrl);
//
// LayerRest layerRest = geoserverCaller.getLayer(layerName);
// // set the dataStore
// layerItem.setDataStore(layerRest.getDatastore());
// layerItem.setDefaultStyle(layerRest.getDefaultStyle());
// layerItem.setStyle(layerRest.getDefaultStyle());
//
// layerItem.setBuffer(2);
// if (layerRest.getType().contentEquals("RASTER")) {
//
// CoverageTypeRest coverageTypeRest = geoserverCaller.getCoverageType(
// layerRest.getWorkspace(),
// layerRest.getCoveragestore(),
// layerName);
//
// layerItem.setMaxExtent(coverageTypeRest.getLatLonBoundingBox().getMinx(),
// coverageTypeRest.getLatLonBoundingBox().getMiny(),
// coverageTypeRest.getLatLonBoundingBox().getMaxx(),
// coverageTypeRest.getLatLonBoundingBox().getMaxy(),
// coverageTypeRest.getLatLonBoundingBox().getCrs());
// layerItem.setHasLegend(false);
// layerItem.setBaseLayer(BASE_LAYER);
// layerItem.setTrasparent(false);
// layerItem.setClickData(false);
// } else {
// FeatureTypeRest featureTypeRest = geoserverCaller.getFeatureType(layerRest.getWorkspace(),
// layerRest.getDatastore(),
// layerName);
//
// layerItem.setMaxExtent(featureTypeRest.getLatLonBoundingBox().getMinx(),
// featureTypeRest.getLatLonBoundingBox().getMiny(),
// featureTypeRest.getLatLonBoundingBox().getMaxx(),
// featureTypeRest.getLatLonBoundingBox().getMaxy(),
// featureTypeRest.getLatLonBoundingBox().getCrs());
//
// layerItem.setBaseLayer(false);
// layerItem.setClickData(true);
// layerItem.setStyles(layerRest.getStyles());
// layerItem.setHasLegend(true);
// layerItem.setTrasparent(true);
// }
//
// // set layer properties info
// List<Property> properties = FeatureTypeParser.getProperties(gsUrl, layerItem.getLayer());
// layerItem.setProperties(properties);
// // set opacity
// setDefaultOpacity(layerItem);
// layerItemsResult.addLayerItem(layerItem);
//
// }
// } catch (Exception e) {
// e.printStackTrace();
// layerItemsResult.addStatusMessage("- Layer \""+layerName+"\" not found.");
// }
// }
//
// boolean isBaseLayer = false;
// for (LayerItem l: layerItemsResult.getLayerItems()) {
// if (!isBaseLayer) isBaseLayer = l.isBaseLayer();
// }
// if (!isBaseLayer && layerItemsResult.getLayerItemsSize() > 0) {
// layerItemsResult.getLayerItems().get(0).setBaseLayer(BASE_LAYER);
// }
//
// return layerItemsResult;
// }
/* (non-Javadoc)
* @see org.gcube.portlets.user.gisviewer.client.GisViewerService#getBaseLayersToGisViewer()
@ -339,198 +327,198 @@ public abstract class GisViewerServiceImpl extends RemoteServiceServlet implemen
}
}
/* (non-Javadoc)
* @see org.gcube.portlets.user.gisviewer.client.GisViewerService#getLayersInfoByLayerItems(java.util.List)
*/
@Override
public LayerItemsResult getLayersInfoByLayerItems(List<LayerItem> layerItems) {
LayerItemsResult layerItemsResult = new LayerItemsResult();
int countVisible=0;
for (LayerItem layerItem: layerItems) {
try {
putLayerInfoInLayerItem(layerItem);
layerItem.setVisible(countVisible++<2);
layerItemsResult.addLayerItem(layerItem);
setDefaultOpacity(layerItem);
} catch (Exception e) {
e.printStackTrace();
layerItemsResult.addStatusMessage("- Layer \""+layerItem.getName()+"\" not found.");
}
}
// set eventually base layer
boolean isBaseLayer = false;
for (LayerItem l: layerItemsResult.getLayerItems())
if (!isBaseLayer) isBaseLayer = l.isBaseLayer();
if (!isBaseLayer && layerItemsResult.getLayerItemsSize() > 0) {
layerItemsResult.getLayerItems().get(0).setBaseLayer(BASE_LAYER);
}
return layerItemsResult;
}
// /* (non-Javadoc)
// * @see org.gcube.portlets.user.gisviewer.client.GisViewerService#getLayersInfoByLayerItems(java.util.List)
// */
// @Override
// public LayerItemsResult getLayersInfoByLayerItems(List<LayerItem> layerItems) {
// LayerItemsResult layerItemsResult = new LayerItemsResult();
//
// int countVisible=0;
// for (LayerItem layerItem: layerItems) {
// try {
// putLayerInfoInLayerItem(layerItem);
// layerItem.setVisible(countVisible++<2);
// layerItemsResult.addLayerItem(layerItem);
// setDefaultOpacity(layerItem);
// } catch (Exception e) {
// e.printStackTrace();
// layerItemsResult.addStatusMessage("- Layer \""+layerItem.getName()+"\" not found.");
// }
// }
//
// // set eventually base layer
// boolean isBaseLayer = false;
// for (LayerItem l: layerItemsResult.getLayerItems())
// if (!isBaseLayer) isBaseLayer = l.isBaseLayer();
//
// if (!isBaseLayer && layerItemsResult.getLayerItemsSize() > 0) {
// layerItemsResult.getLayerItems().get(0).setBaseLayer(BASE_LAYER);
// }
//
// return layerItemsResult;
// }
/**
* Put layer info in layer item.
*
* @param layerItem the layer item
* @throws Exception the exception
*/
private void putLayerInfoInLayerItem(LayerItem layerItem) throws Exception {
String gsUrl = layerItem.getGeoserverUrl();
String layerName = layerItem.getName();
// /**
// * Put layer info in layer item.
// *
// * @param layerItem the layer item
// * @throws Exception the exception
// */
// private void putLayerInfoInLayerItem(LayerItem layerItem) throws Exception {
// String gsUrl = layerItem.getGeoserverUrl();
// String layerName = layerItem.getName();
//
// if (gsUrl==null)
// throw new Exception();
//
// GeoserverCaller geoserverCaller;
// GisViewerServiceParameters parameters = getParameters();
// String gsUser = parameters.getGeoServerUser();
// String gsPwd = parameters.getGeoServerPwd();
// geoserverCaller = new GeoserverCaller(gsUrl, gsUser, gsPwd);
//// String gsGwcUrl = URLMakers.getGeoserverGwcUrl(gsUrl);
// String gsWmsUrl = URLMakers.getGeoserverWmsUrl(gsUrl);
//// layerItem.setUrl(gsGwcUrl);
// layerItem.setUrl(gsWmsUrl);
// layerItem.setGeoserverWmsUrl(gsWmsUrl);
//
// LayerRest layerRest = geoserverCaller.getLayer(layerName);
// // set the dataStore
// layerItem.setDataStore(layerRest.getDatastore());
// layerItem.setDefaultStyle(layerRest.getDefaultStyle());
// layerItem.setStyle(layerRest.getDefaultStyle());
// layerItem.setBuffer(2);
//
//// layerItem.setLayer(ServerGeoExtCostants.workSpace+":" + layerName);
// if (layerRest.getType().contentEquals("RASTER")) {
// CoverageTypeRest coverageTypeRest = geoserverCaller.getCoverageType(
// layerRest.getWorkspace(),
// layerRest.getCoveragestore(),
// layerName);
//
// layerItem.setMaxExtent(coverageTypeRest.getLatLonBoundingBox().getMinx(),
// coverageTypeRest.getLatLonBoundingBox().getMiny(),
// coverageTypeRest.getLatLonBoundingBox().getMaxx(),
// coverageTypeRest.getLatLonBoundingBox().getMaxy(),
// coverageTypeRest.getLatLonBoundingBox().getCrs());
// layerItem.setHasLegend(false);
// layerItem.setBaseLayer(BASE_LAYER);
// layerItem.setTrasparent(false);
// layerItem.setClickData(false);
// } else {
// FeatureTypeRest featureTypeRest = geoserverCaller.getFeatureType(layerRest.getWorkspace(),
// layerRest.getDatastore(),
// layerName);
//
// layerItem.setMaxExtent(featureTypeRest.getLatLonBoundingBox().getMinx(),
// featureTypeRest.getLatLonBoundingBox().getMiny(),
// featureTypeRest.getLatLonBoundingBox().getMaxx(),
// featureTypeRest.getLatLonBoundingBox().getMaxy(),
// featureTypeRest.getLatLonBoundingBox().getCrs());
//
// layerItem.setBaseLayer(false);
// layerItem.setClickData(true);
// layerItem.setStyles(layerRest.getStyles());
// layerItem.setHasLegend(true);
//
// layerItem.setTrasparent(true);
// }
//
// // set layer properties info
// List<Property> properties = FeatureTypeParser.getProperties(gsUrl, layerItem.getLayer());
// layerItem.setProperties(properties);
// }
if (gsUrl==null)
throw new Exception();
GeoserverCaller geoserverCaller;
GisViewerServiceParameters parameters = getParameters();
String gsUser = parameters.getGeoServerUser();
String gsPwd = parameters.getGeoServerPwd();
geoserverCaller = new GeoserverCaller(gsUrl, gsUser, gsPwd);
// String gsGwcUrl = URLMakers.getGeoserverGwcUrl(gsUrl);
String gsWmsUrl = URLMakers.getGeoserverWmsUrl(gsUrl);
// layerItem.setUrl(gsGwcUrl);
layerItem.setUrl(gsWmsUrl);
layerItem.setGeoserverWmsUrl(gsWmsUrl);
LayerRest layerRest = geoserverCaller.getLayer(layerName);
// set the dataStore
layerItem.setDataStore(layerRest.getDatastore());
layerItem.setDefaultStyle(layerRest.getDefaultStyle());
layerItem.setStyle(layerRest.getDefaultStyle());
layerItem.setBuffer(2);
// layerItem.setLayer(ServerGeoExtCostants.workSpace+":" + layerName);
if (layerRest.getType().contentEquals("RASTER")) {
CoverageTypeRest coverageTypeRest = geoserverCaller.getCoverageType(
layerRest.getWorkspace(),
layerRest.getCoveragestore(),
layerName);
layerItem.setMaxExtent(coverageTypeRest.getLatLonBoundingBox().getMinx(),
coverageTypeRest.getLatLonBoundingBox().getMiny(),
coverageTypeRest.getLatLonBoundingBox().getMaxx(),
coverageTypeRest.getLatLonBoundingBox().getMaxy(),
coverageTypeRest.getLatLonBoundingBox().getCrs());
layerItem.setHasLegend(false);
layerItem.setBaseLayer(BASE_LAYER);
layerItem.setTrasparent(false);
layerItem.setClickData(false);
} else {
FeatureTypeRest featureTypeRest = geoserverCaller.getFeatureType(layerRest.getWorkspace(),
layerRest.getDatastore(),
layerName);
layerItem.setMaxExtent(featureTypeRest.getLatLonBoundingBox().getMinx(),
featureTypeRest.getLatLonBoundingBox().getMiny(),
featureTypeRest.getLatLonBoundingBox().getMaxx(),
featureTypeRest.getLatLonBoundingBox().getMaxy(),
featureTypeRest.getLatLonBoundingBox().getCrs());
layerItem.setBaseLayer(false);
layerItem.setClickData(true);
layerItem.setStyles(layerRest.getStyles());
layerItem.setHasLegend(true);
layerItem.setTrasparent(true);
}
// set layer properties info
List<Property> properties = FeatureTypeParser.getProperties(gsUrl, layerItem.getLayer());
layerItem.setProperties(properties);
}
/**
* Gets the layer info by layer name.
*
* @param layerName the layer name
* @param geoserverCallers the geoserver callers
* @return the layer info by layer name
* @throws Exception the exception
*/
private LayerItem getLayerInfoByLayerName(String layerName, Map<String, GeoserverCaller> geoserverCallers) throws Exception {
GeoCaller geoCaller = getGeoCaller();
CswLayersResult cswLayerResult = geoCaller.getLayersFromCsw(null, 1, 1, false, true, FILTER_TYPE.ANY_TEXT, layerName);
if (cswLayerResult.getLayers().size()==0)
throw new Exception("CswLayerResult is empty.");
else {
LayerCsw layerCsw = cswLayerResult.getLayers().get(0);
String gsUrl = URLMakers.getGeoserverUrlFromWmsUrl(layerCsw.getGeoserverUrl());
// String gsGwcUrl = URLMakers.getGeoserverGwcUrl(gsUrl);
String gsWmsUrl = URLMakers.getGeoserverWmsUrl(gsUrl);
GeoserverCaller geoserverCaller;
if ((geoserverCaller = geoserverCallers.get(gsUrl))==null) {
GisViewerServiceParameters parameters = getParameters();
String gsUser = parameters.getGeoServerUser();
String gsPwd = parameters.getGeoServerPwd();
geoserverCaller = new GeoserverCaller(gsUrl, gsUser, gsPwd);
geoserverCallers.put(gsUrl, geoserverCaller);
}
LayerItem layerItem = new LayerItem();
layerItem.setName(layerName);
layerItem.setTitle(layerCsw.getTitle());
layerItem.setLayer(layerCsw.getName());
// layerItem.setUrl(gsGwcUrl);
layerItem.setUrl(gsWmsUrl);
layerItem.setGeoserverUrl(gsUrl);
layerItem.setGeoserverWmsUrl(gsWmsUrl);
LayerRest layerRest = geoserverCaller.getLayer(layerName);
// set the dataStore
layerItem.setDataStore(layerRest.getDatastore());
layerItem.setDefaultStyle(layerRest.getDefaultStyle());
layerItem.setStyle(layerRest.getDefaultStyle());
layerItem.setBuffer(2);
if (layerRest.getType().contentEquals("RASTER")) {
CoverageTypeRest coverageTypeRest = geoserverCaller.getCoverageType(
layerRest.getWorkspace(),
layerRest.getCoveragestore(),
layerName);
layerItem.setMaxExtent(coverageTypeRest.getLatLonBoundingBox().getMinx(),
coverageTypeRest.getLatLonBoundingBox().getMiny(),
coverageTypeRest.getLatLonBoundingBox().getMaxx(),
coverageTypeRest.getLatLonBoundingBox().getMaxy(),
coverageTypeRest.getLatLonBoundingBox().getCrs());
layerItem.setHasLegend(false);
layerItem.setBaseLayer(BASE_LAYER);
layerItem.setTrasparent(false);
layerItem.setClickData(false);
} else {
FeatureTypeRest featureTypeRest = geoserverCaller.getFeatureType(layerRest.getWorkspace(),
layerRest.getDatastore(),
layerName);
layerItem.setMaxExtent(featureTypeRest.getLatLonBoundingBox().getMinx(),
featureTypeRest.getLatLonBoundingBox().getMiny(),
featureTypeRest.getLatLonBoundingBox().getMaxx(),
featureTypeRest.getLatLonBoundingBox().getMaxy(),
featureTypeRest.getLatLonBoundingBox().getCrs());
layerItem.setBaseLayer(false);
layerItem.setClickData(true);
layerItem.setStyles(layerRest.getStyles());
layerItem.setHasLegend(true);
layerItem.setTrasparent(true);
}
// set layer properties info
List<Property> properties = FeatureTypeParser.getProperties(gsUrl, layerItem.getLayer());
layerItem.setProperties(properties);
setDefaultOpacity(layerItem);
return layerItem;
}
}
// /**
// * Gets the layer info by layer name.
// *
// * @param layerName the layer name
// * @param geoserverCallers the geoserver callers
// * @return the layer info by layer name
// * @throws Exception the exception
// */
// private LayerItem getLayerInfoByLayerName(String layerName, Map<String, GeoserverCaller> geoserverCallers) throws Exception {
// GeoCaller geoCaller = getGeoCaller();
//
// CswLayersResult cswLayerResult = geoCaller.getLayersFromCsw(null, 1, 1, false, true, FILTER_TYPE.ANY_TEXT, layerName);
// if (cswLayerResult.getLayers().size()==0)
// throw new Exception("CswLayerResult is empty.");
// else {
// LayerCsw layerCsw = cswLayerResult.getLayers().get(0);
// String gsUrl = URLMakers.getGeoserverUrlFromWmsUrl(layerCsw.getGeoserverUrl());
//// String gsGwcUrl = URLMakers.getGeoserverGwcUrl(gsUrl);
// String gsWmsUrl = URLMakers.getGeoserverWmsUrl(gsUrl);
//
// GeoserverCaller geoserverCaller;
// if ((geoserverCaller = geoserverCallers.get(gsUrl))==null) {
// GisViewerServiceParameters parameters = getParameters();
// String gsUser = parameters.getGeoServerUser();
// String gsPwd = parameters.getGeoServerPwd();
// geoserverCaller = new GeoserverCaller(gsUrl, gsUser, gsPwd);
// geoserverCallers.put(gsUrl, geoserverCaller);
// }
//
// LayerItem layerItem = new LayerItem();
// layerItem.setName(layerName);
// layerItem.setTitle(layerCsw.getTitle());
// layerItem.setLayer(layerCsw.getName());
//// layerItem.setUrl(gsGwcUrl);
// layerItem.setUrl(gsWmsUrl);
// layerItem.setGeoserverUrl(gsUrl);
// layerItem.setGeoserverWmsUrl(gsWmsUrl);
//
// LayerRest layerRest = geoserverCaller.getLayer(layerName);
// // set the dataStore
// layerItem.setDataStore(layerRest.getDatastore());
// layerItem.setDefaultStyle(layerRest.getDefaultStyle());
// layerItem.setStyle(layerRest.getDefaultStyle());
// layerItem.setBuffer(2);
//
// if (layerRest.getType().contentEquals("RASTER")) {
//
// CoverageTypeRest coverageTypeRest = geoserverCaller.getCoverageType(
// layerRest.getWorkspace(),
// layerRest.getCoveragestore(),
// layerName);
//
// layerItem.setMaxExtent(coverageTypeRest.getLatLonBoundingBox().getMinx(),
// coverageTypeRest.getLatLonBoundingBox().getMiny(),
// coverageTypeRest.getLatLonBoundingBox().getMaxx(),
// coverageTypeRest.getLatLonBoundingBox().getMaxy(),
// coverageTypeRest.getLatLonBoundingBox().getCrs());
// layerItem.setHasLegend(false);
// layerItem.setBaseLayer(BASE_LAYER);
// layerItem.setTrasparent(false);
// layerItem.setClickData(false);
// } else {
// FeatureTypeRest featureTypeRest = geoserverCaller.getFeatureType(layerRest.getWorkspace(),
// layerRest.getDatastore(),
// layerName);
//
// layerItem.setMaxExtent(featureTypeRest.getLatLonBoundingBox().getMinx(),
// featureTypeRest.getLatLonBoundingBox().getMiny(),
// featureTypeRest.getLatLonBoundingBox().getMaxx(),
// featureTypeRest.getLatLonBoundingBox().getMaxy(),
// featureTypeRest.getLatLonBoundingBox().getCrs());
//
// layerItem.setBaseLayer(false);
// layerItem.setClickData(true);
// layerItem.setStyles(layerRest.getStyles());
// layerItem.setHasLegend(true);
//
// layerItem.setTrasparent(true);
// }
//
// // set layer properties info
// List<Property> properties = FeatureTypeParser.getProperties(gsUrl, layerItem.getLayer());
// layerItem.setProperties(properties);
// setDefaultOpacity(layerItem);
//
// return layerItem;
// }
// }
/**
* Sets the default opacity.