c6721ce18fa0548e635a4388dcfd42afece7f836
[sdc.git] / openecomp-be / lib / openecomp-sdc-translator-lib / openecomp-sdc-translator-core / src / main / java / org / openecomp / sdc / translator / datatypes / heattotosca / unifiedmodel / consolidation / ComputeTemplateConsolidationData.java
1 package org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation;
2
3 import org.openecomp.sdc.tosca.datatypes.model.RequirementAssignment;
4
5 import java.util.ArrayList;
6 import java.util.HashMap;
7 import java.util.List;
8 import java.util.Map;
9
10 /**
11  * The type Compute template consolidation data.
12  */
13 public class ComputeTemplateConsolidationData extends EntityConsolidationData {
14   // key - volume node template id
15   // List of requirement id and the requirement assignment on the
16   // compute node which connect to this volume
17   private Map<String,List<RequirementAssignmentData>> volumes;
18
19   // key - port type (port id excluding index),
20   // value - List of connected port node template ids, with this port type
21   private Map<String, List<String>> ports;
22
23   /**
24    * Gets volumes.
25    *
26    * @return the volumes
27    */
28   public Map<String,List<RequirementAssignmentData>> getVolumes() {
29     return volumes;
30   }
31
32   /**
33    * Sets volumes.
34    *
35    * @param volumes the volumes
36    */
37   public void setVolumes(Map<String,List<RequirementAssignmentData>> volumes) {
38     this.volumes = volumes;
39   }
40
41   /**
42    * Gets ports.
43    *
44    * @return the ports
45    */
46   public Map<String, List<String>> getPorts() {
47     return ports;
48   }
49
50   /**
51    * Sets ports.
52    *
53    * @param ports the ports
54    */
55   public void setPorts(Map<String, List<String>> ports) {
56     this.ports = ports;
57   }
58
59   /**
60    * Add port.
61    *
62    * @param portType           the port type
63    * @param portNodeTemplateId the port node template id
64    */
65   public void addPort(String portType, String portNodeTemplateId) {
66     if (this.ports == null) {
67       this.ports = new HashMap<>();
68     }
69     this.ports.putIfAbsent(portType, new ArrayList<>());
70     this.ports.get(portType).add(portNodeTemplateId);
71   }
72
73
74   /**
75    * Add volume.
76    *
77    * @param requirementId         the requirement id
78    * @param requirementAssignment the requirement assignment
79    */
80   public void addVolume(String requirementId, RequirementAssignment requirementAssignment) {
81     if (this.volumes == null) {
82       this.volumes = new HashMap<>();
83     }
84     this.volumes.computeIfAbsent(requirementAssignment.getNode(), k -> new ArrayList<>())
85         .add(new RequirementAssignmentData(requirementId,
86             requirementAssignment));
87   }
88 }