blob: 7f3025408f66a9629d8c4e478e735f2cdf9f0593 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
package org.openecomp.sdc.translator.services.heattotosca;
import org.apache.commons.collections4.MapUtils;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation.ComputeTemplateConsolidationData;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Utility class for consolidation data collection helper methods.
*/
public class UnifiedCompositionUtil {
protected static Logger logger = LoggerFactory.getLogger(UnifiedCompositionUtil.class);
/**
* Gets all ports per port type, which are connected to the computes from the input
* computeTemplateConsolidationDataCollection.
*
* @param computeTemplateConsolidationDataCollection collection of compute template
* consolidation data
* @return set of port ids, per port type
*/
static Map<String, List<String>> collectAllPortsFromEachTypesFromComputes(
Collection<ComputeTemplateConsolidationData> computeTemplateConsolidationDataCollection) {
Map<String, List<String>> portTypeToIds = new HashMap<>();
for (ComputeTemplateConsolidationData compute : computeTemplateConsolidationDataCollection) {
Map<String, List<String>> ports = compute.getPorts();
if (!MapUtils.isEmpty(ports)) {
addPortsToMap(portTypeToIds, ports);
}
}
return portTypeToIds;
}
private static void addPortsToMap(Map<String, List<String>> portTypeToIds,
Map<String, List<String>> ports) {
for (Map.Entry<String, List<String>> portTypeToIdEntry : ports.entrySet()) {
portTypeToIds.putIfAbsent(portTypeToIdEntry.getKey(), new ArrayList<>());
portTypeToIds.get(portTypeToIdEntry.getKey()).addAll(portTypeToIdEntry.getValue());
}
}
}
|