diff options
author | PriyanshuAgarwal <pagarwal@amdocs.com> | 2018-04-11 22:19:30 +0530 |
---|---|---|
committer | priyanshu <pagarwal@amdocs.com> | 2018-04-11 22:19:30 +0530 |
commit | b6c2ccf8658133a73b43a1e22f6df5ab608a2bab (patch) | |
tree | 46c5ead28eea880750dde7d19293bd9b91e08fb8 /src/main | |
parent | d4bddaaa7057729cf7178caf8fa4337861c50d73 (diff) |
Interfaces support in SDC Parser
Part 2 of the changes of interface support in SDC Parser.
Change-Id: I0e234415c2dd77a447908359c2f75e7ea3f3f27d
Issue-ID: SDC-1197
Signed-off-by: priyanshu <pagarwal@amdocs.com>
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/org/onap/sdc/tosca/parser/api/ISdcCsarHelper.java | 36 | ||||
-rw-r--r-- | src/main/java/org/onap/sdc/tosca/parser/impl/SdcCsarHelperImpl.java | 38 |
2 files changed, 74 insertions, 0 deletions
diff --git a/src/main/java/org/onap/sdc/tosca/parser/api/ISdcCsarHelper.java b/src/main/java/org/onap/sdc/tosca/parser/api/ISdcCsarHelper.java index 4f2ef29..5052ddf 100644 --- a/src/main/java/org/onap/sdc/tosca/parser/api/ISdcCsarHelper.java +++ b/src/main/java/org/onap/sdc/tosca/parser/api/ISdcCsarHelper.java @@ -27,6 +27,7 @@ import org.apache.commons.lang3.tuple.Pair; import org.onap.sdc.tosca.parser.impl.SdcTypes; import org.onap.sdc.tosca.parser.impl.FilterType; import org.onap.sdc.toscaparser.api.*; +import org.onap.sdc.toscaparser.api.elements.InterfacesDef; import org.onap.sdc.toscaparser.api.elements.Metadata; import org.onap.sdc.toscaparser.api.parameters.Input; @@ -560,4 +561,39 @@ public interface ISdcCsarHelper { */ public List<NodeTemplate> getGroupMembersOfOriginOfNodeTemplate(NodeTemplate nodeTemplate, String groupName); + /** + * Get all interface details for given node template.<br> + * @return Map that contains the list of all interfaces and their definitions. + * If none found, an empty map will be returned. + */ + public Map<String, List<InterfacesDef>> getInterfacesOf(NodeTemplate nt); + + /** + * Get all interface names for given node template.<br> + * @return List that contains the name of all interfaces. + * If none found, an empty list will be returned. + */ + public List<String> getInterfaces(NodeTemplate nt); + + /** + * Get all details for given node template and interface name.<br> + * @return List that contains the definitions of given interface name. + * If none found, an empty list will be returned. + */ + public List<InterfacesDef> getInterfaceDetails(NodeTemplate nt, String interfaceName); + + /** + * Get all operation names for given node template and interface name.<br> + * @return List that contains the name of all operations for a given node template and interface name. + * If none found, an empty list will be returned. + */ + public List<String> getAllInterfaceOperations(NodeTemplate nt, String interfaceName); + + /** + * Get interface details for a given node template, interface name and operation name.<br> + * @return InterfaceDef representing the operation details. + * If none found, null will be returned. + */ + public InterfacesDef getInterfaceOperationDetails(NodeTemplate nt, String interfaceName, String operationName); + }
\ No newline at end of file diff --git a/src/main/java/org/onap/sdc/tosca/parser/impl/SdcCsarHelperImpl.java b/src/main/java/org/onap/sdc/tosca/parser/impl/SdcCsarHelperImpl.java index 8e16c14..ee4c7e8 100644 --- a/src/main/java/org/onap/sdc/tosca/parser/impl/SdcCsarHelperImpl.java +++ b/src/main/java/org/onap/sdc/tosca/parser/impl/SdcCsarHelperImpl.java @@ -48,6 +48,7 @@ import org.onap.sdc.toscaparser.api.RequirementAssignments; import org.onap.sdc.toscaparser.api.SubstitutionMappings; import org.onap.sdc.toscaparser.api.TopologyTemplate; import org.onap.sdc.toscaparser.api.ToscaTemplate; +import org.onap.sdc.toscaparser.api.elements.InterfacesDef; import org.onap.sdc.toscaparser.api.elements.Metadata; import org.onap.sdc.toscaparser.api.elements.NodeType; import org.onap.sdc.toscaparser.api.functions.Function; @@ -1082,4 +1083,41 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper { return null; } + @Override + public Map<String, List<InterfacesDef>> getInterfacesOf(NodeTemplate nt){ + if (nt == null) { + return null; + } + return nt.getAllInterfaceDetailsForNodeType(); + } + + @Override + public List<String> getInterfaces(NodeTemplate nt){ + Map<String, List<InterfacesDef>> interfaceDetails = nt.getAllInterfaceDetailsForNodeType(); + return new ArrayList<>(interfaceDetails.keySet()); + } + + @Override + public List<InterfacesDef> getInterfaceDetails(NodeTemplate nt, String interfaceName){ + Map<String, List<InterfacesDef>> interfaceDetails = nt.getAllInterfaceDetailsForNodeType(); + return interfaceDetails.get(interfaceName); + } + + @Override + public List<String> getAllInterfaceOperations(NodeTemplate nt, String interfaceName){ + Map<String, List<InterfacesDef>> interfaceDetails = nt.getAllInterfaceDetailsForNodeType(); + return interfaceDetails.values().stream().flatMap(List::stream).map(val -> val.getOperationName()).collect( + Collectors.toList()); + } + + @Override + public InterfacesDef getInterfaceOperationDetails(NodeTemplate nt, String interfaceName, String operationName){ + Map<String, List<InterfacesDef>> interfaceDetails = nt.getAllInterfaceDetailsForNodeType(); + if(!interfaceDetails.isEmpty()){ + List<InterfacesDef> interfaceDefs = interfaceDetails.get(interfaceName); + return interfaceDefs.stream().filter(val -> val.getOperationName().equals(operationName)).findFirst().orElse(null); + } + return null; + } + } |