diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c1ba68..d14ecd4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ 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). +## [v2.2.0-SNAPSHOT] + +- Integrated the cross-filtering configuration [#25074] +- Integrated the grouped custom layers configuration [#25110] + ## [v2.1.0] - 2023-05-11 - Integrated the deleteFileset method [#24977] diff --git a/pom.xml b/pom.xml index 63c68a4..35ef306 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ org.gcube.application geoportal-data-common - 2.1.0 + 2.2.0-SNAPSHOT GeoPortal Data Common is common library used by GUI components developed for GeoNA diff --git a/src/main/java/org/gcube/application/geoportalcommon/ConvertToDataValueObjectModel.java b/src/main/java/org/gcube/application/geoportalcommon/ConvertToDataValueObjectModel.java index ea236f2..d046de3 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/ConvertToDataValueObjectModel.java +++ b/src/main/java/org/gcube/application/geoportalcommon/ConvertToDataValueObjectModel.java @@ -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.geojson.Crs; 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.innerobject.PayloadDV; import org.gcube.application.geoportalcommon.shared.geoportal.project.AccessDV; @@ -297,7 +298,7 @@ public class ConvertToDataValueObjectModel { int i = 0; 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 .read(asJSONString, GcubeProfile.class); listGcubeProfiles.add(toGcubeProfileDV(profile)); @@ -317,7 +318,7 @@ public class ConvertToDataValueObjectModel { int i = 0; 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 .read(asJSONString, ItemField.class); listItemFields.add(toItemFieldDV(itemField)); @@ -374,7 +375,33 @@ public class ConvertToDataValueObjectModel { return hdDV; } + case grouped_custom_layers: { + + List listGroupedCL = new ArrayList( + 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> dDV = new ConfigurationDV>( + listGroupedCL); + dDV.setConfiguration(listGroupedCL); + dDV.setConfigurationType(geoportalConfigType); + hdDV.setConfiguration(dDV); + LOG.info("returning {}", hdDV); + return hdDV; + + } + default: + LOG.warn("HANDLER NOT FOUND FOR configs: " + geoportalConfigType); break; } } diff --git a/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/ucd/GEOPORTAL_CONFIGURATION_TYPE.java b/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/ucd/GEOPORTAL_CONFIGURATION_TYPE.java index 0fb7a52..f6e8330 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/ucd/GEOPORTAL_CONFIGURATION_TYPE.java +++ b/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/ucd/GEOPORTAL_CONFIGURATION_TYPE.java @@ -1,7 +1,7 @@ package org.gcube.application.geoportalcommon.shared.geoportal.ucd; 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; diff --git a/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/ucd/GEOPORTAL_DATA_HANDLER.java b/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/ucd/GEOPORTAL_DATA_HANDLER.java index d0b3532..7360d3c 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/ucd/GEOPORTAL_DATA_HANDLER.java +++ b/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/ucd/GEOPORTAL_DATA_HANDLER.java @@ -7,6 +7,8 @@ public enum GEOPORTAL_DATA_HANDLER { 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_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"); String id; diff --git a/src/test/java/org/gcube/application/UCD_Tests.java b/src/test/java/org/gcube/application/UCD_Tests.java index 1e1a890..efaf2ce 100644 --- a/src/test/java/org/gcube/application/UCD_Tests.java +++ b/src/test/java/org/gcube/application/UCD_Tests.java @@ -2,11 +2,15 @@ package org.gcube.application; 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.Arrays; import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; +import java.util.Properties; import java.util.stream.Collectors; 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.GcubeProfileDV; 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.HandlerDeclarationDV; 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.json.JSONArray; import org.json.JSONObject; +import org.junit.Before; +import org.junit.Test; import com.jayway.jsonpath.JsonPath; import com.jayway.jsonpath.spi.json.JsonOrgJsonProvider; @@ -38,17 +47,46 @@ import com.jayway.jsonpath.spi.json.JsonOrgJsonProvider; * Sep 9, 2022 */ 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 static String CONTEXT = "/pred4s/preprod/preVRE"; - private static String TOKEN = ""; //preVRE - //private static String CONTEXT = "/gcube/devsec/devVRE"; //private static String TOKEN = ""; // devVRE 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. * @@ -56,7 +94,7 @@ public class UCD_Tests { */ //@Before public void getClient() { - // assumeTrue(GCubeTest.isTestInfrastructureEnabled()); + readContextSettings(); ScopeProvider.instance.set(CONTEXT); SecurityTokenProvider.instance.set(TOKEN); client = GeoportalClientCaller.useCaseDescriptors(); @@ -192,6 +230,40 @@ public class UCD_Tests { System.out.println(listUCDDV); } + + //@Test + public void getUCDGroupedCustomLayers() throws Exception { + ScopeProvider.instance.set(CONTEXT); + SecurityTokenProvider.instance.set(TOKEN); + + List handlersIds = null; + List 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(); + } + + List listUCDDV = new ArrayList(listUseCaseDescriptor.size()); + for (UseCaseDescriptor ucd : listUseCaseDescriptor) { + listUCDDV.add(ConvertToDataValueObjectModel.toUseCaseDescriptorDV(ucd, null)); + } + + System.out.println(listUCDDV); + + } /** * Gets the UCD for handler types. @@ -203,13 +275,15 @@ public class UCD_Tests { public void getUCDForHandlerTypes() throws Exception { ScopeProvider.instance.set(CONTEXT); SecurityTokenProvider.instance.set(TOKEN); - + + String handlerType = GEOPORTAL_DATA_HANDLER.geoportal_grouped_custom_layers.getType(); + UseCaseDescriptor ucd = null; List handlers = null; try { UseCaseDescriptorCaller client = GeoportalClientCaller.useCaseDescriptors(); 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) { e.printStackTrace(); @@ -219,10 +293,16 @@ public class UCD_Tests { for (HandlerDeclaration handlerDeclaration : handlers) { System.out.println(handlerDeclaration); 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.