2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T 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=========================================================
21 package org.openecomp.sdcrests.vsp.rest.mapping;
23 import org.openecomp.core.utilities.CommonMethods;
24 import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
25 import org.openecomp.sdc.vendorsoftwareproduct.types.LicensingData;
26 import org.openecomp.sdc.vendorsoftwareproduct.types.VersionedVendorSoftwareProductInfo;
27 import org.openecomp.sdcrests.common.types.VersionDto;
28 import org.openecomp.sdcrests.mapping.MappingBase;
29 import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDetailsDto;
31 import java.util.stream.Collectors;
33 public class MapVersionedVendorSoftwareProductInfoToVspDetailsDto
34 extends MappingBase<VersionedVendorSoftwareProductInfo, VspDetailsDto> {
37 public void doMapping(VersionedVendorSoftwareProductInfo source, VspDetailsDto target) {
38 VspDetails vsp = source.getVspDetails();
40 target.setId(vsp.getId());
41 target.setVersion(new VersionDto(vsp.getVersion().toString(), vsp.getVersion().toString()));
42 target.setName(vsp.getName());
43 target.setDescription(vsp.getDescription());
44 target.setCategory(vsp.getCategory());
45 target.setSubCategory(vsp.getSubCategory());
46 target.setVendorId(vsp.getVendorId());
47 target.setVendorName(vsp.getVendorName());
48 target.setLicensingVersion(vsp.getVlmVersion() == null ? null : new VersionDto(vsp.getVlmVersion().toString(), vsp.getVlmVersion().toString()));
49 target.setIsOldVersion("False");
51 if (vsp.getLicenseAgreement() != null || vsp.getFeatureGroups() != null) {
52 LicensingData licensingData = new LicensingData();
53 licensingData.setLicenseAgreement(vsp.getLicenseAgreement());
54 licensingData.setFeatureGroups(vsp.getFeatureGroups());
55 target.setLicensingData(licensingData);
58 target.setValidationData(vsp.getValidationDataStructure());
60 target.setStatus(source.getVersionInfo().getStatus());
61 target.setLockingUser(source.getVersionInfo().getLockingUser());
63 if (!CommonMethods.isEmpty(source.getVersionInfo().getViewableVersions())) {
64 target.setViewableVersions(
65 source.getVersionInfo().getViewableVersions().stream()
66 .map(version -> new VersionDto(version.toString(), version.toString()))
67 .collect(Collectors.toList()));
70 if (!CommonMethods.isEmpty(source.getVersionInfo().getFinalVersions())) {
71 target.setFinalVersions(
72 source.getVersionInfo().getFinalVersions().stream()
73 .map(version -> new VersionDto(version.toString(), version.toString()))
74 .collect(Collectors.toList()));
77 //Onboarding Method valid value will always be present in VSP saved in DB
78 target.setOnboardingMethod(vsp.getOnboardingMethod());