From e10154ff631cf86a978899db8533e86bbc0e658e Mon Sep 17 00:00:00 2001 From: "Manzon, Inna (im453s)" Date: Tue, 25 Dec 2018 17:41:33 +0200 Subject: SDC Tosca Parser getEntity API Change-Id: I7cb1acfcfacd3c58eae52995523b1e55e7302144 Issue-ID: SDC-1967 Signed-off-by: Manzon, Inna (im453s) --- .../onap/sdc/tosca/parser/impl/QueryProcessor.java | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/onap/sdc/tosca/parser/impl/QueryProcessor.java b/src/main/java/org/onap/sdc/tosca/parser/impl/QueryProcessor.java index 42b499b..8ca730c 100644 --- a/src/main/java/org/onap/sdc/tosca/parser/impl/QueryProcessor.java +++ b/src/main/java/org/onap/sdc/tosca/parser/impl/QueryProcessor.java @@ -92,31 +92,33 @@ class QueryProcessor { return topologyTemplateQuery.getNodeTemplateType() == SdcTypes.SERVICE; } - private List getInternalTopologyTemplates(List nodeTemplateList, boolean searchTypeOnly) { + private List getInternalTopologyTemplates(List nodeTemplateList, boolean isRecursive) { return nodeTemplateList .stream() - .map(child->getTopologyTemplatesByQuery(child, searchTypeOnly)) + .map(child->getTopologyTemplatesByQuery(child, isRecursive)) .flatMap(List::stream) .collect(Collectors.toList()); } - private List getTopologyTemplatesByQuery(NodeTemplate current, boolean searchTypeOnly) { + private List getTopologyTemplatesByQuery(NodeTemplate current, boolean isRecursive) { List topologyTemplateList = Lists.newArrayList(); - boolean isTopologyTemplateFound = searchTypeOnly ? - topologyTemplateQuery.isSameSdcType(current.getMetaData()) : topologyTemplateQuery.isMatchingSearchCriteria(current); + boolean isTopologyTemplateFound = isRecursive ? + SdcTypes.isComplex(current.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)) + : topologyTemplateQuery.isMatchingSearchCriteria(current); if (isTopologyTemplateFound) { topologyTemplateList.add(current); - if (!isServiceSearch()) { + if (!isRecursive) { //recursion stop condition return topologyTemplateList; } } - if (SdcTypes.isComplex(current.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)) && current.getSubMappingToscaTemplate() != null) { - //search the node template inside a given topology template + if (SdcTypes.isComplex(current.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)) && + current.getSubMappingToscaTemplate() != null) { + //search the node template inside a given topology template topologyTemplateList.addAll(current.getSubMappingToscaTemplate().getNodeTemplates() .stream() - .map(nt->getTopologyTemplatesByQuery(nt, searchTypeOnly)) + .map(nt->getTopologyTemplatesByQuery(nt, isRecursive)) .flatMap(List::stream) .collect(Collectors.toList())); } -- cgit 1.2.3-korg