re base code
[sdc.git] / test-apis-ci / src / main / java / org / openecomp / sdc / ci / tests / datatypes / ComponentReqDetails.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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.sdc.ci.tests.datatypes;
22
23 import org.openecomp.sdc.be.model.LifecycleStateEnum;
24 import org.openecomp.sdc.be.model.category.CategoryDefinition;
25 import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
26
27 import java.util.ArrayList;
28 import java.util.List;
29
30 public abstract class ComponentReqDetails {
31
32         protected String name;
33         protected String description;
34         protected List<String> tags = new ArrayList<>();
35         protected String contactId;
36         protected String icon;
37         protected String uniqueId;
38         protected String creatorUserId;
39         protected String creatorFullName;
40         protected String lastUpdaterUserId;
41         protected String lastUpdaterFullName;
42         protected Long creationDate;
43         protected Long lastUpdateDate;
44         protected LifecycleStateEnum lifecycleState;
45         protected String version;
46         protected String UUID;
47         protected List<CategoryDefinition> categories;
48         protected String projectCode;
49         protected String csarUUID;
50         protected String csarVersion;
51         protected String importedToscaChecksum;
52         protected String invariantUUID;
53
54         public String getCsarVersion() {
55                 return csarVersion;
56         }
57
58         public void setCsarVersion(String csarVersion) {
59                 this.csarVersion = csarVersion;
60         }
61
62         public String getName() {
63                 return name;
64         }
65
66         public void setName(String name) {
67                 this.name = name;
68                 tags.add(name);
69         }
70
71         public List<String> getTags() {
72                 return tags;
73         }
74
75         public void setTags(List<String> tags) {
76                 this.tags = tags;
77         }
78
79         // public String getCategory() {
80         // return category;
81         // }
82         //
83         public String getContactId() {
84                 return contactId;
85         }
86
87         public void setContactId(String contactId) {
88                 this.contactId = contactId;
89         }
90
91         public String getIcon() {
92                 return icon;
93         }
94
95         public void setIcon(String icon) {
96                 this.icon = icon;
97         }
98
99         public String getUniqueId() {
100                 return uniqueId;
101         }
102
103         public void setUniqueId(String uniqueId) {
104                 this.uniqueId = uniqueId;
105         }
106
107         public void setCreatorUserId(String creatorUserId) {
108                 this.creatorUserId = creatorUserId;
109         }
110
111         public void setCreatorFullName(String creatorFullName) {
112                 this.creatorFullName = creatorFullName;
113         }
114
115         public void setLastUpdaterUserId(String lastUpdaterUserId) {
116                 this.lastUpdaterUserId = lastUpdaterUserId;
117         }
118
119         public void setLastUpdaterFullName(String lastUpdaterFullName) {
120                 this.lastUpdaterFullName = lastUpdaterFullName;
121         }
122
123         public void setCreationDate(Long creationDate) {
124                 this.creationDate = creationDate;
125         }
126
127         public void setLastUpdateDate(Long lastUpdateDate) {
128                 this.lastUpdateDate = lastUpdateDate;
129         }
130
131         public void setLifecycleState(LifecycleStateEnum lifecycleState) {
132                 this.lifecycleState = lifecycleState;
133         }
134
135         public void setUUID(String uUID) {
136                 this.UUID = uUID;
137         }
138
139         public String getCreatorUserId() {
140                 return creatorUserId;
141         }
142
143         public String getCreatorFullName() {
144                 return creatorFullName;
145         }
146
147         public String getLastUpdaterUserId() {
148                 return lastUpdaterUserId;
149         }
150
151         public String getLastUpdaterFullName() {
152                 return lastUpdaterFullName;
153         }
154
155         public Long getCreationDate() {
156                 return creationDate;
157         }
158
159         public Long getLastUpdateDate() {
160                 return lastUpdateDate;
161         }
162
163         public LifecycleStateEnum getLifecycleState() {
164                 return lifecycleState;
165         }
166
167         public String getUUID() {
168                 return UUID;
169         }
170
171         public String getVersion() {
172                 return version;
173         }
174
175         public void setVersion(String version) {
176                 this.version = version;
177         }
178
179         public String getDescription() {
180                 return description;
181         }
182
183         public void setDescription(String description) {
184                 this.description = description;
185         }
186
187         public List<CategoryDefinition> getCategories() {
188                 return categories;
189         }
190
191         public void setCategories(List<CategoryDefinition> categories) {
192                 this.categories = categories;
193         }
194
195         public void removeAllCategories() {
196                 this.categories = new ArrayList<>();
197         }
198
199         public void addCategoryChain(String category, String subCategory) {
200                 if (category != null || subCategory != null) {
201                         if (categories == null) {
202                                 categories = new ArrayList<>();
203                         }
204                         CategoryDefinition selectedCategory = null;
205                         for (CategoryDefinition categoryDef : categories) {
206                                 if (categoryDef.getName().equals(category)) {
207                                         selectedCategory = categoryDef;
208                                 }
209                         }
210                         if (selectedCategory == null) {
211                                 selectedCategory = new CategoryDefinition();
212                                 selectedCategory.setName(category);
213                                 categories.add(selectedCategory);
214                         }
215                         if (subCategory != null) {
216                                 List<SubCategoryDefinition> subcategories = selectedCategory.getSubcategories();
217                                 if (subcategories == null) {
218                                         subcategories = new ArrayList<>();
219                                         selectedCategory.setSubcategories(subcategories);
220                                 }
221                                 SubCategoryDefinition selectedSubcategory = null;
222                                 for (SubCategoryDefinition subcategory : subcategories) {
223                                         if (subcategory.getName().equals(subCategory)) {
224                                                 selectedSubcategory = subcategory;
225                                         }
226                                 }
227                                 if (selectedSubcategory == null) {
228                                         selectedSubcategory = new SubCategoryDefinition();
229                                         selectedSubcategory.setName(subCategory);
230                                         subcategories.add(selectedSubcategory);
231                                 }
232                         }
233                 }
234         }
235
236         public void addCategory(String category) {
237                 addCategoryChain(category, null);
238         }
239
240         public String getProjectCode() {
241                 return projectCode;
242         }
243
244         public void setProjectCode(String projectCode) {
245                 this.projectCode = projectCode;
246         }
247
248         public String getCsarUUID() {
249                 return csarUUID;
250         }
251
252         public void setCsarUUID(String csarUUID) {
253                 this.csarUUID = csarUUID;
254         }
255
256         public String getImportedToscaChecksum() {
257                 return importedToscaChecksum;
258         }
259
260         public void setImportedToscaChecksum(String importedToscaChecksum) {
261                 this.importedToscaChecksum = importedToscaChecksum;
262         }
263
264         public String getInvariantUUID() {
265                 return invariantUUID;
266         }
267
268         public void setInvariantUUID(String invariantUUID) {
269                 this.invariantUUID = invariantUUID;
270         }
271
272 }