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;
|
2022-11-18 16:50:01 +01:00
|
|
|
import java.util.Collections;
|
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;
|
2022-11-28 09:49:46 +01:00
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import java.util.stream.Stream;
|
|
|
|
import java.util.stream.StreamSupport;
|
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;
|
2023-05-15 16:19:40 +02:00
|
|
|
import org.gcube.application.geoportal.common.model.useCaseDescriptor.HandlerDeclaration;
|
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;
|
2023-01-11 17:12:19 +01:00
|
|
|
import org.gcube.application.geoportalcommon.geoportal.access.GeportalCheckAccessPolicy;
|
|
|
|
import org.gcube.application.geoportalcommon.geoportal.access.GeportalCheckAccessPolicy.ACCESS_POLICY;
|
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.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;
|
2023-05-25 11:28:25 +02:00
|
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.config.GeoportalConfigurationID;
|
|
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.config.GroupedLayersDV;
|
2022-10-11 15:00:39 +02:00
|
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
|
2023-05-25 11:28:25 +02:00
|
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.config.layers.ConfiguredLayerDV;
|
|
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.config.layers.CrossFilteringLayerDV;
|
|
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.config.layers.LayerIDV;
|
2022-10-27 15:09:07 +02:00
|
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.geojson.GeoJSON;
|
2023-05-25 11:28:25 +02:00
|
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.GCubeSDILayer;
|
2022-10-18 14:17:41 +02:00
|
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.GCubeSDIViewerLayerDV;
|
2023-05-25 11:28:25 +02:00
|
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.GeoServerPlatformInfoDV;
|
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;
|
2023-05-15 16:19:40 +02:00
|
|
|
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_CONFIGURATION_TYPE;
|
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;
|
2023-08-31 15:17:21 +02:00
|
|
|
import org.gcube.application.geoportalcommon.util.StringUtil;
|
2021-08-02 15:20:01 +02:00
|
|
|
import org.gcube.application.geoportalcommon.util.URLParserUtil;
|
2023-05-08 11:37:27 +02:00
|
|
|
import org.gcube.application.geoportaldatamapper.GcubeProfilesPerUCDIdCache;
|
2023-05-05 17:23:11 +02:00
|
|
|
import org.gcube.application.geoportaldatamapper.Geoportal_JSON_Mapper;
|
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;
|
2023-01-31 15:24:45 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.server.gis.GisMakers;
|
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;
|
2023-06-05 16:54:40 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.server.util.HTTPRequestUtil;
|
2020-11-03 18:04:47 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.server.util.SessionUtil;
|
2022-11-18 16:50:01 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.server.util.TemporalComparatorUtil;
|
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-11-28 09:49:46 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.ResultSetPaginatedDataIDs;
|
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;
|
2023-01-31 15:24:45 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
|
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 {
|
|
|
|
|
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-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
|
|
|
|
}
|
2023-05-05 17:23:11 +02:00
|
|
|
|
2023-05-25 11:28:25 +02:00
|
|
|
/**
|
|
|
|
* The Enum CENTROID_LAYER_INDEX_FLAG.
|
|
|
|
*
|
|
|
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
|
|
|
*
|
|
|
|
* May 25, 2023
|
|
|
|
*/
|
2023-02-20 15:22:51 +01:00
|
|
|
public static enum CENTROID_LAYER_INDEX_FLAG {
|
|
|
|
PUBLIC("public"), PRIVATE("internal");
|
|
|
|
|
|
|
|
String id;
|
|
|
|
|
2023-05-25 11:28:25 +02:00
|
|
|
/**
|
|
|
|
* Instantiates a new centroid layer index flag.
|
|
|
|
*
|
|
|
|
* @param id the id
|
|
|
|
*/
|
2023-02-20 15:22:51 +01:00
|
|
|
CENTROID_LAYER_INDEX_FLAG(String id) {
|
|
|
|
this.id = id;
|
|
|
|
}
|
|
|
|
|
2023-05-25 11:28:25 +02:00
|
|
|
/**
|
|
|
|
* Gets the id.
|
|
|
|
*
|
|
|
|
* @return the id
|
|
|
|
*/
|
2023-02-20 15:22:51 +01:00
|
|
|
public String getId() {
|
|
|
|
return id;
|
|
|
|
}
|
2023-05-05 17:23:11 +02:00
|
|
|
|
2023-05-25 11:28:25 +02:00
|
|
|
/**
|
|
|
|
* To string.
|
|
|
|
*
|
|
|
|
* @return the string
|
|
|
|
*/
|
2023-02-20 15:22:51 +01:00
|
|
|
@Override
|
|
|
|
public String toString() {
|
|
|
|
StringBuilder builder = new StringBuilder();
|
|
|
|
builder.append("CENTROID_LAYER_INDEX_FLAG [id=");
|
|
|
|
builder.append(id);
|
|
|
|
builder.append("]");
|
|
|
|
return builder.toString();
|
|
|
|
}
|
2023-05-05 17:23:11 +02:00
|
|
|
|
2023-02-20 15:22:51 +01:00
|
|
|
}
|
2022-10-11 15:00:39 +02:00
|
|
|
|
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);
|
2023-08-31 15:17:21 +02:00
|
|
|
String wmsServiceServiceEndpoint = validator.getWmsServiceEndPoint();
|
2020-10-27 16:04:34 +01:00
|
|
|
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
|
|
|
|
2023-08-31 15:17:21 +02:00
|
|
|
return new GeoInformationForWMSRequest(wmsServiceServiceEndpoint, validWMSRequest, layerName, versionWms, crs,
|
2021-07-30 14:57:08 +02:00
|
|
|
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
|
|
|
|
2023-05-05 17:23:11 +02:00
|
|
|
String gcubeScope = SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
|
2020-12-02 14:39:52 +01:00
|
|
|
GeoportalCommon gc = new GeoportalCommon();
|
2023-05-05 17:23:11 +02:00
|
|
|
return gc.getPublicLinksFor(gcubeScope, 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
|
2023-01-31 15:24:45 +01:00
|
|
|
* @param maxWFSFeature the max WFS feature. If 0 means all feature
|
2021-08-31 18:21:17 +02:00
|
|
|
* @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());
|
|
|
|
|
2023-05-25 11:28:25 +02:00
|
|
|
SessionUtil.addCollectionToSession(getThreadLocalRequest(), u);
|
|
|
|
|
2022-10-13 16:53:33 +02:00
|
|
|
Projects<Project> p = projects(u.getId()).build();
|
2022-10-14 15:31:32 +02:00
|
|
|
|
2023-05-15 16:19:40 +02:00
|
|
|
UseCaseDescriptorDV ucdDV = ConvertToDataValueObjectModel.toUseCaseDescriptorDV(u, null);
|
2022-10-13 16:53:33 +02:00
|
|
|
Configuration ucdConfig = p.getConfiguration();
|
|
|
|
GCubeCollection coll = new GCubeCollection();
|
2023-05-15 16:19:40 +02:00
|
|
|
coll.setUcd(ucdDV);
|
|
|
|
|
2022-10-13 16:53:33 +02:00
|
|
|
// TODO TO Check index flag should be in configuration or evaluated according to
|
|
|
|
// user credentials
|
|
|
|
|
2023-02-20 15:22:51 +01:00
|
|
|
CENTROID_LAYER_INDEX_FLAG setIndexFlag = null;
|
2022-10-27 16:18:54 +02:00
|
|
|
|
2022-10-27 15:09:07 +02:00
|
|
|
GeoportalServiceIdentityProxy gsp = getGeoportalServiceProxy();
|
2022-10-27 16:18:54 +02:00
|
|
|
if (gsp.isUser()) {
|
2023-02-20 15:22:51 +01:00
|
|
|
setIndexFlag = CENTROID_LAYER_INDEX_FLAG.PRIVATE;
|
|
|
|
LOG.info("user logged - using indexFlag: " + setIndexFlag);
|
2022-10-27 16:18:54 +02:00
|
|
|
} else if (gsp.isIAMClient()) {
|
2023-02-20 15:22:51 +01:00
|
|
|
setIndexFlag = CENTROID_LAYER_INDEX_FLAG.PUBLIC;
|
|
|
|
LOG.info("user not logged - using indexFlag: " + setIndexFlag);
|
2022-10-27 15:09:07 +02:00
|
|
|
}
|
2022-10-13 16:53:33 +02:00
|
|
|
|
|
|
|
// TODO constant
|
|
|
|
coll.setIndexes(new ArrayList());
|
|
|
|
|
2023-05-05 17:23:11 +02:00
|
|
|
LOG.debug("Checking if " + u.getId() + " is GIS Indexed. Index flag needed is '"
|
|
|
|
+ setIndexFlag + "'");
|
2023-02-20 15:22:51 +01:00
|
|
|
IndexLayerDV toAdd = getLayerIndex(ucdConfig, setIndexFlag);
|
2023-05-05 17:23:11 +02:00
|
|
|
if (toAdd != null) {
|
2023-02-20 15:22:51 +01:00
|
|
|
coll.getIndexes().add(toAdd);
|
2022-10-13 16:53:33 +02:00
|
|
|
}
|
|
|
|
|
2023-02-20 15:22:51 +01:00
|
|
|
// Using the public centroid layer as default
|
|
|
|
if (coll.getIndexes().isEmpty()) {
|
2023-05-05 17:23:11 +02:00
|
|
|
LOG.info("No available GIS Index for collection " + coll.getUcd().getName()
|
|
|
|
+ " with flag " + setIndexFlag.getId());
|
2023-02-20 15:22:51 +01:00
|
|
|
setIndexFlag = CENTROID_LAYER_INDEX_FLAG.PUBLIC;
|
2023-05-05 17:23:11 +02:00
|
|
|
LOG.info("Prevent fallback - getting the GIS index with flag '" + setIndexFlag.getId()
|
|
|
|
+ "' available");
|
2023-02-20 15:22:51 +01:00
|
|
|
toAdd = getLayerIndex(ucdConfig, setIndexFlag);
|
2023-05-05 17:23:11 +02:00
|
|
|
if (toAdd != null) {
|
2023-02-20 15:22:51 +01:00
|
|
|
coll.getIndexes().add(toAdd);
|
|
|
|
}
|
|
|
|
}
|
2023-05-05 17:23:11 +02:00
|
|
|
|
|
|
|
if (!coll.getIndexes().isEmpty())
|
2022-10-13 16:53:33 +02:00
|
|
|
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();
|
|
|
|
}
|
2023-05-05 17:23:11 +02:00
|
|
|
|
2023-05-25 11:28:25 +02:00
|
|
|
/**
|
|
|
|
* Gets the avaiable custom grouped layers for UCD.
|
|
|
|
*
|
|
|
|
* @param theHandler the the handler
|
|
|
|
* @return the avaiable custom grouped layers for UCD
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public Map<String, List<GroupedLayersDV<? extends LayerIDV>>> getAvaiableCustomGroupedLayersForUCD(
|
|
|
|
GEOPORTAL_DATA_HANDLER theHandler) {
|
|
|
|
LOG.debug("getAvaiableCustomGroupedLayersForUCD called");
|
|
|
|
|
|
|
|
Map<String, List<GroupedLayersDV<? extends LayerIDV>>> mapProfileIDCustomGroupedLayers = new LinkedHashMap<>();
|
|
|
|
|
|
|
|
// Reading UCDs Collections from the session
|
|
|
|
Map<String, UseCaseDescriptor> ucdCollections = SessionUtil.getAvailableCollections(getThreadLocalRequest());
|
|
|
|
LOG.debug("ucdCollections in session are: " + ucdCollections.size());
|
|
|
|
|
|
|
|
for (String profileId : ucdCollections.keySet()) {
|
|
|
|
|
|
|
|
UseCaseDescriptor u = ucdCollections.get(profileId);
|
|
|
|
|
|
|
|
// Loading geoportal_grouped_overlay_layers if exists
|
|
|
|
List<HandlerDeclaration> handlers = u.getHandlersByType(theHandler.getType());
|
|
|
|
|
|
|
|
GEOPORTAL_CONFIGURATION_TYPE configurationType = null;
|
|
|
|
switch (theHandler) {
|
|
|
|
case geoportal_grouped_overlay_layers:
|
|
|
|
configurationType = GEOPORTAL_CONFIGURATION_TYPE.grouped_overlay_layers;
|
|
|
|
break;
|
|
|
|
case geoportal_grouped_cross_filtering:
|
|
|
|
configurationType = GEOPORTAL_CONFIGURATION_TYPE.grouped_cross_filtering_layers;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (configurationType != null && handlers != null && handlers.size() > 0) {
|
|
|
|
// Loading Handler gcube_profiles
|
|
|
|
HandlerDeclaration handler = handlers.get(0);
|
|
|
|
List<GroupedLayersDV<? extends LayerIDV>> listGroupedCustomLayers = (List<GroupedLayersDV<? extends LayerIDV>>) getGroupedLayers(
|
|
|
|
u, handler, configurationType);
|
|
|
|
LOG.debug("listGroupedCustomLayers for type '{}' are: {}", configurationType, listGroupedCustomLayers);
|
|
|
|
mapProfileIDCustomGroupedLayers.put(profileId, listGroupedCustomLayers);
|
|
|
|
} else {
|
2023-06-05 16:54:40 +02:00
|
|
|
LOG.info("No handler '{}' found into UCD {}, continue...", theHandler, u.getId());
|
2023-05-25 11:28:25 +02:00
|
|
|
mapProfileIDCustomGroupedLayers.put(profileId, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
LOG.debug("mapProfileIDCustomGroupedLayers returned: " + mapProfileIDCustomGroupedLayers);
|
|
|
|
LOG.info("mapProfileIDCustomGroupedLayers returned are: " + mapProfileIDCustomGroupedLayers.size());
|
|
|
|
return mapProfileIDCustomGroupedLayers;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// public Map<String, List<GroupedLayersDV>> getAvaiableCrossFilteringLayers() {
|
|
|
|
//
|
|
|
|
// Map<String, List<GroupedLayersDV>> mapProfileIDOvelayLayers = new LinkedHashMap<>();
|
|
|
|
//
|
|
|
|
// // Reading UCDs Collections from the session
|
|
|
|
// Map<String, UseCaseDescriptor> ucdCollections = SessionUtil.getAvailableCollections(getThreadLocalRequest());
|
|
|
|
//
|
|
|
|
// for (String profileId : ucdCollections.keySet()) {
|
|
|
|
//
|
|
|
|
// UseCaseDescriptor u = ucdCollections.get(profileId);
|
|
|
|
//
|
|
|
|
// // Loading geoportal_grouped_overlay_layers if exists
|
|
|
|
// GEOPORTAL_DATA_HANDLER theHandler = GEOPORTAL_DATA_HANDLER.geoportal_grouped_cross_filtering;
|
|
|
|
// List<HandlerDeclaration> handlers = u.getHandlersByType(theHandler.getType());
|
|
|
|
//
|
|
|
|
// if (handlers != null && handlers.size() > 0) {
|
|
|
|
// // Loading Handler gcube_profiles
|
|
|
|
// HandlerDeclaration handler = handlers.get(0);
|
|
|
|
// List<GroupedLayersDV> listGroupedCustomLayers = null;
|
|
|
|
// try {
|
|
|
|
//
|
|
|
|
// HandlerDeclarationDV handlerDV = ConvertToDataValueObjectModel.toHandlerDeclarationDV(handler, u,
|
|
|
|
// GEOPORTAL_CONFIGURATION_TYPE.grouped_overlay_layers);
|
|
|
|
//
|
|
|
|
// if (handler != null) {
|
|
|
|
// ConfigurationDV<?> config = handlerDV.getConfiguration();
|
|
|
|
// switch (config.getConfigurationType()) {
|
|
|
|
// case grouped_overlay_layers:
|
|
|
|
// listGroupedCustomLayers = (List<GroupedLayersDV>) config.getConfiguration();
|
|
|
|
// break;
|
|
|
|
// default:
|
|
|
|
// break;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// } catch (Exception e) {
|
|
|
|
// LOG.error("Error on loading {} config for ucd Id {}. Returning null",
|
|
|
|
// GEOPORTAL_CONFIGURATION_TYPE.grouped_overlay_layers, u.getId());
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// mapProfileIDOvelayLayers.put(profileId, listGroupedCustomLayers);
|
|
|
|
// } else {
|
|
|
|
// LOG.warn("No handler " + theHandler + "found into UCD " + u.getId() + ", continue...");
|
|
|
|
// mapProfileIDOvelayLayers.put(profileId, null);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// return mapProfileIDOvelayLayers;
|
|
|
|
//
|
|
|
|
// }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the layer index.
|
|
|
|
*
|
|
|
|
* @param ucdConfig the ucd config
|
|
|
|
* @param flag the flag
|
|
|
|
* @return the layer index
|
|
|
|
*/
|
2023-02-20 15:22:51 +01:00
|
|
|
private IndexLayerDV getLayerIndex(Configuration ucdConfig, CENTROID_LAYER_INDEX_FLAG flag) {
|
2023-05-05 17:23:11 +02:00
|
|
|
|
2023-02-20 15:22:51 +01:00
|
|
|
for (Index index : ucdConfig.getIndexes()) {
|
|
|
|
try {
|
|
|
|
IndexLayerDV toAdd = ConvertToDataValueObjectModel.convert(index);
|
2023-05-25 11:28:25 +02:00
|
|
|
toAdd = removeGSWorkspaceFromWMSPathOfOGCLinks(toAdd);
|
2023-05-05 17:23:11 +02:00
|
|
|
LOG.trace("Discovered index: " + toAdd);
|
|
|
|
if (toAdd.getFlag().compareToIgnoreCase(flag.getId()) == 0) {
|
|
|
|
LOG.debug("Layer index found for flag: " + flag + ", returning");
|
2023-02-20 15:22:51 +01:00
|
|
|
return toAdd;
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
LOG.debug("Skipping invalid index ", e);
|
|
|
|
} catch (Throwable t) {
|
|
|
|
LOG.error("Unable to check index ", t);
|
|
|
|
}
|
|
|
|
}
|
2023-05-05 17:23:11 +02:00
|
|
|
|
2023-02-20 15:22:51 +01:00
|
|
|
return null;
|
|
|
|
}
|
2022-10-13 16:53:33 +02:00
|
|
|
|
2023-05-25 11:28:25 +02:00
|
|
|
/**
|
|
|
|
* Removes the GS workspace from WMS path of OGC links.
|
|
|
|
*
|
|
|
|
* @param index the index
|
|
|
|
* @return the index layer DV
|
|
|
|
*/
|
|
|
|
private IndexLayerDV removeGSWorkspaceFromWMSPathOfOGCLinks(IndexLayerDV index) {
|
|
|
|
LOG.info("removeGSWorkspaceFromWMSPathOfOGCLinks called");
|
|
|
|
GCubeSDILayer indexLayer = index.getLayer();
|
|
|
|
HashMap<String, String> ogcLinks = indexLayer.getOgcLinks();
|
|
|
|
String wmsLink = ogcLinks.get("wms");
|
2023-08-31 15:17:21 +02:00
|
|
|
LOG.info("wms link is {}", StringUtil.ellipsize(wmsLink, 150));
|
2023-05-25 11:28:25 +02:00
|
|
|
int lastCharOfthePath = wmsLink.indexOf("?");
|
|
|
|
String wmsPath = wmsLink.substring(0, lastCharOfthePath);
|
|
|
|
for (GeoServerPlatformInfoDV geoserver : indexLayer.getPlatformInfos()) {
|
|
|
|
// removing "workspace/" from the wms path
|
|
|
|
if (wmsPath.contains(geoserver.getWorkspace())) {
|
|
|
|
wmsPath = wmsPath.replace(geoserver.getWorkspace() + "/", "");
|
|
|
|
LOG.debug("purged wmsPath from the 'workspace' is {}", wmsPath);
|
|
|
|
wmsLink = wmsPath + wmsLink.substring(lastCharOfthePath, wmsLink.length());
|
|
|
|
ogcLinks.put("wms", wmsLink);
|
2023-08-31 15:17:21 +02:00
|
|
|
LOG.info("wms link without {} is {}", geoserver.getWorkspace(), StringUtil.ellipsize(wmsLink, 150));
|
2023-05-25 11:28:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return index;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the grouped layers.
|
|
|
|
*
|
|
|
|
* @param ucd the ucd
|
|
|
|
* @param handler the handler
|
|
|
|
* @param type the type
|
|
|
|
* @return the grouped layers
|
|
|
|
*/
|
|
|
|
private List<? extends GeoportalConfigurationID> getGroupedLayers(UseCaseDescriptor ucd, HandlerDeclaration handler,
|
|
|
|
GEOPORTAL_CONFIGURATION_TYPE type) {
|
2023-05-15 16:19:40 +02:00
|
|
|
|
2023-05-25 11:28:25 +02:00
|
|
|
List<? extends GeoportalConfigurationID> listGroupedCustomLayers = null;
|
2023-05-15 16:19:40 +02:00
|
|
|
try {
|
|
|
|
|
2023-05-25 11:28:25 +02:00
|
|
|
HandlerDeclarationDV handlerDV = ConvertToDataValueObjectModel.toHandlerDeclarationDV(handler, ucd, type);
|
2023-05-15 16:19:40 +02:00
|
|
|
|
|
|
|
if (handler != null) {
|
|
|
|
ConfigurationDV<?> config = handlerDV.getConfiguration();
|
|
|
|
switch (config.getConfigurationType()) {
|
2023-05-25 11:28:25 +02:00
|
|
|
case grouped_overlay_layers:
|
|
|
|
listGroupedCustomLayers = (List<GroupedLayersDV<ConfiguredLayerDV>>) config.getConfiguration();
|
2023-05-15 16:19:40 +02:00
|
|
|
break;
|
2023-05-25 11:28:25 +02:00
|
|
|
case grouped_cross_filtering_layers:
|
|
|
|
listGroupedCustomLayers = (List<GroupedLayersDV<CrossFilteringLayerDV>>) config.getConfiguration();
|
2023-05-15 16:19:40 +02:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
2023-05-25 11:28:25 +02:00
|
|
|
LOG.error("Error on loading {} config for ucd Id {}. Returning null", type, ucd.getId());
|
2023-05-15 16:19:40 +02:00
|
|
|
}
|
|
|
|
return listGroupedCustomLayers;
|
|
|
|
}
|
|
|
|
|
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);
|
2022-11-28 09:49:46 +01:00
|
|
|
throw e;
|
2022-10-12 17:12:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
2023-08-31 15:17:21 +02:00
|
|
|
LOG.debug("onBeforeRequestDeserialized called");
|
2022-10-12 17:12:09 +02:00
|
|
|
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-11-28 09:49:46 +01:00
|
|
|
public ResultSetPaginatedDataIDs getListProjects(String theProfileID, Integer start, Integer limit,
|
2022-10-12 17:12:09 +02:00
|
|
|
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);
|
|
|
|
|
2022-11-28 09:49:46 +01:00
|
|
|
// Saving client PROJECTION
|
|
|
|
LinkedHashMap<String, Object> originalProjection = filter.getProjection();
|
2023-01-11 17:12:19 +01:00
|
|
|
|
2022-11-28 09:49:46 +01:00
|
|
|
// Setting PROJECTION ONLY FOR PROEJCT ID
|
|
|
|
LinkedHashMap<String, Object> projectionForIDs = new LinkedHashMap<String, Object>();
|
|
|
|
projectionForIDs.put(Project.ID, 1);
|
|
|
|
filter.setProjection(projectionForIDs);
|
|
|
|
|
|
|
|
ResultSetPaginatedDataIDs searchedDataIDs = new ResultSetPaginatedDataIDs();
|
2023-05-05 17:23:11 +02:00
|
|
|
|
2022-10-12 17:12:09 +02:00
|
|
|
Integer totalProjectForProfile = SessionUtil.getTotalDocumentForProfileID(getThreadLocalRequest(),
|
|
|
|
theProfileID);
|
|
|
|
|
|
|
|
if (totalProjectForProfile == null) {
|
|
|
|
totalProjectForProfile = client.getTotalDocument(theProfileID);
|
|
|
|
SessionUtil.setTotalDocumentForProfileID(getThreadLocalRequest(), theProfileID, totalProjectForProfile);
|
|
|
|
}
|
|
|
|
|
2022-11-28 09:49:46 +01:00
|
|
|
searchedDataIDs.setTotalItems(totalProjectForProfile);
|
2022-10-12 17:12:09 +02:00
|
|
|
LOG.info("Total Docs read from config: " + totalProjectForProfile);
|
|
|
|
|
2022-11-28 09:49:46 +01:00
|
|
|
// FIRST QUERY TO RETRIEVE IDs
|
2023-01-11 17:12:19 +01:00
|
|
|
// LIMIT IS NULL AND START = 0 MEANS THAT IT IS EQUAL TO NUMBER TOTAL OF
|
|
|
|
// DOCUMENTS
|
2022-11-29 15:46:43 +01:00
|
|
|
final Iterator<Project> projectsIDs = client.queryOnMongo(theProfileID, totalProjectForProfile, 0, null,
|
2022-10-12 17:12:09 +02:00
|
|
|
filter);
|
|
|
|
|
2023-01-11 17:12:19 +01:00
|
|
|
// Getting the Project IDs from the Iterable
|
2022-11-28 09:49:46 +01:00
|
|
|
Iterable<Project> itP = () -> projectsIDs;
|
|
|
|
Stream<Project> targetStream = StreamSupport.stream(itP.spliterator(), false);
|
|
|
|
List<String> listProjectIDs = targetStream.map(Project::getId).collect(Collectors.toList());
|
|
|
|
searchedDataIDs.setResultSetProjectIDs(listProjectIDs);
|
2023-01-11 17:12:19 +01:00
|
|
|
// Total number of Projects are exactly listProjectIDs.size()
|
2022-11-28 09:49:46 +01:00
|
|
|
int totalItems = listProjectIDs.size();
|
|
|
|
searchedDataIDs.setTotalItems(totalItems);
|
2022-11-28 15:20:21 +01:00
|
|
|
LOG.info("Total IDs read from query: " + totalItems);
|
2022-11-28 09:49:46 +01:00
|
|
|
|
2023-01-11 17:12:19 +01:00
|
|
|
// NOW PERFORMING THE (REAL) SECOND QUERY FROM CLIENT
|
2022-11-28 09:49:46 +01:00
|
|
|
// SETTING ORIGINAL PROJECTION FROM CLIENT
|
|
|
|
filter.setProjection(originalProjection);
|
|
|
|
// LIMIT IS FROM CLIENT
|
2023-01-11 17:12:19 +01:00
|
|
|
Iterator<Project> projects = client.queryOnMongo(theProfileID, totalItems, start, limit, filter);
|
2022-10-12 17:12:09 +02:00
|
|
|
|
2022-11-28 09:49:46 +01:00
|
|
|
searchedDataIDs.setClientStartIndex(start);
|
|
|
|
searchedDataIDs.setLimit(limit);
|
|
|
|
searchedDataIDs.setServerSearchFinished(false);
|
2022-10-12 17:12:09 +02:00
|
|
|
|
2022-11-28 09:49:46 +01:00
|
|
|
List<ResultDocumentDV> toReturnList = ConvertToDataValueObjectModel.toListResultDocument(projects);
|
|
|
|
searchedDataIDs.setData(toReturnList);
|
2022-10-12 17:12:09 +02:00
|
|
|
|
|
|
|
// 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
|
2022-11-28 09:49:46 +01:00
|
|
|
// if (filter.getConditions() != null) {
|
|
|
|
// searchedDataIDs.setTotalItems(toReturnList.size());
|
|
|
|
// int totalItems = searchedDataIDs.getResultSetProjectIDs().size();
|
|
|
|
// searchedDataIDs.setTotalItems(totalItems);
|
|
|
|
// }
|
2022-10-12 17:12:09 +02:00
|
|
|
|
|
|
|
if (totalProjectForProfile == limit || totalProjectForProfile == 0) {
|
|
|
|
LOG.debug("Page completed returning " + totalProjectForProfile + " projects");
|
|
|
|
int newOffset = start + limit;
|
2022-11-28 09:49:46 +01:00
|
|
|
searchedDataIDs
|
|
|
|
.setServerSearchFinished(newOffset > totalProjectForProfile || totalProjectForProfile == 0);
|
|
|
|
LOG.debug("is Search finished: " + searchedDataIDs.isServerSearchFinished());
|
2022-10-12 17:12:09 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (LOG.isDebugEnabled()) {
|
2022-11-28 09:49:46 +01:00
|
|
|
LOG.debug("returning {}", searchedDataIDs.getData());
|
2022-10-12 17:12:09 +02:00
|
|
|
}
|
|
|
|
|
2022-11-28 09:49:46 +01:00
|
|
|
List<? extends DocumentDV> data = searchedDataIDs.getData();
|
2022-10-12 17:12:09 +02:00
|
|
|
if (data != null) {
|
|
|
|
LOG.info("returning {} project/s", data.size());
|
|
|
|
}
|
|
|
|
|
2022-11-28 09:49:46 +01:00
|
|
|
return searchedDataIDs;
|
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);
|
2023-01-11 17:12:19 +01:00
|
|
|
String username = null;
|
2022-10-18 14:17:41 +02:00
|
|
|
try {
|
2023-01-11 17:12:19 +01:00
|
|
|
username = SessionUtil.getCurrentUser(this.getThreadLocalRequest()).getUsername();
|
2022-10-18 14:17:41 +02:00
|
|
|
} catch (Exception e) {
|
2023-01-11 17:12:19 +01:00
|
|
|
LOG.info("User not found in session, the userName for checking the policy will be null");
|
2022-10-18 14:17:41 +02:00
|
|
|
}
|
|
|
|
|
2023-01-11 17:12:19 +01:00
|
|
|
LOG.trace("Trying to get project for id " + projectID);
|
2022-10-18 14:17:41 +02:00
|
|
|
new GeoportalServiceIdentityProxy(this.getThreadLocalRequest());
|
|
|
|
Project theProject = GeoportalClientCaller.projects().getProjectByID(profileID, projectID);
|
|
|
|
String jsonDocument = theProject.getTheDocument().toJson();
|
|
|
|
LOG.trace("JSON Project is: " + jsonDocument);
|
|
|
|
|
2023-01-11 17:12:19 +01:00
|
|
|
LOG.debug("Checking access policy for the layer...");
|
|
|
|
ACCESS_POLICY accessPolicy = GeportalCheckAccessPolicy.accessPolicyFromSessionLogin(username);
|
|
|
|
LOG.info("Access policy for discovering the layers is: " + accessPolicy);
|
2022-10-18 14:17:41 +02:00
|
|
|
|
2023-01-11 17:12:19 +01:00
|
|
|
String filesetParentJSONPath = null;
|
2023-05-05 17:23:11 +02:00
|
|
|
|
|
|
|
// (see ticket #24390)
|
2023-01-11 17:12:19 +01:00
|
|
|
if (accessPolicy.equals(ACCESS_POLICY.OPEN)) {
|
2023-01-31 15:24:45 +01:00
|
|
|
// Filtering for ACCESS_POLICY.OPEN from the fileset when the username is not in
|
|
|
|
// session. IAM
|
2023-01-11 17:12:19 +01:00
|
|
|
// identity is running, no logged in user.
|
|
|
|
filesetParentJSONPath = String.format("%s..%s[?(@._access._policy=='%s')]",
|
|
|
|
Geoportal_JSON_Mapper.JSON_$_POINTER, Geoportal_JSON_Mapper.FILESET, accessPolicy);
|
|
|
|
} else {
|
|
|
|
// Accessing to all fileset (with any ACCESS_POLICY) when the user is logged in.
|
|
|
|
filesetParentJSONPath = String.format("%s..%s", Geoportal_JSON_Mapper.JSON_$_POINTER,
|
|
|
|
Geoportal_JSON_Mapper.FILESET);
|
|
|
|
}
|
|
|
|
|
|
|
|
listLayers = Geoportal_JSON_Mapper.readGcubeSDILayersForFileset(filesetParentJSONPath, 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) {
|
2023-01-10 14:36:37 +01:00
|
|
|
LOG.info("User not found in session, the userName for checking the policy will be null");
|
2022-10-19 17:51:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
2023-01-10 14:36:37 +01:00
|
|
|
LOG.info("User not found in session, the userName for checking the policy will be null");
|
2022-10-11 15:00:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2023-05-05 17:23:11 +02:00
|
|
|
|
2022-11-16 16:42:12 +01:00
|
|
|
if (temporalReference == null)
|
|
|
|
temporalReference = new TemporalReferenceDV();
|
2023-05-05 17:23:11 +02:00
|
|
|
|
2022-11-16 16:42:12 +01:00
|
|
|
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) {
|
2023-01-10 14:36:37 +01:00
|
|
|
LOG.info("User not found in session, the userName for checking the policy will be null");
|
2022-11-16 16:42:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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-12-15 15:39:08 +01:00
|
|
|
LOG.info("getDataResult called");
|
2023-01-11 17:12:19 +01:00
|
|
|
|
2022-12-15 15:39:08 +01:00
|
|
|
for (LayerObject layerObject : layerObjects) {
|
2023-01-11 17:12:19 +01:00
|
|
|
LOG.info("ProfileID: " + layerObject.getProfileID() + ", ProjectID: " + layerObject.getProjectID()
|
|
|
|
+ ", TYPE: " + layerObject.getType());
|
2022-12-15 15:39:08 +01:00
|
|
|
}
|
2023-01-11 17:12:19 +01:00
|
|
|
|
2022-10-19 17:51:13 +02:00
|
|
|
if (LOG.isDebugEnabled()) {
|
2022-11-29 12:35:30 +01:00
|
|
|
LOG.debug("getDataResult parmeters layerObjects: " + layerObjects,
|
2022-10-19 17:51:13 +02:00
|
|
|
", 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: {
|
|
|
|
|
2022-12-15 17:47:44 +01:00
|
|
|
// Expected more than 1 feature for the BBOX of the Map
|
2022-10-25 17:01:24 +02:00
|
|
|
FeatureRow fRow = features.get(0);
|
2023-01-11 17:12:19 +01:00
|
|
|
// using only the first feature returned from BBOX of the Map
|
|
|
|
// when querying the centroid layers
|
2022-12-15 17:47:44 +01:00
|
|
|
geoDAO.setFeatures(Arrays.asList(fRow));
|
2022-10-25 17:01:24 +02:00
|
|
|
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-11-21 15:16:36 +01:00
|
|
|
GeoJSON geoJson = getSpatialReference(layerObject.getProfileID(),
|
|
|
|
layerObject.getProjectID());
|
2022-10-27 15:09:07 +02:00
|
|
|
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
|
|
|
|
2023-02-03 11:53:37 +01:00
|
|
|
LinkedHashMap<String, Object> documentAsMap = getEntrySetsDocumentForProjectID(
|
2022-10-25 17:01:24 +02:00
|
|
|
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-11-18 16:50:01 +01:00
|
|
|
// Ordering for temporal dimension
|
|
|
|
try {
|
|
|
|
Collections.sort(listDAO, new TemporalComparatorUtil());
|
|
|
|
} catch (Exception e) {
|
|
|
|
// silent
|
|
|
|
}
|
|
|
|
|
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-11-28 15:44:58 +01:00
|
|
|
LOG.info("returning " + listDAO.size() + " geona data objects");
|
2023-01-11 17:12:19 +01:00
|
|
|
|
|
|
|
if (LOG.isDebugEnabled()) {
|
2022-11-29 12:35:30 +01:00
|
|
|
LOG.debug("returning " + listDAO + " geona data objects");
|
|
|
|
}
|
2023-01-11 17:12:19 +01:00
|
|
|
|
2022-10-25 17:01:24 +02:00
|
|
|
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) {
|
2023-02-03 11:53:37 +01:00
|
|
|
LinkedHashMap<String, Object> theDocument = getEntrySetsDocumentForProjectID(profileID, projectID,
|
2022-11-07 17:58:06 +01:00
|
|
|
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
|
|
|
/**
|
2022-11-21 15:16:36 +01:00
|
|
|
* Gets the spatial reference.
|
2022-10-27 16:18:54 +02:00
|
|
|
*
|
|
|
|
* @param profileID the profile ID
|
|
|
|
* @param projectID the project ID
|
2022-11-21 15:16:36 +01:00
|
|
|
* @return the spatial reference
|
2022-10-27 16:18:54 +02:00
|
|
|
*/
|
2022-11-21 15:16:36 +01:00
|
|
|
@Override
|
|
|
|
public GeoJSON getSpatialReference(String profileID, String projectID) {
|
2022-10-27 15:09:07 +02:00
|
|
|
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
|
2023-02-03 11:53:37 +01:00
|
|
|
public LinkedHashMap<String, Object> getEntrySetsDocumentForProjectID(String profileID, String projectID,
|
2022-10-25 17:01:24 +02:00
|
|
|
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
|
|
|
|
2023-02-03 11:53:37 +01:00
|
|
|
LinkedHashMap<String, Object> documentAsMap = new LinkedHashMap<String, Object>(limit);
|
2022-10-25 17:01:24 +02:00
|
|
|
|
|
|
|
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();
|
2023-05-05 17:23:11 +02:00
|
|
|
documentAsMap.put(entry.getKey(), entry.getValue() != null ? entry.getValue().toString() : null);
|
2022-10-25 17:01:24 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2023-01-31 15:24:45 +01:00
|
|
|
/**
|
|
|
|
* Gets the WFS request.
|
|
|
|
*
|
|
|
|
* @param layerItem the layer item
|
|
|
|
* @param mapSrsName the map srs name
|
|
|
|
* @param mapBBOX the map BBOX
|
|
|
|
* @param maxFeatures the max features. If 0 means all feature
|
|
|
|
* @param outputFormat the output format
|
|
|
|
* @return the WFS request
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public String getWFSRequest(LayerItem layerItem, String mapSrsName, BoundsMap mapBBOX, int maxFeatures,
|
|
|
|
String outputFormat) {
|
|
|
|
LOG.info("getWFSRequest called");
|
|
|
|
|
|
|
|
if (LOG.isDebugEnabled()) {
|
|
|
|
LOG.debug("getWFSRequest parameters layerItem name: " + layerItem.getName(), ", mapSrsName: " + mapSrsName
|
|
|
|
+ ", mapBBOX: " + mapBBOX + ", maxFeatures: " + maxFeatures + ", outputFormat: " + outputFormat);
|
|
|
|
}
|
|
|
|
String url = GisMakers.buildWFSFeatureQuery(layerItem, mapSrsName, mapBBOX, maxFeatures, outputFormat);
|
|
|
|
LOG.info("returning WFSRequest: " + url);
|
|
|
|
return url;
|
|
|
|
}
|
|
|
|
|
2023-06-05 16:54:40 +02:00
|
|
|
/**
|
|
|
|
* Gets the HTTP response for URL.
|
|
|
|
*
|
|
|
|
* @param url the url
|
|
|
|
* @return the HTTP response for URL
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public String getHTTPResponseForURL(String url) {
|
|
|
|
LOG.info("getHTTPResponseForURL called");
|
|
|
|
|
|
|
|
if (LOG.isDebugEnabled()) {
|
|
|
|
LOG.debug("getHTTPResponseForURL for URL {} ", url);
|
|
|
|
}
|
|
|
|
return HTTPRequestUtil.getResponse(url);
|
|
|
|
}
|
|
|
|
|
2023-01-31 15:24:45 +01:00
|
|
|
/**
|
|
|
|
* Gets the WFS response.
|
|
|
|
*
|
|
|
|
* @param layerItem the layer item
|
|
|
|
* @param mapSrsName the map srs name
|
|
|
|
* @param mapBBOX the map BBOX
|
|
|
|
* @param maxFeatures the max features
|
|
|
|
* @param outputFormat the output format
|
|
|
|
* @return the WFS response
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public String getWFSResponse(LayerItem layerItem, String mapSrsName, BoundsMap mapBBOX, int maxFeatures,
|
|
|
|
String outputFormat) {
|
|
|
|
LOG.info("getWFSResponse called");
|
|
|
|
|
|
|
|
if (LOG.isDebugEnabled()) {
|
|
|
|
LOG.debug("getWFSResponse parameters layerItem name: " + layerItem.getName(), ", mapSrsName: " + mapSrsName
|
|
|
|
+ ", mapBBOX: " + mapBBOX + ", maxFeatures: " + maxFeatures + ", outputFormat: " + outputFormat);
|
|
|
|
}
|
|
|
|
|
|
|
|
String url = getWFSRequest(layerItem, mapSrsName, mapBBOX, maxFeatures, outputFormat);
|
2023-06-05 16:54:40 +02:00
|
|
|
return HTTPRequestUtil.getResponse(url);
|
2023-01-31 15:24:45 +01:00
|
|
|
}
|
|
|
|
|
2020-10-23 18:18:06 +02:00
|
|
|
}
|