Read configuration and deserialization of

"GROUPED_CROSS_FILTERING_LAYERS"
This commit is contained in:
Francesco Mangiacrapa 2023-05-24 12:19:02 +02:00
parent 6a38ebc0c8
commit af82f20ca5
9 changed files with 229 additions and 39 deletions

View File

@ -42,10 +42,12 @@ import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV;
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.FilePathDV; import org.gcube.application.geoportalcommon.shared.geoportal.config.FilePathDV;
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.GroupedLayersDV;
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.config.layers.ConfiguredLayerDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.layers.CrossFilteringLayerDV;
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;
@ -72,9 +74,11 @@ import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer; import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer; import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import com.jayway.jsonpath.DocumentContext; import com.jayway.jsonpath.DocumentContext;
@ -377,20 +381,48 @@ public class ConvertToDataValueObjectModel {
case grouped_overlay_layers: { case grouped_overlay_layers: {
List<GroupedCustomLayersDV> listGroupedCL = new ArrayList<GroupedCustomLayersDV>( List<GroupedLayersDV<ConfiguredLayerDV>> listGroupedCL = new ArrayList<GroupedLayersDV<ConfiguredLayerDV>>(
jsonConfigurations.size()); jsonConfigurations.size());
int i = 0; int i = 0;
ObjectMapper mapper = new ObjectMapper();
for (String asJSONString : jsonConfigurations) { for (String asJSONString : jsonConfigurations) {
LOG.debug( LOG.debug(++i + ") the " + GroupedLayersDV.class.getSimpleName() + " is: " + asJSONString);
++i + ") the " + GroupedCustomLayersDV.class.getSimpleName() + " is: " + asJSONString); TypeReference<GroupedLayersDV<ConfiguredLayerDV>> typeRef = new TypeReference<GroupedLayersDV<ConfiguredLayerDV>>() {};
GroupedCustomLayersDV profile = org.gcube.application.geoportal.client.utils.Serialization GroupedLayersDV<ConfiguredLayerDV> profile = mapper.readValue(asJSONString, typeRef);
.read(asJSONString, GroupedCustomLayersDV.class); // GroupedLayersDV<ConfiguredLayerDV> profile = org.gcube.application.geoportal.client.utils.Serialization
// .read(asJSONString, typeRef);
// listGroupedCL.add(toGcubeProfileDV(profile)); // listGroupedCL.add(toGcubeProfileDV(profile));
listGroupedCL.add(profile); listGroupedCL.add(profile);
} }
ConfigurationDV<List<GroupedCustomLayersDV>> dDV = new ConfigurationDV<List<GroupedCustomLayersDV>>( ConfigurationDV<List<GroupedLayersDV<ConfiguredLayerDV>>> dDV = new ConfigurationDV<List<GroupedLayersDV<ConfiguredLayerDV>>>(
listGroupedCL);
dDV.setConfiguration(listGroupedCL);
dDV.setConfigurationType(geoportalConfigType);
hdDV.setConfiguration(dDV);
LOG.info("returning {}", hdDV);
return hdDV;
}
case grouped_cross_filtering_layers: {
List<GroupedLayersDV<CrossFilteringLayerDV>> listGroupedCL = new ArrayList<GroupedLayersDV<CrossFilteringLayerDV>>(
jsonConfigurations.size());
int i = 0;
ObjectMapper mapper = new ObjectMapper();
for (String asJSONString : jsonConfigurations) {
LOG.debug(++i + ") the " + GroupedLayersDV.class.getSimpleName() + " is: " + asJSONString);
TypeReference<GroupedLayersDV<CrossFilteringLayerDV>> typeRef = new TypeReference<GroupedLayersDV<CrossFilteringLayerDV>>() {};
GroupedLayersDV<CrossFilteringLayerDV> profile = mapper.readValue(asJSONString, typeRef);
// GroupedLayersDV<CrossFilteringLayerDV> profile = org.gcube.application.geoportal.client.utils.Serialization
// .read(asJSONString, GroupedLayersDV.class);
// listGroupedCL.add(toGcubeProfileDV(profile));
listGroupedCL.add(profile);
}
ConfigurationDV<List<GroupedLayersDV<CrossFilteringLayerDV>>> dDV = new ConfigurationDV<List<GroupedLayersDV<CrossFilteringLayerDV>>>(
listGroupedCL); listGroupedCL);
dDV.setConfiguration(listGroupedCL); dDV.setConfiguration(listGroupedCL);
dDV.setConfigurationType(geoportalConfigType); dDV.setConfigurationType(geoportalConfigType);

View File

@ -1,26 +1,30 @@
package org.gcube.application.geoportalcommon.shared.geoportal.materialization; package org.gcube.application.geoportalcommon.shared.geoportal.config;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
import org.gcube.application.geoportalcommon.shared.geoportal.config.GeoportalConfigurationID; import org.gcube.application.geoportalcommon.shared.geoportal.config.layers.LayerIDV;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
/** /**
* The Class GroupedCustomLayersDV. * The Class GroupedLayersDV.
* *
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
* *
* May 12, 2023 * May 12, 2023
*/ */
public class GroupedCustomLayersDV implements Serializable, GeoportalConfigurationID { public class GroupedLayersDV<T extends LayerIDV> implements Serializable, GeoportalConfigurationID {
/**
*
*/
private static final long serialVersionUID = -2021774489849084231L;
private String name; private String name;
private String description; private String description;
@JsonProperty(value = "layers") @JsonProperty(value = "layers")
private List<CustomLayerDV> listCustomLayers; private List<T> listCustomLayers;
@Override @Override
public String getID() { public String getID() {
@ -34,7 +38,7 @@ public class GroupedCustomLayersDV implements Serializable, GeoportalConfigurati
} }
public GroupedCustomLayersDV() { public GroupedLayersDV() {
} }
@ -46,7 +50,7 @@ public class GroupedCustomLayersDV implements Serializable, GeoportalConfigurati
return description; return description;
} }
public List<CustomLayerDV> getListCustomLayers() { public List<T> getListCustomLayers() {
return listCustomLayers; return listCustomLayers;
} }
@ -58,14 +62,14 @@ public class GroupedCustomLayersDV implements Serializable, GeoportalConfigurati
this.description = description; this.description = description;
} }
public void setListCustomLayers(List<CustomLayerDV> listCustomLayers) { public void setListCustomLayers(List<T> listCustomLayers) {
this.listCustomLayers = listCustomLayers; this.listCustomLayers = listCustomLayers;
} }
@Override @Override
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("GroupedCustomLayersDV [name="); builder.append("GroupedLayersDV [name=");
builder.append(name); builder.append(name);
builder.append(", description="); builder.append(", description=");
builder.append(description); builder.append(description);

View File

@ -1,22 +1,29 @@
package org.gcube.application.geoportalcommon.shared.geoportal.materialization; package org.gcube.application.geoportalcommon.shared.geoportal.config.layers;
import java.io.Serializable; import java.io.Serializable;
/** /**
* The Class CustomLayerDV. * The Class ConfiguredLayerDV.
* *
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
* *
* May 12, 2023 * May 12, 2023
*/ */
public class CustomLayerDV implements Serializable { public class ConfiguredLayerDV implements Serializable, LayerIDV {
String title; /**
String name; *
String wms_url; */
private static final long serialVersionUID = 6910607957385140987L;
private String title;
private String description;
private String name;
private String wms_url;
private String wfs_url;
boolean display = false; boolean display = false;
public CustomLayerDV() { public ConfiguredLayerDV() {
} }
@ -24,14 +31,22 @@ public class CustomLayerDV implements Serializable {
return title; return title;
} }
public String getDescription() {
return description;
}
public String getName() { public String getName() {
return name; return name;
} }
public String getWms_url() { public String getWMS_URL() {
return wms_url; return wms_url;
} }
public String getWFS_URL() {
return wfs_url;
}
public boolean isDisplay() { public boolean isDisplay() {
return display; return display;
} }
@ -40,6 +55,10 @@ public class CustomLayerDV implements Serializable {
this.title = title; this.title = title;
} }
public void setDescription(String description) {
this.description = description;
}
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
@ -48,6 +67,10 @@ public class CustomLayerDV implements Serializable {
this.wms_url = wms_url; this.wms_url = wms_url;
} }
public void setWfs_url(String wfs_url) {
this.wfs_url = wfs_url;
}
public void setDisplay(boolean display) { public void setDisplay(boolean display) {
this.display = display; this.display = display;
} }
@ -55,16 +78,21 @@ public class CustomLayerDV implements Serializable {
@Override @Override
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("CustomLayerDV [title="); builder.append("ConfiguredLayerDV [title=");
builder.append(title); builder.append(title);
builder.append(", description=");
builder.append(description);
builder.append(", name="); builder.append(", name=");
builder.append(name); builder.append(name);
builder.append(", wms_url="); builder.append(", wms_url=");
builder.append(wms_url); builder.append(wms_url);
builder.append(", wfs_url=");
builder.append(wfs_url);
builder.append(", display="); builder.append(", display=");
builder.append(display); builder.append(display);
builder.append("]"); builder.append("]");
return builder.toString(); return builder.toString();
} }
} }

