aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/datatypes/heattotosca/unifiedmodel/consolidation/ComputeTemplateConsolidationData.java
blob: c6721ce18fa0548e635a4388dcfd42afece7f836 (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation;

import org.openecomp.sdc.tosca.datatypes.model.RequirementAssignment;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * The type Compute template consolidation data.
 */
public class ComputeTemplateConsolidationData extends EntityConsolidationData {
  // key - volume node template id
  // List of requirement id and the requirement assignment on the
  // compute node which connect to this volume
  private Map<String,List<RequirementAssignmentData>> volumes;

  // key - port type (port id excluding index),
  // value - List of connected port node template ids, with this port type
  private Map<String, List<String>> ports;

  /**
   * Gets volumes.
   *
   * @return the volumes
   */
  public Map<String,List<RequirementAssignmentData>> getVolumes() {
    return volumes;
  }

  /**
   * Sets volumes.
   *
   * @param volumes the volumes
   */
  public void setVolumes(Map<String,List<RequirementAssignmentData>> volumes) {
    this.volumes = volumes;
  }

  /**
   * Gets ports.
   *
   * @return the ports
   */
  public Map<String, List<String>> getPorts() {
    return ports;
  }

  /**
   * Sets ports.
   *
   * @param ports the ports
   */
  public void setPorts(Map<String, List<String>> ports) {
    this.ports = ports;
  }

  /**
   * Add port.
   *
   * @param portType           the port type
   * @param portNodeTemplateId the port node template id
   */
  public void addPort(String portType, String portNodeTemplateId) {
    if (this.ports == null) {
      this.ports = new HashMap<>();
    }
    this.ports.putIfAbsent(portType, new ArrayList<>());
    this.ports.get(portType).add(portNodeTemplateId);
  }


  /**
   * Add volume.
   *
   * @param requirementId         the requirement id
   * @param requirementAssignment the requirement assignment
   */
  public void addVolume(String requirementId, RequirementAssignment requirementAssignment) {
    if (this.volumes == null) {
      this.volumes = new HashMap<>();
    }
    this.volumes.computeIfAbsent(requirementAssignment.getNode(), k -> new ArrayList<>())
        .add(new RequirementAssignmentData(requirementId,
            requirementAssignment));
  }
}