2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 CMCC 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.be.model;
23 import java.util.ArrayList;
24 import java.util.List;
27 import org.openecomp.sdc.be.model.category.CategoryDefinition;
28 import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
29 import org.openecomp.sdc.common.api.UploadArtifactInfo;
33 public class UploadServiceInfo {
35 private String payloadData;
36 private String payloadName;
37 private String description;
38 private List<String> tags;
39 private List<CategoryDefinition> categories;
41 private String invariantUUID;
44 private String category;
45 private String subcategory;
46 private String resourceVendor;
47 private String resourceVendorRelease;
48 private String serviceRole;
49 private String serviceEcompNaming;
50 private String ecompGeneratedNaming;
51 private String namingPolicy;
52 private String projectCode;
55 private List<UploadArtifactInfo> artifactList;
56 private String contactId, name, serviceIconPath, icon, vendorName, vendorRelease, serviceVendorModelNumber;
58 private String serviceType = "";
60 public UploadServiceInfo(String payloadData, String payloadName, String description,
61 List<String> tags, String invariantUUID, String UUID, String type,
62 String category, String subcategory, String resourceVendor,
63 String resourceVendorRelease, String serviceRole, String serviceEcompNaming,
64 String ecompGeneratedNaming, String namingPolicy,
65 List<UploadArtifactInfo> artifactList, String contactId, String name,
66 String resourceIconPath, String icon, String vendorName, String vendorRelease,
67 String serviceVendorModelNumber, String serviceType, String projectCode) {
68 this.payloadData = payloadData;
69 this.payloadName = payloadName;
70 this.description = description;
72 this.invariantUUID = invariantUUID;
75 this.category = category;
76 this.subcategory = subcategory;
77 this.resourceVendor = resourceVendor;
78 this.resourceVendorRelease = resourceVendorRelease;
79 this.serviceRole = serviceRole;
80 this.serviceEcompNaming = serviceEcompNaming;
81 this.ecompGeneratedNaming = ecompGeneratedNaming;
82 this.namingPolicy = namingPolicy;
83 this.artifactList = artifactList;
84 this.contactId = contactId;
86 this.serviceIconPath = serviceIconPath;
88 this.vendorName = vendorName;
89 this.vendorRelease = vendorRelease;
90 this.serviceVendorModelNumber = serviceVendorModelNumber;
91 this.serviceType = serviceType;
92 this.projectCode = projectCode;
94 if (category != null) {
95 String[] arr = category.split("/");
96 if (arr.length >= 2) {
97 categories = new ArrayList<>();
98 CategoryDefinition catDef = new CategoryDefinition();
99 catDef.setName(arr[0]);
100 SubCategoryDefinition subCat = new SubCategoryDefinition();
101 subCat.setName(arr[1]);
102 catDef.addSubCategory(subCat);
103 categories.add(catDef);
108 public UploadServiceInfo() {
110 public void addSubCategory(String category, String subCategory) {
111 if (category != null || subCategory != null) {
112 if (categories == null) {
113 categories = new ArrayList<>();
115 CategoryDefinition selectedCategory = null;
116 for (CategoryDefinition categoryDef : categories) {
117 if (categoryDef.getName().equals(category)) {
118 selectedCategory = categoryDef;
121 if (selectedCategory == null) {
122 selectedCategory = new CategoryDefinition();
123 selectedCategory.setName(category);
124 categories.add(selectedCategory);
126 List<SubCategoryDefinition> subcategories = selectedCategory.getSubcategories();
127 if (subcategories == null) {
128 subcategories = new ArrayList<>();
129 selectedCategory.setSubcategories(subcategories);
131 SubCategoryDefinition selectedSubcategory = null;
132 for (SubCategoryDefinition subcategory : subcategories) {
133 if (subcategory.getName().equals(subCategory)) {
134 selectedSubcategory = subcategory;
137 if (selectedSubcategory == null) {
138 selectedSubcategory = new SubCategoryDefinition();
139 selectedSubcategory.setName(subCategory);
140 subcategories.add(selectedSubcategory);