1360677d78067416317b6c06e87540f88066c3c1
[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 import org.onap.sdc.tosca.datatypes.model.RequirementAssignment;
24
25 /**
26  * The type Entity consolidation data.
27  */
28 public class EntityConsolidationData {
29
30     private String nodeTemplateId;
31
32     //groups that point to this entity node template
33     private List<String> groupIds;
34
35     // key - node template id which has connection to this entity
36     // value - List of Requirement assignment data which connect to this entity
37     private Map<String, List<RequirementAssignmentData>> nodesConnectedIn;
38
39     // key - node template id which connected from this entity
40     // List of Requirement assignment data which connect to the key node template id
41     private Map<String, List<RequirementAssignmentData>> nodesConnectedOut;
42
43     //key - node template id which include get attribute function from this entity
44     //value - List of getAttr data
45     private Map<String, List<GetAttrFuncData>> nodesGetAttrIn;
46
47     //key - node template id which is pointed by this entity using get attribute function
48     //value - List of getAttr data
49     private Map<String, List<GetAttrFuncData>> nodesGetAttrOut;
50
51     //List of getAttr data
52     private List<GetAttrFuncData> outputParametersGetAttrIn;
53
54     public String getNodeTemplateId() {
55         return nodeTemplateId;
56     }
57
58     public void setNodeTemplateId(String nodeTemplateId) {
59         this.nodeTemplateId = nodeTemplateId;
60     }
61
62     /**
63     * Gets group ids point to me.
64     *
65     * @return the group ids point to me
66     */
67     public List<String> getGroupIds() {
68         return groupIds;
69     }
70
71     /**
72     * Sets group ids point to me.
73     *
74     * @param groupIds the group ids point to me
75     */
76     public void setGroupIds(List<String> groupIds) {
77         this.groupIds = groupIds;
78     }
79
80
81     /**
82     * Sets node connected to me.
83     *
84     * @param nodesConnectedIn the node connected to me
85     */
86     public void setNodesConnectedIn(Map<String, List<RequirementAssignmentData>> nodesConnectedIn) {
87         this.nodesConnectedIn = nodesConnectedIn;
88     }
89
90     /**
91     * Add nodeConnectedIn.
92     *
93     * @param nodeTemplateId        the node template id which has connection to me
94     * @param requirementId         the requirement id
95     * @param requirementAssignment the requirement assignment
96     */
97     public void addNodesConnectedIn(String nodeTemplateId, String requirementId,
98                                   RequirementAssignment requirementAssignment) {
99
100         if (this.nodesConnectedIn == null) {
101             this.nodesConnectedIn = new HashMap<>();
102         }
103
104         this.nodesConnectedIn.computeIfAbsent(nodeTemplateId, k -> new ArrayList<>());
105         this.nodesConnectedIn.get(nodeTemplateId).add(
106                 new RequirementAssignmentData(requirementId, requirementAssignment));
107     }
108
109     /**
110     * Gets node connected to me.
111     *
112     * @return the node connected to me
113     */
114     public Map<String, List<RequirementAssignmentData>> getNodesConnectedIn() {
115         return nodesConnectedIn;
116     }
117
118
119     /**
120     * Gets node connected from me.
121     *
122     * @return the node connected from me
123     */
124     public Map<String, List<RequirementAssignmentData>> getNodesConnectedOut() {
125         return nodesConnectedOut;
126     }
127
128     /**
129     * Sets node connected from me.
130     *
131     * @param nodesConnectedOut the node connected from me
132     */
133     public void setNodesConnectedOut(Map<String, List<RequirementAssignmentData>> nodesConnectedOut) {
134         this.nodesConnectedOut = nodesConnectedOut;
135     }
136
137     /**
138     * Add nodeConnectedOut.
139     *
140     * @param nodeTemplateId        the node template id which is connected from me
141     * @param requirementId         the requirement id
142     * @param requirementAssignment the requirement assignment
143     */
144     public void addNodesConnectedOut(String nodeTemplateId, String requirementId,
145                                    RequirementAssignment requirementAssignment) {
146
147         if (this.nodesConnectedOut == null) {
148             this.nodesConnectedOut = new HashMap<>();
149         }
150
151         this.nodesConnectedOut.computeIfAbsent(nodeTemplateId, k -> new ArrayList<>());
152         this.nodesConnectedOut.get(nodeTemplateId).add(
153                 new RequirementAssignmentData(requirementId, requirementAssignment));
154     }
155
156     /**
157     * Gets nodes get attr in.
158     *
159     * @return the get attr in
160     */
161     public Map<String, List<GetAttrFuncData>> getNodesGetAttrIn() {
162         return nodesGetAttrIn;
163     }
164
165     /**
166     * Sets nodes get attr in.
167     *
168     * @param nodesGetAttrIn the get attr in
169     */
170     public void setNodesGetAttrIn(Map<String, List<GetAttrFuncData>> nodesGetAttrIn) {
171         this.nodesGetAttrIn = nodesGetAttrIn;
172     }
173
174     /**
175     * Add nodes get attr in data.
176     *
177     * @param nodeTemplateId  the node template id
178     * @param getAttrFuncData get attr data
179     */
180     public void addNodesGetAttrIn(String nodeTemplateId, GetAttrFuncData getAttrFuncData) {
181
182         if (nodesGetAttrIn == null) {
183             nodesGetAttrIn = new HashMap<>();
184         }
185
186         this.nodesGetAttrIn.putIfAbsent(nodeTemplateId, new ArrayList<>());
187         this.nodesGetAttrIn.get(nodeTemplateId).add(getAttrFuncData);
188     }
189
190     /**
191     * Gets output parameters get attr from me.
192     *
193     * @return the get attr from me
194     */
195     public List<GetAttrFuncData> getOutputParametersGetAttrIn() {
196         return outputParametersGetAttrIn;
197     }
198
199     /**
200     * Sets output parameters get attr from me.
201     *
202     * @param outputParametersGetAttrIn the output parameters get attr from me
203     */
204     public void setOutputParametersGetAttrIn(List<GetAttrFuncData> outputParametersGetAttrIn) {
205         this.outputParametersGetAttrIn = outputParametersGetAttrIn;
206     }
207
208     /**
209     * Add output parameters get attr data.
210     *
211     * @param getAttrFuncData get attr data
212     */
213     public void addOutputParamGetAttrIn(GetAttrFuncData getAttrFuncData) {
214
215         if (outputParametersGetAttrIn == null) {
216             outputParametersGetAttrIn = new ArrayList<>();
217         }
218
219         this.outputParametersGetAttrIn.add(getAttrFuncData);
220     }
221
222     /**
223     * Gets nodes get attr out.
224     *
225     * @return the get attr out
226     */
227     public Map<String, List<GetAttrFuncData>> getNodesGetAttrOut() {
228         return nodesGetAttrOut;
229     }
230
231     /**
232     * Sets nodes get attr out.
233     *
234     * @param nodesGetAttrOut the get attr out
235     */
236     public void setNodesGetAttrOut(Map<String, List<GetAttrFuncData>> nodesGetAttrOut) {
237         this.nodesGetAttrOut = nodesGetAttrOut;
238     }
239
240     /**
241     * Add nodes get attr out data.
242     *
243     * @param nodeTemplateId  the node template id
244     * @param getAttrFuncData get attr data
245     */
246     public void addNodesGetAttrOut(String nodeTemplateId, GetAttrFuncData getAttrFuncData) {
247
248         if (nodesGetAttrOut == null) {
249             nodesGetAttrOut = new HashMap<>();
250         }
251
252         this.nodesGetAttrOut.putIfAbsent(nodeTemplateId, new ArrayList<>());
253         this.nodesGetAttrOut.get(nodeTemplateId).add(getAttrFuncData);
254     }
255
256     public void removeParamNameFromAttrFuncList(String paramName) {
257
258         if (outputParametersGetAttrIn == null) {
259             return;
260         }
261
262         outputParametersGetAttrIn.removeIf(outputParameters -> paramName.equals(outputParameters.getFieldName()));
263     }
264 }