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=========================================================
20 package org.openecomp.sdc.be.model;
22 import java.util.ArrayList;
23 import java.util.List;
26 import org.openecomp.sdc.be.model.category.CategoryDefinition;
27 import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
28 import org.openecomp.sdc.common.api.UploadArtifactInfo;
32 public class UploadServiceInfo {
34 private String payloadData;
35 private String payloadName;
36 private String description;
37 private List<String> tags;
38 private List<CategoryDefinition> categories;
39 private String invariantUUID;
42 private String category;
43 private String subcategory;
44 private String resourceVendor;
45 private String resourceVendorRelease;
46 private String serviceRole;
47 private String serviceEcompNaming;
48 private String ecompGeneratedNaming;
49 private String namingPolicy;
50 private String projectCode;
51 private List<UploadArtifactInfo> artifactList;
52 private String contactId, name, serviceIconPath, icon, vendorName, vendorRelease, serviceVendorModelNumber;
53 private String serviceType = "";
55 public UploadServiceInfo(String payloadData, String payloadName, String description, List<String> tags, String invariantUUID, String UUID,
56 String type, String category, String subcategory, String resourceVendor, String resourceVendorRelease,
57 String serviceRole, String serviceEcompNaming, String ecompGeneratedNaming, String namingPolicy,
58 List<UploadArtifactInfo> artifactList, String contactId, String name, String resourceIconPath, String icon,
59 String vendorName, String vendorRelease, String serviceVendorModelNumber, String serviceType, String projectCode) {
60 this.payloadData = payloadData;
61 this.payloadName = payloadName;
62 this.description = description;
64 this.invariantUUID = invariantUUID;
67 this.category = category;
68 this.subcategory = subcategory;
69 this.resourceVendor = resourceVendor;
70 this.resourceVendorRelease = resourceVendorRelease;
71 this.serviceRole = serviceRole;
72 this.serviceEcompNaming = serviceEcompNaming;
73 this.ecompGeneratedNaming = ecompGeneratedNaming;
74 this.namingPolicy = namingPolicy;
75 this.artifactList = artifactList;
76 this.contactId = contactId;
78 this.serviceIconPath = serviceIconPath;
80 this.vendorName = vendorName;
81 this.vendorRelease = vendorRelease;
82 this.serviceVendorModelNumber = serviceVendorModelNumber;
83 this.serviceType = serviceType;
84 this.projectCode = projectCode;
85 if (category != null) {
86 String[] arr = category.split("/");
87 if (arr.length >= 2) {
88 categories = new ArrayList<>();
89 CategoryDefinition catDef = new CategoryDefinition();
90 catDef.setName(arr[0]);
91 SubCategoryDefinition subCat = new SubCategoryDefinition();
92 subCat.setName(arr[1]);
93 catDef.addSubCategory(subCat);
94 categories.add(catDef);
99 public UploadServiceInfo() {
102 public void addSubCategory(String category, String subCategory) {
103 if (category != null || subCategory != null) {
104 if (categories == null) {
105 categories = new ArrayList<>();
107 CategoryDefinition selectedCategory = null;
108 for (CategoryDefinition categoryDef : categories) {
109 if (categoryDef.getName().equals(category)) {
110 selectedCategory = categoryDef;
113 if (selectedCategory == null) {
114 selectedCategory = new CategoryDefinition();
115 selectedCategory.setName(category);
116 categories.add(selectedCategory);
118 List<SubCategoryDefinition> subcategories = selectedCategory.getSubcategories();
119 if (subcategories == null) {
120 subcategories = new ArrayList<>();
121 selectedCategory.setSubcategories(subcategories);
123 SubCategoryDefinition selectedSubcategory = null;
124 for (SubCategoryDefinition subcategory : subcategories) {
125 if (subcategory.getName().equals(subCategory)) {
126 selectedSubcategory = subcategory;
129 if (selectedSubcategory == null) {
130 selectedSubcategory = new SubCategoryDefinition();
131 selectedSubcategory.setName(subCategory);
132 subcategories.add(selectedSubcategory);