aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-vendor-license-lib
diff options
context:
space:
mode:
authorshrikantawachar <shrikant.awachar@amdocs.com>2018-07-09 18:53:28 +0530
committerOren Kleks <orenkle@amdocs.com>2018-07-10 07:43:39 +0000
commit47db64bab2f9555e9e2c7da243d6e0ddcbda4fd8 (patch)
treee53f8572db14b5f4de44ace7a2b4a86e4282b39d /openecomp-be/lib/openecomp-sdc-vendor-license-lib
parentb781a6d5303945f23b995b7c24d11fe7d44624a4 (diff)
Enhance MRN in EP & LKG
Enhance MRN in EP & LKG , handling healing , unit tests Change-Id: I60b9ec73bfcdd9a53aa507c6401deab372fdcf58 Issue-ID: SDC-1485 Signed-off-by: shrikantawachar <shrikant.awachar@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-vendor-license-lib')
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/EntitlementPoolZusammenDaoImpl.java1
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/LicenseKeyGroupZusammenDaoImpl.java1
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToEntitlementPoolConvertor.java1
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToLicenseKeyGroupConvertor.java1
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/facade/impl/VendorLicenseFacadeImpl.java7
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/VendorLicenseArtifactsServiceImpl.java73
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/FeatureGroupForArtifact.java65
7 files changed, 60 insertions, 89 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/EntitlementPoolZusammenDaoImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/EntitlementPoolZusammenDaoImpl.java
index be073abae5..b3adddb3d2 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/EntitlementPoolZusammenDaoImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/EntitlementPoolZusammenDaoImpl.java
@@ -225,6 +225,7 @@ public class EntitlementPoolZusammenDaoImpl implements EntitlementPoolDao {
info.addProperty("operational_scope", entitlementPool.getOperationalScope());
info.addProperty("startDate", entitlementPool.getStartDate());
info.addProperty("expiryDate", entitlementPool.getExpiryDate());
+ info.addProperty("manufacturerReferenceNumber", entitlementPool.getManufacturerReferenceNumber());
entitlementPoolElement.setInfo(info);
if (entitlementPool.getReferencingFeatureGroups() != null
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/LicenseKeyGroupZusammenDaoImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/LicenseKeyGroupZusammenDaoImpl.java
index d302ab49b5..1b458f3a47 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/LicenseKeyGroupZusammenDaoImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/LicenseKeyGroupZusammenDaoImpl.java
@@ -209,6 +209,7 @@ public class LicenseKeyGroupZusammenDaoImpl implements LicenseKeyGroupDao {
info.addProperty("thresholdValue", licenseKeyGroup.getThresholdValue());
info.addProperty("thresholdUnits", licenseKeyGroup.getThresholdUnits());
info.addProperty("increments", licenseKeyGroup.getIncrements());
+ info.addProperty("manufacturerReferenceNumber", licenseKeyGroup.getManufacturerReferenceNumber());
lkgElement.setInfo(info);
if (licenseKeyGroup.getReferencingFeatureGroups() != null
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToEntitlementPoolConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToEntitlementPoolConvertor.java
index 75fc6f2605..c7895456ad 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToEntitlementPoolConvertor.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToEntitlementPoolConvertor.java
@@ -68,6 +68,7 @@ public class ElementToEntitlementPoolConvertor extends ElementConvertor {
getOperationalScopeMultiChoiceOrOther(info.getProperty("operational_scope")));
entitlementPool.setStartDate(info.getProperty("startDate"));
entitlementPool.setExpiryDate(info.getProperty("expiryDate"));
+ entitlementPool.setManufacturerReferenceNumber(info.getProperty("manufacturerReferenceNumber"));
}
private void mapRelationsToEntitlementPoolEntity(EntitlementPoolEntity entitlementPool,
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToLicenseKeyGroupConvertor.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToLicenseKeyGroupConvertor.java
index 5956c3e6f1..2627798514 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToLicenseKeyGroupConvertor.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/dao/impl/zusammen/convertor/ElementToLicenseKeyGroupConvertor.java
@@ -77,6 +77,7 @@ public class ElementToLicenseKeyGroupConvertor extends ElementConvertor {
licenseKeyGroup.setThresholdValue(toInteger(info.getProperty("thresholdValue")));
licenseKeyGroup.setIncrements(info.getProperty("increments"));
+ licenseKeyGroup.setManufacturerReferenceNumber(info.getProperty("manufacturerReferenceNumber"));
}
private void mapRelationsToLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup,
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/facade/impl/VendorLicenseFacadeImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/facade/impl/VendorLicenseFacadeImpl.java
index 633de716b7..576cb639c7 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/facade/impl/VendorLicenseFacadeImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/facade/impl/VendorLicenseFacadeImpl.java
@@ -26,6 +26,7 @@ import org.openecomp.core.util.UniqueValueUtil;
import org.openecomp.core.utilities.CommonMethods;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.ErrorCode;
+import org.openecomp.sdc.common.togglz.ToggleableFeature;
import org.openecomp.sdc.vendorlicense.VendorLicenseConstants;
import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDao;
import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDaoFactory;
@@ -95,8 +96,10 @@ public class VendorLicenseFacadeImpl implements VendorLicenseFacade {
FeatureGroupEntity retrieved = featureGroupDao.get(featureGroup);
VersioningUtil
.validateEntityExistence(retrieved, featureGroup, VendorLicenseModelEntity.ENTITY_TYPE);
- if (retrieved.getManufacturerReferenceNumber() == null) {
- updateManufacturerNumberInFeatureGroup(retrieved);
+ if (!ToggleableFeature.MRN.isActive()) { //Remove updateManufacturerNumberInFeatureGroup() while removing remove toggle
+ if (retrieved.getManufacturerReferenceNumber() == null) {
+ updateManufacturerNumberInFeatureGroup(retrieved);
+ }
}
return retrieved;
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/VendorLicenseArtifactsServiceImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/VendorLicenseArtifactsServiceImpl.java
index db745a1b42..b9fd403db1 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/VendorLicenseArtifactsServiceImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/VendorLicenseArtifactsServiceImpl.java
@@ -18,6 +18,7 @@ package org.openecomp.sdc.vendorlicense.licenseartifacts.impl;
import org.apache.commons.collections.CollectionUtils;
import org.openecomp.core.utilities.file.FileContentHandler;
+import org.openecomp.sdc.common.togglz.ToggleableFeature;
import org.openecomp.sdc.vendorlicense.HealingServiceFactory;
import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity;
@@ -34,6 +35,7 @@ import org.openecomp.sdc.versioning.dao.types.Version;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
+import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
@@ -63,36 +65,63 @@ public class VendorLicenseArtifactsServiceImpl implements VendorLicenseArtifacts
for (String featureGroupId : featureGroups) {
FeatureGroupModel featureGroupModel = vendorLicenseFacade
.getFeatureGroupModel(new FeatureGroupEntity(vlmId, vlmVersion, featureGroupId));
- Set<EntitlementPoolEntity> entitlementPoolEntities =
- featureGroupModel.getEntitlementPools();
- for (EntitlementPoolEntity entitlementPoolEntity : entitlementPoolEntities) {
- entitlementPoolEntity.setLimits(vendorLicenseFacade.listLimits(vlmId, vlmVersion,
- entitlementPoolEntity.getId()));
- entitlementPoolEntity.setManufacturerReferenceNumber(featureGroupModel.
- getEntityManufacturerReferenceNumber());
- }
- Set<LicenseKeyGroupEntity> licenseKeyGroupEntities =
- featureGroupModel.getLicenseKeyGroups();
- for (LicenseKeyGroupEntity licenseKeyGroupEntity : licenseKeyGroupEntities) {
- licenseKeyGroupEntity.setLimits(vendorLicenseFacade.listLimits(vlmId, vlmVersion,
- licenseKeyGroupEntity.getId()));
- licenseKeyGroupEntity.setManufacturerReferenceNumber(featureGroupModel.
- getEntityManufacturerReferenceNumber());
- }
+ updateEntitlementPools(vlmId, vlmVersion, featureGroupModel);
+ updateLicenseKeyGroupEntities(vlmId, vlmVersion, featureGroupModel);
- featureGroupModel.setEntitlementPools(entitlementPoolEntities.stream().map(
- entitlementPoolEntity -> (EntitlementPoolEntity) healingService
- .heal(entitlementPoolEntity)).collect(Collectors.toSet()));
- featureGroupModel.setLicenseKeyGroups(licenseKeyGroupEntities.stream().map(
- licenseKeyGroupEntity -> (LicenseKeyGroupEntity) healingService
- .heal(licenseKeyGroupEntity)).collect(Collectors.toSet()));
artifact.getFeatureGroups().add(featureGroupModel);
}
}
return artifact.toXml().getBytes();
}
+ private static void updateEntitlementPools(String vlmId, Version vlmVersion, FeatureGroupModel featureGroupModel) {
+
+ Set<EntitlementPoolEntity> entitlementPoolEntities =
+ featureGroupModel.getEntitlementPools();
+
+ for (EntitlementPoolEntity entitlementPoolEntity : entitlementPoolEntities) {
+ entitlementPoolEntity.setLimits(vendorLicenseFacade.listLimits(vlmId, vlmVersion,
+ entitlementPoolEntity.getId()));
+ String manuFacturerReferenceNumber = featureGroupModel.getEntityManufacturerReferenceNumber();
+ if (ToggleableFeature.MRN.isActive()) {
+ if (Objects.nonNull(manuFacturerReferenceNumber)
+ && !manuFacturerReferenceNumber.trim().isEmpty()) {
+ entitlementPoolEntity.setManufacturerReferenceNumber(manuFacturerReferenceNumber);
+ }
+ } else {
+ entitlementPoolEntity.setManufacturerReferenceNumber(manuFacturerReferenceNumber);
+ }
+ }
+ featureGroupModel.setEntitlementPools(entitlementPoolEntities.stream().map(
+ entitlementPoolEntity -> (EntitlementPoolEntity) healingService
+ .heal(entitlementPoolEntity)).collect(Collectors.toSet()));
+ }
+
+ private static void updateLicenseKeyGroupEntities(String vlmId, Version vlmVersion, FeatureGroupModel featureGroupModel) {
+
+ Set<LicenseKeyGroupEntity> licenseKeyGroupEntities =
+ featureGroupModel.getLicenseKeyGroups();
+ for (LicenseKeyGroupEntity licenseKeyGroupEntity : licenseKeyGroupEntities) {
+ licenseKeyGroupEntity.setLimits(vendorLicenseFacade.listLimits(vlmId, vlmVersion,
+ licenseKeyGroupEntity.getId()));
+ String manuFacturerReferenceNumber = featureGroupModel.getEntityManufacturerReferenceNumber();
+ if (ToggleableFeature.MRN.isActive()) {
+ if (Objects.nonNull(manuFacturerReferenceNumber)
+ && !manuFacturerReferenceNumber.trim().isEmpty()) {
+ licenseKeyGroupEntity.setManufacturerReferenceNumber(manuFacturerReferenceNumber);
+ }
+ } else {
+ licenseKeyGroupEntity.setManufacturerReferenceNumber(manuFacturerReferenceNumber);
+ }
+ }
+
+ featureGroupModel.setLicenseKeyGroups(licenseKeyGroupEntities.stream().map(
+ licenseKeyGroupEntity -> (LicenseKeyGroupEntity) healingService
+ .heal(licenseKeyGroupEntity)).collect(Collectors.toSet()));
+
+ }
+
private static byte[] createVendorLicenseArtifact(String vlmId, String vendorName) {
VendorLicenseArtifact vendorLicenseArtifact = new VendorLicenseArtifact();
vendorLicenseArtifact.setVendorName(vendorName);
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/FeatureGroupForArtifact.java b/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/FeatureGroupForArtifact.java
deleted file mode 100644
index 61eb474736..0000000000
--- a/openecomp-be/lib/openecomp-sdc-vendor-license-lib/openecomp-sdc-vendor-license-core/src/main/java/org/openecomp/sdc/vendorlicense/licenseartifacts/impl/types/FeatureGroupForArtifact.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.vendorlicense.licenseartifacts.impl.types;
-
-import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
-import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-public class FeatureGroupForArtifact {
- Collection<EntitlementPoolEntity> entitlementPoolEntities = new ArrayList<>();
- Collection<LicenseKeyGroupEntity> licenseKeyGroupEntities = new ArrayList<>();
- private String name;
- private String description;
- private String partNumber;
- private String manufacturerReferenceNumber;
- private String id;
-
- public String getName() {
- return name;
- }
-
- public String getDescription() {
- return description;
- }
-
- public String getPartNumber() {
- return partNumber;
- }
-
- public String getManufacturerReferenceNumber(){
- return manufacturerReferenceNumber;
- }
-
- public String getId() {
- return id;
- }
-
- public Collection<EntitlementPoolEntity> getEntitlementPoolEntities() {
- return entitlementPoolEntities;
- }
-
- public Collection<LicenseKeyGroupEntity> getLicenseKeyGroupEntities() {
- return licenseKeyGroupEntities;
- }
-}