diff options
author | KrupaNagabhushan <krupa.nagabhushan@est.tech> | 2020-11-19 14:28:00 +0000 |
---|---|---|
committer | Christophe Closset <christophe.closset@intl.att.com> | 2021-01-14 13:56:39 +0000 |
commit | 3849231a17930b1bb2ba09af15673bfd07538b9d (patch) | |
tree | 9ca26d4457093bbb30924d6731b5615e795ed238 /catalog-model/src/main/java/org | |
parent | 0d38c9a8ed4701b860901f67049920e9b1ca72f2 (diff) |
Create inputs independent of properties
Issue-ID: SDC-3431
Signed-off-by: KrupaNagabhushan <krupa.nagabhushan@est.tech>
Change-Id: I4f29d0e490a14292fd1aa9f96ca6621b37f325d8
Diffstat (limited to 'catalog-model/src/main/java/org')
-rw-r--r-- | catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java index 957c5f9d66..532a641e2f 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java @@ -2482,6 +2482,46 @@ public class ToscaOperationFacade { return Either.left(newProperty); } + public Either<InputDefinition, StorageOperationStatus> addInputToComponent(String inputName, + InputDefinition newInputDefinition, + Component component) { + newInputDefinition.setName(inputName); + + StorageOperationStatus status = getToscaElementOperation(component) + .addToscaDataToToscaElement(component.getUniqueId(), EdgeLabelEnum.INPUTS, VertexTypeEnum.INPUTS, newInputDefinition, JsonPresentationFields.NAME); + if (status != StorageOperationStatus.OK) { + CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to add the input {} to the component {}. Status is {}. ", inputName, component.getName(), status); + return Either.right(status); + } + + ComponentParametersView filter = new ComponentParametersView(true); + filter.setIgnoreProperties(false); + filter.setIgnoreInputs(false); + Either<Component, StorageOperationStatus> getUpdatedComponentRes = getToscaElement(component.getUniqueId(), filter); + if (getUpdatedComponentRes.isRight()) { + CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to get updated component {}. Status is {}. ", component.getUniqueId(), getUpdatedComponentRes.right().value()); + return Either.right(status); + } + + InputDefinition newInput = null; + List<InputDefinition> inputs = + (getUpdatedComponentRes.left().value()).getInputs(); + if (CollectionUtils.isNotEmpty(inputs)) { + Optional<InputDefinition> inputOptional = inputs.stream().filter( + inputEntry -> inputEntry.getName().equals(inputName)).findAny(); + if (inputOptional.isPresent()) { + newInput = inputOptional.get(); + } + } + if (newInput == null) { + CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to find recently added input {} " + + "on the component {}. Status is {}. ", inputs, component.getUniqueId(), StorageOperationStatus.NOT_FOUND); + return Either.right(StorageOperationStatus.NOT_FOUND); + } + + return Either.left(newInput); + } + public StorageOperationStatus deletePropertyOfComponent(Component component, String propertyName) { return getToscaElementOperation(component).deleteToscaDataElement(component.getUniqueId(), EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, propertyName, JsonPresentationFields.NAME); } @@ -2536,8 +2576,7 @@ public class ToscaOperationFacade { return result; } - - public Either<AttributeDataDefinition, StorageOperationStatus> addAttributeOfResource(Component component, AttributeDataDefinition newAttributeDef) { + public Either<AttributeDataDefinition, StorageOperationStatus> addAttributeOfResource(Component component, AttributeDataDefinition newAttributeDef) { Either<Component, StorageOperationStatus> getUpdatedComponentRes = null; Either<AttributeDataDefinition, StorageOperationStatus> result = null; |