feature_25074 #9

Merged
francesco.mangiacrapa merged 6 commits from feature_25074 into master 2023-06-05 14:30:07 +02:00
6 changed files with 124 additions and 10 deletions
Showing only changes of commit 57d4ab211a - Show all commits

View File

@ -4,6 +4,11 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v2.2.0-SNAPSHOT]
- Integrated the cross-filtering configuration [#25074]
- Integrated the grouped custom layers configuration [#25110]
## [v2.1.0] - 2023-05-11 ## [v2.1.0] - 2023-05-11
- Integrated the deleteFileset method [#24977] - Integrated the deleteFileset method [#24977]

View File

@ -10,7 +10,7 @@
<groupId>org.gcube.application</groupId> <groupId>org.gcube.application</groupId>
<artifactId>geoportal-data-common</artifactId> <artifactId>geoportal-data-common</artifactId>
<version>2.1.0</version> <version>2.2.0-SNAPSHOT</version>
<description>GeoPortal Data Common is common library used by GUI components developed for GeoNA</description> <description>GeoPortal Data Common is common library used by GUI components developed for GeoNA</description>
<scm> <scm>

View File

@ -45,6 +45,7 @@ import org.gcube.application.geoportalcommon.shared.geoportal.config.GcubeProfil
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV; import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
import org.gcube.application.geoportalcommon.shared.geoportal.geojson.Crs; import org.gcube.application.geoportalcommon.shared.geoportal.geojson.Crs;
import org.gcube.application.geoportalcommon.shared.geoportal.geojson.GeoJSON; import org.gcube.application.geoportalcommon.shared.geoportal.geojson.GeoJSON;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.GroupedCustomLayersDV;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.IndexLayerDV; import org.gcube.application.geoportalcommon.shared.geoportal.materialization.IndexLayerDV;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.PayloadDV; import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.PayloadDV;
import org.gcube.application.geoportalcommon.shared.geoportal.project.AccessDV; import org.gcube.application.geoportalcommon.shared.geoportal.project.AccessDV;
@ -297,7 +298,7 @@ public class ConvertToDataValueObjectModel {
int i = 0; int i = 0;
for (String asJSONString : jsonConfigurations) { for (String asJSONString : jsonConfigurations) {
LOG.debug(++i + ") the gCubeProfile is: " + asJSONString); LOG.debug(++i + ") the " + geoportalConfigType + " is: " + asJSONString);
GcubeProfile profile = org.gcube.application.geoportal.client.utils.Serialization GcubeProfile profile = org.gcube.application.geoportal.client.utils.Serialization
.read(asJSONString, GcubeProfile.class); .read(asJSONString, GcubeProfile.class);
listGcubeProfiles.add(toGcubeProfileDV(profile)); listGcubeProfiles.add(toGcubeProfileDV(profile));
@ -317,7 +318,7 @@ public class ConvertToDataValueObjectModel {
int i = 0; int i = 0;
for (String asJSONString : jsonConfigurations) { for (String asJSONString : jsonConfigurations) {
LOG.debug(++i + ") the itemField is: " + asJSONString); LOG.debug(++i + ") the " + geoportalConfigType + " is: " + asJSONString);
ItemField itemField = org.gcube.application.geoportal.client.utils.Serialization ItemField itemField = org.gcube.application.geoportal.client.utils.Serialization
.read(asJSONString, ItemField.class); .read(asJSONString, ItemField.class);
listItemFields.add(toItemFieldDV(itemField)); listItemFields.add(toItemFieldDV(itemField));
@ -374,7 +375,33 @@ public class ConvertToDataValueObjectModel {
return hdDV; return hdDV;
} }
case grouped_custom_layers: {
List<GroupedCustomLayersDV> listGroupedCL = new ArrayList<GroupedCustomLayersDV>(
jsonConfigurations.size());
int i = 0;
for (String asJSONString : jsonConfigurations) {
LOG.debug(
++i + ") the " + GroupedCustomLayersDV.class.getSimpleName() + " is: " + asJSONString);
GroupedCustomLayersDV profile = org.gcube.application.geoportal.client.utils.Serialization
.read(asJSONString, GroupedCustomLayersDV.class);
// listGroupedCL.add(toGcubeProfileDV(profile));
listGroupedCL.add(profile);
}
ConfigurationDV<List<GroupedCustomLayersDV>> dDV = new ConfigurationDV<List<GroupedCustomLayersDV>>(
listGroupedCL);
dDV.setConfiguration(listGroupedCL);
dDV.setConfigurationType(geoportalConfigType);
hdDV.setConfiguration(dDV);
LOG.info("returning {}", hdDV);
return hdDV;
}
default: default:
LOG.warn("HANDLER NOT FOUND FOR configs: " + geoportalConfigType);
break; break;
} }
} }

View File

@ -1,7 +1,7 @@
package org.gcube.application.geoportalcommon.shared.geoportal.ucd; package org.gcube.application.geoportalcommon.shared.geoportal.ucd;
public enum GEOPORTAL_CONFIGURATION_TYPE { public enum GEOPORTAL_CONFIGURATION_TYPE {
item_fields("itemFields"), gcube_profiles("gcubeProfiles"), actions_definition("actionsDefinition"); item_fields("itemFields"), gcube_profiles("gcubeProfiles"), actions_definition("actionsDefinition"), grouped_custom_layers("grouped_custom_layers");
String id; String id;

View File

@ -7,6 +7,8 @@ public enum GEOPORTAL_DATA_HANDLER {
geoportal_data_entry("org.gcube.portlets.user.geoportal-data-entry-app", "DATA_ENTRY_GUI"), geoportal_data_entry("org.gcube.portlets.user.geoportal-data-entry-app", "DATA_ENTRY_GUI"),
geoportal_workflow_action_list("org.gcube.portlets.user.geoportal-workflow-action-list","WORKFLOW_ACTION_LIST_GUI"), geoportal_workflow_action_list("org.gcube.portlets.user.geoportal-workflow-action-list","WORKFLOW_ACTION_LIST_GUI"),
geoportal_timeline_json_template("org.gcube.portlets.user.geoportal-timeline-json-template","TIMELINE_JSON_TEMPLATE"), geoportal_timeline_json_template("org.gcube.portlets.user.geoportal-timeline-json-template","TIMELINE_JSON_TEMPLATE"),
geoportal_cross_filtering("org.gcube.portlets.user.cross-filtering","CROSS_FILTERING"),
geoportal_grouped_custom_layers("org.gcube.portlets.user.grouped_custom_layers","GROUPED_CUSTOM_LAYERS"),
gna_concessioni_lc("GNA-CONCESSIONI-LC", "LifecycleManagement"); gna_concessioni_lc("GNA-CONCESSIONI-LC", "LifecycleManagement");
String id; String id;

View File

@ -2,11 +2,15 @@ package org.gcube.application;
import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin.useCaseDescriptors; import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin.useCaseDescriptors;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Properties;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.bson.Document; import org.bson.Document;
@ -19,6 +23,9 @@ import org.gcube.application.geoportalcommon.shared.geoportal.ConfigurationDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.ActionDefinitionDV; import org.gcube.application.geoportalcommon.shared.geoportal.config.ActionDefinitionDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.GcubeProfileDV; import org.gcube.application.geoportalcommon.shared.geoportal.config.GcubeProfileDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV; import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.CustomLayerDV;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.GroupedCustomLayersDV;
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_CONFIGURATION_TYPE;
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_DATA_HANDLER; 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.HandlerDeclarationDV;
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.UseCaseDescriptorDV; import org.gcube.application.geoportalcommon.shared.geoportal.ucd.UseCaseDescriptorDV;
@ -26,6 +33,8 @@ import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.scope.api.ScopeProvider;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
import org.junit.Before;
import org.junit.Test;
import com.jayway.jsonpath.JsonPath; import com.jayway.jsonpath.JsonPath;
import com.jayway.jsonpath.spi.json.JsonOrgJsonProvider; import com.jayway.jsonpath.spi.json.JsonOrgJsonProvider;
@ -38,17 +47,46 @@ import com.jayway.jsonpath.spi.json.JsonOrgJsonProvider;
* Sep 9, 2022 * Sep 9, 2022
*/ */
public class UCD_Tests { public class UCD_Tests {
private static final String GCUBE_CONFIG_PROPERTIES_FILENAME = "gcube_config.properties";
// APP Working Directory + /src/test/resources must be the location of
// gcube_config.properties
private static String gcube_config_path = String.format("%s/%s",
System.getProperty("user.dir") + "/src/test/resources", GCUBE_CONFIG_PROPERTIES_FILENAME);
private static String CONTEXT;
private static String TOKEN;
private UseCaseDescriptorCaller client = null; private UseCaseDescriptorCaller client = null;
private static String CONTEXT = "/pred4s/preprod/preVRE";
private static String TOKEN = ""; //preVRE
//private static String CONTEXT = "/gcube/devsec/devVRE"; //private static String CONTEXT = "/gcube/devsec/devVRE";
//private static String TOKEN = ""; // devVRE //private static String TOKEN = ""; // devVRE
private static String PROFILE_ID = "profiledConcessioni"; private static String PROFILE_ID = "profiledConcessioni";
/**
* Read context settings.
*/
public static void readContextSettings() {
try (InputStream input = new FileInputStream(gcube_config_path)) {
Properties prop = new Properties();
// load a properties file
prop.load(input);
CONTEXT = prop.getProperty("CONTEXT");
TOKEN = prop.getProperty("TOKEN");
// get the property value and print it out
System.out.println("CONTEXT: " + CONTEXT);
System.out.println("TOKEN: " + TOKEN);
} catch (IOException ex) {
ex.printStackTrace();
}
}
/** /**
* Gets the client. * Gets the client.
* *
@ -56,7 +94,7 @@ public class UCD_Tests {
*/ */
//@Before //@Before
public void getClient() { public void getClient() {
// assumeTrue(GCubeTest.isTestInfrastructureEnabled()); readContextSettings();
ScopeProvider.instance.set(CONTEXT); ScopeProvider.instance.set(CONTEXT);
SecurityTokenProvider.instance.set(TOKEN); SecurityTokenProvider.instance.set(TOKEN);
client = GeoportalClientCaller.useCaseDescriptors(); client = GeoportalClientCaller.useCaseDescriptors();
@ -192,6 +230,40 @@ public class UCD_Tests {
System.out.println(listUCDDV); System.out.println(listUCDDV);
} }
//@Test
public void getUCDGroupedCustomLayers() throws Exception {
ScopeProvider.instance.set(CONTEXT);
SecurityTokenProvider.instance.set(TOKEN);
List<String> handlersIds = null;
List<UseCaseDescriptor> listUseCaseDescriptor;
try {
UseCaseDescriptorCaller client = GeoportalClientCaller.useCaseDescriptors();
if (handlersIds == null) {
handlersIds = Arrays.asList(GEOPORTAL_DATA_HANDLER.geoportal_grouped_custom_layers.getId());
System.out.println("handlersIds is null, so using default: " + handlersIds);
}
listUseCaseDescriptor = client.getListForHandlerIds(handlersIds);
} catch (Exception e) {
e.printStackTrace();
return;
}
if (listUseCaseDescriptor == null) {
listUseCaseDescriptor = new ArrayList<UseCaseDescriptor>();
}
List<UseCaseDescriptorDV> listUCDDV = new ArrayList<UseCaseDescriptorDV>(listUseCaseDescriptor.size());
for (UseCaseDescriptor ucd : listUseCaseDescriptor) {
listUCDDV.add(ConvertToDataValueObjectModel.toUseCaseDescriptorDV(ucd, null));
}
System.out.println(listUCDDV);
}
/** /**
* Gets the UCD for handler types. * Gets the UCD for handler types.
@ -203,13 +275,15 @@ public class UCD_Tests {
public void getUCDForHandlerTypes() throws Exception { public void getUCDForHandlerTypes() throws Exception {
ScopeProvider.instance.set(CONTEXT); ScopeProvider.instance.set(CONTEXT);
SecurityTokenProvider.instance.set(TOKEN); SecurityTokenProvider.instance.set(TOKEN);
String handlerType = GEOPORTAL_DATA_HANDLER.geoportal_grouped_custom_layers.getType();
UseCaseDescriptor ucd = null; UseCaseDescriptor ucd = null;
List<HandlerDeclaration> handlers = null; List<HandlerDeclaration> handlers = null;
try { try {
UseCaseDescriptorCaller client = GeoportalClientCaller.useCaseDescriptors(); UseCaseDescriptorCaller client = GeoportalClientCaller.useCaseDescriptors();
ucd = client.getUCDForId(PROFILE_ID); ucd = client.getUCDForId(PROFILE_ID);
handlers = client.getHandlersByType(PROFILE_ID, GEOPORTAL_DATA_HANDLER.geoportal_basic_data_list.getType()); handlers = client.getHandlersByType(PROFILE_ID, handlerType);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -219,10 +293,16 @@ public class UCD_Tests {
for (HandlerDeclaration handlerDeclaration : handlers) { for (HandlerDeclaration handlerDeclaration : handlers) {
System.out.println(handlerDeclaration); System.out.println(handlerDeclaration);
System.out.println("Config json: "+handlerDeclaration.getConfiguration().toJson()); System.out.println("Config json: "+handlerDeclaration.getConfiguration().toJson());
HandlerDeclarationDV handlerDV = ConvertToDataValueObjectModel.toHandlerDeclarationDV(handlerDeclaration, ucd, GEOPORTAL_CONFIGURATION_TYPE.grouped_custom_layers);
System.out.println("handlerDV is: "+handlerDV);
} }
} }
/** /**
* Gets the UCD for handler types. * Gets the UCD for handler types.