actually adding the files to the initial commit
[vid.git] / vid / src / main / java / org / openecomp / vid / model / VfModule.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * VID
4  * ================================================================================
5  * Copyright (C) 2017 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.openecomp.vid.model;
22
23 import org.openecomp.vid.asdc.beans.tosca.Group;
24
25 /**
26  * The Class VfModule.
27  */
28 public class VfModule {
29
30         /** The uuid. */
31         private String uuid;
32         
33         /** The invariant uuid. */
34         private String invariantUuid;
35         
36         /** The description. */
37         private String description;
38         
39         /** The name. */
40         private String name;
41         
42         /** The version. */
43         private String version;
44         
45         /** The volume group allowed. */
46         private boolean volumeGroupAllowed;
47         
48         /**
49          * Instantiates a new vf module.
50          */
51         public VfModule() {}
52         
53         /**
54          * Gets the uuid.
55          *
56          * @return the uuid
57          */
58         public String getUuid() {
59                 return uuid;
60         }
61
62         /**
63          * Gets the invariant uuid.
64          *
65          * @return the invariant uuid
66          */
67         public String getInvariantUuid() {
68                 return invariantUuid;
69         }
70
71         /**
72          * Gets the description.
73          *
74          * @return the description
75          */
76         public String getDescription() {
77                 return description;
78         }
79
80         /**
81          * Gets the name.
82          *
83          * @return the name
84          */
85         public String getName() {
86                 return name;
87         }
88
89         /**
90          * Gets the version.
91          *
92          * @return the version
93          */
94         public String getVersion() {
95                 return version;
96         }
97
98         /**
99          * Checks if is volume group allowed.
100          *
101          * @return true, if is volume group allowed
102          */
103         public boolean isVolumeGroupAllowed() {
104                 return volumeGroupAllowed;
105         }
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         /**
126          * Sets the description.
127          *
128          * @param description the new description
129          */
130         public void setDescription(String description) {
131                 this.description = description;
132         }
133
134         /**
135          * Sets the name.
136          *
137          * @param name the new name
138          */
139         public void setName(String name) {
140                 this.name = name;
141         }
142
143         /**
144          * Sets the version.
145          *
146          * @param version the new version
147          */
148         public void setVersion(String version) {
149                 this.version = version;
150         }
151
152         /**
153          * Sets the volume group allowed.
154          *
155          * @param volumeGroupAllowed the new volume group allowed
156          */
157         private void setVolumeGroupAllowed(boolean volumeGroupAllowed) {
158                 this.volumeGroupAllowed = volumeGroupAllowed;
159         }
160         
161         /**
162          * Extract vf module.
163          *
164          * @param group the group
165          * @return the vf module
166          */
167         public static VfModule extractVfModule(Group group) {
168
169                 final VfModule vfModule = new VfModule();
170                 
171                 vfModule.setUuid(group.getMetadata().getVfModuleModelUUID());
172                 vfModule.setInvariantUuid(group.getMetadata().getVfModuleModelInvariantUUID());
173                 vfModule.setDescription(group.getMetadata().getDescription());
174                 vfModule.setName(group.getMetadata().getVfModuleModelName());
175                 vfModule.setVersion(group.getMetadata().getVfModuleModelVersion());
176                 
177                 if (group.getProperties().containsKey("volume_group")) {
178                         vfModule.setVolumeGroupAllowed(Boolean.valueOf(group.getProperties().get("volume_group")));
179                 } else {
180                         vfModule.setVolumeGroupAllowed(false);
181                 }
182                 
183                 return vfModule;
184         }
185 }