From dd60339b06d252fcb1382aa97ab3d65b37dad021 Mon Sep 17 00:00:00 2001 From: Michael Lando Date: Wed, 12 Jul 2017 00:54:52 +0300 Subject: [sdc] rebase update Change-Id: I8f1fc7150975122dd9f3f4e653b9983064b399a6 Signed-off-by: Michael Lando --- .../zusammen/EntitlementPoolZusammenDaoImpl.java | 16 +++++++++++++-- .../impl/zusammen/FeatureGroupDaoZusammenImpl.java | 8 ++++++++ .../zusammen/LicenseKeyGroupZusammenDaoImpl.java | 24 ++++++++++++++++++---- 3 files changed, 42 insertions(+), 6 deletions(-) (limited to 'openecomp-be/lib/openecomp-sdc-vendor-license-lib') 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 f133aaad9a..ffaf7809c8 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 @@ -73,8 +73,20 @@ public class EntitlementPoolZusammenDaoImpl implements EntitlementPoolDao { SessionContext context = ZusammenUtil.createSessionContext(); Id itemId = new Id(entitlementPool.getVendorLicenseModelId()); - zusammenAdaptor.saveElement(context, new ElementContext(itemId, - VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)), entitlmentpoolElement, + ElementContext elementContext = new ElementContext(itemId, + VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)); + + Optional epFromDb = zusammenAdaptor.getElementInfo(context, elementContext, + new Id(entitlementPool.getId())); + + if (epFromDb.isPresent()) { + if (entitlmentpoolElement.getRelations() == null) { + entitlmentpoolElement.setRelations(new ArrayList<>()); + } + entitlmentpoolElement.getRelations().addAll(epFromDb.get().getRelations()); + } + + zusammenAdaptor.saveElement(context,elementContext, entitlmentpoolElement, String.format("Update entitlement pool with id %s", entitlementPool.getId())); } 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/FeatureGroupDaoZusammenImpl.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/FeatureGroupDaoZusammenImpl.java index 624ffeb05e..6484e83319 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/FeatureGroupDaoZusammenImpl.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/FeatureGroupDaoZusammenImpl.java @@ -204,6 +204,14 @@ public class FeatureGroupDaoZusammenImpl implements FeatureGroupDao { .createRelation(RelationType.FeatureGroupToLicenseKeyGroup, relation)) .collect(Collectors.toList())); + Collection LaRelations = elementInfo.get().getRelations().stream().filter + (rel->rel.getType().equals(RelationType.FeatureGroupToReferencingLicenseAgreement.name())) + .map(rel ->VlmZusammenUtil.createRelation(RelationType + .FeatureGroupToReferencingLicenseAgreement,rel.getEdge2().getElementId().toString())) + .collect(Collectors.toList()); + + featureGroupElement.getRelations().addAll(LaRelations); + zusammenAdaptor .saveElement(context, elementContext, featureGroupElement, "update feature group"); } 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 bf1899cb04..03537a287b 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 @@ -62,14 +62,30 @@ public class LicenseKeyGroupZusammenDaoImpl implements LicenseKeyGroupDao { @Override public void update(LicenseKeyGroupEntity licenseKeyGroup) { - ZusammenElement locenseKeyGroupElement = + ZusammenElement licenseKeyGroupElement = buildLicenseKeyGroupElement(licenseKeyGroup, Action.UPDATE); SessionContext context = ZusammenUtil.createSessionContext(); Id itemId = new Id(licenseKeyGroup.getVendorLicenseModelId()); - zusammenAdaptor.saveElement(context, new ElementContext(itemId, - VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)), - locenseKeyGroupElement, + + ElementContext elementContext = new ElementContext(itemId, + VlmZusammenUtil.getFirstVersionId(context, itemId, zusammenAdaptor)); + + Optional lkgFromDb = zusammenAdaptor.getElementInfo(context, elementContext, + new Id(licenseKeyGroup.getId())); + + if(lkgFromDb.isPresent()) { + + if( licenseKeyGroupElement.getRelations() == null) { + licenseKeyGroupElement.setRelations(new ArrayList<>()); + } + + lkgFromDb.get().getRelations().forEach(relation -> + licenseKeyGroupElement.getRelations().add(relation)); + } + + zusammenAdaptor.saveElement(context, elementContext, + licenseKeyGroupElement, String.format("Update license key group with id %s", licenseKeyGroup.getId())); } -- cgit 1.2.3-korg