Implement 'Update Service by importing Tosca Template'-story
[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.NoArgsConstructor;
27 import lombok.Setter;
28 import org.openecomp.sdc.be.model.category.CategoryDefinition;
29 import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
30 import org.openecomp.sdc.common.api.UploadArtifactInfo;
31
32 @Getter
33 @Setter
34 @NoArgsConstructor
35 public class UploadServiceInfo {
36
37     private String payloadData;
38     private String payloadName;
39     private String description;
40     private List<String> tags;
41     private List<CategoryDefinition> categories;
42     private String invariantUUID;
43     private String UUID;
44     private String type;
45     private String category;
46     private String subcategory;
47     private String resourceVendor;
48     private String resourceVendorRelease;
49     private String serviceRole;
50     private String serviceEcompNaming;
51     private String ecompGeneratedNaming;
52     private String namingPolicy;
53     private String serviceFunction;
54     private String environmentContext;
55     private String instantiationType;
56     private String projectCode;
57     private List<UploadArtifactInfo> artifactList;
58     private String contactId;
59     private String name;
60     private String serviceIconPath;
61     private String icon;
62     private String vendorName;
63     private String tenant;
64     private String vendorRelease;
65     private String serviceVendorModelNumber;
66     private String serviceType = "";
67     private String model;
68     private Map<String, String> categorySpecificMetadata;
69     private String derivedFromGenericType;
70     private String derivedFromGenericVersion;
71
72     public void addSubCategory(String category, String subCategory) {
73         if (category != null || subCategory != null) {
74             if (categories == null) {
75                 categories = new ArrayList<>();
76             }
77             CategoryDefinition selectedCategory = null;
78             for (CategoryDefinition categoryDef : categories) {
79                 if (categoryDef.getName().equals(category)) {
80                     selectedCategory = categoryDef;
81                 }
82             }
83             if (selectedCategory == null) {
84                 selectedCategory = new CategoryDefinition();
85                 selectedCategory.setName(category);
86                 categories.add(selectedCategory);
87             }
88             List<SubCategoryDefinition> subcategories = selectedCategory.getSubcategories();
89             if (subcategories == null) {
90                 subcategories = new ArrayList<>();
91                 selectedCategory.setSubcategories(subcategories);
92             }
93             SubCategoryDefinition selectedSubcategory = null;
94             for (SubCategoryDefinition subcategory : subcategories) {
95                 if (subcategory.getName().equals(subCategory)) {
96                     selectedSubcategory = subcategory;
97                 }
98             }
99             if (selectedSubcategory == null) {
100                 selectedSubcategory = new SubCategoryDefinition();
101                 selectedSubcategory.setName(subCategory);
102                 subcategories.add(selectedSubcategory);
103             }
104         }
105     }
106 }