merged with branch 'task_20004'

1.0.0-SNAPSHOT
Francesco Mangiacrapa 3 years ago
parent c5c6823587
commit e6c32701c5

@ -32,6 +32,7 @@
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>

@ -1,4 +1,4 @@
eclipse.preferences.version=1
lastWarOutDir=/home/francesco/git/geoportal-data-viewer-app/target/geoportal-data-viewer-app-1.0.0-SNAPSHOT
lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-viewer-app/target/geoportal-data-viewer-app-1.0.0-SNAPSHOT
warSrcDir=src/main/webapp
warSrcDirIsOutput=false

@ -109,24 +109,30 @@
<artifactId>geo-utility</artifactId>
<version>[1.0.0,2.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>authorization-client</artifactId>
<version>[2.0.0, 3.0.0-SNAPSHOT)</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.resources.discovery</groupId>
<artifactId>ic-client</artifactId>
<version>[1.0.0, 2.0.0-SNAPSHOT)</version>
<scope>provided</scope>
</dependency>
<!-- <dependency> -->
<!-- <groupId>org.gcube.common</groupId> -->
<!-- <artifactId>authorization-client</artifactId> -->
<!-- <version>[2.0.0, 3.0.0-SNAPSHOT)</version> -->
<!-- <scope>provided</scope> -->
<!-- </dependency> -->
<!-- <dependency> -->
<!-- <groupId>org.gcube.resources.discovery</groupId> -->
<!-- <artifactId>ic-client</artifactId> -->
<!-- <version>[1.0.0, 2.0.0-SNAPSHOT)</version> -->
<!-- <scope>provided</scope> -->
<!-- </dependency> -->
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-scope-maps</artifactId>
<version>[1.1.0, 2.0.0-SNAPSHOT)</version>
<scope>compile</scope>
</dependency>
<!-- <dependency> -->
<!-- <groupId>org.gcube.portlets.user</groupId> -->
<!-- <artifactId>gcube-url-shortener</artifactId> -->
<!-- <version>[1.0.0,2.0.0-SNAPSHOT)</version> -->
<!-- <scope>compile</scope> -->
<!-- </dependency> -->
<dependency>
<groupId>org.gcube.common.portal</groupId>
<artifactId>portal-manager</artifactId>
@ -203,7 +209,7 @@
<execution>
<goals>
<goal>compile</goal>
<!-- <goal>test</goal> -->
<!-- <goal>test</goal> -->
<!-- <goal>generateAsync</goal> -->
</goals>
</execution>

@ -1,18 +1,25 @@
package org.gcube.portlets.user.geoportaldataviewer.client;
import java.util.List;
import java.util.Iterator;
import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEventHandler;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ClosedViewDetailsEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ClosedViewDetailsEventHandler;
import org.gcube.portlets.user.geoportaldataviewer.client.events.QueryDataEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowDetailsEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowDetailsEventHandler;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerOSM;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ZoomOutOverMinimumEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ZoomOutOverMinimumEventHandler;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.GeonaDataViewMainPanel;
import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil;
import org.gcube.portlets.user.geoportaldataviewer.shared.ProductType;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.FeatureRow;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaDataViewerProfile;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaItemRef;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.ConcessioneDV;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.RecordDV;
import com.github.gwtbootstrap.client.ui.Tab;
import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler;
@ -22,10 +29,10 @@ import com.google.gwt.event.logical.shared.ResizeHandler;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.RootPanel;
// TODO: Auto-generated Javadoc
import ol.Coordinate;
/**
* Entry point classes define <code>onModuleLoad()</code>.
*
@ -34,18 +41,12 @@ import com.google.gwt.user.client.ui.RootPanel;
* 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 Constant APP_DIV. */
public final static String APP_DIV = "geoportal-data-viewer";
/** The ol map. */
private OpenLayerOSM olMap = null;
//private OpenLayerOSM olMap = null;
/** The main panel. */
private GeonaDataViewMainPanel mainPanel;
@ -54,15 +55,24 @@ public class GeoportalDataViewer implements EntryPoint {
private String paramWmsRequest;
/** The param UUID. */
private String paramUUID;
//private String paramUUID;
private String paramGeonaItemType;
/** The param layer title. */
private String paramLayerTitle;
private HandlerManager eventBus = new HandlerManager("");
private HandlerManager applicationBus = new HandlerManager("");
/** The layer manager. */
private LayerManager layerManager = new LayerManager(eventBus);
private LayerManager layerManager = new LayerManager(applicationBus);
private String paramGeonaItemID;
private GeoNaDataViewerProfile geonaDataViewerProfile;
private OLMapManager olMapMng = null;
//https://data.d4science.org/gis-viewer-app/?wmsrequest=https%3A%2F%2Fgeona-proto.d4science.org%2Fgeoserver%2Fconcessioni_conf%2Fwms%3Fservice%3DWMS%26version%3D1.1.0%26request%3DGetMap%26layers%3Dconcessioni_conf%3Acentroids_concessioni%26styles%3D%26bbox%3D8.476%2C39.179%2C17.391%2C45.772%26width%3D768%26height%3D567%26srs%3DEPSG%3A4326%26format%3Dapplication%2Fopenlayers&zoom=6&centermap=12.45%2C42.98
@ -71,7 +81,7 @@ public class GeoportalDataViewer implements EntryPoint {
*/
public void onModuleLoad() {
mainPanel = new GeonaDataViewMainPanel(eventBus);
mainPanel = new GeonaDataViewMainPanel(applicationBus, getClientHeight());
RootPanel.get(APP_DIV).add(mainPanel);
@ -79,110 +89,197 @@ public class GeoportalDataViewer implements EntryPoint {
@Override
public void execute() {
olMap = new OpenLayerOSM(mainPanel.getMapPanel().getElement().getId(),layerManager.getEventBus());
layerManager.setOlMap(olMap);
mainPanel.setMap(olMap);
olMapMng = new OLMapManager(mainPanel.getMapPanel().getElement().getId(),layerManager.getLayerManagerBus());
layerManager.setOlMap(olMapMng.getOLOSMMap());
mainPanel.setMap(olMapMng.getOLOSMMap());
updateSize();
}
});
Window.addResizeHandler(new ResizeHandler() {
@Override
public void onResize(ResizeEvent event) {
GWT.log("onWindowResized width: " + event.getWidth() + " height: " + event.getHeight());
mainPanel.setMapHeight(event.getHeight() - 200);
updateSize();
}
});
paramWmsRequest = Window.Location.getParameter(GeoportalDataViewerConstants.GET_WMS_PARAMETER);
paramUUID = Window.Location.getParameter(GeoportalDataViewerConstants.GET_UUID_PARAMETER);
paramGeonaItemType = Window.Location.getParameter(GeoportalDataViewerConstants.GET_GEONA_ITEM_TYPE);
//paramUUID = Window.Location.getParameter(GeoportalDataViewerConstants.GET_UUID_PARAMETER);
paramGeonaItemID = Window.Location.getParameter(GeoportalDataViewerConstants.GET_GEONA_ITEM_ID);
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_GEONA_ITEM_TYPE + " = " + paramGeonaItemType);
GWT.log(GeoportalDataViewerConstants.GET_GEONA_ITEM_ID + " = " + paramGeonaItemID);
//GWT.log(GeoportalDataViewerConstants.GET_UUID_PARAMETER + " = " + paramUUID);
GWT.log(GeoportalDataViewerConstants.GET_LAYER_TITLE + " = " + paramLayerTitle);
//VALIDATING THE LONG FORMAT FOR GID
try {
if(paramGeonaItemID!=null)
Long.parseLong(paramGeonaItemID);
}catch (Exception e) {
Window.alert("Bad format for parameter "+GeoportalDataViewerConstants.GET_GEONA_ITEM_ID+". It must be a Long");
}
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
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!");
}
@Override
public void execute() {
GeoportalDataViewerServiceAsync.Util.getInstance().getGeoNaDataViewProfile(new AsyncCallback<GeoNaDataViewerProfile>() {
String layerName = URLUtil.getValueOfParameter("layers", paramWmsRequest);
String displayName = paramLayerTitle==null || paramLayerTitle.isEmpty()?layerName:paramLayerTitle;
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void onFailure(Throwable caught) {
Window.alert(caught.getMessage());
}
@Override
public void execute() {
layerManager.addLayerByWmsRequest(displayName, layerName, paramWmsRequest, false, false, paramUUID, true);
public void onSuccess(GeoNaDataViewerProfile profile) {
geonaDataViewerProfile = profile;
GWT.log("Profile: "+geonaDataViewerProfile);
Iterator<String> it;
String theItemType = paramGeonaItemType;
if(theItemType==null) {
it = geonaDataViewerProfile.getMapLayers().keySet().iterator();
it.hasNext();
theItemType= it.next();
}
LayerItem layerItem = geonaDataViewerProfile.getMapLayers().get(theItemType);
if(layerItem==null) {
Window.alert("Not detected any layer with type: "+theItemType);
return;
}
GWT.log("The layerItem is: "+layerItem);
layerManager.addLayer(theItemType, null, null, layerItem.getWmsLink(), false, false, null, true);
if(paramGeonaItemID!=null) {
if(paramGeonaItemType==null) {
Window.alert("Missing parameter "+GeoportalDataViewerConstants.GET_GEONA_ITEM_TYPE +" (GeoNa Data Type) where to search the item id: "+paramGeonaItemID);
return;
}
GeoNaItemRef gir = new GeoNaItemRef(new Long(paramGeonaItemID), paramGeonaItemType);
applicationBus.fireEvent(new ShowDetailsEvent(gir, null, null));
}
}
});
} catch (Exception e) {
GWT.log("An error occurred on adding wmsrequest :" + paramWmsRequest, e);
e.printStackTrace();
}
}
});
bindEvents();
}
/**
* Update window size.
*/
public void updateSize() {
int rootHeight = getClientHeight();
int height = rootHeight;
mainPanel.setPanelsHeight(height);
GWT.log("Set height: "+height);
}
public int getClientHeight() {
RootPanel principalDiv = RootPanel.get(APP_DIV);
int topBorder = principalDiv.getAbsoluteTop();
int rootHeight = Window.getClientHeight() - topBorder;
return rootHeight;
}
/**
* Bind events.
*/
private void bindEvents() {
eventBus.addHandler(ShowDetailsEvent.TYPE, new ShowDetailsEventHandler() {
applicationBus.addHandler(ShowDetailsEvent.TYPE, new ShowDetailsEventHandler() {
@Override
public void onShowDetails(ShowDetailsEvent showDetailsEvent) {
GWT.log("Fired event: "+showDetailsEvent);
FeatureRow fRow = showDetailsEvent.getFeatureRow();
if(fRow!=null) {
if(showDetailsEvent.getProductType().equals(ProductType.CONCESSIONE)) {
List<String> productIds = fRow.getMapProperties().get("product_id");
if(productIds!=null && productIds.size()>0) {
long id = Long.parseLong(productIds.get(0));
String tabName = "Dettagli Prodotto";
List<String> listName = fRow.getMapProperties().get("nome");
if(listName!=null && listName.size()>0) {
tabName = listName.get(0);
Long id = showDetailsEvent.getGeonaID();
if(id==null) {
Window.alert("Item Id not found");
return;
}
//TODO
boolean found = false;
GWT.log("Product with id: "+id+" found? "+found);
if(!found) {
if(showDetailsEvent.getGeonaItemType().equalsIgnoreCase("Concessione")) {
GeoportalDataViewerServiceAsync.Util.getInstance().getConcessioneForId(id, new AsyncCallback<ConcessioneDV>() {
@Override
public void onFailure(Throwable caught) {
Window.alert(caught.getMessage());
mainPanel.hidePanelDetails();
}
boolean found = mainPanel.selectTabForProductId(id);
GWT.log("Product with id: "+id+" found? "+found);
if(!found) {
final Tab theTab = mainPanel.addAsTab(tabName, true, null);
GeoportalDataViewerServiceAsync.Util.getInstance().getConcessioneForId(id, new AsyncCallback<ConcessioneDV>() {
@Override
public void onFailure(Throwable caught) {
Window.alert(caught.getMessage());
theTab.clear();
theTab.setIcon(IconType.WARNING_SIGN);
theTab.add(new HTML(caught.getMessage()));
}
@Override
public void onSuccess(ConcessioneDV result) {
GWT.log("Showing: "+result);
mainPanel.renderProductIntoTab(theTab, result);
}
});
}else
Window.alert("No product id found");
}
@Override
public void onSuccess(ConcessioneDV concessioneDV) {
GWT.log("Showing: "+concessioneDV);
mainPanel.showAsDetails(concessioneDV, showDetailsEvent.getGeonaItemRef());
}
});
}
}
}
});
applicationBus.addHandler(AddedLayerToMapEvent.TYPE, new AddedLayerToMapEventHandler() {
@Override
public void onLayerRendered(AddedLayerToMapEvent addedLayerToMapEvent) {
GWT.log("Fired AddedLayerToMapEvent "+addedLayerToMapEvent.getLayerItem());
if(paramGeonaItemID!=null && mainPanel.getDisplyedRecord()!=null) {
RecordDV record = mainPanel.getDisplyedRecord();
GWT.log("record instanceof ConcessioneDV: " +(record instanceof ConcessioneDV));
if(record instanceof ConcessioneDV) {
ConcessioneDV concessioneDV = (ConcessioneDV) record;
Double x = concessioneDV.getCentroidLong();
Double y = concessioneDV.getCentroidLat();
Coordinate transfCoord = MapUtils.transformCoordiante(new Coordinate(x, y), GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857);
GeoQuery select = olMapMng.toDataPointQuery(transfCoord);
layerManager.getLayerManagerBus().fireEvent(new QueryDataEvent(select, transfCoord));
}
}
}
});
applicationBus.addHandler(ZoomOutOverMinimumEvent.TYPE, new ZoomOutOverMinimumEventHandler() {
@Override
public void onZoomOut(ZoomOutOverMinimumEvent zoomOutEvent) {
if(mainPanel.getDisplyedRecord()==null && !olMapMng.isQueryPointActive()) {
olMapMng.hidePopInfo();
}
}
});
applicationBus.addHandler(ClosedViewDetailsEvent.TYPE, new ClosedViewDetailsEventHandler() {
@Override
public void onClosed(ClosedViewDetailsEvent closedViewDetailsEvent) {
olMapMng.hidePopInfo();
}
});

@ -10,6 +10,8 @@ public class GeoportalDataViewerConstants {
public static final String MAP_DIV = "map";
public static final String GET_WMS_PARAMETER = "wmsrequest";
public static final String GET_GEONA_ITEM_TYPE = "git";
public static final String GET_GEONA_ITEM_ID = "gid";
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();
@ -18,6 +20,15 @@ public class GeoportalDataViewerConstants {
public enum LayerType {RASTER_BASELAYER, FEATURE_TYPE};
public static final int MAX_WFS_FEATURES = 5; // zero for no limit
public static final int MAX_WFS_FEATURES = 3; // zero for no limit
public static final String NEW_LINE_BR = "<br/>";
public static final double ITALY_CENTER_LONG = 12.45;
public static final double ITALY_CENTER_LAT = 42.98;
public static final int ITALY_FIT_ZOOM_ON = 5;
}

@ -2,26 +2,111 @@ package org.gcube.portlets.user.geoportaldataviewer.client;
import java.util.List;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaDataObject;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaDataViewerProfile;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaItemRef;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformationForWMSRequest;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.ConcessioneDV;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.UploadedImageDV;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
/**
* The client side stub for the RPC service.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Nov 17, 2020
*/
@RemoteServiceRelativePath("geoportaldataviewerservice")
public interface GeoportalDataViewerService extends RemoteService {
/**
* Parses the wms request.
*
* @param wmsRequest the wms request
* @param layerName the layer name
* @return the geo information for WMS request
* @throws Exception the exception
*/
GeoInformationForWMSRequest parseWmsRequest(String wmsRequest, String layerName) throws Exception;
List<GeoNaDataObject> getDataResult(List<LayerItem> layerItems, String mapSrsName, BoundsMap mapBBOX,
/**
* Gets the data result.
*
* @param layerObjects the layer objects
* @param mapSrsName the map srs name
* @param mapBBOX the map BBOX
* @param maxWFSFeature the max WFS feature
* @param zoomLevel the zoom level
* @return the data result
*/
List<GeoNaSpatialQueryResult> getDataResult(List<LayerObject> layerObjects, String mapSrsName, BoundsMap mapBBOX,
int maxWFSFeature, double zoomLevel);
/**
* Gets the concessione for id.
*
* @param id the id
* @return the concessione for id
* @throws Exception the exception
*/
ConcessioneDV getConcessioneForId(Long id) throws Exception;
/**
* Gets the my login.
*
* @return the my login
*/
String getMyLogin();
/**
* Gets the layer for type.
*
* @param layerType the layer type
* @return the layer for type
* @throws Exception the exception
*/
GeoInformationForWMSRequest getLayerForType(String layerType) throws Exception;
/**
* Gets the geo na data view profile.
*
* @return the geo na data view profile
* @throws Exception the exception
*/
GeoNaDataViewerProfile getGeoNaDataViewProfile() throws Exception;
/**
* Gets the uploaded images for id.
*
* @param itemType the item type
* @param id the id
* @param maxImages the max images
* @return the uploaded images for id
* @throws Exception the exception
*/
List<UploadedImageDV> getUploadedImagesForId(String itemType, Long id, int maxImages) throws Exception;
/**
* Gets the public links for.
*
* @param item the item
* @return the public links for
* @throws Exception the exception
*/
GeoNaItemRef getPublicLinksFor(GeoNaItemRef item) throws Exception;
/**
* Gets the short url.
*
* @param longUrl the long url
* @return the short url
* @throws Exception the exception
*/
String getShortUrl(String longUrl) throws Exception;
}

@ -2,11 +2,14 @@ package org.gcube.portlets.user.geoportaldataviewer.client;
import java.util.List;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaDataObject;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaDataViewerProfile;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaItemRef;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformationForWMSRequest;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.ConcessioneDV;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.UploadedImageDV;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
@ -32,8 +35,20 @@ public interface GeoportalDataViewerServiceAsync {
void parseWmsRequest(String wmsRequest, String layerName, AsyncCallback<GeoInformationForWMSRequest> callback);
void getDataResult(List<LayerItem> layerItems, String mapSrsName, BoundsMap mapBBOX, int maxWFSFeature, double zoomLevel,
AsyncCallback<List<GeoNaDataObject>> callback);
void getDataResult(List<LayerObject> layerObjects, String mapSrsName, BoundsMap mapBBOX, int maxWFSFeature, double zoomLevel,
AsyncCallback<List<GeoNaSpatialQueryResult>> callback);
void getConcessioneForId(Long id, AsyncCallback<ConcessioneDV> callback);
void getMyLogin(AsyncCallback<String> callback);
void getLayerForType(String layerType, AsyncCallback<GeoInformationForWMSRequest> callback);
void getGeoNaDataViewProfile(AsyncCallback<GeoNaDataViewerProfile> callback);
void getUploadedImagesForId(String itemType, Long id, int maxImages, AsyncCallback<List<UploadedImageDV>> callback);
void getPublicLinksFor(GeoNaItemRef item, AsyncCallback<GeoNaItemRef> asyncCallback);
void getShortUrl(String longUrl, AsyncCallback<String> callback);
}

@ -1,3 +1,6 @@
/*
*
*/
package org.gcube.portlets.user.geoportaldataviewer.client;
import java.util.ArrayList;
@ -6,19 +9,27 @@ import java.util.List;
import java.util.Map;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.LayerType;
import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEventHandler;
import org.gcube.portlets.user.geoportaldataviewer.client.events.QueryDataEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.QueryDataEventHandler;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowDetailsEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ZoomOutOverMinimumEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ZoomOutOverMinimumEventHandler;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerOSM;
import org.gcube.portlets.user.geoportaldataviewer.client.util.StringUtil;
import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaDataObject;
import org.gcube.portlets.user.geoportaldataviewer.shared.ProductType;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.FeatureRow;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.PointsPath;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformationForWMSRequest;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.ZAxis;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.content.WorkspaceContentDV;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.UploadedImageDV;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
@ -52,17 +63,17 @@ public class LayerManager {
/** The ol map. */
private OpenLayerOSM olMap;
private List<LayerObject> layerObjects = new ArrayList<LayerObject>();
/** The layer items. */
private List<LayerItem> layerItems = new ArrayList<LayerItem>();
private HandlerManager eventBus = new HandlerManager("");
private HandlerManager layerManagerBus = new HandlerManager("");
private HandlerManager applicationBus;
/**
* Instantiates a new layer manager.
* @param applicationBus
*
* @param applicationBus the application bus
*/
public LayerManager(HandlerManager applicationBus) {
this.applicationBus = applicationBus;
@ -70,9 +81,12 @@ public class LayerManager {
}
/**
* Bind events.
*/
private void bindEvents() {
eventBus.addHandler(QueryDataEvent.TYPE, new QueryDataEventHandler() {
layerManagerBus.addHandler(QueryDataEvent.TYPE, new QueryDataEventHandler() {
@Override
public void onQueryInteraction(final QueryDataEvent queryEvent) {
@ -81,9 +95,9 @@ public class LayerManager {
GeoQuery selectDataInfo = queryEvent.getGeoQuery();
GWT.log("("+selectDataInfo.getX1()+","+selectDataInfo.getY1()+")("+selectDataInfo.getX2()+","+selectDataInfo.getY2()+")");
for (LayerItem layerItem : layerItems){
for (LayerObject layerObj : layerObjects){
//TODO
isLayerVisible(layerItem);
isLayerVisible(layerObj.getLayerItem());
}
@ -119,131 +133,246 @@ public class LayerManager {
GWT.log("Bounds is: "+mapBBOX);
GeoportalDataViewerServiceAsync.Util.getInstance().getDataResult(layerItems, olMap.getProjectionCode(), mapBBOX, GeoportalDataViewerConstants.MAX_WFS_FEATURES, olMap.getCurrentZoomLevel(), new AsyncCallback<List<GeoNaDataObject>>() {
GeoportalDataViewerServiceAsync.Util.getInstance().getDataResult(layerObjects, olMap.getProjectionCode(), mapBBOX, GeoportalDataViewerConstants.MAX_WFS_FEATURES, olMap.getCurrentZoomLevel(), new AsyncCallback<List<GeoNaSpatialQueryResult>>() {
@Override
public void onFailure(Throwable caught) {
}
@Override
public void onSuccess(List<GeoNaDataObject> result) {
public void onSuccess(List<GeoNaSpatialQueryResult> listGeonaDataObjects) {
if(result==null || result.isEmpty())
return;
GWT.log("Data result: "+result);
GWT.log("GeoNaDataObject's: "+listGeonaDataObjects);
if(listGeonaDataObjects==null || listGeonaDataObjects.isEmpty())
return;
FlexTable flex = new FlexTable();
flex.setCellPadding(1);
flex.setCellSpacing(1);
flex.getElement().addClassName("popup-table");
boolean featureFound = false;
FeatureRow feature = null;
for (GeoNaDataObject geoNaDataObject : result) {
//TODO SWTCH FOR EARCH ITEM TYPE
for (GeoNaSpatialQueryResult geoNaDataObject : listGeonaDataObjects) {
List<FeatureRow> features = geoNaDataObject.getFeatures();
//USING ONLY THE FIRST FEATURE IN THE LIST
if(features!=null && features.size()>0) {
feature = features.get(0);
Map<String, List<String>> entries = features.get(0).getMapProperties();
Map<String, List<String>> entries = feature.getMapProperties();
for (String key : entries.keySet()) {
String theValue = entries.get(key).get(0);
if(key.equalsIgnoreCase("nome")) {
flex.setHTML(0, 0, new HTML(entries.get(key).get(0)).toString());
flex.setHTML(0, 0, new HTML(theValue).toString());
}
else if(key.equalsIgnoreCase("descrizione")) {
flex.setText(1, 0, entries.get(key).get(0));
String reducedValue = theValue;
try {
reducedValue = StringUtil.ellipsize(theValue, 300);
GWT.log("reduced: "+reducedValue);
} catch (Exception e) {
GWT.log("error: "+e.getMessage());
}
flex.setText(1, 0, reducedValue);
}else if(key.equalsIgnoreCase("date_scavo")) {
flex.setHTML(2, 0, new HTML("<code>"+entries.get(key).get(0)).toString()+"</code>");
flex.setHTML(2, 0, new HTML("<code>"+theValue).toString()+"</code>");
}
}
/*Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
List<String> listConcessioni = entries.get("product_id");
if(listConcessioni!=null && listConcessioni.size()>0) {
String concessioneId = listConcessioni.get(0);
try {
Long theConcessioneId = Long.parseLong(concessioneId);
GeoportalDataViewerServiceAsync.Util.getInstance().getUploadedImagesForId("Concessione", theConcessioneId, 1, new AsyncCallback<List<UploadedImageDV>>() {
@Override
public void onFailure(Throwable caught) {
// TODO Auto-generated method stub
}
@Override
public void onSuccess(List<UploadedImageDV> result) {
GWT.log("Loaded images: "+result);
for (UploadedImageDV img : result) {
if(img.getListWsContent()!=null) {
WorkspaceContentDV wsContent = img.getListWsContent().get(img.getListWsContent().size()-1);
String theImgHTML = "<img src=\""+wsContent.getLink()+"\"></img>";
GWT.log("theImgHTML: "+theImgHTML);
flex.setHTML(flex.getRowCount()+1, 0, theImgHTML);
}
}
}
});
}catch (Exception e) {
// TODO: handle exception
}
}
}
});*/
if(geoNaDataObject.getMapImages()!=null) {
for (Long key : geoNaDataObject.getMapImages().keySet()) {
List<UploadedImageDV> listUI = geoNaDataObject.getMapImages().get(key);
GWT.log("Adding images: "+listUI);
if(listUI!=null) {
UploadedImageDV img = listUI.get(0);
if(img.getListWsContent()!=null) {
WorkspaceContentDV wsContent = img.getListWsContent().get(img.getListWsContent().size()-1);
String theImgHTML = "<img src=\""+wsContent.getLink()+"\"></img>";
GWT.log("theImgHTML: "+theImgHTML);
flex.setHTML(flex.getRowCount()+1, 0, theImgHTML);
}
}
}
}
featureFound = true;
break; //Only the first one
//break; //Only the first one
}
}
FeatureRow theFeature = feature;
Button button = null;
if(!featureFound) {
flex.setHTML(0, 0, new HTML("No data available").toString());
}else {
button = new Button("Open Details");
button.getElement().setId("open-details");
button.setType(ButtonType.LINK);
}
VerticalPanel vpPanel = new VerticalPanel();
vpPanel.add(flex);
if(button!=null)
vpPanel.add(button);
olMap.showPopup(vpPanel.toString(), queryEvent.getoLCoordinate());
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
Element buttonElement = DOM.getElementById("open-details");
Event.sinkEvents(buttonElement, Event.ONCLICK);
Event.setEventListener(buttonElement, new EventListener() {
@Override
public void onBrowserEvent(Event event) {
if(Event.ONCLICK == event.getTypeInt()) {
applicationBus.fireEvent(new ShowDetailsEvent(ProductType.CONCESSIONE, theFeature));
}
}
});
if(feature==null)
return;
GWT.log("The selected Feature is: "+feature);
FeatureRow theFeature = feature;
Button button = null;
if(!featureFound) {
flex.setHTML(0, 0, new HTML("No data available").toString());
}else {
button = new Button("Open Details");
button.getElement().setId("open-details");
button.setType(ButtonType.LINK);
}
});
button.setType(ButtonType.LINK);
button.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
GWT.log("qui");
applicationBus.fireEvent(new ShowDetailsEvent(ProductType.CONCESSIONE, theFeature));
VerticalPanel vpPanel = new VerticalPanel();
vpPanel.add(flex);
if(button!=null) {
vpPanel.add(button);
button.setType(ButtonType.LINK);
button.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
ShowDetailsEvent toEvent = parseGeonaReferences(geoNaDataObject.getSourceLayerObject().getItemType(), theFeature);
applicationBus.fireEvent(toEvent);
}
});
}
});
PointsPath path = feature.getGeometry().getPath();
GWT.log("Points Path: "+path);
Coordinate centerTo = null;
if(path!=null && path.getCoordinates()!=null && path.getCoordinates().length>0) {
org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.Coordinate center = path.getCoordinates()[0];
centerTo = new Coordinate(center.getX(), center.getY());
}
if(centerTo==null)
centerTo = queryEvent.getoLCoordinate();
olMap.showPopup(vpPanel.toString(), centerTo);
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
Element buttonElement = DOM.getElementById("open-details");
Event.sinkEvents(buttonElement, Event.ONCLICK);
Event.setEventListener(buttonElement, new EventListener() {
@Override
public void onBrowserEvent(Event event) {
if(Event.ONCLICK == event.getTypeInt()) {
ShowDetailsEvent toEvent = parseGeonaReferences(geoNaDataObject.getSourceLayerObject().getItemType(), theFeature);
applicationBus.fireEvent(toEvent);
}
}
});
}
});
}
}
});
}
}
});
layerManagerBus.addHandler(AddedLayerToMapEvent.TYPE, new AddedLayerToMapEventHandler() {
@Override
public void onLayerRendered(AddedLayerToMapEvent addedLayerToMapEvent) {
GWT.log("Fired into layerManagerBus");
applicationBus.fireEvent(addedLayerToMapEvent);
}
});
layerManagerBus.addHandler(ZoomOutOverMinimumEvent.TYPE, new ZoomOutOverMinimumEventHandler() {
@Override
public void onZoomOut(ZoomOutOverMinimumEvent zoomOutEvent) {
applicationBus.fireEvent(zoomOutEvent);
}
});
}
/**
* Adds the layer by wms.
* Parses the geona references.
*
* @param layerTitle the layer title
* @param layerName the layer name
* @param wmsRequest the wms request
* @param isBase the is base
* @param UUID the uuid
* @param itemType the item type
* @param fRow the f row
* @return the show details event
*/
public void addLayerByWms(String layerTitle, String layerName, String wmsRequest, boolean isBase, String UUID) {
private ShowDetailsEvent parseGeonaReferences(String itemType, FeatureRow fRow) {
if(fRow==null)
return null;
List<String> productIds = fRow.getMapProperties().get("product_id");
if(productIds!=null && productIds.size()>0) {
long id = Long.parseLong(productIds.get(0));
String itemName = "Dettagli Prodotto";
List<String> listName = fRow.getMapProperties().get("nome");
if(listName!=null && listName.size()>0) {
itemName = listName.get(0);
}
return new ShowDetailsEvent(itemType, id, itemName, fRow);
}
return null;
}
boolean displayInLayerSwitcher = false;
if(isBase)
displayInLayerSwitcher = true;
addLayerByWmsRequest(layerTitle, layerName, wmsRequest, isBase, displayInLayerSwitcher, UUID, true);
}
/**
* Adds the layer by wms request.
* Adds the layer.
*
* @param geonaItemType the geona item type
* @param layerTitle the layer title
* @param layerName the layer name
* @param wmsRequest the wms request
* @param wmsLink the wms link
* @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) {
public void addLayer(final String geonaItemType, final String layerTitle, final String layerName, final String wmsLink, final boolean isBase,final boolean displayInLayerSwitcher, final String UUID, final boolean onTop) {
// final LayoutContainer westPanel = (LayoutContainer) layersPanel.getParent();
//
@ -254,7 +383,7 @@ public class LayerManager {
final LayerType featureType = isBase?LayerType.RASTER_BASELAYER:LayerType.FEATURE_TYPE;
// Info.display("Adding Layer", layerName);
GeoportalDataViewerServiceAsync.Util.getInstance().parseWmsRequest(wmsRequest, layerName, new AsyncCallback<GeoInformationForWMSRequest>() {
GeoportalDataViewerServiceAsync.Util.getInstance().parseWmsRequest(wmsLink, layerName, new AsyncCallback<GeoInformationForWMSRequest>() {
@Override
public void onFailure(Throwable caught) {
@ -263,18 +392,24 @@ public class LayerManager {
}
@Override
public void onSuccess(GeoInformationForWMSRequest result) {
public void onSuccess(GeoInformationForWMSRequest geoInfoWMS) {
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());
GWT.log("Parsed WMS Request returned: "+geoInfoWMS);
//ddLayerByWms(featureType, layerTitle, result.getLayerName(), result.getWmsRequest(), result.getBaseWmsServiceHost(), true, isBase, displayInLayerSwitcher, (ArrayList<String>) result.getStyles().getGeoStyles(), result.getWmsRequest(), false, result.getMapWMSNoStandard(), result.isNcWMS(), UUID, result.getZAxis());
LayerItem layerItem = toLayerItem(featureType, layerTitle, geoInfoWMS.getLayerName(), geoInfoWMS.getWmsRequest(), geoInfoWMS.getBaseWmsServiceHost(), true, isBase, displayInLayerSwitcher, (ArrayList<String>) geoInfoWMS.getStyles().getGeoStyles(), geoInfoWMS.getWmsRequest(), false, geoInfoWMS.getMapWMSNoStandard(), geoInfoWMS.isNcWMS(), UUID, geoInfoWMS.getZAxis());
LayerObject lo = new LayerObject();
lo.setLayerItem(layerItem);
lo.setItemType(geonaItemType);
layerObjects.add(lo);
olMap.addWMSLayer(layerItem);
}
});
}
/**
* Adds the layer by wms.
* To layer item.
*
* @param layerType the layer type
* @param layerTitle the layer title
@ -285,14 +420,15 @@ public class LayerManager {
* @param isBase the is base
* @param displayInLayerSwitcher the display in layer switcher
* @param styles the styles
* @param serverWmsRequest the server wms request
* @param wmsLink the wms link
* @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
* @return the layer item
*/
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) {
private LayerItem toLayerItem(LayerType layerType, String layerTitle, String layerName, String layerURL, String mapServerHost, boolean isExternal, boolean isBase, boolean displayInLayerSwitcher, ArrayList<String> styles, String wmsLink, boolean onTop, HashMap<String, String> wmsNotStandardParams, boolean isNcWms, String UUID, ZAxis zAxis) {
// GWT.log("Add addLayerByWms 1");
LayerItem layerItem = new LayerItem();
@ -304,7 +440,7 @@ public class LayerManager {
//l.setExternal(isExternal);
layerItem.setOpacity(1d);
layerItem.setBuffer(2);
layerItem.setServerWmsRequest(serverWmsRequest);
layerItem.setWmsLink(wmsLink);
layerItem.setWmsNotStandardParams(wmsNotStandardParams);
layerItem.setNcWms(isNcWms);
layerItem.setUUID(UUID);
@ -339,22 +475,16 @@ public class LayerManager {
layerItem.setStyle(styles.get(0));
layerItem.setStyles(styles);
}else{
String style = URLUtil.getValueOfParameter("styles", serverWmsRequest);
String style = URLUtil.getValueOfParameter("styles", wmsLink);
if(style!=null){ //CASE OF STYLE ="";
//TENTATIVE TO GET LEGEND
layerItem.setHasLegend(true);
}
}
GWT.log("Built layer: "+layerItem);
layerItems.add(layerItem);
olMap.addWMSLayer(layerItem.getMapServerHost(), layerName);
// openLayersMap.addLayerItemByWms(l, displayInLayerSwitcher);
// layersPanel.addLayerItems(layerItems, onTop);
// layersPanel.updateLayersOrder();
return layerItem;
}
/**
* Checks if is layer visible.
*
@ -365,7 +495,6 @@ public class LayerManager {
return olMap.isLayerVisible(layerItem.getName());
}
/**
* Sets the ol map.
*
@ -374,12 +503,14 @@ public class LayerManager {
public void setOlMap(OpenLayerOSM olMap) {
this.olMap = olMap;
}
public HandlerManager getEventBus() {
return eventBus;
}
/**
* Gets the layer manager bus.
*
* @return the layer manager bus
*/
public HandlerManager getLayerManagerBus() {
return layerManagerBus;
}
}

@ -0,0 +1,245 @@
package org.gcube.portlets.user.geoportaldataviewer.client;
import org.gcube.portlets.user.geoportaldataviewer.client.events.QueryDataEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ZoomOutOverMinimumEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.ExtentWrapped;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerOSM;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery.TYPE;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.shared.HandlerManager;
import ol.Coordinate;
import ol.MapBrowserEvent;
import ol.MapEvent;
import ol.OLFactory;
/**
* The Class OLMapManager.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Nov 19, 2020
*/
public class OLMapManager {
private String targetId;
private HandlerManager layerManagerBus;
private OpenLayerOSM olMap;
private ol.Extent dragStartExtent = null;
private Double zoomStart = null;
private Double zoomEnd = null;
private ol.Extent dragEndExtent = null;
private static final int QUERY_MIN_ZOOM_LEVEL = 13;
/**
* Instantiates a new OL map manager.
*
* @param targetId the target id
* @param layerManagerBus the layer manager bus
*/
public OLMapManager(String targetId, HandlerManager layerManagerBus) {
this.targetId = targetId;
this.layerManagerBus = layerManagerBus;
instanceOLMap();
}
/**
* Instance OL map.
*/
public void instanceOLMap() {
olMap = new OpenLayerOSM(targetId, layerManagerBus) {
@Override
public void clickListener(MapBrowserEvent event) {
Coordinate coordinate = event.getCoordinate();
if(!olMap.mapInstancied())
return;
if (olMap.isQueryPointActive()) {
GeoQuery select = toDataPointQuery(coordinate);
layerManagerBus.fireEvent(new QueryDataEvent(select, coordinate));
}
}
@Override
public void moveEndListener(MapEvent event) {
//onInit
if(!olMap.mapInstancied())
return;
checkSelectQuery();
}
@Override
public void moveStartListener(MapEvent event) {
//onInit
if(!olMap.mapInstancied())
return;
setDragStart();
}
@Override
public void mapZoomListener(MapEvent event) {
//onInit
if(!olMap.mapInstancied())
return;
setDragStart();
zoomStart = olMap.getCurrentZoomLevel();
GWT.log("zoomStart: "+zoomStart);
}
@Override
public void mapZoomEndListener(MapEvent event) {
//onInit
//onInit
if(!olMap.mapInstancied())
return;
setDragStart();
zoomEnd = olMap.getCurrentZoomLevel();
GWT.log("zoomEnd: "+zoomEnd);
checkSelectQuery();
}
};
// EPSG_4326_TO_ITALY
Coordinate centerCoordinate = OLFactory.createCoordinate(GeoportalDataViewerConstants.ITALY_CENTER_LONG,
GeoportalDataViewerConstants.ITALY_CENTER_LAT);
Coordinate transformedCenterCoordinate = MapUtils.transformCoordiante(centerCoordinate,
GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857);
olMap.setCenter(transformedCenterCoordinate);
olMap.setZoom(GeoportalDataViewerConstants.ITALY_FIT_ZOOM_ON);
}
/**
* To data point query.
*
* @param coordinate the coordinate
* @return the geo query
*/
public GeoQuery toDataPointQuery(Coordinate coordinate) {
double lon = coordinate.getX();
double lat = coordinate.getY();
int w = (int) olMap.getSize().getWidth();
int h = (int) olMap.getSize().getHeight();
// handler.clickOnMap(x, y, w, h);
// ratio - mapPixelWeight : bboxWeight = 20px : geoRectangleWidth
// where 10px is the pixel diameter dimension of the clicked point
double bboxWidth = Math.abs(olMap.getExtent().getLowerLeftX() - olMap.getExtent().getUpperRightX());
double geoWidth = (bboxWidth / w) * (20 / 2);
double x1 = Math.min(lon + geoWidth, lon - geoWidth);
double x2 = Math.max(lon + geoWidth, lon - geoWidth);
double y1 = Math.min(lat + geoWidth, lat - geoWidth);
double y2 = Math.max(lat + geoWidth, lat - geoWidth);
// GWT.log("("+x1+","+y1+")("+x2+","+y2+")");
// Point pt = new Point(coordinate);
// ol.Extent extent = pt.getExtent();
// //new ClickDataInfo(x1, y1, x2, y2)
// SelectDataInfo selectDataInfo
// selectBox(new GeoQuery(x1, y1, x2, y2, GeoQuery.TYPE.POINT));
GeoQuery select = new GeoQuery(x1, y1, x2, y2, TYPE.POINT);
return select;
}
/**
* Gets the OLOSM map.
*
* @return the OLOSM map
*/
public OpenLayerOSM getOLOSMMap() {
return olMap;
}
/**
* Check select query.
*/
private void checkSelectQuery() {
GWT.log("Zoom is:" + olMap.getCurrentZoomLevel());
if (dragStartExtent != null && olMap.getCurrentZoomLevel() > QUERY_MIN_ZOOM_LEVEL) {
dragEndExtent = olMap.getExtent();
// GWT.log("Drag end is: "+dragEndExtent);
ExtentWrapped startExt = new ExtentWrapped(dragStartExtent.getLowerLeftX(), dragStartExtent.getLowerLeftY(),
dragStartExtent.getUpperRightX(), dragStartExtent.getUpperRightY());
ExtentWrapped endExt = new ExtentWrapped(dragEndExtent.getLowerLeftX(), dragEndExtent.getLowerLeftY(),
dragEndExtent.getUpperRightX(), dragEndExtent.getUpperRightY());
// GWT.log("start Ext: "+startExt);
// GWT.log("endExt Ext: "+endExt);
long dist = MapUtils.distanceBetweenCentroid(startExt, endExt);
GWT.log("the distance is: " + dist);
if (dist > 5000 || startExt.containsExtent(endExt)) {
GeoQuery select = toDataBoxQuery(dragEndExtent);
layerManagerBus.fireEvent(new QueryDataEvent(select, endExt.getCenter()));
}
}
else if(zoomStart!=null && zoomEnd!=null) {
if(zoomEnd<QUERY_MIN_ZOOM_LEVEL) {
layerManagerBus.fireEvent(new ZoomOutOverMinimumEvent(zoomStart, zoomEnd, QUERY_MIN_ZOOM_LEVEL));
}
}
}
/**
* Sets the drag start.
*/
private void setDragStart() {
if (olMap.getCurrentZoomLevel() > QUERY_MIN_ZOOM_LEVEL) {
dragStartExtent = olMap.getExtent();
GWT.log("Drag Start is: " + dragStartExtent);
}
}
/**
* To data point query.
*
* @param extent the extent
* @return the geo query
*/
private GeoQuery toDataBoxQuery(ol.Extent extent) {
return new GeoQuery(extent.getLowerLeftX(), extent.getLowerLeftY(), extent.getUpperRightX(), extent.getUpperRightY(), TYPE.BOX);
}
/**
* Checks if is query point active.
*
* @return true, if is query point active
*/
public boolean isQueryPointActive() {
return olMap.isQueryPointActive();
}
/**
* Hide pop info.
*/
public void hidePopInfo() {
olMap.hidePopup();
}
}

@ -0,0 +1,60 @@
package org.gcube.portlets.user.geoportaldataviewer.client.events;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
import com.google.gwt.event.shared.GwtEvent;
/**
* The Class AddedLayerToMapEvent.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Nov 18, 2020
*/
public class AddedLayerToMapEvent extends GwtEvent<AddedLayerToMapEventHandler> {
public static Type<AddedLayerToMapEventHandler> TYPE = new Type<AddedLayerToMapEventHandler>();
private LayerItem layerItem;
/**
* Instantiates a new added layer to map event.
*
* @param layerItem the layer item
*/
public AddedLayerToMapEvent(LayerItem layerItem) {
this.layerItem = layerItem;
}
/**
* Gets the associated type.
*
* @return the associated type
*/
@Override
public Type<AddedLayerToMapEventHandler> getAssociatedType() {
return TYPE;
}
/**
* Dispatch.
*
* @param handler the handler
*/
@Override
protected void dispatch(AddedLayerToMapEventHandler handler) {
handler.onLayerRendered(this);
}
/**
* Gets the layer item.
*
* @return the layer item
*/
public LayerItem getLayerItem() {
return layerItem;
}
}

@ -0,0 +1,20 @@
package org.gcube.portlets.user.geoportaldataviewer.client.events;
import com.google.gwt.event.shared.EventHandler;
/**
* The Interface AddedLayerToMapEventHandler.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Nov 18, 2020
*/
public interface AddedLayerToMapEventHandler extends EventHandler {
/**
* On layer rendered.
*
* @param addedLayerToMapEvent the added layer to map event
*/
void onLayerRendered(AddedLayerToMapEvent addedLayerToMapEvent);
}

@ -0,0 +1,41 @@
package org.gcube.portlets.user.geoportaldataviewer.client.events;
import com.google.gwt.event.shared.GwtEvent;
/**
* The Class ClosedViewDetailsEvent.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Nov 19, 2020
*/
public class ClosedViewDetailsEvent extends GwtEvent<ClosedViewDetailsEventHandler> {
public static Type<ClosedViewDetailsEventHandler> TYPE = new Type<ClosedViewDetailsEventHandler>();
public ClosedViewDetailsEvent() {
}
/**
* Gets the associated type.
*
* @return the associated type
*/
@Override
public Type<ClosedViewDetailsEventHandler> getAssociatedType() {
return TYPE;
}
/**
* Dispatch.
*
* @param handler the handler
*/
@Override
protected void dispatch(ClosedViewDetailsEventHandler handler) {
handler.onClosed(this);
}
}

@ -0,0 +1,21 @@
package org.gcube.portlets.user.geoportaldataviewer.client.events;
import com.google.gwt.event.shared.EventHandler;
/**
* The Interface ClosedViewDetailsEventHandler.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Nov 19, 2020
*/
public interface ClosedViewDetailsEventHandler extends EventHandler {
/**
* On closed.
*
* @param closedViewDetailsEvent the closed view details event
*/
void onClosed(ClosedViewDetailsEvent closedViewDetailsEvent);
}

@ -1,32 +1,57 @@
package org.gcube.portlets.user.geoportaldataviewer.client.events;
import org.gcube.portlets.user.geoportaldataviewer.shared.ProductType;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaItemRef;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.FeatureRow;
import com.google.gwt.event.shared.GwtEvent;
/**
* The Class QueryDataEvent.
* The Class ShowDetailsEvent.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Oct 29, 2020
* Nov 13, 2020
*/
public class ShowDetailsEvent extends GwtEvent<ShowDetailsEventHandler> {
public static Type<ShowDetailsEventHandler> TYPE = new Type<ShowDetailsEventHandler>();
private ProductType productType;
private String geonaItemType;
private FeatureRow featureRow;
private Long geonaID;
private String itemName;
/**
* Instantiates a new table row selected event.
* @param coordinate
* Instantiates a new show details event.
*
* @param geonaItemType the geona item type
* @param geonaID the geona ID
* @param itemName the item name
* @param featureRow the feature row
*/
public ShowDetailsEvent(ProductType productType, FeatureRow row) {
this.productType = productType;
this.featureRow = row;
public ShowDetailsEvent(String geonaItemType, Long geonaID, String itemName, FeatureRow featureRow) {
this.geonaItemType = geonaItemType;
this.geonaID = geonaID;
this.itemName = itemName;
this.featureRow = featureRow;
}
/**
* Instantiates a new show details event.
*
* @param gir the gir
* @param itemName the item name
* @param featureRow the feature row
*/
public ShowDetailsEvent(GeoNaItemRef gir, String itemName, FeatureRow featureRow) {
this.geonaItemType = gir.getItemType();
this.geonaID = gir.getItemId();
this.itemName = itemName;
this.featureRow = featureRow;
}
/**
* Gets the associated type.
*
@ -47,12 +72,63 @@ public class ShowDetailsEvent extends GwtEvent<ShowDetailsEventHandler> {
handler.onShowDetails(this);
}
public ProductType getProductType() {
return productType;
/**
* Gets the geona item type.
*
* @return the geona item type
*/
public String getGeonaItemType() {
return geonaItemType;
}
/**
* Gets the feature row.
*
* @return the feature row
*/
public FeatureRow getFeatureRow() {
return featureRow;
}
/**
* Gets the geona ID.
*
* @return the geona ID
*/
public Long getGeonaID() {
return geonaID;
}
/**
* Gets the item name.
*
* @return the item name
*/
public String getItemName() {
return itemName;
}
/**
* Sets the item name.
*
* @param itemName the new item name
*/
public void setItemName(String itemName) {
this.itemName = itemName;
}
/**
* Gets the geona item ref.
*
* @return the geona item ref
*/
public GeoNaItemRef getGeonaItemRef() {
return new GeoNaItemRef(geonaID, geonaItemType);
}
}

@ -0,0 +1,67 @@
package org.gcube.portlets.user.geoportaldataviewer.client.events;
import com.google.gwt.event.shared.GwtEvent;
/**
* The Class ZoomOutEvent.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Nov 19, 2020
*/
public class ZoomOutOverMinimumEvent extends GwtEvent<ZoomOutOverMinimumEventHandler> {
public static Type<ZoomOutOverMinimumEventHandler> TYPE = new Type<ZoomOutOverMinimumEventHandler>();
private double startZoom;
private double endZoom;
private double minimum;
/**
* Instantiates a new zoom out event.
*
* @param startZoom the start zoom
* @param endZoom the end zoom
* @param minimum the minimum
*/
public ZoomOutOverMinimumEvent(double startZoom, double endZoom, double minimum) {
this.startZoom = startZoom;
this.endZoom = endZoom;
this.minimum = minimum;
}
/**
* Gets the associated type.
*
* @return the associated type
*/
@Override
public Type<ZoomOutOverMinimumEventHandler> getAssociatedType() {
return TYPE;
}
/**
* Dispatch.
*
* @param handler the handler
*/
@Override
protected void dispatch(ZoomOutOverMinimumEventHandler handler) {
handler.onZoomOut(this);
}
public double getStartZoom() {
return startZoom;
}
public double getEndZoom() {
return endZoom;
}
public double getMinimum() {
return minimum;
}
}

@ -0,0 +1,22 @@
package org.gcube.portlets.user.geoportaldataviewer.client.events;
import com.google.gwt.event.shared.EventHandler;
/**
* The Interface ZoomOutEventHandler.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Nov 19, 2020
*/
public interface ZoomOutOverMinimumEventHandler extends EventHandler {
/**
* On zoom out.
*
* @param zoomOutEvent the zoom out event
*/
void onZoomOut(ZoomOutOverMinimumEvent zoomOutEvent);
}

@ -1,119 +0,0 @@
package org.gcube.portlets.user.geoportaldataviewer.client.gis;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.LinkElement;
import com.google.gwt.dom.client.Style.Display;
import com.google.gwt.dom.client.Style.Overflow;
import com.google.gwt.dom.client.Style.Position;
import com.google.gwt.dom.client.Style.Unit;
import ol.Collection;
import ol.Coordinate;
import ol.OLFactory;
import ol.OLUtil;
import ol.control.Control;
import ol.control.ControlOptions;
import ol.control.FullScreen;
import ol.control.MousePosition;
import ol.control.ZoomSlider;
import ol.geom.Polygon;
import ol.layer.Base;
import ol.layer.LayerOptions;
import ol.layer.Tile;
import ol.source.Osm;
import ol.source.XyzOptions;
/**
*
* @author Tino Desjardins
*
*/
public final class DemoUtils {
private DemoUtils() {
throw new AssertionError();
}
/**
* Creates some default controls and adds it to the collection.
*
* @param controls collection with controls
*/
public static void addDefaultControls(final Collection<Control> controls) {
controls.push(new FullScreen());
controls.push(new ZoomSlider());
MousePosition mousePosition = new MousePosition();
mousePosition.setCoordinateFormat(Coordinate.createStringXY(5));
controls.push(mousePosition);
//controls.push(new ZoomToExtent());
}
/**
* Create a MapBox logo.
*
* @return MapBox logo
*/
public static Control createMapboxLogo() {
ControlOptions controlOptions = new ControlOptions();
LinkElement mapboxLogo = Document.get().createLinkElement();
mapboxLogo.setHref("https://mapbox.com/about/maps");
mapboxLogo.setTarget("_blank");
mapboxLogo.getStyle().setPosition(Position.ABSOLUTE);
mapboxLogo.getStyle().setLeft(2, Unit.PX);
mapboxLogo.getStyle().setBottom(5, Unit.PX);
mapboxLogo.getStyle().setWidth(126, Unit.PX);
mapboxLogo.getStyle().setHeight(40, Unit.PX);
mapboxLogo.getStyle().setDisplay(Display.BLOCK);
mapboxLogo.getStyle().setOverflow(Overflow.HIDDEN);
mapboxLogo.getStyle().setBackgroundImage("url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIIAAAAoCAMAAAAFWtJHAAAAwFBMVEUAAAAAAAAAAABtbW0AAAAAAAAAAAAAAAAAAAAAAAClpaUAAADp6ekAAAD5+fna2toAAAAMDAzv7+/Nzc0AAAA2Njb8/Pz9/f3T09MAAAAAAAD7+/sAAAArKyuxsbH39/fs7OwbGxuIiIjz8/N8fHyenp7u7u74+PgAAAC8vLxWVlbx8fF1dXXl5eVcXFyUlJTQ0NDFxcVCQkLAwMC4uLj19fXo6OjW1tarq6ve3t77+/vi4uL6+vrKysrNzc3///8w7gSSAAAAP3RSTlMAOQNdPSYBPywKexLLGPCxNEHXnzFL+v2nGwf1IEiE6dBFad9jd9PuLo1V2mDDV3Cjl06SiuXIq4C3973ym6BQMVUPAAAEXElEQVR4Ae2WCVP6OBiH05L0l1IqrVbkKHJ54I0oHn+PfP9vtUle0z/YdhbH2XVnd58ZnRJIeHiPJOx//mH4vQSAN+8FjAhFxgHIaPvJeZ99hxwEElon5iAQbj85Y98g8ODwjEOMAvGFyeE3FEKgodTBqj0BJGN9DhyNd5Ta3ean9QEopfaA+LsKhnEKRExqg4FSP6Og7oEkAjBWnxSCgBX4xF+kcLoPcOBQrSv0e5kH7s1j37jECQieCTPiFGxL5VHw2zQWCeeJiPt6kjRQw0XSkIdVChf67xGa4alSnZlT6HEQ8CK9ANbhvXUF9xlDkBfTuHDWScgC9+z5FQpPI12TlwC6+sV7ixR8CUMKiwjm2GQeOQWHMGuHGdbnObJAwCEqFJpNU5H6uaPUaEIKiQfg+PHk1+u4OwW9PlWW2ctbA4BHCtp+cNK+H8Jos4gDmC5ar4Nx9waaG/2B13NgDqS7+vm2RgEtEws82P+kwIHhs/pgkQKcFIhfd7CogtGNjYMHTLpurD0ERbYFw4JaD3GlQuNAL/JEsSAF4HqlCnaHACk4WhOn4OgCkMD5hSpYNYDJTD8Y46n+jsE1kPhVCuR6QBXhFK7MUOu9O6b1SWF3b+/9ZVWMGOlu93E8UDaAhgc7bfH+0DHqKXCkHzoNDFfU+zxiVQrUC9QXTuHYtKpN59OA3IxCG4b7jh6ZFuVockaNTW09mkJzOaPU49a6mE9cAchZpQJNpUWcwgV9r6FJswsFKrITp2B5pMBMdnS0z2HZNy2+BNKxSZxZfglkrFYBJxQnpzA5sN/HheR2aFQoZBLAi149dQoyAYYjW0hHlHguBAdMcR0DuDZ5omevX6+AI8qcU7ikKT3GBHCnXwydgmCC0tRwCnGQ2Wp6Be71yNIWfQSkOl9vAI1SBCNWrwC01RROgX7BuT2HI4r7tFAw086p/NwZEdOEa7R1uAFuNmQPuKAEAjYNQ0CyeoUEWHYBnpQVQgpvc0Ph+gsKlAnKg1+vEHsw5LKciLKCAJobiWBzYFGbCKpHqkZZrxBFHEASyFI59vJPCskcwNVGOWZAOqsrR+pKbaNeAMT1CixMEtlnsqopNxUMzVJT3tY35aXZm6a6Y9QhwMN6BUJWbE1lhbMO1WehkO7poO0sK7em9MJGxp1XSbC1gtugzzSLQmGsX7VntJGSwsPZ2d2z3bIPKzdoOp3Wzqt8G4XyMVUoFIxLx1S7+piaHtCvR3FeRVsq0GFdp9C5TbGpcNqsPqyHKxcfd14h21KhuLKUFU4f3osrC7F6uV3WXFnadL7wyAPeKDXw2RoJCO5GY4DouYvb/gepVXheLoewzPseQG9N/vzilrMIjoStE3++zvle4eSurw7XEe76ynI4aq+v7lEyt1x5awiFlFLQbHKIpabnM3eJLym4Szzzc/du7SU+zOXv9UNpECH7IoH/gecURPlN9vdQpeD47yhIFNX0U0QgvID9nENm+yxk/xb+AGAjNfRZuk9qAAAAAElFTkSuQmCC)");
controlOptions.setElement(mapboxLogo);
return new Control(controlOptions);
}
/**
* Creates a test polygon geometry (triangle).
*
* @return test polygon geometry (EPSG:3857)
*/
public static Polygon createTestPolygon() {
Coordinate[][] coordinates = new Coordinate[1][4];
Coordinate point1 = new Coordinate(13.36, 52.53);
Coordinate point2 = new Coordinate(13.36, 52.51);
Coordinate point3 = new Coordinate(13.37, 52.52);
Coordinate point4 = new Coordinate(13.36, 52.53);
coordinates[0][0] = point1;
coordinates[0][1] = point2;
coordinates[0][2] = point3;
coordinates[0][3] = point4;
Coordinate[][] tranformedCoordinates = new Coordinate[coordinates.length][];
tranformedCoordinates[0] = OLUtil.transform(coordinates[0], GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857);
return OLFactory.createPolygon(tranformedCoordinates);
}
public static Base createOsmLayer() {
XyzOptions osmSourceOptions = OLFactory.createOptions();
Osm osmSource = new Osm(osmSourceOptions);
LayerOptions osmLayerOptions = OLFactory.createOptions();
osmLayerOptions.setSource(osmSource);
return new Tile(osmLayerOptions);
}
}

@ -0,0 +1,48 @@
package org.gcube.portlets.user.geoportaldataviewer.client.gis;
import jsinterop.annotations.JsMethod;
import jsinterop.annotations.JsOverlay;
import jsinterop.annotations.JsPackage;
import jsinterop.annotations.JsType;
import ol.Coordinate;
import ol.Extent;
/**
* The Class ExtentWrapped.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Nov 11, 2020
*/
@JsType(isNative = true, name = "Array", namespace = JsPackage.GLOBAL)
public class ExtentWrapped extends ol.Extent {
@JsOverlay
private static final String PACKAGE_EXTENT = "ol.extent";
/**
* Instantiates a new extent wrapped.
*
* @param minX the min X
* @param minY the min Y
* @param maxX the max X
* @param maxY the max Y
*/
public ExtentWrapped(double minX, double minY, double maxX, double maxY) {
super(minX, minY, maxX, maxY);
}
/**
* @param coordinate coordinate to check.
* @return true if the passed coordinate is contained or on the edge of the
* extent.
*/
@JsOverlay
public final Coordinate getCenter() {
return getCenter((ol.Extent) this);
}
@JsMethod(name = "getCenter", namespace = PACKAGE_EXTENT)
private static native Coordinate getCenter(Extent extent);
}

@ -0,0 +1,338 @@
package org.gcube.portlets.user.geoportaldataviewer.client.gis;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.Images;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery.TYPE;
import com.google.gwt.core.client.GWT;
import ol.Coordinate;
import ol.Feature;
import ol.Map;
import ol.MapBrowserEvent;
import ol.MapOptions;
import ol.OLFactory;
import ol.View;
import ol.ViewOptions;
import ol.control.Attribution;
import ol.event.EventListener;
import ol.geom.Point;
import ol.interaction.KeyboardPan;
import ol.interaction.KeyboardZoom;
import ol.layer.Image;
import ol.layer.LayerOptions;
import ol.layer.Tile;
import ol.layer.VectorLayerOptions;
import ol.proj.Projection;
import ol.proj.ProjectionOptions;
import ol.source.ImageWms;
import ol.source.ImageWmsOptions;
import ol.source.ImageWmsParams;
import ol.source.Osm;
import ol.source.XyzOptions;
import ol.style.Icon;
import ol.style.IconOptions;
import ol.style.Style;
import ol.style.Text;
import ol.style.TextOptions;
/**
* The Class LightOpenLayerOSM.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Nov 11, 2020
*/
public class LightOpenLayerOSM {
/** 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();
private boolean isQueryPointActive;
private ol.layer.Vector geometryLayer;
private String markerURL = Images.ICONS.mapMarkerIcon().getURL();
/**
* Instantiates a new open layer OSM.
*
* @param divTargetId the div target id
*/
/* (non-Javadoc)
* @see de.desjardins.ol3.demo.client.example.Example#show()
*/
public LightOpenLayerOSM(String divTargetId) {
// create a OSM-layer
XyzOptions osmSourceOptions = OLFactory.createOptions();
Osm osmSource = new Osm(osmSourceOptions);
LayerOptions osmLayerOptions = OLFactory.createOptions();
osmLayerOptions.setSource(osmSource);
Tile osmLayer = new Tile(osmLayerOptions);
// create a projection
projectionOptions.setCode(GeoportalDataViewerConstants.EPSG_3857);
projectionOptions.setUnits("m");
Projection projection = new Projection(projectionOptions);
viewOptions.setProjection(projection);
viewOptions.setMaxZoom(19);
//viewOptions.setExtent(new Extent(-180, -90, 180, 90));
// create a view
view = new View(viewOptions);
// //EPSG_4326_TO_ITALY
// Coordinate centerCoordinate = OLFactory.createCoordinate(12.45, 42.98);
// Coordinate transformedCenterCoordinate = Projection.transform(centerCoordinate, GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857);
//
// view.setCenter(transformedCenterCoordinate);
// view.setZoom(5);
// create the map
MapOptions mapOptions = OLFactory.createOptions();
mapOptions.setTarget(divTargetId);
mapOptions.setView(view);
map = new Map(mapOptions);
map.addLayer(osmLayer);
//map.addLayer(tileDebugLayer);
// add some controls
// map.addControl(OLFactory.createScaleLine());
// DemoUtils.addDefaultControls(map.getControls());
Attribution attribution = new Attribution();
attribution.setCollapsed(true);
map.addClickListener(new EventListener<MapBrowserEvent>() {
@Override
public void onEvent(MapBrowserEvent event) {
// TODO Auto-generated method stub
Coordinate coordinate = event.getCoordinate();
if(isQueryPointActive) {
double lon = coordinate.getX();
double lat = coordinate.getY();
int w = (int) map.getSize().getWidth();
int h = (int) map.getSize().getHeight();
// handler.clickOnMap(x, y, w, h);
// ratio - mapPixelWeight : bboxWeight = 10px : geoRectangleWidth
// where 10px is the pixel diameter dimension of the clicked point
double bboxWidth = Math.abs(getExtent().getLowerLeftX() - getExtent().getUpperRightX());
double geoWidth = (bboxWidth / w) * (20 / 2);
double x1 = Math.min(lon+geoWidth, lon-geoWidth);
double x2 = Math.max(lon+geoWidth, lon-geoWidth);
double y1 = Math.min(lat+geoWidth, lat-geoWidth);
double y2 = Math.max(lat+geoWidth, lat-geoWidth);
//GWT.log("("+x1+","+y1+")("+x2+","+y2+")");
// Point pt = new Point(coordinate);
// ol.Extent extent = pt.getExtent();
// //new ClickDataInfo(x1, y1, x2, y2)
// SelectDataInfo selectDataInfo
//selectBox(new GeoQuery(x1, y1, x2, y2, GeoQuery.TYPE.POINT));
GeoQuery select = new GeoQuery(x1, y1, x2, y2, TYPE.POINT);
}
}
});
map.addControl(attribution);
// add some interactions
map.addInteraction(new KeyboardPan());
map.addInteraction(new KeyboardZoom());
}
/**
* Sets the center.
*
* @param centerCoordinate the new center
*/
public void setCenter(Coordinate centerCoordinate) {
view.setCenter(centerCoordinate);
}
/**
* Sets the center.
*
* @param centerCoordinate the new center
*/
public void setZoom(int zoom) {
view.setZoom(zoom);
}
/**
* Adds the WMS layer.
*
* @param mapServerHost the map server host
* @param layerName the layer name
* @return the image
*/
public Image addWMSLayer(String mapServerHost, String layerName) {
GWT.log("Adding wmsLayer with mapServerHost: "+mapServerHost+", layerName: "+layerName);
ImageWmsParams imageWMSParams = OLFactory.createOptions();
imageWMSParams.setLayers(layerName);
ImageWmsOptions imageWMSOptions = OLFactory.createOptions();
imageWMSOptions.setUrl(mapServerHost);
imageWMSOptions.setParams(imageWMSParams);
//imageWMSOptions.setRatio(1.5f);
ImageWms imageWMSSource = new ImageWms(imageWMSOptions);
LayerOptions layerOptions = OLFactory.createOptions();
layerOptions.setSource(imageWMSSource);
ol.layer.Image wmsLayer = new ol.layer.Image(layerOptions);
//visibleLayerItems
map.addLayer(wmsLayer);
return wmsLayer;
}
/**
* Gets the first layer.
*
* @return the first layer
*/
public Image getFirstLayer() {
if(map.getLayers()!=null) {
return (Image) map.getLayers().getArray()[0];
}
return null;
}
/**
* Adds the point.
*
* @param coordinate the coordinate
* @param showCoordinateText the show coordinate text
* @param asMarker the as marker
*/
public void addPoint(Coordinate coordinate, boolean showCoordinateText, boolean asMarker) {
if(geometryLayer!=null) {
map.removeLayer(geometryLayer);
}else {
}
Style style = new Style();
if(asMarker) {
IconOptions iconOptions = new IconOptions();
iconOptions.setSrc(markerURL);
Icon icon = new Icon(iconOptions);
style.setImage(icon);
}
if(showCoordinateText) {
TextOptions textOptions = new TextOptions();
textOptions.setOffsetY(-25);
// StrokeOptions strokeOptions = new StrokeOptions();
// strokeOptions.setColor(new Color(0, 0, 255, 0.0));
// strokeOptions.setWidth(4);
// Stroke stroke = new Stroke(strokeOptions);
// textOptions.setStroke(stroke);
// FillOptions fillOptions = new FillOptions();
// fillOptions.setColor(new Color(0, 0, 0, 0.0));
// textOptions.setFill(new Fill(fillOptions));
Coordinate transfCoord = MapUtils.transformCoordiante(coordinate, GeoportalDataViewerConstants.EPSG_3857, GeoportalDataViewerConstants.EPSG_4326);
textOptions.setText("Long: "+transfCoord.getX() + ", Lat: "+transfCoord.getY());
Text text = new Text(textOptions);
// FillOptions fillOptions = new FillOptions();
// Color color = new Color(217, 217, 223, 0.0);
// fillOptions.setColor(color);
// Fill fill = new Fill(fillOptions);
// style.setFill(fill);
style.setText(text);
}
Point thePoint = new Point(coordinate);
Feature vf = new Feature(thePoint);
vf.setStyle(style);
ol.source.Vector vector = new ol.source.Vector();
vector.addFeature(vf);
VectorLayerOptions vectorLayerOptions = new VectorLayerOptions();
vectorLayerOptions.setSource(vector);
geometryLayer = new ol.layer.Vector(vectorLayerOptions);
map.addLayer(geometryLayer);
}
/**
* Gets the map.
*
* @return the map
*/
public Map getMap() {
return map;
}
/**
* Gets the projection code.
*
* @return the projection code
*/
public String getProjectionCode() {
return map.getView().getProjection().getCode();
}
/**
* Gets the current zoom level.
*
* @return the current zoom level
*/
public double getCurrentZoomLevel() {
return map.getView().getZoom();
}
/**
* Gets the bbox.
*
* @return the bbox
*/
public ol.Extent getBBOX() {
return getExtent();
}
/**
* Gets the extent.
*
* @return the extent
*/
public ol.Extent getExtent() {
return this.map.getView().calculateExtent(map.getSize());
}
}

@ -0,0 +1,93 @@
package org.gcube.portlets.user.geoportaldataviewer.client.gis;
import ol.Collection;
import ol.Coordinate;
import ol.control.Control;
import ol.control.FullScreen;
import ol.control.MousePosition;
import ol.control.ZoomSlider;
import ol.geom.LineString;
import ol.proj.Projection;
/**
* The Class MapUtils.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Nov 12, 2020
*/
public final class MapUtils {
/**
* Creates some default controls and adds it to the collection.
*
* @param controls collection with controls
*/
public static void addDefaultControls(final Collection<Control> controls) {
controls.push(new FullScreen());
controls.push(new ZoomSlider());
MousePosition mousePosition = new MousePosition();
mousePosition.setCoordinateFormat(Coordinate.createStringXY(5));
controls.push(mousePosition);
//controls.push(new ZoomToExtent());
}
/**
* Transform coordiante.
*
* @param centerCoordinate the center coordinate
* @param source the source
* @param target the target
* @return the coordinate
*/
public static Coordinate transformCoordiante(Coordinate centerCoordinate, String source, String target) {
return Projection.transform(centerCoordinate, source, target);
}
/**
* Distance between centroid.
*
* @param ex1 the ex 1
* @param ex2 the ex 2
* @return the long
*/
public static long distanceBetweenCentroid(ExtentWrapped ex1, ExtentWrapped ex2) {
return distanceBetween(ex1.getCenter(),ex2.getCenter());
}
/**
* Distance between.
*
* @param c1 the c 1
* @param c2 the c 2
* @return the long
*/
public static long distanceBetween(Coordinate c1, Coordinate c2) {
Coordinate[] arrayCoordinate = new Coordinate[2];
arrayCoordinate[0] = c1;
arrayCoordinate[1] = c2;
LineString ls = new LineString(arrayCoordinate);
// GWT.log("Line length is: "+ls);
return Math.round(ls.getLength() * 100) / 100;
}
/**
* Reverse coordinate.
*
* @param coord the coord
* @return the coordinate
*/
public static Coordinate reverseCoordinate(Coordinate coord){
return new Coordinate(coord.getY(), coord.getX());
}
}

@ -1,11 +1,11 @@
package org.gcube.portlets.user.geoportaldataviewer.client.gis;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
import org.gcube.portlets.user.geoportaldataviewer.client.events.QueryDataEvent;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery.TYPE;
import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEvent;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Visibility;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
@ -15,10 +15,12 @@ import ol.Collection;
import ol.Coordinate;
import ol.Map;
import ol.MapBrowserEvent;
import ol.MapEvent;
import ol.MapOptions;
import ol.OLFactory;
import ol.Overlay;
import ol.OverlayOptions;
import ol.Size;
import ol.View;
import ol.ViewOptions;
import ol.control.Attribution;
@ -52,8 +54,18 @@ import ol.source.XyzOptions;
*
* Oct 27, 2020
*/
public class OpenLayerOSM {
public abstract class OpenLayerOSM {
public abstract void clickListener(MapBrowserEvent event);
public abstract void moveEndListener(MapEvent event);
public abstract void moveStartListener(MapEvent event);
public abstract void mapZoomListener(MapEvent event);
public abstract void mapZoomEndListener(MapEvent event);
/** The map. */
private Map map;
@ -112,13 +124,6 @@ public class OpenLayerOSM {
// create a view
view = new View(viewOptions);
//EPSG_4326_TO_ITALY
Coordinate centerCoordinate = OLFactory.createCoordinate(12.45, 42.98);
Coordinate transformedCenterCoordinate = Projection.transform(centerCoordinate, GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857);
view.setCenter(transformedCenterCoordinate);
view.setZoom(5);
// create the map
MapOptions mapOptions = OLFactory.createOptions();
@ -132,59 +137,87 @@ public class OpenLayerOSM {
// add some controls
map.addControl(OLFactory.createScaleLine());
DemoUtils.addDefaultControls(map.getControls());
MapUtils.addDefaultControls(map.getControls());
Attribution attribution = new Attribution();
attribution.setCollapsed(true);
map.addControl(attribution);
// add some interactions
map.addInteraction(new KeyboardPan());
map.addInteraction(new KeyboardZoom());
map.addClickListener(new EventListener<MapBrowserEvent>() {
bindEvents();
}
private void bindEvents() {
map.addClickListener(new EventListener<MapBrowserEvent>() {
@Override
public void onEvent(MapBrowserEvent event) {
// TODO Auto-generated method stub
Coordinate coordinate = event.getCoordinate();
if(isQueryPointActive) {
double lon = coordinate.getX();
double lat = coordinate.getY();
int w = (int) map.getSize().getWidth();
int h = (int) map.getSize().getHeight();
// handler.clickOnMap(x, y, w, h);
// ratio - mapPixelWeight : bboxWeight = 10px : geoRectangleWidth
// where 10px is the pixel diameter dimension of the clicked point
double bboxWidth = Math.abs(getExtent().getLowerLeftX() - getExtent().getUpperRightX());
double geoWidth = (bboxWidth / w) * (20 / 2);
double x1 = Math.min(lon+geoWidth, lon-geoWidth);
double x2 = Math.max(lon+geoWidth, lon-geoWidth);
double y1 = Math.min(lat+geoWidth, lat-geoWidth);
double y2 = Math.max(lat+geoWidth, lat-geoWidth);
//GWT.log("("+x1+","+y1+")("+x2+","+y2+")");
// Point pt = new Point(coordinate);
// ol.Extent extent = pt.getExtent();
// //new ClickDataInfo(x1, y1, x2, y2)
// SelectDataInfo selectDataInfo
//selectBox(new GeoQuery(x1, y1, x2, y2, GeoQuery.TYPE.POINT));
GeoQuery select = new GeoQuery(x1, y1, x2, y2, TYPE.POINT);
eventBus.fireEvent(new QueryDataEvent(select,coordinate));
}
clickListener(event);
}
});
map.addControl(attribution);
map.addMoveEndListener(new EventListener<MapEvent>() {
@Override
public void onEvent(MapEvent event) {
moveEndListener(event);
}
});
map.addMoveStartListener(new EventListener<MapEvent>() {
@Override
public void onEvent(MapEvent event) {
moveStartListener(event);
}
});
map.addMapZoomListener(new EventListener<MapEvent>() {
@Override
public void onEvent(MapEvent event) {
mapZoomListener(event);
}
});
map.addMapZoomEndListener(new EventListener<MapEvent>() {
@Override
public void onEvent(MapEvent event) {
mapZoomEndListener(event);
}
});
}
/**
* Sets the center.
*
* @param centerCoordinate the new center
*/
public void setCenter(Coordinate centerCoordinate) {
view.setCenter(centerCoordinate);
}
/**
* Sets the center.
*
* @param centerCoordinate the new center
*/
public void setZoom(int zoom) {
view.setZoom(zoom);
}
// add some interactions
map.addInteraction(new KeyboardPan());
map.addInteraction(new KeyboardZoom());
}
public void showPopup(String html, Coordinate coordinate) {
GWT.log("Showing popup on: "+coordinate);
Element elPopup = DOM.getElementById("popup");
elPopup.getStyle().setVisibility(Visibility.VISIBLE);
if(popupOverlay==null) {
Element elPopup = DOM.getElementById("popup");
popupOverlay = addOverlay(elPopup);
addPopupCloserHandelr(popupOverlay);
}
@ -193,6 +226,13 @@ public class OpenLayerOSM {
popupOverlay.setPosition(coordinate);
}
public void hidePopup() {
if(popupOverlay!=null) {
Element elPopup = DOM.getElementById("popup");
elPopup.getStyle().setVisibility(Visibility.HIDDEN);
}
}
/**
* Adds the popup closer handelr.
*
@ -230,19 +270,19 @@ public class OpenLayerOSM {
}-*/;
/**
* Adds the WMS layer.
*
* @param mapServerHost the map server host
* @param layerName the layer name
* @param layerItem the layer item
*/
public void addWMSLayer(String mapServerHost, String layerName) {
public void addWMSLayer(LayerItem layerItem) {
ImageWmsParams imageWMSParams = OLFactory.createOptions();
imageWMSParams.setLayers(layerName);
imageWMSParams.setLayers(layerItem.getName());
ImageWmsOptions imageWMSOptions = OLFactory.createOptions();
imageWMSOptions.setUrl(mapServerHost);
imageWMSOptions.setUrl(layerItem.getMapServerHost());
imageWMSOptions.setParams(imageWMSParams);
//imageWMSOptions.setRatio(1.5f);
@ -256,8 +296,39 @@ public class OpenLayerOSM {
//visibleLayerItems
map.addLayer(wmsLayer);
GWT.log("Fired the event Added Layer");
eventBus.fireEvent(new AddedLayerToMapEvent(layerItem));
}
// /**
// * Adds the WMS layer.
// *
// * @param mapServerHost the map server host
// * @param layerName the layer name
// */
// public void addWMSLayer(String mapServerHost, String layerName) {
//
// ImageWmsParams imageWMSParams = OLFactory.createOptions();
// imageWMSParams.setLayers(layerName);
//
// ImageWmsOptions imageWMSOptions = OLFactory.createOptions();
// imageWMSOptions.setUrl(mapServerHost);
// imageWMSOptions.setParams(imageWMSParams);
// //imageWMSOptions.setRatio(1.5f);
//
// ImageWms imageWMSSource = new ImageWms(imageWMSOptions);
//
// LayerOptions layerOptions = OLFactory.createOptions();
// layerOptions.setSource(imageWMSSource);
//
// Image wmsLayer = new Image(layerOptions);
//
// //visibleLayerItems
//
// map.addLayer(wmsLayer);
// }
/**
* Adds the point vector source.
@ -423,6 +494,21 @@ public class OpenLayerOSM {
return Projection.transform(centerCoordinate, source, target);
}
public boolean isQueryBoxActive() {
return isQueryBoxActive;
}
public boolean isQueryPointActive() {
return isQueryPointActive;
}
public Size getSize() {
return map.getSize();
}
public boolean mapInstancied() {
return this.map!=null;
}
}

@ -10,4 +10,10 @@ public interface Images extends ClientBundle {
@Source("loading.gif")
ImageResource loading();
@Source("map-marker-icon.png")
ImageResource mapMarkerIcon();
@Source("icon_share.png")
ImageResource shareIcon();
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 731 B

@ -0,0 +1,88 @@
package org.gcube.portlets.user.geoportaldataviewer.client.ui;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ClosedViewDetailsEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.products.concessioni.ConcessioneView;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaItemRef;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.ConcessioneDV;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.RecordDV;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Widget;
public class DetailsPanel extends Composite {
private static DetailsPanelUiBinder uiBinder = GWT.create(DetailsPanelUiBinder.class);
@UiField
Button closeButton;
@UiField
HTMLPanel datailsContainerPanel;
@UiField
HTMLPanel detailsHTMLPanel;
private RecordDV displayedRecord = null;
private HandlerManager applicationBus;
interface DetailsPanelUiBinder extends UiBinder<Widget, DetailsPanel> {
}
public DetailsPanel() {
initWidget(uiBinder.createAndBindUi(this));
closeButton.setType(ButtonType.LINK);
closeButton.setIcon(IconType.REMOVE_SIGN);
closeButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
hidePanelDetails();
applicationBus.fireEvent(new ClosedViewDetailsEvent());
}
});
}
public void setApplicationBus(HandlerManager applicationBus) {
this.applicationBus = applicationBus;
}
public void showDetailsFor(ConcessioneDV cdv, GeoNaItemRef geonaItemRef) {
this.displayedRecord = cdv;
datailsContainerPanel.clear();
if(detailsHTMLPanel.getParent()!=null)
detailsHTMLPanel.getParent().getElement().setScrollTop(0);
datailsContainerPanel.add(new ConcessioneView(geonaItemRef, cdv));
showPanelDetails();
}
private void showPanelDetails() {
detailsHTMLPanel.setVisible(true);
}
public void hidePanelDetails() {
this.displayedRecord = null;
datailsContainerPanel.clear();
detailsHTMLPanel.setVisible(false);
}
public RecordDV getDisplayedRecord() {
return displayedRecord;
}
}

@ -0,0 +1,19 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
<ui:style>
.important {
font-weight: bold;
}
.to-align-right{
position: absolute;
top: 10px;
right: 10px;
}
</ui:style>
<g:HTMLPanel ui:field="detailsHTMLPanel" visible="false">
<b:Button ui:field="closeButton" addStyleNames="{style.to-align-right}"></b:Button>
<g:HTMLPanel ui:field="datailsContainerPanel"></g:HTMLPanel>
</g:HTMLPanel>
</ui:UiBinder>

@ -1,40 +1,53 @@
package org.gcube.portlets.user.geoportaldataviewer.client.ui;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerOSM;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.products.ConcessioneView;
import org.gcube.portlets.user.geoportaldataviewer.client.util.LoaderIcon;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaItemRef;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.ConcessioneDV;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.RecordDV;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.NavLink;
import com.github.gwtbootstrap.client.ui.Tab;
import com.github.gwtbootstrap.client.ui.TabPanel;
import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Widget;
/**
* The Class GeonaDataViewMainPanel.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Nov 19, 2020
*/
public class GeonaDataViewMainPanel extends Composite {
private static GeonaDataViewMainPanelUiBinder uiBinder = GWT.create(GeonaDataViewMainPanelUiBinder.class);
/**
* The Interface GeonaDataViewMainPanelUiBinder.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Nov 19, 2020
*/
interface GeonaDataViewMainPanelUiBinder extends UiBinder<Widget, GeonaDataViewMainPanel> {
}
// @UiField
// Tab mapTabPanel;
@UiField
HTMLPanel mainContainerPanel;
@UiField
Tab mapTabPanel;
HTMLPanel mainToolBar;
@UiField
NavLink dataPointSelection;
@ -46,23 +59,28 @@ public class GeonaDataViewMainPanel extends Composite {
Button removeQuery;
@UiField
TabPanel mainTabPanel;
private List<Tab> listTabs = new ArrayList<Tab>();
DetailsPanel detailsPanel;
private MapPanel mapPanel;
private OpenLayerOSM map;
private HandlerManager eventBus;
private Map<Long, Tab> mapProducts = new HashMap<Long, Tab>();
private HandlerManager applicationBus;
public GeonaDataViewMainPanel(HandlerManager eventBus) {
/**
* Instantiates a new geona data view main panel.
*
* @param applicationBus the application bus
* @param mapHeight the map height
*/
public GeonaDataViewMainPanel(HandlerManager applicationBus, int mapHeight) {
initWidget(uiBinder.createAndBindUi(this));
this.eventBus = eventBus;
mapPanel = new MapPanel("600px");
mapTabPanel.add(mapPanel);
this.applicationBus = applicationBus;
mapPanel = new MapPanel(mapHeight+"px");
detailsPanel.setHeight(mapHeight+"px");
detailsPanel.setApplicationBus(applicationBus);
mainContainerPanel.add(mapPanel);
bindHandlers();
dataPointSelection.setIcon(IconType.SCREENSHOT);
dataBoxSelection.setIcon(IconType.BOOKMARK);
@ -70,18 +88,38 @@ public class GeonaDataViewMainPanel extends Composite {
removeQuery.setIcon(IconType.REMOVE);
}
public void setMapHeight(int height) {
mapPanel.setHeight(height + "px");
/**
* Sets the panels height.
*
* @param height the new panels height
*/
public void setPanelsHeight(int height) {
String toH = height + "px";
mapPanel.setMapHeight(height);
detailsPanel.setHeight(toH);
}
/**
* Gets the map panel.
*
* @return the map panel
*/
public MapPanel getMapPanel() {
return mapPanel;
}
/**
* Sets the map.
*
* @param map the new map
*/
public void setMap(OpenLayerOSM map) {
this.map = map;
}
/**
* Bind handlers.
*/
public void bindHandlers() {
dataPointSelection.addClickHandler(new ClickHandler() {
@ -94,8 +132,6 @@ public class GeonaDataViewMainPanel extends Composite {
map.addPointVectorSource();
}
removeQuery.setVisible(true);
//dataBoxSelection.setActive(false);
//dataBoxSelection.getElement().removeClassName("active");
}
});
@ -109,8 +145,6 @@ public class GeonaDataViewMainPanel extends Composite {
map.addExtentInteraction();
}
removeQuery.setVisible(true);
//dataPointSelection.setActive(false);
//dataPointSelection.getElement().removeClassName("active");
}
});
@ -124,91 +158,33 @@ public class GeonaDataViewMainPanel extends Composite {
});
}
public void renderProductIntoTab(Tab tab, ConcessioneDV cdv) {
tab.clear();
tab.setHeading(cdv.getNome());
tab.add(new ConcessioneView(cdv));
mapProducts.put(cdv.getId(), tab);
selectTabForProductId(cdv.getId());
}
public boolean selectTabForProductId(long productId) {
Tab product = mapProducts.get(productId);
if(product!=null) {
selectTab(product);
//found
return true;
}
//not found
return false;
/**
* Show as details.
*
* @param concessioneDV the concessione DV
* @param geonaItemRef the geona item ref
*/
public void showAsDetails(ConcessioneDV concessioneDV, GeoNaItemRef geonaItemRef) {
detailsPanel.showDetailsFor(concessioneDV, geonaItemRef);
}
/**
* Adds the as tab.
*
* @param tabTitle the tab title
* @param tabDescr the tab descr
* @param spinner the spinner
* @param w the w
* @return the tab
* Hide panel details.
*/
public Tab addAsTab(String tabTitle, boolean spinner, Widget w){
// field_create_analytics_request.setActive(false);
Tab tab = new Tab();
mainTabPanel.add(tab);
if(spinner) {
LoaderIcon loader = new LoaderIcon("Loading...");
tab.add(loader);
}
tab.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
}
});
public void hidePanelDetails() {
detailsPanel.hidePanelDetails();
//tab.setActive(true);
tab.setHeading(tabTitle);
listTabs.add(tab);
if(w!=null)
tab.add(w);
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
selectTab(tab);
}
});
return tab;
// tab.setActive(true);
}
private void selectTab(Tab theTab) {
int i = 1;
for (Tab tab : listTabs) {
GWT.log("Selecting "+tab);
tab.setActive(false);
if(tab.equals(theTab)) {
GWT.log("Tab selected "+tab);
mainTabPanel.selectTab(i);
}
i++;
}
/**
* Gets the displyed record.
*
* @return the displyed record
*/
public RecordDV getDisplyedRecord() {
return detailsPanel.getDisplayedRecord();
}
}

@ -1,15 +1,17 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui"
xmlns:c="urn:import:org.gcube.portlets.user.geoportaldataviewer.client.ui">
<ui:style>
.margin-right-10 {
margin-right: 10px;
}
</ui:style>
<g:HTMLPanel ui:field="mainHTMLPanel">
<b:TabPanel ui:field="mainTabPanel" tabPosition="top">
<b:Tab ui:field="mapTabPanel" active="true" heading="Map">
<g:HTMLPanel ui:field="mainContainerPanel">
<g:HTMLPanel ui:field="mainToolBar"
addStyleNames="inner-toolbar">
<b:DropdownButton type="LINK" text="Query">
<!-- <b:ButtonGroup toggle="checkbox" ui:field="buttonGroup"> -->
<b:NavLink ui:field="dataPointSelection"
@ -19,8 +21,11 @@
Selection</b:NavLink>
<!-- </b:ButtonGroup> -->
</b:DropdownButton>
<b:Button type="LINK" ui:field="removeQuery" text="Remove Query" visible="false"></b:Button>
</b:Tab>
</b:TabPanel>
<b:Button type="LINK" ui:field="removeQuery"
text="Remove Query" visible="false"></b:Button>
</g:HTMLPanel>
</g:HTMLPanel>
<c:DetailsPanel ui:field="detailsPanel"
addStyleNames="details-panel"></c:DetailsPanel>
</g:HTMLPanel>
</ui:UiBinder>

@ -0,0 +1,474 @@
package org.gcube.portlets.user.geoportaldataviewer.client.ui.dialogs;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaItemRef;
import org.gcube.portlets.user.geoportaldataviewer.shared.PublicLink;
import com.github.gwtbootstrap.client.ui.Alert;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.ControlGroup;
import com.github.gwtbootstrap.client.ui.Fieldset;
import com.github.gwtbootstrap.client.ui.Modal;
import com.github.gwtbootstrap.client.ui.ModalFooter;
import com.github.gwtbootstrap.client.ui.TextBox;
import com.github.gwtbootstrap.client.ui.Tooltip;
import com.github.gwtbootstrap.client.ui.constants.VisibilityChange;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Element;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.MouseOverEvent;
import com.google.gwt.event.dom.client.MouseOverHandler;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.Random;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
/**
* The Class DialogShareableLink.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Sep 19, 2019
*/
public class DialogShareableLink extends Composite {
private static DialogShareableLinkUiBinder uiBinder = GWT.create(DialogShareableLinkUiBinder.class);
private Modal modalBox = new Modal();
@UiField
ControlGroup cgPublicLink;
@UiField
ControlGroup cgPrivateLongLink;
@UiField
ControlGroup cgPublicLongLink;
@UiField
TextBox textPublicLink;
@UiField
TextBox textPrivateLink;
@UiField
TextBox textPrivateLongLink;
@UiField
TextBox textPublicLongLink;
@UiField
Alert errorAlert;
@UiField
Alert actionAlert;
// @UiField
// Well alertFilePublicLink;
@UiField
Fieldset fieldSetPrivate;
@UiField
Fieldset fieldSetPublic;
@UiField
VerticalPanel fieldPrivateSharing;
// @UiField
// VerticalPanel filedEnableDisableSharing;
@UiField
Label labelLinkSharing;
@UiField
Button privateLinkCopyButton;
@UiField
Button privateLongLinkCopyButton;
@UiField
Button publicLinkCopyButton;
@UiField
Button publicLongLinkCopyButton;
//
// @UiField
// Well wellPrivateLinkDescription;
@UiField
Button showPrivateLongLinkButton;
@UiField
Button showPublicLongLinkButton;
// @UiField
// HTMLPanel panelFieldsContainer;
private GeoNaItemRef geonItemRef;
private String fileVersion;
private boolean itemIsPublicStatus;
private PublicLink openPublicLink;
private PublicLink restrictedPublicLink;
private final String privateShareToFileDescription = "By sharing the following Private Link "
+ "with your coworkers, you will enact the users of the group the folder is shared with, "
+ "to access the file and the shared folder content. Login required";
/**
* The Interface DialogShareableLinkUiBinder.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Sep 19, 2019
*/
interface DialogShareableLinkUiBinder extends UiBinder<Widget, DialogShareableLink> {
}
/**
* Instantiates a new dialog shareable link.
*
* @param item the item
* @param version the version
*/
public DialogShareableLink(GeoNaItemRef item, String version) {
initWidget(uiBinder.createAndBindUi(this));
this.geonItemRef = item;
this.fileVersion = version;
this.actionAlert.setAnimation(true);
//cgRemovePublicLink.setVisible(false);
// fieldSetPrivate.setVisible(false);
// fieldPrivateSharing.setVisible(false);
cgPublicLink.setVisible(true);
fieldPrivateSharing.setVisible(false);
fieldSetPrivate.setVisible(false);
GeoportalDataViewerServiceAsync.Util.getInstance().getMyLogin(new AsyncCallback<String>() {
@Override
public void onFailure(Throwable caught) {
// TODO Auto-generated method stub
}
@Override
public void onSuccess(String result) {
if(result!=null) {
fieldPrivateSharing.setVisible(true);
fieldSetPrivate.setVisible(true);
}
}
});
showMessage("", false);
//alertFilePublicLink.setVisible(true);
loadAndShowPublicLinksForItem(item);
//getElement().setClassName("gwt-DialogBoxNew");
modalBox.setTitle("Share Link...");
ModalFooter modalFooter = new ModalFooter();
final Button buttClose = new Button("Close");
modalFooter.add(buttClose);
buttClose.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
modalBox.hide();
}
});
addEvents();
textPrivateLink.setId(Random.nextInt()+Random.nextInt()+"");
textPrivateLongLink.setId(Random.nextInt()+Random.nextInt()+"");
textPublicLink.setId(Random.nextInt()+Random.nextInt()+"");
textPublicLongLink.setId(Random.nextInt()+Random.nextInt()+"");
modalBox.add(this);
modalBox.add(modalFooter);
modalBox.show();
}
/**
* Adds the events.
*/
private void addEvents() {
showPrivateLongLinkButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
showPrivateLongLinkButton.setVisible(false);
cgPrivateLongLink.setVisible(true);
textPrivateLongLink.setText(restrictedPublicLink.getCompleteURL());
}
});
showPublicLongLinkButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
if(openPublicLink!=null && openPublicLink.getCompleteURL()!=null) {
showPublicLongLinkButton.setVisible(false);
cgPublicLongLink.setVisible(true);
textPublicLongLink.setText(openPublicLink.getCompleteURL());
}else {
textPublicLongLink.setText("Not available");
showPublicLongLinkButton.setText("Not available");
showPublicLongLinkButton.addStyleName("href-disabled");
publicLongLinkCopyButton.setEnabled(false);
// showPublicLongLinkButton.setVisible(false);
disableTextBox(textPublicLongLink);
}
}
});
privateLinkCopyButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final Element elem = event.getRelativeElement();
elem.setTitle("Copied to clipboard");
Tooltip.changeVisibility(elem, VisibilityChange.TOGGLE.get());
Timer timer = new Timer() {
@Override
public void run() {
Tooltip.changeVisibility(elem, VisibilityChange.HIDE.get());
}
};
timer.schedule(1000);
copyToClipboard(textPrivateLink.getId());
}
});
privateLinkCopyButton.addMouseOverHandler(new MouseOverHandler() {
@Override
public void onMouseOver(MouseOverEvent event) {
final Element elem = event.getRelativeElement();
elem.setTitle("Copy");
}
});
privateLongLinkCopyButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final Element elem = event.getRelativeElement();
Tooltip.changeVisibility(elem, VisibilityChange.TOGGLE.get());
Timer timer = new Timer() {
@Override
public void run() {
Tooltip.changeVisibility(elem, VisibilityChange.HIDE.get());
}
};
timer.schedule(1000);
copyToClipboard(textPrivateLongLink.getId());
}
});
privateLongLinkCopyButton.addMouseOverHandler(new MouseOverHandler() {
@Override
public void onMouseOver(MouseOverEvent event) {
final Element elem = event.getRelativeElement();
elem.setTitle("Copy");
}
});
publicLinkCopyButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final Element elem = event.getRelativeElement();
Tooltip.changeVisibility(elem, VisibilityChange.TOGGLE.get());
Timer timer = new Timer() {
@Override
public void run() {
Tooltip.changeVisibility(elem, VisibilityChange.HIDE.get());
}
};
timer.schedule(1000);
copyToClipboard(textPublicLink.getId());
}
});
publicLinkCopyButton.addMouseOverHandler(new MouseOverHandler() {
@Override
public void onMouseOver(MouseOverEvent event) {
final Element elem = event.getRelativeElement();
elem.setTitle("Copy");
}
});
publicLongLinkCopyButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final Element elem = event.getRelativeElement();
Tooltip.changeVisibility(elem, VisibilityChange.TOGGLE.get());
Timer timer = new Timer() {
@Override
public void run() {
Tooltip.changeVisibility(elem, VisibilityChange.HIDE.get());
}
};
timer.schedule(1000);
copyToClipboard(textPublicLongLink.getId());
}
});
publicLongLinkCopyButton.addMouseOverHandler(new MouseOverHandler() {
@Override
public void onMouseOver(MouseOverEvent event) {
final Element elem = event.getRelativeElement();
elem.setTitle("Copy");
}
});
textPrivateLink.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
textPrivateLink.selectAll();
}
});
textPrivateLongLink.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
textPrivateLongLink.selectAll();
}
});
textPublicLongLink.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
textPublicLongLink.selectAll();
}
});
}
/**
* Copy to clipboard.
*
* @param myDivId the my div id
*/
private native void copyToClipboard(String myDivId) /*-{
var copyText = $doc.getElementById(myDivId);
console.log("text copied is :"+copyText.value);
copyText.select();
//For mobile devices
copyText.setSelectionRange(0, 99999);
$doc.execCommand("copy");
//alert("Copied the text: " + copyText.value);
}-*/;
/**
* Load and show public links for item.
*
* @param item the item
*/
private void loadAndShowPublicLinksForItem(GeoNaItemRef item) {
GeoportalDataViewerServiceAsync.Util.getInstance().getPublicLinksFor(item,
new AsyncCallback<GeoNaItemRef>() {
@Override
public void onSuccess(GeoNaItemRef itemReferences) {
openPublicLink = itemReferences.getOpenLink();
restrictedPublicLink = itemReferences.getRestrictedLink();
String toPublicURL = openPublicLink.getShortURL() != null && !openPublicLink.getShortURL().isEmpty()
? openPublicLink.getShortURL()
: openPublicLink.getCompleteURL();
textPublicLink.setValue(toPublicURL);
textPublicLongLink.setValue(openPublicLink.getCompleteURL());
String toPrivateURL = restrictedPublicLink.getShortURL() != null && !restrictedPublicLink.getShortURL().isEmpty()
? restrictedPublicLink.getShortURL()
: restrictedPublicLink.getCompleteURL();
textPrivateLink.setValue(toPrivateURL);
textPrivateLongLink.setValue(restrictedPublicLink.getCompleteURL());
}
@Override
public void onFailure(Throwable caught) {
openPublicLink = null;
disableTextBox(textPublicLink);
disableTextBox(textPrivateLink);
showError(caught.getMessage());
}
});
}
/**
* Disable text box.
*
* @param textBox the text box
*/
private void disableTextBox(TextBox textBox) {
textBox.setEnabled(false);
textBox.getElement().getStyle().setOpacity(0.3);
}
/**
* Show error.
*
* @param msg the msg
*/
private void showError(String msg) {
errorAlert.setVisible(true);
errorAlert.setText(msg);
}
/**
* Show message.
*
* @param msg the msg
* @param visible the visible
*/
private void showMessage(String msg, boolean visible) {
actionAlert.setVisible(visible);
actionAlert.setText(msg==null?"":msg);
}
}

