e2f3be12fb17dfd44ddd35dc15a7887208a61d3f
[sdc.git] /
1 /*
2  * Copyright © 2016-2018 European Support Limited
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.openecomp.sdc.translator.datatypes.heattotosca.unifiedmodel.consolidation;
18
19 import java.util.ArrayList;
20 import java.util.HashMap;
21 import java.util.List;
22 import java.util.Map;
23
24 import org.onap.sdc.tosca.datatypes.model.RequirementAssignment;
25
26 public class ComputeTemplateConsolidationData extends EntityConsolidationData {
27     // key - volume node template id
28     // value - List of requirement id and the requirement assignment on the
29     // compute node which connect to this volume
30     private Map<String,List<RequirementAssignmentData>> volumes;
31
32     // key - port type (port id excluding index),
33     // value - List of connected port node template ids, with this port type
34     private Map<String, List<String>> ports;
35
36     public Map<String,List<RequirementAssignmentData>> getVolumes() {
37         return volumes;
38     }
39
40     public void setVolumes(Map<String,List<RequirementAssignmentData>> volumes) {
41         this.volumes = volumes;
42     }
43
44     public Map<String, List<String>> getPorts() {
45         return ports;
46     }
47
48     public void setPorts(Map<String, List<String>> ports) {
49         this.ports = ports;
50     }
51
52     public void addPort(String portType, String portNodeTemplateId) {
53         if (this.ports == null) {
54             this.ports = new HashMap<>();
55         }
56         this.ports.putIfAbsent(portType, new ArrayList<>());
57         this.ports.get(portType).add(portNodeTemplateId);
58     }
59
60     public void addVolume(String requirementId, RequirementAssignment requirementAssignment) {
61         if (this.volumes == null) {
62             this.volumes = new HashMap<>();
63         }
64         this.volumes.computeIfAbsent(requirementAssignment.getNode(), k -> new ArrayList<>())
65                 .add(new RequirementAssignmentData(requirementId,
66                 requirementAssignment));
67     }
68 }