summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/java/org
diff options
context:
space:
mode:
authorJvD_Ericsson <jeff.van.dam@est.tech>2023-07-25 09:47:41 +0100
committerMichael Morris <michael.morris@est.tech>2023-09-22 07:43:02 +0000
commit27633293d6d45521ea985019ea7b99c2009b62c7 (patch)
tree1e3df4c1aa47c14c2cb5abeb19080056748353a3 /catalog-be/src/main/java/org
parent629837b3f7a282c74604987fd531ff4523f98a0c (diff)
Backend support for operation milestones with activity inputs
Issue-ID: SDC-4582 Signed-off-by: JvD_Ericsson <jeff.van.dam@est.tech> Change-Id: I625ec9bb05790bb5f9e78ed9d65abda8f8af5ec3
Diffstat (limited to 'catalog-be/src/main/java/org')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceDefinitionHandler.java15
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverter.java20
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaActivity.java2
3 files changed, 34 insertions, 3 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceDefinitionHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceDefinitionHandler.java
index 9f0adcf217..c8d7862306 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceDefinitionHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceDefinitionHandler.java
@@ -31,6 +31,7 @@ import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.OPERATIONS;
import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.REQUIRED;
import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.STATUS;
import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.TYPE;
+import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.VALUE;
import static org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum.WORKFLOW;
import com.google.gson.Gson;
@@ -211,10 +212,13 @@ public class InterfaceDefinitionHandler {
for (Object activityValue : milestoneActivities) {
ActivityDataDefinition activity = new ActivityDataDefinition();
if (activityValue instanceof Map) {
- Map<String, String> activityMap = (Map<String, String>) activityValue;
+ Map<String, Object> activityMap = (Map<String, Object>) activityValue;
+ if (activityMap.containsKey(INPUTS.getElementName())) {
+ activity.setInputs(handleInterfaceOperationInputs((Map<String, Object>) activityMap.get(INPUTS.getElementName())));
+ }
if (activityMap.containsKey(TYPE.getElementName()) && activityMap.containsKey(WORKFLOW.getElementName())) {
- activity.setType(activityMap.get(TYPE.getElementName()));
- activity.setWorkflow(activityMap.get(WORKFLOW.getElementName()));
+ activity.setType((String) activityMap.get(TYPE.getElementName()));
+ activity.setWorkflow((String) activityMap.get(WORKFLOW.getElementName()));
activities.add(activity);
} else {
return new ListDataDefinition<>();
@@ -268,6 +272,11 @@ public class InterfaceDefinitionHandler {
LOGGER.debug(WITH_ATTRIBUTE, DEFAULT.getElementName(), json);
operationInput.setToscaDefaultValue(json);
}
+ if (inputPropertyValue.get(VALUE.getElementName()) != null) {
+ final Gson gson = new Gson();
+ final String json = gson.toJson(inputPropertyValue.get(VALUE.getElementName()));
+ operationInput.setValue(json);
+ }
if (inputPropertyValue.get(STATUS.getElementName()) != null) {
final String status = inputPropertyValue.get(STATUS.getElementName()).toString();
LOGGER.debug(WITH_ATTRIBUTE, STATUS.getElementName(), status);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverter.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverter.java
index e95f16eaac..52fdfcc4e5 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverter.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/InterfacesOperationsConverter.java
@@ -36,6 +36,7 @@ import java.util.Set;
import java.util.stream.Collectors;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.openecomp.sdc.be.datatypes.elements.ActivityDataDefinition;
@@ -332,6 +333,10 @@ public class InterfacesOperationsConverter {
Map<String, ToscaActivity> toscaActivityMap = new HashMap<>();
ToscaActivity toscaActivity = new ToscaActivity();
toscaActivity.setWorkflow(activity.getWorkflow());
+ Map<String, Object> inputs = getToscaActivityInputs(activity.getInputs(), dataTypes);
+ if (!inputs.isEmpty()) {
+ toscaActivity.setInputs(inputs);
+ }
toscaActivityMap.put(activity.getType(), toscaActivity);
toscaActivities.add(toscaActivityMap);
}
@@ -342,6 +347,21 @@ public class InterfacesOperationsConverter {
toscaOperation.setMilestones(toscaMilestones);
}
+ private Map<String, Object> getToscaActivityInputs(ListDataDefinition<OperationInputDefinition> inputs,
+ Map<String, DataTypeDefinition> dataTypes) {
+ if (Objects.isNull(inputs) || inputs.isEmpty()) {
+ return null;
+ }
+ Map<String, Object> toscaInputs = new HashMap<>();
+ for (OperationInputDefinition input : inputs.getListToscaDataDefinition()) {
+ Object value = propertyConvertor.convertToToscaObject(input, getInputValue(input), dataTypes, false);
+ if (ObjectUtils.isNotEmpty(value)) {
+ toscaInputs.put(input.getName(), value);
+ }
+ }
+ return toscaInputs;
+ }
+
private boolean operationHasAnImplementation(OperationDataDefinition operation) {
return operation.getImplementation() != null && StringUtils.isNotEmpty(operation.getImplementation().getArtifactName()) &&
!operation.getImplementation().getArtifactName().equals("''");
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaActivity.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaActivity.java
index 736988e85e..3f33bc7ab3 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaActivity.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaActivity.java
@@ -21,10 +21,12 @@
package org.openecomp.sdc.be.tosca.model;
+import java.util.Map;
import lombok.Data;
@Data
public class ToscaActivity {
String workflow;
+ private Map<String, Object> inputs;
}