View File

@ -0,0 +1,78 @@
package org.gcube.application.geoportalcommon.shared.geoportal.config.layers;
import java.util.List;
public class CrossFilteringLayerDV extends ConfiguredLayerDV {
/**
*
*/
private static final long serialVersionUID = 1130075528037312939L;
String table_show_field;
String table_key_field;
String table_parent_key_field;
String table_geometry_name;
List<CrossFilteringLayerDV> related_to;
public CrossFilteringLayerDV() {
}
public String getTable_show_field() {
return table_show_field;
}
public String getTable_key_field() {
return table_key_field;
}
public String getTable_parent_key_field() {
return table_parent_key_field;
}
public String getTable_geometry_name() {
return table_geometry_name;
}
public List<CrossFilteringLayerDV> getRelated_to() {
return related_to;
}
public void setTable_show_field(String table_show_field) {
this.table_show_field = table_show_field;
}
public void setTable_key_field(String table_key_field) {
this.table_key_field = table_key_field;
}
public void setTable_parent_key_field(String table_parent_key_field) {
this.table_parent_key_field = table_parent_key_field;
}
public void setTable_geometry_name(String table_geometry_name) {
this.table_geometry_name = table_geometry_name;
}
public void setRelated_to(List<CrossFilteringLayerDV> related_to) {
this.related_to = related_to;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("CrossFilteringLayerDV [table_show_field=");
builder.append(table_show_field);
builder.append(", table_key_field=");
builder.append(table_key_field);
builder.append(", table_parent_key_field=");
builder.append(table_parent_key_field);
builder.append(", table_geometry_name=");
builder.append(table_geometry_name);
builder.append(", related_to=");
builder.append(related_to);
builder.append("]");
return builder.toString();
}
}