@ -0,0 +1,169 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
<ui:style>
.back-color-info {
background-color: #fafaff !important;
}
.margin-bottom-20 {
margin-bottom: 20px;
}
.padding-left-10 {
padding-left: 10px;
}
.margin-left-5 {
margin-left: 5px;
}
.margin-left-25 {
margin-left: 25px;
}
.text-bold {
font-weight: bold;
}
.not-active {
pointer-events: none;
cursor: default;
opacity: .5;
padding-left: 10px;
}
.to-top-alignment {
vertical-align: top;
padding-top: 0px !important;
}
.no-border {
border: 0px;
}
</ui:style>
<g:HTMLPanel>
<b:Form type="HORIZONTAL">
<b:Alert ui:field="actionAlert" close="false" type="INFO"
visible="false">
<b:Icon type="ROTATE_RIGHT" spin="true" />
</b:Alert>
<g:VerticalPanel ui:field="fieldPrivateSharing"
addStyleNames="{style.margin-bottom-20}">
<g:HorizontalPanel>
<b:Label type="INFO" addStyleNames="sharelabel">With
coworkers</b:Label>
</g:HorizontalPanel>
<g:VerticalPanel
addStyleNames="{style.margin-left-5}">
<g:Label ui:field="labelLinkPrivateSharing">(Only the) Members of the VRE are enacted
to access it. Login required</g:Label>
</g:VerticalPanel>
</g:VerticalPanel>
<b:Fieldset ui:field="fieldSetPrivate"
styleName="{style.noBorder}">
<g:HTMLPanel>
<!-- <b:Legend>sharing....</b:Legend> -->
<b:ControlGroup ui:field="cgPrivateLink"
addStyleNames="my-control-group">
<!-- <b:Well ui:field="wellPrivateLinkDescription"> -->
<!-- The following Restricted Link for this product -->
<!-- is accessible by the users of the VRE. Login required</b:Well> -->
<b:ControlLabel>Restricted Link</b:ControlLabel>
<b:Controls>
<b:InputAddOn prependIcon="LINK"
addStyleNames="my-prepend-width">
<b:TextBox ui:field="textPrivateLink" readOnly="true">
</b:TextBox>
<b:Tooltip text='Copied to clipboard' trigger="MANUAL">
<b:Button icon="COPY" ui:field="privateLinkCopyButton"
type="PRIMARY"></b:Button>
</b:Tooltip>
</b:InputAddOn>
<b:Button ui:field="showPrivateLongLinkButton"
type="LINK" addStyleNames="{style.margin-left-25}">Show as Long URL</b:Button>
</b:Controls>
</b:ControlGroup>
<b:ControlGroup addStyleNames="my-control-group"
ui:field="cgPrivateLongLink" visible="false">
<b:ControlLabel></b:ControlLabel>
<b:Controls>
<b:InputAddOn prependIcon="LINK"
addStyleNames="my-prepend-width">
<b:TextBox ui:field="textPrivateLongLink"
readOnly="true">
</b:TextBox>
<b:Tooltip text='Copied to clipboard' trigger="MANUAL">
<b:Button icon="COPY"
ui:field="privateLongLinkCopyButton" type="PRIMARY"></b:Button>
</b:Tooltip>
</b:InputAddOn>
</b:Controls>
</b:ControlGroup>
</g:HTMLPanel>
</b:Fieldset>
<g:VerticalPanel ui:field="filedEnableDisableSharing"
addStyleNames="{style.margin-bottom-20}">
<g:HorizontalPanel>
<b:Label type="INFO" addStyleNames="sharelabel">With
everyone</b:Label>
</g:HorizontalPanel>
<g:VerticalPanel
addStyleNames="{style.margin-left-5}">
<g:Label ui:field="labelLinkSharing">Anyone with
this link can access it. No
login is required</g:Label>
</g:VerticalPanel>
</g:VerticalPanel>
<b:Fieldset ui:field="fieldSetPublic">
<b:ControlGroup ui:field="cgPublicLink"
addStyleNames="my-control-group">
<!-- <b:Well ui:field="alertFilePublicLink" visible="true">Anyone with -->
<!-- this link can access it, no login is required.</b:Well> -->
<b:ControlLabel>Open Link</b:ControlLabel>
<b:Controls>
<b:InputAddOn prependIcon="GLOBE"
addStyleNames="my-prepend-width">
<b:TextBox ui:field="textPublicLink" readOnly="true">
</b:TextBox>
<b:Tooltip text='Copied to clipboard' trigger="MANUAL">
<b:Button icon="COPY" ui:field="publicLinkCopyButton"
type="PRIMARY"></b:Button>
</b:Tooltip>
</b:InputAddOn>
<b:Button ui:field="showPublicLongLinkButton" type="LINK"
addStyleNames="{style.margin-left-25}">Show as Long URL</b:Button>
</b:Controls>
</b:ControlGroup>
<b:ControlGroup addStyleNames="my-control-group"
ui:field="cgPublicLongLink" visible="false">
<b:ControlLabel></b:ControlLabel>
<b:Controls>
<b:InputAddOn prependIcon="GLOBE"
addStyleNames="my-prepend-width">
<b:TextBox ui:field="textPublicLongLink"
readOnly="true">
</b:TextBox>
<b:Tooltip text='Copied to clipboard' trigger="MANUAL">
<b:Button icon="COPY"
ui:field="publicLongLinkCopyButton" type="PRIMARY"></b:Button>
</b:Tooltip>
</b:InputAddOn>
</b:Controls>
</b:ControlGroup>
</b:Fieldset>
<b:Alert close="false" ui:field="errorAlert" type="ERROR"
visible="false"></b:Alert>
</b:Form>
</g:HTMLPanel>
</ui:UiBinder>

