From ffce2fdab1c5f6efff795107ef7756d2e9fdcf57 Mon Sep 17 00:00:00 2001 From: KrupaNagabhushan Date: Wed, 9 Jun 2021 22:11:46 +0100 Subject: 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 Change-Id: Ibcfd9be0c8ceb95d5c1c3bd3f21c3dec26c398f7 --- .../main/java/org/openecomp/sdc/be/model/Component.java | 1 - .../openecomp/sdc/be/model/ComponentParametersView.java | 2 +- .../model/jsonjanusgraph/datamodel/TopologyTemplate.java | 2 +- .../operations/TopologyTemplateOperation.java | 14 +++++++++++++- .../sdc/be/model/jsonjanusgraph/utils/ModelConverter.java | 8 +++++--- .../openecomp/sdc/be/ui/model/UiComponentDataTransfer.java | 3 +-- 6 files changed, 21 insertions(+), 9 deletions(-) (limited to 'catalog-model/src/main') 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 nodeFilterComponents; - private Map substitutionFilterComponents; private Map interfaces; private List 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 instInterfaces; private Map componentInstInterfaces; private Map nodeFilterComponents; - private Map substitutionFilterDataDefinitionMap; + private SubstitutionFilterDataDefinition substitutionFilters; //----------------------------------------------------------------------- private Map 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, JanusGraphOperationStatus> result = getDataFromGraph(componentV, EdgeLabelEnum.SUBSTITUTION_FILTER_TEMPLATE); if (result.isLeft()) { - topologyTemplate.setSubstitutionFilterDataDefinitionMap(result.left().value()); + final Map 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 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 groups; private Map interfaces; private Map nodeFilter; - private Map substitutionFilter; + private UINodeFilter substitutionFilters; private Map nodeFilterforNode; - private Map substitutionFilterForTopologyTemplate; private List properties; private List attributes; private Map> componentInstancesInterfaces; -- cgit 1.2.3-korg