#23835 implementing WORKFLOW_ACTION_LIST_GUI configuration

This commit is contained in:
Francesco Mangiacrapa 2022-09-12 15:03:33 +02:00
parent b629928f36
commit b4bade9951
8 changed files with 361 additions and 159 deletions

View File

@ -11,6 +11,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- [#22883] Integrated the configurations exposed by (the new) geoportal-client (>= 1.1.0-SNAPSHOT)
- Passed to UCD/Projects geoportal client/service
- [#23835] Intrageted with WORKFLOW_ACTION_LIST_GUI configuration
## [v1.4.0] - 2022-06-08

View File

@ -23,12 +23,14 @@ import org.gcube.application.geoportal.common.model.document.lifecycle.Lifecycle
import org.gcube.application.geoportal.common.model.document.relationships.Relationship;
import org.gcube.application.geoportal.common.model.useCaseDescriptor.HandlerDeclaration;
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
import org.gcube.application.geoportalcommon.geoportal.config.ActionDefinition;
import org.gcube.application.geoportalcommon.geoportal.config.FilePath;
import org.gcube.application.geoportalcommon.geoportal.config.GcubeProfile;
import org.gcube.application.geoportalcommon.geoportal.config.ItemField;
import org.gcube.application.geoportalcommon.shared.geoportal.ConfigurationDV;
import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV;
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.FilePathDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.GcubeProfileDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
@ -104,6 +106,7 @@ public class ConvertToDataValueObjectModel {
List<HandlerDeclarationDV> listHandlersDV = new ArrayList<HandlerDeclarationDV>();
if (handlersIds != null) {
LOG.info("List of input handlersIds is "+handlersIds+", converting it");
Map<String, List<HandlerDeclaration>> handlersMapByID = ucd.getHandlersMapByID();
if (handlersMapByID != null) {
@ -124,6 +127,7 @@ public class ConvertToDataValueObjectModel {
}
}
} else {
LOG.info("List of input handlersIds is null, reading all handlers");
List<HandlerDeclaration> listHandlerDeclaration = ucd.getHandlers();
for (HandlerDeclaration handlerDeclaration : listHandlerDeclaration) {
LOG.debug("converting handler {}", handlerDeclaration);
@ -175,7 +179,8 @@ public class ConvertToDataValueObjectModel {
*/
public static HandlerDeclarationDV toHandlerDeclarationDV(HandlerDeclaration handlerDeclaration, String profileName,
GEOPORTAL_CONFIGURATION_TYPE... readConfigs) throws Exception {
LOG.debug("toHandlerDeclarationDV called [handlerDeclaration: "+handlerDeclaration+"], [profileName: "+profileName+"], [readConfigs: "+readConfigs+"]");
if (handlerDeclaration == null) {
LOG.warn(HandlerDeclaration.class.getSimpleName() + " is null");
return null;
@ -199,24 +204,25 @@ public class ConvertToDataValueObjectModel {
readConfigs = GEOPORTAL_CONFIGURATION_TYPE.values();
}
GEOPORTAL_CONFIGURATION_TYPE geoportalConfigType = null;
List<GEOPORTAL_CONFIGURATION_TYPE> listGeoportalConfigType = new ArrayList<GEOPORTAL_CONFIGURATION_TYPE>();
ArrayList<String> jsonConfigurations = null;
//this is the 'projection' field stored in the Configuration,
//if the field exists, e.g. _theDocument, it used as suffix to get the right JSON path concatenating the projection + the paths
// this is the 'projection' field stored in the Configuration,
// if the field exists, e.g. _theDocument, it used as suffix to get the right
// JSON path concatenating the projection + the paths
String projection = null;
for (GEOPORTAL_CONFIGURATION_TYPE configManaged : readConfigs) {
try {
LOG.debug("searching '" + configManaged.getId() + "' in the configuration " + configuration);
LOG.trace("contains " + configManaged.getId() + ": "
+ configuration.containsKey(configManaged.getId()));
try {
projection = configuration.getString("projection");
}catch (Exception e) {
} catch (Exception e) {
// TODO: handle exception
}
ArrayList<LinkedHashMap<String, Object>> listHashMapConfig = configuration
.get(configManaged.getId(), ArrayList.class);
LOG.debug("hashMapConfig found is: {}", listHashMapConfig);
@ -227,17 +233,17 @@ public class ConvertToDataValueObjectModel {
for (LinkedHashMap<String, Object> config : listHashMapConfig) {
Document document = new Document(config);
// //THIS PART MUST BE REVISITED
// if(projection!=null)
// document.append("projection", projection);
String jsonValue = document.toJson();
LOG.debug("config is: {}", jsonValue);
jsonConfigurations.add(jsonValue);
}
LOG.debug("configurations found are: {}", jsonConfigurations);
geoportalConfigType = configManaged;
listGeoportalConfigType.add(configManaged);
break;
}
} catch (Exception e) {
@ -246,6 +252,7 @@ public class ConvertToDataValueObjectModel {
}
}
if (jsonConfigurations == null) {
String error = "No managed configurations as '"
+ Arrays.asList(GEOPORTAL_CONFIGURATION_TYPE.values()).toString() + "' found in the handler "
@ -253,50 +260,73 @@ public class ConvertToDataValueObjectModel {
LOG.warn(error);
return null;
}
for (GEOPORTAL_CONFIGURATION_TYPE geoportalConfigType : listGeoportalConfigType) {
switch (geoportalConfigType) {
case gcube_profiles: {
switch (geoportalConfigType) {
case gcube_profiles: {
List<GcubeProfileDV> listGcubeProfiles = new ArrayList<GcubeProfileDV>(jsonConfigurations.size());
List<GcubeProfileDV> listGcubeProfiles = new ArrayList<GcubeProfileDV>(jsonConfigurations.size());
int i = 0;
for (String asJSONString : jsonConfigurations) {
LOG.debug(++i + ") the gCubeProfile is: " + asJSONString);
GcubeProfile profile = org.gcube.application.geoportal.client.utils.Serialization.read(asJSONString,
GcubeProfile.class);
listGcubeProfiles.add(toGcubeProfileDV(profile));
}
int i = 0;
for (String asJSONString : jsonConfigurations) {
LOG.debug(++i + ") the gCubeProfile is: " + asJSONString);
GcubeProfile profile = org.gcube.application.geoportal.client.utils.Serialization.read(asJSONString,
GcubeProfile.class);
listGcubeProfiles.add(toGcubeProfileDV(profile));
ConfigurationDV<List<GcubeProfileDV>> dDV = new ConfigurationDV<List<GcubeProfileDV>>(
listGcubeProfiles);
dDV.setConfiguration(listGcubeProfiles);
dDV.setConfigurationType(geoportalConfigType); // -> GEOPORTAL_CONFIGURATION_TYPE.gcube_profiles
hdDV.setConfiguration(dDV);
LOG.info("returning {}", hdDV);
return hdDV;
}
case item_fields: {
List<ItemFieldDV> listItemFields = new ArrayList<ItemFieldDV>(jsonConfigurations.size());
int i = 0;
for (String asJSONString : jsonConfigurations) {
LOG.debug(++i + ") the itemField is: " + asJSONString);
ItemField itemField = org.gcube.application.geoportal.client.utils.Serialization.read(asJSONString,
ItemField.class);
listItemFields.add(toItemFieldDV(itemField));
}
ConfigurationDV<List<ItemFieldDV>> dDV = new ConfigurationDV<List<ItemFieldDV>>(listItemFields);
dDV.setConfiguration(listItemFields);
dDV.setConfigurationType(geoportalConfigType); // -> GEOPORTAL_CONFIGURATION_TYPE.item_fields
hdDV.setConfiguration(dDV);
LOG.info("returning {}", hdDV);
return hdDV;
}
ConfigurationDV<List<GcubeProfileDV>> dDV = new ConfigurationDV<List<GcubeProfileDV>>(
listGcubeProfiles);
dDV.setConfiguration(listGcubeProfiles);
dDV.setConfigurationType(geoportalConfigType); //-> GEOPORTAL_CONFIGURATION_TYPE.gcube_profiles
hdDV.setConfiguration(dDV);
LOG.info("returning {}", hdDV);
return hdDV;
}
case item_fields: {
case actions_definition: {
List<ItemFieldDV> listItemFields = new ArrayList<ItemFieldDV>(jsonConfigurations.size());
List<ActionDefinitionDV> listActionsDef = new ArrayList<ActionDefinitionDV>(jsonConfigurations.size());
int i = 0;
for (String asJSONString : jsonConfigurations) {
LOG.debug(++i + ") the itemField is: " + asJSONString);
ItemField profile = org.gcube.application.geoportal.client.utils.Serialization.read(asJSONString,
ItemField.class);
listItemFields.add(toItemFieldDV(profile));
int i = 0;
for (String asJSONString : jsonConfigurations) {
LOG.debug(++i + ") the ActionDefinition is: " + asJSONString);
ActionDefinition actionDef = org.gcube.application.geoportal.client.utils.Serialization
.read(asJSONString, ActionDefinition.class);
listActionsDef.add(toActionDefinition(actionDef));
}
ConfigurationDV<List<ActionDefinitionDV>> dDV = new ConfigurationDV<List<ActionDefinitionDV>>(listActionsDef);
dDV.setConfiguration(listActionsDef);
dDV.setConfigurationType(geoportalConfigType); // -> GEOPORTAL_CONFIGURATION_TYPE.actions_definition
hdDV.setConfiguration(dDV);
LOG.info("returning {}", hdDV);
return hdDV;
}
ConfigurationDV<List<ItemFieldDV>> dDV = new ConfigurationDV<List<ItemFieldDV>>(listItemFields);
dDV.setConfiguration(listItemFields);
dDV.setConfigurationType(geoportalConfigType); //-> GEOPORTAL_CONFIGURATION_TYPE.item_fields
hdDV.setConfiguration(dDV);
LOG.info("returning {}", hdDV);
return hdDV;
}
default:
break;
default:
break;
}
}
} catch (Exception e) {
@ -372,6 +402,30 @@ public class ConvertToDataValueObjectModel {
return ifDV;
}
/**
* To action definition.
*
* @param actionDefinition the action definition
* @return the action definition DV
*/
public static ActionDefinitionDV toActionDefinition(ActionDefinition actionDefinition) {
LOG.trace("toActionDefinition called");
if (actionDefinition == null) {
LOG.warn(ActionDefinition.class.getSimpleName() + " is null");
return null;
}
ActionDefinitionDV actDef = new ActionDefinitionDV();
actDef.setId(actionDefinition.getId());
actDef.setCallSteps(actionDefinition.getCall_STEPS());
actDef.setDescription(actionDefinition.getDescription());
actDef.setDisplayOnPhase(actionDefinition.getDisplay_on_phase());
LOG.info("returning: " + actionDefinition);
return actDef;
}
/**
* To file path DV.
*
@ -712,34 +766,86 @@ public class ConvertToDataValueObjectModel {
return documentDV;
}
public static final DateTimeFormatter FULL_FORMATTER=DateTimeFormatter.ofPattern("uuuuMMdd_HH-mm-ss");
public static final DateTimeFormatter FULL_FORMATTER = DateTimeFormatter.ofPattern("uuuuMMdd_HH-mm-ss");
/**
* The Class MyLocalDateSerializer.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Sep 9, 2022
*/
public static class MyLocalDateSerializer extends JsonSerializer<LocalDate> {
@Override
public void serialize(LocalDate value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeString(value.format(FULL_FORMATTER));
}
}
public static class ParseDeserializer extends StdDeserializer<LocalDateTime> {
public ParseDeserializer() {
super(LocalDateTime.class);
}
@Override
public LocalDateTime deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
return LocalDateTime.parse(p.getValueAsString()); // or overloaded with an appropriate format
}
/**
* Serialize.
*
* @param value the value
* @param gen the gen
* @param serializers the serializers
* @throws IOException Signals that an I/O exception has occurred.
*/
@Override
public void serialize(LocalDate value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
gen.writeString(value.format(FULL_FORMATTER));
}
}
public static class MyLocalDateDeserializer extends JsonDeserializer<LocalDate> {
/**
* The Class ParseDeserializer.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Sep 9, 2022
*/
public static class ParseDeserializer extends StdDeserializer<LocalDateTime> {
@Override
public LocalDate deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
return LocalDate.parse(p.getValueAsString(),FULL_FORMATTER);
}
}
/**
* Instantiates a new parses the deserializer.
*/
public ParseDeserializer() {
super(LocalDateTime.class);
}
/**
* Deserialize.
*
* @param p the p
* @param ctxt the ctxt
* @return the local date time
* @throws IOException Signals that an I/O exception has occurred.
* @throws JsonProcessingException the json processing exception
*/
@Override
public LocalDateTime deserialize(JsonParser p, DeserializationContext ctxt)
throws IOException, JsonProcessingException {
return LocalDateTime.parse(p.getValueAsString()); // or overloaded with an appropriate format
}
}
/**
* The Class MyLocalDateDeserializer.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Sep 9, 2022
*/
public static class MyLocalDateDeserializer extends JsonDeserializer<LocalDate> {
/**
* Deserialize.
*
* @param p the p
* @param ctxt the ctxt
* @return the local date
* @throws IOException Signals that an I/O exception has occurred.
*/
@Override
public LocalDate deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
return LocalDate.parse(p.getValueAsString(), FULL_FORMATTER);
}
}
/**
* Fill map.
@ -754,32 +860,33 @@ public class ConvertToDataValueObjectModel {
Object value = document.get(key);
String keyLower = key.toLowerCase();
/*
ObjectMapper objectMapper = new ObjectMapper();
JavaTimeModule javaTimeModule = new JavaTimeModule();
javaTimeModule.addDeserializer(LocalDateTime.class, new ParseDeserializer());
// javaTimeModule.addSerializer(LocalDate.class, new MyLocalDateSerializer());
objectMapper.registerModule(javaTimeModule);
* ObjectMapper objectMapper = new ObjectMapper(); JavaTimeModule javaTimeModule
* = new JavaTimeModule(); javaTimeModule.addDeserializer(LocalDateTime.class,
* new ParseDeserializer()); // javaTimeModule.addSerializer(LocalDate.class,
* new MyLocalDateSerializer()); objectMapper.registerModule(javaTimeModule);
*
* objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
* objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS,
* false); objectMapper.configure(SerializationFeature.
* WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false);
*/
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
objectMapper.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false);
*/
//checking if the key is a Date
// checking if the key is a Date
for (String possibleDate : KEYSET_POSSIBLE_DATE) {
if (keyLower.contains(possibleDate)) {
try {
LOG.debug("value "+value+" is instance of: "+value.getClass());
LOG.debug("value " + value + " is instance of: " + value.getClass());
Document documentDate = new Document((Map) value);
String jsonValue = documentDate.toJson();
LOG.debug("jsonValue "+value);
//LocalDate asDate = objectMapper.readerFor(LocalDate.class).readValue(jsonValue);
LocalDateTime asDate = org.gcube.application.geoportal.client.utils.Serialization.read(jsonValue, LocalDateTime.class);
LOG.debug("jsonValue " + value);
// LocalDate asDate =
// objectMapper.readerFor(LocalDate.class).readValue(jsonValue);
LocalDateTime asDate = org.gcube.application.geoportal.client.utils.Serialization.read(jsonValue,
LocalDateTime.class);
LOG.info("Casted as date: " + asDate);
value = asDate;
break;
@ -788,19 +895,33 @@ public class ConvertToDataValueObjectModel {
}
}
}
documentAsMap.put(key, value);
return documentAsMap;
}
public class LocalDateDeserializer extends JsonDeserializer<LocalDate> {
@Override
public LocalDate deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
return LocalDate.parse(p.getValueAsString());
}
}
/**
* The Class LocalDateDeserializer.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Sep 9, 2022
*/
public class LocalDateDeserializer extends JsonDeserializer<LocalDate> {
/**
* Deserialize.
*
* @param p the p
* @param ctxt the ctxt
* @return the local date
* @throws IOException Signals that an I/O exception has occurred.
*/
@Override
public LocalDate deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
return LocalDate.parse(p.getValueAsString());
}
}
/**
* To relationship DV.
@ -835,10 +956,10 @@ public class ConvertToDataValueObjectModel {
liDV.setPhase(li.getPhase());
liDV.setErrorMessages(li.getErrorMessages());
liDV.setLastInvokedStep(li.getLastInvokedStep());
if(li.getLastEvent()!=null)
if (li.getLastEvent() != null)
liDV.setLastEvent(li.getLastEvent().getEvent());
liDV.setLastOperationStatus(toLifecycleInformationDVStatus(li.getLastOperationStatus()));
liDV.setWarningMessages(li.getWarningMessages());
liDV.setAsJSONString(toJSON(li));

View File

@ -360,9 +360,9 @@ public class ProjectsCaller {
for (ItemFieldDV itemField : orderByFields) {
if (itemField.getJsonFields() != null) {
for (String field : itemField.getJsonFields()) {
String fieldFullPath = String.format("%s.%s", itemField.getProjection(), field);
orderingFields.add(fieldFullPath);
for (String jsonFieldPath : itemField.getJsonFields()) {
//String fieldFullPath = String.format("%s.%s", itemField.getProjection(), field);
orderingFields.add(jsonFieldPath);
}
}

View File

@ -0,0 +1,34 @@
package org.gcube.application.geoportalcommon.geoportal.config;
import javax.xml.bind.annotation.XmlRootElement;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
@Data
@XmlRootElement(name = "actionsDefinition")
@Slf4j
public class ActionDefinition {
@JsonProperty
private String id;
@JsonProperty
private String title;
@JsonProperty
private String[] call_STEPS;
@JsonProperty
private String description;
@JsonProperty
private String[] display_on_phase;
@JsonProperty
private boolean searchable;
private String configID;
public ActionDefinition() {
}
}

View File

@ -1,43 +0,0 @@
//package org.gcube.application.geoportalcommon.geoportal.config;
//
//import java.util.List;
//
//import javax.xml.bind.annotation.XmlRootElement;
//
//import com.fasterxml.jackson.annotation.JsonProperty;
//
//import lombok.Data;
//import lombok.extern.slf4j.Slf4j;
//
//@Data
//@XmlRootElement
//@Slf4j
//public class HandlerGcubeProfile {
//
// @JsonProperty
// private String gcubeSecondaryType;
//
// @JsonProperty
// private String gcubeName;
//
// @JsonProperty
// private String sectionName;
//
// @JsonProperty
// private String sectionTitle;
//
// @JsonProperty
// private Integer minOccurs;
//
// @JsonProperty
// private Integer maxOccurs;
//
// @JsonProperty
// private String parentName;
//
// @JsonProperty(value = "filePaths")
// private List<FilePath> listFilePaths;
//
//
//
//}

View File

@ -0,0 +1,103 @@
package org.gcube.application.geoportalcommon.shared.geoportal.config;
import java.io.Serializable;
import java.util.Arrays;
public class ActionDefinitionDV implements GeoportalConfigurationID, Serializable {
/**
*
*/
private static final long serialVersionUID = 6071900142588642601L;
private String id;
private String title;
private String[] callSteps;
private String description;
private String[] displayOnPhase;
private String configID;
public ActionDefinitionDV() {
}
@Override
public String getID() {
// TODO Auto-generated method stub
return null;
}
@Override
public void setID(String configID) {
// TODO Auto-generated method stub
}
public String getId() {
return id;
}
public String getTitle() {
return title;
}
public String[] getCallSteps() {
return callSteps;
}
public String getDescription() {
return description;
}
public String[] getDisplayOnPhase() {
return displayOnPhase;
}
public String getConfigID() {
return configID;
}
public void setId(String id) {
this.id = id;
}
public void setTitle(String title) {
this.title = title;
}
public void setCallSteps(String[] callSteps) {
this.callSteps = callSteps;
}
public void setDescription(String description) {
this.description = description;
}
public void setDisplayOnPhase(String[] displayOnPhase) {
this.displayOnPhase = displayOnPhase;
}
public void setConfigID(String configID) {
this.configID = configID;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("ActionDefinitionDV [id=");
builder.append(id);
builder.append(", title=");
builder.append(title);
builder.append(", callSteps=");
builder.append(Arrays.toString(callSteps));
builder.append(", description=");
builder.append(description);
builder.append(", displayOnPhase=");
builder.append(Arrays.toString(displayOnPhase));
builder.append(", configID=");
builder.append(configID);
builder.append("]");
return builder.toString();
}
}

View File

@ -25,9 +25,6 @@ public class ItemFieldDV implements GeoportalConfigurationID, Serializable {
private String configID;
// This is the prefix of the document projection, e.g. _theDocument
private String projection = "_theDocument";
/**
* Instantiates a new item field.
*/
@ -175,15 +172,6 @@ public class ItemFieldDV implements GeoportalConfigurationID, Serializable {
this.searchable = searchable;
}
//THIS ONE MUST BE REVISITED. MUST BE PASSED IN THE CONFIGURATION
public String getProjection() {
return projection;
}
// public void setProjection(String projection) {
// this.projection = projection;
// }
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
@ -201,8 +189,6 @@ public class ItemFieldDV implements GeoportalConfigurationID, Serializable {
builder.append(searchable);
builder.append(", configID=");
builder.append(configID);
builder.append(", projection=");
builder.append(projection);
builder.append("]");
return builder.toString();
}

View File

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