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 = "";
56 public UploadServiceInfo(String payloadData, String payloadName, String description, List<String> tags, String invariantUUID, String UUID,
57 String type, String category, String subcategory, String resourceVendor, String resourceVendorRelease,
58 String serviceRole, String serviceEcompNaming, String ecompGeneratedNaming, String namingPolicy,
59 List<UploadArtifactInfo> artifactList, String contactId, String name, String resourceIconPath, String icon,
60 String vendorName, String vendorRelease, String serviceVendorModelNumber, String serviceType, String projectCode, String model) {
61 this.payloadData = payloadData;
62 this.payloadName = payloadName;
63 this.description = description;
65 this.invariantUUID = invariantUUID;
68 this.category = category;
69 this.subcategory = subcategory;
70 this.resourceVendor = resourceVendor;
71 this.resourceVendorRelease = resourceVendorRelease;
72 this.serviceRole = serviceRole;
73 this.serviceEcompNaming = serviceEcompNaming;
74 this.ecompGeneratedNaming = ecompGeneratedNaming;
75 this.namingPolicy = namingPolicy;
76 this.artifactList = artifactList;
77 this.contactId = contactId;
79 this.serviceIconPath = serviceIconPath;
81 this.vendorName = vendorName;
82 this.vendorRelease = vendorRelease;
83 this.serviceVendorModelNumber = serviceVendorModelNumber;
84 this.serviceType = serviceType;
85 this.projectCode = projectCode;
87 if (category != null) {
88 String[] arr = category.split("/");
89 if (arr.length >= 2) {
90 categories = new ArrayList<>();
91 CategoryDefinition catDef = new CategoryDefinition();
92 catDef.setName(arr[0]);
93 SubCategoryDefinition subCat = new SubCategoryDefinition();
94 subCat.setName(arr[1]);
95 catDef.addSubCategory(subCat);
96 categories.add(catDef);
101 public UploadServiceInfo() {
104 public void addSubCategory(String category, String subCategory) {
105 if (category != null || subCategory != null) {
106 if (categories == null) {
107 categories = new ArrayList<>();
109 CategoryDefinition selectedCategory = null;
110 for (CategoryDefinition categoryDef : categories) {
111 if (categoryDef.getName().equals(category)) {
112 selectedCategory = categoryDef;
115 if (selectedCategory == null) {
116 selectedCategory = new CategoryDefinition();
117 selectedCategory.setName(category);
118 categories.add(selectedCategory);
120 List<SubCategoryDefinition> subcategories = selectedCategory.getSubcategories();
121 if (subcategories == null) {
122 subcategories = new ArrayList<>();
123 selectedCategory.setSubcategories(subcategories);
125 SubCategoryDefinition selectedSubcategory = null;
126 for (SubCategoryDefinition subcategory : subcategories) {
127 if (subcategory.getName().equals(subCategory)) {
128 selectedSubcategory = subcategory;
131 if (selectedSubcategory == null) {
132 selectedSubcategory = new SubCategoryDefinition();
133 selectedSubcategory.setName(subCategory);
134 subcategories.add(selectedSubcategory);