added a method
This commit is contained in:
parent
c7683e1245
commit
1c3184fd0b
|
@ -9,6 +9,7 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap;
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject;
|
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.gis.wms.GeoInformationForWMSRequest;
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.shared.products.ConcessioneDV;
|
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.UploadedImageDV;
|
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.RemoteService;
|
||||||
|
@ -100,4 +101,14 @@ public interface GeoportalDataViewerService extends RemoteService {
|
||||||
*/
|
*/
|
||||||
GeoNaItemRef getPublicLinksFor(GeoNaItemRef item) throws Exception;
|
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;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap;
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject;
|
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.gis.wms.GeoInformationForWMSRequest;
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.shared.products.ConcessioneDV;
|
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.UploadedImageDV;
|
import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.UploadedImageDV;
|
||||||
|
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
|
@ -50,4 +51,7 @@ public interface GeoportalDataViewerServiceAsync {
|
||||||
|
|
||||||
void getPublicLinksFor(GeoNaItemRef item, AsyncCallback<GeoNaItemRef> asyncCallback);
|
void getPublicLinksFor(GeoNaItemRef item, AsyncCallback<GeoNaItemRef> asyncCallback);
|
||||||
|
|
||||||
|
void getLayersForId(String itemType, String itemId,
|
||||||
|
AsyncCallback<List<LayerConcessioneDV>> asyncCallback);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,13 +175,13 @@ public class LayerManager {
|
||||||
|
|
||||||
// USING ONLY THE FIRST FEATURE IN THE LIST
|
// USING ONLY THE FIRST FEATURE IN THE LIST
|
||||||
if (features != null && features.size() > 0) {
|
if (features != null && features.size() > 0) {
|
||||||
|
String theProductId = null;
|
||||||
// I need to show exaclty the feature with produc_id == recordId
|
// I need to show exaclty the feature with produc_id == recordId
|
||||||
if (mongoItemId != null) {
|
if (mongoItemId != null) {
|
||||||
for (FeatureRow fRow : features) {
|
for (FeatureRow fRow : features) {
|
||||||
List<String> productIdLst = fRow.getMapProperties()
|
List<String> productIdLst = fRow.getMapProperties()
|
||||||
.get("product_id");
|
.get("product_id");
|
||||||
String theProductId = productIdLst.get(0);
|
theProductId = productIdLst.get(0);
|
||||||
try {
|
try {
|
||||||
//long productId = Long.parseLong(thePID);
|
//long productId = Long.parseLong(thePID);
|
||||||
if (theProductId == mongoItemId) {
|
if (theProductId == mongoItemId) {
|
||||||
|
@ -196,9 +196,12 @@ public class LayerManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If recordId not passed, I'm using the first feature returned
|
// If mongoItemId not passed, I'm using the first feature returned
|
||||||
if (mongoItemId == null) {
|
if (mongoItemId == null) {
|
||||||
feature = features.get(0);
|
feature = features.get(0);
|
||||||
|
List<String> productIdLst = feature.getMapProperties()
|
||||||
|
.get("product_id");
|
||||||
|
theProductId = productIdLst.get(0);
|
||||||
} else {
|
} else {
|
||||||
// the recordId to show has been passed but not found into list of
|
// the recordId to show has been passed but not found into list of
|
||||||
// FeatureRow
|
// FeatureRow
|
||||||
|
@ -207,6 +210,35 @@ public class LayerManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GWT.log("the product id is: "+theProductId);
|
||||||
|
|
||||||
|
/*if(olMap.getCurrentZoomLevel()>10) {
|
||||||
|
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) {
|
||||||
|
GWT.log("Adding layers: "+result);
|
||||||
|
for (LayerConcessioneDV layer : result) {
|
||||||
|
addLayer("concessione", layer.getLayerName(), layer.getLayerName(), layer.getWmsLink(), false, false, layer.getLayerUUID(), true);
|
||||||
|
// LayerItem li = new LayerItem();
|
||||||
|
// li.setBaseLayer(false);
|
||||||
|
// li.setWmsLink(layer.getWmsLink());
|
||||||
|
// li.setTitle(layer.getLayerName());
|
||||||
|
// olMap.addWMSLayer(li);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
Map<String, List<String>> entries = feature.getMapProperties();
|
Map<String, List<String>> entries = feature.getMapProperties();
|
||||||
|
|
||||||
String nome = "";
|
String nome = "";
|
||||||
|
|
|
@ -10,15 +10,13 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.gcube.application.geoportal.client.legacy.ConcessioniManagerI;
|
import org.gcube.application.geoportal.client.legacy.ConcessioniManagerI;
|
||||||
import org.gcube.application.geoportal.common.model.legacy.Concessione;
|
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.legacy.UploadedImage;
|
||||||
import org.gcube.application.geoportalcommon.GeoNaDataViewerProfileReader;
|
import org.gcube.application.geoportalcommon.GeoNaDataViewerProfileReader;
|
||||||
import org.gcube.application.geoportalcommon.GeoportalCommon;
|
import org.gcube.application.geoportalcommon.GeoportalCommon;
|
||||||
import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile;
|
import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile;
|
||||||
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
|
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
|
||||||
import org.gcube.application.geoportalcommon.shared.LayerItem;
|
import org.gcube.application.geoportalcommon.shared.LayerItem;
|
||||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
|
||||||
import org.gcube.common.portal.PortalContext;
|
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerService;
|
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.FeatureParser;
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.server.gis.WMSUrlValidator;
|
import org.gcube.portlets.user.geoportaldataviewer.server.gis.WMSUrlValidator;
|
||||||
|
@ -32,6 +30,7 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformation
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.Styles;
|
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.gis.wms.ZAxis;
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.shared.products.ConcessioneDV;
|
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.UploadedImageDV;
|
import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.UploadedImageDV;
|
||||||
import org.gcube.spatial.data.geoutility.GeoNcWMSMetadataUtility;
|
import org.gcube.spatial.data.geoutility.GeoNcWMSMetadataUtility;
|
||||||
import org.gcube.spatial.data.geoutility.bean.LayerStyles;
|
import org.gcube.spatial.data.geoutility.bean.LayerStyles;
|
||||||
|
@ -227,6 +226,68 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
|
||||||
|
if (itemType.equalsIgnoreCase("concessione")) {
|
||||||
|
|
||||||
|
LOG.info("Trying to get concessione for id " + itemId);
|
||||||
|
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
|
||||||
|
SessionUtil.getCurrentToken(this.getThreadLocalRequest(), true);
|
||||||
|
ConcessioniManagerI concessioniManager = statefulMongoConcessioni().build();
|
||||||
|
Concessione concessione = concessioniManager.getById(itemId);
|
||||||
|
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()) {
|
||||||
|
listLayers.add(ConvertToDataViewModel.toLayerConcessione(lc));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (concessione.getPosizionamentoScavo() != null) {
|
||||||
|
LayerConcessioneDV thePosizScavo = ConvertToDataViewModel
|
||||||
|
.toLayerConcessione(concessione.getPosizionamentoScavo());
|
||||||
|
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.
|
* Gets the concessione for id.
|
||||||
*
|
*
|
||||||
|
@ -364,6 +425,13 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
||||||
return profile;
|
return profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the public links for.
|
||||||
|
*
|
||||||
|
* @param item the item
|
||||||
|
* @return the public links for
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public GeoNaItemRef getPublicLinksFor(GeoNaItemRef item) throws Exception {
|
public GeoNaItemRef getPublicLinksFor(GeoNaItemRef item) throws Exception {
|
||||||
LOG.info("getPublicLinksFor called for: " + item);
|
LOG.info("getPublicLinksFor called for: " + item);
|
||||||
|
@ -390,6 +458,12 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if is session expired.
|
||||||
|
*
|
||||||
|
* @return true, if is session expired
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
public boolean isSessionExpired() throws Exception {
|
public boolean isSessionExpired() throws Exception {
|
||||||
return SessionUtil.isSessionExpired(this.getThreadLocalRequest());
|
return SessionUtil.isSessionExpired(this.getThreadLocalRequest());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue