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=========================================================
20 package org.openecomp.sdc.be.model;
22 import java.util.ArrayList;
23 import java.util.List;
24 import lombok.NoArgsConstructor;
25 import org.openecomp.sdc.be.model.category.CategoryDefinition;
26 import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
27 import org.openecomp.sdc.common.api.UploadArtifactInfo;
30 public class UploadResourceInfo {
32 private String payloadData;
33 private String payloadName;
34 private String description;
35 private List<String> tags;
36 private List<CategoryDefinition> categories;
37 private List<UploadArtifactInfo> artifactList;
38 private String contactId, name, resourceIconPath, icon, vendorName, vendorRelease, resourceVendorModelNumber;
39 private String resourceType = "VFC";
42 public UploadResourceInfo(String payload, String payloadName, String description, String category, List<String> tags,
43 List<UploadArtifactInfo> artifactsList, String modelName) {
44 this.payloadData = payload;
45 this.payloadName = payloadName;
46 this.description = description;
48 this.artifactList = artifactsList;
49 this.model = modelName;
50 if (category != null) {
51 String[] arr = category.split("/");
52 if (arr.length >= 2) {
53 categories = new ArrayList<>();
54 CategoryDefinition catDef = new CategoryDefinition();
55 catDef.setName(arr[0]);
56 SubCategoryDefinition subCat = new SubCategoryDefinition();
57 subCat.setName(arr[1]);
58 catDef.addSubCategory(subCat);
59 categories.add(catDef);
64 public String getPayloadData() {
68 public void setPayloadData(String payload) {
69 this.payloadData = payload;
72 public String getPayloadName() {
76 public void setPayloadName(String payloadName) {
77 this.payloadName = payloadName;
80 public String getDescription() {
84 public void setDescription(String description) {
85 this.description = description;
88 public List<String> getTags() {
92 public void setTags(List<String> tags) {
96 public List<UploadArtifactInfo> getArtifactList() {
100 public void setArtifactList(List<UploadArtifactInfo> artifactsList) {
101 this.artifactList = artifactsList;
104 public String getModel() {
108 public void setModel(final String model) {
113 public int hashCode() {
114 final int prime = 31;
116 result = prime * result + ((artifactList == null) ? 0 : artifactList.hashCode());
117 result = prime * result + ((contactId == null) ? 0 : contactId.hashCode());
118 result = prime * result + ((description == null) ? 0 : description.hashCode());
119 result = prime * result + ((icon == null) ? 0 : icon.hashCode());
120 result = prime * result + ((payloadData == null) ? 0 : payloadData.hashCode());
121 result = prime * result + ((payloadName == null) ? 0 : payloadName.hashCode());
122 result = prime * result + ((resourceIconPath == null) ? 0 : resourceIconPath.hashCode());
123 result = prime * result + ((name == null) ? 0 : name.hashCode());
124 result = prime * result + ((tags == null) ? 0 : tags.hashCode());
125 result = prime * result + ((vendorName == null) ? 0 : vendorName.hashCode());
126 result = prime * result + ((vendorRelease == null) ? 0 : vendorRelease.hashCode());
127 result = prime * result + ((model == null) ? 0 : model.hashCode());
128 result = prime * result + ((resourceVendorModelNumber == null) ? 0 : resourceVendorModelNumber.hashCode());
133 public boolean equals(Object obj) {
140 if (getClass() != obj.getClass()) {
143 UploadResourceInfo other = (UploadResourceInfo) obj;
144 if (artifactList == null) {
145 if (other.artifactList != null) {
148 } else if (!artifactList.equals(other.artifactList)) {
151 if (contactId == null) {
152 if (other.contactId != null) {
155 } else if (!contactId.equals(other.contactId)) {
158 if (description == null) {
159 if (other.description != null) {
162 } else if (!description.equals(other.description)) {
166 if (other.icon != null) {
169 } else if (!icon.equals(other.icon)) {
172 if (payloadData == null) {
173 if (other.payloadData != null) {
176 } else if (!payloadData.equals(other.payloadData)) {
179 if (payloadName == null) {
180 if (other.payloadName != null) {
183 } else if (!payloadName.equals(other.payloadName)) {
186 if (resourceIconPath == null) {
187 if (other.resourceIconPath != null) {
190 } else if (!resourceIconPath.equals(other.resourceIconPath)) {
194 if (other.name != null) {
197 } else if (!name.equals(other.name)) {
201 if (other.tags != null) {
204 } else if (!tags.equals(other.tags)) {
208 if (other.model != null) {
211 } else if (!model.equals(other.model)) {
214 if (vendorName == null) {
215 if (other.vendorName != null) {
218 } else if (!vendorName.equals(other.vendorName)) {
221 if (resourceVendorModelNumber == null) {
222 if (other.resourceVendorModelNumber != null) {
225 } else if (!resourceVendorModelNumber.equals(other.resourceVendorModelNumber)) {
228 if (vendorRelease == null) {
229 if (other.vendorRelease != null) {
232 } else if (!vendorRelease.equals(other.vendorRelease)) {
238 public String getContactId() {
242 public void setContactId(String userId) {
243 this.contactId = userId;
246 public String getName() {
250 public void setName(String resourceName) {
251 this.name = resourceName;
254 // Icon when using UI import otherwise resourceIconPath
255 public String getResourceIconPath() {
256 return (resourceIconPath != null) ? resourceIconPath : icon;
259 public void setResourceIconPath(String resourceIconPath) {
260 this.resourceIconPath = resourceIconPath;
263 public String getVendorName() {
267 public void setVendorName(String vendorName) {
268 this.vendorName = vendorName;
271 public String getVendorRelease() {
272 return vendorRelease;
275 public void setVendorRelease(String vendorRelease) {
276 this.vendorRelease = vendorRelease;
279 public String getResourceVendorModelNumber() {
280 return resourceVendorModelNumber;
283 public void setResourceVendorModelNumber(String resourceVendorModelNumber) {
284 this.resourceVendorModelNumber = resourceVendorModelNumber;
287 public void setIcon(String icon) {
291 public String getResourceType() {
295 public void setResourceType(String resourceType) {
296 this.resourceType = resourceType;
299 public List<CategoryDefinition> getCategories() {
303 public void setCategories(List<CategoryDefinition> categories) {
304 this.categories = categories;
307 public void addSubCategory(String category, String subCategory) {
308 if (category != null || subCategory != null) {
309 if (categories == null) {
310 categories = new ArrayList<>();
312 CategoryDefinition selectedCategory = null;
313 for (CategoryDefinition categoryDef : categories) {
314 if (categoryDef.getName().equals(category)) {
315 selectedCategory = categoryDef;
318 if (selectedCategory == null) {
319 selectedCategory = new CategoryDefinition();
320 selectedCategory.setName(category);
321 categories.add(selectedCategory);
323 List<SubCategoryDefinition> subcategories = selectedCategory.getSubcategories();
324 if (subcategories == null) {
325 subcategories = new ArrayList<>();
326 selectedCategory.setSubcategories(subcategories);
328 SubCategoryDefinition selectedSubcategory = null;
329 for (SubCategoryDefinition subcategory : subcategories) {
330 if (subcategory.getName().equals(subCategory)) {
331 selectedSubcategory = subcategory;
334 if (selectedSubcategory == null) {
335 selectedSubcategory = new SubCategoryDefinition();
336 selectedSubcategory.setName(subCategory);
337 subcategories.add(selectedSubcategory);