summaryrefslogtreecommitdiffstats
path: root/catalog-model/src
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2023-09-07 10:17:14 +0100
committervasraz <vasyl.razinkov@est.tech>2023-09-07 10:17:14 +0100
commitc469756a1092194adedd590d35f0f1f8feac3a36 (patch)
treefd6d13177627286b00b998ce2ae16f4ba605137d /catalog-model/src
parent5c1294eb8e2dc00cae4ef21d6111e0fa18fc2caa (diff)
Implement 'Update Service by importing Tosca Model'-story
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Change-Id: I34414caeb53c4dcc6499d3639e4ea8f80407a6f6 Issue-ID: SDC-4579
Diffstat (limited to 'catalog-model/src')
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/BaseOperation.java9
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperation.java9
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java34
3 files changed, 28 insertions, 24 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/BaseOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/BaseOperation.java
index af8414dc81..2bf1c96abb 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/BaseOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/BaseOperation.java
@@ -1423,16 +1423,15 @@ public abstract class BaseOperation {
mergedToscaDataMap.putAll(existingToscaDataMap);
}
for (T toscaDataElement : toscaDataList) {
- status = handleToscaDataElement(toscaElement, mapKeyField, mergedToscaDataMap, toscaDataElement, isUpdate);
+ status = handleToscaDataElement(toscaElement.getUniqueId(), mapKeyField, mergedToscaDataMap, toscaDataElement, isUpdate);
if (status != StorageOperationStatus.OK) {
- result = Either.right(status);
- break;
+ return Either.right(status);
}
}
return result;
}
- private <T extends ToscaDataDefinition> StorageOperationStatus handleToscaDataElement(GraphVertex toscaElement,
+ private <T extends ToscaDataDefinition> StorageOperationStatus handleToscaDataElement(String toscaElementId,
JsonPresentationFields mapKeyField,
Map<String, T> mergedToscaDataMap, T toscaDataElement,
boolean isUpdate) {
@@ -1450,7 +1449,7 @@ public abstract class BaseOperation {
status = StorageOperationStatus.BAD_REQUEST;
} else if (!isUpdate && mergedToscaDataMap.containsKey(currKey)) {
CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG,
- "Failed to add tosca data to tosca element {}. The element with the same key {} already exists. ", toscaElement.getUniqueId(),
+ "Failed to add tosca data to tosca element {}. The element with the same key {} already exists. ", toscaElementId,
currKey);
status = StorageOperationStatus.BAD_REQUEST;
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperation.java
index 15d741b156..a253d815ad 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperation.java
@@ -1219,9 +1219,9 @@ public class TopologyTemplateOperation extends ToscaElementOperation {
log.debug("Failed to disassociate instances properties for {} error {}", toscaElementVertex.getUniqueId(), status);
Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
}
- status = janusGraphDao.disassociateAndDeleteLast(toscaElementVertex, Direction.OUT, EdgeLabelEnum.INST_INPUTS);
+ status = janusGraphDao.disassociateAndDeleteLast(toscaElementVertex, Direction.OUT, EdgeLabelEnum.INST_OUTPUTS);
if (status != JanusGraphOperationStatus.OK) {
- log.debug("Failed to disassociate instances inputs for {} error {}", toscaElementVertex.getUniqueId(), status);
+ log.debug("Failed to disassociate instances outputs for {} error {}", toscaElementVertex.getUniqueId(), status);
Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
}
status = janusGraphDao.disassociateAndDeleteLast(toscaElementVertex, Direction.OUT, EdgeLabelEnum.GROUPS);
@@ -1244,6 +1244,11 @@ public class TopologyTemplateOperation extends ToscaElementOperation {
log.debug("Failed to disassociate inputs for {} error {}", toscaElementVertex.getUniqueId(), status);
Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
}
+ status = janusGraphDao.disassociateAndDeleteLast(toscaElementVertex, Direction.OUT, EdgeLabelEnum.OUTPUTS);
+ if (status != JanusGraphOperationStatus.OK) {
+ log.debug("Failed to disassociate outputs for {} error {}", toscaElementVertex.getUniqueId(), status);
+ Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
+ }
status = janusGraphDao.disassociateAndDeleteLast(toscaElementVertex, Direction.OUT, EdgeLabelEnum.INST_INPUTS);
if (status != JanusGraphOperationStatus.OK) {
log.debug("Failed to disassociate instance inputs for {} error {}", toscaElementVertex.getUniqueId(), status);
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 d654f23fbb..951dc5aaed 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
@@ -1791,25 +1791,25 @@ public class ToscaOperationFacade {
}
public Either<Map<String, List<ComponentInstanceAttribute>>, StorageOperationStatus> addComponentInstanceAttributesToComponent(
- final Component containerComponent, final Map<String, List<ComponentInstanceAttribute>> instProperties) {
- requireNonNull(instProperties);
- for (final Entry<String, List<ComponentInstanceAttribute>> entry : instProperties.entrySet()) {
- final List<ComponentInstanceAttribute> props = entry.getValue();
- if (isEmpty(props)) {
+ final Component containerComponent, final Map<String, List<ComponentInstanceAttribute>> componentInstanceAttribute) {
+ requireNonNull(componentInstanceAttribute);
+ for (final Entry<String, List<ComponentInstanceAttribute>> entry : componentInstanceAttribute.entrySet()) {
+ final List<ComponentInstanceAttribute> attributes = entry.getValue();
+ if (isEmpty(attributes)) {
continue;
}
final String componentInstanceId = entry.getKey();
- final List<ComponentInstanceAttribute> originalComponentInstProps = containerComponent.getComponentInstancesAttributes()
+ final List<ComponentInstanceAttribute> componentInstanceAttributes = containerComponent.getComponentInstancesAttributes()
.get(componentInstanceId);
- for (final ComponentInstanceAttribute property : props) {
+ for (final ComponentInstanceAttribute attribute : attributes) {
final StorageOperationStatus status = updateOrAddComponentInstanceAttribute(containerComponent, componentInstanceId,
- originalComponentInstProps, property);
+ componentInstanceAttributes, attribute);
if (status != StorageOperationStatus.OK) {
return Either.right(status);
}
}
}
- return Either.left(instProperties);
+ return Either.left(componentInstanceAttribute);
}
private StorageOperationStatus populateAndUpdateInstanceCapProperty(Component containerComponent, String componentInstanceId,
@@ -1847,19 +1847,19 @@ public class ToscaOperationFacade {
}
private StorageOperationStatus updateOrAddComponentInstanceAttribute(Component containerComponent, String componentInstanceId,
- List<ComponentInstanceAttribute> originalComponentInstProps,
- ComponentInstanceAttribute property) {
+ List<ComponentInstanceAttribute> componentInstanceAttributes,
+ ComponentInstanceAttribute attribute) {
StorageOperationStatus status;
- // check if the property already exists or not
- Optional<ComponentInstanceAttribute> instanceProperty = originalComponentInstProps.stream()
- .filter(p -> p.getUniqueId().equals(property.getUniqueId())).findAny();
+ // check if the attribute already exists or not
+ Optional<ComponentInstanceAttribute> instanceProperty = componentInstanceAttributes.stream()
+ .filter(p -> p.getUniqueId().equals(attribute.getUniqueId())).findAny();
if (instanceProperty.isPresent()) {
- status = updateComponentInstanceAttribute(containerComponent, componentInstanceId, property);
+ status = updateComponentInstanceAttribute(containerComponent, componentInstanceId, attribute);
} else {
- status = addComponentInstanceAttribute(containerComponent, componentInstanceId, property);
+ status = addComponentInstanceAttribute(containerComponent, componentInstanceId, attribute);
}
if (status != StorageOperationStatus.OK) {
- log.debug("Failed to update instance property {} for instance {} error {} ", property, componentInstanceId, status);
+ log.debug("Failed to update instance attribute {} for instance {} error {} ", attribute, componentInstanceId, status);
}
return status;
}