aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be
diff options
context:
space:
mode:
authorojasdubey <ojas.dubey@amdocs.com>2018-07-19 14:23:40 +0530
committerAvi Gaffa <avi.gaffa@amdocs.com>2018-07-19 14:04:23 +0000
commit7bfba3ec8f482a36884f9675bf8b2f3ca8b56033 (patch)
tree5f14be55a2a9984d2fb8b8896c28835125d00d7f /catalog-be
parentf1d0e936a6a99d81f2d3e74825a717e7440285ea (diff)
Bugfix - Workflow operation input type tosca
Fix for incorrect type being populated for workflow operation inputs Change-Id: I5a70153b5bde289b8e5f499a9f3f1f21c4786ce6 Issue-ID: SDC-1528 Signed-off-by: ojasdubey <ojas.dubey@amdocs.com>
Diffstat (limited to 'catalog-be')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtil.java27
2 files changed, 22 insertions, 7 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
index 8d8eac36b9..4455c3205a 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
@@ -577,10 +577,10 @@ public class ToscaExportHandler {
inputDef.forEach(i -> {
ToscaProperty property = propertyConvertor.convertProperty(dataTypes, i, false);
inputs.put(i.getName(), property);
- addInterfaceDefinitionElement(component, toscaNodeType);
});
if (!inputs.isEmpty()) {
toscaNodeType.setProperties(inputs);
+ addInterfaceDefinitionElement(component, toscaNodeType);
}
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtil.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtil.java
index 8c9c63af03..75a65f95da 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtil.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtil.java
@@ -16,6 +16,7 @@
package org.openecomp.sdc.be.tosca.utils;
+import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.ArrayList;
import java.util.HashMap;
@@ -132,7 +133,7 @@ public class InterfacesOperationsToscaUtil {
toscaOperation.setImplementation(operationArtifactPath);
}
toscaOperation.setDescription(operationEntry.getValue().getDescription());
- fillToscaOperationInputs(operationEntry.getValue(), toscaOperation);
+ fillToscaOperationInputs(operationEntry.getValue(), toscaOperation, nodeType);
toscaOperations.put(operationEntry.getValue().getName(), toscaOperation);
}
@@ -179,7 +180,8 @@ public class InterfacesOperationsToscaUtil {
}
private static void fillToscaOperationInputs(OperationDataDefinition operation,
- ToscaLifecycleOperationDefinition toscaOperation) {
+ ToscaLifecycleOperationDefinition toscaOperation,
+ ToscaNodeType nodeType) {
if (Objects.isNull(operation.getInputs()) || operation.getInputs().isEmpty()) {
toscaOperation.setInputs(null);
return;
@@ -189,15 +191,23 @@ public class InterfacesOperationsToscaUtil {
for (OperationInputDefinition input : operation.getInputs().getListToscaDataDefinition()) {
ToscaProperty toscaInput = new ToscaProperty();
toscaInput.setDescription(input.getDescription());
- toscaInput.setType(DEFAULT_INPUT_TYPE);
-
- toscaInput.setDefaultp(createDefaultValue(getLastPartOfName(input.getInputId())));
+ String mappedPropertyName = getLastPartOfName(input.getInputId());
+ toscaInput.setType(getOperationInputType(mappedPropertyName, nodeType));
+ toscaInput.setDefaultp(createDefaultValue(mappedPropertyName));
toscaInputs.put(input.getName(), toscaInput);
}
toscaOperation.setInputs(toscaInputs);
}
+ private static String getOperationInputType(String inputName, ToscaNodeType nodeType) {
+ if (nodeType.getProperties() != null
+ && nodeType.getProperties().containsKey(inputName)) {
+ return nodeType.getProperties().get(inputName).getType();
+ }
+ return DEFAULT_INPUT_TYPE;
+ }
+
private static Map<String, List<String>> createDefaultValue(String propertyName) {
Map<String, List<String>> getPropertyMap = new HashMap<>();
List<String> values = new ArrayList<>();
@@ -210,8 +220,13 @@ public class InterfacesOperationsToscaUtil {
private static Map<String, Object> getObjectAsMap(Object obj) {
+ ObjectMapper objectMapper = new ObjectMapper();
+ if (obj instanceof ToscaInterfaceDefinition) {
+ //Prevent empty field serialization in interface definition
+ objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
+ }
Map<String, Object> objectAsMap =
- obj instanceof Map ? (Map<String, Object>) obj : new ObjectMapper().convertValue(obj, Map.class);
+ obj instanceof Map ? (Map<String, Object>) obj : objectMapper.convertValue(obj, Map.class);
if (objectAsMap.containsKey(DEFAULT)) {
Object defaultValue = objectAsMap.get(DEFAULT);