2 * ============LICENSE_START=======================================================
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
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.openecomp.sdc.ci.tests.datatypes;
23 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
24 import org.openecomp.sdc.be.model.Resource;
26 import java.util.List;
28 public class ResourceReqDetails extends ComponentReqDetails {
29 List<String> derivedFrom;
32 String componentType = "RESOURCE";
34 public String getComponentType() {
37 // Unsettable/unupdatable fields
40 Boolean isHighestVersion;
44 String toscaResourceName;
45 String resourceVendorModelNumber;
47 private String resourceType = ResourceTypeEnum.VFC.toString(); // Default
50 public ResourceReqDetails() {
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) {
57 this.derivedFrom = derivedFrom;
58 this.vendorName = vendorName;
59 this.vendorRelease = vendorRelease;
60 this.isAbstract = isAbstract;
61 this.isHighestVersion = isHighestVersion;
63 this.licenseType = licenseType;
64 this.toscaResourceName = toscaResourceName;
65 this.resourceVendorModelNumber = resourceVendorModelNumber;
66 this.resourceType = resourceType;
69 public ResourceReqDetails(Resource resource) {
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();
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());
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) {
105 this.resourceType = resourceType;
106 this.name = resourceName;
107 this.description = description;
109 this.derivedFrom = derivedFrom;
110 this.vendorName = vendorName;
111 this.vendorRelease = vendorRelease;
112 this.contactId = contactId;
114 if (category != null) {
115 String[] arr = category.split("/");
116 if (arr.length == 2) {
117 addCategoryChain(arr[0], arr[1]);
120 this.toscaResourceName = resourceName;
123 public ResourceReqDetails(ResourceReqDetails originalResource, String version) {
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();
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) {
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;
152 this.licenseType = licenseType;
153 this.resourceType = resourceType;
154 this.toscaResourceName = resourceName;
157 public String getResourceVendorModelNumber() {
158 return resourceVendorModelNumber;
161 public void setResourceVendorModelNumber(String resourceVendorModelNumber) {
162 this.resourceVendorModelNumber = resourceVendorModelNumber;
164 public String getToscaResourceName() {
165 return toscaResourceName;
168 public void setToscaResourceName(String toscaResourceName) {
169 this.toscaResourceName = toscaResourceName;
172 public List<String> getDerivedFrom() {
176 public void setDerivedFrom(List<String> derivedFrom) {
177 this.derivedFrom = derivedFrom;
180 public String getVendorName() {
184 public void setVendorName(String vendorName) {
185 this.vendorName = vendorName;
188 public String getVendorRelease() {
189 return vendorRelease;
192 public void setVendorRelease(String vendorRelease) {
193 this.vendorRelease = vendorRelease;
196 public String getCost() {
200 public void setCost(String cost) {
204 public String getLicenseType() {
208 public void setLicenseType(String licenseType) {
209 this.licenseType = licenseType;
212 // Unupdatable fields - to check that they are not updated
213 public void setIsAbstract(Boolean isAbstract) {
214 this.isAbstract = isAbstract;
217 public void setIsHighestVersion(Boolean isHighestVersion) {
218 this.isHighestVersion = isHighestVersion;
221 public Boolean getIsAbstract() {
225 public Boolean getIsHighestVersion() {
226 return isHighestVersion;
229 public String getResourceType() {
233 public void setResourceType(String resourceType) {
234 this.resourceType = resourceType;
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 + "]";