@ -1,18 +1,20 @@
package org.gcube.portlets.user.geoportaldataviewer.client.ui.images;
import org.gcube.portlets.user.geoportaldataviewer.client.util.NewBrowserWindow;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.content.WorkspaceContentDV;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.UploadedImageDV;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.Heading;
import com.github.gwtbootstrap.client.ui.Image;
import com.github.gwtbootstrap.client.ui.Paragraph;
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;
@ -36,6 +38,11 @@ public class ImageView extends Composite {
@UiField
Paragraph paragraph1;
@UiField
Button expandImage;
private WorkspaceContentDV latest;
public ImageView(UploadedImageDV imageDV) {
initWidget(uiBinder.createAndBindUi(this));
@ -45,9 +52,57 @@ public class ImageView extends Composite {
paragraph1.setText(imageDV.getDidascalia());
if(imageDV.getListWsContent()!=null && imageDV.getListWsContent().size()>0) {
WorkspaceContentDV latest = imageDV.getListWsContent().get(imageDV.getListWsContent().size()-1);
latest = imageDV.getListWsContent().get(imageDV.getListWsContent().size()-1);
expandImage.setVisible(true);
imageURL.setVisible(true);
imageURL.setUrl(latest.getLink());
}
expandImage.setType(ButtonType.LINK);
expandImage.setIcon(IconType.RESIZE_FULL);
expandImage.setTitle("Open Image in New Browser Window");
expandImage.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
if(latest!=null) {
NewBrowserWindow.open(latest.getLink(), "_blank", null);
/*String noProtocolLink = latest.getLink().replaceFirst("https:", "").replaceFirst("httP:", "");
GWT.log("noProtocolLink: "+noProtocolLink);
final RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.HEAD, noProtocolLink);
requestBuilder.setHeader("Content-Disposition", "inline");
requestBuilder.setCallback(new RequestCallback() {
@Override
public void onResponseReceived(Request request, Response response) {
String responseURL = response.getHeader("Location");
GWT.log("Response Received link: "+responseURL);
String link = responseURL+"?content-disposition=inline";
NewBrowserWindow.open(link, "_blank", null);
}
@Override
public void onError(Request request, Throwable exception) {
}
});
try {
requestBuilder.send();
} catch (RequestException e) {
e.printStackTrace();
}*/
}
}
});
}

@ -3,19 +3,21 @@
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
<ui:style>
.max-width-300 {
max-width: 300px;
.max-width-400 {
max-width: 400px !important;
}
.float-right{
float: right;
}
</ui:style>
<b:Thumbnail size="4">
<b:Image ui:field="imageURL"
addStyleNames="{style.max-width-300}" />
<b:Thumbnail size="4" addStyleNames="{style.max-width-400}">
<b:Button ui:field="expandImage" addStyleNames="{style.float-right}" visible="false">Open</b:Button>
<b:Image ui:field="imageURL" visible="false" />
<b:Caption>
<b:Heading size="4" ui:field="heading"></b:Heading>
<b:Paragraph ui:field="paragraph1">
</b:Paragraph>
<b:Paragraph ui:field="paragraph2">
<b:Button ui:field="expandImage">Expand</b:Button>
</b:Paragraph>
</b:Caption>
</b:Thumbnail>

@ -0,0 +1,134 @@
package org.gcube.portlets.user.geoportaldataviewer.client.ui.map;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.ExtentWrapped;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.LightOpenLayerOSM;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.Random;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Widget;
import ol.Coordinate;
import ol.OLFactory;
/**
* The Class MapView.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Nov 11, 2020
*/
public class MapView extends Composite{
private static MapViewUiBinder uiBinder = GWT.create(MapViewUiBinder.class);
/**
* The Interface MapViewUiBinder.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Nov 11, 2020
*/
interface MapViewUiBinder extends UiBinder<Widget, MapView> {
}
@UiField
HTMLPanel theMap;
@UiField
HorizontalPanel coordinatePanel;
private LightOpenLayerOSM olsm;
/**
* Instantiates a new map view.
*/
public MapView() {
initWidget(uiBinder.createAndBindUi(this));
String theMapId = "map"+Random.nextInt();
theMap.getElement().setId(theMapId);
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
olsm = new LightOpenLayerOSM(theMapId);
//EPSG_4326_TO_ITALY
Coordinate centerCoordinate = OLFactory.createCoordinate(GeoportalDataViewerConstants.ITALY_CENTER_LONG, GeoportalDataViewerConstants.ITALY_CENTER_LAT);
Coordinate transformedCenterCoordinate = MapUtils.transformCoordiante(centerCoordinate, GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857);
olsm.setCenter(transformedCenterCoordinate);
olsm.setZoom(GeoportalDataViewerConstants.ITALY_FIT_ZOOM_ON);
}
});
}
/**
* Adds the marker.
*
* @param coordinate the coordinate
* @param showCoordinateText the show coordinate text
*/
public void addMarker(Coordinate coordinate, boolean showCoordinateText) {
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
if(olsm!=null) {
olsm.addPoint(coordinate, showCoordinateText, true);
olsm.getMap().getView().setCenter(coordinate);
}
}
});
}
/**
* Adds the WMS layer.
*
* @param mapServerHost the map server host
* @param layerName the layer name
* @param bbox the bbox
*/
public void addWMSLayer(String mapServerHost, String layerName, BoundsMap bbox) {
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
olsm.addWMSLayer(mapServerHost, layerName);
if (bbox != null) {
Coordinate lower = OLFactory.createCoordinate(bbox.getLowerLeftX(), bbox.getLowerLeftY());
Coordinate lowerCoord = MapUtils.transformCoordiante(lower, GeoportalDataViewerConstants.EPSG_4326,
GeoportalDataViewerConstants.EPSG_3857);
Coordinate upper = OLFactory.createCoordinate(bbox.getUpperRightX(), bbox.getUpperRightY());
Coordinate upperCoord = MapUtils.transformCoordiante(upper, GeoportalDataViewerConstants.EPSG_4326,
GeoportalDataViewerConstants.EPSG_3857);
ExtentWrapped ew = new ExtentWrapped(lowerCoord.getX(), lowerCoord.getY(), upperCoord.getX(),
upperCoord.getY());
//Coordinate center = ew.getCenter();
//GWT.log("center: "+center);
//Coordinate invertCoordinate = new Coordinate(center.getY(), center.getX());
// Size size = new Size(300, 300);
//olsm.getMap().getView().setCenter(invertCoordinate);
olsm.getMap().getView().fit(ew);
}
}
});
}
}

@ -0,0 +1,17 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui">
<ui:style>
.internalMap {
width: 300px;
height: 300px;
}
</ui:style>
<g:HTMLPanel>
<g:HTMLPanel ui:field="theMap"
addStyleNames="{style.internalMap}">
</g:HTMLPanel>
<g:HorizontalPanel ui:field="coordinatePanel"
visible="false"></g:HorizontalPanel>
</g:HTMLPanel>
</ui:UiBinder>

@ -1,106 +0,0 @@
package org.gcube.portlets.user.geoportaldataviewer.client.ui.products;
import java.util.List;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.images.ImageView;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.ConcessioneDV;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.UploadedImageDV;
import com.github.gwtbootstrap.client.ui.Column;
import com.github.gwtbootstrap.client.ui.Heading;
import com.github.gwtbootstrap.client.ui.Label;
import com.github.gwtbootstrap.client.ui.Paragraph;
import com.github.gwtbootstrap.client.ui.Thumbnails;
import com.github.gwtbootstrap.client.ui.constants.LabelType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Widget;
public class ConcessioneView extends Composite {
private static ConcessioneViewUiBinder uiBinder = GWT.create(ConcessioneViewUiBinder.class);
interface ConcessioneViewUiBinder extends UiBinder<Widget, ConcessioneView> {
}
@UiField
Heading titolo;
@UiField
Paragraph introduzione;
@UiField
Column autori;
@UiField
Column contributore;
@UiField
HTMLPanel imagesPanel;
private ConcessioneDV concessioneDV;
private Thumbnails thumbNails = new Thumbnails();
public ConcessioneView() {
initWidget(uiBinder.createAndBindUi(this));
}
public ConcessioneView(ConcessioneDV concessioneDV) {
this();
this.concessioneDV = concessioneDV;
titolo.setText(concessioneDV.getNome());
introduzione.setText(concessioneDV.getIntroduzione());
for (String author : concessioneDV.getAuthors()) {
addLabel(autori, author);
//autori.add(new Label(author));
}
addLabel(contributore, concessioneDV.getContributore());
addImages();
}
private void addImages() {
List<UploadedImageDV> immagini = concessioneDV.getImmaginiRappresentative();
if(immagini!=null && immagini.size()>0) {
imagesPanel.setVisible(true);
int i = 0;
for (UploadedImageDV uploadedImageDV : immagini) {
if(i==0)
imagesPanel.add(thumbNails);
thumbNails.add(new ImageView(uploadedImageDV));
}
}
}
public void addLabel(FlowPanel w, String labelValue, LabelType type){
Label label = new Label(labelValue);
label.setType(type);
label.getElement().getStyle().setMarginRight(5, Unit.PX);
w.add(label);
}
public void addLabel(FlowPanel w, String labelValue){
com.google.gwt.user.client.ui.Label label = new com.google.gwt.user.client.ui.Label(labelValue);
label.getElement().getStyle().setMarginRight(5, Unit.PX);
w.add(label);
}
public ConcessioneDV getConcessioneDV() {
return concessioneDV;
}
}

@ -1,42 +0,0 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
<ui:style>
.important {
font-weight: bold;
}
.margin-left-10 {
margin-left: 10px;
}
.font-size-h1-22 h1{
font-size: 22px;
}
</ui:style>
<g:HTMLPanel>
<b:Hero>
<b:Heading size="2" ui:field="titolo">Hero Unit</b:Heading>
<b:Paragraph ui:field="introduzione">Some Text for the Hero Unit.</b:Paragraph>
</b:Hero>
<g:HTMLPanel ui:field="concessioniPanel"
addStyleNames="{style.margin-left-10}">
<b:Row>
<b:Column size="2">
<g:Label>Autori</g:Label>
</b:Column>
<b:Column size="8" ui:field="autori"></b:Column>
</b:Row>
<b:Row>
<b:Column size="2">
<g:Label>Contributore</g:Label>
</b:Column>
<b:Column size="8" ui:field="contributore"></b:Column>
</b:Row>
</g:HTMLPanel>
<g:HTMLPanel ui:field="imagesPanel"
addStyleNames="{style.margin-left-10}" visible="false">
<b:PageHeader addStyleNames="{style.font-size-h1-22}">Immagini Rappresentative</b:PageHeader>
</g:HTMLPanel>
</g:HTMLPanel>
</ui:UiBinder>

@ -0,0 +1,49 @@
package org.gcube.portlets.user.geoportaldataviewer.client.ui.products;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.util.CustomFlexTable;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.RecordDV;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Widget;
public class RecordView extends Composite {
private static RecordViewUiBinder uiBinder = GWT.create(RecordViewUiBinder.class);
interface RecordViewUiBinder extends UiBinder<Widget, RecordView> {
}
@UiField
HTMLPanel recordDVPanel;
private CustomFlexTable customTable = new CustomFlexTable();
public RecordView() {
initWidget(uiBinder.createAndBindUi(this));
}
public RecordView(RecordDV record) {
initWidget(uiBinder.createAndBindUi(this));
customTable.addNextKeyValue("Created", record.getCreationTime());
customTable.addNextKeyValue("Last Updated", record.getLastUpdateTime());
customTable.addNextKeyValue("Updated by", record.getLastUpdateUser());
recordDVPanel.add(customTable);
}
public void addLabel(FlowPanel w, String labelValue){
com.google.gwt.user.client.ui.Label label = new com.google.gwt.user.client.ui.Label(labelValue);
label.getElement().getStyle().setMarginRight(5, Unit.PX);
w.add(label);
}
}

@ -0,0 +1,9 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
<ui:style>
</ui:style>
<g:HTMLPanel ui:field="recordDVPanel">
</g:HTMLPanel>
</ui:UiBinder>

@ -0,0 +1,329 @@
package org.gcube.portlets.user.geoportaldataviewer.client.ui.products.concessioni;
import java.util.List;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.dialogs.DialogShareableLink;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.images.ImageView;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.MapView;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.util.CustomFlexTable;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaItemRef;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.ConcessioneDV;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.LayerConcessioneDV;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.RelazioneScavoDV;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.UploadedImageDV;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.Modal;
import com.github.gwtbootstrap.client.ui.ModalFooter;
import com.github.gwtbootstrap.client.ui.PageHeader;
import com.github.gwtbootstrap.client.ui.Paragraph;
import com.github.gwtbootstrap.client.ui.Thumbnails;
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Widget;
import ol.Coordinate;
public class ConcessioneView extends Composite {
private static ConcessioneViewUiBinder uiBinder = GWT.create(ConcessioneViewUiBinder.class);
interface ConcessioneViewUiBinder extends UiBinder<Widget, ConcessioneView> {
}
@UiField
PageHeader titolo;
@UiField
Paragraph introduzione;
@UiField
HTMLPanel concessioniPanel;
@UiField
HTMLPanel relazioneScavoPanel;
@UiField
HTMLPanel imagesPanel;
@UiField
HTMLPanel pageViewDetails;
@UiField
HTMLPanel mapViewPanel;
@UiField
HTMLPanel posizionamentoAreaIndaginePanel;
@UiField
HTMLPanel piantaFineScavoPanel;
// @UiField
// HTMLPanel sharePanel;
@UiField
Button shareButton;
@UiField
Button openButton;
private ConcessioneDV concessioneDV;
private Thumbnails thumbNails = new Thumbnails();
private CustomFlexTable customTable = new CustomFlexTable();
private GeoNaItemRef geonaItemRef;
private String myLogin;
private ConcessioneView() {
initWidget(uiBinder.createAndBindUi(this));
pageViewDetails.getElement().setId("page-view-details");
}
public ConcessioneView(GeoNaItemRef item, ConcessioneDV concDV) {
this();
this.concessioneDV = concDV;
this.geonaItemRef = item;
titolo.setText(concessioneDV.getNome());
introduzione.setText(concessioneDV.getIntroduzione());
if (concessioneDV.getDataInizioProgetto() != null) {
customTable.addNextKeyValue("Data Inizio Progetto", concessioneDV.getDataFineProgetto());
}
if (concessioneDV.getDataFineProgetto() != null) {
customTable.addNextKeyValue("Data Fine Progetto", concessioneDV.getDataFineProgetto());
}
if (concessioneDV.getParoleChiaveLibere() != null) {
customTable.addNextKeyValues("Parole chiave Libere", concessioneDV.getParoleChiaveICCD(), GeoportalDataViewerConstants.NEW_LINE_BR);
}
if (concessioneDV.getParoleChiaveICCD() != null) {
customTable.addNextKeyValues("Parole chiave Cronologia", concessioneDV.getParoleChiaveICCD(), GeoportalDataViewerConstants.NEW_LINE_BR);
}
if (concessioneDV.getAuthors() != null) {
customTable.addNextKeyValues("Autori", concessioneDV.getAuthors(), GeoportalDataViewerConstants.NEW_LINE_BR);
}
if (concessioneDV.getContributore() != null) {
customTable.addNextKeyValue("Contributore", concessioneDV.getContributore());
}
if (concessioneDV.getEditore() != null) {
customTable.addNextKeyValue("Editore", concessioneDV.getEditore());
}
if (concessioneDV.getResponsabile() != null) {
customTable.addNextKeyValue("Responsabile", concessioneDV.getResponsabile());
}
if (concessioneDV.getRisorseCorrelate() != null) {
customTable.addNextKeyValues("Risorse Correlate", concessioneDV.getRisorseCorrelate(), GeoportalDataViewerConstants.NEW_LINE_BR);
}
if (concessioneDV.getTitolari() != null) {
customTable.addNextKeyValues("Titolari dei dati", concessioneDV.getTitolari(), GeoportalDataViewerConstants.NEW_LINE_BR);
}
if (concessioneDV.getSoggetto() != null) {
customTable.addNextKeyValues("Soggetti", concessioneDV.getSoggetto(), GeoportalDataViewerConstants.NEW_LINE_BR);
}
if (concessioneDV.getEditore() != null) {
customTable.addNextKeyValue("Editore", concessioneDV.getEditore());
}
if (concessioneDV.getFontiFinanziamento() != null) {
customTable.addNextKeyValues("Fonti di Finanziamento", concessioneDV.getFontiFinanziamento(), GeoportalDataViewerConstants.NEW_LINE_BR);
}
if (concessioneDV.getLicenzaID() != null) {
customTable.addNextKeyValue("ID Licenza", concessioneDV.getLicenzaID());
}
if (concessioneDV.getTitolareLicenza() != null) {
customTable.addNextKeyValue("Titolare Licenza", concessioneDV.getTitolareLicenza());
}
if (concessioneDV.getTitolareCopyright() != null) {
customTable.addNextKeyValue("Titolare Copyright", concessioneDV.getTitolareCopyright());
}
shareButton.setType(ButtonType.LINK);
shareButton.setIcon(IconType.SHARE);
shareButton.setTitle("Get a link to share with...");
shareButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
DialogShareableLink dg = new DialogShareableLink(geonaItemRef, null);
}
});
openButton.setType(ButtonType.LINK);
openButton.setIcon(IconType.EXPAND);
openButton.setTitle("Open Details in New Dialog");
openButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
Modal modal = new Modal(false);
modal.hide(false);
modal.setCloseVisible(true);
modal.setWidth(900);
modal.setTitle(concessioneDV.getNome());
modal.add(new ConcessioneView(geonaItemRef, concessioneDV));
ModalFooter modalFooter = new ModalFooter();
final Button buttClose = new Button("Close");
modalFooter.add(buttClose);
buttClose.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
modal.hide();
}
});
modal.add(modalFooter);
modal.show();
}
});
concessioniPanel.add(customTable);
GeoportalDataViewerServiceAsync.Util.getInstance().getMyLogin(new AsyncCallback<String>() {
@Override
public void onSuccess(String result) {
myLogin = result;
addCentroidMap();
addRelazioneDiScavo();
addPosizionamentoAreaIndagine();
addPiantaFineScavo();
}
@Override
public void onFailure(Throwable caught) {
}
});
addUploadedImages();
}
private void addPosizionamentoAreaIndagine() {
LayerConcessioneDV layer = concessioneDV.getPosizionamentoScavo();
if(layer==null)
return;
if(layer.getPolicy()==null || layer.getPolicy().equalsIgnoreCase("OPEN")) {
posizionamentoAreaIndaginePanel.setVisible(true);
posizionamentoAreaIndaginePanel.add(new LayerConcessioneView(layer));
}else {
//I need to be authenticated to show the fields according to POLICY
if(myLogin!=null) {
posizionamentoAreaIndaginePanel.setVisible(true);
posizionamentoAreaIndaginePanel.add(new LayerConcessioneView(layer));
}
}
}
private void addPiantaFineScavo() {
List<LayerConcessioneDV> listLayersDV = concessioneDV.getPianteFineScavo();
if(listLayersDV==null)
return;
for (LayerConcessioneDV layer : listLayersDV) {
if(layer.getPolicy()==null || layer.getPolicy().equalsIgnoreCase("OPEN")) {
piantaFineScavoPanel.setVisible(true);
piantaFineScavoPanel.add(new LayerConcessioneView(layer));
}else {
//I need to be authenticated to show the fields according to POLICY
if(myLogin!=null) {
piantaFineScavoPanel.setVisible(true);
piantaFineScavoPanel.add(new LayerConcessioneView(layer));
}
}
}
}
private void addRelazioneDiScavo() {
RelazioneScavoDV relazioneScavo = concessioneDV.getRelazioneScavo();
if(relazioneScavo==null)
return;
if(relazioneScavo.getPolicy()==null || relazioneScavo.getPolicy().equalsIgnoreCase("OPEN")) {
relazioneScavoPanel.setVisible(true);
relazioneScavoPanel.add(new RelazioneScavoView(relazioneScavo));
}else {
//I need to be authenticated to show the fields according to POLICY
if(myLogin!=null) {
relazioneScavoPanel.setVisible(true);
relazioneScavoPanel.add(new RelazioneScavoView(relazioneScavo));
}
}
}
private void addCentroidMap() {
MapView mapView = new MapView();
Coordinate coord = new Coordinate(concessioneDV.getCentroidLong(), concessioneDV.getCentroidLat());
Coordinate transfCoord = MapUtils.transformCoordiante(coord, GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857);
//Coordinate invertedCoordinate = MapUtils.reverseCoordinate(coord);
boolean authenticatedUser = myLogin!=null?true:false;
mapView.addMarker(transfCoord, authenticatedUser);
mapViewPanel.add(mapView);
}
private void addUploadedImages() {
List<UploadedImageDV> immagini = concessioneDV.getImmaginiRappresentative();
if (immagini != null && immagini.size() > 0) {
imagesPanel.setVisible(true);
int i = 0;
for (UploadedImageDV uploadedImageDV : immagini) {
if (i == 0)
imagesPanel.add(thumbNails);
thumbNails.add(new ImageView(uploadedImageDV));
}
}
}
public ConcessioneDV getConcessioneDV() {
return concessioneDV;
}
}

@ -0,0 +1,59 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
<ui:style>
.margin-left-10 {
margin-left: 10px;
}
.font-size-h1-22 h1 {
font-size: 22px;
}
.align-to-right {
right: 20px;
position: absolute;
}
.margin-bottom-10 {
margin-bottom: 10px;
}
</ui:style>
<g:HTMLPanel ui:field="pageViewDetails">
<!-- <g:HTMLPanel ui:field="sharePanel" -->
<!-- addStyleNames="{style.align-to-right}"> -->
<!-- </g:HTMLPanel> -->
<b:PageHeader ui:field="titolo"></b:PageHeader>
<g:HorizontalPanel
addStyleNames="{style.margin-bottom-10}">
<b:Button ui:field="shareButton">Share</b:Button>
<b:Button ui:field="openButton">Open</b:Button>
</g:HorizontalPanel>
<b:Paragraph ui:field="introduzione"></b:Paragraph>
<g:HorizontalPanel>
<g:HTMLPanel ui:field="concessioniPanel">
</g:HTMLPanel>
<g:HTMLPanel ui:field="mapViewPanel">
</g:HTMLPanel>
</g:HorizontalPanel>
<g:HTMLPanel ui:field="relazioneScavoPanel"
addStyleNames="{style.margin-left-10}" visible="false">
<b:PageHeader addStyleNames="{style.font-size-h1-22}">Relazione Scavo</b:PageHeader>
</g:HTMLPanel>
<g:HTMLPanel ui:field="imagesPanel"
addStyleNames="{style.margin-left-10}" visible="false">
<b:PageHeader addStyleNames="{style.font-size-h1-22}">Immagini Rappresentative</b:PageHeader>
</g:HTMLPanel>
<g:HTMLPanel ui:field="posizionamentoAreaIndaginePanel"
addStyleNames="{style.margin-left-10}" visible="false">
<b:PageHeader addStyleNames="{style.font-size-h1-22}">Posizionamento Area di
Indagine</b:PageHeader>
</g:HTMLPanel>
<g:HTMLPanel ui:field="piantaFineScavoPanel"
addStyleNames="{style.margin-left-10}" visible="false">
<b:PageHeader addStyleNames="{style.font-size-h1-22}">Pianta Fine Scavo</b:PageHeader>
</g:HTMLPanel>
</g:HTMLPanel>
</ui:UiBinder>

