summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-healing-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-healing-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-healing-lib')
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/resources/entityHealingConfiguration.json3
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ManufacturerReferenceNumberHealer.java106
2 files changed, 109 insertions, 0 deletions
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/resources/entityHealingConfiguration.json b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/resources/entityHealingConfiguration.json
index d8f6986a73..a70c4afc6b 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/resources/entityHealingConfiguration.json
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/resources/entityHealingConfiguration.json
@@ -12,6 +12,9 @@
"vlm": {
"structure": [
"org.openecomp.sdc.healing.healers.OwnerHealer"
+ ],
+ "data": [
+ "org.openecomp.sdc.healing.healers.ManufacturerReferenceNumberHealer"
]
}
} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ManufacturerReferenceNumberHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ManufacturerReferenceNumberHealer.java
new file mode 100644
index 0000000000..237e4bf55b
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ManufacturerReferenceNumberHealer.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * 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.
+ */
+
+package org.openecomp.sdc.healing.healers;
+
+import org.openecomp.sdc.healing.interfaces.Healer;
+import org.openecomp.sdc.vendorlicense.dao.FeatureGroupDao;
+import org.openecomp.sdc.vendorlicense.dao.FeatureGroupDaoFactory;
+import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
+import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity;
+import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
+import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
+import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacadeFactory;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+import java.util.Collection;
+import java.util.Objects;
+import java.util.Set;
+
+public class ManufacturerReferenceNumberHealer implements Healer {
+
+ private static final String manufacturerReferenceNumber = "MRN";
+ private VendorLicenseFacade vendorLicenseFacade = VendorLicenseFacadeFactory.getInstance()
+ .createInterface();
+ private static final FeatureGroupDao featureGroupDao =
+ FeatureGroupDaoFactory.getInstance().createInterface();
+
+ @Override
+ public boolean isHealingNeeded(String itemId, Version version) {
+ return Objects.isNull(vendorLicenseFacade.listEntitlementPools
+ (itemId, version).iterator().next().getManufacturerReferenceNumber()) ? true :
+ false;
+ }
+
+ @Override
+ public void heal(String itemId, Version version) throws Exception {
+
+ healEntitlementPools(itemId, version);
+ healLicenseKeyGroups(itemId, version);
+ healFeatureGroups(itemId, version);
+ }
+
+ private void healEntitlementPools(String itemId, Version version) {
+ Collection<EntitlementPoolEntity> entitlementPoolEntities = vendorLicenseFacade
+ .listEntitlementPools(itemId, version);
+
+ for (EntitlementPoolEntity entitlementPoolEntity : entitlementPoolEntities) {
+ Set<String> referencingFeatureGroup = entitlementPoolEntity.getReferencingFeatureGroups();
+
+ if (referencingFeatureGroup.size() == 1) {
+ entitlementPoolEntity.setManufacturerReferenceNumber(getMRN(itemId, version,
+ referencingFeatureGroup));
+ } else {
+ entitlementPoolEntity.setManufacturerReferenceNumber(manufacturerReferenceNumber);
+ }
+ vendorLicenseFacade.updateEntitlementPool(entitlementPoolEntity);
+ }
+ }
+
+ private void healLicenseKeyGroups(String itemId, Version version) {
+ Collection<LicenseKeyGroupEntity> licenseKeyGroupEntities = vendorLicenseFacade
+ .listLicenseKeyGroups(itemId, version);
+
+ for (LicenseKeyGroupEntity licenseKeyGroupEntity : licenseKeyGroupEntities) {
+ Set<String> referencingFeatureGroup = licenseKeyGroupEntity.getReferencingFeatureGroups();
+ if (referencingFeatureGroup.size() == 1) {
+ licenseKeyGroupEntity.setManufacturerReferenceNumber(getMRN(itemId, version,
+ referencingFeatureGroup));
+ } else {
+ licenseKeyGroupEntity.setManufacturerReferenceNumber(manufacturerReferenceNumber);
+ }
+ vendorLicenseFacade.updateLicenseKeyGroup(licenseKeyGroupEntity);
+ }
+ }
+
+ private String getMRN(String itemId, Version
+ version, Set<String> referencingFeatureGroup) {
+ FeatureGroupEntity featureGroupEntity = vendorLicenseFacade.getFeatureGroup(new
+ FeatureGroupEntity(itemId, version, referencingFeatureGroup.iterator().next()));
+ return featureGroupEntity.getManufacturerReferenceNumber();
+ }
+
+ private void healFeatureGroups(String itemId, Version version) {
+
+ Collection<FeatureGroupEntity> featureGroupEntities = vendorLicenseFacade.listFeatureGroups
+ (itemId, version);
+
+ for (FeatureGroupEntity featureGroupEntity : featureGroupEntities) {
+ featureGroupEntity.setManufacturerReferenceNumber("");
+ featureGroupDao.update(featureGroupEntity);
+ }
+ }
+}