summaryrefslogtreecommitdiffstats
path: root/catalog-model/src
diff options
context:
space:
mode:
authorKrupaNagabhushan <krupa.nagabhushan@est.tech>2021-06-09 22:11:46 +0100
committerChristophe Closset <christophe.closset@intl.att.com>2021-07-05 09:19:53 +0000
commitffce2fdab1c5f6efff795107ef7756d2e9fdcf57 (patch)
treed795b99028569a927df824c7d97418d4c9d12628 /catalog-model/src
parent3453264c35275af52a2fdcde33f6e8347a65d15b (diff)
Refactor Substitution filters structure
The refactor removes unnecessary component id from the substitution filters structure, as the substitution filters belongs to and only to the component. This also avoid any copying issues during the new version creation, as there is not need to update the structure with a new component id. Issue-ID: SDC-3619 Signed-off-by: KrupaNagabhushan <krupa.nagabhushan@est.tech> Change-Id: Ibcfd9be0c8ceb95d5c1c3bd3f21c3dec26c398f7
Diffstat (limited to 'catalog-model/src')
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java1
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/ComponentParametersView.java2
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/TopologyTemplate.java2
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/TopologyTemplateOperation.java14
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java8
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentDataTransfer.java3
6 files changed, 21 insertions, 9 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java
index 05cf94a266..dee4088d04 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/Component.java
@@ -87,7 +87,6 @@ public abstract class Component implements PropertiesOwner {
private String derivedFromGenericVersion;
private String toscaType;
private Map<String, CINodeFilterDataDefinition> nodeFilterComponents;
- private Map<String, SubstitutionFilterDataDefinition> substitutionFilterComponents;
private Map<String, InterfaceDefinition> interfaces;
private List<DataTypeDefinition> dataTypes;
private SubstitutionFilterDataDefinition substitutionFilter;
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 e55c454829..4b5533fe84 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
@@ -263,7 +263,7 @@ public class ComponentParametersView {
component.setNodeFilterComponents(null);
}
if (ignoreSubstitutionFilter) {
- component.setSubstitutionFilterComponents(null);
+ component.setSubstitutionFilter(null);
}
if (ignoreDataType) {
component.setDataTypes(null);
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/TopologyTemplate.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/TopologyTemplate.java
index 348b849719..1438454389 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/TopologyTemplate.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/datamodel/TopologyTemplate.java
@@ -77,7 +77,7 @@ public class TopologyTemplate extends ToscaElement {
private Map<String, MapInterfaceInstanceDataDefinition> instInterfaces;
private Map<String, MapInterfaceDataDefinition> componentInstInterfaces;
private Map<String, CINodeFilterDataDefinition> nodeFilterComponents;
- private Map<String, SubstitutionFilterDataDefinition> substitutionFilterDataDefinitionMap;
+ private SubstitutionFilterDataDefinition substitutionFilters;
//-----------------------------------------------------------------------
private Map<String, MapComponentInstanceExternalRefs> mapComponentInstancesExternalRefs;
//Component Instances External References (instanceId -> ExternalRefsMap)
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 0ca76b5304..3827cc5999 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
@@ -88,6 +88,9 @@ import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
import org.openecomp.sdc.common.api.Constants;
import org.openecomp.sdc.common.jsongraph.util.CommonUtility;
import org.openecomp.sdc.common.jsongraph.util.CommonUtility.LogLevelEnum;
+import org.openecomp.sdc.common.log.elements.ErrorLogOptionalData;
+import org.openecomp.sdc.common.log.enums.EcompErrorSeverity;
+import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode;
import org.openecomp.sdc.common.log.wrappers.Logger;
import org.openecomp.sdc.common.util.ValidationUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -971,7 +974,16 @@ public class TopologyTemplateOperation extends ToscaElementOperation {
final Either<Map<String, SubstitutionFilterDataDefinition>, JanusGraphOperationStatus> result = getDataFromGraph(componentV,
EdgeLabelEnum.SUBSTITUTION_FILTER_TEMPLATE);
if (result.isLeft()) {
- topologyTemplate.setSubstitutionFilterDataDefinitionMap(result.left().value());
+ final Map<String, SubstitutionFilterDataDefinition> filters = result.left().value();
+ if (MapUtils.isEmpty(filters)) {
+ return JanusGraphOperationStatus.OK;
+ }
+ 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;
+ }
+ topologyTemplate.setSubstitutionFilters(new SubstitutionFilterDataDefinition(filters.values().iterator().next()));
} else {
if (result.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
return result.right().value();
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java
index 8b0ef75e43..225a068aaf 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/utils/ModelConverter.java
@@ -902,10 +902,12 @@ public class ModelConverter {
}
private static void convertSubstitutionFiltersComponents(final TopologyTemplate topologyTemplate, final Component component) {
- final Map<String, SubstitutionFilterDataDefinition> filters = topologyTemplate.getSubstitutionFilterDataDefinitionMap();
- if (MapUtils.isNotEmpty(filters)) {
- component.setSubstitutionFilter(filters.get(component.getUniqueId()));
+ final SubstitutionFilterDataDefinition filters = topologyTemplate.getSubstitutionFilters();
+ if (filters == null){
+ component.setSubstitutionFilter(null);
+ return;
}
+ component.setSubstitutionFilter(new SubstitutionFilterDataDefinition(filters));
}
private static void convertServiceApiArtifacts(TopologyTemplate topologyTemplate, Service service) {
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentDataTransfer.java b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentDataTransfer.java
index 92149143e6..96c1613d5a 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentDataTransfer.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/ui/model/UiComponentDataTransfer.java
@@ -73,9 +73,8 @@ public class UiComponentDataTransfer {
private List<GroupDefinition> groups;
private Map<String, InterfaceDefinition> interfaces;
private Map<String, CINodeFilterDataDefinition> nodeFilter;
- private Map<String, SubstitutionFilterDataDefinition> substitutionFilter;
+ private UINodeFilter substitutionFilters;
private Map<String, UINodeFilter> nodeFilterforNode;
- private Map<String, UINodeFilter> substitutionFilterForTopologyTemplate;
private List<PropertyDefinition> properties;
private List<AttributeDefinition> attributes;
private Map<String, List<ComponentInstanceInterface>> componentInstancesInterfaces;