diff options
Diffstat (limited to 'catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/InputsOperation.java')
-rw-r--r-- | catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/InputsOperation.java | 114 |
1 files changed, 0 insertions, 114 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/InputsOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/InputsOperation.java index dba4ff9b75..d3db95df65 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/InputsOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/InputsOperation.java @@ -1210,121 +1210,7 @@ public class InputsOperation extends AbstractOperation implements IInputsOperati } - public Either<List<InputDefinition>, StorageOperationStatus> addInputsToComponent(String resourceId, NodeTypeEnum nodeType, ComponentInstInputsMap componentInsInputs, Map<String, DataTypeDefinition> dataTypes) { - List<InputDefinition> resList = new ArrayList<InputDefinition>(); - Map<String, List<InputDefinition>> newInputsMap = componentInsInputs.getComponentInstanceInputsMap(); - if (newInputsMap != null && !newInputsMap.isEmpty()) { - for (Entry<String, List<InputDefinition>> entry : newInputsMap.entrySet()) { - String compInstId = entry.getKey(); - Either<TitanVertex, TitanOperationStatus> ciVertexEither = titanGenericDao.getVertexByProperty(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), compInstId); - if (ciVertexEither.isRight()) { - log.debug("Failed to fetch vertex of resource instance for id {} error {}", compInstId, ciVertexEither.right().value()); - return Either.right( DaoStatusConverter.convertTitanStatusToStorageStatus(ciVertexEither.right().value())); - } - TitanVertex ciVertex = ciVertexEither.left().value(); - - - //String originType = (String) titanGenericDao.getProperty(originVertex, GraphPropertiesDictionary.LABEL.getProperty()); - String compInstname = (String) titanGenericDao.getProperty(ciVertex, GraphPropertiesDictionary.NORMALIZED_NAME.getProperty()); - - List<InputDefinition> inputs = entry.getValue(); - - if (inputs != null && !inputs.isEmpty()) { - for (InputDefinition input : inputs) { - - - Either<Integer, StorageOperationStatus> counterRes = componentInstanceOperation.increaseAndGetResourceInstanceSpecificCounter(compInstId, GraphPropertiesDictionary.INPUT_COUNTER, true); - if (counterRes.isRight()) { - log.debug("increaseAndGetResourceInputCounter failed resource instance {}", compInstId); - StorageOperationStatus status = counterRes.right().value(); - return Either.right(status); - } - - Either<InputDefinition, TitanOperationStatus> oldInputEither = getInputFromGraph(input.getUniqueId(), true, true); - if (oldInputEither.isRight()) { - log.error("Failed to get input {} ", input.getUniqueId()); - - return Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(oldInputEither.right().value())); - } - - InputDefinition oldInput = oldInputEither.left().value(); - String serviceInputName = compInstname + "_" + input.getName(); - input.setName(serviceInputName); - - JSONObject jobject = new JSONObject(); - jobject.put(GET_INPUT, input.getName()); - - ComponentInstanceInput inputValue = new ComponentInstanceInput(oldInput, jobject.toJSONString(), null); - Integer index = counterRes.left().value(); - - Either<ComponentInstanceInput, StorageOperationStatus> eitherStatus = componentInstanceOperation.addInputValueToResourceInstance(inputValue, compInstId, index, true); - - if (eitherStatus.isRight()) { - log.error("Failed to add input value {} to resource instance {} in Graph. status is {}", inputValue, compInstId, eitherStatus.right().value().name()); - - return Either.right(eitherStatus.right().value()); - } - ComponentInstanceInput inputValueData = eitherStatus.left().value(); - - input.setSchema(oldInputEither.left().value().getSchema()); - input.setDefaultValue(oldInput.getDefaultValue()); - input.setConstraints(oldInput.getConstraints()); - input.setDescription(oldInput.getDescription()); - input.setHidden(oldInput.isHidden()); - input.setImmutable(oldInput.isImmutable()); - input.setDefinition(oldInput.isDefinition()); - input.setRequired(oldInput.isRequired()); - - StorageOperationStatus validateAndUpdateProperty = validateAndUpdateProperty(input, dataTypes); - if (validateAndUpdateProperty != StorageOperationStatus.OK) { - log.error("Property {} is invalid. Status is {}", input, validateAndUpdateProperty); - return Either.right(validateAndUpdateProperty); - } - - Either<InputsData, TitanOperationStatus> addPropertyToGraph = addInputToGraph(serviceInputName, input, resourceId, nodeType); - if (addPropertyToGraph.isRight()) { - return Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(addPropertyToGraph.right().value())); - } - InputDefinition createdInputyDefinition = convertInputDataToInputDefinition(addPropertyToGraph.left().value()); - createdInputyDefinition.setName(serviceInputName); - createdInputyDefinition.setParentUniqueId(resourceId); - - Map<String, Object> props = new HashMap<String, Object>(); - props.put(GraphEdgePropertiesDictionary.NAME.getProperty(), createdInputyDefinition.getName()); - props.put(GraphEdgePropertiesDictionary.OWNER_ID.getProperty(), compInstId); - - GraphNode propertyData = new UniqueIdData(NodeTypeEnum.InputValue, inputValueData.getValueUniqueUid()); - - Either<GraphRelation, TitanOperationStatus> addPropRefResult = titanGenericDao.createRelation(addPropertyToGraph.left().value(), propertyData, GraphEdgeLabels.GET_INPUT, props); - - if (addPropRefResult.isRight()) { - TitanOperationStatus status = addPropRefResult.right().value(); - String description = "Failed to associate input " + addPropertyToGraph.left().value().getUniqueId() + " to input value " + inputValueData.getUniqueId() + " in graph. Status is " + status; - BeEcompErrorManager.getInstance().logInternalFlowError(ASSOCIATING_INPUT_TO_PROP, description, ErrorSeverity.ERROR); - return Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(status)); - } - - resList.add(createdInputyDefinition); - - } - } - - } - } - Map<String, List<ComponentInstancePropInput>> newInputsPropsMap = componentInsInputs.getComponentInstanceProperties(); - if (newInputsPropsMap != null && !newInputsPropsMap.isEmpty()) { - Either<List<InputDefinition>, StorageOperationStatus> result = createInputsFromProperty(resourceId, nodeType, dataTypes, resList, newInputsPropsMap); - - if (result.isRight()) { - log.debug("Failed to create inputs of resource for id {} error {}", resourceId, result.right().value()); - return result; - } - resList = result.left().value(); - - } - return Either.left(resList); - } private Either<List<InputDefinition>, StorageOperationStatus> createInputsFromProperty(String resourceId, NodeTypeEnum nodeType, Map<String, DataTypeDefinition> dataTypes, List<InputDefinition> resList, Map<String, List<ComponentInstancePropInput>> newInputsPropsMap) { for (Entry<String, List<ComponentInstancePropInput>> entry : newInputsPropsMap.entrySet()) { |