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.setOnboardingOrigin(vsp.getOnboardingOrigin());
49 target.setLicensingVersion(vsp.getVlmVersion() == null ? null : new VersionDto(vsp.getVlmVersion().toString(), vsp.getVlmVersion().toString()));
50 target.setIsOldVersion("False");
51 target.setNetworkPackageName(vsp.getNetworkPackageName());
53 if (vsp.getLicenseAgreement() != null || vsp.getFeatureGroups() != null) {
54 LicensingData licensingData = new LicensingData();
55 licensingData.setLicenseAgreement(vsp.getLicenseAgreement());
56 licensingData.setFeatureGroups(vsp.getFeatureGroups());
57 target.setLicensingData(licensingData);
60 target.setValidationData(vsp.getValidationDataStructure());
62 target.setStatus(source.getVersionInfo().getStatus());
63 target.setLockingUser(source.getVersionInfo().getLockingUser());
65 if (!CommonMethods.isEmpty(source.getVersionInfo().getViewableVersions())) {
66 target.setViewableVersions(
67 source.getVersionInfo().getViewableVersions().stream()
68 .map(version -> new VersionDto(version.toString(), version.toString()))
69 .collect(Collectors.toList()));
72 if (!CommonMethods.isEmpty(source.getVersionInfo().getFinalVersions())) {
73 target.setFinalVersions(
74 source.getVersionInfo().getFinalVersions().stream()
75 .map(version -> new VersionDto(version.toString(), version.toString()))
76 .collect(Collectors.toList()));
79 //Onboarding Method valid value will always be present in VSP saved in DB
80 target.setOnboardingMethod(vsp.getOnboardingMethod());