Specify a model while creating a VSP
[sdc.git] / openecomp-be / api / openecomp-sdc-rest-webapp / vendor-software-products-rest / vendor-software-products-rest-types / src / main / java / org / openecomp / sdcrests / vendorsoftwareproducts / types / VspDescriptionDto.java
1 /*
2  * Copyright © 2016-2018 European Support Limited
3  * Modifications Copyright (C) 2021 Nordix Foundation.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 package org.openecomp.sdcrests.vendorsoftwareproducts.types;
18
19 import java.util.ArrayList;
20 import java.util.Collections;
21 import java.util.List;
22 import java.util.stream.Collectors;
23 import javax.validation.constraints.NotNull;
24 import lombok.Data;
25 import lombok.EqualsAndHashCode;
26 import lombok.ToString;
27 import org.apache.commons.collections.CollectionUtils;
28 import org.openecomp.sdc.common.util.ValidationUtils;
29 import org.openecomp.sdc.vendorsoftwareproduct.dao.type.LicenseType;
30 import org.openecomp.sdc.vendorsoftwareproduct.types.LicensingData;
31
32 @Data
33 @ToString
34 @EqualsAndHashCode
35 public class VspDescriptionDto {
36
37     @NotNull
38     private String name;
39     @NotNull
40     private String description;
41     private String icon;
42     @NotNull
43     private String category;
44     @NotNull
45     private String subCategory;
46     @NotNull
47     private String vendorName;
48     @NotNull
49     private String vendorId;            // this will be populated with vlm id
50     private String licensingVersion;    // this will be populated with vlm version
51     private LicenseType licenseType;
52     private LicensingData licensingData;
53     private List<String> selectedModelList;
54
55     public void setName(final String name) {
56         this.name = ValidationUtils.sanitizeInputString(name);
57     }
58
59     public void setVendorName(final String vendorName) {
60         this.vendorName = ValidationUtils.sanitizeInputString(vendorName);
61     }
62
63     public void setDescription(final String description) {
64         this.description = ValidationUtils.sanitizeInputString(description);
65     }
66
67     public void setSelectedModelList(final List<String> selectedModelList) {
68         if (CollectionUtils.isEmpty(selectedModelList)) {
69             this.selectedModelList = new ArrayList<>();
70             return;
71         }
72         this.selectedModelList = selectedModelList.stream().map(ValidationUtils::sanitizeInputString).collect(Collectors.toList());
73     }
74
75     public List<String> getSelectedModelList() {
76         if (selectedModelList == null) {
77             return Collections.emptyList();
78         }
79         return new ArrayList<>(selectedModelList);
80     }
81 }