diff options
author | mojahidi <mojahidul.islam@amdocs.com> | 2018-06-22 16:37:52 +0530 |
---|---|---|
committer | Oren Kleks <orenkle@amdocs.com> | 2018-06-26 11:27:30 +0000 |
commit | 4720f5aea7d548701a832b965a2b0e38dbc3bc4a (patch) | |
tree | 0a85184267f75ccdb1a211a06f503616894c6472 /catalog-model/src/main/java/org | |
parent | 82c94daf74c08f111f6ce31c832df3f5583b14f7 (diff) |
Add output parameter support in Operation screen
Added code to support Output parameter, fixed UTs, Added flow test
Change-Id: I4ff869d120cefd7645a407278caeea6ee695c73b
Issue-ID: SDC-1440
Signed-off-by: mojahidi <mojahidul.islam@amdocs.com>
Diffstat (limited to 'catalog-model/src/main/java/org')
-rw-r--r-- | catalog-model/src/main/java/org/openecomp/sdc/be/model/Operation.java | 5 | ||||
-rw-r--r-- | catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/utils/InterfaceUtils.java | 28 |
2 files changed, 30 insertions, 3 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Operation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Operation.java index 066cd67fec..4455920d3d 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Operation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Operation.java @@ -24,6 +24,7 @@ import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition; import org.openecomp.sdc.be.datatypes.elements.OperationDataDefinition; import org.openecomp.sdc.be.datatypes.elements.OperationInputDefinition; +import org.openecomp.sdc.be.datatypes.elements.OperationOutputDefinition; /** * Defines an operation available to manage particular aspects of the Node Type. @@ -54,10 +55,12 @@ public class Operation extends OperationDataDefinition implements IOperationPara } public Operation(ArtifactDataDefinition implementation, String description, - ListDataDefinition<OperationInputDefinition> inputs) { + ListDataDefinition<OperationInputDefinition> inputs, + ListDataDefinition<OperationOutputDefinition> outputs) { super(description); setImplementation(implementation); setInputs(inputs); + setOutputs(outputs); } @Override diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/utils/InterfaceUtils.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/utils/InterfaceUtils.java index 6b22413d56..49f16946af 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/utils/InterfaceUtils.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/utils/InterfaceUtils.java @@ -29,6 +29,7 @@ import org.apache.commons.collections.MapUtils; import org.openecomp.sdc.be.datatypes.elements.InputDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition; import org.openecomp.sdc.be.datatypes.elements.OperationInputDefinition; +import org.openecomp.sdc.be.datatypes.elements.OperationOutputDefinition; import org.openecomp.sdc.be.model.InputDefinition; import org.openecomp.sdc.be.model.InterfaceDefinition; import org.openecomp.sdc.be.model.Operation; @@ -82,12 +83,14 @@ public class InterfaceUtils { } InterfaceDefinition interfaceDefinition = optionalInterface.get(); interfaceDefinition.getOperationsMap().values().stream() - .forEach(operation -> createInput(operation, resource.getInputs())); + .forEach(operation -> createInputOutput(operation, resource.getInputs())); + + return interfaceDefinition.getOperationsMap(); } - private static void createInput(Operation operation, List<InputDefinition> inputs) throws IllegalStateException { + private static void createInputOutput(Operation operation, List<InputDefinition> inputs) throws IllegalStateException { ListDataDefinition<OperationInputDefinition> inputDefinitionListDataDefinition = operation.getInputs(); if (inputDefinitionListDataDefinition != null) { return; @@ -97,8 +100,20 @@ public class InterfaceUtils { List<OperationInputDefinition> convertedInputs = listToscaDataDefinition.stream() .map(input -> convertInput(input, inputs)) .collect(Collectors.toList()); + + ListDataDefinition<OperationOutputDefinition> outputDefinitionListDataDefinition = operation.getOutputs(); + if (outputDefinitionListDataDefinition != null) { + return; + } + List<OperationOutputDefinition> outListToscaDefinition = outputDefinitionListDataDefinition + .getListToscaDataDefinition(); + List<OperationOutputDefinition> convertedOutputs = outListToscaDefinition.stream() + .map(operationOutputDefinition -> convertOutput(operationOutputDefinition, inputs) ) + .collect(Collectors.toList()); inputDefinitionListDataDefinition.getListToscaDataDefinition().clear(); inputDefinitionListDataDefinition.getListToscaDataDefinition().addAll(convertedInputs); + outputDefinitionListDataDefinition.getListToscaDataDefinition().clear(); + outputDefinitionListDataDefinition.getListToscaDataDefinition().addAll(convertedOutputs); } private static OperationInputDefinition convertInput(OperationInputDefinition input, @@ -111,6 +126,15 @@ public class InterfaceUtils { throw new IllegalStateException("Could not find input :"+ input.getLabel()); } + private static OperationOutputDefinition convertOutput(OperationOutputDefinition output, + List<InputDefinition> outputs) throws IllegalStateException { + Optional<InputDefinition> anyOutputDefinition = outputs.stream() + .filter(inp -> inp.getUniqueId().equals(output.getUniqueId())).findAny(); + if (anyOutputDefinition.isPresent()) { + return new OperationOutputDefinition(output.getLabel(),new InputDataDefinition(anyOutputDefinition.get())); + } + throw new IllegalStateException("Could not find output :"+ output.getLabel()); + } public static List<Operation> getOperationsFromInterface(Map<String, InterfaceDefinition> interfaces) { List<Operation> operationData = new ArrayList<>(); if (!MapUtils.isEmpty(interfaces)) { |