Sync Integ to Master
[sdc.git] / test-apis-ci / src / main / java / org / openecomp / sdc / ci / tests / datatypes / ResourceReqDetails.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 java.util.List;
24
25 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
26 import org.openecomp.sdc.be.model.Resource;
27
28 public class ResourceReqDetails extends ComponentReqDetails {
29         List<String> derivedFrom;
30         String vendorName;
31         String vendorRelease;
32         String componentType = "RESOURCE";
33
34         public String getComponentType() {
35                 return componentType;
36         }
37         // Unsettable/unupdatable fields
38
39         Boolean isAbstract;
40         Boolean isHighestVersion;
41         String cost;
42
43         String licenseType;
44         String toscaResourceName;
45         String resourceVendorModelNumber;
46
47         private String resourceType = ResourceTypeEnum.VFC.toString(); // Default
48                                                                                                                                         // value
49
50         public ResourceReqDetails() {
51                 super();
52         }
53
54         public ResourceReqDetails(List<String> derivedFrom, String vendorName, String vendorRelease, Boolean isAbstract, Boolean isHighestVersion, String cost, String licenseType, String toscaResourceName, String resourceVendorModelNumber,
55                         String resourceType) {
56                 super();
57                 this.derivedFrom = derivedFrom;
58                 this.vendorName = vendorName;
59                 this.vendorRelease = vendorRelease;
60                 this.isAbstract = isAbstract;
61                 this.isHighestVersion = isHighestVersion;
62                 this.cost = cost;
63                 this.licenseType = licenseType;
64                 this.toscaResourceName = toscaResourceName;
65                 this.resourceVendorModelNumber = resourceVendorModelNumber;
66                 this.resourceType = resourceType;
67         }
68
69         public ResourceReqDetails(Resource resource) {
70                 super();
71                 this.resourceType = resource.getResourceType().toString();
72                 this.name = resource.getName();
73                 this.description = resource.getDescription();
74                 this.tags = resource.getTags();
75                 // this.category = resource.getCategories();
76                 this.derivedFrom = resource.getDerivedFrom();
77                 this.vendorName = resource.getVendorName();
78                 this.vendorRelease = resource.getVendorRelease();
79                 this.contactId = resource.getContactId();
80                 this.icon = resource.getIcon();
81                 this.toscaResourceName = resource.getToscaResourceName();
82                 this.uniqueId = resource.getUniqueId();
83                 this.creatorUserId = resource.getCreatorUserId();
84                 this.creatorFullName = resource.getCreatorFullName();
85                 this.lastUpdaterUserId = resource.getLastUpdaterUserId();
86                 this.lastUpdaterFullName = resource.getLastUpdaterFullName();
87                 this.lifecycleState = resource.getLifecycleState();
88                 this.version = resource.getVersion();
89                 this.UUID = resource.getUUID();
90                 this.categories = resource.getCategories();
91                 this.importedToscaChecksum = resource.getImportedToscaChecksum();
92                 this.resourceVendorModelNumber = resource.getResourceVendorModelNumber();
93
94         }
95
96         public ResourceReqDetails(String resourceName, String description, List<String> tags, String category,
97                         List<String> derivedFrom, String vendorName, String vendorRelease, String contactId, String icon) {
98                 this(resourceName, description, tags, category, derivedFrom, vendorName, vendorRelease, contactId, icon,
99                                 ResourceTypeEnum.VFC.toString());
100         }
101
102         // new
103         public ResourceReqDetails(String resourceName, String description, List<String> tags, String category,
104                         List<String> derivedFrom, String vendorName, String vendorRelease, String contactId, String icon,
105                         String resourceType) {
106                 super();
107                 this.resourceType = resourceType;
108                 this.name = resourceName;
109                 this.description = description;
110                 this.tags = tags;
111                 // this.category = category;
112                 this.derivedFrom = derivedFrom;
113                 this.vendorName = vendorName;
114                 this.vendorRelease = vendorRelease;
115                 this.contactId = contactId;
116                 this.icon = icon;
117                 if (category != null) {
118                         String[] arr = category.split("/");
119                         if (arr.length == 2) {
120                                 addCategoryChain(arr[0], arr[1]);
121                         }
122                 }
123                 this.toscaResourceName = resourceName;
124         }
125
126         public ResourceReqDetails(ResourceReqDetails originalResource, String version) {
127                 super();
128                 this.name = originalResource.getName();
129                 this.description = originalResource.getDescription();
130                 this.tags = originalResource.getTags();
131                 // this.category = originalResource.getCategory();
132                 this.derivedFrom = originalResource.getDerivedFrom();
133                 this.vendorName = originalResource.getVendorName();
134                 this.vendorRelease = originalResource.getVendorRelease();
135                 this.contactId = originalResource.getContactId();
136                 this.icon = originalResource.getIcon();
137                 this.version = version;
138                 this.uniqueId = originalResource.getUniqueId();
139                 this.categories = originalResource.getCategories();
140                 this.toscaResourceName = originalResource.getToscaResourceName();
141                 this.resourceType = originalResource.getResourceType();
142         }
143
144         public ResourceReqDetails(String resourceName, List<String> derivedFrom, String vendorName, String vendorRelease,
145                         String resourceVersion, Boolean isAbstract, Boolean isHighestVersion, String cost, String licenseType,
146                         String resourceType) {
147                 super();
148                 this.name = resourceName;
149                 this.derivedFrom = derivedFrom;
150                 this.vendorName = vendorName;
151                 this.vendorRelease = vendorRelease;
152                 this.version = resourceVersion;
153                 this.isAbstract = isAbstract;
154                 this.isHighestVersion = isHighestVersion;
155                 this.cost = cost;
156                 this.licenseType = licenseType;
157                 this.resourceType = resourceType;
158                 this.toscaResourceName = resourceName;
159         }
160
161         public String getResourceVendorModelNumber() {
162                 return resourceVendorModelNumber;
163         }
164         
165         public void setResourceVendorModelNumber(String resourceVendorModelNumber) {
166                 this.resourceVendorModelNumber = resourceVendorModelNumber;
167         }
168         public String getToscaResourceName() {
169                 return toscaResourceName;
170         }
171
172         public void setToscaResourceName(String toscaResourceName) {
173                 this.toscaResourceName = toscaResourceName;
174         }
175
176         public List<String> getDerivedFrom() {
177                 return derivedFrom;
178         }
179
180         public void setDerivedFrom(List<String> derivedFrom) {
181                 this.derivedFrom = derivedFrom;
182         }
183
184         public String getVendorName() {
185                 return vendorName;
186         }
187
188         public void setVendorName(String vendorName) {
189                 this.vendorName = vendorName;
190         }
191
192         public String getVendorRelease() {
193                 return vendorRelease;
194         }
195
196         public void setVendorRelease(String vendorRelease) {
197                 this.vendorRelease = vendorRelease;
198         }
199
200         public String getCost() {
201                 return cost;
202         }
203
204         public void setCost(String cost) {
205                 this.cost = cost;
206         }
207
208         public String getLicenseType() {
209                 return licenseType;
210         }
211
212         public void setLicenseType(String licenseType) {
213                 this.licenseType = licenseType;
214         }
215
216         // Unupdatable fields - to check that they are not updated
217         public void setIsAbstract(Boolean isAbstract) {
218                 this.isAbstract = isAbstract;
219         }
220
221         public void setIsHighestVersion(Boolean isHighestVersion) {
222                 this.isHighestVersion = isHighestVersion;
223         }
224
225         public Boolean getIsAbstract() {
226                 return isAbstract;
227         }
228
229         public Boolean getIsHighestVersion() {
230                 return isHighestVersion;
231         }
232
233         public String getResourceType() {
234                 return resourceType;
235         }
236
237         public void setResourceType(String resourceType) {
238                 this.resourceType = resourceType;
239         }
240
241         @Override
242         public String toString() {
243                 return "ResourceReqDetails [name=" + name + ", derivedFrom=" + derivedFrom + ", vendorName=" + vendorName
244                                 + ", vendorRelease=" + vendorRelease + ", version=" + version + ", isAbstract=" + isAbstract
245                                 + ", isHighestVersion=" + isHighestVersion + ", cost=" + cost + ", licenseType=" + licenseType
246                                 + ", resourceType=" + resourceType + "]";
247         }
248
249 }