2020-10-23 18:18:06 +02:00
|
|
|
package org.gcube.portlets.user.geoportaldataviewer.server;
|
|
|
|
|
2022-10-13 16:53:33 +02:00
|
|
|
import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin.projects;
|
|
|
|
import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin.useCaseDescriptors;
|
|
|
|
|
2020-11-19 15:19:27 +01:00
|
|
|
import java.util.ArrayList;
|
2021-09-07 17:29:56 +02:00
|
|
|
import java.util.Arrays;
|
2020-10-27 16:04:34 +01:00
|
|
|
import java.util.HashMap;
|
2022-10-12 17:12:09 +02:00
|
|
|
import java.util.Iterator;
|
2020-11-19 15:19:27 +01:00
|
|
|
import java.util.LinkedHashMap;
|
2020-10-29 15:18:14 +01:00
|
|
|
import java.util.List;
|
2020-10-27 16:04:34 +01:00
|
|
|
import java.util.Map;
|
2022-10-25 14:53:56 +02:00
|
|
|
import java.util.Map.Entry;
|
2020-10-27 16:04:34 +01:00
|
|
|
|
2022-10-12 11:13:40 +02:00
|
|
|
import javax.servlet.ServletConfig;
|
|
|
|
import javax.servlet.ServletException;
|
2021-09-24 11:13:25 +02:00
|
|
|
|
2022-10-11 15:00:39 +02:00
|
|
|
import org.bson.Document;
|
2022-10-13 16:53:33 +02:00
|
|
|
import org.gcube.application.geoportal.common.model.configuration.Configuration;
|
|
|
|
import org.gcube.application.geoportal.common.model.configuration.Index;
|
2022-10-12 17:12:09 +02:00
|
|
|
import org.gcube.application.geoportal.common.model.document.Project;
|
2022-10-27 15:09:07 +02:00
|
|
|
import org.gcube.application.geoportal.common.model.document.identification.IdentificationReference;
|
2022-11-03 17:03:15 +01:00
|
|
|
import org.gcube.application.geoportal.common.model.document.relationships.Relationship;
|
2022-11-07 17:58:06 +01:00
|
|
|
import org.gcube.application.geoportal.common.model.document.relationships.RelationshipNavigationObject;
|
2022-10-13 16:53:33 +02:00
|
|
|
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
|
2022-10-12 17:12:09 +02:00
|
|
|
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
|
2022-10-13 16:53:33 +02:00
|
|
|
import org.gcube.application.geoportal.common.rest.Projects;
|
2022-10-11 15:00:39 +02:00
|
|
|
import org.gcube.application.geoportalcommon.ConvertToDataValueObjectModel;
|
2020-12-02 14:39:52 +01:00
|
|
|
import org.gcube.application.geoportalcommon.GeoportalCommon;
|
2022-10-18 14:17:41 +02:00
|
|
|
import org.gcube.application.geoportalcommon.ProjectDVBuilder;
|
2022-10-12 17:12:09 +02:00
|
|
|
import org.gcube.application.geoportalcommon.geoportal.GeoportalClientCaller;
|
|
|
|
import org.gcube.application.geoportalcommon.geoportal.ProjectsCaller;
|
|
|
|
import org.gcube.application.geoportalcommon.geoportal.UseCaseDescriptorCaller;
|
2021-12-21 16:52:35 +01:00
|
|
|
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
|
2022-10-18 17:32:12 +02:00
|
|
|
import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences;
|
2021-12-07 17:13:20 +01:00
|
|
|
import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData;
|
|
|
|
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
|
2022-10-12 17:12:09 +02:00
|
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.ConfigurationDV;
|
|
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV;
|
|
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV;
|
2022-10-11 15:00:39 +02:00
|
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
|
2022-10-27 15:09:07 +02:00
|
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.geojson.GeoJSON;
|
2022-10-18 14:17:41 +02:00
|
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.GCubeSDIViewerLayerDV;
|
2022-10-14 15:31:32 +02:00
|
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.IndexLayerDV;
|
2022-10-19 17:51:13 +02:00
|
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.PayloadDV;
|
2022-10-27 15:09:07 +02:00
|
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.project.IdentificationReferencesTYPE;
|
2022-10-11 15:00:39 +02:00
|
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
|
2022-11-16 16:42:12 +01:00
|
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.project.TemporalReferenceDV;
|
2022-10-12 17:12:09 +02:00
|
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_DATA_HANDLER;
|
|
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.HandlerDeclarationDV;
|
|
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.UseCaseDescriptorDV;
|
2022-10-11 15:00:39 +02:00
|
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
|
2021-08-02 15:20:01 +02:00
|
|
|
import org.gcube.application.geoportalcommon.shared.gis.BoundsMap;
|
|
|
|
import org.gcube.application.geoportalcommon.util.URLParserUtil;
|
2022-10-25 14:53:56 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
|
2020-10-26 12:24:23 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerService;
|
2020-10-29 15:18:14 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.server.gis.FeatureParser;
|
2020-10-27 16:04:34 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.server.gis.WMSUrlValidator;
|
2022-10-11 15:00:39 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.GeoportalServiceIdentityProxy;
|
2022-10-13 16:53:33 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.server.util.ContextRequest;
|
2020-11-03 18:04:47 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.server.util.SessionUtil;
|
2022-10-13 16:53:33 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.GCubeCollection;
|
2020-11-19 15:19:27 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult;
|
2022-10-17 16:52:22 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.ItemFieldsResponse;
|
2022-10-13 16:53:33 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.ViewerConfiguration;
|
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.faults.ControlledError;
|
2021-11-12 12:37:15 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
|
2020-11-19 15:19:27 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject;
|
2022-10-20 18:01:54 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObjectType;
|
2020-11-19 15:19:27 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.FeatureRow;
|
2020-11-03 13:09:08 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformationForWMSRequest;
|
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.Styles;
|
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.ZAxis;
|
2020-10-27 16:04:34 +01:00
|
|
|
import org.gcube.spatial.data.geoutility.GeoNcWMSMetadataUtility;
|
|
|
|
import org.gcube.spatial.data.geoutility.bean.LayerStyles;
|
|
|
|
import org.gcube.spatial.data.geoutility.bean.LayerZAxis;
|
|
|
|
import org.gcube.spatial.data.geoutility.bean.WmsParameters;
|
2020-11-19 15:19:27 +01:00
|
|
|
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
2022-11-02 18:05:38 +01:00
|
|
|
import org.json.JSONObject;
|
2020-10-27 16:04:34 +01:00
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
2020-10-23 18:18:06 +02:00
|
|
|
|
|
|
|
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The server side implementation of the RPC service.
|
2020-11-19 15:19:27 +01:00
|
|
|
*
|
|
|
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
|
|
|
*
|
2021-07-30 14:57:08 +02:00
|
|
|
* Nov 12, 2020
|
2020-10-23 18:18:06 +02:00
|
|
|
*/
|
|
|
|
@SuppressWarnings("serial")
|
2021-07-30 14:57:08 +02:00
|
|
|
public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet implements GeoportalDataViewerService {
|
|
|
|
|
2022-11-16 16:42:12 +01:00
|
|
|
// private static final String TIMELINE_CONFIG_TJT_DOCUMENT =
|
|
|
|
// UseCaseDescriptorCaller.TIMELINE_CONFIG_TJT_DOCUMENT;
|
2022-11-08 17:56:36 +01:00
|
|
|
|
2020-10-27 16:04:34 +01:00
|
|
|
private static final Logger LOG = LoggerFactory.getLogger(GeoportalDataViewerServiceImpl.class);
|
2020-10-23 18:18:06 +02:00
|
|
|
|
2022-11-16 16:42:12 +01:00
|
|
|
// private static final String CACHE_IMAGE_PREVIEW_FOR_CONCESSIONE =
|
|
|
|
// "MAP_IMAGE_PREVIEW_FOR_CONCESSIONE";
|
2021-09-24 11:13:25 +02:00
|
|
|
|
2022-10-18 14:17:41 +02:00
|
|
|
/**
|
|
|
|
* The Enum COMMON_IMAGES_FORMAT.
|
|
|
|
*
|
|
|
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
|
|
|
*
|
|
|
|
* Oct 18, 2022
|
|
|
|
*/
|
2022-10-11 15:00:39 +02:00
|
|
|
public static enum COMMON_IMAGES_FORMAT {
|
|
|
|
gif, png, jpeg, jpg, bmp, tif, tiff, svg, avif, webp
|
|
|
|
}
|
|
|
|
|
2022-10-18 14:17:41 +02:00
|
|
|
/**
|
|
|
|
* The Class ImageDetector.
|
|
|
|
*
|
|
|
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
|
|
|
*
|
|
|
|
* Oct 18, 2022
|
|
|
|
*/
|
2022-10-11 15:00:39 +02:00
|
|
|
public static class ImageDetector {
|
|
|
|
|
2022-10-18 14:17:41 +02:00
|
|
|
/**
|
|
|
|
* Gets the names.
|
|
|
|
*
|
|
|
|
* @param e the e
|
|
|
|
* @return the names
|
|
|
|
*/
|
2022-10-11 15:00:39 +02:00
|
|
|
private static String[] getNames(Class<? extends Enum<?>> e) {
|
|
|
|
return Arrays.stream(e.getEnumConstants()).map(Enum::name).toArray(String[]::new);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static List<String> listFormatImages;
|
|
|
|
|
|
|
|
static {
|
|
|
|
|
|
|
|
String[] arrayImgs = ImageDetector.getNames(COMMON_IMAGES_FORMAT.class);
|
|
|
|
listFormatImages = Arrays.asList(arrayImgs);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-10-18 14:17:41 +02:00
|
|
|
/**
|
|
|
|
* Checks if is image.
|
|
|
|
*
|
|
|
|
* @param mimeType the mime type
|
|
|
|
* @return true, if is image
|
|
|
|
*/
|
2022-10-11 15:00:39 +02:00
|
|
|
public static boolean isImage(String mimeType) {
|
|
|
|
if (mimeType == null || mimeType.isEmpty())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
String inputImageFormat = mimeType.replaceAll("image/", "");
|
|
|
|
|
|
|
|
return listFormatImages.contains(inputImageFormat);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-12-21 16:52:35 +01:00
|
|
|
/**
|
|
|
|
* Gets the GNA data viewe config profile.
|
|
|
|
*
|
|
|
|
* @return the GNA data viewe config profile
|
|
|
|
* @throws Exception the exception
|
|
|
|
*/
|
|
|
|
private GNADataViewerConfigProfile getGNADataVieweConfigProfile() throws Exception {
|
|
|
|
|
|
|
|
GNADataViewerConfigProfile profile = SessionUtil.getGNADataViewerConfigProfile(getThreadLocalRequest());
|
|
|
|
if (profile == null) {
|
|
|
|
LOG.info(GNADataViewerConfigProfile.class.getSimpleName() + " is null, loading configurations from IS");
|
2022-07-26 16:28:25 +02:00
|
|
|
// to be sure
|
2021-12-21 16:52:35 +01:00
|
|
|
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
|
|
|
|
GeoportalCommon geoportalComm = new GeoportalCommon();
|
|
|
|
profile = geoportalComm.readGNADataViewerConfig(null);
|
|
|
|
} else {
|
|
|
|
LOG.info(GNADataViewerConfigProfile.class.getSimpleName() + " read from session");
|
|
|
|
}
|
|
|
|
return profile;
|
|
|
|
}
|
|
|
|
|
2020-11-19 15:19:27 +01:00
|
|
|
/**
|
|
|
|
* Parses the wms request.
|
|
|
|
*
|
|
|
|
* @param wmsRequest the wms request
|
2021-07-30 14:57:08 +02:00
|
|
|
* @param layerName the layer name
|
2020-11-19 15:19:27 +01:00
|
|
|
* @return the geo information for WMS request
|
|
|
|
* @throws Exception the exception
|
|
|
|
*/
|
2020-10-27 16:04:34 +01:00
|
|
|
@Override
|
2020-10-27 16:41:30 +01:00
|
|
|
public GeoInformationForWMSRequest parseWmsRequest(String wmsRequest, String layerName) throws Exception {
|
2020-10-27 16:04:34 +01:00
|
|
|
return loadGeoInfoForWmsRequest(wmsRequest, layerName);
|
|
|
|
}
|
2020-11-19 15:19:27 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Load geo info for wms request.
|
2020-10-27 16:04:34 +01:00
|
|
|
*
|
2021-07-30 14:57:08 +02:00
|
|
|
* @param wmsLink the wms link
|
2020-10-27 16:04:34 +01:00
|
|
|
* @param layerName the layer name
|
2020-11-19 15:19:27 +01:00
|
|
|
* @return the geo information for WMS request
|
2020-10-27 16:04:34 +01:00
|
|
|
* @throws Exception the exception
|
|
|
|
*/
|
2021-12-21 16:52:35 +01:00
|
|
|
public GeoInformationForWMSRequest loadGeoInfoForWmsRequest(String wmsLink, String layerName) throws Exception {
|
2020-10-27 16:04:34 +01:00
|
|
|
try {
|
2020-11-19 15:19:27 +01:00
|
|
|
WMSUrlValidator validator = new WMSUrlValidator(wmsLink, layerName);
|
2020-10-27 16:04:34 +01:00
|
|
|
String wmsServiceHost = validator.getWmsServiceHost();
|
|
|
|
String validWMSRequest = validator.parseWMSRequest(true, true);
|
|
|
|
layerName = validator.getLayerName();
|
|
|
|
String versionWms = validator.getValueOfParsedWMSParameter(WmsParameters.VERSION);
|
|
|
|
String crs = validator.getValueOfParsedWMSParameter(WmsParameters.CRS);
|
2021-07-30 14:57:08 +02:00
|
|
|
//
|
2020-10-27 16:04:34 +01:00
|
|
|
HashMap<String, String> mapWmsNotStandard = new HashMap<String, String>();
|
|
|
|
|
2021-07-30 14:57:08 +02:00
|
|
|
if (validator.getMapWmsNoStandardParams() != null) {
|
2020-10-27 16:04:34 +01:00
|
|
|
mapWmsNotStandard.putAll(validator.getMapWmsNoStandardParams());
|
|
|
|
}
|
2021-07-30 14:57:08 +02:00
|
|
|
//
|
2020-10-27 16:04:34 +01:00
|
|
|
GeoNcWMSMetadataUtility geoGS = new GeoNcWMSMetadataUtility(validWMSRequest, 4000);
|
2021-07-30 14:57:08 +02:00
|
|
|
// STYLES
|
|
|
|
LayerStyles layerStyle = geoGS.loadStyles();
|
|
|
|
Map<String, String> mapNcWmsStyles = layerStyle.getMapNcWmsStyles() == null ? new HashMap<String, String>(1)
|
|
|
|
: layerStyle.getMapNcWmsStyles();
|
2020-10-27 16:04:34 +01:00
|
|
|
mapWmsNotStandard.putAll(mapNcWmsStyles);
|
2021-07-30 14:57:08 +02:00
|
|
|
// MAP STYLES INTO GWT-SERIALIZABLE OBJECT
|
2020-10-27 16:04:34 +01:00
|
|
|
Styles styles = new Styles(layerStyle.getGeoStyles(), layerStyle.getMapNcWmsStyles(), layerStyle.isNcWms());
|
2021-07-30 14:57:08 +02:00
|
|
|
// ZAxis
|
2020-10-27 16:04:34 +01:00
|
|
|
LayerZAxis layerZAxis = geoGS.loadZAxis();
|
2021-07-30 14:57:08 +02:00
|
|
|
// MAP ZAXIS INTO GWT-SERIALIZABLE OBJECT
|
|
|
|
ZAxis zAxis = layerZAxis != null
|
|
|
|
? new ZAxis(layerZAxis.getUnits(), layerZAxis.isPositive(), layerZAxis.getValues())
|
|
|
|
: null;
|
2020-10-27 16:04:34 +01:00
|
|
|
|
2021-07-30 14:57:08 +02:00
|
|
|
return new GeoInformationForWMSRequest(wmsServiceHost, validWMSRequest, layerName, versionWms, crs,
|
|
|
|
mapWmsNotStandard, styles, styles.isNcWms(), zAxis);
|
|
|
|
} catch (Exception e) {
|
|
|
|
String msg = "An error occurred during wms request validation for layer: " + layerName;
|
|
|
|
LOG.error(msg, e);
|
2020-10-27 16:04:34 +01:00
|
|
|
throw new Exception(msg);
|
|
|
|
}
|
|
|
|
}
|
2020-11-19 15:19:27 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the parameters from URL.
|
|
|
|
*
|
2021-07-30 14:57:08 +02:00
|
|
|
* @param theURL the the URL
|
2020-11-19 15:19:27 +01:00
|
|
|
* @param parameters the parameters
|
|
|
|
* @return a map with couple (paramKey, paramValue)
|
|
|
|
*/
|
2021-07-30 14:57:08 +02:00
|
|
|
|
2020-11-19 15:19:27 +01:00
|
|
|
public Map<String, String> getParametersFromURL(String theURL, List<String> parameters) {
|
2020-10-29 15:18:14 +01:00
|
|
|
|
2020-11-19 15:19:27 +01:00
|
|
|
if (theURL == null)
|
|
|
|
return null;
|
|
|
|
|
|
|
|
if (parameters == null || parameters.size() == 0)
|
|
|
|
return null;
|
|
|
|
|
|
|
|
Map<String, String> hashParameters = new HashMap<String, String>(parameters.size());
|
|
|
|
for (String paramKey : parameters) {
|
|
|
|
String paramValue = URLParserUtil.extractValueOfParameterFromURL(paramKey, theURL);
|
|
|
|
hashParameters.put(paramKey, paramValue);
|
|
|
|
}
|
2021-07-30 14:57:08 +02:00
|
|
|
|
2020-11-19 15:19:27 +01:00
|
|
|
return hashParameters;
|
|
|
|
|
|
|
|
}
|
2021-07-30 14:57:08 +02:00
|
|
|
|
2020-11-19 15:19:27 +01:00
|
|
|
/**
|
|
|
|
* Gets the my login.
|
|
|
|
*
|
|
|
|
* @return the my login
|
|
|
|
*/
|
|
|
|
@Override
|
2021-07-30 14:57:08 +02:00
|
|
|
public String getMyLogin() {
|
2020-11-19 15:19:27 +01:00
|
|
|
try {
|
|
|
|
GCubeUser user = SessionUtil.getCurrentUser(this.getThreadLocalRequest());
|
2021-07-30 14:57:08 +02:00
|
|
|
if (user == null)
|
2020-11-19 15:19:27 +01:00
|
|
|
return null;
|
|
|
|
return user.getUsername();
|
2021-07-30 14:57:08 +02:00
|
|
|
} catch (Exception e) {
|
2020-11-19 15:19:27 +01:00
|
|
|
LOG.warn("Error on getting the login, am I out of portal? Returning null");
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
2021-07-30 14:57:08 +02:00
|
|
|
|
2020-11-19 15:19:27 +01:00
|
|
|
/**
|
|
|
|
* Gets the geo na data view profile.
|
|
|
|
*
|
|
|
|
* @return the geo na data view profile
|
|
|
|
* @throws Exception the exception
|
|
|
|
*/
|
|
|
|
@Override
|
2021-12-21 16:52:35 +01:00
|
|
|
public GNADataViewerConfigProfile getGeoNaDataViewProfile() throws Exception {
|
2020-11-19 15:19:27 +01:00
|
|
|
LOG.info("getGeoNaDataViewProfile called");
|
2021-07-30 14:57:08 +02:00
|
|
|
|
2020-11-19 15:19:27 +01:00
|
|
|
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
|
2021-12-21 16:52:35 +01:00
|
|
|
GNADataViewerConfigProfile profile = getGNADataVieweConfigProfile();
|
2021-07-30 14:57:08 +02:00
|
|
|
LOG.info("Returning profile: " + profile);
|
2020-11-19 15:19:27 +01:00
|
|
|
return profile;
|
|
|
|
}
|
|
|
|
|
2021-07-30 15:57:25 +02:00
|
|
|
/**
|
|
|
|
* Gets the public links for.
|
|
|
|
*
|
|
|
|
* @param item the item
|
|
|
|
* @return the public links for
|
|
|
|
* @throws Exception the exception
|
|
|
|
*/
|
2020-11-19 15:19:27 +01:00
|
|
|
@Override
|
2022-10-18 17:32:12 +02:00
|
|
|
public GeoportalItemReferences getPublicLinksFor(GeoportalItemReferences item) throws Exception {
|
2020-11-19 15:19:27 +01:00
|
|
|
LOG.info("getPublicLinksFor called for: " + item);
|
2020-12-02 14:39:52 +01:00
|
|
|
|
2020-11-19 15:19:27 +01:00
|
|
|
try {
|
|
|
|
|
|
|
|
if (item == null)
|
|
|
|
throw new Exception("Bad request, the item is null");
|
2021-07-30 14:57:08 +02:00
|
|
|
|
2022-10-13 16:53:33 +02:00
|
|
|
if (item.getProjectID() == null)
|
|
|
|
throw new Exception("Bad request, the projectID is null");
|
2021-07-30 14:57:08 +02:00
|
|
|
|
2022-10-13 16:53:33 +02:00
|
|
|
if (item.getProfileID() == null)
|
|
|
|
throw new Exception("Bad request, the profileID is null");
|
2021-07-30 14:57:08 +02:00
|
|
|
|
2020-12-02 14:39:52 +01:00
|
|
|
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
|
|
|
|
GeoportalCommon gc = new GeoportalCommon();
|
2021-09-23 18:18:02 +02:00
|
|
|
return gc.getPublicLinksFor(item, true);
|
2021-07-30 14:57:08 +02:00
|
|
|
|
2020-11-19 15:19:27 +01:00
|
|
|
} catch (Exception e) {
|
|
|
|
LOG.error("Error on getPublicLinksFor for: " + item, e);
|
2021-07-30 14:57:08 +02:00
|
|
|
throw new Exception("Share link not available for this item. Try later or contact the support. Error: "
|
|
|
|
+ e.getMessage());
|
2020-11-19 15:19:27 +01:00
|
|
|
}
|
|
|
|
}
|
2021-07-30 14:57:08 +02:00
|
|
|
|
2021-07-30 15:57:25 +02:00
|
|
|
/**
|
|
|
|
* Checks if is session expired.
|
|
|
|
*
|
|
|
|
* @return true, if is session expired
|
|
|
|
* @throws Exception the exception
|
|
|
|
*/
|
2020-11-19 15:19:27 +01:00
|
|
|
public boolean isSessionExpired() throws Exception {
|
|
|
|
return SessionUtil.isSessionExpired(this.getThreadLocalRequest());
|
|
|
|
}
|
2021-07-30 14:57:08 +02:00
|
|
|
|
2021-08-31 18:21:17 +02:00
|
|
|
/**
|
|
|
|
* Gets the WFS features.
|
|
|
|
*
|
|
|
|
* @param layerObjects the layer objects
|
|
|
|
* @param mapSrsName the map srs name
|
|
|
|
* @param selectBBOX the select BBOX
|
|
|
|
* @param maxWFSFeature the max WFS feature
|
|
|
|
* @param zoomLevel the zoom level
|
|
|
|
* @return the WFS features
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public List<GeoNaSpatialQueryResult> getWFSFeatures(List<LayerObject> layerObjects, String mapSrsName,
|
|
|
|
BoundsMap selectBBOX, int maxWFSFeature, double zoomLevel) {
|
|
|
|
LOG.info("getWFSFeatures called");
|
|
|
|
|
|
|
|
List<GeoNaSpatialQueryResult> listDAO = new ArrayList<GeoNaSpatialQueryResult>(layerObjects.size());
|
|
|
|
|
|
|
|
for (LayerObject layerObject : layerObjects) {
|
|
|
|
GeoNaSpatialQueryResult geoDAO = new GeoNaSpatialQueryResult();
|
|
|
|
List<FeatureRow> features = FeatureParser.getWFSFeatures(layerObject.getLayerItem(), mapSrsName, selectBBOX,
|
|
|
|
maxWFSFeature);
|
|
|
|
LOG.debug("For layer name: " + layerObject.getLayerItem().getName() + " got features: " + features);
|
|
|
|
geoDAO.setFeatures(features);
|
|
|
|
geoDAO.setSourceLayerObject(layerObject);
|
|
|
|
LOG.info("For layer name: " + layerObject.getLayerItem().getName() + " got " + features.size()
|
|
|
|
+ " feature/s");
|
|
|
|
listDAO.add(geoDAO);
|
|
|
|
}
|
|
|
|
LOG.info("returning " + listDAO + " geona data objects");
|
|
|
|
return listDAO;
|
|
|
|
}
|
|
|
|
|
2021-12-07 17:13:20 +01:00
|
|
|
/**
|
|
|
|
* Gets the list base layers.
|
|
|
|
*
|
|
|
|
* @return the list base layers
|
|
|
|
*/
|
2021-11-12 12:37:15 +01:00
|
|
|
@Override
|
|
|
|
public List<BaseMapLayer> getListBaseLayers() {
|
2021-11-18 15:55:05 +01:00
|
|
|
LOG.info("getListBaseLayers called");
|
2021-11-12 12:37:15 +01:00
|
|
|
List<BaseMapLayer> listBL = new ArrayList<BaseMapLayer>();
|
2021-12-21 16:52:35 +01:00
|
|
|
// Setting scope in the cuurent thread
|
2021-11-18 15:55:05 +01:00
|
|
|
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
|
|
|
|
listBL = SessionUtil.getGNABaseMaps(this.getThreadLocalRequest());
|
2021-12-21 16:52:35 +01:00
|
|
|
LOG.info("getListBaseLayers returning " + listBL.size() + " base maps");
|
2021-11-12 12:37:15 +01:00
|
|
|
return listBL;
|
|
|
|
|
|
|
|
}
|
2021-12-21 16:52:35 +01:00
|
|
|
|
2022-10-11 15:00:39 +02:00
|
|
|
/**
|
2022-10-18 14:17:41 +02:00
|
|
|
* NEW CODE HERE.
|
|
|
|
*
|
|
|
|
* @return the initial configuration
|
|
|
|
* @throws Exception the exception
|
2022-10-11 15:00:39 +02:00
|
|
|
*/
|
2022-10-12 17:12:09 +02:00
|
|
|
|
2022-10-13 16:53:33 +02:00
|
|
|
@Override
|
|
|
|
public ViewerConfiguration getInitialConfiguration() throws Exception {
|
|
|
|
LOG.debug("getInitialConfiguration called");
|
|
|
|
|
|
|
|
return new ContextRequest<ViewerConfiguration>(this.getThreadLocalRequest()) {
|
|
|
|
@Override
|
|
|
|
protected ViewerConfiguration run() throws Exception, ControlledError {
|
|
|
|
try {
|
|
|
|
|
|
|
|
// ************* LOAD BASE LAYERS
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
// ************** LOAD AVAILABLE COLLECTIONS
|
|
|
|
|
|
|
|
LOG.debug("Loading available collections.. ");
|
|
|
|
config.setAvailableCollections(new HashMap<String, GCubeCollection>());
|
|
|
|
|
|
|
|
// TODO filter by
|
|
|
|
// configured ?
|
|
|
|
// gis indexed
|
|
|
|
QueryRequest request = new QueryRequest();
|
|
|
|
|
|
|
|
// TODO Constant
|
|
|
|
String Id = "org.gcube.portlets.user.geoportaldataviewer";
|
|
|
|
request.setFilter(Document.parse("{\"" + UseCaseDescriptor.HANDLERS + "."
|
|
|
|
+ org.gcube.application.geoportal.common.model.useCaseDescriptor.HandlerDeclaration.ID
|
|
|
|
+ "\" : " + "{\"$eq\" : \"" + Id + "\"}}"));
|
|
|
|
|
|
|
|
useCaseDescriptors().build().query(new QueryRequest()).forEachRemaining(u -> {
|
|
|
|
try {
|
|
|
|
LOG.debug("Checking configuration for collection " + u.getId());
|
|
|
|
|
|
|
|
Projects<Project> p = projects(u.getId()).build();
|
2022-10-14 15:31:32 +02:00
|
|
|
|
2022-10-13 16:53:33 +02:00
|
|
|
UseCaseDescriptorDV ucd = ConvertToDataValueObjectModel.toUseCaseDescriptorDV(u, null);
|
|
|
|
Configuration ucdConfig = p.getConfiguration();
|
|
|
|
GCubeCollection coll = new GCubeCollection();
|
|
|
|
coll.setUcd(ucd);
|
|
|
|
|
|
|
|
// TODO TO Check index flag should be in configuration or evaluated according to
|
|
|
|
// user credentials
|
|
|
|
|
2022-10-27 16:18:54 +02:00
|
|
|
String indexFlag = "public"; // default
|
|
|
|
|
2022-10-27 15:09:07 +02:00
|
|
|
GeoportalServiceIdentityProxy gsp = getGeoportalServiceProxy();
|
2022-10-27 16:18:54 +02:00
|
|
|
if (gsp.isUser()) {
|
2022-10-27 15:09:07 +02:00
|
|
|
indexFlag = "internal";
|
2022-10-27 16:18:54 +02:00
|
|
|
LOG.info("user logged - using indexFlag: " + indexFlag);
|
|
|
|
} else if (gsp.isIAMClient()) {
|
2022-10-27 15:09:07 +02:00
|
|
|
indexFlag = "public";
|
2022-10-27 16:18:54 +02:00
|
|
|
LOG.info("user not logged - using indexFlag: " + indexFlag);
|
2022-10-27 15:09:07 +02:00
|
|
|
}
|
2022-10-13 16:53:33 +02:00
|
|
|
|
|
|
|
// TODO constant
|
|
|
|
coll.setIndexes(new ArrayList());
|
|
|
|
|
2022-10-27 16:18:54 +02:00
|
|
|
LOG.debug(
|
|
|
|
"Checking if " + u.getId() + " is GIS Indexed. Index flag needed is " + indexFlag);
|
2022-10-13 16:53:33 +02:00
|
|
|
|
|
|
|
for (Index index : ucdConfig.getIndexes()) {
|
|
|
|
try {
|
2022-10-14 15:31:32 +02:00
|
|
|
IndexLayerDV toAdd = ConvertToDataValueObjectModel.convert(index);
|
2022-10-27 15:09:07 +02:00
|
|
|
if (toAdd.getFlag().equals(indexFlag)) {
|
2022-10-13 16:53:33 +02:00
|
|
|
coll.getIndexes().add(toAdd);
|
2022-10-13 17:19:53 +02:00
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
2022-10-13 16:53:33 +02:00
|
|
|
LOG.debug("Skipping invalid index ", e);
|
|
|
|
} catch (Throwable t) {
|
|
|
|
LOG.error("Unable to check index ", t);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return only if gis indexed
|
|
|
|
if (coll.getIndexes().isEmpty())
|
|
|
|
LOG.info("No available GIS Index for collection " + coll.getUcd().getName());
|
|
|
|
else
|
|
|
|
config.getAvailableCollections().put(coll.getUcd().getId(), 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();
|
|
|
|
}
|
|
|
|
|
2022-10-18 14:17:41 +02:00
|
|
|
/**
|
2022-10-27 16:18:54 +02:00
|
|
|
* Gets the config list of fields for searching.
|
2022-10-18 14:17:41 +02:00
|
|
|
*
|
2022-10-27 16:18:54 +02:00
|
|
|
* @return the config list of fields for searching
|
2022-10-18 14:17:41 +02:00
|
|
|
* @throws Exception the exception
|
|
|
|
*/
|
2022-10-12 17:12:09 +02:00
|
|
|
@Override
|
2022-10-27 16:18:54 +02:00
|
|
|
public List<ItemFieldsResponse> getConfigListOfFieldsForSearching() throws Exception {
|
2022-10-12 17:12:09 +02:00
|
|
|
LOG.info("listOfFieldsForSearching called");
|
|
|
|
|
|
|
|
try {
|
|
|
|
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
|
2022-11-09 14:35:37 +01:00
|
|
|
new GeoportalServiceIdentityProxy(this.getThreadLocalRequest());
|
2022-10-17 16:52:22 +02:00
|
|
|
List<ItemFieldsResponse> listIFResponse = new ArrayList<ItemFieldsResponse>();
|
2022-10-12 17:12:09 +02:00
|
|
|
|
2022-10-27 16:18:54 +02:00
|
|
|
List<String> handlersIds = Arrays.asList(GEOPORTAL_DATA_HANDLER.geoportal_basic_data_list.getId());
|
2022-10-12 17:12:09 +02:00
|
|
|
List<UseCaseDescriptor> listUseCaseDescriptor;
|
|
|
|
try {
|
|
|
|
UseCaseDescriptorCaller client = GeoportalClientCaller.useCaseDescriptors();
|
|
|
|
listUseCaseDescriptor = client.getListForHandlerIds(handlersIds);
|
|
|
|
} catch (Exception e) {
|
|
|
|
LOG.error("Error on reading handlerIds: " + handlersIds + ", in the UCDs", e);
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (listUseCaseDescriptor == null) {
|
|
|
|
listUseCaseDescriptor = new ArrayList<UseCaseDescriptor>();
|
|
|
|
}
|
|
|
|
|
|
|
|
for (UseCaseDescriptor ucd : listUseCaseDescriptor) {
|
|
|
|
UseCaseDescriptorDV ucdDV = ConvertToDataValueObjectModel.toUseCaseDescriptorDV(ucd, null);
|
2022-10-27 16:18:54 +02:00
|
|
|
|
2022-10-12 17:12:09 +02:00
|
|
|
HandlerDeclarationDV dataListHandler = getHandlerDeclarationFor(ucdDV,
|
2022-10-27 16:18:54 +02:00
|
|
|
GEOPORTAL_DATA_HANDLER.geoportal_basic_data_list);
|
2022-10-12 17:12:09 +02:00
|
|
|
|
|
|
|
if (dataListHandler != null) {
|
|
|
|
ConfigurationDV<?> config = dataListHandler.getConfiguration();
|
|
|
|
switch (config.getConfigurationType()) {
|
|
|
|
case item_fields:
|
2022-10-17 16:52:22 +02:00
|
|
|
ItemFieldsResponse ifResponse = new ItemFieldsResponse();
|
|
|
|
ifResponse.setUseCaseDescriptorDV(ucdDV);
|
2022-10-12 17:12:09 +02:00
|
|
|
List<ItemFieldDV> listItemFields = (List<ItemFieldDV>) config.getConfiguration();
|
2022-10-17 16:52:22 +02:00
|
|
|
ifResponse.setListItemFields(listItemFields);
|
|
|
|
listIFResponse.add(ifResponse);
|
2022-10-12 17:12:09 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2022-10-17 16:52:22 +02:00
|
|
|
LOG.info("listOfFieldsForSearching returning: " + listIFResponse);
|
|
|
|
return listIFResponse;
|
2022-10-12 17:12:09 +02:00
|
|
|
} catch (Exception e) {
|
|
|
|
LOG.error("Error on loading list of fields for searching: ", e);
|
|
|
|
throw new Exception("Error occurred on loading list of fields for searching. Error: " + e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-18 14:17:41 +02:00
|
|
|
/**
|
|
|
|
* Gets the handler declaration for.
|
|
|
|
*
|
|
|
|
* @param useCaseDescriptor the use case descriptor
|
|
|
|
* @param dataHandler the data handler
|
|
|
|
* @return the handler declaration for
|
|
|
|
*/
|
2022-10-12 17:12:09 +02:00
|
|
|
public static HandlerDeclarationDV getHandlerDeclarationFor(UseCaseDescriptorDV useCaseDescriptor,
|
|
|
|
GEOPORTAL_DATA_HANDLER dataHandler) {
|
|
|
|
|
|
|
|
if (useCaseDescriptor == null)
|
|
|
|
return null;
|
|
|
|
|
|
|
|
for (HandlerDeclarationDV handler : useCaseDescriptor.getHandlers()) {
|
|
|
|
GEOPORTAL_DATA_HANDLER dataHandlerType = handler.getDataHandlerType();
|
|
|
|
|
|
|
|
if (dataHandlerType != null && dataHandlerType.equals(dataHandler)) {
|
|
|
|
return handler;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-10-18 14:17:41 +02:00
|
|
|
/**
|
|
|
|
* Inits the.
|
|
|
|
*
|
|
|
|
* @param config the config
|
|
|
|
* @throws ServletException the servlet exception
|
|
|
|
*/
|
2022-10-12 17:12:09 +02:00
|
|
|
@Override
|
|
|
|
public void init(ServletConfig config) throws ServletException {
|
|
|
|
super.init(config);
|
|
|
|
LOG.info("init called");
|
|
|
|
// Init one GcubeProfilesPerUCDIdCache for the application
|
|
|
|
new GcubeProfilesPerUCDIdCache();
|
|
|
|
}
|
|
|
|
|
2022-10-18 14:17:41 +02:00
|
|
|
/**
|
|
|
|
* On before request deserialized.
|
|
|
|
*
|
|
|
|
* @param serializedRequest the serialized request
|
|
|
|
*/
|
2022-10-12 17:12:09 +02:00
|
|
|
@Override
|
|
|
|
protected void onBeforeRequestDeserialized(String serializedRequest) {
|
|
|
|
LOG.info("onBeforeRequestDeserialized called");
|
|
|
|
String scope = "";
|
2022-10-18 14:17:41 +02:00
|
|
|
|
2022-10-12 17:12:09 +02:00
|
|
|
try {
|
2022-10-12 11:13:40 +02:00
|
|
|
new GeoportalServiceIdentityProxy(this.getThreadLocalRequest());
|
2022-10-12 17:12:09 +02:00
|
|
|
scope = SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
|
|
|
|
// Loading GcubeProfilesPerUCDIdCache per scope
|
2022-10-12 11:13:40 +02:00
|
|
|
GcubeProfilesPerUCDIdCache.get(scope);
|
|
|
|
} catch (Exception e) {
|
2022-10-12 17:12:09 +02:00
|
|
|
LOG.error("Error on loading the " + GcubeProfilesPerUCDIdCache.class.getSimpleName() + " for scope: "
|
|
|
|
+ scope, e);
|
2022-10-12 11:13:40 +02:00
|
|
|
}
|
2022-10-12 17:12:09 +02:00
|
|
|
super.onBeforeRequestDeserialized(serializedRequest);
|
|
|
|
}
|
|
|
|
|
2021-12-07 17:13:20 +01:00
|
|
|
/**
|
2022-10-12 17:12:09 +02:00
|
|
|
* Gets the list projects.
|
2021-12-07 17:13:20 +01:00
|
|
|
*
|
2022-10-12 17:12:09 +02:00
|
|
|
* @param theProfileID the the profile ID
|
2021-12-21 16:52:35 +01:00
|
|
|
* @param start the start
|
|
|
|
* @param limit the limit
|
|
|
|
* @param filter the filter
|
2021-12-07 17:13:20 +01:00
|
|
|
* @param reloadFromService the reload from service
|
2022-10-12 17:12:09 +02:00
|
|
|
* @return the list projects
|
2021-12-07 17:13:20 +01:00
|
|
|
* @throws Exception the exception
|
|
|
|
*/
|
|
|
|
@Override
|
2022-10-12 17:12:09 +02:00
|
|
|
public ResultSetPaginatedData getListProjects(String theProfileID, Integer start, Integer limit,
|
|
|
|
SearchingFilter filter, boolean reloadFromService) throws Exception {
|
|
|
|
LOG.info("getListProjects called with profileID: " + theProfileID + ", start: " + start + ", limit: " + limit
|
|
|
|
+ ", filter: " + filter);
|
2021-12-07 17:13:20 +01:00
|
|
|
|
|
|
|
try {
|
|
|
|
|
2022-10-12 17:12:09 +02:00
|
|
|
ProjectsCaller client = GeoportalClientCaller.projects();
|
|
|
|
SessionUtil.getCurrentContext(getThreadLocalRequest(), true);
|
|
|
|
|
|
|
|
Integer totalProjectForProfile = SessionUtil.getTotalDocumentForProfileID(getThreadLocalRequest(),
|
|
|
|
theProfileID);
|
|
|
|
|
|
|
|
if (totalProjectForProfile == null) {
|
|
|
|
totalProjectForProfile = client.getTotalDocument(theProfileID);
|
|
|
|
SessionUtil.setTotalDocumentForProfileID(getThreadLocalRequest(), theProfileID, totalProjectForProfile);
|
|
|
|
}
|
|
|
|
|
|
|
|
LOG.info("Total Docs read from config: " + totalProjectForProfile);
|
|
|
|
|
|
|
|
Iterator<Project> projects = client.queryOnMongo(theProfileID, totalProjectForProfile, start, limit,
|
|
|
|
filter);
|
|
|
|
|
|
|
|
ResultSetPaginatedData searchedData = new ResultSetPaginatedData(start, limit, false);
|
|
|
|
searchedData.setTotalItems(totalProjectForProfile);
|
|
|
|
|
|
|
|
List<ResultDocumentDV> toReturnList = ConvertToDataValueObjectModel.toListResultDocument(projects);
|
|
|
|
|
|
|
|
searchedData.setData(toReturnList);
|
|
|
|
|
|
|
|
// TODO BUGGY WORKAROUND. BLOCKED BY #22487 IT MUST BE REMOVE AFTER THE QUERY
|
|
|
|
// COUNT
|
|
|
|
// AND LIST.SIZE BY QUERY WILL BE AVAILABLE IN THE SERVICE
|
|
|
|
if (filter.getConditions() != null) {
|
|
|
|
searchedData.setTotalItems(toReturnList.size());
|
|
|
|
int totalItems = toReturnList.size();
|
|
|
|
searchedData.setTotalItems(totalItems);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (totalProjectForProfile == limit || totalProjectForProfile == 0) {
|
|
|
|
LOG.debug("Page completed returning " + totalProjectForProfile + " projects");
|
|
|
|
int newOffset = start + limit;
|
|
|
|
searchedData.setServerSearchFinished(newOffset > totalProjectForProfile || totalProjectForProfile == 0);
|
|
|
|
LOG.debug("is Search finished: " + searchedData.isServerSearchFinished());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (LOG.isDebugEnabled()) {
|
|
|
|
LOG.debug("returning {}", searchedData.getData());
|
|
|
|
}
|
|
|
|
|
|
|
|
List<? extends DocumentDV> data = searchedData.getData();
|
|
|
|
if (data != null) {
|
|
|
|
LOG.info("returning {} project/s", data.size());
|
|
|
|
}
|
|
|
|
|
|
|
|
return searchedData;
|
2021-12-07 17:13:20 +01:00
|
|
|
|
|
|
|
} catch (Exception e) {
|
2022-10-12 17:12:09 +02:00
|
|
|
LOG.error("Error on loading paginated and filtered list of projects for id: ", e);
|
2021-12-07 17:13:20 +01:00
|
|
|
throw new Exception("Error occurred on loading list of Concessioni. Error: " + e.getMessage());
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-10-11 15:00:39 +02:00
|
|
|
/**
|
|
|
|
* Gets the layers for id.
|
|
|
|
*
|
2022-10-18 14:17:41 +02:00
|
|
|
* @param profileID the profile ID
|
|
|
|
* @param projectID the project ID
|
2022-10-11 15:00:39 +02:00
|
|
|
* @return the layers for id
|
|
|
|
* @throws Exception the exception
|
|
|
|
*/
|
|
|
|
@Override
|
2022-10-18 14:17:41 +02:00
|
|
|
public List<GCubeSDIViewerLayerDV> getLayersForId(String profileID, String projectID) throws Exception {
|
|
|
|
LOG.info("getLayersForId [profileID: " + profileID + ", projectID: " + projectID + "] called");
|
2022-10-11 15:00:39 +02:00
|
|
|
|
2022-10-18 14:17:41 +02:00
|
|
|
if (profileID == null)
|
|
|
|
throw new Exception("Invalid parameter. The profileID is null");
|
2022-10-11 15:00:39 +02:00
|
|
|
|
2022-10-18 14:17:41 +02:00
|
|
|
if (projectID == null)
|
|
|
|
throw new Exception("Invalid parameter. The projectID is null");
|
|
|
|
|
|
|
|
List<GCubeSDIViewerLayerDV> listLayers = null;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
|
|
|
|
try {
|
|
|
|
SessionUtil.getCurrentUser(this.getThreadLocalRequest()).getUsername();
|
|
|
|
} catch (Exception e) {
|
|
|
|
LOG.info("User not found in session, the userName for cecking policy will be null");
|
|
|
|
}
|
|
|
|
|
|
|
|
LOG.info("Trying to get project for id " + profileID);
|
|
|
|
|
|
|
|
new GeoportalServiceIdentityProxy(this.getThreadLocalRequest());
|
|
|
|
Project theProject = GeoportalClientCaller.projects().getProjectByID(profileID, projectID);
|
|
|
|
String jsonDocument = theProject.getTheDocument().toJson();
|
|
|
|
LOG.trace("JSON Project is: " + jsonDocument);
|
|
|
|
|
2022-10-19 17:51:13 +02:00
|
|
|
String materializationParentJSONPath = String.format("%s..%s", Geoportal_JSON_Mapper.JSON_$_POINTER,
|
|
|
|
Geoportal_JSON_Mapper.FILESET);
|
2022-10-18 14:17:41 +02:00
|
|
|
|
2022-10-19 17:51:13 +02:00
|
|
|
listLayers = Geoportal_JSON_Mapper.readGcubeSDILayersForFileset(materializationParentJSONPath,
|
|
|
|
jsonDocument);
|
2022-10-18 14:17:41 +02:00
|
|
|
|
|
|
|
LOG.info("For projectID " + projectID + ", returning " + listLayers.size() + " layer/s");
|
|
|
|
return listLayers;
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
String erroMsg = "Layers are not available for profileID " + profileID + " with projectID " + projectID;
|
|
|
|
LOG.error(erroMsg, e);
|
|
|
|
throw new Exception(erroMsg);
|
|
|
|
}
|
2022-10-11 15:00:39 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-10-25 17:01:24 +02:00
|
|
|
/**
|
|
|
|
* Gets the images for id.
|
|
|
|
*
|
|
|
|
* @param profileID the profile ID
|
|
|
|
* @param projectID the project ID
|
|
|
|
* @param limitToFirstOneFound the limit to first one found
|
|
|
|
* @return the images for id
|
|
|
|
* @throws Exception the exception
|
|
|
|
*/
|
2022-10-25 11:35:03 +02:00
|
|
|
protected List<PayloadDV> getImagesForId(String profileID, String projectID, boolean limitToFirstOneFound)
|
|
|
|
throws Exception {
|
|
|
|
LOG.info("getImagesForId [profileID: " + profileID + ", projectID: " + projectID + ", limitToFirstOneFound: "
|
|
|
|
+ limitToFirstOneFound + "] called");
|
2022-10-19 17:51:13 +02:00
|
|
|
|
|
|
|
if (profileID == null)
|
|
|
|
throw new Exception("Invalid parameter. The profileID is null");
|
|
|
|
|
|
|
|
if (projectID == null)
|
|
|
|
throw new Exception("Invalid parameter. The projectID is null");
|
|
|
|
|
|
|
|
List<PayloadDV> listImages = null;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
|
|
|
|
try {
|
|
|
|
SessionUtil.getCurrentUser(this.getThreadLocalRequest()).getUsername();
|
|
|
|
} catch (Exception e) {
|
|
|
|
LOG.info("User not found in session, the userName for cecking policy will be null");
|
|
|
|
}
|
|
|
|
|
|
|
|
LOG.info("Trying to get project for id " + profileID);
|
|
|
|
|
|
|
|
new GeoportalServiceIdentityProxy(this.getThreadLocalRequest());
|
|
|
|
Project theProject = GeoportalClientCaller.projects().getProjectByID(profileID, projectID);
|
|
|
|
String jsonDocument = theProject.getTheDocument().toJson();
|
|
|
|
LOG.trace("JSON Project is: " + jsonDocument);
|
2022-10-20 18:01:54 +02:00
|
|
|
|
|
|
|
String filesetJSONPath = String.format("%s..%s", Geoportal_JSON_Mapper.JSON_$_POINTER,
|
|
|
|
Geoportal_JSON_Mapper.FILESET);
|
2022-10-19 17:51:13 +02:00
|
|
|
|
2022-10-25 11:35:03 +02:00
|
|
|
listImages = Geoportal_JSON_Mapper.readImagesForFileset(filesetJSONPath, jsonDocument,
|
|
|
|
limitToFirstOneFound);
|
2022-10-19 17:51:13 +02:00
|
|
|
|
|
|
|
LOG.info("For projectID " + projectID + ", returning " + listImages.size() + " image/s");
|
|
|
|
return listImages;
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
String erroMsg = "Images are not available for profileID " + profileID + " with projectID " + projectID;
|
|
|
|
LOG.error(erroMsg, e);
|
|
|
|
throw new Exception(erroMsg);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-10-11 15:00:39 +02:00
|
|
|
/**
|
|
|
|
* Gets the project view for id.
|
|
|
|
*
|
|
|
|
* @param profileID the profile ID
|
|
|
|
* @param projectID the project ID
|
|
|
|
* @return the project view for id
|
|
|
|
* @throws Exception the exception
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public ProjectView getProjectViewForId(String profileID, String projectID) throws Exception {
|
2022-11-04 17:16:37 +01:00
|
|
|
LOG.info("getProjectViewForId profileID: " + profileID + ", projectID: " + projectID + ", called");
|
2022-10-11 15:00:39 +02:00
|
|
|
|
|
|
|
if (profileID == null || projectID == null)
|
|
|
|
throw new Exception("Invalid parameter. Either profileID or projectID is null");
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
2022-10-12 11:13:40 +02:00
|
|
|
String scope = SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
|
2022-10-11 15:00:39 +02:00
|
|
|
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");
|
|
|
|
}
|
|
|
|
|
|
|
|
LOG.info("Trying to get project for id " + profileID);
|
|
|
|
|
2022-10-18 14:17:41 +02:00
|
|
|
new GeoportalServiceIdentityProxy(this.getThreadLocalRequest());
|
2022-11-08 17:56:36 +01:00
|
|
|
|
|
|
|
UseCaseDescriptor ucd = SessionUtil.getUCDForId(this.getThreadLocalRequest(), profileID);
|
|
|
|
|
|
|
|
if (ucd == null) {
|
|
|
|
ucd = GeoportalClientCaller.useCaseDescriptors().getUCDForId(profileID);
|
|
|
|
SessionUtil.setUCDForId(this.getThreadLocalRequest(), profileID, ucd);
|
|
|
|
}
|
|
|
|
|
2022-10-18 14:17:41 +02:00
|
|
|
Project theProject = GeoportalClientCaller.projects().getProjectByID(profileID, projectID);
|
2022-10-25 11:35:03 +02:00
|
|
|
|
2022-10-18 14:17:41 +02:00
|
|
|
ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(true);
|
2022-10-18 17:32:12 +02:00
|
|
|
projectBuilder.relationships(true);
|
2022-10-18 14:17:41 +02:00
|
|
|
ProjectDV theProjectDV = ConvertToDataValueObjectModel.toProjectDV(theProject, projectBuilder);
|
2022-10-17 16:52:22 +02:00
|
|
|
theProjectDV.setProfileName(ucd.getName());
|
2022-10-11 15:00:39 +02:00
|
|
|
|
2022-11-16 16:42:12 +01:00
|
|
|
TemporalReferenceDV temporalReference = temporalReferenceForProject(theProject);
|
|
|
|
if (temporalReference == null)
|
|
|
|
temporalReference = new TemporalReferenceDV();
|
|
|
|
theProjectDV.setTemporalReference(temporalReference);
|
|
|
|
|
2022-10-14 15:31:32 +02:00
|
|
|
ProjectView projectView = Geoportal_JSON_Mapper.loadProjectView(theProjectDV, scope, userName);
|
|
|
|
|
2022-10-25 17:01:24 +02:00
|
|
|
if (LOG.isTraceEnabled()) {
|
2022-10-14 15:31:32 +02:00
|
|
|
Geoportal_JSON_Mapper.prettyPrintProjectView(projectView);
|
|
|
|
}
|
2022-10-11 15:00:39 +02:00
|
|
|
|
2022-11-16 16:42:12 +01:00
|
|
|
LOG.info("returning project view for id: " + projectView.getTheProjectDV().getId());
|
|
|
|
return projectView;
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
String erroMsg = "Error occurred on creating projectView for id: " + projectID;
|
|
|
|
LOG.error(erroMsg, e);
|
|
|
|
throw new Exception(erroMsg);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the project edit for id.
|
|
|
|
*
|
|
|
|
* @param profileID the profile ID
|
|
|
|
* @param projectID the project ID
|
|
|
|
* @return the project edit for id
|
|
|
|
* @throws Exception the exception
|
|
|
|
*/
|
|
|
|
public ProjectView getProjectEditForId(String profileID, String projectID) throws Exception {
|
|
|
|
LOG.info("getProjectEditForId profileID: " + profileID + ", projectID: " + projectID + ", called");
|
|
|
|
|
|
|
|
if (profileID == null || projectID == null)
|
|
|
|
throw new Exception("Invalid parameter. Either profileID or projectID is null");
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
String scope = 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");
|
|
|
|
}
|
|
|
|
|
|
|
|
LOG.info("Trying to get project for id " + profileID);
|
|
|
|
|
|
|
|
new GeoportalServiceIdentityProxy(this.getThreadLocalRequest());
|
|
|
|
|
|
|
|
UseCaseDescriptor ucd = SessionUtil.getUCDForId(this.getThreadLocalRequest(), profileID);
|
|
|
|
|
|
|
|
if (ucd == null) {
|
|
|
|
ucd = GeoportalClientCaller.useCaseDescriptors().getUCDForId(profileID);
|
|
|
|
SessionUtil.setUCDForId(this.getThreadLocalRequest(), profileID, ucd);
|
|
|
|
}
|
|
|
|
|
|
|
|
Project theProject = GeoportalClientCaller.projects().getProjectByID(profileID, projectID);
|
|
|
|
|
|
|
|
ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(true);
|
|
|
|
projectBuilder.relationships(true);
|
|
|
|
ProjectDV theProjectDV = ConvertToDataValueObjectModel.toProjectDV(theProject, projectBuilder);
|
|
|
|
theProjectDV.setProfileName(ucd.getName());
|
|
|
|
|
|
|
|
ProjectView projectView = Geoportal_JSON_Mapper.loadProjectView(theProjectDV, scope, userName);
|
|
|
|
|
|
|
|
if (LOG.isTraceEnabled()) {
|
|
|
|
Geoportal_JSON_Mapper.prettyPrintProjectView(projectView);
|
|
|
|
}
|
2022-11-11 16:30:20 +01:00
|
|
|
|
2022-10-13 16:53:33 +02:00
|
|
|
LOG.info("returning project view for id: " + projectView.getTheProjectDV().getId());
|
|
|
|
return projectView;
|
2022-10-11 15:00:39 +02:00
|
|
|
|
2022-10-13 16:53:33 +02:00
|
|
|
} catch (Exception e) {
|
|
|
|
String erroMsg = "Error occurred on creating projectView for id: " + projectID;
|
|
|
|
LOG.error(erroMsg, e);
|
|
|
|
throw new Exception(erroMsg);
|
|
|
|
}
|
2022-10-11 15:00:39 +02:00
|
|
|
|
2022-10-13 16:53:33 +02:00
|
|
|
}
|
2022-10-11 15:00:39 +02:00
|
|
|
|
2022-10-19 17:51:13 +02:00
|
|
|
/**
|
|
|
|
* Gets the data result.
|
|
|
|
*
|
|
|
|
* @param layerObjects the layer objects
|
|
|
|
* @param mapSrsName the map srs name
|
|
|
|
* @param selectBBOX the select BBOX
|
|
|
|
* @param maxWFSFeature the max WFS feature
|
|
|
|
* @param zoomLevel the zoom level
|
|
|
|
* @return the data result
|
2022-10-27 16:18:54 +02:00
|
|
|
* @throws Exception the exception
|
2022-10-19 17:51:13 +02:00
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public List<GeoNaSpatialQueryResult> getDataResult(List<LayerObject> layerObjects, String mapSrsName,
|
2022-10-25 17:01:24 +02:00
|
|
|
BoundsMap selectBBOX, int maxWFSFeature, double zoomLevel) throws Exception {
|
2022-10-19 17:51:13 +02:00
|
|
|
LOG.info("getDataResult called for layerObjects: " + layerObjects);
|
|
|
|
if (LOG.isDebugEnabled()) {
|
|
|
|
LOG.info("getDataResult parmeters layerObjects: " + layerObjects,
|
|
|
|
", mapSrsName: " + mapSrsName + ", selectBBOX: " + selectBBOX + ", maxWFSFeature: " + maxWFSFeature
|
|
|
|
+ ", zoomLevel: " + zoomLevel);
|
|
|
|
}
|
2022-10-27 15:09:07 +02:00
|
|
|
|
2022-10-19 17:51:13 +02:00
|
|
|
List<GeoNaSpatialQueryResult> listDAO = new ArrayList<GeoNaSpatialQueryResult>(layerObjects.size());
|
|
|
|
|
2022-10-25 17:01:24 +02:00
|
|
|
try {
|
|
|
|
new GeoportalServiceIdentityProxy(this.getThreadLocalRequest());
|
|
|
|
|
|
|
|
for (LayerObject layerObject : layerObjects) {
|
|
|
|
GeoNaSpatialQueryResult geoDAO = new GeoNaSpatialQueryResult();
|
|
|
|
List<FeatureRow> features = FeatureParser.getWFSFeatures(layerObject.getLayerItem(), mapSrsName,
|
|
|
|
selectBBOX, maxWFSFeature);
|
|
|
|
LOG.debug("For layer name: " + layerObject.getLayerItem().getName() + " got features: " + features);
|
|
|
|
geoDAO.setFeatures(features);
|
|
|
|
|
|
|
|
if (features != null && features.size() > 0) {
|
|
|
|
|
|
|
|
LayerObjectType loType = layerObject.getType();
|
|
|
|
if (loType == null)
|
|
|
|
loType = LayerObjectType.GENERIC_LAYER;
|
|
|
|
|
|
|
|
switch (layerObject.getType()) {
|
|
|
|
case INDEX_LAYER: {
|
|
|
|
|
|
|
|
// Expected 1 feature
|
|
|
|
FeatureRow fRow = features.get(0);
|
|
|
|
if (fRow.getMapProperties() != null) {
|
|
|
|
List<String> productIDs = fRow.getMapProperties()
|
|
|
|
.get(GeoportalDataViewerConstants.PROJECT_ID_KEY_FEATURE);
|
|
|
|
if (productIDs != null && productIDs.size() > 0) {
|
|
|
|
String projectID = productIDs.get(0);
|
|
|
|
layerObject.setProjectID(projectID);
|
|
|
|
String profileID = layerObject.getProfileID();
|
|
|
|
|
|
|
|
List<PayloadDV> images;
|
|
|
|
// Loading images for profileID and projectID
|
|
|
|
try {
|
2022-11-07 17:58:06 +01:00
|
|
|
|
2022-10-25 17:01:24 +02:00
|
|
|
images = getImagesForId(profileID, projectID, true);
|
|
|
|
|
|
|
|
Map<String, List<PayloadDV>> mapImages = new LinkedHashMap<String, List<PayloadDV>>();
|
|
|
|
mapImages.put(projectID, images);
|
|
|
|
// mapImages.put(cId, listUI);
|
|
|
|
geoDAO.setMapImages(mapImages);
|
|
|
|
} catch (Exception e) {
|
|
|
|
LOG.warn("Error on loading images for projectID: " + projectID + " profileID: "
|
|
|
|
+ profileID);
|
|
|
|
}
|
2022-10-19 17:51:13 +02:00
|
|
|
|
2022-10-25 17:01:24 +02:00
|
|
|
// Sets only profileID and profileName into ProjectDV
|
2022-11-07 17:58:06 +01:00
|
|
|
if (layerObject.getProjectDV() == null
|
|
|
|
|| layerObject.getProjectDV().getTheDocument() == null) {
|
|
|
|
ProjectDV projectDV = minimalProjectDV(profileID, projectID, true, 2);
|
2022-10-25 17:01:24 +02:00
|
|
|
layerObject.setProjectDV(projectDV);
|
|
|
|
}
|
2022-11-16 16:42:12 +01:00
|
|
|
|
|
|
|
if (layerObject.getProjectDV().getTemporalReference() == null) {
|
|
|
|
Project theProject = GeoportalClientCaller.projects().getProjectByID(profileID,
|
|
|
|
projectID);
|
|
|
|
TemporalReferenceDV temporalReferenceDV = temporalReferenceForProject(theProject);
|
|
|
|
// Empty TemporalReferenceDV
|
|
|
|
if (temporalReferenceDV == null)
|
|
|
|
temporalReferenceDV = new TemporalReferenceDV();
|
|
|
|
|
|
|
|
layerObject.getProjectDV().setTemporalReference(temporalReferenceDV);
|
|
|
|
}
|
|
|
|
|
2022-10-25 17:01:24 +02:00
|
|
|
}
|
|
|
|
}
|
2022-10-20 18:01:54 +02:00
|
|
|
|
2022-10-25 17:01:24 +02:00
|
|
|
geoDAO.setSourceLayerObject(layerObject);
|
|
|
|
LOG.info("For layer name: " + layerObject.getLayerItem().getName() + " got " + features.size()
|
|
|
|
+ " feature/s");
|
|
|
|
listDAO.add(geoDAO);
|
2022-10-20 18:01:54 +02:00
|
|
|
|
2022-10-25 17:01:24 +02:00
|
|
|
break;
|
|
|
|
}
|
2022-10-19 17:51:13 +02:00
|
|
|
|
2022-10-25 17:01:24 +02:00
|
|
|
case PROJECT_LAYER:
|
|
|
|
case GENERIC_LAYER: {
|
|
|
|
LOG.debug("The LayerObject is a of kind: " + layerObject.getType());
|
|
|
|
// TODO CHECK THIS
|
|
|
|
// Getting the projectid from WFS features, but limiting to the first one, Do we
|
|
|
|
// have more than one centroid in the same position??
|
2022-10-25 11:35:03 +02:00
|
|
|
|
2022-10-25 17:01:24 +02:00
|
|
|
// Mininal set of info for displaying into popup
|
|
|
|
if (layerObject.getProjectDV() == null) {
|
2022-10-27 15:09:07 +02:00
|
|
|
ProjectDV projectDV = minimalProjectDV(layerObject.getProfileID(),
|
2022-11-07 17:58:06 +01:00
|
|
|
layerObject.getProjectID(), false, 0);
|
2022-10-25 17:01:24 +02:00
|
|
|
layerObject.setProjectDV(projectDV);
|
|
|
|
}
|
2022-10-27 16:18:54 +02:00
|
|
|
|
|
|
|
if (layerObject.getProjectDV().getSpatialReference() == null) {
|
2022-10-27 15:09:07 +02:00
|
|
|
GeoJSON geoJson = spatialReference(layerObject.getProfileID(), layerObject.getProjectID());
|
|
|
|
layerObject.getProjectDV().setSpatialReference(geoJson);
|
|
|
|
}
|
2022-10-25 17:01:24 +02:00
|
|
|
|
|
|
|
if (layerObject.getProjectDV().getTheDocument() == null) {
|
2022-10-20 18:01:54 +02:00
|
|
|
try {
|
2022-10-19 17:51:13 +02:00
|
|
|
|
2022-10-25 17:01:24 +02:00
|
|
|
LinkedHashMap<String, Object> documentAsMap = getEntrySetsDocumentForProjectID(
|
|
|
|
layerObject.getProfileID(), layerObject.getProjectID(), 1);
|
|
|
|
DocumentDV documentDV = new DocumentDV();
|
|
|
|
documentDV.setDocumentAsMap(documentAsMap);
|
|
|
|
layerObject.getProjectDV().setTheDocument(documentDV);
|
2022-10-20 18:01:54 +02:00
|
|
|
} catch (Exception e) {
|
2022-10-25 17:01:24 +02:00
|
|
|
String erroMsg = "Error occurred on loading document for profileID "
|
|
|
|
+ layerObject.getProfileID() + " and projectID " + layerObject.getProjectID();
|
|
|
|
LOG.warn(erroMsg, e);
|
2022-10-20 18:01:54 +02:00
|
|
|
}
|
2022-10-25 17:01:24 +02:00
|
|
|
}
|
2022-10-25 11:35:03 +02:00
|
|
|
|
2022-11-16 16:42:12 +01:00
|
|
|
if (layerObject.getProjectDV().getTemporalReference() == null) {
|
|
|
|
Project theProject = GeoportalClientCaller.projects()
|
|
|
|
.getProjectByID(layerObject.getProfileID(), layerObject.getProjectID());
|
|
|
|
TemporalReferenceDV temporalReferenceDV = temporalReferenceForProject(theProject);
|
|
|
|
// Empty TemporalReferenceDV
|
|
|
|
if (temporalReferenceDV == null)
|
|
|
|
temporalReferenceDV = new TemporalReferenceDV();
|
|
|
|
|
|
|
|
layerObject.getProjectDV().setTemporalReference(temporalReferenceDV);
|
|
|
|
}
|
|
|
|
|
2022-10-25 17:01:24 +02:00
|
|
|
LOG.debug("Case PROJECT_LAYER/GENERIC_LAYER setting layerObject: " + layerObject);
|
|
|
|
geoDAO.setSourceLayerObject(layerObject);
|
|
|
|
LOG.info("For layer name: " + layerObject.getLayerItem().getName() + " got " + features.size()
|
|
|
|
+ " feature/s");
|
|
|
|
listDAO.add(geoDAO);
|
2022-10-25 11:35:03 +02:00
|
|
|
|
2022-10-20 18:01:54 +02:00
|
|
|
}
|
|
|
|
|
2022-10-25 17:01:24 +02:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2022-10-19 17:51:13 +02:00
|
|
|
|
2022-10-20 18:01:54 +02:00
|
|
|
}
|
2022-10-25 17:01:24 +02:00
|
|
|
}
|
2022-10-25 11:35:03 +02:00
|
|
|
|
2022-10-25 17:01:24 +02:00
|
|
|
} catch (Exception e) {
|
|
|
|
String erroMsg = "Error occurred on getting data results";
|
|
|
|
LOG.error(erroMsg, e);
|
|
|
|
throw new Exception(erroMsg);
|
|
|
|
}
|
2022-10-27 15:09:07 +02:00
|
|
|
|
2022-10-25 17:01:24 +02:00
|
|
|
LOG.info("returning " + listDAO + " geona data objects");
|
|
|
|
return listDAO;
|
|
|
|
}
|
|
|
|
|
2022-10-27 16:18:54 +02:00
|
|
|
/**
|
|
|
|
* Minimal project DV.
|
|
|
|
*
|
2022-11-16 16:42:12 +01:00
|
|
|
* @param profileID the profile ID
|
|
|
|
* @param projectID the project ID
|
|
|
|
* @param loadDocument the load document
|
|
|
|
* @param limitDocumentEntries the limit document entries
|
2022-10-27 16:18:54 +02:00
|
|
|
* @return the project DV
|
|
|
|
*/
|
2022-11-07 17:58:06 +01:00
|
|
|
private ProjectDV minimalProjectDV(String profileID, String projectID, boolean loadDocument,
|
|
|
|
int limitDocumentEntries) {
|
|
|
|
LOG.debug("called minimalProjectDV for profileID: " + profileID + ", projectID: " + projectID
|
|
|
|
+ ", loadDocument: " + loadDocument + ", limitDocumentEntries: " + limitDocumentEntries);
|
2022-10-25 17:01:24 +02:00
|
|
|
|
|
|
|
QueryRequest request = new QueryRequest();
|
|
|
|
request.setFilter(
|
|
|
|
Document.parse("{\"" + UseCaseDescriptor.ID + "\" : " + "{\"$eq\" : \"" + profileID + "\"}}"));
|
|
|
|
request.setProjection(Document.parse("{\"" + UseCaseDescriptor.NAME + "\" : " + "1}"));
|
|
|
|
ProjectDV projectDV = new ProjectDV();
|
2022-10-25 11:35:03 +02:00
|
|
|
|
2022-10-25 17:01:24 +02:00
|
|
|
try {
|
2022-11-08 17:56:36 +01:00
|
|
|
new GeoportalServiceIdentityProxy(this.getThreadLocalRequest());
|
2022-11-16 16:42:12 +01:00
|
|
|
|
2022-10-25 17:01:24 +02:00
|
|
|
useCaseDescriptors().build().query(request).forEachRemaining(u -> {
|
|
|
|
try {
|
|
|
|
LOG.debug("UCD for id" + u.getId() + " returend name: " + u.getName());
|
2022-10-20 18:01:54 +02:00
|
|
|
|
2022-10-25 17:01:24 +02:00
|
|
|
projectDV.setId(projectID);
|
|
|
|
projectDV.setProfileName(u.getName());
|
|
|
|
projectDV.setProfileID(u.getId());
|
|
|
|
} catch (Exception e) {
|
|
|
|
LOG.warn("Invalid UCD, UCID : " + u.getId());
|
2022-10-20 18:01:54 +02:00
|
|
|
}
|
2022-10-25 17:01:24 +02:00
|
|
|
});
|
2022-11-07 17:58:06 +01:00
|
|
|
|
|
|
|
if (loadDocument) {
|
|
|
|
LinkedHashMap<String, Object> theDocument = getEntrySetsDocumentForProjectID(profileID, projectID,
|
|
|
|
limitDocumentEntries);
|
|
|
|
DocumentDV docDV = new DocumentDV();
|
|
|
|
docDV.setDocumentAsMap(theDocument);
|
|
|
|
projectDV.setTheDocument(docDV);
|
|
|
|
}
|
|
|
|
|
2022-10-25 17:01:24 +02:00
|
|
|
} catch (Exception e) {
|
2022-11-07 17:58:06 +01:00
|
|
|
LOG.warn("Error on getting minimalProjectDV of projectID: ", e);
|
2022-10-25 17:01:24 +02:00
|
|
|
}
|
2022-10-20 18:01:54 +02:00
|
|
|
|
2022-11-08 17:56:36 +01:00
|
|
|
LOG.debug("minimalProjectDV returning: " + projectDV);
|
2022-10-25 17:01:24 +02:00
|
|
|
return projectDV;
|
|
|
|
}
|
|
|
|
|
2022-10-27 16:18:54 +02:00
|
|
|
/**
|
|
|
|
* Spatial reference.
|
|
|
|
*
|
|
|
|
* @param profileID the profile ID
|
|
|
|
* @param projectID the project ID
|
|
|
|
* @return the geo JSON
|
|
|
|
*/
|
2022-10-27 15:09:07 +02:00
|
|
|
private GeoJSON spatialReference(String profileID, String projectID) {
|
|
|
|
LOG.trace("spatialReference for profileID: " + profileID + ", projectID: " + projectID + "called");
|
|
|
|
try {
|
2022-11-08 17:56:36 +01:00
|
|
|
new GeoportalServiceIdentityProxy(this.getThreadLocalRequest());
|
2022-10-27 15:09:07 +02:00
|
|
|
List<IdentificationReference> listIR = projects(profileID).build().getById(projectID)
|
|
|
|
.getIdentificationReferenceByType(IdentificationReferencesTYPE.SPATIAL_REFERENCE.getType());
|
|
|
|
if (listIR != null && !listIR.isEmpty()) {
|
|
|
|
String _identificationReferenceString = listIR.get(0).toJson(); // one expected
|
|
|
|
LOG.debug("converting for profileID: " + profileID + ", projectID: " + projectID + "called");
|
|
|
|
return ConvertToDataValueObjectModel.toSpatialReference(_identificationReferenceString);
|
|
|
|
}
|
|
|
|
} catch (Exception e1) {
|
|
|
|
// silent
|
|
|
|
}
|
|
|
|
return new GeoJSON();
|
|
|
|
}
|
|
|
|
|
2022-10-25 17:01:24 +02:00
|
|
|
/**
|
|
|
|
* Gets the entry sets document for project ID.
|
|
|
|
*
|
|
|
|
* @param profileID the profile ID
|
|
|
|
* @param projectID the project ID
|
|
|
|
* @param limit the limit
|
|
|
|
* @return the entry sets document for project ID
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public LinkedHashMap<String, Object> getEntrySetsDocumentForProjectID(String profileID, String projectID,
|
|
|
|
int limit) {
|
2022-11-07 17:58:06 +01:00
|
|
|
LOG.debug("called getEntrySetsDocumentForProjectID for profileID: " + profileID + ", projectID: " + projectID);
|
2022-10-25 17:01:24 +02:00
|
|
|
|
|
|
|
LinkedHashMap<String, Object> documentAsMap = new LinkedHashMap<String, Object>(limit);
|
|
|
|
|
|
|
|
try {
|
2022-11-16 16:42:12 +01:00
|
|
|
|
2022-11-08 17:56:36 +01:00
|
|
|
new GeoportalServiceIdentityProxy(this.getThreadLocalRequest());
|
2022-11-16 16:42:12 +01:00
|
|
|
|
2022-11-08 17:56:36 +01:00
|
|
|
Project theProject = GeoportalClientCaller.projects().getProjectByID(profileID, projectID);
|
|
|
|
|
2022-10-25 17:01:24 +02:00
|
|
|
try {
|
|
|
|
Iterator<Entry<String, Object>> entrySetsIt = theProject.getTheDocument().entrySet().iterator();
|
|
|
|
int i = 0;
|
|
|
|
while (entrySetsIt.hasNext()) {
|
2022-11-08 17:56:36 +01:00
|
|
|
if (i + 1 > limit)
|
2022-10-25 17:01:24 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
Entry<String, Object> entry = entrySetsIt.next();
|
|
|
|
documentAsMap.put(entry.getKey(), entry.getValue());
|
|
|
|
i++;
|
2022-10-19 17:51:13 +02:00
|
|
|
}
|
2022-10-20 18:01:54 +02:00
|
|
|
|
2022-10-25 17:01:24 +02:00
|
|
|
} catch (Exception e) {
|
|
|
|
throw e;
|
2022-10-19 17:51:13 +02:00
|
|
|
}
|
2022-10-25 17:01:24 +02:00
|
|
|
|
2022-11-08 17:56:36 +01:00
|
|
|
/*
|
|
|
|
* QueryRequest request = new QueryRequest();
|
|
|
|
* request.setFilter(Document.parse("{\"" + Project.ID + "\" : " +
|
|
|
|
* "{\"$eq\" : \"" + projectID + "\"}}"));
|
|
|
|
* request.setProjection(Document.parse("{\"" + Project.THE_DOCUMENT + "\" : " +
|
|
|
|
* "1}")); // should be one
|
|
|
|
* projects(profileID).build().query(request).forEachRemaining(p -> { try {
|
|
|
|
* Iterator<Entry<String, Object>> entrySetsIt =
|
|
|
|
* p.getTheDocument().entrySet().iterator(); int i = 0; while
|
|
|
|
* (entrySetsIt.hasNext()) { if (i > limit) break;
|
|
|
|
*
|
|
|
|
* Entry<String, Object> entry = entrySetsIt.next();
|
|
|
|
* documentAsMap.put(entry.getKey(), entry.getValue()); i++; }
|
|
|
|
*
|
|
|
|
* } catch (Exception e) { throw e; } });
|
|
|
|
*/
|
|
|
|
|
|
|
|
LOG.debug("getEntrySetsDocumentForProjectID returning map: " + documentAsMap);
|
2022-10-25 17:01:24 +02:00
|
|
|
return documentAsMap;
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
String erroMsg = "Error occurred on loading EntrySets document for profileID " + profileID
|
|
|
|
+ " and projectID " + projectID;
|
|
|
|
LOG.warn(erroMsg, e);
|
2022-10-19 17:51:13 +02:00
|
|
|
}
|
2022-10-25 17:01:24 +02:00
|
|
|
|
|
|
|
return documentAsMap;
|
2022-10-19 17:51:13 +02:00
|
|
|
}
|
|
|
|
|
2022-11-16 16:42:12 +01:00
|
|
|
/**
|
|
|
|
* Gets the relationships for timeline.
|
|
|
|
*
|
|
|
|
* @param profileID the profile ID
|
|
|
|
* @param projectID the project ID
|
|
|
|
* @return the relationships for timeline
|
|
|
|
* @throws Exception the exception
|
|
|
|
*/
|
2022-11-02 18:05:38 +01:00
|
|
|
@Override
|
|
|
|
public List<String> getRelationshipsForTimeline(String profileID, String projectID) throws Exception {
|
|
|
|
if (profileID == null || projectID == null)
|
|
|
|
throw new Exception("Invalid parameter. Either profileID or projectID is null");
|
|
|
|
|
|
|
|
try {
|
2022-11-03 17:03:15 +01:00
|
|
|
LOG.info("Trying to getRelationshipsForTimeline for id " + profileID);
|
2022-11-02 18:05:38 +01:00
|
|
|
|
2022-11-08 17:56:36 +01:00
|
|
|
new GeoportalServiceIdentityProxy(this.getThreadLocalRequest());
|
2022-11-02 18:05:38 +01:00
|
|
|
List<String> listJSON = new ArrayList<String>();
|
2022-11-08 17:56:36 +01:00
|
|
|
String template = null;
|
2022-11-03 17:03:15 +01:00
|
|
|
try {
|
|
|
|
|
2022-11-08 17:56:36 +01:00
|
|
|
template = SessionUtil.getJSONTimelineTemplate(this.getThreadLocalRequest(), profileID);
|
2022-11-03 17:03:15 +01:00
|
|
|
|
2022-11-08 17:56:36 +01:00
|
|
|
try {
|
2022-11-07 17:58:06 +01:00
|
|
|
|
2022-11-08 17:56:36 +01:00
|
|
|
if (template == null) {
|
2022-11-16 16:42:12 +01:00
|
|
|
Document temporalJsonTemplate = GeoportalClientCaller.useCaseDescriptors()
|
|
|
|
.readTemporalDimensionTemplate(profileID);
|
|
|
|
if (temporalJsonTemplate != null) {
|
|
|
|
template = new Document(temporalJsonTemplate).toJson();
|
|
|
|
LOG.info(UseCaseDescriptorCaller.TIMELINE_CONFIG_TJT_DOCUMENT + " read is: " + template);
|
2022-11-08 17:56:36 +01:00
|
|
|
SessionUtil.setJSONTimelineTemplate(this.getThreadLocalRequest(), profileID, template);
|
|
|
|
}
|
|
|
|
}
|
2022-11-07 17:58:06 +01:00
|
|
|
|
2022-11-08 17:56:36 +01:00
|
|
|
} catch (Exception e) {
|
|
|
|
LOG.warn(GEOPORTAL_DATA_HANDLER.geoportal_timeline_json_template.getType()
|
|
|
|
+ " not found!!! Timeline cannot be available");
|
|
|
|
}
|
|
|
|
// String template = "{\"content\": \"$.nome\"," + "\"title\": \"$.nome\","
|
|
|
|
// + "\"start\" : \"$.dataInizioProgetto\"," + "\"end\" : \"$.dataFineProgetto\"}";
|
2022-11-03 17:03:15 +01:00
|
|
|
|
2022-11-08 17:56:36 +01:00
|
|
|
if (template != null) {
|
2022-11-03 17:03:15 +01:00
|
|
|
|
2022-11-08 17:56:36 +01:00
|
|
|
JSONObject sourceJsonTemplate = new JSONObject(template);
|
|
|
|
|
|
|
|
Project theProject = GeoportalClientCaller.projects().getProjectByID(profileID, projectID);
|
|
|
|
List<Relationship> relationships = theProject.getRelationships();
|
|
|
|
|
|
|
|
if (relationships == null || relationships.size() == 0)
|
|
|
|
return new ArrayList<String>();
|
|
|
|
|
2022-11-16 16:42:12 +01:00
|
|
|
JSONObject targetJsonObject = toTimelineWithImageJSONModel(theProject, sourceJsonTemplate,
|
|
|
|
profileID, projectID, null);
|
2022-11-08 17:56:36 +01:00
|
|
|
|
|
|
|
targetJsonObject.put("selected", "from here");
|
|
|
|
String theJSONResult = targetJsonObject.toString();
|
|
|
|
LOG.debug("Base jsonObject " + theJSONResult);
|
2022-11-03 17:03:15 +01:00
|
|
|
listJSON.add(theJSONResult);
|
|
|
|
|
2022-11-08 17:56:36 +01:00
|
|
|
// Adding the relationships
|
|
|
|
for (Relationship relationship : relationships) {
|
|
|
|
|
|
|
|
// Adding the first level of the related project
|
|
|
|
theProject = GeoportalClientCaller.projects().getProjectByID(relationship.getTargetUCD(),
|
|
|
|
relationship.getTargetID());
|
2022-11-16 16:42:12 +01:00
|
|
|
targetJsonObject = toTimelineWithImageJSONModel(theProject, sourceJsonTemplate,
|
2022-11-08 17:56:36 +01:00
|
|
|
relationship.getTargetUCD(), relationship.getTargetID(),
|
|
|
|
relationship.getRelationshipName());
|
|
|
|
theJSONResult = targetJsonObject.toString();
|
|
|
|
listJSON.add(theJSONResult);
|
|
|
|
|
|
|
|
LOG.debug("\n\ngetRelationshipsChain for " + relationship);
|
|
|
|
Iterator<RelationshipNavigationObject> iterator = GeoportalClientCaller.projects()
|
|
|
|
.getRelationshipChain(relationship.getTargetUCD(), relationship.getTargetID(),
|
|
|
|
relationship.getRelationshipName(), true);
|
|
|
|
// Adding deep > 1
|
|
|
|
while (iterator.hasNext()) {
|
|
|
|
RelationshipNavigationObject nav = (RelationshipNavigationObject) iterator.next();
|
2022-11-16 16:42:12 +01:00
|
|
|
listJSON = visitRelationshipsChain(nav, relationship.getRelationshipName(), listJSON,
|
2022-11-08 17:56:36 +01:00
|
|
|
sourceJsonTemplate);
|
|
|
|
}
|
2022-11-07 17:58:06 +01:00
|
|
|
|
2022-11-08 17:56:36 +01:00
|
|
|
LOG.debug("Finally list of jsonObject " + listJSON);
|
2022-11-04 17:16:37 +01:00
|
|
|
|
2022-11-08 17:56:36 +01:00
|
|
|
}
|
2022-11-03 17:03:15 +01:00
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
String erroMsg = "Error occurred on reading relatioships for id: " + projectID;
|
|
|
|
LOG.error(erroMsg, e);
|
|
|
|
}
|
|
|
|
|
2022-11-07 17:58:06 +01:00
|
|
|
LOG.debug("returning list of relantionships having size: " + listJSON.size());
|
2022-11-02 18:05:38 +01:00
|
|
|
return listJSON;
|
|
|
|
} catch (Exception e) {
|
2022-11-16 16:42:12 +01:00
|
|
|
String erroMsg = "Error occurred on reading relationships for id: " + projectID;
|
2022-11-02 18:05:38 +01:00
|
|
|
LOG.error(erroMsg, e);
|
|
|
|
throw new Exception(erroMsg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-16 16:42:12 +01:00
|
|
|
/**
|
|
|
|
* Visit relationships chain.
|
|
|
|
*
|
|
|
|
* @param nav the nav
|
|
|
|
* @param relationshipName the relationship name
|
|
|
|
* @param listJSONTimelineModel the list JSON timeline model
|
|
|
|
* @param sourceJsonTemplate the source json template
|
|
|
|
* @return the list
|
|
|
|
*/
|
2022-11-07 17:58:06 +01:00
|
|
|
// recursive visit of the Relationships
|
|
|
|
public List<String> visitRelationshipsChain(RelationshipNavigationObject nav, String relationshipName,
|
2022-11-16 16:42:12 +01:00
|
|
|
List<String> listJSONTimelineModel, JSONObject sourceJsonTemplate) {
|
2022-11-07 17:58:06 +01:00
|
|
|
|
|
|
|
if (nav == null)
|
|
|
|
return listJSONTimelineModel;
|
|
|
|
|
|
|
|
LOG.debug("visitRelationshipsChain of target: " + nav.getTarget().getId() + ", relationshipName: "
|
|
|
|
+ relationshipName);
|
|
|
|
|
|
|
|
if (LOG.isDebugEnabled()) {
|
|
|
|
LOG.debug("visitRelationshipsChain target doc: " + nav.getTarget().getTheDocument());
|
|
|
|
LOG.debug("visitRelationshipsChain children " + nav.getChildren());
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
Project targetProject = nav.getTarget();
|
2022-11-16 16:42:12 +01:00
|
|
|
JSONObject targetJsonObject = toTimelineWithImageJSONModel(targetProject, sourceJsonTemplate,
|
2022-11-07 17:58:06 +01:00
|
|
|
nav.getTarget().getProfileID(), nav.getTarget().getId(), relationshipName);
|
|
|
|
String theJSONResult = targetJsonObject.toString();
|
|
|
|
listJSONTimelineModel.add(theJSONResult);
|
|
|
|
LOG.debug("Built jsonObject " + theJSONResult);
|
|
|
|
} catch (Exception e) {
|
|
|
|
LOG.warn("Skipping " + nav.getTarget().getId() + " translate relationshipName: " + relationshipName);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nav.getChildren() != null) {
|
|
|
|
LOG.debug("visiting children...");
|
|
|
|
for (RelationshipNavigationObject relationship : nav.getChildren()) {
|
|
|
|
listJSONTimelineModel = visitRelationshipsChain(relationship, relationshipName, listJSONTimelineModel,
|
2022-11-16 16:42:12 +01:00
|
|
|
sourceJsonTemplate);
|
2022-11-07 17:58:06 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return listJSONTimelineModel;
|
|
|
|
}
|
|
|
|
|
2022-11-16 16:42:12 +01:00
|
|
|
/**
|
|
|
|
* To timeline with image JSON model.
|
|
|
|
*
|
|
|
|
* @param theProject the the project
|
|
|
|
* @param sourceJsonTemplate the source json template
|
|
|
|
* @param targetUCD the target UCD
|
|
|
|
* @param targetID the target ID
|
|
|
|
* @param relationName the relation name
|
|
|
|
* @return the JSON object
|
|
|
|
*/
|
|
|
|
private JSONObject toTimelineWithImageJSONModel(Project theProject, JSONObject sourceJsonTemplate, String targetUCD,
|
|
|
|
String targetID, String relationName) {
|
2022-11-04 17:16:37 +01:00
|
|
|
|
2022-11-16 16:42:12 +01:00
|
|
|
JSONObject targetJsonObject = ConvertToDataValueObjectModel.toTimelineJSONModel(theProject, sourceJsonTemplate,
|
|
|
|
targetUCD, targetID, relationName);
|
2022-11-04 17:16:37 +01:00
|
|
|
|
|
|
|
List<PayloadDV> images = null;
|
|
|
|
try {
|
2022-11-16 16:42:12 +01:00
|
|
|
images = getImagesForId(theProject.getProfileID(), theProject.getId(), true);
|
2022-11-04 17:16:37 +01:00
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
}
|
|
|
|
if (images != null && images.size() > 0) {
|
|
|
|
images.get(0).getLink();
|
|
|
|
targetJsonObject.put("image_url", images.get(0).getLink());
|
|
|
|
}
|
|
|
|
|
|
|
|
return targetJsonObject;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-11-16 16:42:12 +01:00
|
|
|
/**
|
|
|
|
* Temporal reference for project.
|
|
|
|
*
|
|
|
|
* @param theProject the the project
|
|
|
|
* @return the temporal reference DV
|
|
|
|
*/
|
|
|
|
private TemporalReferenceDV temporalReferenceForProject(Project theProject) {
|
|
|
|
LOG.trace("temporalReference for profileID: " + theProject.getProfileID() + ", projectID: "
|
|
|
|
+ theProject.getId() + "called");
|
|
|
|
String template = null;
|
|
|
|
try {
|
|
|
|
|
|
|
|
new GeoportalServiceIdentityProxy(this.getThreadLocalRequest());
|
|
|
|
template = SessionUtil.getJSONTimelineTemplate(this.getThreadLocalRequest(), theProject.getProfileID());
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
if (template == null) {
|
|
|
|
|
|
|
|
Document temporalJsonTemplate = GeoportalClientCaller.useCaseDescriptors()
|
|
|
|
.readTemporalDimensionTemplate(theProject.getProfileID());
|
|
|
|
|
|
|
|
if (temporalJsonTemplate != null) {
|
|
|
|
template = new Document(temporalJsonTemplate).toJson();
|
|
|
|
LOG.info(UseCaseDescriptorCaller.TIMELINE_CONFIG_TJT_DOCUMENT + " read is: " + template);
|
|
|
|
SessionUtil.setJSONTimelineTemplate(this.getThreadLocalRequest(), theProject.getProfileID(),
|
|
|
|
template);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
LOG.warn(GEOPORTAL_DATA_HANDLER.geoportal_timeline_json_template.getType()
|
|
|
|
+ " not found!!! Timeline cannot be available");
|
|
|
|
}
|
|
|
|
|
|
|
|
// String template = "{\"content\": \"$.nome\"," + "\"title\": \"$.nome\","
|
|
|
|
// + "\"start\" : \"$.dataInizioProgetto\"," + "\"end\" : \"$.dataFineProgetto\"}";
|
|
|
|
|
|
|
|
if (template != null) {
|
|
|
|
|
|
|
|
JSONObject sourceJsonTemplate = new JSONObject(template);
|
|
|
|
JSONObject targetJsonObject = ConvertToDataValueObjectModel.toTimelineJSONModel(theProject,
|
|
|
|
sourceJsonTemplate, theProject.getProfileID(), theProject.getId(), null);
|
|
|
|
|
|
|
|
return ConvertToDataValueObjectModel.toTemporalReferenceDV(theProject, targetJsonObject);
|
|
|
|
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
String erroMsg = "Error occurred on reading temporalReference for id: " + theProject.getId();
|
|
|
|
LOG.warn(erroMsg, e);
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2020-10-23 18:18:06 +02:00
|
|
|
}
|