@ -0,0 +1,49 @@
package org.gcube.portlets.user.geoportaldataviewer.client.ui.products.concessioni;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.MapView;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.util.CustomFlexTable;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.LayerConcessioneDV;
import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Widget;
public class LayerConcessioneView extends Composite {
private static LayerConcessioneUiBinder uiBinder = GWT.create(LayerConcessioneUiBinder.class);
interface LayerConcessioneUiBinder extends UiBinder<Widget, LayerConcessioneView> {
}
@UiField
HTMLPanel layerConcessionePanel;
@UiField
HTMLPanel mapViewPanel;
private CustomFlexTable customTable = new CustomFlexTable();
public LayerConcessioneView(LayerConcessioneDV layerDV) {
initWidget(uiBinder.createAndBindUi(this));
GWT.log("Showing: "+layerDV);
//customTable.addNextKeyValue("Created", relazioneScavoDV.getCreationTime());
customTable.addNextKeyValue("Valutazione qualità", layerDV.getValutazioneQualita());
customTable.addNextKeyValue("Metodo raccolta dati", layerDV.getMetodoRaccoltaDati());
customTable.addNextKeyValue("Scala acquisizione dati", layerDV.getScalaAcquisizione());
customTable.addNextKeyValues("Autori", layerDV.getAuthors(), GeoportalDataViewerConstants.NEW_LINE_BR);
layerConcessionePanel.add(customTable);
if(layerDV.getLayerName()!=null && layerDV.getWmsLink()!=null) {
MapView mapView = new MapView();
mapViewPanel.add(mapView);
String mapServerHost = layerDV.getWmsLink().contains("?")? layerDV.getWmsLink().substring(0,layerDV.getWmsLink().indexOf("?")):layerDV.getWmsLink();
mapView.addWMSLayer(mapServerHost, layerDV.getLayerName(), layerDV.getBbox());
}
}
}

@ -0,0 +1,28 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
<ui:style>
.important {
font-weight: bold;
}
.style-layer {
display: inline-block;
border: 1px solid #ddd;
border-radius: 4px;
box-shadow: 0 1px 3px rgba(0,0,0,0.055);
margin-right: 10px;
margin-bottom: 10px;
width: 673px;
}
</ui:style>
<g:HTMLPanel addStyleNames="{style.style-layer}">
<g:HorizontalPanel>
<g:HTMLPanel ui:field="layerConcessionePanel"></g:HTMLPanel>
<g:HTMLPanel ui:field="mapViewPanel">
</g:HTMLPanel>
</g:HorizontalPanel>
</g:HTMLPanel>
</ui:UiBinder>

@ -0,0 +1,43 @@
package org.gcube.portlets.user.geoportaldataviewer.client.ui.products.concessioni;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.util.CustomFlexTable;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.RelazioneScavoDV;
import com.github.gwtbootstrap.client.ui.Paragraph;
import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Widget;
public class RelazioneScavoView extends Composite {
private static RelazioneScavoViewUiBinder uiBinder = GWT.create(RelazioneScavoViewUiBinder.class);
interface RelazioneScavoViewUiBinder extends UiBinder<Widget, RelazioneScavoView> {
}
@UiField
HTMLPanel relazioneScavoPanel;
@UiField
Paragraph abstractParagraph;
private CustomFlexTable customTable = new CustomFlexTable();
public RelazioneScavoView(RelazioneScavoDV relazioneScavoDV) {
initWidget(uiBinder.createAndBindUi(this));
if(relazioneScavoDV.getAbstractSection()!=null)
abstractParagraph.setText(relazioneScavoDV.getAbstractSection());
//customTable.addNextKeyValue("Created", relazioneScavoDV.getCreationTime());
customTable.addNextKeyValue("ID Licenza", relazioneScavoDV.getLicenseID());
customTable.addNextKeyValues("Responsabili", relazioneScavoDV.getResponsabili(), GeoportalDataViewerConstants.NEW_LINE_BR);
relazioneScavoPanel.add(customTable);
}
}

@ -0,0 +1,18 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
<ui:style>
.description > p {
font-size: 20px;
padding: 10px;
color: #999;
}
</ui:style>
<g:HTMLPanel ui:field="relazioneScavoPanel" addStyleNames="{style.description}">
<b:Paragraph ui:field="abstractParagraph"></b:Paragraph>
</g:HTMLPanel>
</ui:UiBinder>

@ -0,0 +1,91 @@
package org.gcube.portlets.user.geoportaldataviewer.client.ui.util;
import java.util.List;
import com.google.gwt.core.shared.GWT;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;
/**
* The Class CustomFlexTable.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Nov 11, 2020
*/
public class CustomFlexTable extends FlexTable {
/**
* Instantiates a new custom flex table.
*/
public CustomFlexTable() {
this.getElement().addClassName("my-custom-flex-table");
}
/**
* Adds the next key values.
*
* @param key the key
* @param listValues the list values
* @param separator the separator
*/
public void addNextKeyValues(String key, List<String> listValues, String separator) {
GWT.log("adding key "+key +", values: "+listValues);
Label keyLabel = new Label(key);
int row = getRowCount() + 1;
setWidget(row, 0, keyLabel);
if(listValues==null)
return;
String valuesAsString = "";
for (String value : listValues) {
String theValue = value;
if(theValue.startsWith("http://") || (theValue.startsWith("https://"))){
theValue = "<a href=\""+value+"\" target=\"_blank\">"+value+"</a>";
}
valuesAsString+=theValue+separator;
}
valuesAsString = valuesAsString.substring(0, valuesAsString.lastIndexOf(separator));
HTML valuesLabel = new HTML(valuesAsString);
setWidget(row, 1, valuesLabel);
}
/**
* Adds the next key value.
*
* @param key the key
* @param value the value
*/
public void addNextKeyValue(String key, String value) {
Label keyLabel = new Label(key);
// keyLabel.getElement().getStyle().setMarginRight(5, Unit.PX);
int row = getRowCount() + 1;
setWidget(row, 0, keyLabel);
if(value==null)
return;
HTML valueLabel = new HTML(value);
setWidget(row, 1, valueLabel);
}
/**
* Adds the next key widget.
*
* @param key the key
* @param value the value
*/
public void addNextKeyWidget(String key, Widget value) {
Label keyLabel = new Label(key);
int row = getRowCount() + 1;
setWidget(row, 0, keyLabel);
setWidget(row, 1, value);
}
}

@ -0,0 +1,34 @@
/**
*
*/
package org.gcube.portlets.user.geoportaldataviewer.client.util;
/**
* The Class StringUtil.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Nov 16, 2020
*/
public class StringUtil {
/**
* Ellipsize.
*
* @param input the input string that may be subjected to shortening
* @param maxCharacters the maximum characters that must be returned for the input string. Must be at least 3 (that is the ellipses size)
* @return the string
* @throws Exception the exception
*/
public static String ellipsize(String input, int maxCharacters) throws Exception{
if(maxCharacters < 3) {
throw new IllegalArgumentException("maxCharacters must be at least 3 because the ellipsis already take up 3 characters");
}
if (input == null || input.length() < maxCharacters) {
return input;
}
return input.substring(0, maxCharacters)+"...";
}
}

@ -0,0 +1,20 @@
package org.gcube.portlets.user.geoportaldataviewer.server;
/**
* The Class ApplicationProfileException.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
* Sep 6, 2016
*/
@SuppressWarnings("serial")
public class ApplicationProfileNotFoundException extends Exception {
/**
* Instantiates a new application profile exception.
*
* @param message the message
*/
public ApplicationProfileNotFoundException(String message) {
super(message);
}
}

