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.wms.GeoInformationForWMSRequest;
|
||||
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 com.google.gwt.user.client.rpc.RemoteService;
|
||||
|
@ -100,4 +101,14 @@ 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;
|
||||
|
||||
}
|
||||
|
|
|
@ -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.wms.GeoInformationForWMSRequest;
|
||||
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 com.google.gwt.core.client.GWT;
|
||||
|
@ -50,4 +51,7 @@ public interface GeoportalDataViewerServiceAsync {
|
|||
|
||||
void getPublicLinksFor(GeoNaItemRef item, AsyncCallback<GeoNaItemRef> asyncCallback);
|
||||
|
||||
void getLayersForId(String itemType, String itemId,
|
||||
AsyncCallback<List<LayerConcessioneDV>> asyncCallback);
|
||||
|
||||
}
|
||||
|
|
|
@ -168,20 +168,20 @@ public class LayerManager {
|
|||
flex.getElement().addClassName("popup-table");
|
||||
boolean featureFound = false;
|
||||
FeatureRow feature = null;
|
||||
|
||||
|
||||
// TODO SWTCH FOR EARCH ITEM TYPE
|
||||
for (GeoNaSpatialQueryResult geoNaDataObject : listGeonaDataObjects) {
|
||||
List<FeatureRow> features = geoNaDataObject.getFeatures();
|
||||
|
||||
// USING ONLY THE FIRST FEATURE IN THE LIST
|
||||
if (features != null && features.size() > 0) {
|
||||
|
||||
String theProductId = null;
|
||||
// I need to show exaclty the feature with produc_id == recordId
|
||||
if (mongoItemId != null) {
|
||||
for (FeatureRow fRow : features) {
|
||||
List<String> productIdLst = fRow.getMapProperties()
|
||||
.get("product_id");
|
||||
String theProductId = productIdLst.get(0);
|
||||
theProductId = productIdLst.get(0);
|
||||
try {
|
||||
//long productId = Long.parseLong(thePID);
|
||||
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) {
|
||||
feature = features.get(0);
|
||||
List<String> productIdLst = feature.getMapProperties()
|
||||
.get("product_id");
|
||||
theProductId = productIdLst.get(0);
|
||||
} else {
|
||||
// the recordId to show has been passed but not found into list of
|
||||
// FeatureRow
|
||||
|
@ -206,6 +209,35 @@ public class LayerManager {
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
|
|
|
@ -10,15 +10,13 @@ import java.util.Map;
|
|||
|
||||
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.LayerConcessione;
|
||||
import org.gcube.application.geoportal.common.model.legacy.UploadedImage;
|
||||
import org.gcube.application.geoportalcommon.GeoNaDataViewerProfileReader;
|
||||
import org.gcube.application.geoportalcommon.GeoportalCommon;
|
||||
import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile;
|
||||
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
|
||||
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.server.gis.FeatureParser;
|
||||
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.ZAxis;
|
||||
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.spatial.data.geoutility.GeoNcWMSMetadataUtility;
|
||||
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.
|
||||
*
|
||||
|
@ -364,6 +425,13 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
|||
return profile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the public links for.
|
||||
*
|
||||
* @param item the item
|
||||
* @return the public links for
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
@Override
|
||||
public GeoNaItemRef getPublicLinksFor(GeoNaItemRef item) throws Exception {
|
||||
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 {
|
||||
return SessionUtil.isSessionExpired(this.getThreadLocalRequest());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue