aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/java
diff options
context:
space:
mode:
authormojahidi <mojahidul.islam@amdocs.com>2018-06-22 16:37:52 +0530
committerOren Kleks <orenkle@amdocs.com>2018-06-26 11:27:30 +0000
commit4720f5aea7d548701a832b965a2b0e38dbc3bc4a (patch)
tree0a85184267f75ccdb1a211a06f503616894c6472 /catalog-be/src/main/java
parent82c94daf74c08f111f6ce31c832df3f5583b14f7 (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-be/src/main/java')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/InterfaceOperationValidation.java49
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/InterfaceUIDataConverter.java22
2 files changed, 69 insertions, 2 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/InterfaceOperationValidation.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/InterfaceOperationValidation.java
index aa58c14227..e57c7b9496 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/InterfaceOperationValidation.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/InterfaceOperationValidation.java
@@ -89,6 +89,13 @@ public class InterfaceOperationValidation {
if(inputParametersResponse.isRight()) {
return Either.right(inputParametersResponse.right().value());
}
+
+ Either<Boolean, ResponseFormat> outputParametersResponse = validateOutputParameters(interfaceOperation,
+ responseFormatManager);
+ if(outputParametersResponse.isRight()) {
+ return Either.right(outputParametersResponse.right().value());
+ }
+
return Either.left(Boolean.TRUE);
}
@@ -223,6 +230,28 @@ public class InterfaceOperationValidation {
return Either.left(Boolean.TRUE);
}
+
+ private Either<Boolean, ResponseFormat> validateOutputParameters(Operation interfaceOperation,
+ ResponseFormatManager responseFormatManager) {
+ if (isOutputParameterNameEmpty(interfaceOperation)) {
+ LOGGER.error("Interface operation output parameter name can't be empty");
+ ResponseFormat inputResponse = responseFormatManager.getResponseFormat(ActionStatus
+ .INTERFACE_OPERATION_OUTPUT_NAME_MANDATORY);
+ return Either.right(inputResponse);
+ }
+
+ Either<Boolean, Set<String>> validateOutputParametersUniqueResponse = isOutputParametersUnique(interfaceOperation);
+ if(validateOutputParametersUniqueResponse.isRight()) {
+ LOGGER.error("Interface operation output parameter names {} already in use",
+ validateOutputParametersUniqueResponse.right().value().toString());
+ ResponseFormat inputResponse = responseFormatManager.getResponseFormat(ActionStatus
+ .INTERFACE_OPERATION_OUTPUT_NAME_ALREADY_IN_USE, validateOutputParametersUniqueResponse.right().value().toString());
+ return Either.right(inputResponse);
+ }
+ return Either.left(Boolean.TRUE);
+ }
+
+
private Either<Boolean, Set<String>> isInputParametersUnique(Operation operationDataDefinition) {
Set<String> inputParamNamesSet = new HashSet<>();
Set<String> duplicateParamNamesToReturn = new HashSet<>();
@@ -238,11 +267,29 @@ public class InterfaceOperationValidation {
return Either.left(Boolean.TRUE);
}
+ private Either<Boolean, Set<String>> isOutputParametersUnique(Operation operationDataDefinition) {
+ Set<String> outputParamNamesSet = new HashSet<>();
+ Set<String> duplicateParamNamesToReturn = new HashSet<>();
+ operationDataDefinition.getOutputs().getListToscaDataDefinition()
+ .forEach(outputParam -> {
+ if(!outputParamNamesSet.add(outputParam.getName().trim())) {
+ duplicateParamNamesToReturn.add(outputParam.getName().trim());
+ }
+ });
+ if(!duplicateParamNamesToReturn.isEmpty()) {
+ return Either.right(duplicateParamNamesToReturn);
+ }
+ return Either.left(Boolean.TRUE);
+ }
+
private Boolean isInputParameterNameEmpty(Operation operationDataDefinition) {
return operationDataDefinition.getInputs().getListToscaDataDefinition().stream()
.anyMatch(inputParam -> inputParam.getName() == null || inputParam.getName().trim().equals(StringUtils.EMPTY));
}
-
+ private Boolean isOutputParameterNameEmpty(Operation operationDataDefinition) {
+ return operationDataDefinition.getInputs().getListToscaDataDefinition().stream()
+ .anyMatch(inputParam -> inputParam.getName() == null || inputParam.getName().trim().equals(StringUtils.EMPTY));
+ }
private boolean validateOperationTypeUniqueForUpdate(Operation interfaceOperation,
Map<String, String> operationTypes) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/InterfaceUIDataConverter.java b/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/InterfaceUIDataConverter.java
index 78b2354615..2db551643c 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/InterfaceUIDataConverter.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/InterfaceUIDataConverter.java
@@ -23,6 +23,7 @@ import org.openecomp.sdc.be.datatypes.elements.InterfaceOperationDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.InterfaceOperationParamDataDefinition;
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.Operation;
public class InterfaceUIDataConverter {
@@ -40,11 +41,21 @@ public class InterfaceUIDataConverter {
interfaceOperationParamDataDefinition.getParamId())).collect(Collectors.toList());
inputList.forEach(inputs::add);
}
+ ListDataDefinition<InterfaceOperationParamDataDefinition> outputParams = interfaceOperation.getOutputParams();
+ ListDataDefinition<OperationOutputDefinition> outputs = new ListDataDefinition<>();
+ if(outputParams != null) {
+ List<OperationOutputDefinition> outputList = outputParams.getListToscaDataDefinition().stream()
+ .map(interfaceOperationParamDataDefinition -> new OperationOutputDefinition(interfaceOperationParamDataDefinition.getParamName(),
+ interfaceOperationParamDataDefinition.getParamId())).collect(Collectors.toList());
+ outputList.forEach(outputs::add);
+ }
+
Operation operationData = new Operation();
operationData.setDescription(interfaceOperation.getDescription());
operationData.setName(interfaceOperation.getOperationType());
operationData.setUniqueId(interfaceOperation.getUniqueId());
operationData.setInputs(inputs);
+ operationData.setOutputs(outputs);
return operationData;
}
@@ -53,16 +64,25 @@ public class InterfaceUIDataConverter {
ListDataDefinition<OperationInputDefinition> inputs = operationData.getInputs();
List<InterfaceOperationParamDataDefinition> inputParamList = inputs.getListToscaDataDefinition().stream()
- .map(a -> new InterfaceOperationParamDataDefinition(a.getName(), a.getInputId())).collect(
+ .map(operationInputDefinition -> new InterfaceOperationParamDataDefinition(operationInputDefinition.getName(),
+ operationInputDefinition.getInputId())).collect(
Collectors.toList());
ListDataDefinition<InterfaceOperationParamDataDefinition> inputParams = new ListDataDefinition<>();
inputParamList.forEach(inputParams::add);
+ ListDataDefinition<OperationOutputDefinition> outputs = operationData.getOutputs();
+ List<InterfaceOperationParamDataDefinition> outputParamList = outputs.getListToscaDataDefinition()
+ .stream().map(operationOutputDefinition -> new InterfaceOperationParamDataDefinition(operationOutputDefinition.getName(),
+ operationOutputDefinition.getInputId())).collect(Collectors.toList());
+ ListDataDefinition<InterfaceOperationParamDataDefinition> outputParams = new ListDataDefinition<>();
+ outputParamList.forEach(outputParams::add);
+
InterfaceOperationDataDefinition interfaceOperationDataDefinition = new InterfaceOperationDataDefinition();
interfaceOperationDataDefinition.setUniqueId(operationData.getUniqueId());
interfaceOperationDataDefinition.setOperationType(operationData.getName());
interfaceOperationDataDefinition.setDescription(operationData.getDescription());
interfaceOperationDataDefinition.setInputParams(inputParams);
+ interfaceOperationDataDefinition.setOutputParams(outputParams);
interfaceOperationDataDefinition.setArtifactUUID(operationData.getImplementation().getArtifactUUID());
return interfaceOperationDataDefinition;