@ -16,10 +16,10 @@ import org.gcube.application.geoportal.model.content.WorkspaceContent;
import org.gcube.application.geoportal.model.gis.BBOX;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.ConcessioneDV;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.LayerConcessioneDV;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.RelazioneScavoDV;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.content.OtherContentDV;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.content.WorkspaceContentDV;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.LayerConcessioneDV;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.RelazioneScavoDV;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.UploadedImageDV;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -62,7 +62,7 @@ public class ConvertToDataViewModel {
ConcessioneDV theConcessione = new ConcessioneDV();
theConcessione.setPolicy(toPolicy(concessione.getPolicy()));
theConcessione.setAuthors(concessione.getAuthors());
//theConcessione.setAuthors(concessione.getAuthors());
theConcessione.setCentroidLat(concessione.getCentroidLat());
theConcessione.setCentroidLong(concessione.getCentroidLong());
theConcessione.setContributore(concessione.getContributore());
@ -72,19 +72,31 @@ public class ConvertToDataViewModel {
theConcessione.setDataInizioProgetto(toDateString(concessione.getDataInizioProgetto()));
theConcessione.setDescrizioneContenuto(concessione.getDescrizioneContenuto());
theConcessione.setEditore(concessione.getEditore());
theConcessione.setFontiFinanziamento(concessione.getFontiFinanziamento());
theConcessione.setFontiFinanziamento(toListString(concessione.getFontiFinanziamento()));
theConcessione.setId(concessione.getId());
theConcessione.setNome(concessione.getNome());
if (concessione.getGenericContent() != null) {
List<OtherContentDV> otherContentsDV = new ArrayList<OtherContentDV>(
concessione.getGenericContent().size());
for (OtherContent gc : concessione.getGenericContent()) {
otherContentsDV.add(toOtherContentDV(gc));
}
theConcessione.setGenericContent(otherContentsDV);
}
theConcessione.setIntroduzione(concessione.getIntroduzione());
theConcessione.setLastUpdateTime(toDateString(concessione.getLastUpdateTime()));
theConcessione.setLastUpdateUser(toUser(concessione.getLastUpdateUser()));
theConcessione.setLicenzaID(concessione.getLicenzaID());
theConcessione.setNome(concessione.getNome());
theConcessione.setParoleChiaveICCD(concessione.getParoleChiaveICCD());
theConcessione.setParoleChiaveLibere(concessione.getParoleChiaveLibere());
theConcessione.setResponsabile(concessione.getResponsabile());
theConcessione.setRisorseCorrelate(concessione.getRisorseCorrelate());
theConcessione.setSoggetto(concessione.getSoggetto());
theConcessione.setTitolareCopyright(concessione.getTitolareCopyright());
theConcessione.setTitolareLicenza(concessione.getTitolareLicenza());
theConcessione.setTitolari(concessione.getTitolari());
theConcessione.setVersion(concessione.getVersion());
theConcessione.setRecordType(concessione.getRecordType().name());
theConcessione.setRelazioneScavo(toRelazioneScavo(concessione.getRelazioneScavo()));
if (concessione.getImmaginiRappresentative() != null) {
List<UploadedImageDV> uploadedImagesDV = new ArrayList<UploadedImageDV>(
concessione.getImmaginiRappresentative().size());
@ -93,15 +105,18 @@ public class ConvertToDataViewModel {
}
theConcessione.setImmaginiRappresentative(uploadedImagesDV);
}
if (concessione.getGenericContent() != null) {
List<OtherContentDV> otherContentsDV = new ArrayList<OtherContentDV>(
concessione.getGenericContent().size());
for (OtherContent gc : concessione.getGenericContent()) {
otherContentsDV.add(toOtherContentDV(gc));
}
theConcessione.setGenericContent(otherContentsDV);
}
theConcessione.setIntroduzione(concessione.getIntroduzione());
theConcessione.setLastUpdateTime(toDateString(concessione.getLastUpdateTime()));
theConcessione.setLastUpdateUser(toUser(concessione.getLastUpdateUser()));
theConcessione.setLicenzaID(concessione.getLicenzaID());
theConcessione.setNome(concessione.getNome());
theConcessione.setParoleChiaveICCD(concessione.getParoleChiaveICCD());
theConcessione.setParoleChiaveLibere(concessione.getParoleChiaveLibere());
if (concessione.getPianteFineScavo() != null) {
List<LayerConcessioneDV> piantaScavoDV = new ArrayList<LayerConcessioneDV>(
concessione.getPianteFineScavo().size());
@ -116,17 +131,6 @@ public class ConvertToDataViewModel {
theConcessione.setPosizionamentoScavo(thePosizScavo);
}
theConcessione.setRecordType(concessione.getRecordType().name());
theConcessione.setRelazioneScavo(toRelazioneScavo(concessione.getRelazioneScavo()));
theConcessione.setResponsabile(concessione.getResponsabile());
theConcessione.setRisorseCorrelate(concessione.getRisorseCorrelate());
theConcessione.setSoggetto(concessione.getSoggetto());
theConcessione.setTitolareCopyright(concessione.getTitolareCopyright());
theConcessione.setTitolareLicenza(concessione.getTitolareLicenza());
theConcessione.setTitolari(concessione.getTitolari());
theConcessione.setVersion(concessione.getVersion());
LOG.debug("Returning concessione: " + theConcessione);
return theConcessione;
@ -137,6 +141,19 @@ public class ConvertToDataViewModel {
}
//TO AVOID SERIALIZATION ISSUE AGAINST GWT
public static List<String> toListString(List<String> orginList){
if(orginList==null)
return null;
List<String> destList = new ArrayList<String>(orginList.size());
for (String orgValue : orginList) {
destList.add(orgValue);
}
return destList;
}
public static String toUser(String username) {
if(username==null)

@ -0,0 +1,202 @@
package org.gcube.portlets.user.geoportaldataviewer.server;
import static org.gcube.resources.discovery.icclient.ICFactory.client;
import java.io.StringReader;
import java.net.URLDecoder;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathFactory;
import org.gcube.common.resources.gcore.utils.XPathHelper;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaDataViewerProfile;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.Query;
import org.gcube.resources.discovery.client.queries.impl.QueryBox;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
/**
* The Class GeoNaViewerProfileReader.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Nov 12, 2020
*/
public class GeoNaDataViewerProfileReader {
private static final String RESOURCE_PROFILE_BODY = "/Resource/Profile/Body";
/**
*
*/
public static final String SECONDARY_TYPE = "ApplicationProfile";
public static final String WORKSPACE_EXPLORER_APP_NAME = "GeoNa-Viewer-Profile";
private Logger logger = LoggerFactory.getLogger(GeoNaDataViewerProfileReader.class);
private String secondaryType;
private String scope;
private String appID;
/**
* Instantiates a new application profile reader.
*
* @param appID the app id
*/
public GeoNaDataViewerProfileReader(String appID) {
this.appID = appID;
this.secondaryType = SECONDARY_TYPE;
this.scope = ScopeProvider.instance.get();
}
/**
* Read profile from infrastrucure.
*
* @return the map
*/
public GeoNaDataViewerProfile readProfileFromInfrastrucure() throws Exception {
String queryString = getGcubeGenericQueryString(secondaryType, appID);
logger.info("Scope "+scope+", trying to perform query: "+queryString);
try {
if (scope == null)
throw new Exception("Scope is null, set scope into ScopeProvider");
GeoNaDataViewerProfile profile = new GeoNaDataViewerProfile();
logger.info("Trying to fetch ApplicationProfile in the scope: " + scope + ", SecondaryType: "
+ secondaryType + ", AppId: " + appID);
Query q = new QueryBox(queryString);
DiscoveryClient<String> client = client();
List<String> appProfile = client.submit(q);
if (appProfile == null || appProfile.size() == 0)
throw new ApplicationProfileNotFoundException("ApplicationProfile with SecondaryType: " + secondaryType
+ ", AppId: " + appID + " is not registered in the scope: " + scope);
else {
String elem = appProfile.get(0);
DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = docBuilder.parse(new InputSource(new StringReader(elem)));
XPathHelper helper = new XPathHelper(doc.getDocumentElement());
List<String> currValue = null;
String xPathExp = RESOURCE_PROFILE_BODY+"/RestrictedPortletURL/text()";
currValue = helper.evaluate(xPathExp);
if (currValue != null && currValue.size() > 0) {
profile.setRestrictedPortletURL(currValue.get(0));
}else
throw new Exception("I'm not able to read the path: "+xPathExp);
xPathExp = RESOURCE_PROFILE_BODY+"/OpenPortletURL/text()";
currValue = helper.evaluate(xPathExp);
if (currValue != null && currValue.size() > 0) {
profile.setOpenPortletURL(currValue.get(0));
}else
throw new Exception("I'm not able to read the path: "+xPathExp);
XPath xPath = XPathFactory.newInstance().newXPath();
NodeList nodeList = (NodeList) xPath.compile("/Resource/Profile/Body/AvailableLayers/Layer")
.evaluate(doc, XPathConstants.NODESET);
Map<String, LayerItem> mapLayers = new HashMap<String, LayerItem>(nodeList.getLength());
for (int i = 0; i < nodeList.getLength(); i++) {
Node layerNode = nodeList.item(i);
if (layerNode.getNodeType() == Node.ELEMENT_NODE) {
Element eElement = (Element) layerNode;
String layerType = eElement.getElementsByTagName("Type").item(0).getTextContent();
String wmsLink = eElement.getElementsByTagName("WMSLink").item(0).getTextContent();
String decodedURL = URLDecoder.decode(wmsLink, "UTF-8");
LayerItem layer = new LayerItem();
layer.setWmsLink(decodedURL);
mapLayers.put(layerType.toLowerCase(), layer);
}
}
profile.setMapLayers(mapLayers);
logger.info("returning: "+profile);
return profile;
}
} catch (Exception e) {
logger.error("Error while trying to read the " + SECONDARY_TYPE + " with SecondaryType "
+ WORKSPACE_EXPLORER_APP_NAME + " from scope " + scope, e);
return null;
} finally {
}
}
/**
* Gets the gcube generic query string.
*
* @param secondaryType the secondary type
* @param appId the app id
* @return the gcube generic query string
*/
public static String getGcubeGenericQueryString(String secondaryType, String appId) {
return "for $profile in collection('/db/Profiles/GenericResource')//Resource "
+ "where $profile/Profile/SecondaryType/string() eq '" + secondaryType
+ "' and $profile/Profile/Body/AppId/string() " + " eq '" + appId + "'" + "return $profile";
}
/**
* Gets the secondary type.
*
* @return the secondary type
*/
public String getSecondaryType() {
return secondaryType;
}
/**
* Gets the scope.
*
* @return the scope
*/
public String getScope() {
return scope;
}
@Override
public String toString() {
return "GeoNaViewerProfileReader [secondaryType=" + secondaryType + ", scope=" + scope + ", appID=" + appID
+ "]";
}
/*
public static void main(String[] args) throws Exception {
ScopeProvider.instance.set("/gcube/devNext/NextNext");
GeoNaDataViewerProfileReader gdvp = new GeoNaDataViewerProfileReader("geoportal-data-viewer-app");
GeoNaDataViewerProfile profile = gdvp.readProfileFromInfrastrucure();
System.out.println(profile.getRestrictedPortletURL());
System.out.println(profile.getOpenPortletURL());
if(profile.getMapLayers()!=null) {
for (String type : profile.getMapLayers().keySet()) {
System.out.println("key: "+type+", value: "+profile.getMapLayers().get(type));
}
}
}*/
}

@ -1,6 +1,11 @@
package org.gcube.portlets.user.geoportaldataviewer.server;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@ -8,22 +13,33 @@ import org.gcube.application.geoportal.managers.AbstractRecordManager;
import org.gcube.application.geoportal.managers.ManagerFactory;
import org.gcube.application.geoportal.model.Record;
import org.gcube.application.geoportal.model.concessioni.Concessione;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.application.geoportal.model.content.UploadedImage;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerService;
import org.gcube.portlets.user.geoportaldataviewer.server.gis.FeatureParser;
import org.gcube.portlets.user.geoportaldataviewer.server.gis.WMSUrlValidator;
import org.gcube.portlets.user.geoportaldataviewer.server.util.SessionUtil;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaDataObject;
import org.gcube.portlets.user.geoportaldataviewer.server.util.URLParserUtil;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaDataViewerProfile;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaItemRef;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult;
import org.gcube.portlets.user.geoportaldataviewer.shared.PublicLink;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.FeatureRow;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformationForWMSRequest;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.Styles;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.ZAxis;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.ConcessioneDV;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.content.WorkspaceContentDV;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.UploadedImageDV;
import org.gcube.portlets.user.urlshortener.UrlShortener;
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.gcube.vomanagement.usermanagement.model.GCubeUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -31,6 +47,10 @@ import com.google.gwt.user.server.rpc.RemoteServiceServlet;
/**
* The server side implementation of the RPC service.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Nov 12, 2020
*/
@SuppressWarnings("serial")
public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet implements
@ -40,21 +60,31 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
/** The Constant LOG. */
private static final Logger LOG = LoggerFactory.getLogger(GeoportalDataViewerServiceImpl.class);
/**
* Parses the wms request.
*
* @param wmsRequest the wms request
* @param layerName the layer name
* @return the geo information for WMS request
* @throws Exception the exception
*/
@Override
public GeoInformationForWMSRequest parseWmsRequest(String wmsRequest, String layerName) throws Exception {
return loadGeoInfoForWmsRequest(wmsRequest, layerName);
}
/* Load geo info for wms request.
/**
* Load geo info for wms request.
*
* @param wmsRequest the wms request
* @param wmsLink the wms link
* @param layerName the layer name
* @return the gis viewer wms valid parameters
* @return the geo information for WMS request
* @throws Exception the exception
*/
public static GeoInformationForWMSRequest loadGeoInfoForWmsRequest(String wmsRequest, String layerName) throws Exception{
public static GeoInformationForWMSRequest loadGeoInfoForWmsRequest(String wmsLink, String layerName) throws Exception{
try {
WMSUrlValidator validator = new WMSUrlValidator(wmsRequest, layerName);
WMSUrlValidator validator = new WMSUrlValidator(wmsLink, layerName);
String wmsServiceHost = validator.getWmsServiceHost();
String validWMSRequest = validator.parseWMSRequest(true, true);
layerName = validator.getLayerName();
@ -87,33 +117,133 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
throw new Exception(msg);
}
}
/*
* (non-Javadoc)
*
* @see
* org.gcube.portlets.user.gisviewer.client.GisViewerService#getDataResult(java.
* util.List, java.lang.String, int)
/**
* Gets the data result.
*
* @param layerObjects the layer objects
* @param mapSrsName the map srs name
* @param selectBBOX the select BBOX
* @param maxWFSFeature the max WFS feature
* @param zoomLevel the zoom level
* @return the data result
*/
@Override
public List<GeoNaDataObject> getDataResult(List<LayerItem> layerItems, String mapSrsName, BoundsMap selectBBOX,
public List<GeoNaSpatialQueryResult> getDataResult(List<LayerObject> layerObjects, String mapSrsName, BoundsMap selectBBOX,
int maxWFSFeature, double zoomLevel) {
LOG.info("getDataResult called");
List<GeoNaDataObject> result = FeatureParser.getDataResults(layerItems, mapSrsName, selectBBOX, maxWFSFeature);
return result;
List<GeoNaSpatialQueryResult> listDAO = new ArrayList<GeoNaSpatialQueryResult>(layerObjects.size());
for (LayerObject layerObject : layerObjects) {
GeoNaSpatialQueryResult geoDAO = new GeoNaSpatialQueryResult();
List<FeatureRow> features = FeatureParser.getWFSFeatures(layerObject.getLayerItem(), mapSrsName, selectBBOX, maxWFSFeature);
LOG.debug("For layer name: "+layerObject.getLayerItem().getName() +" got features: "+features);
geoDAO.setFeatures(features);
for (FeatureRow fRow : features) {
if(fRow.getMapProperties()!=null) {
List<String> concessioneIds = fRow.getMapProperties().get("product_id");
if(concessioneIds!=null && concessioneIds.size()>0) {
String cId = concessioneIds.get(0);
try {
long theConcessionID = Long.parseLong(cId);
List<UploadedImageDV> listUI = getUploadedImagesForId("Concessione", theConcessionID, 1);
Map<Long, List<UploadedImageDV>> mapImages = new LinkedHashMap<Long, List<UploadedImageDV>>();
mapImages.put(theConcessionID, listUI);
geoDAO.setMapImages(mapImages);
}catch (Exception e) {
LOG.warn("Error on loading uploaded images for concessione: "+cId, e);
}
}
}
}
geoDAO.setSourceLayerObject(layerObject);
LOG.info("Fo layer name: "+layerObject.getLayerItem().getName() +" got "+features.size()+" feature/s");
listDAO.add(geoDAO);
}
LOG.info("returning "+listDAO+" geona data objects");
return listDAO;
}
/**
* Gets the uploaded images for id.
*
* @param id the id
* @return the uploaded images for id
* @throws Exception the exception
*/
@Override
public ConcessioneDV getConcessioneForId(Long id) throws Exception{
public List<UploadedImageDV> getUploadedImagesForId(String itemType, Long id, int maxImages) throws Exception{
LOG.info("getConcessioneForId "+id+ "called");
if(!SessionUtil.isIntoPortal()) {
LOG.warn("OUT OF PORTAL setting HARD-CODED SCOPE");
String scope = "/gcube/devNext/NextNext";
LOG.warn("SCOPE is: "+scope);
ScopeProvider.instance.set(scope);
if(itemType==null)
throw new Exception("Invalid parameter. The itemType is null");
if(id==null)
throw new Exception("Invalid parameter. The Id is null");
List<UploadedImageDV> listUI = null;
try {
LOG.info("Trying to get record for id "+id);
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
AbstractRecordManager<Record> abmRecord = ManagerFactory.getByRecordID(id);
LOG.info("Got record for id "+id);
Record record = abmRecord.getRecord();
Concessione concessione = null;
if (record != null) {
if (itemType.equalsIgnoreCase("Concessione") && record instanceof Concessione) {
concessione = (Concessione) record;
List<UploadedImage> images = concessione.getImmaginiRappresentative();
if (images != null) {
listUI = new ArrayList<UploadedImageDV>();
int max = maxImages < images.size() ? maxImages : images.size();
for (int i = 0; i < max; i++) {
UploadedImageDV ui = ConvertToDataViewModel.toUploadedImage(images.get(i));
listUI.add(ui);
}
}
}
}
return listUI;
}catch (Exception e) {
String erroMsg = UploadedImage.class.getSimpleName() +" not available for "+Concessione.class.getSimpleName() +" with id "+id;
LOG.error(erroMsg,e);
//TODO REMOTE THIS
listUI = new ArrayList<UploadedImageDV>(1);
UploadedImageDV img = new UploadedImageDV();
List<WorkspaceContentDV> listWsContent = new ArrayList<WorkspaceContentDV>();
WorkspaceContentDV wcDV = new WorkspaceContentDV();
wcDV.setLink("https://upload.wikimedia.org/wikipedia/commons/thumb/b/b4/Tempio_di_Giove_2.jpg/1280px-Tempio_di_Giove_2.jpg");
listWsContent.add(wcDV);
img.setListWsContent(listWsContent);
listUI.add(img);
LOG.warn("DUMMY UploadedImageDVs: "+listUI);
return listUI;
//throw new Exception(erroMsg);
}
}
/**
* Gets the concessione for id.
*
* @param id the id
* @return the concessione for id
* @throws Exception the exception
*/
@Override
public ConcessioneDV getConcessioneForId(Long id) throws Exception{
LOG.info("getConcessioneForId "+id+ "called");
ConcessioneDV concessionDV = null;
if(id==null)
@ -121,6 +251,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
try {
LOG.info("Trying to get record for id "+id);
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
AbstractRecordManager<Record> abmRecord = ManagerFactory.getByRecordID(id);
LOG.info("Got record for id "+id);
Record record = abmRecord.getRecord();
@ -139,6 +270,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
String erroMsg = Concessione.class.getSimpleName() +" with id "+id+" not available";
LOG.error(erroMsg,e);
//TODO REMOVE THIS
Concessione concessione= TestModel.prepareConcessione();
LOG.warn("DUMMY CONCESSIONE: "+concessione);
ConcessioneDV theConcessione = ConvertToDataViewModel.toConcessione(concessione);
@ -149,5 +281,193 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
}
}
/**
* Gets the parameters from URL.
*
* @param theURL the the URL
* @param parameters the parameters
* @return a map with couple (paramKey, paramValue)
*/
public Map<String, String> getParametersFromURL(String theURL, List<String> parameters) {
if (theURL == null)
return null;
if (parameters == null || parameters.size() == 0)
return null;
Map<String, String> hashParameters = new HashMap<String, String>(parameters.size());
for (String paramKey : parameters) {
String paramValue = URLParserUtil.extractValueOfParameterFromURL(paramKey, theURL);
hashParameters.put(paramKey, paramValue);
}
return hashParameters;
}
/**
* Gets the my login.
*
* @return the my login
*/
@Override
public String getMyLogin(){
try {
GCubeUser user = SessionUtil.getCurrentUser(this.getThreadLocalRequest());
if(user==null)
return null;
return user.getUsername();
}catch (Exception e) {
LOG.warn("Error on getting the login, am I out of portal? Returning null");
return null;
}
}
/**
* Gets the layer for type.
*
* @param layerType the layer type
* @return the layer for type
* @throws Exception the exception
*/
@Override
public GeoInformationForWMSRequest getLayerForType(String layerType) throws Exception{
LOG.info("Called getLayerForType for:"+layerType);
if(layerType==null || layerType.isEmpty())
throw new Exception("The input parameter layerType is null or empty");
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
GeoNaDataViewerProfileReader gdvp = new GeoNaDataViewerProfileReader("geoportal-data-viewer-app");
GeoNaDataViewerProfile profile = gdvp.readProfileFromInfrastrucure();
LOG.info("Read profile: "+profile);
String lowerLayerType = layerType.toLowerCase();
LOG.info("Reading map layers for type:"+lowerLayerType);
LayerItem layer = profile.getMapLayers().get(lowerLayerType);
if(layer==null || layer.getWmsLink()==null)
throw new Exception("The layer type "+lowerLayerType+" has not been found. Please check your input parameter");
if(layer.getWmsLink()==null)
throw new Exception("The layer type "+lowerLayerType+" has not a WMS Link associated. Please check your input parameter");
return parseWmsRequest(layer.getWmsLink(), null);
}
/**
* Gets the geo na data view profile.
*
* @return the geo na data view profile
* @throws Exception the exception
*/
@Override
public GeoNaDataViewerProfile getGeoNaDataViewProfile() throws Exception{
LOG.info("getGeoNaDataViewProfile called");
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
GeoNaDataViewerProfileReader gdvp = new GeoNaDataViewerProfileReader("geoportal-data-viewer-app");
GeoNaDataViewerProfile profile = gdvp.readProfileFromInfrastrucure();
LOG.info("Returning profile: "+profile);
return profile;
}
@Override
public GeoNaItemRef getPublicLinksFor(GeoNaItemRef item) throws Exception {
LOG.info("getPublicLinksFor called for: " + item);
try {
if (item == null)
throw new Exception("Bad request, the item is null");
if(item.getItemId()==null)
throw new Exception("Bad request, the item id is null");
if(item.getItemType()==null)
throw new Exception("Bad request, the item type is null");
GeoNaDataViewerProfile geonaDataProfile = getGeoNaDataViewProfile();
//Restricted Link
String link = String.format("%s?%s=%s&%s=%s",
geonaDataProfile.getRestrictedPortletURL(),
GeoportalDataViewerConstants.GET_GEONA_ITEM_ID,
item.getItemId(),
GeoportalDataViewerConstants.GET_GEONA_ITEM_TYPE,
item.getItemType());
String shortUrl = getShortUrl(link);
item.setRestrictedLink(new PublicLink(link, shortUrl));
//Open Link
link = String.format("%s?%s=%s&%s=%s",
geonaDataProfile.getOpenPortletURL(),
GeoportalDataViewerConstants.GET_GEONA_ITEM_ID,
item.getItemId(),
GeoportalDataViewerConstants.GET_GEONA_ITEM_TYPE,
item.getItemType());
shortUrl = getShortUrl(link);
item.setOpenLink(new PublicLink(link, shortUrl));
LOG.info("returning: " + item);
return item;
} catch (Exception e) {
LOG.error("Error on getPublicLinksFor for: " + item, e);
throw new Exception("Share link not available for this item. Try later or contact the support. Error: "+e.getMessage());
}
}
@Override
public String getShortUrl(String longUrl) throws Exception {
LOG.info("getShortUrl called for " + longUrl);
if(longUrl==null)
return longUrl;
UrlShortener shortener = SessionUtil.getUrlShortener(this.getThreadLocalRequest());
try {
if (shortener != null && shortener.isAvailable()) {
String toShort = longUrl;
String[] splitted = toShort.split("\\?");
LOG.debug("Splitted long URL is: "+Arrays.asList(splitted));
String link = toShort;
if (splitted.length > 1) {
LOG.debug("Query string detected, encoding it...");
String encodedQuery = splitted[1];
try {
encodedQuery = URLEncoder.encode(splitted[1], "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
LOG.debug("encodedQuery is: "+encodedQuery);
link = String.format("%s?%s", splitted[0], encodedQuery);
}
return shortener.shorten(link);
}
return longUrl;
} catch (Exception e) {
LOG.error("Error on shortening the longURL "+longUrl, e);
return null;
}
}
public boolean isSessionExpired() throws Exception {
return SessionUtil.isSessionExpired(this.getThreadLocalRequest());
}
}

@ -3,106 +3,121 @@ package org.gcube.portlets.user.geoportaldataviewer.server;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.gcube.application.geoportal.model.AccessPolicy;
import org.gcube.application.geoportal.model.concessioni.Concessione;
import org.gcube.application.geoportal.model.concessioni.LayerConcessione;
import org.gcube.application.geoportal.model.concessioni.RelazioneScavo;
import org.gcube.application.geoportal.model.content.PersistedContent;
import org.gcube.application.geoportal.model.content.UploadedImage;
import org.gcube.application.geoportal.model.content.WorkspaceContent;
import org.gcube.application.geoportal.model.gis.BBOX;
public class TestModel {
public static Concessione prepareEmptyConcessione() {
Concessione concessione=new Concessione();
Concessione concessione = new Concessione();
// Generic fields
// Concessione fields
concessione.setNome("Italia, forse");
concessione.setIntroduzione("This is my project");
concessione.setDescrizioneContenuto("It contains this and that");
concessione.setAuthors(Arrays.asList(new String[] {"Some one","Some, oneelse"}));
concessione.setAuthors(Arrays.asList(new String[] { "Some one", "Some, oneelse" }));
concessione.setContributore("Contrib 1");
concessione.setTitolari(Arrays.asList(new String[] {"Some one","Some, oneelse"}));
concessione.setTitolari(Arrays.asList(new String[] { "Some one", "Some, oneelse" }));
concessione.setResponsabile("Someone");
concessione.setEditore("Editore");
concessione.setFontiFinanziamento(Arrays.asList(new String[] {"Big pharma","Pentagon"}));
concessione.setFontiFinanziamento(Arrays.asList(new String[] { "Big pharma", "Pentagon" }));
concessione.setSoggetto(Arrays.asList(new String[] {"Research Excavation","Archeology"}));
concessione.setSoggetto(Arrays.asList(new String[] { "Research Excavation", "Archeology" }));
concessione
.setRisorseCorrelate(Arrays.asList(new String[] { "https://google.com", "https://www.repubblica.it" }));
concessione.setDataInizioProgetto(LocalDateTime.now());
concessione.setDataFineProgetto(LocalDateTime.now());
concessione.setLicenzaID("CC-BY");
concessione.setTitolareLicenza("Qualcun altro");
concessione.setTitolareCopyright("Chiedilo in giro");
concessione.setParoleChiaveLibere(Arrays.asList(new String[] {"Robba","Stuff"}));
concessione.setParoleChiaveICCD(Arrays.asList(new String[] {"vattelapesca","somthing something"}));
concessione.setParoleChiaveLibere(Arrays.asList(new String[] { "Robba", "Stuff" }));
concessione.setParoleChiaveICCD(Arrays.asList(new String[] { "vattelapesca", "somthing something" }));
concessione.setLastUpdateTime(LocalDateTime.now());
concessione.setCreationTime(LocalDateTime.now());
concessione.setLastUpdateUser("fake user");
concessione.setCentroidLat(43.0); // N-S
concessione.setCentroidLong(9.0); // E-W
concessione.setCentroidLat(43.0); //N-S
concessione.setCentroidLong(9.0); //E-W
return concessione;
}
public static Concessione prepareConcessione() {
Concessione concessione=prepareEmptyConcessione();
Concessione concessione = prepareEmptyConcessione();
// Attachments
// Relazione scavo
RelazioneScavo relScavo=new RelazioneScavo();
RelazioneScavo relScavo = new RelazioneScavo();
relScavo.setAbstractSection("simple abstract section");
relScavo.setResponsabili(concessione.getAuthors());
concessione.setRelazioneScavo(relScavo);
//Immagini rappresentative
ArrayList<UploadedImage> imgs=new ArrayList<>();
for(int i=0;i<5;i++) {
UploadedImage img=new UploadedImage();
img.setTitolo("My image number "+i);
img.setDidascalia("You can see my image number "+i);
// Immagini rappresentative
ArrayList<UploadedImage> imgs = new ArrayList<>();
for (int i = 0; i < 5; i++) {
UploadedImage img = new UploadedImage();
img.setTitolo("My image number " + i);
img.setDidascalia("You can see my image number " + i);
img.setFormat("TIFF");
img.setCreationTime(LocalDateTime.now());
img.setResponsabili(concessione.getAuthors());
List<PersistedContent> actualContentList = new ArrayList<PersistedContent>(1);
WorkspaceContent ws = new WorkspaceContent();
ws.setLink("https://data-dev.d4science.net/ie8Y");
actualContentList.add(ws);
img.setActualContent(actualContentList);
imgs.add(img);
}
concessione.setImmaginiRappresentative(imgs);
//Posizionamento
LayerConcessione posizionamento=new LayerConcessione();
// Posizionamento
LayerConcessione posizionamento = new LayerConcessione();
posizionamento.setValutazioneQualita("Secondo me si");
posizionamento.setMetodoRaccoltaDati("Fattobbene");
posizionamento.setScalaAcquisizione("1:10000");
posizionamento.setAuthors(concessione.getAuthors());
posizionamento.setAuthors(concessione.getAuthors());
concessione.setPosizionamentoScavo(posizionamento);
// Piante fine scavo
ArrayList<LayerConcessione> piante=new ArrayList<LayerConcessione>();
for(int i=0;i<4;i++) {
LayerConcessione pianta=new LayerConcessione();
ArrayList<LayerConcessione> piante = new ArrayList<LayerConcessione>();
for (int i = 0; i < 4; i++) {
LayerConcessione pianta = new LayerConcessione();
pianta.setValutazioneQualita("Secondo me si");
pianta.setMetodoRaccoltaDati("Fattobbene");
pianta.setScalaAcquisizione("1:10000");
pianta.setAuthors(concessione.getAuthors());
pianta.setAuthors(concessione.getAuthors());
pianta.setPolicy(AccessPolicy.RESTRICTED);
pianta.setLayerName("gna_conc_12:pos");
pianta.setWmsLink(
"https://geoserver1.dev.d4science.org/geoserver/gna_conc_12/wms?service=WMS&version=1.1.0&request=GetMap&layers=gna_conc_12:pos&styles=&bbox=8.62091913167495,40.62975046683799,8.621178639172953,40.630257904721645&width=392&height=768&srs=EPSG:4326&format=application/openlayers#toggle");
pianta.setBbox(new BBOX(40.630257904721645,8.621178639172953,40.62975046683799,8.62091913167495));
piante.add(pianta);
}
concessione.setPianteFineScavo(piante);
return concessione;
}
}

@ -17,11 +17,12 @@ import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
import org.gcube.portlets.user.geoportaldataviewer.server.util.URLParserUtil;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaDataObject;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.Coordinate;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.FeatureGeometry;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.FeatureRow;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.PointsPath;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@ -29,48 +30,37 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class FeatureParser.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Oct 29, 2020
* Nov 13, 2020
*/
public class FeatureParser {
private static Logger LOG = LoggerFactory.getLogger(FeatureParser.class);
/**
* Gets the data results.
* Gets the WFS features.
*
* @param layerItems the layer items
* @param layerItem the layer item
* @param mapSrsName the map srs name
* @param selectBBOX the select BBOX
* @param maxWFSFeature the max WFS feature
* @return the data results
* @return the WFS features
*/
public static List<GeoNaDataObject> getDataResults(List<LayerItem> layerItems, String mapSrsName, BoundsMap selectBBOX, int maxWFSFeature) {
public static List<FeatureRow> getWFSFeatures(LayerItem layerItem, String mapSrsName, BoundsMap selectBBOX, int maxWFSFeature) {
if(maxWFSFeature<0) {
maxWFSFeature = GeoportalDataViewerConstants.MAX_WFS_FEATURES;
}
List<GeoNaDataObject> listGeonaDO = new ArrayList<GeoNaDataObject>();
//IF WFS IS AVAILABLE USE WFS REQUEST OTHERWHISE TRY TO USE WPS SERVICE
for (LayerItem layerItem : layerItems){
List<FeatureRow> rows = getWFSFeatureProperties(layerItem, mapSrsName, selectBBOX, maxWFSFeature);
GeoNaDataObject gdo = new GeoNaDataObject();
gdo.setLayerItem(layerItem);
gdo.setFeatures(rows);
listGeonaDO.add(gdo);
}
return listGeonaDO;
return getWFSFeatureProperties(layerItem, mapSrsName, selectBBOX, maxWFSFeature);
}
/**
* Gets the WFS feature properties.
*
@ -138,8 +128,26 @@ public class FeatureParser {
JSONObject geometry = theFeature.getJSONObject("geometry");
String typeValue = geometry.getString("type");
JSONArray coordinates = geometry.getJSONArray("coordinates");
String toCoordinates = coordinates.toString();
row.setGeometry(new FeatureGeometry(typeValue, toCoordinates));
//String toCoordinates = coordinates.toString();
String x1 = coordinates.get(0).toString();
String y1 = coordinates.get(1).toString();
LOG.debug("Coordinate x1: "+x1);
LOG.debug("Coordinate y1: "+y1);
Double coordX = null;
Double coordY = null;
FeatureGeometry fg = new FeatureGeometry();
fg.setType(typeValue);
//TODO ONLY POINT GEOMETRY
try {
coordX = Double.parseDouble(x1);
coordY = Double.parseDouble(y1);
Coordinate coord = new Coordinate(coordX, coordY);
fg.setPath(new PointsPath(new Coordinate[] {coord}));
}catch (Exception e) {
LOG.warn("Not able to parse the 'coordinates' field: ",e);
}
row.setGeometry(fg);
}catch (Exception e) {
LOG.debug("Unable to pase geometry at index: "+i);
}

@ -35,15 +35,18 @@ public class WMSUrlValidator {
private static final Logger LOG = LoggerFactory.getLogger(WMSUrlValidator.class);
/**
* Instantiates a new gis viewer wms url validator.
* Instantiates a new WMS url validator.
*
* @param wmsRequest the full url
* @param layerName the layer name
* @param wmsRequest the wms request
* @param inputLayerName the input layer name
* @throws Exception the exception
*/
public WMSUrlValidator(String wmsRequest, String layerName) throws Exception{
public WMSUrlValidator(String wmsRequest, String inputLayerName) throws Exception{
LOG.debug("WMSURLValidator wmsRequest: "+wmsRequest);
LOG.debug("WMSURLValidator layerName: "+inputLayerName);
if(wmsRequest==null || wmsRequest.isEmpty())
throw new Exception("WMS request is null or empty");
@ -57,13 +60,13 @@ public class WMSUrlValidator {
LOG.trace("found "+GeoWmsServiceUtility.SERVICE_WMS+" in wms request: "+wmsRequestURI);
webMapServerHost = getWebMapServerHost(wmsRequestURI);
}else
throw new Exception("WMS service not found for layer: "+layerName);
throw new Exception("WMS service not found for layer: "+inputLayerName);
//VALIDATION WMS
String baseWmsService = webMapServerHost.getHost();
//IS OWS OR WMS?
this.wmsServiceHost = appendWmsServiceToBaseUrl(wmsRequest.substring(0, wmsRequest.indexOf("?")),isOwsService);
this.layerName = layerName;
this.layerName = inputLayerName;
try {
//VALIDATE WMS SERVICE FOR WEB MAP SERVER
@ -82,7 +85,7 @@ public class WMSUrlValidator {
if(this.layerName==null || this.layerName.isEmpty()){
this.layerName = WmsUrlValidator.getValueOfParameter(WmsParameters.LAYERS, wmsRequest);
if(this.layerName==null || layerName.isEmpty())
if(this.layerName==null || this.layerName.isEmpty())
throw new Exception("Layer name is null or empty");
}

@ -3,20 +3,21 @@
*/
package org.gcube.portlets.user.geoportaldataviewer.server.gis;
/**
* The Class GeoserverBaseUri.
* The Class WebMapServerHost.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Jan 28, 2016
*
* Nov 12, 2020
*/
public class WebMapServerHost {
private String host = "";
private String scope = "";
/**
* Instantiates a new geoserver base uri.
* Instantiates a new web map server host.
*/
public WebMapServerHost() {
}
@ -34,6 +35,8 @@ public class WebMapServerHost {
/**
* Gets the host.
*
* @return the host
*/
public String getHost() {
@ -43,6 +46,8 @@ public class WebMapServerHost {
/**
* Gets the scope.
*
* @return the scope
*/
public String getScope() {
@ -52,6 +57,8 @@ public class WebMapServerHost {
/**
* Sets the host.
*
* @param host the host to set
*/
public void setHost(String host) {
@ -61,6 +68,8 @@ public class WebMapServerHost {
/**
* Sets the scope.
*
* @param scope the scope to set
*/
public void setScope(String scope) {
@ -68,6 +77,11 @@ public class WebMapServerHost {
this.scope = scope;
}
/**
* To string.
*
* @return the string
*/
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/

@ -4,9 +4,11 @@
package org.gcube.portlets.user.geoportaldataviewer.server.util;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.gcube.common.portal.PortalContext;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portlets.user.urlshortener.UrlShortener;
import org.gcube.vomanagement.usermanagement.GroupManager;
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
@ -30,6 +32,8 @@ public class SessionUtil {
/** The log. */
private static Logger LOG = LoggerFactory.getLogger(SessionUtil.class);
public static final String URL_SHORTENER_SERVICE = "URL_SHORTENER_SERVICE";
/**
* Checks if is into portal.
@ -45,6 +49,20 @@ public class SessionUtil {
return false;
}
}
/**
* Checks if is session expired.
*
* @param httpServletRequest
* the http servlet request
* @return true, if is session expired
* @throws Exception
* the exception
*/
public static boolean isSessionExpired(HttpServletRequest httpServletRequest) throws Exception {
LOG.trace("workspace session validating...");
return PortalContext.getConfiguration().getCurrentUser(httpServletRequest) == null;
}
/**
* Retrieve the current user by using the portal manager.
@ -103,4 +121,30 @@ public class SessionUtil {
return gm.getGroup(groupId);
}
/**
* Gets the url shortener.
*
* @param httpServletRequest the http servlet request
* @return the url shortener
*/
public static UrlShortener getUrlShortener(HttpServletRequest httpServletRequest) {
HttpSession session = httpServletRequest.getSession();
UrlShortener shortener = null;
try {
shortener = (UrlShortener) session.getAttribute(URL_SHORTENER_SERVICE);
if (shortener == null) {
shortener = new UrlShortener();
session.setAttribute(URL_SHORTENER_SERVICE, shortener);
}
} catch (Exception e) {
LOG.warn("Error occurred when instancing the "+UrlShortener.class.getSimpleName(), e);
}
return shortener;
}
}

@ -1,65 +1,48 @@
package org.gcube.portlets.user.geoportaldataviewer.server.util;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLDecoder;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
/**
* The Class URLUtil.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Oct 29, 2020
* Oct 29, 2020
*/
public class URLParserUtil {
/**
* 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;
}
/**
* Adds the parameter to query string.
*
* @param key the key
* @param value the value
* @param key the key
* @param value the value
* @param prefixAmpersand the prefix ampersand
* @param suffixAmpersand the suffix ampersand
* @return the string
*/
public static String addParameterToQueryString(String key, String value, boolean prefixAmpersand, boolean suffixAmpersand) {
public static String addParameterToQueryString(String key, String value, boolean prefixAmpersand,
boolean suffixAmpersand) {
String queryParameter = "";
if(prefixAmpersand)
queryParameter+="&";
queryParameter+=key+"="+value;
if(suffixAmpersand)
queryParameter+="&";
if (prefixAmpersand)
queryParameter += "&";
queryParameter += key + "=" + value;
if (suffixAmpersand)
queryParameter += "&";
return queryParameter;
}
/**
* Extract value of parameter from URL.
*
@ -68,7 +51,8 @@ public class URLParserUtil {
* @return the string
*/
public static String extractValueOfParameterFromURL(String paramName, String url) {
int index = url.toLowerCase().indexOf(paramName.toLowerCase() + "="); // ADDING CHAR "=" IN TAIL TO BE SURE THAT IT
int index = url.toLowerCase().indexOf(paramName.toLowerCase() + "="); // ADDING CHAR "=" IN TAIL TO BE SURE THAT
// IT
// IS A PARAMETER
String value = "";
if (index > -1) {
@ -84,5 +68,29 @@ public class URLParserUtil {
return value;
}
/**
* Split query.
*
* @param url the url
* @return the map
* @throws UnsupportedEncodingException the unsupported encoding exception
*/
public static Map<String, List<String>> splitQuery(URL url) throws UnsupportedEncodingException {
final Map<String, List<String>> query_pairs = new LinkedHashMap<String, List<String>>();
final String[] pairs = url.getQuery().split("&");
for (String pair : pairs) {
final int idx = pair.indexOf("=");
final String key = idx > 0 ? URLDecoder.decode(pair.substring(0, idx), "UTF-8") : pair;
if (!query_pairs.containsKey(key)) {
query_pairs.put(key, new LinkedList<String>());
}
final String value = idx > 0 && pair.length() > idx + 1
? URLDecoder.decode(pair.substring(idx + 1), "UTF-8")
: null;
query_pairs.get(key).add(value);
}
return query_pairs;
}
}

@ -1,85 +0,0 @@
package org.gcube.portlets.user.geoportaldataviewer.shared;
import java.io.Serializable;
import java.util.List;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.FeatureRow;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.ConcessioneDV;
/**
* The Class GeoNaDataObject.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Oct 29, 2020
*/
public class GeoNaDataObject implements Serializable{
/**
*
*/
private static final long serialVersionUID = 5566069859060851625L;
/** The form data entry fields. */
private List<FeatureRow> features;
private ProductType productType;
private LayerItem layerItem;
private ConcessioneDV concessioneDV;
/**
* Instantiates a new geo na data object.
*/
public GeoNaDataObject(){
}
public List<FeatureRow> getFeatures() {
return features;
}
public void setFeatures(List<FeatureRow> features) {
this.features = features;
}
public ProductType getProductType() {
return productType;
}
public void setProductType(ProductType productType) {
this.productType = productType;
}
public LayerItem getLayerItem() {
return layerItem;
}
public void setLayerItem(LayerItem layerItem) {
this.layerItem = layerItem;
}
public ConcessioneDV getConcessioneDV() {
return concessioneDV;
}
public void setConcessioneDV(ConcessioneDV concessioneDV) {
this.concessioneDV = concessioneDV;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("GeoNaDataObject [features=");
builder.append(features);
builder.append(", productType=");
builder.append(productType);
builder.append(", layerItem=");
builder.append(layerItem);
builder.append(", concessioneDV=");
builder.append(concessioneDV);
builder.append("]");
return builder.toString();
}
}

@ -0,0 +1,109 @@
package org.gcube.portlets.user.geoportaldataviewer.shared;
import java.io.Serializable;
import java.util.Map;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
import com.google.gwt.user.client.rpc.IsSerializable;
/**
* The Class GeoNaDataViewerProfile.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Nov 13, 2020
*/
public class GeoNaDataViewerProfile implements IsSerializable, Serializable{
/**
*
*/
private static final long serialVersionUID = 8583236018312392009L;
private String restrictedPortletURL;
private String openPortletURL;
//the key is the layer type
private Map<String, LayerItem> mapLayers;
/**
* Instantiates a new geo na data viewer profile.
*/
public GeoNaDataViewerProfile() {
}
/**
* Gets the restricted portlet URL.
*
* @return the restricted portlet URL
*/
public String getRestrictedPortletURL() {
return restrictedPortletURL;
}
/**
* Sets the restricted portlet URL.
*
* @param restrictedPortletURL the new restricted portlet URL
*/
public void setRestrictedPortletURL(String restrictedPortletURL) {
this.restrictedPortletURL = restrictedPortletURL;
}
/**
* Gets the open portlet URL.
*
* @return the open portlet URL
*/
public String getOpenPortletURL() {
return openPortletURL;
}
/**
* Sets the open portlet URL.
*
* @param openPortletURL the new open portlet URL
*/
public void setOpenPortletURL(String openPortletURL) {
this.openPortletURL = openPortletURL;
}
/**
* Gets the map layers.
*
* @return the map layers
*/
public Map<String, LayerItem> getMapLayers() {
return mapLayers;
}
/**
* Sets the map layers.
*
* @param mapLayers the map layers
*/
public void setMapLayers(Map<String, LayerItem> mapLayers) {
this.mapLayers = mapLayers;
}
/**
* To string.
*
* @return the string
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("GeoNaDataViewerProfile [restrictedPortletURL=");
builder.append(restrictedPortletURL);
builder.append(", openPortletURL=");
builder.append(openPortletURL);
builder.append(", mapLayers=");
builder.append(mapLayers);
builder.append("]");
return builder.toString();
}
}

@ -0,0 +1,156 @@
package org.gcube.portlets.user.geoportaldataviewer.shared;
import java.io.Serializable;
/**
* The Class GeoNaItemRef.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Nov 17, 2020
*/
public class GeoNaItemRef implements Serializable {
/**
*
*/
private static final long serialVersionUID = -7021431511279022193L;
private Long itemId;
private String itemType;
private String itemName;
private PublicLink restrictedLink;
private PublicLink openLink;
/**
* Instantiates a new geo na object.
*/
public GeoNaItemRef() {
}
/**
* Instantiates a new geo na object.
*
* @param itemId the item id
* @param itemType the item type
*/
public GeoNaItemRef(Long itemId, String itemType) {
super();
this.itemId = itemId;
this.itemType = itemType;
}
/**
* Gets the item id.
*
* @return the item id
*/
public Long getItemId() {
return itemId;
}
/**
* Sets the item id.
*
* @param itemId the new item id
*/
public void setItemId(Long itemId) {
this.itemId = itemId;
}
/**
* Gets the item type.
*
* @return the item type
*/
public String getItemType() {
return itemType;
}
/**
* Sets the item type.
*
* @param itemType the new item type
*/
public void setItemType(String itemType) {
this.itemType = itemType;
}
/**
* Gets the item name.
*
* @return the item name
*/
public String getItemName() {
return itemName;
}
/**
* Sets the item name.
*
* @param itemName the new item name
*/
public void setItemName(String itemName) {
this.itemName = itemName;
}
/**
* Gets the restricted link.
*
* @return the restricted link
*/
public PublicLink getRestrictedLink() {
return restrictedLink;
}
/**
* Sets the restricted link.
*
* @param restrictedLink the new restricted link
*/
public void setRestrictedLink(PublicLink restrictedLink) {
this.restrictedLink = restrictedLink;
}
/**
* Gets the open link.
*
* @return the open link
*/
public PublicLink getOpenLink() {
return openLink;
}
/**
* Sets the open link.
*
* @param openLink the new open link
*/
public void setOpenLink(PublicLink openLink) {
this.openLink = openLink;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("GeoNaItemRef [itemId=");
builder.append(itemId);
builder.append(", itemType=");
builder.append(itemType);
builder.append(", itemName=");
builder.append(itemName);
builder.append(", restrictedLink=");
builder.append(restrictedLink);
builder.append(", openLink=");
builder.append(openLink);
builder.append("]");
return builder.toString();
}
}

@ -0,0 +1,103 @@
package org.gcube.portlets.user.geoportaldataviewer.shared;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.FeatureRow;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.UploadedImageDV;
/**
* The Class GeoNaSpatialQueryResult.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Nov 17, 2020
*/
public class GeoNaSpatialQueryResult implements Serializable {
/**
*
*/
private static final long serialVersionUID = 3513120677727206958L;
private List<FeatureRow> features;
private LayerObject sourceLayerObject;
// Map with couple (id concessione, list of uplaoded Images for the concessione)
private Map<Long, List<UploadedImageDV>> mapImages = null;
/**
* Instantiates a new geo na data object.
*/
public GeoNaSpatialQueryResult() {
}
/**
* Gets the features.
*
* @return the features
*/
public List<FeatureRow> getFeatures() {
return features;
}
/**
* Sets the features.
*
* @param features the new features
*/
public void setFeatures(List<FeatureRow> features) {
this.features = features;
}
/**
* Gets the source layer object.
*
* @return the source layer object
*/
public LayerObject getSourceLayerObject() {
return sourceLayerObject;
}
/**
* Sets the source layer object.
*
* @param sourceLayerObject the new source layer object
*/
public void setSourceLayerObject(LayerObject sourceLayerObject) {
this.sourceLayerObject = sourceLayerObject;
}
/**
* Gets the map images.
*
* @return the map images
*/
public Map<Long, List<UploadedImageDV>> getMapImages() {
return mapImages;
}
/**
* Sets the map images.
*
* @param mapImages the map images
*/
public void setMapImages(Map<Long, List<UploadedImageDV>> mapImages) {
this.mapImages = mapImages;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("GeoNaSpatialQueryResult [features=");
builder.append(features);
builder.append(", sourceLayerObject=");
builder.append(sourceLayerObject);
builder.append(", mapImages=");
builder.append(mapImages);
builder.append("]");
return builder.toString();
}
}

@ -1,7 +0,0 @@
package org.gcube.portlets.user.geoportaldataviewer.shared;
public enum ProductType {
CONCESSIONE
}

@ -0,0 +1,95 @@
/**
*
*/
package org.gcube.portlets.user.geoportaldataviewer.shared;
import java.io.Serializable;
/**
* The Class PublicLink.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
* Sep 13, 2016
*/
public class PublicLink implements Serializable {
/**
*
*/
private static final long serialVersionUID = -8157172818802297440L;
private String completeURL;
private String shortURL;
/**
* Instantiates a new public link.
*/
public PublicLink() {
}
/**
* Instantiates a new public link.
*
* @param completeURL the complete url
* @param shortURL the short url
*/
public PublicLink(String completeURL, String shortURL) {
super();
this.completeURL = completeURL;
this.shortURL = shortURL;
}
/**
* Gets the complete url.
*
* @return the completeURL
*/
public String getCompleteURL() {
return completeURL;
}
/**
* Gets the short url.
*
* @return the shortURL
*/
public String getShortURL() {
return shortURL;
}
/**
* Sets the complete url.
*
* @param completeURL the completeURL to set
*/
public void setCompleteURL(String completeURL) {
this.completeURL = completeURL;
}
/**
* Sets the short url.
*
* @param shortURL the shortURL to set
*/
public void setShortURL(String shortURL) {
this.shortURL = shortURL;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("PublicLink [completeURL=");
builder.append(completeURL);
builder.append(", shortURL=");
builder.append(shortURL);
builder.append("]");
return builder.toString();
}
}

@ -0,0 +1,24 @@
/**
*
*/
package org.gcube.portlets.user.geoportaldataviewer.shared;
/**
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
* Sep 4, 2013
*
*/
public class SessionExpiredException extends Exception{
/**
*
*/
private static final long serialVersionUID = 8423680645305738442L;
/**
*
*/
public SessionExpiredException() {
super("Session expired");
}
}

@ -94,7 +94,7 @@ public class LayerItem implements Serializable, Cloneable {
private boolean isNcWms = false;
/** The server wms request. */
public String serverWmsRequest;
public String wmsLink;
/** The cql filter available. */
private boolean cqlFilterAvailable = false;
@ -759,21 +759,21 @@ public class LayerItem implements Serializable, Cloneable {
}
/**
* Gets the server wms request.
* Gets the wms link.
*
* @return the server wms request
* @return the wms link
*/
public String getServerWmsRequest() {
return serverWmsRequest;
public String getWmsLink() {
return wmsLink;
}
/**
* Sets the server wms request.
* Sets the wms link.
*
* @param serverWmsRequest the new server wms request
* @param wmsLink the new wms link
*/
public void setServerWmsRequest(String serverWmsRequest) {
this.serverWmsRequest = serverWmsRequest;
public void setWmsLink(String wmsLink) {
this.wmsLink = wmsLink;
}
/**
@ -848,11 +848,6 @@ public class LayerItem implements Serializable, Cloneable {
this.zAxisSelected = zAxisSelected;
}
/**
* To string.
*
* @return the string
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
@ -904,8 +899,8 @@ public class LayerItem implements Serializable, Cloneable {
builder.append(wmsNotStandardParams);
builder.append(", isNcWms=");
builder.append(isNcWms);
builder.append(", serverWmsRequest=");
builder.append(serverWmsRequest);
builder.append(", wmsLink=");
builder.append(wmsLink);
builder.append(", cqlFilterAvailable=");
builder.append(cqlFilterAvailable);
builder.append(", UUID=");
@ -918,4 +913,5 @@ public class LayerItem implements Serializable, Cloneable {
return builder.toString();
}
}

@ -0,0 +1,82 @@
package org.gcube.portlets.user.geoportaldataviewer.shared.gis;
import java.io.Serializable;
/**
* The Class LayerObject.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Nov 13, 2020
*/
public class LayerObject implements Serializable {
/**
*
*/
private static final long serialVersionUID = -2282478701630148774L;
/* This is the layer/product type. E.g. Concessione */
private String itemType;
private LayerItem layerItem;
/**
* Instantiates a new layer object.
*/
public LayerObject() {
// TODO Auto-generated constructor stub
}
/**
* Gets the item type.
*
* @return the item type
*/
public String getItemType() {
return itemType;
}
/**
* Sets the item type.
*
* @param itemType the new item type
*/
public void setItemType(String itemType) {
this.itemType = itemType;
}
/**
* Gets the layer item.
*
* @return the layer item
*/
public LayerItem getLayerItem() {
return layerItem;
}
/**
* Sets the layer item.
*
* @param layerItem the new layer item
*/
public void setLayerItem(LayerItem layerItem) {
this.layerItem = layerItem;
}
/**
* To string.
*
* @return the string
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("LayerObject [itemType=");
builder.append(itemType);
builder.append(", layerItem=");
builder.append(layerItem);
builder.append("]");
return builder.toString();
}
}

@ -0,0 +1,71 @@
package org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs;
import java.io.Serializable;
/**
* The Class Coordinate.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Nov 16, 2020
*/
public class Coordinate implements Serializable{
/**
*
*/
private static final long serialVersionUID = -3352677110683481305L;
private Double x;
private Double y;
/**
* Instantiates a new coordinate.
*/
public Coordinate() {
super();
}
/**
* Instantiates a new coordinate.
*
* @param x the x
* @param y the y
*/
public Coordinate(Double x, Double y) {
super();
this.x = x;
this.y = y;
}
public Double getX() {
return x;
}
public void setX(Double x) {
this.x = x;
}
public Double getY() {
return y;
}
public void setY(Double y) {
this.y = y;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("Coordinate [x=");
builder.append(x);
builder.append(", y=");
builder.append(y);
builder.append("]");
return builder.toString();
}
}

@ -7,24 +7,24 @@ import java.io.Serializable;
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Oct 29, 2020
* Oct 29, 2020
*/
public class FeatureGeometry implements Serializable{
public class FeatureGeometry implements WFSGeometry, Serializable {
/**
*
*/
private static final long serialVersionUID = 6251162740446739453L;
private String type;
private String coordinates;
private PointsPath path;
public FeatureGeometry() {
}
public FeatureGeometry(String type, String coordinates) {
public FeatureGeometry(String type, PointsPath path) {
super();
this.type = type;
this.coordinates = coordinates;
this.path = path;
}
public String getType() {
@ -35,12 +35,12 @@ public class FeatureGeometry implements Serializable{
this.type = type;
}
public String getCoordinates() {
return coordinates;
public PointsPath getPath() {
return path;
}
public void setCoordinates(String coordinates) {
this.coordinates = coordinates;
public void setPath(PointsPath path) {
this.path = path;
}
@Override
@ -48,8 +48,8 @@ public class FeatureGeometry implements Serializable{
StringBuilder builder = new StringBuilder();
builder.append("FeatureGeometry [type=");
builder.append(type);
builder.append(", coordinates=");
builder.append(coordinates);
builder.append(", path=");
builder.append(path);
builder.append("]");
return builder.toString();
}

@ -0,0 +1,60 @@
package org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs;
import java.io.Serializable;
import java.util.Arrays;
/**
* The Class PointsPath.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Nov 16, 2020
*/
public class PointsPath implements Serializable{
/**
*
*/
private static final long serialVersionUID = -3295493507974317970L;
private Coordinate[] coordinates;
/**
* Instantiates a new points path.
*/
public PointsPath() {
}
/**
* Instantiates a new points path.
*
* @param coordinates the coordinates
*/
public PointsPath(Coordinate[] coordinates) {
super();
this.coordinates = coordinates;
}
public Coordinate[] getCoordinates() {
return coordinates;
}
/**
* To string.
*
* @return the string
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("PointsPath [coordinates=");
builder.append(Arrays.toString(coordinates));
builder.append("]");
return builder.toString();
}
}

@ -0,0 +1,28 @@
package org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs;
/**
* The Interface WFSGeometry.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Nov 16, 2020
*/
public interface WFSGeometry {
/**
* Gets the type.
*
* @return the type
*/
String getType();
/**
* Gets the path.
*
* @return the path
*/
PointsPath getPath();
}

@ -5,7 +5,9 @@ import java.util.ArrayList;
import java.util.List;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.content.OtherContentDV;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.LayerConcessioneDV;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.RecordDV;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.RelazioneScavoDV;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.UploadedImageDV;
import com.google.gwt.user.client.rpc.IsSerializable;
@ -89,10 +91,10 @@ public class ConcessioneDV extends RecordDV implements Serializable, IsSerializa
private LayerConcessioneDV posizionamentoScavo;
/** The piante fine scavo. */
private List<LayerConcessioneDV> pianteFineScavo = new ArrayList<>();
private List<LayerConcessioneDV> pianteFineScavo = new ArrayList<LayerConcessioneDV>();
/** The generic content. */
private List<OtherContentDV> genericContent = new ArrayList<>();
private List<OtherContentDV> genericContent = new ArrayList<OtherContentDV>();
/**
* Instantiates a new concessione.

@ -4,6 +4,8 @@ import java.io.Serializable;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.RecordDV;
import com.google.gwt.user.client.rpc.IsSerializable;
/**
* The Class AssociatedContent.
*
@ -11,7 +13,7 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.RecordD
*
* Nov 2, 2020
*/
public class AssociatedContentDV implements Serializable{
public class AssociatedContentDV implements IsSerializable, Serializable{
/**

@ -1,11 +1,13 @@
package org.gcube.portlets.user.geoportaldataviewer.shared.products;
package org.gcube.portlets.user.geoportaldataviewer.shared.products.model;
import java.io.Serializable;
import java.util.List;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.SDILayerDescriptorDV;
public class LayerConcessioneDV extends SDILayerDescriptorDV {
import com.google.gwt.user.client.rpc.IsSerializable;
public class LayerConcessioneDV extends SDILayerDescriptorDV implements IsSerializable, Serializable{
/**
*

@ -11,7 +11,7 @@ import com.google.gwt.user.client.rpc.IsSerializable;
*
* Nov 2, 2020
*/
public class RecordDV implements Serializable, IsSerializable {
public abstract class RecordDV implements Serializable, IsSerializable {
/**

@ -1,4 +1,4 @@
package org.gcube.portlets.user.geoportaldataviewer.shared.products;
package org.gcube.portlets.user.geoportaldataviewer.shared.products.model;
import java.io.Serializable;
import java.util.List;

@ -4,6 +4,8 @@ import java.io.Serializable;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.content.AssociatedContentDV;
import com.google.gwt.user.client.rpc.IsSerializable;
/**
* The Class SDILayerDescriptorDV.
@ -12,7 +14,7 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.products.content.Assoc
*
* Nov 4, 2020
*/
public class SDILayerDescriptorDV extends AssociatedContentDV implements Serializable {
public class SDILayerDescriptorDV extends AssociatedContentDV implements IsSerializable, Serializable {
/**
*

@ -6,6 +6,8 @@ import java.util.List;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.content.AssociatedContentDV;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.content.WorkspaceContentDV;
import com.google.gwt.user.client.rpc.IsSerializable;
/**
* The Class UploadedImage.
*
@ -13,7 +15,7 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.products.content.Works
*
* Nov 2, 2020
*/
public class UploadedImageDV extends AssociatedContentDV implements Serializable {
public class UploadedImageDV extends AssociatedContentDV implements IsSerializable, Serializable {
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 809167060189883015L;
@ -119,15 +121,10 @@ public class UploadedImageDV extends AssociatedContentDV implements Serializable
this.listWsContent = listWsContent;
}
/**
* To string.
*
* @return the string
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("UploadedImage [didascalia=");
builder.append("UploadedImageDV [didascalia=");
builder.append(didascalia);
builder.append(", format=");
builder.append(format);
@ -135,6 +132,8 @@ public class UploadedImageDV extends AssociatedContentDV implements Serializable
builder.append(responsabili);
builder.append(", soggetto=");
builder.append(soggetto);
builder.append(", listWsContent=");
builder.append(listWsContent);
builder.append("]");
return builder.toString();
}

@ -1,5 +1,9 @@
/** Add css rules here for your application. */
/** Most GWT widgets already have a style name defined */
body {
padding-top: 0px !important;
}
.gwt-DialogBox {
width: 400px;
}
@ -27,6 +31,12 @@
bottom: 12px;
left: -50px;
min-width: 280px;
max-width: 350px;
visibility: hidden;
}
.ol-popup img {
max-width: 100%;
}
.ol-popup:after, .ol-popup:before {
@ -37,7 +47,7 @@
width: 0;
position: absolute;
pointer-events: none;
visibility: visible;
overflow: hidden;
}
.ol-popup:after {
@ -65,6 +75,130 @@
content: "✖";
}
.data-click-img {
max-width: 395px;
}
.popup-table div:first-child {
font-weight: bold;
}
#page-view-details {
margin: 10px;
text-rendering: optimizelegibility;
font-family: Lato, 'Helvetica Neue', Arial, Helvetica, sans-serif;
}
#page-view-details .page-header {
margin-bottom: 22px;
}
#page-view-details > h1 {
font-size: 32px;
}
#page-view-details > p {
font-size: 24px;
padding: 10px;
color: #999;
}
#page-view-details .my-custom-flex-table {
margin-left: 20px;
margin-right: 40px;
font-size: 14px;
}
#page-view-details .my-custom-flex-table td {
padding: 5px;
}
#page-view-details .my-custom-flex-table tbody tr>td:first-child {
color: gray;
font-weight: bold;
width: 200px;
}
.ol-mouse-position {
top: 8px !important;
right: 60px !important;
position: absolute !important;
border: 2px solid #eee;
color: #eee;
font-size: 12px;
text-align: center;
margin: 1px;
will-change: contents, width;
transition: all .25s;
background: rgba(0, 60, 136, .5);
border-radius: 2px;
padding-left: 2px;
padding-right: 2px;
padding-bottom: 1px;
padding-top: 1px;
}
.my-control-group .controls {
margin-left: 70px !important;
}
.my-control-group .control-label {
width: 100px !important;
text-align: left !important;
padding-left: 10px !important;
}
.my-control-group .add-on {
width: 20px !important;
}
.my-control-group .gwt-TextBox {
width: 305px !important;
}
.my-control-group .gwt-TextBox:hover {
cursor: text !important;
}
.sharelabel {
font-size: 14px !important;
padding-top: 4px !important;
margin-bottom: 5px;
}
.details-panel {
position: absolute;
top: 0;
right: 0px;
background: #FFF;
width: 725px;
/*margin-top: 30px;*/
padding-left: 5px;
overflow-y: auto;
transition: width 0.5s;
z-index: 1000;
}
.overlay {
z-index: 1000;
opacity: 0.9;
}
.inner-toolbar {
position: absolute;
z-index: 500;
top: 8px;
left: 50px;
}
.inner-toolbar .btn-link {
border: 1px solid #eee;
background-color: #fcfcfc;
text-align: center;
margin: 1px;
}
.inner-toolbar .btn-link:hover, .inner-toolbar .btn-link:focus {
background-color: #f3f3f3 !important;
text-decoration: none;
}

@ -6,6 +6,8 @@ import org.gcube.application.geoportal.model.Record;
import org.gcube.application.geoportal.model.concessioni.Concessione;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portlets.user.geoportaldataviewer.server.ConvertToDataViewModel;
import org.gcube.portlets.user.geoportaldataviewer.server.GeoportalDataViewerServiceImpl;
import org.gcube.portlets.user.geoportaldataviewer.shared.products.ConcessioneDV;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -14,9 +16,9 @@ public class GetConcessione {
private static final Logger LOG = LoggerFactory.getLogger(GetConcessione.class);
public static String SCOPE = "/gcube/devNext/NextNext";
public static long concessioneId = 48;
public static long concessioneId = 16;
public static void main(String[] args) {
/*public static void main(String[] args) {
ScopeProvider.instance.set(SCOPE);
@ -39,6 +41,14 @@ public class GetConcessione {
String erroMsg = Concessione.class.getSimpleName() +" with id "+concessioneId+" not available";
LOG.error(erroMsg,e);
}
}*/
public static void main(String[] args) throws Exception {
GeoportalDataViewerServiceImpl geonNaServiecImpl = new GeoportalDataViewerServiceImpl();
ScopeProvider.instance.set(SCOPE);
LOG.info("Trying to get record for id "+concessioneId);
ConcessioneDV concessione = geonNaServiecImpl.getConcessioneForId(concessioneId);
LOG.info("Got record for id "+concessione);
}

@ -0,0 +1,38 @@
package org.gcube.portlets.user.geoportaldataviewer;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Arrays;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portlets.user.urlshortener.UrlShortener;
public class TestShortener {
public static void main(String[] args) {
try {
String toShort = "https://next.d4science.org/group/nextnext/geona-data-viewer";
String[] splitted = toShort.split("\\?");
System.out.println("Splitted is: "+Arrays.asList(splitted));
String link = toShort;
if (splitted.length > 1) {
String encodedQuery = splitted[1];
try {
encodedQuery = URLEncoder.encode(splitted[1], "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
System.out.println("encodedQuery is: "+encodedQuery);
link = String.format("%s?%s", splitted[0], encodedQuery);
}
ScopeProvider.instance.set("/gcube/devNext/NextNext");
UrlShortener shortener = new UrlShortener();
System.out.println(shortener.shorten(link));
} catch (Exception e) {
e.printStackTrace();
}
}
}
Loading…
Cancel
Save