Fix for Penetration test _ Session and cookie management
[vid.git] / vid-app-common / src / main / java / org / onap / vid / model / Group.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * VID
4  * ================================================================================
5  * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.vid.model;
22
23 import org.onap.vid.asdc.beans.tosca.Input;
24 import org.onap.vid.asdc.parser.ToscaParserImpl2.Constants;
25
26 import java.util.Map;
27
28 import static org.onap.vid.asdc.parser.ToscaParserImpl2.isModuleTypeIsBaseObjectSafe;
29
30 public class Group implements MinimalNode {
31
32
33     /** The uuid. */
34     private String uuid;
35
36     /** The invariant uuid. */
37     private String invariantUuid;
38
39     /** The customization uuid. */
40     private String customizationUuid;
41
42     /** The description. */
43     private String description;
44
45     /** The name. */
46     private String name;
47
48     /** The version. */
49     private String version;
50
51     /** The model customization name. */
52     private String modelCustomizationName;
53
54     /** The group properties. */
55     private GroupProperties properties;
56
57     private Map<String, Input> inputs;
58
59
60     /**
61      * Gets the model customization name.
62      *
63      * @return the model customization name
64      */
65     public String getModelCustomizationName() {
66         return modelCustomizationName;
67     }
68     /**
69      * Gets the uuid.
70      *
71      * @return the uuid
72      */
73     public String getUuid() {
74         return uuid;
75     }
76
77     /**
78      * Gets the invariant uuid.
79      *
80      * @return the invariant uuid
81      */
82     public String getInvariantUuid() {
83         return invariantUuid;
84     }
85     /**
86      * Gets the customization uuid.
87      *
88      * @return the invariant uuid
89      */
90     public String getCustomizationUuid() {
91         return customizationUuid;
92     }
93     /**
94      * Gets the description.
95      *
96      * @return the description
97      */
98     public String getDescription() {
99         return description;
100     }
101     /**
102      * Gets the name.
103      *
104      * @return the name
105      */
106     public String getName() {
107         return name;
108     }
109
110     /**
111      * Gets the version.
112      *
113      * @return the version
114      */
115     public String getVersion() {
116         return version;
117     }
118
119     /**
120      * Gets the properties.
121      *
122      * @return the properties
123      */
124     public GroupProperties getProperties() {
125         return properties;
126     }
127     /**
128      * Sets the uuid.
129      *
130      * @param uuid the new uuid
131      */
132     public void setUuid(String uuid) {
133         this.uuid = uuid;
134     }
135
136     /**
137      * Sets the invariant uuid.
138      *
139      * @param invariantUuid the new invariant uuid
140      */
141     public void setInvariantUuid(String invariantUuid) {
142         this.invariantUuid = invariantUuid;
143     }
144     /**
145      * Sets the customization uuid.
146      *
147      * @param customizationUuid the new customization uuid
148      */
149     public void setCustomizationUuid(String customizationUuid) {
150         this.customizationUuid = customizationUuid;
151     }
152     /**
153      * Sets the description.
154      *
155      * @param description the new description
156      */
157     public void setDescription(String description) {
158         this.description = description;
159     }
160
161     /**
162      * Sets the name.
163      *
164      * @param name the new name
165      */
166     public void setName(String name) {
167         this.name = name;
168     }
169
170     /**
171      * Sets the version.
172      *
173      * @param version the new version
174      */
175     public void setVersion(String version) {
176         this.version = version;
177     }
178
179     public Map<String, Input> getInputs() {
180         return inputs;
181     }
182
183     public void setInputs(Map<String, Input> inputs) {
184         this.inputs = inputs;
185     }
186
187     /**
188      * Sets the model customization name.
189      *
190      * @param modelCustomizationName the new model customization name
191      */
192     public void setModelCustomizationName(String modelCustomizationName) {
193         this.modelCustomizationName = modelCustomizationName;
194     }
195     /**
196      * Sets the group properties.
197      *
198      * @param properties the new model customization name
199      */
200     public void setProperties(GroupProperties properties) {
201         this.properties = properties;
202     }
203
204
205
206     protected static GroupProperties extractPropertiesForGroup(org.onap.vid.asdc.beans.tosca.Group group){
207         String [] propertyKeys = {
208                 Constants.MIN_VF_MODULE_INSTANCES,
209                 Constants.MAX_VF_MODULE_INSTANCES,
210                 Constants.INITIAL_COUNT,
211         };
212         GroupProperties groupProperties = new GroupProperties();
213
214         for(String propertyKey : propertyKeys){
215             Object val = group.getProperties().get(propertyKey);
216             if (val != null && val instanceof Integer) {
217                 setInGroupProperties(groupProperties, propertyKey, (Integer) val);
218             }
219         }
220
221         groupProperties.setBaseModule(isModuleTypeIsBaseObjectSafe(group.getProperties().get(Constants.VF_MODULE_TYPE)));
222
223         return groupProperties;
224     }
225
226     private static void setInGroupProperties(GroupProperties groupProperties, String propertyKey, Integer propertyValue){
227         switch (propertyKey) {
228             case Constants.MIN_VF_MODULE_INSTANCES:
229                 groupProperties.setMinCountInstances(propertyValue);
230                 break;
231             case Constants.MAX_VF_MODULE_INSTANCES:
232                 groupProperties.setMaxCountInstances(propertyValue);
233                 break;
234             case Constants.INITIAL_COUNT:
235                 groupProperties.setInitialCount(propertyValue);
236                 break;
237             default:
238                 // do noting
239         }
240     }
241 }