View File

@ -0,0 +1,10 @@
package org.gcube.application.geoportalcommon.shared.geoportal.config.layers;
public interface LayerIDV {
String getName();
String getTitle();
String getWMS_URL();
String getWFS_URL();
}

View File

@ -1,7 +1,11 @@
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"), grouped_overlay_layers("grouped_overlay_layers"); item_fields("itemFields"),
gcube_profiles("gcubeProfiles"),
actions_definition("actionsDefinition"),
grouped_overlay_layers("grouped_overlay_layers"),
grouped_cross_filtering_layers("grouped_cross_filtering_layers");
String id; String id;

View File

@ -7,7 +7,7 @@ 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_cross_filtering("org.gcube.portlets.user.grouped_cross_filtering_layers","GROUPED_CROSS_FILTERING_LAYERS"),
geoportal_grouped_overlay_layers("org.gcube.portlets.user.grouped_overlay_layers","GROUPED_OVERLAY_LAYERS"), geoportal_grouped_overlay_layers("org.gcube.portlets.user.grouped_overlay_layers","GROUPED_OVERLAY_LAYERS"),
gna_concessioni_lc("GNA-CONCESSIONI-LC", "LifecycleManagement"); gna_concessioni_lc("GNA-CONCESSIONI-LC", "LifecycleManagement");

View File

@ -15,8 +15,6 @@ import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences;
import org.gcube.application.geoportalcommon.shared.config.RoleRights; import org.gcube.application.geoportalcommon.shared.config.RoleRights;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.scope.api.ScopeProvider;
import org.junit.Before;
import org.junit.Test;
public class TestGNACommon { public class TestGNACommon {

View File

@ -23,8 +23,6 @@ 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_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;
@ -232,7 +230,7 @@ public class UCD_Tests {
} }
//@Test //@Test
public void getUCDGroupedCustomLayers() throws Exception { public void getUCDGroupedOverlayLayers() throws Exception {
ScopeProvider.instance.set(CONTEXT); ScopeProvider.instance.set(CONTEXT);
SecurityTokenProvider.instance.set(TOKEN); SecurityTokenProvider.instance.set(TOKEN);
@ -264,6 +262,43 @@ public class UCD_Tests {
System.out.println(listUCDDV); System.out.println(listUCDDV);
} }
//@Test
public void getUCDGroupedCrossFilteringLayers() throws Exception {
System.out.println("Running getUCDGroupedCrossFilteringLayers");
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_cross_filtering.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);
System.out.println("Terminated getUCDGroupedCrossFilteringLayers");
}
/** /**
* Gets the UCD for handler types. * Gets the UCD for handler types.
@ -273,10 +308,11 @@ public class UCD_Tests {
*/ */
//@Test //@Test
public void getUCDForHandlerTypes() throws Exception { public void getUCDForHandlerTypes() throws Exception {
System.out.println("Running getUCDForHandlerTypes");
ScopeProvider.instance.set(CONTEXT); ScopeProvider.instance.set(CONTEXT);
SecurityTokenProvider.instance.set(TOKEN); SecurityTokenProvider.instance.set(TOKEN);
String handlerType = GEOPORTAL_DATA_HANDLER.geoportal_grouped_overlay_layers.getType(); String handlerType = GEOPORTAL_DATA_HANDLER.geoportal_grouped_cross_filtering.getType();
UseCaseDescriptor ucd = null; UseCaseDescriptor ucd = null;
List<HandlerDeclaration> handlers = null; List<HandlerDeclaration> handlers = null;
@ -290,15 +326,15 @@ public class UCD_Tests {
return; return;
} }
int i = 0;
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(++i+")##Config json: "+handlerDeclaration.getConfiguration().toJson());
HandlerDeclarationDV handlerDV = ConvertToDataValueObjectModel.toHandlerDeclarationDV(handlerDeclaration, ucd, GEOPORTAL_CONFIGURATION_TYPE.grouped_overlay_layers); HandlerDeclarationDV handlerDV = ConvertToDataValueObjectModel.toHandlerDeclarationDV(handlerDeclaration, ucd, GEOPORTAL_CONFIGURATION_TYPE.grouped_cross_filtering_layers);
System.out.println("handlerDV is: "+handlerDV); System.out.println("\nhandlerDV is: "+handlerDV);
} }
System.out.println("\n");
System.out.println("Terminated getUCDForHandlerTypes");
} }