re base code
[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 org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
24 import org.openecomp.sdc.be.model.Resource;
25
26 import java.util.List;
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.derivedFrom = resource.getDerivedFrom();
76                 this.vendorName = resource.getVendorName();
77                 this.vendorRelease = resource.getVendorRelease();
78                 this.contactId = resource.getContactId();
79                 this.icon = resource.getIcon();
80                 this.toscaResourceName = resource.getToscaResourceName();
81                 this.uniqueId = resource.getUniqueId();
82                 this.creatorUserId = resource.getCreatorUserId();
83                 this.creatorFullName = resource.getCreatorFullName();
84                 this.lastUpdaterUserId = resource.getLastUpdaterUserId();
85                 this.lastUpdaterFullName = resource.getLastUpdaterFullName();
86                 this.lifecycleState = resource.getLifecycleState();
87                 this.version = resource.getVersion();
88                 this.UUID = resource.getUUID();
89                 this.categories = resource.getCategories();
90                 this.importedToscaChecksum = resource.getImportedToscaChecksum();
91                 this.resourceVendorModelNumber = resource.getResourceVendorModelNumber();
92
93         }
94
95         public ResourceReqDetails(String resourceName, String description, List<String> tags, String category,
96                         List<String> derivedFrom, String vendorName, String vendorRelease, String contactId, String icon) {
97                 this(resourceName, description, tags, category, derivedFrom, vendorName, vendorRelease, contactId, icon,
98                                 ResourceTypeEnum.VFC.toString());
99         }
100
101         public ResourceReqDetails(String resourceName, String description, List<String> tags, String category,
102                         List<String> derivedFrom, String vendorName, String vendorRelease, String contactId, String icon,
103                         String resourceType) {
104                 super();
105                 this.resourceType = resourceType;
106                 this.name = resourceName;
107                 this.description = description;
108                 this.tags = tags;
109                 this.derivedFrom = derivedFrom;
110                 this.vendorName = vendorName;
111                 this.vendorRelease = vendorRelease;
112                 this.contactId = contactId;
113                 this.icon = icon;
114                 if (category != null) {
115                         String[] arr = category.split("/");
116                         if (arr.length == 2) {
117                                 addCategoryChain(arr[0], arr[1]);
118                         }
119                 }
120                 this.toscaResourceName = resourceName;
121         }
122
123         public ResourceReqDetails(ResourceReqDetails originalResource, String version) {
124                 super();
125                 this.name = originalResource.getName();
126                 this.description = originalResource.getDescription();
127                 this.tags = originalResource.getTags();
128                 this.derivedFrom = originalResource.getDerivedFrom();
129                 this.vendorName = originalResource.getVendorName();
130                 this.vendorRelease = originalResource.getVendorRelease();
131                 this.contactId = originalResource.getContactId();
132                 this.icon = originalResource.getIcon();
133                 this.version = version;
134                 this.uniqueId = originalResource.getUniqueId();
135                 this.categories = originalResource.getCategories();
136                 this.toscaResourceName = originalResource.getToscaResourceName();
137                 this.resourceType = originalResource.getResourceType();
138         }
139
140         public ResourceReqDetails(String resourceName, List<String> derivedFrom, String vendorName, String vendorRelease,
141                         String resourceVersion, Boolean isAbstract, Boolean isHighestVersion, String cost, String licenseType,
142                         String resourceType) {
143                 super();
144                 this.name = resourceName;
145                 this.derivedFrom = derivedFrom;
146                 this.vendorName = vendorName;
147                 this.vendorRelease = vendorRelease;
148                 this.version = resourceVersion;
149                 this.isAbstract = isAbstract;
150                 this.isHighestVersion = isHighestVersion;
151                 this.cost = cost;
152                 this.licenseType = licenseType;
153                 this.resourceType = resourceType;
154                 this.toscaResourceName = resourceName;
155         }
156
157         public String getResourceVendorModelNumber() {
158                 return resourceVendorModelNumber;
159         }
160         
161         public void setResourceVendorModelNumber(String resourceVendorModelNumber) {
162                 this.resourceVendorModelNumber = resourceVendorModelNumber;
163         }
164         public String getToscaResourceName() {
165                 return toscaResourceName;
166         }
167
168         public void setToscaResourceName(String toscaResourceName) {
169                 this.toscaResourceName = toscaResourceName;
170         }
171
172         public List<String> getDerivedFrom() {
173                 return derivedFrom;
174         }
175
176         public void setDerivedFrom(List<String> derivedFrom) {
177                 this.derivedFrom = derivedFrom;
178         }
179
180         public String getVendorName() {
181                 return vendorName;
182         }
183
184         public void setVendorName(String vendorName) {
185                 this.vendorName = vendorName;
186         }
187
188         public String getVendorRelease() {
189                 return vendorRelease;
190         }
191
192         public void setVendorRelease(String vendorRelease) {
193                 this.vendorRelease = vendorRelease;
194         }
195
196         public String getCost() {
197                 return cost;
198         }
199
200         public void setCost(String cost) {
201                 this.cost = cost;
202         }
203
204         public String getLicenseType() {
205                 return licenseType;
206         }
207
208         public void setLicenseType(String licenseType) {
209                 this.licenseType = licenseType;
210         }
211
212         // Unupdatable fields - to check that they are not updated
213         public void setIsAbstract(Boolean isAbstract) {
214                 this.isAbstract = isAbstract;
215         }
216
217         public void setIsHighestVersion(Boolean isHighestVersion) {
218                 this.isHighestVersion = isHighestVersion;
219         }
220
221         public Boolean getIsAbstract() {
222                 return isAbstract;
223         }
224
225         public Boolean getIsHighestVersion() {
226                 return isHighestVersion;
227         }
228
229         public String getResourceType() {
230                 return resourceType;
231         }
232
233         public void setResourceType(String resourceType) {
234                 this.resourceType = resourceType;
235         }
236
237         @Override
238         public String toString() {
239                 return "ResourceReqDetails [name=" + name + ", derivedFrom=" + derivedFrom + ", vendorName=" + vendorName
240                                 + ", vendorRelease=" + vendorRelease + ", version=" + version + ", isAbstract=" + isAbstract
241                                 + ", isHighestVersion=" + isHighestVersion + ", cost=" + cost + ", licenseType=" + licenseType
242                                 + ", resourceType=" + resourceType + "]";
243         }
244
245 }