2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.vid.model;
23 import org.onap.vid.asdc.beans.tosca.Input;
24 import org.onap.vid.asdc.parser.ToscaParserImpl2.Constants;
28 import static org.onap.vid.asdc.parser.ToscaParserImpl2.isModuleTypeIsBaseObjectSafe;
30 public class Group implements MinimalNode {
36 /** The invariant uuid. */
37 private String invariantUuid;
39 /** The customization uuid. */
40 private String customizationUuid;
42 /** The description. */
43 private String description;
49 private String version;
51 /** The model customization name. */
52 private String modelCustomizationName;
54 /** The group properties. */
55 private GroupProperties properties;
57 private Map<String, Input> inputs;
61 * Gets the model customization name.
63 * @return the model customization name
65 public String getModelCustomizationName() {
66 return modelCustomizationName;
73 public String getUuid() {
78 * Gets the invariant uuid.
80 * @return the invariant uuid
82 public String getInvariantUuid() {
86 * Gets the customization uuid.
88 * @return the invariant uuid
90 public String getCustomizationUuid() {
91 return customizationUuid;
94 * Gets the description.
96 * @return the description
98 public String getDescription() {
106 public String getName() {
113 * @return the version
115 public String getVersion() {
120 * Gets the properties.
122 * @return the properties
124 public GroupProperties getProperties() {
130 * @param uuid the new uuid
132 public void setUuid(String uuid) {
137 * Sets the invariant uuid.
139 * @param invariantUuid the new invariant uuid
141 public void setInvariantUuid(String invariantUuid) {
142 this.invariantUuid = invariantUuid;
145 * Sets the customization uuid.
147 * @param customizationUuid the new customization uuid
149 public void setCustomizationUuid(String customizationUuid) {
150 this.customizationUuid = customizationUuid;
153 * Sets the description.
155 * @param description the new description
157 public void setDescription(String description) {
158 this.description = description;
164 * @param name the new name
166 public void setName(String name) {
173 * @param version the new version
175 public void setVersion(String version) {
176 this.version = version;
179 public Map<String, Input> getInputs() {
183 public void setInputs(Map<String, Input> inputs) {
184 this.inputs = inputs;
188 * Sets the model customization name.
190 * @param modelCustomizationName the new model customization name
192 public void setModelCustomizationName(String modelCustomizationName) {
193 this.modelCustomizationName = modelCustomizationName;
196 * Sets the group properties.
198 * @param properties the new model customization name
200 public void setProperties(GroupProperties properties) {
201 this.properties = properties;
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,
212 GroupProperties groupProperties = new GroupProperties();
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);
221 groupProperties.setBaseModule(isModuleTypeIsBaseObjectSafe(group.getProperties().get(Constants.VF_MODULE_TYPE)));
223 return groupProperties;
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);
231 case Constants.MAX_VF_MODULE_INSTANCES:
232 groupProperties.setMaxCountInstances(propertyValue);
234 case Constants.INITIAL_COUNT:
235 groupProperties.setInitialCount(propertyValue);