diff options
Diffstat (limited to 'openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/DataModelUtil.java')
-rw-r--r-- | openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/DataModelUtil.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/DataModelUtil.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/DataModelUtil.java index 97932289b9..39240ebe05 100644 --- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/DataModelUtil.java +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/DataModelUtil.java @@ -202,6 +202,16 @@ public class DataModelUtil { return serviceTemplate.getTopology_template().getNode_templates(); } + public static Map<String, GroupDefinition> getGroups(ServiceTemplate serviceTemplate) { + if (Objects.isNull(serviceTemplate) + || Objects.isNull(serviceTemplate.getTopology_template()) + || MapUtils.isEmpty(serviceTemplate.getTopology_template().getGroups())) { + return new HashMap<>(); + } + + return serviceTemplate.getTopology_template().getGroups(); + } + /** * Add node template. * @@ -481,6 +491,26 @@ public class DataModelUtil { serviceTemplate.getTopology_template().getGroups().put(groupName, group); } + public static void addGroupMember(ServiceTemplate serviceTemplate, + String groupName, + String groupMemberId) { + TopologyTemplate topologyTemplate = serviceTemplate.getTopology_template(); + if (Objects.isNull(topologyTemplate) + || topologyTemplate.getGroups() == null + || topologyTemplate.getGroups().get(groupName) == null) { + return; + } + + GroupDefinition groupDefinition = topologyTemplate.getGroups().get(groupName); + if (CollectionUtils.isEmpty(groupDefinition.getMembers())) { + groupDefinition.setMembers(new ArrayList<>()); + } + + if(!groupDefinition.getMembers().contains(groupMemberId)) { + groupDefinition.getMembers().add(groupMemberId); + } + } + /** * Create parameter definition property definition. * |