summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/openecomp/sdc/tosca/parser/api/ISdcCsarHelper.java7
-rw-r--r--src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java36
2 files changed, 38 insertions, 5 deletions
diff --git a/src/main/java/org/openecomp/sdc/tosca/parser/api/ISdcCsarHelper.java b/src/main/java/org/openecomp/sdc/tosca/parser/api/ISdcCsarHelper.java
index bb5bd25..06a66c6 100644
--- a/src/main/java/org/openecomp/sdc/tosca/parser/api/ISdcCsarHelper.java
+++ b/src/main/java/org/openecomp/sdc/tosca/parser/api/ISdcCsarHelper.java
@@ -387,4 +387,11 @@ public interface ISdcCsarHelper {
* @return true if node template has topology template, false if not.
*/
public boolean hasTopology(NodeTemplate nodeTemplate);
+
+ /**
+ * Get children node templates for node template.
+ * @param nodeTemplate - Node Template to get its children
+ * @return return list of children node templates for node template.
+ */
+ public List<NodeTemplate> getNodeTemplateChildren(NodeTemplate nodeTemplate);
}
diff --git a/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java b/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java
index c927817..9b40416 100644
--- a/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java
+++ b/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java
@@ -22,9 +22,7 @@ package org.openecomp.sdc.tosca.parser.impl;
import java.util.*;
import java.util.Map.Entry;
-import java.util.regex.Pattern;
import java.util.stream.Collectors;
-import java.util.stream.Stream;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
@@ -41,7 +39,6 @@ import org.openecomp.sdc.toscaparser.api.ToscaTemplate;
import org.openecomp.sdc.toscaparser.api.elements.Metadata;
import org.openecomp.sdc.toscaparser.api.elements.NodeType;
import org.openecomp.sdc.toscaparser.api.functions.Function;
-import org.openecomp.sdc.toscaparser.api.functions.GetInput;
import org.openecomp.sdc.toscaparser.api.parameters.Input;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -625,13 +622,13 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
if (sdcType.equals(SdcTypes.VFC) && isVNF) {
return nodeTemplates.stream()
.filter(x -> (x.getMetaData() != null &&
- sdcType.toString().equals(x.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE))) && (x.getType().endsWith("VnfConfiguration")))
+ sdcType.toString().equals(x.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE))) && isVNFType(x))
.collect(Collectors.toList());
}
else {
return nodeTemplates.stream()
.filter(x -> (x.getMetaData() != null &&
- sdcType.toString().equals(x.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE))) && !(x.getType().endsWith("VnfConfiguration")))
+ sdcType.toString().equals(x.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE))) && !isVNFType(x))
.collect(Collectors.toList());
}
}
@@ -705,7 +702,36 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
return false;
}
+ @Override
+ public List<NodeTemplate> getNodeTemplateChildren(NodeTemplate nodeTemplate) {
+ if (nodeTemplate == null) {
+ log.error("getNodeTemplateChildren - nodeTemplate - is null");
+ return new ArrayList<>();
+ }
+
+ SubstitutionMappings substitutionMappings = nodeTemplate.getSubMappingToscaTemplate();
+ if (substitutionMappings != null) {
+ List<NodeTemplate> nodeTemplates = substitutionMappings.getNodeTemplates();
+ if (nodeTemplates != null && nodeTemplates.size() > 0) {
+
+ return nodeTemplates.stream()
+ .filter(x -> !isVNFType(x))
+ .collect(Collectors.toList());
+ }
+ else {
+ log.debug("getNodeTemplateChildren - SubstitutionMappings' node Templates not exist");
+ }
+ } else
+ log.debug("getNodeTemplateChildren - SubstitutionMappings not exist");
+
+ return new ArrayList<>();
+ }
+
/************************************* helper functions ***********************************/
+ private boolean isVNFType(NodeTemplate nt) {
+ return nt.getType().endsWith("VnfConfiguration");
+ }
+
private Map<String, String> filterProperties(Object property, String path, FilterType filterType, String pattern, Map<String, String> filterMap) {
if (property instanceof Map) {