From 7e49c060458ff13b72bc997ffff9ea668e934676 Mon Sep 17 00:00:00 2001 From: imamSidero Date: Fri, 5 Aug 2022 10:43:18 +0100 Subject: 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 Issue-ID: SDC-4124 Change-Id: I1e1e992881cd51dff209bac0111a472793dd41d1 --- .../main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java | 6 ++++-- .../src/main/java/org/openecomp/sdc/be/tosca/model/NodeFilter.java | 7 +++++++ 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'catalog-be/src/main/java/org') 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 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>> properties; private List> capabilities; + + public boolean hasData() { + return CollectionUtils.isNotEmpty(properties) || CollectionUtils.isNotEmpty(capabilities); + } } -- cgit 1.2.3-korg