- private class AttributesDeclarationData {
-
- private final List<OutputDefinition> outputsToCreate;
- private final List<ATTRIBUTETYPE> attributesToUpdate;
-
- AttributesDeclarationData(final List<OutputDefinition> outputsToCreate,
- final List<ATTRIBUTETYPE> attributesToUpdate) {
- this.outputsToCreate = outputsToCreate;
- this.attributesToUpdate = attributesToUpdate;
- }
-
- List<OutputDefinition> getOutputsToCreate() {
- return outputsToCreate;
- }
-
- List<ATTRIBUTETYPE> getAttributesToUpdate() {
- return attributesToUpdate;
- }
- }
-
- Either<OutputDefinition, ResponseFormat> prepareValueBeforeDelete(final OutputDefinition inputForDelete,
- final AttributeDataDefinition inputValue,
- final List<String> pathOfComponentInstances) {
- final Either<OutputDefinition, ResponseFormat> deleteEither = prepareValueBeforeDelete(inputForDelete, inputValue);
-
-// Either<String, JanusGraphOperationStatus> findDefaultValue = propertyOperation
-// .findDefaultValueFromSecondPosition(pathOfComponentInstances, inputValue.getUniqueId(),
-// (String) inputValue.get_default());
-// if (findDefaultValue.isRight()) {
-// deleteEither = Either.right(componentsUtils.getResponseFormat(componentsUtils
-// .convertFromStorageResponse(
-// DaoStatusConverter.convertJanusGraphStatusToStorageStatus(findDefaultValue.right().value()))));
-// return deleteEither;
-//
-// }
-// String defaultValue = findDefaultValue.left().value();
-// inputValue.set_default(defaultValue);
-// log.debug("The returned default value in ResourceInstanceProperty is {}", defaultValue);
- return deleteEither;
- }
-
- private Either<OutputDefinition, ResponseFormat> prepareValueBeforeDelete(final OutputDefinition outputForDelete,
- final AttributeDataDefinition outputValue) {
- final Either<OutputDefinition, ResponseFormat> deleteEither = Either.left(outputForDelete);
- String value = outputValue.getValue();
- final Map<String, Object> mappedToscaTemplate = (Map<String, Object>) new Yaml().load(value);
-
- resetOutputName(mappedToscaTemplate, outputForDelete.getName());
-
- value = "";
- if (MapUtils.isNotEmpty(mappedToscaTemplate)) {
- final Either result = cleanNestedMap(mappedToscaTemplate, true);
- Map modifiedMappedToscaTemplate = mappedToscaTemplate;
- if (result.isLeft()) {
- modifiedMappedToscaTemplate = (Map) result.left().value();
- } else {
- log.warn("Map cleanup failed -> {}", result.right().value()); //continue, don't break operation
- }
- value = gson.toJson(modifiedMappedToscaTemplate);
- }
- outputValue.setValue(value);
-
- final List<GetOutputValueDataDefinition> getInputsValues = outputValue.getGetOutputValues();
- if (getInputsValues != null && !getInputsValues.isEmpty()) {
- final Optional<GetOutputValueDataDefinition> op =
- getInputsValues.stream().filter(gi -> gi.getOutputId().equals(outputForDelete.getUniqueId())).findAny();
- op.ifPresent(getInputsValues::remove);
- }
- outputValue.setGetOutputValues(getInputsValues);
- return deleteEither;
- }
-