diff options
author | imamSidero <imam.hussain@est.tech> | 2022-08-05 10:43:18 +0100 |
---|---|---|
committer | Michael Morris <michael.morris@est.tech> | 2022-08-11 14:10:16 +0000 |
commit | 7e49c060458ff13b72bc997ffff9ea668e934676 (patch) | |
tree | 6e00b4c19d3a78624fe222c2a67d006fbaf5c250 /catalog-be/src/main | |
parent | 33538725267c361efe813f1a4e6eff8b69c09c9f (diff) |
Empty node filter is removed when no filter is added
Null and empty check is added before adding a node filter object
Signed-off-by: Imam hussain <imam.hussain@est.tech>
Issue-ID: SDC-4124
Change-Id: I1e1e992881cd51dff209bac0111a472793dd41d1
Diffstat (limited to 'catalog-be/src/main')
-rw-r--r-- | catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java | 6 | ||||
-rw-r--r-- | catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/NodeFilter.java | 7 |
2 files changed, 11 insertions, 2 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java index a8aa6b33a9..9591e6b1a7 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java @@ -937,8 +937,10 @@ public class ToscaExportHandler { } nodeTemplate.setType(componentInstance.getToscaComponentName()); nodeTemplate.setDirectives(componentInstance.getDirectives()); - nodeTemplate.setNode_filter(convertToNodeTemplateNodeFilterComponent(componentInstance.getNodeFilter())); - + NodeFilter nodeFilter = convertToNodeTemplateNodeFilterComponent(componentInstance.getNodeFilter()); + if(nodeFilter != null && nodeFilter.hasData()){ + nodeTemplate.setNode_filter(nodeFilter); + } final Either<Component, Boolean> originComponentRes = capabilityRequirementConverter .getOriginComponent(componentCache, componentInstance); if (originComponentRes.isRight()) { diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/NodeFilter.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/NodeFilter.java index 6cad788a1e..ba93e09c13 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/NodeFilter.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/NodeFilter.java @@ -17,6 +17,9 @@ package org.openecomp.sdc.be.tosca.model; import java.util.List; import java.util.Map; + +import org.apache.commons.collections.CollectionUtils; + import lombok.Getter; import lombok.Setter; @@ -27,4 +30,8 @@ public class NodeFilter { private Object tosca_id; private List<Map<String, List<Object>>> properties; private List<Map<String, CapabilityFilter>> capabilities; + + public boolean hasData() { + return CollectionUtils.isNotEmpty(properties) || CollectionUtils.isNotEmpty(capabilities); + } } |