Load init config : base layers and available collections
This commit is contained in:
parent
1e84ca40a7
commit
a07befcc1d
37
pom.xml
37
pom.xml
|
@ -73,39 +73,14 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.application</groupId>
|
||||
<artifactId>geoportal-data-common</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
<scope>compile</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.gcube.application</groupId>
|
||||
<artifactId>geoportal-client</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
<!-- END FORCING -->
|
||||
<!-- <dependency>
|
||||
<groupId>org.gcube.application</groupId>
|
||||
<artifactId>geoportal-client</artifactId>
|
||||
<version>[1.0.0, 2.0.0-SNAPSHOT)</version>
|
||||
<scope>compile</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.gcube.resources.discovery</groupId>
|
||||
<artifactId>ic-client</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.ow2.asm</groupId>
|
||||
<artifactId>asm</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- END FORCING -->
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.9.1</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependency> -->
|
||||
|
||||
|
||||
<dependency>
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.client;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
|
||||
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.model.RecordDV;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.events.application.AddedLayerToMapEvent;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.events.application.AddedLayerToMapEvent.LAYER_TYPE;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.events.application.AddedLayerToMapEventHandler;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.events.application.ChangeBaseMapLayerEvent;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.events.application.ClosedViewDetailsEvent;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.events.application.DoActionOnDetailLayersEvent;
|
||||
|
@ -20,9 +21,11 @@ import org.gcube.portlets.user.geoportaldataviewer.client.events.application.Sho
|
|||
import org.gcube.portlets.user.geoportaldataviewer.client.events.application.ZoomOutOverMinimumEvent;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerMap;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.ui.GeonaDataViewMainPanel;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.util.ControlledCallBack;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.util.LoaderIcon;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.util.OGCUtils;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.GCubeCollection;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.ViewerConfiguration;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
|
||||
|
||||
import com.google.gwt.core.client.EntryPoint;
|
||||
|
@ -33,7 +36,6 @@ import com.google.gwt.core.client.ScriptInjector;
|
|||
import com.google.gwt.event.logical.shared.ResizeEvent;
|
||||
import com.google.gwt.event.logical.shared.ResizeHandler;
|
||||
import com.google.gwt.event.shared.HandlerManager;
|
||||
import com.google.gwt.user.client.Timer;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.HTML;
|
||||
|
@ -59,18 +61,14 @@ public class GeoportalDataViewer implements EntryPoint {
|
|||
/** The main panel. */
|
||||
private GeonaDataViewMainPanel mainPanel;
|
||||
|
||||
private StartParameters startParameters = null;
|
||||
|
||||
private HandlerManager applicationBus = new HandlerManager("");
|
||||
|
||||
/** The layer manager. */
|
||||
private LayerManager layerManager = new LayerManager(applicationBus);
|
||||
|
||||
|
||||
private GNADataViewerConfigProfile geonaDataViewerProfile;
|
||||
|
||||
private OLMapManager olMapMng = null;
|
||||
|
||||
|
||||
int attempt = 0;
|
||||
|
||||
private LoaderIcon loaderApp = new LoaderIcon("Loading application... please wait");
|
||||
|
@ -78,12 +76,8 @@ public class GeoportalDataViewer implements EntryPoint {
|
|||
private HTML attributionDiv = new HTML();
|
||||
|
||||
private static List<BaseMapLayer> listBaseMapLayers = null;
|
||||
|
||||
// Configuration by UCD
|
||||
// Map : UCID -> Collection description
|
||||
private Map<String, GCubeCollection> openedCollections=new HashMap<>();
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This is the entry point method.
|
||||
*/
|
||||
|
@ -92,11 +86,9 @@ public class GeoportalDataViewer implements EntryPoint {
|
|||
loaderApp.getElement().addClassName("loader-gna-app");
|
||||
RootPanel.get(APP_DIV).add(loaderApp);
|
||||
|
||||
startParameters = new StartParameters(Window.Location.getParameterMap());
|
||||
|
||||
// Fields configurations are read on open collection event
|
||||
|
||||
mainPanel = new GeonaDataViewMainPanel(applicationBus, getClientHeight(),null,null,null);
|
||||
mainPanel = new GeonaDataViewMainPanel(applicationBus, getClientHeight());
|
||||
RootPanel.get(APP_DIV).add(mainPanel);
|
||||
|
||||
initApplication();
|
||||
|
@ -104,34 +96,30 @@ public class GeoportalDataViewer implements EntryPoint {
|
|||
}
|
||||
|
||||
private void initApplication() {
|
||||
|
||||
|
||||
|
||||
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
|
||||
//LOADING THE BASE MAP LAYERS
|
||||
GeoportalDataViewerServiceAsync.Util.getInstance().getListBaseLayers(new AsyncCallback<List<BaseMapLayer>>() {
|
||||
|
||||
Map<String,List<String>> queryParameters = new HashMap<String,List<String>> ();
|
||||
queryParameters.putAll(Window.Location.getParameterMap());
|
||||
|
||||
GWT.log("Sending query params : "+ queryParameters);
|
||||
// Load Initial Configuration
|
||||
GeoportalDataViewerServiceAsync.Util.getInstance().getInitialConfiguration(queryParameters, new ControlledCallBack<ViewerConfiguration>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
RootPanel.get(APP_DIV).remove(loaderApp);
|
||||
GWT.log("Failure on loading base layers", caught);
|
||||
Window.alert("Sorry, an error occurred on instancing the GeoPortale Viewer. Please, contact the support");
|
||||
}
|
||||
|
||||
public void after() {RootPanel.get(APP_DIV).remove(loaderApp);}
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<BaseMapLayer> listBaseMapLayers) {
|
||||
|
||||
// ?? Maybe remove after load collection / project?
|
||||
try {
|
||||
RootPanel.get(APP_DIV).remove(loaderApp);
|
||||
}catch (Exception e) {
|
||||
loaderApp.setVisible(false);
|
||||
}
|
||||
|
||||
//now the map is loaded and I'm sure that I can load the GeonaDataViewer Profile
|
||||
GeoportalDataViewer.listBaseMapLayers = listBaseMapLayers;
|
||||
public void onSuccess(ViewerConfiguration result) {
|
||||
super.onSuccess(result);
|
||||
|
||||
GWT.log("Received init config : "+result);
|
||||
GWT.log("Loading base layers, count : "+result.getBaseLayers().size());
|
||||
|
||||
GeoportalDataViewer.listBaseMapLayers = result.getBaseLayers();
|
||||
mainPanel.setBaseLayers(listBaseMapLayers);
|
||||
|
||||
BaseMapLayer firstBaseLayer = listBaseMapLayers.get(0);
|
||||
|
@ -143,44 +131,21 @@ public class GeoportalDataViewer implements EntryPoint {
|
|||
mainPanel.setMap(olMap);
|
||||
|
||||
updateSize();
|
||||
|
||||
ScriptInjector.fromUrl("//cdnjs.cloudflare.com/ajax/libs/nanogallery2/3.0.5/jquery.nanogallery2.min.js")
|
||||
.setWindow(ScriptInjector.TOP_WINDOW).inject();
|
||||
|
||||
if(!startParameters.toOpenCollections().isEmpty()){
|
||||
// Fire
|
||||
}
|
||||
|
||||
if(!startParameters.toOpenProjects().isEmpty()){
|
||||
// open projects by projectID list
|
||||
}
|
||||
|
||||
if(!startParameters.toOpenLayers().isEmpty()){
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
GeoportalDataViewerServiceAsync.Util.getInstance().getAvailableCollections(new AsyncCallback<List<GCubeCollection>>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
GWT.log("Failure on loading available collections ", caught);
|
||||
Window.alert("Sorry, an error occurred while gathering collections. Please, contact the support");
|
||||
}
|
||||
|
||||
public void onSuccess(java.util.List<GCubeCollection> result) {
|
||||
GWT.log("Loaded Collections");
|
||||
result.forEach(g ->GWT.log(g.getUcd().getName()));
|
||||
|
||||
};
|
||||
|
||||
|
||||
GWT.log("Loading collections, count "+result.getAvailableCollections().size());
|
||||
|
||||
mainPanel.setAvailableCollections(result.getAvailableCollections());
|
||||
|
||||
// TODO LOAD INITIAL LAYERS
|
||||
|
||||
GWT.log("DONE INIT LOAD");
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -1,19 +1,15 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.client;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
|
||||
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
|
||||
import org.gcube.application.geoportalcommon.shared.ItemField;
|
||||
import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData;
|
||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
|
||||
import org.gcube.application.geoportalcommon.shared.gis.BoundsMap;
|
||||
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.GCubeCollection;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.ViewerConfiguration;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.faults.ControlledError;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformationForWMSRequest;
|
||||
|
||||
|
@ -53,14 +49,14 @@ public interface GeoportalDataViewerService extends RemoteService {
|
|||
List<GeoNaSpatialQueryResult> getDataResult(List<LayerObject> layerObjects, String mapSrsName, BoundsMap mapBBOX,
|
||||
int maxWFSFeature, double zoomLevel);
|
||||
|
||||
/**
|
||||
* Gets the concessione for id.
|
||||
*
|
||||
* @param mongoId the mongo id
|
||||
* @return the concessione for id
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
ConcessioneDV getConcessioneForId(String mongoId) throws Exception;
|
||||
// /**
|
||||
// * Gets the concessione for id.
|
||||
// *
|
||||
// * @param mongoId the mongo id
|
||||
// * @return the concessione for id
|
||||
// * @throws Exception the exception
|
||||
// */
|
||||
// ConcessioneDV getConcessioneForId(String mongoId) throws Exception;
|
||||
|
||||
/**
|
||||
* Gets the my login.
|
||||
|
@ -106,15 +102,15 @@ public interface GeoportalDataViewerService extends RemoteService {
|
|||
*/
|
||||
GeoNaItemRef getPublicLinksFor(GeoNaItemRef item) throws Exception;
|
||||
|
||||
/**
|
||||
* Gets the layers for id.
|
||||
*
|
||||
* @param itemType the item type
|
||||
* @param itemId the item id
|
||||
* @return the layers for id
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
List<LayerConcessioneDV> getLayersForId(String itemType, String itemId) throws Exception;
|
||||
// /**
|
||||
// * Gets the layers for id.
|
||||
// *
|
||||
// * @param itemType the item type
|
||||
// * @param itemId the item id
|
||||
// * @return the layers for id
|
||||
// * @throws Exception the exception
|
||||
// */
|
||||
// List<LayerConcessioneDV> getLayersForId(String itemType, String itemId) throws Exception;
|
||||
|
||||
/**
|
||||
* Gets the WFS features.
|
||||
|
@ -129,32 +125,9 @@ public interface GeoportalDataViewerService extends RemoteService {
|
|||
List<GeoNaSpatialQueryResult> getWFSFeatures(List<LayerObject> layerObjects, String mapSrsName,
|
||||
BoundsMap selectBBOX, int maxWFSFeature, double zoomLevel);
|
||||
|
||||
List<BaseMapLayer> getListBaseLayers();
|
||||
|
||||
/**
|
||||
* List of fields for searching.
|
||||
*
|
||||
* @return the list
|
||||
* @throws Exception
|
||||
*/
|
||||
List<ItemField> listOfFieldsForSearching() throws Exception;
|
||||
|
||||
/**
|
||||
* Gets the list concessioni.
|
||||
*
|
||||
* @param start the start
|
||||
* @param limit the limit
|
||||
* @param filter the filter
|
||||
* @param reloadFromService the reload from service
|
||||
* @return the list concessioni
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
ResultSetPaginatedData getListConcessioni(Integer start, Integer limit, SearchingFilter filter,
|
||||
boolean reloadFromService) throws Exception;
|
||||
|
||||
|
||||
// Collections
|
||||
|
||||
List<GCubeCollection> getAvailableCollections() throws Exception;
|
||||
|
||||
ViewerConfiguration getInitialConfiguration(Map<String, List<String>> parameters) throws Exception, ControlledError;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,19 +1,14 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.client;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
|
||||
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
|
||||
import org.gcube.application.geoportalcommon.shared.ItemField;
|
||||
import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData;
|
||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
|
||||
import org.gcube.application.geoportalcommon.shared.gis.BoundsMap;
|
||||
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.GCubeCollection;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.ViewerConfiguration;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformationForWMSRequest;
|
||||
|
||||
|
@ -44,8 +39,6 @@ public interface GeoportalDataViewerServiceAsync {
|
|||
void getDataResult(List<LayerObject> layerObjects, String mapSrsName, BoundsMap mapBBOX, int maxWFSFeature,
|
||||
double zoomLevel, AsyncCallback<List<GeoNaSpatialQueryResult>> callback);
|
||||
|
||||
void getConcessioneForId(String mongoId, AsyncCallback<ConcessioneDV> callback);
|
||||
|
||||
void getMyLogin(AsyncCallback<String> callback);
|
||||
|
||||
void getLayerForType(String layerType, AsyncCallback<GeoInformationForWMSRequest> callback);
|
||||
|
@ -57,23 +50,13 @@ public interface GeoportalDataViewerServiceAsync {
|
|||
|
||||
void getPublicLinksFor(GeoNaItemRef item, AsyncCallback<GeoNaItemRef> asyncCallback);
|
||||
|
||||
void getLayersForId(String itemType, String itemId, AsyncCallback<List<LayerConcessioneDV>> asyncCallback);
|
||||
|
||||
void getWFSFeatures(List<LayerObject> layerObjects, String mapSrsName, BoundsMap selectBBOX, int maxWFSFeature,
|
||||
double zoomLevel, AsyncCallback<List<GeoNaSpatialQueryResult>> callback);
|
||||
|
||||
void getListBaseLayers(AsyncCallback<List<BaseMapLayer>> callback);
|
||||
|
||||
// PROJECTS SUPPORT
|
||||
|
||||
void listOfFieldsForSearching(AsyncCallback<List<ItemField>> callback);
|
||||
|
||||
void getListConcessioni(Integer start, Integer limit, SearchingFilter filter, boolean reloadFromService,
|
||||
AsyncCallback<ResultSetPaginatedData> callback);
|
||||
|
||||
|
||||
|
||||
|
||||
// Collections
|
||||
|
||||
void getAvailableCollections(AsyncCallback<List<GCubeCollection>> callback);
|
||||
void getInitialConfiguration(Map<String, List<String>> parameters, AsyncCallback<ViewerConfiguration> callback);
|
||||
|
||||
}
|
||||
|
|
|
@ -274,39 +274,47 @@ public class LayerManager {
|
|||
queryEvent.getQueryClickExtent().getCenter());
|
||||
}
|
||||
|
||||
// retrieving and showing WMS layers of a concessione if the ZOOM level is >
|
||||
// QUERY_MIN_ZOOM_LEVEL
|
||||
if (olMap.getCurrentZoomLevel() > OLMapManager.QUERY_MIN_ZOOM_LEVEL) {
|
||||
GeoportalDataViewerServiceAsync.Util.getInstance().getLayersForId(
|
||||
"concessione", theProductId,
|
||||
new AsyncCallback<List<LayerConcessioneDV>>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<LayerConcessioneDV> result) {
|
||||
|
||||
for (LayerConcessioneDV layer : result) {
|
||||
GWT.log("Adding layer: " + layer.getLayerName());
|
||||
addLayer("concessione", layer.getLayerName(),
|
||||
layer.getLayerName(), layer.getWmsLink(),
|
||||
false, false, layer.getLayerUUID(), true,
|
||||
OLMapManager.LAYER_DETAIL_MIN_RESOLUTION,
|
||||
OLMapManager.LAYER_DETAIL_MAX_RESOLUTION,
|
||||
layer.getRefersTo());
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// removing all WMS detail layers if the ZOOM level is <
|
||||
// QUERY_MIN_ZOOM_LEVEL
|
||||
removeAllDetailLayers();
|
||||
}
|
||||
|
||||
//TODO LOAD LAYERS FOM BBOX
|
||||
GWT.log("TODO LAOD LAYERS" );
|
||||
|
||||
|
||||
|
||||
// // retrieving and showing WMS layers of a concessione if the ZOOM level is >
|
||||
// // QUERY_MIN_ZOOM_LEVEL
|
||||
// if (olMap.getCurrentZoomLevel() > OLMapManager.QUERY_MIN_ZOOM_LEVEL) {
|
||||
// GeoportalDataViewerServiceAsync.Util.getInstance().getLayersForId(
|
||||
// "concessione", theProductId,
|
||||
// new AsyncCallback<List<LayerConcessioneDV>>() {
|
||||
//
|
||||
// @Override
|
||||
// public void onFailure(Throwable caught) {
|
||||
// // TODO Auto-generated method stub
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onSuccess(List<LayerConcessioneDV> result) {
|
||||
//
|
||||
// for (LayerConcessioneDV layer : result) {
|
||||
// GWT.log("Adding layer: " + layer.getLayerName());
|
||||
// addLayer("concessione", layer.getLayerName(),
|
||||
// layer.getLayerName(), layer.getWmsLink(),
|
||||
// false, false, layer.getLayerUUID(), true,
|
||||
// OLMapManager.LAYER_DETAIL_MIN_RESOLUTION,
|
||||
// OLMapManager.LAYER_DETAIL_MAX_RESOLUTION,
|
||||
// layer.getRefersTo());
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// });
|
||||
// } else {
|
||||
// // removing all WMS detail layers if the ZOOM level is <
|
||||
// // QUERY_MIN_ZOOM_LEVEL
|
||||
// removeAllDetailLayers();
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.client;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.ViewerConfiguration;
|
||||
|
||||
public class ViewerStatus {
|
||||
|
||||
|
||||
private GNADataViewerConfigProfile geonaDataViewerProfile;
|
||||
|
||||
private ViewerConfiguration config;
|
||||
|
||||
|
||||
// ucid -> indexId
|
||||
private Map<String,String> openedIndexes;
|
||||
|
||||
// ucid -> projectId
|
||||
private Map<String,String> openedProjects;
|
||||
|
||||
public GNADataViewerConfigProfile getGeonaDataViewerProfile() {
|
||||
return geonaDataViewerProfile;
|
||||
}
|
||||
|
||||
public void setGeonaDataViewerProfile(GNADataViewerConfigProfile geonaDataViewerProfile) {
|
||||
this.geonaDataViewerProfile = geonaDataViewerProfile;
|
||||
}
|
||||
|
||||
public ViewerConfiguration getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public void setConfig(ViewerConfiguration config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
public Map<String, String> getOpenedIndexes() {
|
||||
return openedIndexes;
|
||||
}
|
||||
|
||||
public void setOpenedIndexes(Map<String, String> openedIndexes) {
|
||||
this.openedIndexes = openedIndexes;
|
||||
}
|
||||
|
||||
public Map<String, String> getOpenedProjects() {
|
||||
return openedProjects;
|
||||
}
|
||||
|
||||
public void setOpenedProjects(Map<String, String> openedProjects) {
|
||||
this.openedProjects = openedProjects;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -2,7 +2,6 @@ package org.gcube.portlets.user.geoportaldataviewer.client.ui;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.ItemField;
|
||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
|
||||
import org.gcube.application.geoportalcommon.shared.products.model.RecordDV;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION;
|
||||
|
@ -138,9 +137,7 @@ public class GeonaDataViewMainPanel extends Composite {
|
|||
* @param applicationBus the application bus
|
||||
* @param mapHeight the map height
|
||||
*/
|
||||
public GeonaDataViewMainPanel(HandlerManager applicationBus, int mapHeight,
|
||||
List<ItemField> sortByFields,
|
||||
List<ItemField> searchForFields, SearchingFilter initialSortFilter) {
|
||||
public GeonaDataViewMainPanel(HandlerManager applicationBus, int mapHeight) {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
this.applicationBus = applicationBus;
|
||||
mapPanel = new MapPanel(mapHeight + "px");
|
||||
|
@ -169,9 +166,6 @@ public class GeonaDataViewMainPanel extends Composite {
|
|||
openCollectionDropDown.setCustomIconStyle(GNAIcons.CustomIconType.MAP.get());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// TODO
|
||||
GWT.log("!!! NB TODO : Search facility is skipped ");
|
||||
|
||||
|
@ -195,7 +189,7 @@ public class GeonaDataViewMainPanel extends Composite {
|
|||
|
||||
// layersDDB.setToggle(true);
|
||||
bindEvents();
|
||||
|
||||
GWT.log("Main Panel Created");
|
||||
}
|
||||
|
||||
private void bindEvents() {
|
||||
|
@ -434,6 +428,7 @@ public class GeonaDataViewMainPanel extends Composite {
|
|||
|
||||
|
||||
for(GCubeCollection coll : toSetAvailableCollections) {
|
||||
GWT.log("Found available collection "+coll);
|
||||
String label = coll.getUcd().getName();
|
||||
String id=coll.getUcd().getId();
|
||||
|
||||
|
|
|
@ -1,50 +1,22 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.client.ui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
|
||||
import org.gcube.application.geoportalcommon.shared.ItemField;
|
||||
import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData;
|
||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
|
||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter.LOGICAL_OP;
|
||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter.ORDER;
|
||||
import org.gcube.application.geoportalcommon.shared.WhereClause;
|
||||
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.events.application.SearchPerformedEvent;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.events.application.ShowDetailsEvent;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.events.application.ShowPopupOnCentroiEvent;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.util.LoaderIcon;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.util.StringUtil;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.Alert;
|
||||
import com.github.gwtbootstrap.client.ui.Button;
|
||||
import com.github.gwtbootstrap.client.ui.DropdownButton;
|
||||
import com.github.gwtbootstrap.client.ui.ListBox;
|
||||
import com.github.gwtbootstrap.client.ui.NavLink;
|
||||
import com.github.gwtbootstrap.client.ui.TextBox;
|
||||
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
||||
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.ChangeEvent;
|
||||
import com.google.gwt.event.dom.client.ChangeHandler;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.event.dom.client.KeyPressEvent;
|
||||
import com.google.gwt.event.dom.client.KeyPressHandler;
|
||||
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.Window;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.Composite;
|
||||
import com.google.gwt.user.client.ui.FlexTable;
|
||||
import com.google.gwt.user.client.ui.HTML;
|
||||
import com.google.gwt.user.client.ui.HTMLPanel;
|
||||
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||
|
@ -85,9 +57,9 @@ public class SearchFacilityUI extends Composite {
|
|||
@UiField
|
||||
HorizontalPanel toogleSortBy;
|
||||
|
||||
private List<ItemField> searchForFields;
|
||||
|
||||
private List<ItemField> sortByFields;
|
||||
// private List<ItemField> searchForFields;
|
||||
//
|
||||
// private List<ItemField> sortByFields;
|
||||
|
||||
private SearchingFilter currentSortFilter;
|
||||
|
||||
|
@ -109,122 +81,122 @@ public class SearchFacilityUI extends Composite {
|
|||
interface SearchFacilityPanelUiBinder extends UiBinder<Widget, SearchFacilityUI> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new search facility UI.
|
||||
*
|
||||
* @param appManagerBus the app manager bus
|
||||
* @param sortByFields the sort by fields
|
||||
* @param searchForFields the search for fields
|
||||
* @param initialSortFilter the initial sort filter
|
||||
*/
|
||||
public SearchFacilityUI(HandlerManager appManagerBus, List<ItemField> sortByFields, List<ItemField> searchForFields,
|
||||
SearchingFilter initialSortFilter) {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
this.searchForFields = searchForFields;
|
||||
this.currentSortFilter = initialSortFilter;
|
||||
this.sortByFields = sortByFields;
|
||||
this.appManagerBus = appManagerBus;
|
||||
// /**
|
||||
// * Instantiates a new search facility UI.
|
||||
// *
|
||||
// * @param appManagerBus the app manager bus
|
||||
// * @param sortByFields the sort by fields
|
||||
// * @param searchForFields the search for fields
|
||||
// * @param initialSortFilter the initial sort filter
|
||||
// */
|
||||
// public SearchFacilityUI(HandlerManager appManagerBus, List<ItemField> sortByFields, List<ItemField> searchForFields,
|
||||
// SearchingFilter initialSortFilter) {
|
||||
// initWidget(uiBinder.createAndBindUi(this));
|
||||
// this.searchForFields = searchForFields;
|
||||
// this.currentSortFilter = initialSortFilter;
|
||||
// this.sortByFields = sortByFields;
|
||||
// this.appManagerBus = appManagerBus;
|
||||
//
|
||||
// resetSearch.setType(ButtonType.LINK);
|
||||
//
|
||||
// listBoxSortBy.setWidth("180px");
|
||||
// listBoxSearchFor.setWidth("140px");
|
||||
//
|
||||
// bindEvents();
|
||||
// }
|
||||
|
||||
resetSearch.setType(ButtonType.LINK);
|
||||
|
||||
listBoxSortBy.setWidth("180px");
|
||||
listBoxSearchFor.setWidth("140px");
|
||||
|
||||
bindEvents();
|
||||
}
|
||||
|
||||
/**
|
||||
* To label filter.
|
||||
*
|
||||
* @param itemField the item field
|
||||
* @param direction the direction
|
||||
* @return the string
|
||||
*/
|
||||
private String toLabelFilter(ItemField itemField, ORDER direction) {
|
||||
String labelFilter = itemField.getDisplayName() + LABEL_FILTER_SEPARATOR + direction.name();
|
||||
return labelFilter;
|
||||
}
|
||||
// /**
|
||||
// * To label filter.
|
||||
// *
|
||||
// * @param itemField the item field
|
||||
// * @param direction the direction
|
||||
// * @return the string
|
||||
// */
|
||||
// private String toLabelFilter(ItemField itemField, ORDER direction) {
|
||||
// String labelFilter = itemField.getDisplayName() + LABEL_FILTER_SEPARATOR + direction.name();
|
||||
// return labelFilter;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Bind events.
|
||||
*/
|
||||
private void bindEvents() {
|
||||
|
||||
for (ItemField record_FIELD : sortByFields) {
|
||||
if(record_FIELD.isSortable()) {
|
||||
String labelASC = toLabelFilter(record_FIELD, ORDER.ASC);
|
||||
String labelDESC = toLabelFilter(record_FIELD, ORDER.DESC);
|
||||
listBoxSortBy.addItem(labelASC);
|
||||
listBoxSortBy.addItem(labelDESC);
|
||||
}
|
||||
}
|
||||
|
||||
listBoxSortBy.addChangeHandler(new ChangeHandler() {
|
||||
|
||||
@Override
|
||||
public void onChange(ChangeEvent event) {
|
||||
if(latestResult!=null && latestResult.getData().size()>0) {
|
||||
doSearchEvent();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
for (ItemField record_FIELD : searchForFields) {
|
||||
GWT.log("search for: "+record_FIELD);
|
||||
if(record_FIELD.isSearchable()) {
|
||||
listBoxSearchFor.addItem(record_FIELD.getDisplayName());
|
||||
}
|
||||
}
|
||||
|
||||
listBoxSearchFor.addChangeHandler(new ChangeHandler() {
|
||||
|
||||
@Override
|
||||
public void onChange(ChangeEvent event) {
|
||||
if (searchField.getText().length() >= MIN_LENGHT_SERCHING_STRING) {
|
||||
doSearchEvent();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
sortByToogle.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
if (toogleSortBy.isVisible())
|
||||
toogleSortBy.setVisible(false);
|
||||
else
|
||||
toogleSortBy.setVisible(true);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
searchField.addKeyPressHandler(new KeyPressHandler() {
|
||||
|
||||
@Override
|
||||
public void onKeyPress(KeyPressEvent event) {
|
||||
if (com.google.gwt.event.dom.client.KeyCodes.KEY_ENTER == event.getCharCode()) {
|
||||
GWT.log(searchField.getText());
|
||||
doSearchEvent();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
resetSearch.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
searchField.setText("");
|
||||
resetSearch.setVisible(false);
|
||||
panelResults.clear();
|
||||
latestResult = null;
|
||||
appManagerBus.fireEvent(new SearchPerformedEvent(null,true));
|
||||
setSearchEnabled(false);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
// private void bindEvents() {
|
||||
//
|
||||
// for (ItemField record_FIELD : sortByFields) {
|
||||
// if(record_FIELD.isSortable()) {
|
||||
// String labelASC = toLabelFilter(record_FIELD, ORDER.ASC);
|
||||
// String labelDESC = toLabelFilter(record_FIELD, ORDER.DESC);
|
||||
// listBoxSortBy.addItem(labelASC);
|
||||
// listBoxSortBy.addItem(labelDESC);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// listBoxSortBy.addChangeHandler(new ChangeHandler() {
|
||||
//
|
||||
// @Override
|
||||
// public void onChange(ChangeEvent event) {
|
||||
// if(latestResult!=null && latestResult.getData().size()>0) {
|
||||
// doSearchEvent();
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// for (ItemField record_FIELD : searchForFields) {
|
||||
// GWT.log("search for: "+record_FIELD);
|
||||
// if(record_FIELD.isSearchable()) {
|
||||
// listBoxSearchFor.addItem(record_FIELD.getDisplayName());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// listBoxSearchFor.addChangeHandler(new ChangeHandler() {
|
||||
//
|
||||
// @Override
|
||||
// public void onChange(ChangeEvent event) {
|
||||
// if (searchField.getText().length() >= MIN_LENGHT_SERCHING_STRING) {
|
||||
// doSearchEvent();
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// sortByToogle.addClickHandler(new ClickHandler() {
|
||||
//
|
||||
// @Override
|
||||
// public void onClick(ClickEvent event) {
|
||||
// if (toogleSortBy.isVisible())
|
||||
// toogleSortBy.setVisible(false);
|
||||
// else
|
||||
// toogleSortBy.setVisible(true);
|
||||
//
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// searchField.addKeyPressHandler(new KeyPressHandler() {
|
||||
//
|
||||
// @Override
|
||||
// public void onKeyPress(KeyPressEvent event) {
|
||||
// if (com.google.gwt.event.dom.client.KeyCodes.KEY_ENTER == event.getCharCode()) {
|
||||
// GWT.log(searchField.getText());
|
||||
// doSearchEvent();
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// resetSearch.addClickHandler(new ClickHandler() {
|
||||
//
|
||||
// @Override
|
||||
// public void onClick(ClickEvent event) {
|
||||
// searchField.setText("");
|
||||
// resetSearch.setVisible(false);
|
||||
// panelResults.clear();
|
||||
// latestResult = null;
|
||||
// appManagerBus.fireEvent(new SearchPerformedEvent(null,true));
|
||||
// setSearchEnabled(false);
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// }
|
||||
|
||||
private void setSearchEnabled(boolean bool) {
|
||||
if(bool) {
|
||||
|
@ -243,136 +215,138 @@ public class SearchFacilityUI extends Composite {
|
|||
SearchingFilter filter = getCurrentSortFilter();
|
||||
panelResults.clear();
|
||||
panelResults.add(new HTML("<hr>"));
|
||||
panelResults.add(new LoaderIcon("Searching..."));
|
||||
GeoportalDataViewerServiceAsync.Util.getInstance().getListConcessioni(0, 30, filter, false,
|
||||
new AsyncCallback<ResultSetPaginatedData>() {
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
// showLoading(false);
|
||||
// Window.alert(caught.getMessage());
|
||||
panelResults.clear();
|
||||
panelResults.add(new HTML("<hr>"));
|
||||
Alert alert = new Alert("Error on searching. Please, refresh or change the search");
|
||||
alert.setType(AlertType.ERROR);
|
||||
alert.setClose(false);
|
||||
panelResults.add(alert);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(ResultSetPaginatedData result) {
|
||||
|
||||
appManagerBus.fireEvent(new SearchPerformedEvent(result.getData(),false));
|
||||
setSearchEnabled(true);
|
||||
latestResult = result;
|
||||
|
||||
panelResults.clear();
|
||||
panelResults.add(new HTML("<hr>"));
|
||||
|
||||
if (result.getData().size() == 0) {
|
||||
panelResults.add(new HTML("No result found"));
|
||||
return;
|
||||
}
|
||||
|
||||
FlexTable ft = new FlexTable();
|
||||
ft.getElement().setClassName("table-results");
|
||||
int i = 1;
|
||||
ft.setWidget(0, i, new HTML("Nome Progetto"));
|
||||
|
||||
String selValue = listBoxSearchFor.getSelectedValue().toLowerCase();
|
||||
|
||||
boolean addIntroduction = false;
|
||||
if(selValue.startsWith("proj") || selValue.startsWith("any")) {
|
||||
ft.setWidget(0, ++i, new HTML("Introduzione"));
|
||||
addIntroduction = true;
|
||||
}
|
||||
|
||||
boolean addStaff = false;
|
||||
if(selValue.startsWith("director")) {
|
||||
ft.setWidget(0, ++i, new HTML("Autori"));
|
||||
ft.setWidget(0, ++i, new HTML("Responsabile"));
|
||||
ft.setWidget(0, ++i, new HTML("Editore"));
|
||||
ft.setWidget(0, ++i, new HTML("Titolari"));
|
||||
ft.setWidget(0, ++i, new HTML("Contributore"));
|
||||
addStaff = true;
|
||||
}
|
||||
boolean addParole = false;
|
||||
if(selValue.startsWith("keyword")) {
|
||||
ft.setWidget(0, ++i, new HTML("Parole Libere"));
|
||||
ft.setWidget(0, ++i, new HTML("Parole Cronologia"));
|
||||
addParole = true;
|
||||
}
|
||||
|
||||
i = 1;
|
||||
for (ConcessioneDV concessione : result.getData()) {
|
||||
int j = -1;
|
||||
|
||||
NavLink locateOnMap = new NavLink("Show");
|
||||
locateOnMap.setTitle("Locate on the Map and show details");
|
||||
locateOnMap.setIcon(IconType.MAP_MARKER);
|
||||
|
||||
locateOnMap.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
GeoNaItemRef gir = new GeoNaItemRef(concessione.getItemId(), GeoportalDataViewerConstants.RECORD_TYPE.CONCESSIONE.toString());
|
||||
appManagerBus.fireEvent(new ShowDetailsEvent(gir, null, null));
|
||||
appManagerBus.fireEvent(new ShowPopupOnCentroiEvent(concessione));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
ft.setWidget(i, ++j, locateOnMap);
|
||||
|
||||
|
||||
ft.setWidget(i, ++j, new HTML(concessione.getNome()));
|
||||
if(addIntroduction)
|
||||
ft.setWidget(i, ++j, new HTML(StringUtil.ellipsize(concessione.getIntroduzione(), 200)));
|
||||
|
||||
if(addStaff) {
|
||||
ft.setWidget(i, ++j, new HTML(toDisplayList(concessione.getAuthors())));
|
||||
ft.setWidget(i, ++j, new HTML(toDisplayList(Arrays.asList(concessione.getResponsabile()))));
|
||||
ft.setWidget(i, ++j, new HTML(toDisplayList(Arrays.asList(concessione.getEditore()))));
|
||||
ft.setWidget(i, ++j, new HTML(toDisplayList(concessione.getTitolari())));
|
||||
ft.setWidget(i, ++j, new HTML(toDisplayList(Arrays.asList(concessione.getContributore()))));
|
||||
}
|
||||
|
||||
if(addParole) {
|
||||
ft.setWidget(i, ++j, new HTML(toDisplayList(concessione.getParoleChiaveLibere())));
|
||||
ft.setWidget(i, ++j, new HTML(toDisplayList(concessione.getParoleChiaveICCD())));
|
||||
}
|
||||
|
||||
|
||||
// List<UploadedImageDV> listImg = concessione.getImmaginiRappresentative();
|
||||
// GWT.log(listImg.toString());
|
||||
// boolean imagePreviewFound = false;
|
||||
// if (listImg != null && listImg.size() > 0) {
|
||||
panelResults.add(new LoaderIcon("TODO..."));
|
||||
//TODO
|
||||
|
||||
// GeoportalDataViewerServiceAsync.Util.getInstance().getListConcessioni(0, 30, filter, false,
|
||||
// new AsyncCallback<ResultSetPaginatedData>() {
|
||||
//
|
||||
// UploadedImageDV uImg = listImg.get(0);
|
||||
//
|
||||
//
|
||||
// if (uImg != null && uImg.getListWsContent() != null
|
||||
// && uImg.getListWsContent().size() > 0) {
|
||||
// WorkspaceContentDV wsc = uImg.getListWsContent().get(0);
|
||||
// String image = "<img style=\"width:50px;height:50px;\" src='" + wsc.getLink()
|
||||
// + "' alt='" + wsc.getName() + "'>";
|
||||
// ft.setWidget(i, 2, new HTML(image));
|
||||
// imagePreviewFound = true;
|
||||
// @Override
|
||||
// public void onFailure(Throwable caught) {
|
||||
//// showLoading(false);
|
||||
//// Window.alert(caught.getMessage());
|
||||
// panelResults.clear();
|
||||
// panelResults.add(new HTML("<hr>"));
|
||||
// Alert alert = new Alert("Error on searching. Please, refresh or change the search");
|
||||
// alert.setType(AlertType.ERROR);
|
||||
// alert.setClose(false);
|
||||
// panelResults.add(alert);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onSuccess(ResultSetPaginatedData result) {
|
||||
//
|
||||
// appManagerBus.fireEvent(new SearchPerformedEvent(result.getData(),false));
|
||||
// setSearchEnabled(true);
|
||||
// latestResult = result;
|
||||
//
|
||||
// panelResults.clear();
|
||||
// panelResults.add(new HTML("<hr>"));
|
||||
//
|
||||
// if (result.getData().size() == 0) {
|
||||
// panelResults.add(new HTML("No result found"));
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// FlexTable ft = new FlexTable();
|
||||
// ft.getElement().setClassName("table-results");
|
||||
// int i = 1;
|
||||
// ft.setWidget(0, i, new HTML("Nome Progetto"));
|
||||
//
|
||||
// String selValue = listBoxSearchFor.getSelectedValue().toLowerCase();
|
||||
//
|
||||
// boolean addIntroduction = false;
|
||||
// if(selValue.startsWith("proj") || selValue.startsWith("any")) {
|
||||
// ft.setWidget(0, ++i, new HTML("Introduzione"));
|
||||
// addIntroduction = true;
|
||||
// }
|
||||
//
|
||||
// boolean addStaff = false;
|
||||
// if(selValue.startsWith("director")) {
|
||||
// ft.setWidget(0, ++i, new HTML("Autori"));
|
||||
// ft.setWidget(0, ++i, new HTML("Responsabile"));
|
||||
// ft.setWidget(0, ++i, new HTML("Editore"));
|
||||
// ft.setWidget(0, ++i, new HTML("Titolari"));
|
||||
// ft.setWidget(0, ++i, new HTML("Contributore"));
|
||||
// addStaff = true;
|
||||
// }
|
||||
// boolean addParole = false;
|
||||
// if(selValue.startsWith("keyword")) {
|
||||
// ft.setWidget(0, ++i, new HTML("Parole Libere"));
|
||||
// ft.setWidget(0, ++i, new HTML("Parole Cronologia"));
|
||||
// addParole = true;
|
||||
// }
|
||||
//
|
||||
// i = 1;
|
||||
// for (ConcessioneDV concessione : result.getData()) {
|
||||
// int j = -1;
|
||||
//
|
||||
// NavLink locateOnMap = new NavLink("Show");
|
||||
// locateOnMap.setTitle("Locate on the Map and show details");
|
||||
// locateOnMap.setIcon(IconType.MAP_MARKER);
|
||||
//
|
||||
// locateOnMap.addClickHandler(new ClickHandler() {
|
||||
//
|
||||
// @Override
|
||||
// public void onClick(ClickEvent event) {
|
||||
// GeoNaItemRef gir = new GeoNaItemRef(concessione.getItemId(), GeoportalDataViewerConstants.RECORD_TYPE.CONCESSIONE.toString());
|
||||
// appManagerBus.fireEvent(new ShowDetailsEvent(gir, null, null));
|
||||
// appManagerBus.fireEvent(new ShowPopupOnCentroiEvent(concessione));
|
||||
//
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// ft.setWidget(i, ++j, locateOnMap);
|
||||
//
|
||||
//
|
||||
// ft.setWidget(i, ++j, new HTML(concessione.getNome()));
|
||||
// if(addIntroduction)
|
||||
// ft.setWidget(i, ++j, new HTML(StringUtil.ellipsize(concessione.getIntroduzione(), 200)));
|
||||
//
|
||||
// if(addStaff) {
|
||||
// ft.setWidget(i, ++j, new HTML(toDisplayList(concessione.getAuthors())));
|
||||
// ft.setWidget(i, ++j, new HTML(toDisplayList(Arrays.asList(concessione.getResponsabile()))));
|
||||
// ft.setWidget(i, ++j, new HTML(toDisplayList(Arrays.asList(concessione.getEditore()))));
|
||||
// ft.setWidget(i, ++j, new HTML(toDisplayList(concessione.getTitolari())));
|
||||
// ft.setWidget(i, ++j, new HTML(toDisplayList(Arrays.asList(concessione.getContributore()))));
|
||||
// }
|
||||
//
|
||||
// if(addParole) {
|
||||
// ft.setWidget(i, ++j, new HTML(toDisplayList(concessione.getParoleChiaveLibere())));
|
||||
// ft.setWidget(i, ++j, new HTML(toDisplayList(concessione.getParoleChiaveICCD())));
|
||||
// }
|
||||
//
|
||||
//
|
||||
//// List<UploadedImageDV> listImg = concessione.getImmaginiRappresentative();
|
||||
//// GWT.log(listImg.toString());
|
||||
//// boolean imagePreviewFound = false;
|
||||
//// if (listImg != null && listImg.size() > 0) {
|
||||
////
|
||||
//// UploadedImageDV uImg = listImg.get(0);
|
||||
////
|
||||
//// if (uImg != null && uImg.getListWsContent() != null
|
||||
//// && uImg.getListWsContent().size() > 0) {
|
||||
//// WorkspaceContentDV wsc = uImg.getListWsContent().get(0);
|
||||
//// String image = "<img style=\"width:50px;height:50px;\" src='" + wsc.getLink()
|
||||
//// + "' alt='" + wsc.getName() + "'>";
|
||||
//// ft.setWidget(i, 2, new HTML(image));
|
||||
//// imagePreviewFound = true;
|
||||
//// }
|
||||
//// }
|
||||
////
|
||||
//// if (!imagePreviewFound) {
|
||||
//// ft.setWidget(i, 2, new Image(GNAImages.ICONS.italyIcon()));
|
||||
//// }
|
||||
//
|
||||
// i++;
|
||||
// }
|
||||
//
|
||||
// if (!imagePreviewFound) {
|
||||
// ft.setWidget(i, 2, new Image(GNAImages.ICONS.italyIcon()));
|
||||
// }
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
panelResults.add(ft);
|
||||
|
||||
}
|
||||
});
|
||||
// panelResults.add(ft);
|
||||
//
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -409,75 +383,77 @@ public class SearchFacilityUI extends Composite {
|
|||
searchConcessioni();
|
||||
}
|
||||
|
||||
/**
|
||||
* To sort filter.
|
||||
*
|
||||
* @param labelFilter the label filter
|
||||
* @return the searching filter
|
||||
*/
|
||||
public SearchingFilter toSortFilter(String labelFilter) {
|
||||
GWT.log("toSortFilter for label " + labelFilter);
|
||||
String[] array = labelFilter.split(LABEL_FILTER_SEPARATOR);
|
||||
|
||||
SearchingFilter sortFilter = null;
|
||||
try {
|
||||
ItemField recordField = null;
|
||||
for (ItemField value : sortByFields) {
|
||||
if (array[0].equalsIgnoreCase(value.getDisplayName())) {
|
||||
recordField = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ORDER orderField = ORDER.valueOf(array[1]);
|
||||
sortFilter = new SearchingFilter(Arrays.asList(recordField), orderField);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
GWT.log("toSortFilter Got " + sortFilter);
|
||||
return sortFilter;
|
||||
|
||||
}
|
||||
// /**
|
||||
// * To sort filter.
|
||||
// *
|
||||
// * @param labelFilter the label filter
|
||||
// * @return the searching filter
|
||||
// */
|
||||
// public SearchingFilter toSortFilter(String labelFilter) {
|
||||
// GWT.log("toSortFilter for label " + labelFilter);
|
||||
// String[] array = labelFilter.split(LABEL_FILTER_SEPARATOR);
|
||||
//
|
||||
// SearchingFilter sortFilter = null;
|
||||
// try {
|
||||
// ItemField recordField = null;
|
||||
// for (ItemField value : sortByFields) {
|
||||
// if (array[0].equalsIgnoreCase(value.getDisplayName())) {
|
||||
// recordField = value;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// ORDER orderField = ORDER.valueOf(array[1]);
|
||||
// sortFilter = new SearchingFilter(Arrays.asList(recordField), orderField);
|
||||
// } catch (Exception e) {
|
||||
//
|
||||
// }
|
||||
// GWT.log("toSortFilter Got " + sortFilter);
|
||||
// return sortFilter;
|
||||
//
|
||||
// }
|
||||
|
||||
/**
|
||||
* Built searching filter.
|
||||
*
|
||||
* @return the searching filter
|
||||
*/
|
||||
private SearchingFilter builtSearchingFilter() {
|
||||
SearchingFilter searchingFilter = toSortFilter(listBoxSortBy.getSelectedValue());
|
||||
String searchText = searchField.getText();
|
||||
if (searchText != null && !searchText.isEmpty()) {
|
||||
Map<String, Object> searchInto = new HashMap<String, Object>();
|
||||
|
||||
List<String> listOfSeachingFields = new ArrayList<String>();
|
||||
|
||||
for (ItemField recordField : searchForFields) {
|
||||
if (recordField.getDisplayName().equals(listBoxSearchFor.getSelectedValue())) {
|
||||
listOfSeachingFields = recordField.getJsonFields();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if(listOfSeachingFields.size()==0) {
|
||||
listOfSeachingFields.add("nome");
|
||||
}
|
||||
for (String fieldname : listOfSeachingFields) {
|
||||
searchInto.put(fieldname, searchText);
|
||||
}
|
||||
|
||||
WhereClause where = new WhereClause();
|
||||
where.setSearchInto(searchInto);
|
||||
where.setOperator(LOGICAL_OP.OR);
|
||||
|
||||
//THIS CLAUSE IS ADDED IN ORDER TO SEARCH ONLY PUBLISHED PRODUCT (WITH SUCCESS)
|
||||
Map<String, Object> searchInto2 = new HashMap<String, Object>();
|
||||
searchInto2.put("report.status", "PASSED");
|
||||
WhereClause where2 = new WhereClause(LOGICAL_OP.AND, searchInto2);
|
||||
|
||||
searchingFilter.setConditions(Arrays.asList(where, where2));
|
||||
}
|
||||
return searchingFilter;
|
||||
}
|
||||
//TODO
|
||||
|
||||
// private SearchingFilter builtSearchingFilter() {
|
||||
// SearchingFilter searchingFilter = toSortFilter(listBoxSortBy.getSelectedValue());
|
||||
// String searchText = searchField.getText();
|
||||
// if (searchText != null && !searchText.isEmpty()) {
|
||||
// Map<String, Object> searchInto = new HashMap<String, Object>();
|
||||
//
|
||||
// List<String> listOfSeachingFields = new ArrayList<String>();
|
||||
//
|
||||
// for (ItemField recordField : searchForFields) {
|
||||
// if (recordField.getDisplayName().equals(listBoxSearchFor.getSelectedValue())) {
|
||||
// listOfSeachingFields = recordField.getJsonFields();
|
||||
// continue;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if(listOfSeachingFields.size()==0) {
|
||||
// listOfSeachingFields.add("nome");
|
||||
// }
|
||||
// for (String fieldname : listOfSeachingFields) {
|
||||
// searchInto.put(fieldname, searchText);
|
||||
// }
|
||||
//
|
||||
// WhereClause where = new WhereClause();
|
||||
// where.setSearchInto(searchInto);
|
||||
// where.setOperator(LOGICAL_OP.OR);
|
||||
//
|
||||
// //THIS CLAUSE IS ADDED IN ORDER TO SEARCH ONLY PUBLISHED PRODUCT (WITH SUCCESS)
|
||||
// Map<String, Object> searchInto2 = new HashMap<String, Object>();
|
||||
// searchInto2.put("report.status", "PASSED");
|
||||
// WhereClause where2 = new WhereClause(LOGICAL_OP.AND, searchInto2);
|
||||
//
|
||||
// searchingFilter.setConditions(Arrays.asList(where, where2));
|
||||
// }
|
||||
// return searchingFilter;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Gets the current sort filter.
|
||||
|
@ -485,7 +461,9 @@ public class SearchFacilityUI extends Composite {
|
|||
* @return the current sort filter
|
||||
*/
|
||||
public SearchingFilter getCurrentSortFilter() {
|
||||
currentSortFilter = builtSearchingFilter();
|
||||
|
||||
//TODO
|
||||
//currentSortFilter = builtSearchingFilter();
|
||||
GWT.log("currentSortFilter: " + currentSortFilter);
|
||||
return currentSortFilter;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.client.util;
|
||||
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.faults.ControlledError;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
|
||||
public abstract class ControlledCallBack<T> implements AsyncCallback<T> {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
before();
|
||||
if(caught instanceof ControlledError) {
|
||||
GWT.log("Controlled error "+caught);
|
||||
Window.alert(caught.getMessage());
|
||||
}else {
|
||||
GWT.log("Uncontrolled failure, check server log.", caught);
|
||||
Window.alert("Sorry, an unexpected error occurred. Please, contact the support");
|
||||
}
|
||||
after();
|
||||
}
|
||||
|
||||
public void before() {}
|
||||
|
||||
public void after() {}
|
||||
|
||||
@Override
|
||||
public void onSuccess(T result) {
|
||||
before();
|
||||
after();
|
||||
}
|
||||
}
|
|
@ -12,38 +12,29 @@ import java.util.Map;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.gcube.application.geoportal.client.utils.Serialization;
|
||||
import org.gcube.application.geoportal.common.model.legacy.Concessione;
|
||||
import org.gcube.application.geoportal.common.model.legacy.LayerConcessione;
|
||||
import org.gcube.application.geoportal.common.model.legacy.UploadedImage;
|
||||
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
|
||||
import org.gcube.application.geoportal.common.rest.UseCaseDescriptorsI;
|
||||
import org.gcube.application.geoportalcommon.ConvertToDataValueObjectModel;
|
||||
import org.gcube.application.geoportalcommon.ConvertToDataViewModel;
|
||||
import org.gcube.application.geoportalcommon.GeoportalCommon;
|
||||
import org.gcube.application.geoportalcommon.MongoServiceCommon;
|
||||
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
|
||||
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
|
||||
import org.gcube.application.geoportalcommon.shared.ItemField;
|
||||
import org.gcube.application.geoportalcommon.shared.LayerItem;
|
||||
import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData;
|
||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.UseCaseDescriptorDV;
|
||||
import org.gcube.application.geoportalcommon.shared.gis.BoundsMap;
|
||||
import org.gcube.application.geoportalcommon.shared.products.BaseConcessioneDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.model.AbstractRelazioneScavoDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.model.RelazioneScavoDV;
|
||||
import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV;
|
||||
import org.gcube.application.geoportalcommon.util.URLParserUtil;
|
||||
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.mongoservice.ConcessioniMongoServiceIdentityProxy;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accesspolicy.GeoNACheckAccessPolicy;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.server.util.ContextRequest;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.server.util.SessionUtil;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.GCubeCollection;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.cl.ucd.UCD;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.ViewerConfiguration;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.faults.ControlledError;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.FeatureRow;
|
||||
|
@ -85,7 +76,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
|||
*/
|
||||
private GNADataViewerConfigProfile getGNADataVieweConfigProfile() throws Exception {
|
||||
LOG.info("METHOD getDataResult called");
|
||||
|
||||
|
||||
GNADataViewerConfigProfile profile = SessionUtil.getGNADataViewerConfigProfile(getThreadLocalRequest());
|
||||
if (profile == null) {
|
||||
LOG.info(GNADataViewerConfigProfile.class.getSimpleName() + " is null, loading configurations from IS");
|
||||
|
@ -149,7 +140,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
|||
// MAP ZAXIS INTO GWT-SERIALIZABLE OBJECT
|
||||
ZAxis zAxis = layerZAxis != null
|
||||
? new ZAxis(layerZAxis.getUnits(), layerZAxis.isPositive(), layerZAxis.getValues())
|
||||
: null;
|
||||
: null;
|
||||
|
||||
return new GeoInformationForWMSRequest(wmsServiceHost, validWMSRequest, layerName, versionWms, crs,
|
||||
mapWmsNotStandard, styles, styles.isNcWms(), zAxis);
|
||||
|
@ -206,7 +197,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
|||
}
|
||||
geoDAO.setSourceLayerObject(layerObject);
|
||||
LOG.info("For layer name: " + layerObject.getLayerItem().getName() + " got " + features.size()
|
||||
+ " feature/s");
|
||||
+ " feature/s");
|
||||
listDAO.add(geoDAO);
|
||||
}
|
||||
LOG.info("returning " + listDAO + " geona data objects");
|
||||
|
@ -230,201 +221,201 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
|||
return getUploadedImagesForId(this.getThreadLocalRequest(), itemType, itemId, maxImages);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the layers for id.
|
||||
*
|
||||
* @param itemType the item type
|
||||
* @param itemId the item id
|
||||
* @return the layers for id
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Override
|
||||
public List<LayerConcessioneDV> getLayersForId(String itemType, String itemId) throws Exception {
|
||||
LOG.info("getLayersForId [itemId: " + itemId + ", itemType: " + itemType + "] called");
|
||||
// /**
|
||||
// * Gets the layers for id.
|
||||
// *
|
||||
// * @param itemType the item type
|
||||
// * @param itemId the item id
|
||||
// * @return the layers for id
|
||||
// * @throws Exception the exception
|
||||
// */
|
||||
// @Override
|
||||
// public List<LayerConcessioneDV> getLayersForId(String itemType, String itemId) throws Exception {
|
||||
// LOG.info("getLayersForId [itemId: " + itemId + ", itemType: " + itemType + "] called");
|
||||
//
|
||||
// if (itemType == null)
|
||||
// throw new Exception("Invalid parameter. The itemType is null");
|
||||
//
|
||||
// if (itemId == null)
|
||||
// throw new Exception("Invalid parameter. The itemId is null");
|
||||
//
|
||||
// List<LayerConcessioneDV> listLayers = null;
|
||||
//
|
||||
// try {
|
||||
//
|
||||
// SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
|
||||
// String userName = null;
|
||||
// try {
|
||||
// userName = SessionUtil.getCurrentUser(this.getThreadLocalRequest()).getUsername();
|
||||
// } catch (Exception e) {
|
||||
// LOG.info("User not found in session, the userName for cecking policy will be null");
|
||||
// }
|
||||
//
|
||||
// if (itemType.equalsIgnoreCase("concessione")) {
|
||||
//
|
||||
// LOG.info("Trying to get concessione for id " + itemId);
|
||||
// ConcessioniMongoServiceIdentityProxy cms = new ConcessioniMongoServiceIdentityProxy(
|
||||
// this.getThreadLocalRequest());
|
||||
// Concessione concessione = cms.getItemById(itemId);
|
||||
//
|
||||
// BaseConcessioneDV baseConcessione = ConvertToDataViewModel.toBaseConcessione(concessione);
|
||||
// if (concessione != null) {
|
||||
// LOG.info("For id " + itemId + ", got concessione " + concessione.getNome() + " from service");
|
||||
// listLayers = new ArrayList<LayerConcessioneDV>();
|
||||
// if (concessione.getPianteFineScavo() != null) {
|
||||
//
|
||||
// for (LayerConcessione lc : concessione.getPianteFineScavo()) {
|
||||
// if (GeoNACheckAccessPolicy.isAccessible(lc.getPolicy().name(), userName)) {
|
||||
// listLayers.add(ConvertToDataViewModel.toLayerConcessione(lc, baseConcessione));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// LayerConcessione lcPosizionamento = concessione.getPosizionamentoScavo();
|
||||
//
|
||||
// if (lcPosizionamento != null) {
|
||||
//
|
||||
// if (GeoNACheckAccessPolicy.isAccessible(lcPosizionamento.getPolicy().name(), userName)) {
|
||||
//
|
||||
// LayerConcessioneDV thePosizScavo = ConvertToDataViewModel
|
||||
// .toLayerConcessione(lcPosizionamento, baseConcessione);
|
||||
// if (thePosizScavo != null)
|
||||
// listLayers.add(thePosizScavo);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// } else
|
||||
// throw new Exception("Concessione with id '" + itemId + "' not available");
|
||||
// }
|
||||
// LOG.info("For id " + itemId + ", returning " + listLayers.size() + " layer/s");
|
||||
// return listLayers;
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// String erroMsg = "Layers are not available for " + Concessione.class.getSimpleName() + " with id " + itemId;
|
||||
// LOG.error(erroMsg, e);
|
||||
// throw new Exception(erroMsg);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
if (itemType == null)
|
||||
throw new Exception("Invalid parameter. The itemType is null");
|
||||
|
||||
if (itemId == null)
|
||||
throw new Exception("Invalid parameter. The itemId is null");
|
||||
|
||||
List<LayerConcessioneDV> listLayers = null;
|
||||
|
||||
try {
|
||||
|
||||
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
|
||||
String userName = null;
|
||||
try {
|
||||
userName = SessionUtil.getCurrentUser(this.getThreadLocalRequest()).getUsername();
|
||||
} catch (Exception e) {
|
||||
LOG.info("User not found in session, the userName for cecking policy will be null");
|
||||
}
|
||||
|
||||
if (itemType.equalsIgnoreCase("concessione")) {
|
||||
|
||||
LOG.info("Trying to get concessione for id " + itemId);
|
||||
ConcessioniMongoServiceIdentityProxy cms = new ConcessioniMongoServiceIdentityProxy(
|
||||
this.getThreadLocalRequest());
|
||||
Concessione concessione = cms.getItemById(itemId);
|
||||
|
||||
BaseConcessioneDV baseConcessione = ConvertToDataViewModel.toBaseConcessione(concessione);
|
||||
if (concessione != null) {
|
||||
LOG.info("For id " + itemId + ", got concessione " + concessione.getNome() + " from service");
|
||||
listLayers = new ArrayList<LayerConcessioneDV>();
|
||||
if (concessione.getPianteFineScavo() != null) {
|
||||
|
||||
for (LayerConcessione lc : concessione.getPianteFineScavo()) {
|
||||
if (GeoNACheckAccessPolicy.isAccessible(lc.getPolicy().name(), userName)) {
|
||||
listLayers.add(ConvertToDataViewModel.toLayerConcessione(lc, baseConcessione));
|
||||
}
|
||||
}
|
||||
|
||||
LayerConcessione lcPosizionamento = concessione.getPosizionamentoScavo();
|
||||
|
||||
if (lcPosizionamento != null) {
|
||||
|
||||
if (GeoNACheckAccessPolicy.isAccessible(lcPosizionamento.getPolicy().name(), userName)) {
|
||||
|
||||
LayerConcessioneDV thePosizScavo = ConvertToDataViewModel
|
||||
.toLayerConcessione(lcPosizionamento, baseConcessione);
|
||||
if (thePosizScavo != null)
|
||||
listLayers.add(thePosizScavo);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else
|
||||
throw new Exception("Concessione with id '" + itemId + "' not available");
|
||||
}
|
||||
LOG.info("For id " + itemId + ", returning " + listLayers.size() + " layer/s");
|
||||
return listLayers;
|
||||
|
||||
} catch (Exception e) {
|
||||
String erroMsg = "Layers are not available for " + Concessione.class.getSimpleName() + " with id " + itemId;
|
||||
LOG.error(erroMsg, e);
|
||||
throw new Exception(erroMsg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the concessione for id.
|
||||
*
|
||||
* @param mongoId the mongo id
|
||||
* @return the concessione for id
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Override
|
||||
public ConcessioneDV getConcessioneForId(String mongoId) throws Exception {
|
||||
LOG.info("getConcessioneForId " + mongoId + " called");
|
||||
|
||||
ConcessioneDV concessionDV = null;
|
||||
|
||||
if (mongoId == null)
|
||||
throw new Exception("Invalid parameter. The itemId is null");
|
||||
|
||||
try {
|
||||
LOG.info("Trying to get record for id " + mongoId);
|
||||
|
||||
ConcessioniMongoServiceIdentityProxy cms = new ConcessioniMongoServiceIdentityProxy(
|
||||
this.getThreadLocalRequest());
|
||||
Concessione concessione = cms.getItemById(mongoId);
|
||||
|
||||
LOG.info("Got concessione for mongoId: " + mongoId);
|
||||
if (concessione != null) {
|
||||
concessionDV = ConvertToDataViewModel.toConcessione(concessione);
|
||||
|
||||
String userName = null;
|
||||
try {
|
||||
userName = SessionUtil.getCurrentUser(this.getThreadLocalRequest()).getUsername();
|
||||
|
||||
} catch (Exception e) {
|
||||
LOG.info("User not found in session, so going to apply the acess policies");
|
||||
}
|
||||
|
||||
// TODO THIS IS A WORKAROUND WAITING FOR ADOPTING OF USER ROLES. AT THE MOMENT,
|
||||
// A USER AUTHENTICATED CAN ACCESS EVERYTHING
|
||||
// I CAN CHECK THE ACCCESS POLICIES IF AND ONLY IF THE USER IS NOT LOGGED IN.
|
||||
if (userName == null) {
|
||||
|
||||
// CHECKING ACCESS POLICY
|
||||
LOG.info("Applying access policies for concessione " + mongoId + " returned by service");
|
||||
LayerConcessioneDV layerPosizionamento = concessionDV.getPosizionamentoScavo();
|
||||
if (layerPosizionamento != null) {
|
||||
if (!GeoNACheckAccessPolicy.isAccessible(layerPosizionamento.getPolicy(), userName)) {
|
||||
concessionDV.setPosizionamentoScavo(null);
|
||||
LOG.info("Posizionamento di Scavo is not accessible by current user: " + userName);
|
||||
}
|
||||
}
|
||||
|
||||
List<LayerConcessioneDV> listLayersDV = concessionDV.getPianteFineScavo();
|
||||
if (listLayersDV != null) {
|
||||
List<LayerConcessioneDV> accessibleListLayersDV = new ArrayList<LayerConcessioneDV>();
|
||||
for (LayerConcessioneDV layerDV : listLayersDV) {
|
||||
if (GeoNACheckAccessPolicy.isAccessible(layerDV.getPolicy(), userName)) {
|
||||
accessibleListLayersDV.add(layerDV);
|
||||
} else {
|
||||
LOG.info("(Pianta) Layer " + layerDV.getLayerName()
|
||||
+ " is not accessible by current user: " + userName);
|
||||
}
|
||||
}
|
||||
concessionDV.setPianteFineScavo(accessibleListLayersDV);
|
||||
}
|
||||
|
||||
AbstractRelazioneScavoDV abstractRS = concessionDV.getAbstractRelazioneScavo();
|
||||
if (abstractRS != null) {
|
||||
if (!GeoNACheckAccessPolicy.isAccessible(abstractRS.getPolicy(), userName)) {
|
||||
concessionDV.setAbstractRelazioneScavo(null);
|
||||
LOG.info("Abstract relazione is not accessible by current user: " + userName);
|
||||
}
|
||||
}
|
||||
|
||||
RelazioneScavoDV relazioneScavo = concessionDV.getRelazioneScavo();
|
||||
if (relazioneScavo != null) {
|
||||
if (!GeoNACheckAccessPolicy.isAccessible(relazioneScavo.getPolicy(), userName)) {
|
||||
concessionDV.setRelazioneScavo(null);
|
||||
LOG.info("Relazione scavo is not accessible by current user: " + userName);
|
||||
}
|
||||
}
|
||||
|
||||
List<UploadedImageDV> immagini = concessionDV.getImmaginiRappresentative();
|
||||
if (immagini != null && immagini.size() > 0) {
|
||||
List<UploadedImageDV> accessibleListImages = new ArrayList<UploadedImageDV>();
|
||||
|
||||
// SHOWING ACESSIBLE IMAGES
|
||||
for (UploadedImageDV uploadedImageDV : immagini) {
|
||||
|
||||
if (GeoNACheckAccessPolicy.isAccessible(uploadedImageDV.getPolicy(), userName)) {
|
||||
accessibleListImages.add(uploadedImageDV);
|
||||
} else {
|
||||
LOG.info("Immagine " + uploadedImageDV.getTitolo()
|
||||
+ " is not accessible by current user: " + userName);
|
||||
}
|
||||
|
||||
}
|
||||
concessionDV.setImmaginiRappresentative(accessibleListImages);
|
||||
|
||||
}
|
||||
|
||||
// END CHECKING ACCESS POLICY
|
||||
LOG.info("Access policies applied");
|
||||
}
|
||||
}
|
||||
|
||||
if (concessionDV == null)
|
||||
throw new Exception("Concessione with id '" + mongoId + "' not available");
|
||||
|
||||
LOG.debug("For id " + mongoId + " returning " + ConcessioneDV.class.getSimpleName() + ": " + concessionDV);
|
||||
return concessionDV;
|
||||
|
||||
} catch (Exception e) {
|
||||
String erroMsg = Concessione.class.getSimpleName() + " with id '" + mongoId + "' not available";
|
||||
LOG.error(erroMsg, e);
|
||||
throw new Exception(erroMsg);
|
||||
}
|
||||
|
||||
}
|
||||
// /**
|
||||
// * Gets the concessione for id.
|
||||
// *
|
||||
// * @param mongoId the mongo id
|
||||
// * @return the concessione for id
|
||||
// * @throws Exception the exception
|
||||
// */
|
||||
// @Override
|
||||
// public ConcessioneDV getConcessioneForId(String mongoId) throws Exception {
|
||||
// LOG.info("getConcessioneForId " + mongoId + " called");
|
||||
//
|
||||
// ConcessioneDV concessionDV = null;
|
||||
//
|
||||
// if (mongoId == null)
|
||||
// throw new Exception("Invalid parameter. The itemId is null");
|
||||
//
|
||||
// try {
|
||||
// LOG.info("Trying to get record for id " + mongoId);
|
||||
//
|
||||
// ConcessioniMongoServiceIdentityProxy cms = new ConcessioniMongoServiceIdentityProxy(
|
||||
// this.getThreadLocalRequest());
|
||||
// Concessione concessione = cms.getItemById(mongoId);
|
||||
//
|
||||
// LOG.info("Got concessione for mongoId: " + mongoId);
|
||||
// if (concessione != null) {
|
||||
// concessionDV = ConvertToDataViewModel.toConcessione(concessione);
|
||||
//
|
||||
// String userName = null;
|
||||
// try {
|
||||
// userName = SessionUtil.getCurrentUser(this.getThreadLocalRequest()).getUsername();
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// LOG.info("User not found in session, so going to apply the acess policies");
|
||||
// }
|
||||
//
|
||||
// // TODO THIS IS A WORKAROUND WAITING FOR ADOPTING OF USER ROLES. AT THE MOMENT,
|
||||
// // A USER AUTHENTICATED CAN ACCESS EVERYTHING
|
||||
// // I CAN CHECK THE ACCCESS POLICIES IF AND ONLY IF THE USER IS NOT LOGGED IN.
|
||||
// if (userName == null) {
|
||||
//
|
||||
// // CHECKING ACCESS POLICY
|
||||
// LOG.info("Applying access policies for concessione " + mongoId + " returned by service");
|
||||
// LayerConcessioneDV layerPosizionamento = concessionDV.getPosizionamentoScavo();
|
||||
// if (layerPosizionamento != null) {
|
||||
// if (!GeoNACheckAccessPolicy.isAccessible(layerPosizionamento.getPolicy(), userName)) {
|
||||
// concessionDV.setPosizionamentoScavo(null);
|
||||
// LOG.info("Posizionamento di Scavo is not accessible by current user: " + userName);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// List<LayerConcessioneDV> listLayersDV = concessionDV.getPianteFineScavo();
|
||||
// if (listLayersDV != null) {
|
||||
// List<LayerConcessioneDV> accessibleListLayersDV = new ArrayList<LayerConcessioneDV>();
|
||||
// for (LayerConcessioneDV layerDV : listLayersDV) {
|
||||
// if (GeoNACheckAccessPolicy.isAccessible(layerDV.getPolicy(), userName)) {
|
||||
// accessibleListLayersDV.add(layerDV);
|
||||
// } else {
|
||||
// LOG.info("(Pianta) Layer " + layerDV.getLayerName()
|
||||
// + " is not accessible by current user: " + userName);
|
||||
// }
|
||||
// }
|
||||
// concessionDV.setPianteFineScavo(accessibleListLayersDV);
|
||||
// }
|
||||
//
|
||||
// AbstractRelazioneScavoDV abstractRS = concessionDV.getAbstractRelazioneScavo();
|
||||
// if (abstractRS != null) {
|
||||
// if (!GeoNACheckAccessPolicy.isAccessible(abstractRS.getPolicy(), userName)) {
|
||||
// concessionDV.setAbstractRelazioneScavo(null);
|
||||
// LOG.info("Abstract relazione is not accessible by current user: " + userName);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// RelazioneScavoDV relazioneScavo = concessionDV.getRelazioneScavo();
|
||||
// if (relazioneScavo != null) {
|
||||
// if (!GeoNACheckAccessPolicy.isAccessible(relazioneScavo.getPolicy(), userName)) {
|
||||
// concessionDV.setRelazioneScavo(null);
|
||||
// LOG.info("Relazione scavo is not accessible by current user: " + userName);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// List<UploadedImageDV> immagini = concessionDV.getImmaginiRappresentative();
|
||||
// if (immagini != null && immagini.size() > 0) {
|
||||
// List<UploadedImageDV> accessibleListImages = new ArrayList<UploadedImageDV>();
|
||||
//
|
||||
// // SHOWING ACESSIBLE IMAGES
|
||||
// for (UploadedImageDV uploadedImageDV : immagini) {
|
||||
//
|
||||
// if (GeoNACheckAccessPolicy.isAccessible(uploadedImageDV.getPolicy(), userName)) {
|
||||
// accessibleListImages.add(uploadedImageDV);
|
||||
// } else {
|
||||
// LOG.info("Immagine " + uploadedImageDV.getTitolo()
|
||||
// + " is not accessible by current user: " + userName);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// concessionDV.setImmaginiRappresentative(accessibleListImages);
|
||||
//
|
||||
// }
|
||||
//
|
||||
// // END CHECKING ACCESS POLICY
|
||||
// LOG.info("Access policies applied");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (concessionDV == null)
|
||||
// throw new Exception("Concessione with id '" + mongoId + "' not available");
|
||||
//
|
||||
// LOG.debug("For id " + mongoId + " returning " + ConcessioneDV.class.getSimpleName() + ": " + concessionDV);
|
||||
// return concessionDV;
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// String erroMsg = Concessione.class.getSimpleName() + " with id '" + mongoId + "' not available";
|
||||
// LOG.error(erroMsg, e);
|
||||
// throw new Exception(erroMsg);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
/**
|
||||
* Gets the parameters from URL.
|
||||
|
@ -436,8 +427,8 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
|||
|
||||
public Map<String, String> getParametersFromURL(String theURL, List<String> parameters) {
|
||||
LOG.info("METHOD getPAramsFromURL");
|
||||
|
||||
|
||||
|
||||
|
||||
if (theURL == null)
|
||||
return null;
|
||||
|
||||
|
@ -592,7 +583,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
|||
geoDAO.setFeatures(features);
|
||||
geoDAO.setSourceLayerObject(layerObject);
|
||||
LOG.info("For layer name: " + layerObject.getLayerItem().getName() + " got " + features.size()
|
||||
+ " feature/s");
|
||||
+ " feature/s");
|
||||
listDAO.add(geoDAO);
|
||||
}
|
||||
LOG.info("returning " + listDAO + " geona data objects");
|
||||
|
@ -704,93 +695,111 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list base layers.
|
||||
*
|
||||
* @return the list base layers
|
||||
*/
|
||||
@Override
|
||||
public List<BaseMapLayer> getListBaseLayers() {
|
||||
LOG.info("getListBaseLayers called");
|
||||
List<BaseMapLayer> listBL = new ArrayList<BaseMapLayer>();
|
||||
// Setting scope in the current thread
|
||||
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
|
||||
listBL = SessionUtil.getGNABaseMaps(this.getThreadLocalRequest());
|
||||
LOG.info("getListBaseLayers returning " + listBL.size() + " base maps");
|
||||
return listBL;
|
||||
|
||||
}
|
||||
|
||||
// TODO THIS PART REQUIRES THE JSON MAPPING based on keys read from gCube Meta
|
||||
|
||||
/**
|
||||
* List of fields for searching.
|
||||
*
|
||||
* @return the list
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Override
|
||||
public List<ItemField> listOfFieldsForSearching() throws Exception {
|
||||
LOG.info("listOfFieldsForSearching called");
|
||||
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
|
||||
GNADataViewerConfigProfile profile = getGNADataVieweConfigProfile();
|
||||
return profile.getListItemFields();
|
||||
}
|
||||
// /**
|
||||
// * List of fields for searching.
|
||||
// *
|
||||
// * @return the list
|
||||
// * @throws Exception the exception
|
||||
// */
|
||||
// @Override
|
||||
// public List<ItemField> listOfFieldsForSearching() throws Exception {
|
||||
// LOG.info("listOfFieldsForSearching called");
|
||||
// SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
|
||||
// GNADataViewerConfigProfile profile = getGNADataVieweConfigProfile();
|
||||
// return profile.getListItemFields();
|
||||
// }
|
||||
|
||||
/**
|
||||
* Gets the list concessioni.
|
||||
*
|
||||
* @param start the start
|
||||
* @param limit the limit
|
||||
* @param filter the filter
|
||||
* @param reloadFromService the reload from service
|
||||
* @return the list concessioni
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Override
|
||||
public ResultSetPaginatedData getListConcessioni(Integer start, Integer limit, SearchingFilter filter,
|
||||
boolean reloadFromService) throws Exception {
|
||||
LOG.info("getListConcessioni called wit start: " + start + ", limit: " + limit + ", filter: " + filter);
|
||||
// /**
|
||||
// * Gets the list concessioni.
|
||||
// *
|
||||
// * @param start the start
|
||||
// * @param limit the limit
|
||||
// * @param filter the filter
|
||||
// * @param reloadFromService the reload from service
|
||||
// * @return the list concessioni
|
||||
// * @throws Exception the exception
|
||||
// */
|
||||
// @Override
|
||||
// public ResultSetPaginatedData getListConcessioni(Integer start, Integer limit, SearchingFilter filter,
|
||||
// boolean reloadFromService) throws Exception {
|
||||
// LOG.info("getListConcessioni called wit start: " + start + ", limit: " + limit + ", filter: " + filter);
|
||||
//
|
||||
// try {
|
||||
// // setting identity as D4S User or KC client
|
||||
// new ConcessioniMongoServiceIdentityProxy(this.getThreadLocalRequest());
|
||||
// SessionUtil.getCurrentContext(getThreadLocalRequest(), true);
|
||||
// MongoServiceCommon serviceCommon = new MongoServiceCommon();
|
||||
// // TODO MUST BE REPLACED BY COUNT
|
||||
// List<Concessione> listOfConcessioni = SessionUtil.getListOfConcessioni(getThreadLocalRequest(),
|
||||
// reloadFromService);
|
||||
// int listConcessioniSize = listOfConcessioni.size();
|
||||
//
|
||||
// ResultSetPaginatedData searchedData = serviceCommon.queryOnMongo(listConcessioniSize, start, limit, filter,
|
||||
// "concessione");
|
||||
// return searchedData;
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// LOG.error("Error on loading paginated and filtered list of concessioni: ", e);
|
||||
// throw new Exception("Error occurred on loading list of Concessioni. Error: " + e.getMessage());
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
try {
|
||||
// setting identity as D4S User or KC client
|
||||
new ConcessioniMongoServiceIdentityProxy(this.getThreadLocalRequest());
|
||||
SessionUtil.getCurrentContext(getThreadLocalRequest(), true);
|
||||
MongoServiceCommon serviceCommon = new MongoServiceCommon();
|
||||
// TODO MUST BE REPLACED BY COUNT
|
||||
List<Concessione> listOfConcessioni = SessionUtil.getListOfConcessioni(getThreadLocalRequest(),
|
||||
reloadFromService);
|
||||
int listConcessioniSize = listOfConcessioni.size();
|
||||
|
||||
ResultSetPaginatedData searchedData = serviceCommon.queryOnMongo(listConcessioniSize, start, limit, filter,
|
||||
"concessione");
|
||||
return searchedData;
|
||||
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error on loading paginated and filtered list of concessioni: ", e);
|
||||
throw new Exception("Error occurred on loading list of Concessioni. Error: " + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ************************************** COLLECTIONS
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<GCubeCollection> getAvailableCollections() throws Exception {
|
||||
ArrayList<GCubeCollection> toReturn= new ArrayList<GCubeCollection>();
|
||||
public ViewerConfiguration getInitialConfiguration(Map<String,List<String>> parameters) throws Exception {
|
||||
LOG.debug("Received Initial configuration request with params "+parameters);
|
||||
|
||||
UseCaseDescriptorsI client = useCaseDescriptors().build();
|
||||
client.query(new QueryRequest()).forEachRemaining(u->{
|
||||
UCD ucd = Serialization.convert(u, UCD.class);
|
||||
|
||||
GCubeCollection coll=new GCubeCollection();
|
||||
coll.setUcd(ucd);
|
||||
|
||||
toReturn.add(coll);
|
||||
});
|
||||
return toReturn;
|
||||
return new ContextRequest<ViewerConfiguration>(this.getThreadLocalRequest()) {
|
||||
@Override
|
||||
protected ViewerConfiguration run() throws Exception, ControlledError {
|
||||
try {
|
||||
final ViewerConfiguration config = new ViewerConfiguration();
|
||||
LOG.info("Getting initial configuration ");
|
||||
LOG.debug("Loading base layers..");
|
||||
List<BaseMapLayer> listBL= SessionUtil.getGNABaseMaps(request);
|
||||
|
||||
LOG.debug("getListBaseLayers returning " + listBL.size() + " base maps");
|
||||
config.setBaseLayers(listBL);
|
||||
|
||||
|
||||
LOG.debug("Loading available collections.. ");
|
||||
config.setAvailableCollections(new ArrayList<GCubeCollection>());
|
||||
|
||||
useCaseDescriptors().build().query(new QueryRequest()).forEachRemaining(u->{
|
||||
try{
|
||||
UseCaseDescriptorDV ucd = ConvertToDataValueObjectModel.toUseCaseDescriptorDV(u, null);
|
||||
GCubeCollection coll=new GCubeCollection();
|
||||
coll.setUcd(ucd);
|
||||
config.getAvailableCollections().add(coll);
|
||||
|
||||
|
||||
|
||||
}catch(Throwable t) {
|
||||
LOG.warn("Invalid UCD, can't translate to DV. UCID : "+u.getId(),t);
|
||||
}
|
||||
});
|
||||
// TODO load initial layers from query parameters
|
||||
LOG.debug("Found "+config.getAvailableCollections().size()+" collections");
|
||||
|
||||
return config;
|
||||
}catch(Throwable t) {
|
||||
LOG.error("Unexpected exception while loading initial config",t);
|
||||
throw new ControlledError("Unable to configure viewer. Please retry in a few minutes.");
|
||||
}
|
||||
}
|
||||
|
||||
}.execute().getResult();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.server.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.faults.ControlledError;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
|
||||
|
||||
public abstract class ContextRequest<T> {
|
||||
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ContextRequest.class);
|
||||
|
||||
private static List<Runnable> preoperations=new ArrayList<>();
|
||||
|
||||
public static void addPreoperation(Runnable preoperation){
|
||||
preoperations.add(preoperation);
|
||||
}
|
||||
|
||||
|
||||
protected HttpServletRequest request;
|
||||
private T result=null;
|
||||
|
||||
|
||||
|
||||
public ContextRequest(HttpServletRequest httpRequest) {
|
||||
this.request=httpRequest;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public ContextRequest<T> execute() throws Exception,ControlledError{
|
||||
try {
|
||||
if (!preoperations.isEmpty()) {
|
||||
LOG.trace("Running preops (size : {} )", preoperations.size());
|
||||
for (Runnable r : preoperations)
|
||||
r.run();
|
||||
}
|
||||
|
||||
LOG.debug("Context is "+SessionUtil.getCurrentContext(request, true));
|
||||
LOG.debug("Context is "+SessionUtil.getCurrentToken(request, true)==null?null:"***");
|
||||
LOG.trace("Executing actual method..");
|
||||
result = run();
|
||||
return this;
|
||||
}catch(ControlledError e) {
|
||||
throw e;
|
||||
}catch(Throwable t) {
|
||||
LOG.error("Unexpected error ",t);
|
||||
throw new Exception("Unexpected error contacting the infrastructure", t);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public T getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
protected abstract T run() throws Exception,ControlledError;
|
||||
}
|
||||
|
||||
|
|
@ -3,16 +3,11 @@
|
|||
*/
|
||||
package org.gcube.portlets.user.geoportaldataviewer.server.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.gcube.application.geoportal.common.model.legacy.Concessione;
|
||||
import org.gcube.application.geoportal.common.rest.MongoConcessioni;
|
||||
import org.gcube.application.geoportalcommon.MongoServiceCommon;
|
||||
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.portal.PortalContext;
|
||||
|
@ -214,39 +209,39 @@ public class SessionUtil {
|
|||
* @return the list of concessioni
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public static List<Concessione> getListOfConcessioni(HttpServletRequest httpServletRequest,
|
||||
boolean reloadFromService) throws Exception {
|
||||
HttpSession session = httpServletRequest.getSession();
|
||||
List<Concessione> listOfConcessioni = (List<Concessione>) session.getAttribute(LIST_OF_CONCESSIONI);
|
||||
|
||||
// setting null to force reloading from service
|
||||
if (reloadFromService)
|
||||
listOfConcessioni = null;
|
||||
|
||||
if (listOfConcessioni == null) {
|
||||
listOfConcessioni = new ArrayList<Concessione>();
|
||||
LOG.info("Loading list of concessione from client mongo");
|
||||
SessionUtil.getCurrentContext(httpServletRequest, true);
|
||||
MongoServiceCommon serviceUtil = new MongoServiceCommon();
|
||||
MongoConcessioni clientMongo = serviceUtil.getInstanceMongoConcessioni();
|
||||
|
||||
Iterator<Concessione> concessioni = clientMongo.getList();
|
||||
if (concessioni != null) {
|
||||
while (concessioni.hasNext()) {
|
||||
Concessione concessione = (Concessione) concessioni.next();
|
||||
listOfConcessioni.add(concessione);
|
||||
|
||||
}
|
||||
}
|
||||
// LOG.debug("Got list of concessioni from client mongo: " + listOfConcessioni);
|
||||
session.setAttribute(LIST_OF_CONCESSIONI, listOfConcessioni);
|
||||
LOG.info("Saved in session list of concessioni from client mongo with size: " + listOfConcessioni.size());
|
||||
} else
|
||||
LOG.info("list of concessioni presents in session, using it");
|
||||
|
||||
LOG.info("read list of concessioni with size: " + listOfConcessioni.size());
|
||||
return listOfConcessioni;
|
||||
}
|
||||
// public static List<Concessione> getListOfConcessioni(HttpServletRequest httpServletRequest,
|
||||
// boolean reloadFromService) throws Exception {
|
||||
// HttpSession session = httpServletRequest.getSession();
|
||||
// List<Concessione> listOfConcessioni = (List<Concessione>) session.getAttribute(LIST_OF_CONCESSIONI);
|
||||
//
|
||||
// // setting null to force reloading from service
|
||||
// if (reloadFromService)
|
||||
// listOfConcessioni = null;
|
||||
//
|
||||
// if (listOfConcessioni == null) {
|
||||
// listOfConcessioni = new ArrayList<Concessione>();
|
||||
// LOG.info("Loading list of concessione from client mongo");
|
||||
// SessionUtil.getCurrentContext(httpServletRequest, true);
|
||||
// MongoServiceCommon serviceUtil = new MongoServiceCommon();
|
||||
// MongoConcessioni clientMongo = serviceUtil.getInstanceMongoConcessioni();
|
||||
//
|
||||
// Iterator<Concessione> concessioni = clientMongo.getList();
|
||||
// if (concessioni != null) {
|
||||
// while (concessioni.hasNext()) {
|
||||
// Concessione concessione = (Concessione) concessioni.next();
|
||||
// listOfConcessioni.add(concessione);
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// // LOG.debug("Got list of concessioni from client mongo: " + listOfConcessioni);
|
||||
// session.setAttribute(LIST_OF_CONCESSIONI, listOfConcessioni);
|
||||
// LOG.info("Saved in session list of concessioni from client mongo with size: " + listOfConcessioni.size());
|
||||
// } else
|
||||
// LOG.info("list of concessioni presents in session, using it");
|
||||
//
|
||||
// LOG.info("read list of concessioni with size: " + listOfConcessioni.size());
|
||||
// return listOfConcessioni;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Gets the GNA data viewer config profile.
|
||||
|
|
|
@ -4,18 +4,17 @@ package org.gcube.portlets.user.geoportaldataviewer.shared;
|
|||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.cl.ucd.UCD;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.UseCaseDescriptorDV;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.IndexLayer;
|
||||
|
||||
|
||||
public class GCubeCollection implements Serializable {
|
||||
|
||||
private UCD ucd;
|
||||
private UseCaseDescriptorDV ucd;
|
||||
private List<IndexLayer> indexes;
|
||||
|
||||
|
||||
public UCD getUcd() {
|
||||
public UseCaseDescriptorDV getUcd() {
|
||||
return ucd;
|
||||
}
|
||||
|
||||
|
@ -24,11 +23,18 @@ public class GCubeCollection implements Serializable {
|
|||
}
|
||||
|
||||
|
||||
public void setUcd(UCD ucd) {
|
||||
public void setUcd(UseCaseDescriptorDV ucd) {
|
||||
this.ucd = ucd;
|
||||
}
|
||||
|
||||
public void setIndexes(List<IndexLayer> indexes) {
|
||||
this.indexes = indexes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GCubeCollection [ucd=" + ucd + ", indexes=" + indexes + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
|
||||
|
||||
public class ViewerConfiguration implements Serializable{
|
||||
|
||||
|
||||
//TODO BaseLayers
|
||||
public List<BaseMapLayer> baseLayers;
|
||||
|
||||
|
||||
public List<GCubeCollection> availableCollections;
|
||||
|
||||
|
||||
public List<BaseMapLayer> getBaseLayers() {
|
||||
return baseLayers;
|
||||
}
|
||||
|
||||
|
||||
public void setBaseLayers(List<BaseMapLayer> baseLayers) {
|
||||
this.baseLayers = baseLayers;
|
||||
}
|
||||
|
||||
|
||||
public List<GCubeCollection> getAvailableCollections() {
|
||||
return availableCollections;
|
||||
}
|
||||
|
||||
|
||||
public void setAvailableCollections(List<GCubeCollection> availableCollections) {
|
||||
this.availableCollections = availableCollections;
|
||||
}
|
||||
|
||||
//TODO
|
||||
// public List<String> displayedCollections;
|
||||
//
|
||||
//
|
||||
// public Map<String,String> selectedProjects;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.shared.faults;
|
||||
|
||||
public class ControlledError extends Exception {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 3471094758439575063L;
|
||||
|
||||
public ControlledError() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public ControlledError(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
|
||||
super(message, cause, enableSuppression, writableStackTrace);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public ControlledError(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public ControlledError(String message) {
|
||||
super(message);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public ControlledError(Throwable cause) {
|
||||
super(cause);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer;
|
||||
|
||||
import org.gcube.application.geoportal.common.model.legacy.Concessione;
|
||||
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.IAMClientCredentialsReader;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accessidentity.IAMClientCredentials;
|
||||
|
@ -23,14 +23,7 @@ public class IAMClient {
|
|||
}
|
||||
|
||||
System.out.println("Read credentials: " + credentials);
|
||||
Concessione concessione;
|
||||
try {
|
||||
// concessione = new ConcessioniMongoServiceIdentityProxy();
|
||||
|
||||
// System.out.println("Get concessione: " + concessione);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue