From f2c0a4118c3c0b6360b639622766543bd754b59c Mon Sep 17 00:00:00 2001 From: JerzySzachniewicz Date: Fri, 12 Feb 2021 13:53:13 +0100 Subject: Creation of Vendor Licensing Model is an optional step in VSP onboarding Issue-ID: SDC-3471 Signed-off-by: JerzySzachniewicz Change-Id: Icb98d0832c49939e200ece77f4ca26744cb82222 --- .../mapping/MapVspDescriptionDtoToVspDetails.java | 8 +- .../vsp/rest/mapping/MapVspDetailsToDto.java | 8 +- .../MapVspDescriptionDtoToVspDetailsTest.java | 23 +++++- .../vsp/rest/mapping/MapVspDetailsToDtoTest.java | 8 +- .../types/VspDescriptionDto.java | 2 + .../dao/type/LicenseType.java | 27 +++++++ .../vendorsoftwareproduct/dao/type/VspDetails.java | 1 + .../VendorSoftwareProductInfoDaoZusammenImpl.java | 3 + .../convertor/ElementToVSPGeneralConvertor.java | 2 + .../scss/modules/_softwareProductLandingPage.scss | 10 ++- openecomp-ui/src/nfvo-utils/i18n/en.json | 2 + .../softwareProduct/SoftwareProductActionHelper.js | 1 + .../details/SoftwareProductDetailsView.jsx | 25 ++++-- .../landingPage/SoftwareProductLandingPage.js | 30 +++++-- .../landingPage/SoftwareProductLandingPageView.jsx | 91 ++++++++++++++++------ .../landingPage/landingPage.test.js | 28 +++++++ 16 files changed, 226 insertions(+), 43 deletions(-) create mode 100644 openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/LicenseType.java diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDescriptionDtoToVspDetails.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDescriptionDtoToVspDetails.java index 634bd90d20..3ab2667821 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDescriptionDtoToVspDetails.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDescriptionDtoToVspDetails.java @@ -20,6 +20,7 @@ package org.openecomp.sdcrests.vsp.rest.mapping; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.LicenseType; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; import org.openecomp.sdc.vendorsoftwareproduct.types.LicensingData; import org.openecomp.sdc.versioning.dao.types.Version; @@ -38,12 +39,15 @@ public class MapVspDescriptionDtoToVspDetails extends MappingBase { target.setVendorName(source.getVendorName()); target.setLicensingVersion( source.getVlmVersion() == null ? null : source.getVlmVersion().getId()); - + if (StringUtils.isNotBlank(source.getLicenseType())) { + target.setLicenseType(LicenseType.valueOf(source.getLicenseType())); + } else if (StringUtils.isNotBlank(target.getLicensingVersion())){ + target.setLicenseType(LicenseType.INTERNAL); + } if (source.getLicenseAgreement() != null || source.getFeatureGroups() != null) { LicensingData licensingData = new LicensingData(); licensingData.setLicenseAgreement(source.getLicenseAgreement()); diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDescriptionDtoToVspDetailsTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDescriptionDtoToVspDetailsTest.java index 9ec43e9226..20a544927e 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDescriptionDtoToVspDetailsTest.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDescriptionDtoToVspDetailsTest.java @@ -17,9 +17,13 @@ package org.openecomp.sdcrests.vsp.rest.mapping; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; -import org.junit.Test; +import java.util.Collections; +import org.junit.jupiter.api.Test; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.LicenseType; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; +import org.openecomp.sdc.vendorsoftwareproduct.types.LicensingData; import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDescriptionDto; /** @@ -65,4 +69,21 @@ public class MapVspDescriptionDtoToVspDetailsTest { assertEquals(vendorName, target.getVendorName()); assertEquals(vendorId, target.getVendorId()); } + + @Test + public void testLicenceTypeMapping() { + final VspDescriptionDto source = new VspDescriptionDto(); + LicensingData licensingData = new LicensingData(); + licensingData.setLicenseAgreement("testLicenseAgreement"); + licensingData.setFeatureGroups(Collections.emptyList()); + source.setLicenseType(LicenseType.EXTERNAL); + source.setLicensingData(licensingData); + + final VspDetails target = new VspDetails(); + final MapVspDescriptionDtoToVspDetails mapper = new MapVspDescriptionDtoToVspDetails(); + mapper.doMapping(source, target); + assertEquals(LicenseType.EXTERNAL.name(), target.getLicenseType()); + assertNull(target.getLicenseAgreement()); + assertNull(target.getFeatureGroups()); + } } diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDetailsToDtoTest.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDetailsToDtoTest.java index d5eb7be0d3..2386328378 100644 --- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDetailsToDtoTest.java +++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/test/java/org/openecomp/sdcrests/vsp/rest/mapping/MapVspDetailsToDtoTest.java @@ -18,9 +18,9 @@ package org.openecomp.sdcrests.vsp.rest.mapping; import static org.junit.Assert.assertEquals; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.LicenseType; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; -import org.openecomp.sdc.vendorsoftwareproduct.types.LicensingData; import org.openecomp.sdc.versioning.dao.types.Version; import org.openecomp.sdcrests.vendorsoftwareproducts.types.VspDetailsDto; @@ -68,6 +68,9 @@ public class MapVspDetailsToDtoTest { final String onboardingMethod = "b46520ac-e62f-4a24-8f40-ee6e65889bfc"; source.setOnboardingMethod(onboardingMethod); + final String licenseType = LicenseType.EXTERNAL.name(); + source.setLicenseType(licenseType); + final VspDetailsDto target = new VspDetailsDto(); final MapVspDetailsToDto mapper = new MapVspDetailsToDto(); mapper.doMapping(source, target); @@ -83,5 +86,6 @@ public class MapVspDetailsToDtoTest { assertEquals(vendorName, target.getVendorName()); assertEquals(vlmVersionId, target.getLicensingVersion()); assertEquals(onboardingMethod, target.getOnboardingMethod()); + assertEquals(LicenseType.EXTERNAL, target.getLicenseType()); } } diff --git a/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 b/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 index 1b64ab7b2c..3cddb5d4e3 100644 --- a/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 +++ b/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 @@ -17,6 +17,7 @@ package org.openecomp.sdcrests.vendorsoftwareproducts.types; import lombok.Data; +import org.openecomp.sdc.vendorsoftwareproduct.dao.type.LicenseType; import org.openecomp.sdc.vendorsoftwareproduct.types.LicensingData; import javax.validation.constraints.NotNull; @@ -37,5 +38,6 @@ public class VspDescriptionDto { @NotNull private String vendorId; // this will be populated with vlm id private String licensingVersion; // this will be populated with vlm version + private LicenseType licenseType; private LicensingData licensingData; } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/LicenseType.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/LicenseType.java new file mode 100644 index 0000000000..35dfda4568 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/LicenseType.java @@ -0,0 +1,27 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2021 Nokia. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + + +package org.openecomp.sdc.vendorsoftwareproduct.dao.type; + +public enum LicenseType { + EXTERNAL, + INTERNAL +} diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspDetails.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspDetails.java index 14e6bf52cf..8f4aed8c71 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspDetails.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/VspDetails.java @@ -44,6 +44,7 @@ public class VspDetails implements VersionableEntity { private String vendorName; private String vendorId; private Version vlmVersion; + private String licenseType; private String licenseAgreement; private List featureGroups; private String onboardingMethod; diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VendorSoftwareProductInfoDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VendorSoftwareProductInfoDaoZusammenImpl.java index e1be8b9dec..de42344788 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VendorSoftwareProductInfoDaoZusammenImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/VendorSoftwareProductInfoDaoZusammenImpl.java @@ -251,6 +251,8 @@ public class VendorSoftwareProductInfoDaoZusammenImpl implements VendorSoftwareP info.addProperty(InfoPropertyName.VENDOR_VERSION.getValue(), vspDetails.getVlmVersion().getId()); } + info.addProperty(InfoPropertyName.LICENSE_TYPE.getValue(), + vspDetails.getLicenseType()); info.addProperty(InfoPropertyName.LICENSE_AGREEMENT.getValue(), vspDetails.getLicenseAgreement()); info.addProperty(InfoPropertyName.FEATURE_GROUPS.getValue(), vspDetails.getFeatureGroups()); @@ -267,6 +269,7 @@ public class VendorSoftwareProductInfoDaoZusammenImpl implements VendorSoftwareP VENDOR_ID("vendorId"), VENDOR_NAME("vendorName"), VENDOR_VERSION("vendorVersion"), + LICENSE_TYPE("licenseType"), LICENSE_AGREEMENT("licenseAgreement"), FEATURE_GROUPS("featureGroups"), ON_BOARDING_METHOD("onboardingMethod"); diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToVSPGeneralConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToVSPGeneralConvertor.java index 8c631675da..d8bb1798ff 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToVSPGeneralConvertor.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/zusammen/convertor/ElementToVSPGeneralConvertor.java @@ -84,6 +84,8 @@ public class ElementToVSPGeneralConvertor extends ElementConvertor { VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.VENDOR_VERSION.getValue()))); } + vspDetails.setLicenseType(info.getProperty( + VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.LICENSE_TYPE.getValue())); vspDetails.setLicenseAgreement(info.getProperty( VendorSoftwareProductInfoDaoZusammenImpl.InfoPropertyName.LICENSE_AGREEMENT.getValue())); vspDetails.setFeatureGroups(info.getProperty( diff --git a/openecomp-ui/resources/scss/modules/_softwareProductLandingPage.scss b/openecomp-ui/resources/scss/modules/_softwareProductLandingPage.scss index 8f0803f6d0..a0620b3639 100644 --- a/openecomp-ui/resources/scss/modules/_softwareProductLandingPage.scss +++ b/openecomp-ui/resources/scss/modules/_softwareProductLandingPage.scss @@ -97,7 +97,7 @@ margin-right: 0; } .software-product-landing-view-top-block-col-upl { - height: 215px; + height: 225px; width: initial; } } @@ -132,7 +132,7 @@ } border: 1px solid $light-gray; padding: 20px 18px 0 18px; - height: 215px; + height: 225px; display: flex; justify-content: space-between; background-color: $white; @@ -161,7 +161,7 @@ .software-product-landing-view-top-block-col-upl { @extend .flex; - height: 215px; + height: 225px; text-align: center; flex-direction: column; justify-content: center; @@ -219,6 +219,10 @@ } } } + .licenceLabel { + float: right; + margin-left: 5px; + } } .vsp-details-page { diff --git a/openecomp-ui/src/nfvo-utils/i18n/en.json b/openecomp-ui/src/nfvo-utils/i18n/en.json index 5b2d09a6ad..786fe16313 100644 --- a/openecomp-ui/src/nfvo-utils/i18n/en.json +++ b/openecomp-ui/src/nfvo-utils/i18n/en.json @@ -194,6 +194,8 @@ "Select file": "Select file", "Software Product Details": "Software Product Details", "Missing": "Missing", + "Internal license": "Internal", + "External license": "External", "Filter Networks": "Filter Networks", "DHCP": "DHCP", "YES": "YES", diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js index a067fd4765..02e5a24f3b 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js @@ -134,6 +134,7 @@ function putSoftwareProduct({ softwareProduct, version }) { ? softwareProduct.licensingVersion : undefined, icon: softwareProduct.icon, + licenseType: softwareProduct.licenseType, licensingData: getLicensingData(softwareProduct.licensingData) } ); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/details/SoftwareProductDetailsView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/details/SoftwareProductDetailsView.jsx index dbc04d0e87..06ecf6b773 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/details/SoftwareProductDetailsView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/details/SoftwareProductDetailsView.jsx @@ -204,7 +204,8 @@ class LicensesSection extends React.Component { onLicensingDataChanged: PropTypes.func.isRequired, featureGroupsList: PropTypes.array, licenseAgreementList: PropTypes.array, - isVendorArchived: PropTypes.bool + isVendorArchived: PropTypes.bool, + licenseType: PropTypes.string }; onVendorParamChanged(e) { @@ -234,7 +235,10 @@ class LicensesSection extends React.Component { onChange={e => this.onVendorParamChanged(e)} value={this.props.licensingVersion || ''} label={i18n('Licensing Version')} - disabled={this.props.isVendorArchived} + disabled={ + this.props.isVendorArchived || + this.props.licenseType !== 'internal' + } type="select"> {this.props.licensingVersionsList.map(version => (