summaryrefslogtreecommitdiffstats
path: root/catalog-model/src/main/java
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2022-03-31 13:35:04 +0100
committerVasyl Razinkov <vasyl.razinkov@est.tech>2022-03-31 13:58:12 +0000
commit6cffd9e3eecb10281d880ea7d217f0ecddf8fb5a (patch)
tree3edeea0e0ff6d074877e87840feb00810f5af2a5 /catalog-model/src/main/java
parentfcb0da941d472c1f94868246c4bb0e2e9d590e38 (diff)
Update Interface definition on VFC
Signed-off-by: aribeiro <anderson.ribeiro@est.tech> Change-Id: I13678c92ae6088016a78554ffaf0da47b82f7e65 Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Issue-ID: SDC-3893 Signed-off-by: andre.schmid <andre.schmid@est.tech>
Diffstat (limited to 'catalog-model/src/main/java')
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentParametersView.java5
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/BaseOperation.java10
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperation.java30
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java15
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/DaoStatusConverter.java4
5 files changed, 38 insertions, 26 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentParametersView.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentParametersView.java
index 4b5533fe84..56164736b8 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentParametersView.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentParametersView.java
@@ -274,9 +274,9 @@ public class ComponentParametersView {
public void disableAll() {
ignoreUsers = true;
ignoreGroups = true;
- ignorePolicies = true;
ignoreComponentInstances = true;
ignoreComponentInstancesProperties = true;
+ ignoreComponentInstancesAttributes = true;
ignoreProperties = true;
ignoreAttributes = true;
ignoreCapabilities = true;
@@ -287,14 +287,15 @@ public class ComponentParametersView {
ignoreArtifacts = true;
ignoreInterfaces = true;
ignoreInterfaceInstances = true;
+ ignoreComponentInstancesInterfaces = true;
ignoreDerivedFrom = true;
ignoreInputs = true;
ignoreOutputs = true;
- ignoreComponentInstancesAttributes = true;
ignoreComponentInstancesInputs = true;
ignoreComponentInstancesOutputs = true;
ignoreCapabiltyProperties = true;
ignoreServicePath = true;
+ ignorePolicies = true;
ignoreNodeFilterRequirements = true;
ignoreNodeFilter = true;
ignoreSubstitutionFilter = true;
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 92dc67bbca..054ed9fe7e 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
@@ -39,9 +39,9 @@ import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.VertexProperty;
import org.janusgraph.core.JanusGraphVertex;
import org.openecomp.sdc.be.dao.impl.HealingPipelineDao;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphDao;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
-import org.openecomp.sdc.be.dao.janusgraph.JanusGraphDao;
import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
@@ -1009,7 +1009,13 @@ public abstract class BaseOperation {
if (!currMap.containsKey(pathKeys.get(0))) {
currMap.put(pathKeys.get(0), new MapDataDefinition<>());
}
- MapDataDefinition currDeepElement = currMap.get(pathKeys.get(0));
+ Object object = currMap.get(pathKeys.get(0));
+ MapDataDefinition currDeepElement = null;
+ if (object instanceof MapDataDefinition) {
+ currDeepElement = (MapDataDefinition) object;
+ } else {
+ currDeepElement = new MapDataDefinition(currMap);
+ }
for (int i = 1; i < pathKeys.size(); ++i) {
if (currDeepElement.findByKey(pathKeys.get(i)) == null) {
currDeepElement.put(pathKeys.get(i), new MapDataDefinition<>());
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 b45dae9c68..7742cbfe0e 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
@@ -774,12 +774,6 @@ public class TopologyTemplateOperation extends ToscaElementOperation {
return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(storageStatus));
}
}
- if (!componentParametersView.isIgnoreInterfaces()) {
- JanusGraphOperationStatus storageStatus = setInterfcesFromGraph(componentV, toscaElement);
- if (storageStatus != JanusGraphOperationStatus.OK) {
- return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(storageStatus));
- }
- }
if (!componentParametersView.isIgnoreComponentInstancesInterfaces()) {
JanusGraphOperationStatus storageStatus = setComponentInstancesInterfacesFromGraph(componentV, toscaElement);
if (storageStatus != JanusGraphOperationStatus.OK) {
@@ -807,18 +801,6 @@ public class TopologyTemplateOperation extends ToscaElementOperation {
return JanusGraphOperationStatus.OK;
}
- private JanusGraphOperationStatus setInterfcesFromGraph(GraphVertex componentV, TopologyTemplate topologyTemplate) {
- Either<Map<String, InterfaceDataDefinition>, JanusGraphOperationStatus> result = getDataFromGraph(componentV, EdgeLabelEnum.INTERFACE);
- if (result.isLeft()) {
- topologyTemplate.setInterfaces(result.left().value());
- } else {
- if (result.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
- return result.right().value();
- }
- }
- return JanusGraphOperationStatus.OK;
- }
-
private JanusGraphOperationStatus setPoliciesFromGraph(GraphVertex componentV, TopologyTemplate toscaElement) {
Either<Map<String, PolicyDataDefinition>, JanusGraphOperationStatus> result = getDataFromGraph(componentV, EdgeLabelEnum.POLICIES);
if (result.isLeft()) {
@@ -985,7 +967,7 @@ public class TopologyTemplateOperation extends ToscaElementOperation {
if (MapUtils.isEmpty(filters)) {
return JanusGraphOperationStatus.OK;
}
- if(filters.values().size() > 1) {
+ if (filters.values().size() > 1) {
log.error(EcompLoggerErrorCode.DATA_ERROR, TopologyTemplateOperation.class.getName(),
(ErrorLogOptionalData) null, "Only a single substitution filter is expected, but got '{}'", filters.values().size());
return JanusGraphOperationStatus.GENERAL_ERROR;
@@ -1493,6 +1475,16 @@ public class TopologyTemplateOperation extends ToscaElementOperation {
return StorageOperationStatus.OK;
}
+
+ public StorageOperationStatus updateComponentInterfaces(final String componentId, final MapInterfaceDataDefinition instanceInterfaces,
+ final String componentInterfaceUpdatedKey) {
+ if (MapUtils.isNotEmpty(instanceInterfaces.getMapToscaDataDefinition())) {
+ return updateToscaDataDeepElementsBlockToToscaElement(componentId, EdgeLabelEnum.INTERFACE_ARTIFACTS, instanceInterfaces,
+ componentInterfaceUpdatedKey);
+ }
+ return StorageOperationStatus.OK;
+ }
+
private boolean isNotEmptyMapOfProperties(String instanceId, Map<String, MapCapabilityProperty> mapPropertiesDataDefinition) {
return MapUtils.isNotEmpty(mapPropertiesDataDefinition) && instanceId != null && mapPropertiesDataDefinition.get(instanceId) != null
&& MapUtils.isNotEmpty(mapPropertiesDataDefinition.get(instanceId).getMapToscaDataDefinition());
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 d477b8ce6a..c07523d3cc 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
@@ -101,6 +101,7 @@ import org.openecomp.sdc.be.model.DistributionStatusEnum;
import org.openecomp.sdc.be.model.GroupDefinition;
import org.openecomp.sdc.be.model.GroupInstance;
import org.openecomp.sdc.be.model.InputDefinition;
+import org.openecomp.sdc.be.model.InterfaceDefinition;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
import org.openecomp.sdc.be.model.OutputDefinition;
import org.openecomp.sdc.be.model.PolicyDefinition;
@@ -3126,6 +3127,12 @@ public class ToscaOperationFacade {
return topologyTemplateOperation.updateComponentInstanceInterfaces(containerComponent, componentInstanceUniqueId, mapInterfaceDataDefinition);
}
+ public StorageOperationStatus updateComponentInterfaces(final String componentId, final Map<String, InterfaceDefinition> interfaces,
+ final String componentInterfaceUpdatedKey) {
+ MapInterfaceDataDefinition mapInterfaceDataDefinition = convertComponentInterfaces(interfaces);
+ return topologyTemplateOperation.updateComponentInterfaces(componentId, mapInterfaceDataDefinition, componentInterfaceUpdatedKey);
+ }
+
public StorageOperationStatus updateComponentCalculatedCapabilitiesProperties(Component containerComponent) {
Map<String, MapCapabilityProperty> mapCapabiltyPropertyMap = convertComponentCapabilitiesProperties(containerComponent);
return nodeTemplateOperation.overrideComponentCapabilitiesProperties(containerComponent, mapCapabiltyPropertyMap);
@@ -3187,6 +3194,14 @@ public class ToscaOperationFacade {
return mapInterfaceDataDefinition;
}
+ private MapInterfaceDataDefinition convertComponentInterfaces(final Map<String, InterfaceDefinition> interfaces) {
+ final MapInterfaceDataDefinition mapInterfaceDataDefinition = new MapInterfaceDataDefinition();
+ if (MapUtils.isNotEmpty(interfaces)) {
+ interfaces.values().stream().forEach(interfaceDef -> mapInterfaceDataDefinition.put(interfaceDef.getType(), interfaceDef));
+ }
+ return mapInterfaceDataDefinition;
+ }
+
private Map<String, MapCapabilityProperty> convertComponentCapabilitiesProperties(Component currComponent) {
Map<String, MapCapabilityProperty> map = ModelConverter.extractCapabilityPropertiesFromGroups(currComponent.getGroups(), true);
map.putAll(ModelConverter.extractCapabilityProperteisFromInstances(currComponent.getComponentInstances(), true));
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/DaoStatusConverter.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/DaoStatusConverter.java
index 14611ae4ad..0ee71734e2 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/DaoStatusConverter.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/DaoStatusConverter.java
@@ -37,10 +37,10 @@ public class DaoStatusConverter {
case NOT_FOUND:
return StorageOperationStatus.NOT_FOUND;
case NOT_CREATED:
- return StorageOperationStatus.SCHEMA_ERROR;
case INDEX_CANNOT_BE_CHANGED:
return StorageOperationStatus.SCHEMA_ERROR;
case MISSING_UNIQUE_ID:
+ case ILLEGAL_ARGUMENT:
return StorageOperationStatus.BAD_REQUEST;
case ALREADY_LOCKED:
return StorageOperationStatus.FAILED_TO_LOCK_ELEMENT;
@@ -50,8 +50,6 @@ public class DaoStatusConverter {
return StorageOperationStatus.INVALID_ID;
case MATCH_NOT_FOUND:
return StorageOperationStatus.MATCH_NOT_FOUND;
- case ILLEGAL_ARGUMENT:
- return StorageOperationStatus.BAD_REQUEST;
case ALREADY_EXIST:
return StorageOperationStatus.ENTITY_ALREADY_EXISTS;
case PROPERTY_NAME_ALREADY_EXISTS: