d709947cfa98981590b67edea2c1826e12b1c780
[sdc.git] / catalog-model / src / main / java / org / openecomp / sdc / be / model / UploadServiceInfo.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20 package org.openecomp.sdc.be.model;
21
22 import java.util.ArrayList;
23 import java.util.List;
24 import java.util.Map;
25 import lombok.Getter;
26 import lombok.Setter;
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;
30
31 @Getter
32 @Setter
33 public class UploadServiceInfo {
34
35     private String payloadData;
36     private String payloadName;
37     private String description;
38     private List<String> tags;
39     private List<CategoryDefinition> categories;
40     private String invariantUUID;
41     private String UUID;
42     private String type;
43     private String category;
44     private String subcategory;
45     private String resourceVendor;
46     private String resourceVendorRelease;
47     private String serviceRole;
48     private String serviceEcompNaming;
49     private String ecompGeneratedNaming;
50     private String namingPolicy;
51     private String serviceFunction;
52     private String environmentContext;
53     private String instantiationType;
54     private String projectCode;
55     private List<UploadArtifactInfo> artifactList;
56     private String contactId;
57     private String name;
58     private String serviceIconPath;
59     private String icon;
60     private String vendorName;
61     private String tenant;
62     private String vendorRelease;
63     private String serviceVendorModelNumber;
64     private String serviceType = "";
65     private String model;
66     private Map<String, String> categorySpecificMetadata;
67     private String derivedFromGenericType;
68     private String derivedFromGenericVersion;
69
70     public UploadServiceInfo() {
71     }
72
73     public void addSubCategory(String category, String subCategory) {
74         if (category != null || subCategory != null) {
75             if (categories == null) {
76                 categories = new ArrayList<>();
77             }
78             CategoryDefinition selectedCategory = null;
79             for (CategoryDefinition categoryDef : categories) {
80                 if (categoryDef.getName().equals(category)) {
81                     selectedCategory = categoryDef;
82                 }
83             }
84             if (selectedCategory == null) {
85                 selectedCategory = new CategoryDefinition();
86                 selectedCategory.setName(category);
87                 categories.add(selectedCategory);
88             }
89             List<SubCategoryDefinition> subcategories = selectedCategory.getSubcategories();
90             if (subcategories == null) {
91                 subcategories = new ArrayList<>();
92                 selectedCategory.setSubcategories(subcategories);
93             }
94             SubCategoryDefinition selectedSubcategory = null;
95             for (SubCategoryDefinition subcategory : subcategories) {
96                 if (subcategory.getName().equals(subCategory)) {
97                     selectedSubcategory = subcategory;
98                 }
99             }
100             if (selectedSubcategory == null) {
101                 selectedSubcategory = new SubCategoryDefinition();
102                 selectedSubcategory.setName(subCategory);
103                 subcategories.add(selectedSubcategory);
104             }
105         }
106     }
107 }