private Map<String, List<LocationResourceTemplate>> getAvailableSubstitutions(Topology topology, Map<String, NodeGroup> locationGroups,
Map<String, Location> locationByIds, String environmentId) {
Map<String, NodeType> nodeTypes = getNodeTypes(topology);
Map<String, List<LocationResourceTemplate>> availableSubstitutions = Maps.newHashMap();
for (final Map.Entry<String, NodeGroup> locationGroupEntry : locationGroups.entrySet()) {
String groupName = locationGroupEntry.getKey();
final NodeGroup locationNodeGroup = locationGroupEntry.getValue();
Map<String, NodeTemplate> nodesToMatch = Maps.newHashMap();
if (MapUtils.isNotEmpty(topology.getNodeTemplates())) {
if (AlienConstants.GROUP_ALL.equals(groupName)) {
locationNodeGroup.setMembers(topology.getNodeTemplates().keySet());
nodesToMatch = topology.getNodeTemplates();
} else {
nodesToMatch = Maps.filterEntries(topology.getNodeTemplates(), input -> locationNodeGroup.getMembers().contains(input.getKey()));
}
}
availableSubstitutions.putAll(nodeMatcherService.match(nodeTypes, nodesToMatch, locationByIds.get(groupName), environmentId));
}
return availableSubstitutions;
}