Merge from ECOMP's repository
[vid.git] / vid-app-common / src / main / java / org / onap / vid / model / Group.java
1 package org.onap.vid.model;
2
3 import org.onap.vid.asdc.beans.tosca.Input;
4 import org.onap.vid.asdc.parser.ToscaParserImpl2.Constants;
5
6 import java.util.Map;
7
8 import static org.onap.vid.asdc.parser.ToscaParserImpl2.isModuleTypeIsBaseObjectSafe;
9
10 public class Group implements MinimalNode {
11
12
13     /** The uuid. */
14     private String uuid;
15
16     /** The invariant uuid. */
17     private String invariantUuid;
18
19     /** The customization uuid. */
20     private String customizationUuid;
21
22     /** The description. */
23     private String description;
24
25     /** The name. */
26     private String name;
27
28     /** The version. */
29     private String version;
30
31     /** The model customization name. */
32     private String modelCustomizationName;
33
34     /** The group properties. */
35     private GroupProperties properties;
36
37     private Map<String, Input> inputs;
38
39
40     /**
41      * Gets the model customization name.
42      *
43      * @return the model customization name
44      */
45     public String getModelCustomizationName() {
46         return modelCustomizationName;
47     }
48     /**
49      * Gets the uuid.
50      *
51      * @return the uuid
52      */
53     public String getUuid() {
54         return uuid;
55     }
56
57     /**
58      * Gets the invariant uuid.
59      *
60      * @return the invariant uuid
61      */
62     public String getInvariantUuid() {
63         return invariantUuid;
64     }
65     /**
66      * Gets the customization uuid.
67      *
68      * @return the invariant uuid
69      */
70     public String getCustomizationUuid() {
71         return customizationUuid;
72     }
73     /**
74      * Gets the description.
75      *
76      * @return the description
77      */
78     public String getDescription() {
79         return description;
80     }
81     /**
82      * Gets the name.
83      *
84      * @return the name
85      */
86     public String getName() {
87         return name;
88     }
89
90     /**
91      * Gets the version.
92      *
93      * @return the version
94      */
95     public String getVersion() {
96         return version;
97     }
98
99     /**
100      * Gets the properties.
101      *
102      * @return the properties
103      */
104     public GroupProperties getProperties() {
105         return properties;
106     }
107     /**
108      * Sets the uuid.
109      *
110      * @param uuid the new uuid
111      */
112     public void setUuid(String uuid) {
113         this.uuid = uuid;
114     }
115
116     /**
117      * Sets the invariant uuid.
118      *
119      * @param invariantUuid the new invariant uuid
120      */
121     public void setInvariantUuid(String invariantUuid) {
122         this.invariantUuid = invariantUuid;
123     }
124     /**
125      * Sets the customization uuid.
126      *
127      * @param customizationUuid the new customization uuid
128      */
129     public void setCustomizationUuid(String customizationUuid) {
130         this.customizationUuid = customizationUuid;
131     }
132     /**
133      * Sets the description.
134      *
135      * @param description the new description
136      */
137     public void setDescription(String description) {
138         this.description = description;
139     }
140
141     /**
142      * Sets the name.
143      *
144      * @param name the new name
145      */
146     public void setName(String name) {
147         this.name = name;
148     }
149
150     /**
151      * Sets the version.
152      *
153      * @param version the new version
154      */
155     public void setVersion(String version) {
156         this.version = version;
157     }
158
159     public Map<String, Input> getInputs() {
160         return inputs;
161     }
162
163     public void setInputs(Map<String, Input> inputs) {
164         this.inputs = inputs;
165     }
166
167     /**
168      * Sets the model customization name.
169      *
170      * @param modelCustomizationName the new model customization name
171      */
172     public void setModelCustomizationName(String modelCustomizationName) {
173         this.modelCustomizationName = modelCustomizationName;
174     }
175     /**
176      * Sets the group properties.
177      *
178      * @param properties the new model customization name
179      */
180     public void setProperties(GroupProperties properties) {
181         this.properties = properties;
182     }
183
184
185
186     protected static GroupProperties extractPropertiesForGroup(org.onap.vid.asdc.beans.tosca.Group group){
187         String [] propertyKeys = {
188                 Constants.MIN_VF_MODULE_INSTANCES,
189                 Constants.MAX_VF_MODULE_INSTANCES,
190                 Constants.INITIAL_COUNT,
191         };
192         GroupProperties groupProperties = new GroupProperties();
193
194         for(String propertyKey : propertyKeys){
195             Object val = group.getProperties().get(propertyKey);
196             if (val != null && val instanceof Integer) {
197                 setInGroupProperties(groupProperties, propertyKey, (Integer) val);
198             }
199         }
200
201         groupProperties.setBaseModule(isModuleTypeIsBaseObjectSafe(group.getProperties().get(Constants.VF_MODULE_TYPE)));
202
203         return groupProperties;
204     }
205
206     private static void setInGroupProperties(GroupProperties groupProperties, String propertyKey, Integer propertyValue){
207         switch (propertyKey) {
208             case Constants.MIN_VF_MODULE_INSTANCES:
209                 groupProperties.setMinCountInstances(propertyValue);
210                 break;
211             case Constants.MAX_VF_MODULE_INSTANCES:
212                 groupProperties.setMaxCountInstances(propertyValue);
213                 break;
214             case Constants.INITIAL_COUNT:
215                 groupProperties.setInitialCount(propertyValue);
216                 break;
217             default:
218                 // do noting
219         }
220     }
221 }