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