2 * Copyright © 2016-2017 European Support Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.openecomp.sdc.vendorlicense.impl;
19 import org.openecomp.core.dao.UniqueValueDao;
20 import org.openecomp.core.util.UniqueValueUtil;
21 import org.openecomp.core.utilities.CommonMethods;
22 import org.openecomp.sdc.common.errors.CoreException;
23 import org.openecomp.sdc.common.errors.ErrorCode;
24 import org.openecomp.sdc.vendorlicense.VendorLicenseConstants;
25 import org.openecomp.sdc.vendorlicense.VendorLicenseManager;
26 import org.openecomp.sdc.vendorlicense.dao.*;
27 import org.openecomp.sdc.vendorlicense.dao.types.*;
28 import org.openecomp.sdc.vendorlicense.errors.InvalidDateErrorBuilder;
29 import org.openecomp.sdc.vendorlicense.errors.LimitErrorBuilder;
30 import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
31 import org.openecomp.sdc.versioning.VersioningUtil;
32 import org.openecomp.sdc.versioning.dao.types.Version;
34 import java.time.LocalDate;
35 import java.time.format.DateTimeFormatter;
36 import java.util.Collection;
37 import java.util.Optional;
40 public class VendorLicenseManagerImpl implements VendorLicenseManager {
41 private final UniqueValueUtil uniqueValueUtil;
42 private final VendorLicenseFacade vendorLicenseFacade;
43 private final VendorLicenseModelDao vendorLicenseModelDao;
44 private final LicenseAgreementDao licenseAgreementDao;
45 private final FeatureGroupDao featureGroupDao;
46 private final EntitlementPoolDao entitlementPoolDao;
47 private final LicenseKeyGroupDao licenseKeyGroupDao;
48 private final LimitDao limitDao;
50 private static final String EP_POOL_START_TIME = "T00:00:00Z";
51 private static final String EP_POOL_EXPIRY_TIME = "T23:59:59Z";
52 private static final DateTimeFormatter FORMATTER
53 = DateTimeFormatter.ofPattern("MM/dd/yyyy'T'HH:mm:ss'Z'");
54 public VendorLicenseManagerImpl(VendorLicenseFacade vendorLicenseFacade,
55 VendorLicenseModelDao vendorLicenseModelDao,
56 LicenseAgreementDao licenseAgreementDao,
57 FeatureGroupDao featureGroupDao,
58 EntitlementPoolDao entitlementPoolDao,
59 LicenseKeyGroupDao licenseKeyGroupDao,
61 UniqueValueDao uniqueValueDao) {
62 this.vendorLicenseFacade = vendorLicenseFacade;
63 this.vendorLicenseModelDao = vendorLicenseModelDao;
64 this.licenseAgreementDao = licenseAgreementDao;
65 this.featureGroupDao = featureGroupDao;
66 this.entitlementPoolDao = entitlementPoolDao;
67 this.licenseKeyGroupDao = licenseKeyGroupDao;
68 this.limitDao = limitDao;
69 this.uniqueValueUtil = new UniqueValueUtil(uniqueValueDao);
74 public void validate(String vendorLicenseModelId, Version version) {
75 vendorLicenseFacade.validate(vendorLicenseModelId, version);
79 public VendorLicenseModelEntity createVendorLicenseModel(
80 VendorLicenseModelEntity vendorLicenseModelEntity) {
81 vendorLicenseModelDao.create(vendorLicenseModelEntity);
82 return vendorLicenseModelEntity;
86 public void updateVendorLicenseModel(VendorLicenseModelEntity vendorLicenseModelEntity) {
87 VendorLicenseModelEntity retrieved = vendorLicenseModelDao.get(vendorLicenseModelEntity);
88 if (retrieved == null){
89 throw new CoreException((new ErrorCode.ErrorCodeBuilder()
90 .withMessage(String.format("Vlm with id %s and version %s does not exist.",
91 vendorLicenseModelEntity.getId(), vendorLicenseModelEntity.getVersion().getId()))).build());
94 String existingVendorName = retrieved.getVendorName();
96 updateUniqueName(VendorLicenseConstants.UniqueValues.VENDOR_NAME, existingVendorName,
97 vendorLicenseModelEntity.getVendorName());
98 vendorLicenseModelDao.update(vendorLicenseModelEntity);
102 public VendorLicenseModelEntity getVendorLicenseModel(String vlmId, Version version) {
103 return vendorLicenseFacade.getVendorLicenseModel(vlmId, version);
107 public void deleteVendorLicenseModel(String vlmId, Version version) {
108 throw new UnsupportedOperationException(VendorLicenseConstants.UNSUPPORTED_OPERATION_ERROR);
112 public Collection<LicenseAgreementEntity> listLicenseAgreements(String vlmId, Version version) {
113 return licenseAgreementDao.list(new LicenseAgreementEntity(vlmId, version, null));
117 public LicenseAgreementEntity createLicenseAgreement(LicenseAgreementEntity licenseAgreement) {
118 return vendorLicenseFacade.createLicenseAgreement(licenseAgreement);
122 public void updateLicenseAgreement(LicenseAgreementEntity licenseAgreement,
123 Set<String> addedFeatureGroupIds,
124 Set<String> removedFeatureGroupIds) {
125 LicenseAgreementEntity retrieved = licenseAgreementDao.get(licenseAgreement);
127 .validateEntityExistence(retrieved, licenseAgreement, VendorLicenseModelEntity.ENTITY_TYPE);
128 VersioningUtil.validateContainedEntitiesExistence(new FeatureGroupEntity().getEntityType(),
129 removedFeatureGroupIds, retrieved, retrieved.getFeatureGroupIds());
130 VersioningUtil.validateEntitiesExistence(addedFeatureGroupIds,
131 new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(),
132 licenseAgreement.getVersion(),
134 featureGroupDao, VendorLicenseModelEntity.ENTITY_TYPE);
136 updateUniqueName(VendorLicenseConstants.UniqueValues.LICENSE_AGREEMENT_NAME,
137 retrieved.getName(), licenseAgreement.getName(), licenseAgreement.getVendorLicenseModelId(),
138 licenseAgreement.getVersion().getId());
139 licenseAgreementDao.updateColumnsAndDeltaFeatureGroupIds(licenseAgreement, addedFeatureGroupIds,
140 removedFeatureGroupIds);
142 addFeatureGroupsToLicenseAgreementRef(addedFeatureGroupIds, licenseAgreement);
143 removeFeatureGroupsToLicenseAgreementRef(removedFeatureGroupIds, licenseAgreement);
147 public LicenseAgreementModel getLicenseAgreementModel(String vlmId, Version version,
148 String licenseAgreementId) {
149 return vendorLicenseFacade.getLicenseAgreementModel(vlmId, version, licenseAgreementId);
153 public void deleteLicenseAgreement(String vlmId, Version version, String licenseAgreementId) {
154 LicenseAgreementEntity input =
155 new LicenseAgreementEntity(vlmId, version, licenseAgreementId);
156 LicenseAgreementEntity retrieved = licenseAgreementDao.get(input);
157 VersioningUtil.validateEntityExistence(retrieved, input, VendorLicenseModelEntity.ENTITY_TYPE);
159 removeFeatureGroupsToLicenseAgreementRef(retrieved.getFeatureGroupIds(), retrieved);
161 licenseAgreementDao.delete(retrieved);
163 deleteUniqueName(VendorLicenseConstants.UniqueValues.LICENSE_AGREEMENT_NAME,
164 retrieved.getVendorLicenseModelId(), retrieved.getVersion().toString(),
165 retrieved.getName());
169 public Collection<FeatureGroupEntity> listFeatureGroups(String vlmId, Version version) {
170 return vendorLicenseFacade.listFeatureGroups(vlmId, version);
174 public FeatureGroupEntity createFeatureGroup(FeatureGroupEntity featureGroup) {
175 return vendorLicenseFacade.createFeatureGroup(featureGroup);
179 public void updateFeatureGroup(FeatureGroupEntity featureGroup,
180 Set<String> addedLicenseKeyGroups,
181 Set<String> removedLicenseKeyGroups,
182 Set<String> addedEntitlementPools,
183 Set<String> removedEntitlementPools) {
184 FeatureGroupEntity retrieved = featureGroupDao.get(featureGroup);
186 .validateEntityExistence(retrieved, featureGroup, VendorLicenseModelEntity.ENTITY_TYPE);
188 VersioningUtil.validateContainedEntitiesExistence(new LicenseKeyGroupEntity().getEntityType(),
189 removedLicenseKeyGroups, retrieved, retrieved.getLicenseKeyGroupIds());
190 VersioningUtil.validateContainedEntitiesExistence(new EntitlementPoolEntity().getEntityType(),
191 removedEntitlementPools, retrieved, retrieved.getEntitlementPoolIds());
193 VersioningUtil.validateEntitiesExistence(addedLicenseKeyGroups,
194 new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(), featureGroup.getVersion(),
196 licenseKeyGroupDao, VendorLicenseModelEntity.ENTITY_TYPE);
197 VersioningUtil.validateEntitiesExistence(addedEntitlementPools,
198 new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(), featureGroup.getVersion(),
200 entitlementPoolDao, VendorLicenseModelEntity.ENTITY_TYPE);
202 updateUniqueName(VendorLicenseConstants.UniqueValues.FEATURE_GROUP_NAME,
203 retrieved.getName(), featureGroup.getName(), featureGroup.getVendorLicenseModelId(),
204 featureGroup.getVersion().getId());
206 addLicenseKeyGroupsToFeatureGroupsRef(addedLicenseKeyGroups, featureGroup);
207 removeLicenseKeyGroupsToFeatureGroupsRef(removedLicenseKeyGroups, featureGroup);
208 addEntitlementPoolsToFeatureGroupsRef(addedEntitlementPools, featureGroup);
209 removeEntitlementPoolsToFeatureGroupsRef(removedEntitlementPools, featureGroup);
211 featureGroupDao.updateFeatureGroup(featureGroup, addedEntitlementPools, removedEntitlementPools,
212 addedLicenseKeyGroups, removedLicenseKeyGroups);
217 public FeatureGroupModel getFeatureGroupModel(FeatureGroupEntity featureGroup) {
218 return vendorLicenseFacade.getFeatureGroupModel(featureGroup);
222 public void deleteFeatureGroup(FeatureGroupEntity featureGroup) {
223 FeatureGroupEntity retrieved = featureGroupDao.get(featureGroup);
225 .validateEntityExistence(retrieved, featureGroup, VendorLicenseModelEntity.ENTITY_TYPE);
227 removeLicenseKeyGroupsToFeatureGroupsRef(retrieved.getLicenseKeyGroupIds(), featureGroup);
228 removeEntitlementPoolsToFeatureGroupsRef(retrieved.getEntitlementPoolIds(), featureGroup);
230 for (String licenceAgreementId : retrieved.getReferencingLicenseAgreements()) {
231 licenseAgreementDao.removeFeatureGroup(
232 new LicenseAgreementEntity(featureGroup.getVendorLicenseModelId(),
233 featureGroup.getVersion(),
234 licenceAgreementId), featureGroup.getId());
237 featureGroupDao.delete(featureGroup);
239 deleteUniqueName(VendorLicenseConstants.UniqueValues.FEATURE_GROUP_NAME,
240 retrieved.getVendorLicenseModelId(), retrieved.getVersion().toString(),
241 retrieved.getName());
245 public Collection<EntitlementPoolEntity> listEntitlementPools(String vlmId, Version version) {
246 return vendorLicenseFacade.listEntitlementPools(vlmId, version);
250 public EntitlementPoolEntity createEntitlementPool(EntitlementPoolEntity entitlementPool) {
251 entitlementPool.setStartDate(entitlementPool.getStartDate() != null ? (entitlementPool
252 .getStartDate().trim().length() != 0 ? entitlementPool.getStartDate() + EP_POOL_START_TIME
254 entitlementPool.setExpiryDate(entitlementPool.getExpiryDate() != null ? (entitlementPool
255 .getExpiryDate().trim().length() != 0 ? entitlementPool.getExpiryDate() + EP_POOL_EXPIRY_TIME
258 validateCreateDate(entitlementPool.getStartDate(), entitlementPool.getExpiryDate(),
259 entitlementPool.getVendorLicenseModelId());
260 return vendorLicenseFacade.createEntitlementPool(entitlementPool);
263 private void validateCreateDate(String startDate, String expiryDate,
264 String vendorLicenseModelId) {
265 LocalDate parsedStartDate = parseLocalDate(startDate);
266 LocalDate parsedExpiryDate = parseLocalDate(expiryDate);
269 validateIfStartAndExpiryDateIsNotNull(startDate, expiryDate,
270 vendorLicenseModelId, parsedStartDate, parsedExpiryDate);
272 if (startDate != null && expiryDate == null
273 && parsedStartDate.atStartOfDay().isBefore
274 (LocalDate.now().atStartOfDay())) {
275 throw new CoreException(
276 new InvalidDateErrorBuilder(vendorLicenseModelId)
280 if (startDate == null && expiryDate != null) {
281 throw new CoreException(
282 new InvalidDateErrorBuilder(vendorLicenseModelId)
288 private void validateIfStartAndExpiryDateIsNotNull(String startDate, String expiryDate,
289 String vendorLicenseModelId,
290 LocalDate parsedStartDate,
291 LocalDate parsedExpiryDate) {
292 if (startDate != null && expiryDate != null
293 && isValidatStartAndExpiryDate(parsedStartDate, parsedExpiryDate)) {
294 throw new CoreException(
295 new InvalidDateErrorBuilder(vendorLicenseModelId)
300 private boolean isValidatStartAndExpiryDate(LocalDate parsedStartDate,
301 LocalDate parsedExpiryDate) {
302 return parsedStartDate.atStartOfDay().isBefore(LocalDate.now().atStartOfDay())
303 || parsedExpiryDate.atStartOfDay().isEqual(parsedStartDate.atStartOfDay())
304 || parsedExpiryDate.isBefore(parsedStartDate);
307 private static LocalDate parseLocalDate(String date) {
308 if (date == null || date.isEmpty()) {
312 return LocalDate.parse(date, FORMATTER );
315 private void validateUpdateDate(String startDate, String expiryDate,
316 String vendorLicenseModelId) {
317 LocalDate parsedStartDate = parseLocalDate(startDate);
318 LocalDate parsedExpiryDate = parseLocalDate(expiryDate);
320 if (startDate != null && expiryDate != null
321 && (parsedExpiryDate.atStartOfDay()
322 .isEqual(parsedStartDate.atStartOfDay())
323 || parsedExpiryDate.isBefore(parsedStartDate ))) {
324 throw new CoreException(
325 new InvalidDateErrorBuilder(vendorLicenseModelId)
329 if (startDate == null && expiryDate != null) {
330 throw new CoreException(
331 new InvalidDateErrorBuilder(vendorLicenseModelId)
338 public void updateEntitlementPool(EntitlementPoolEntity entitlementPool) {
339 entitlementPool.setStartDate(entitlementPool.getStartDate() != null ? (entitlementPool
340 .getStartDate().trim().length() != 0 ? entitlementPool.getStartDate() + EP_POOL_START_TIME
342 entitlementPool.setExpiryDate(entitlementPool.getExpiryDate() != null ? (entitlementPool
343 .getExpiryDate().trim().length() != 0 ? entitlementPool.getExpiryDate() + EP_POOL_EXPIRY_TIME
346 validateUpdateDate(entitlementPool.getStartDate(), entitlementPool.getExpiryDate(),
347 entitlementPool.getVendorLicenseModelId());
348 vendorLicenseFacade.updateEntitlementPool(entitlementPool);
352 public EntitlementPoolEntity getEntitlementPool(EntitlementPoolEntity entitlementPool) {
353 EntitlementPoolEntity retrieved = entitlementPoolDao.get(entitlementPool);
355 .validateEntityExistence(retrieved, entitlementPool, VendorLicenseModelEntity.ENTITY_TYPE);
356 DateTimeFormatter targetFormatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
357 if (retrieved.getStartDate() != null) {
358 retrieved.setStartDate(LocalDate.parse(retrieved.getStartDate(), FORMATTER ).format
362 if (retrieved.getExpiryDate() != null) {
363 retrieved.setExpiryDate(LocalDate.parse(retrieved.getExpiryDate(), FORMATTER ).format
370 public void deleteEntitlementPool(EntitlementPoolEntity entitlementPool) {
371 EntitlementPoolEntity retrieved = entitlementPoolDao.get(entitlementPool);
373 .validateEntityExistence(retrieved, entitlementPool, VendorLicenseModelEntity.ENTITY_TYPE);
375 for (String referencingFeatureGroupId : retrieved.getReferencingFeatureGroups()) {
376 featureGroupDao.removeEntitlementPool(
377 new FeatureGroupEntity(entitlementPool.getVendorLicenseModelId(),
378 entitlementPool.getVersion(),
379 referencingFeatureGroupId), entitlementPool.getId());
382 deleteChildLimits(entitlementPool.getVendorLicenseModelId(), entitlementPool.getVersion(),
383 entitlementPool.getId());
385 entitlementPoolDao.delete(entitlementPool);
387 deleteUniqueName(VendorLicenseConstants.UniqueValues.ENTITLEMENT_POOL_NAME,
388 retrieved.getVendorLicenseModelId(), retrieved.getVersion().toString(),
389 retrieved.getName());
392 protected void deleteChildLimits(String vlmId, Version version, String epLkgId) {
393 Optional<Collection<LimitEntity>> limitEntities = Optional.ofNullable(
394 listLimits(vlmId, version, epLkgId));
395 limitEntities.ifPresent(entities -> entities.forEach(this::deleteLimit));
399 public Collection<LicenseKeyGroupEntity> listLicenseKeyGroups(String vlmId, Version version) {
400 return vendorLicenseFacade.listLicenseKeyGroups(vlmId, version);
404 public LicenseKeyGroupEntity createLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup) {
405 licenseKeyGroup.setStartDate(licenseKeyGroup.getStartDate() != null ? (licenseKeyGroup
406 .getStartDate().trim().length() != 0 ? licenseKeyGroup.getStartDate() + EP_POOL_START_TIME
408 licenseKeyGroup.setExpiryDate(licenseKeyGroup.getExpiryDate() != null ? (licenseKeyGroup
409 .getExpiryDate().trim().length() != 0 ? licenseKeyGroup.getExpiryDate() + EP_POOL_EXPIRY_TIME
412 validateCreateDate(licenseKeyGroup.getStartDate(), licenseKeyGroup.getExpiryDate(),
413 licenseKeyGroup.getVendorLicenseModelId());
414 return vendorLicenseFacade.createLicenseKeyGroup(licenseKeyGroup);
418 public void updateLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup) {
419 licenseKeyGroup.setStartDate(licenseKeyGroup.getStartDate() != null ? (licenseKeyGroup
420 .getStartDate().trim().length() != 0 ? licenseKeyGroup.getStartDate() + EP_POOL_START_TIME
422 licenseKeyGroup.setExpiryDate(licenseKeyGroup.getExpiryDate() != null ? (licenseKeyGroup
423 .getExpiryDate().trim().length() != 0 ? licenseKeyGroup.getExpiryDate() + EP_POOL_EXPIRY_TIME
426 validateUpdateDate(licenseKeyGroup.getStartDate(), licenseKeyGroup.getExpiryDate(),
427 licenseKeyGroup.getVendorLicenseModelId());
428 vendorLicenseFacade.updateLicenseKeyGroup(licenseKeyGroup);
432 public LicenseKeyGroupEntity getLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup) {
433 LicenseKeyGroupEntity retrieved = licenseKeyGroupDao.get(licenseKeyGroup);
435 .validateEntityExistence(retrieved, licenseKeyGroup, VendorLicenseModelEntity.ENTITY_TYPE);
440 public void deleteLicenseKeyGroup(LicenseKeyGroupEntity licenseKeyGroup) {
441 LicenseKeyGroupEntity retrieved = licenseKeyGroupDao.get(licenseKeyGroup);
443 .validateEntityExistence(retrieved, licenseKeyGroup, VendorLicenseModelEntity.ENTITY_TYPE);
445 for (String referencingFeatureGroupId : retrieved.getReferencingFeatureGroups()) {
446 featureGroupDao.removeLicenseKeyGroup(
447 new FeatureGroupEntity(licenseKeyGroup.getVendorLicenseModelId(),
448 licenseKeyGroup.getVersion(),
449 referencingFeatureGroupId), licenseKeyGroup.getId());
452 deleteChildLimits(licenseKeyGroup.getVendorLicenseModelId(), licenseKeyGroup.getVersion(),
453 licenseKeyGroup.getId());
455 licenseKeyGroupDao.delete(licenseKeyGroup);
457 deleteUniqueName(VendorLicenseConstants.UniqueValues.LICENSE_KEY_GROUP_NAME,
458 retrieved.getVendorLicenseModelId(), retrieved.getVersion().toString(),
459 retrieved.getName());
463 public LimitEntity createLimit(LimitEntity limit) {
464 validateLimit(limit);
465 LimitEntity createdLimit = vendorLicenseFacade.createLimit(limit);
466 updateParentForLimit(limit);
470 private void validateLimit(LimitEntity limit) {
471 Collection<LimitEntity> limitList =
472 listLimits(limit.getVendorLicenseModelId(), limit.getVersion()
473 , limit.getEpLkgId());
475 if (!isLimitNameUnique(limitList, limit.getName(), limit.getType(), limit.getId())) {
476 final ErrorCode duplicateLimitNameErrorBuilder =
477 LimitErrorBuilder.getDuplicateNameErrorbuilder(limit.getName(), limit.getType().name());
478 throw new CoreException(duplicateLimitNameErrorBuilder);
482 private boolean isLimitNameUnique(Collection<LimitEntity> limitList, String name, LimitType
484 for (LimitEntity limit : limitList) {
485 if (limit.getName().equalsIgnoreCase(name) &&
486 limit.getType().name().equalsIgnoreCase(type.name())) {
487 if (id != null && limit.getId().equals(id)) {
497 public Collection<LimitEntity> listLimits(String vlmId, Version version, String epLkgId) {
498 return vendorLicenseFacade.listLimits(vlmId, version, epLkgId);
502 public void deleteLimit(LimitEntity limitEntity) {
503 if (!isLimitPresent(limitEntity)) {
505 .validateEntityExistence(null, limitEntity, VendorLicenseModelEntity.ENTITY_TYPE);
507 LimitEntity retrieved = limitDao.get(limitEntity);
509 .validateEntityExistence(retrieved, limitEntity, VendorLicenseModelEntity.ENTITY_TYPE);
511 limitDao.delete(limitEntity);
513 updateParentForLimit(limitEntity);
517 public void updateLimit(LimitEntity limit) {
519 validateLimit(limit);
520 LimitEntity retrieved = limitDao.get(limit);
521 if(!retrieved.equals(limit)){
522 vendorLicenseFacade.updateLimit(limit);
523 updateParentForLimit(limit);
527 private boolean isLimitPresent(LimitEntity limit) {
528 return limitDao.isLimitPresent(limit);
532 public LimitEntity getLimit(LimitEntity limitEntity) {
533 if (!isLimitPresent(limitEntity)) {
535 .validateEntityExistence(null, limitEntity, VendorLicenseModelEntity.ENTITY_TYPE);
537 LimitEntity retrieved = limitDao.get(limitEntity);
539 .validateEntityExistence(retrieved, limitEntity, VendorLicenseModelEntity.ENTITY_TYPE);
544 * update Parent of limit (EP/LKG) versionuuid when limit is modified so that limit updates are
545 * captured in VLM XML
547 private void updateParentForLimit(LimitEntity limit) {
548 if ("EntitlementPool".equals(limit.getParent())) {
549 EntitlementPoolEntity entitlementPoolEntity =
550 entitlementPoolDao.get(new EntitlementPoolEntity(limit.getVendorLicenseModelId(),
551 limit.getVersion(), limit.getEpLkgId()));
552 entitlementPoolEntity.setVersionUuId(CommonMethods.nextUuId());
553 entitlementPoolDao.update(entitlementPoolEntity);
556 if ("LicenseKeyGroup".equals(limit.getParent())) {
557 LicenseKeyGroupEntity licenseKeyGroupEntity = licenseKeyGroupDao.get(
558 new LicenseKeyGroupEntity(limit.getVendorLicenseModelId(), limit.getVersion(),
559 limit.getEpLkgId()));
560 licenseKeyGroupEntity.setVersionUuId(CommonMethods.nextUuId());
561 licenseKeyGroupDao.update(licenseKeyGroupEntity);
565 protected void addFeatureGroupsToLicenseAgreementRef(Set<String> featureGroupIds,
566 LicenseAgreementEntity licenseAgreement) {
567 if (featureGroupIds != null) {
568 for (String featureGroupId : featureGroupIds) {
569 featureGroupDao.addReferencingLicenseAgreement(
570 new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(),
571 licenseAgreement.getVersion(), featureGroupId), licenseAgreement.getId());
576 protected void removeFeatureGroupsToLicenseAgreementRef(Set<String> featureGroupIds,
577 LicenseAgreementEntity licenseAgreement) {
578 if (featureGroupIds != null) {
579 for (String featureGroupId : featureGroupIds) {
580 featureGroupDao.removeReferencingLicenseAgreement(
581 new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(),
582 licenseAgreement.getVersion(), featureGroupId), licenseAgreement.getId());
587 protected void addLicenseKeyGroupsToFeatureGroupsRef(Set<String> licenseKeyGroupIds,
588 FeatureGroupEntity featureGroup) {
589 if (licenseKeyGroupIds != null) {
590 for (String licenseKeyGroupId : licenseKeyGroupIds) {
591 licenseKeyGroupDao.addReferencingFeatureGroup(
592 new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(),
593 featureGroup.getVersion(), licenseKeyGroupId), featureGroup.getId());
598 protected void removeLicenseKeyGroupsToFeatureGroupsRef(Set<String> licenseKeyGroupIds,
599 FeatureGroupEntity featureGroup) {
600 if (licenseKeyGroupIds != null) {
601 for (String licenseKeyGroupId : licenseKeyGroupIds) {
602 licenseKeyGroupDao.removeReferencingFeatureGroup(
603 new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(),
604 featureGroup.getVersion(), licenseKeyGroupId), featureGroup.getId());
609 protected void addEntitlementPoolsToFeatureGroupsRef(Set<String> entitlementPoolIds,
610 FeatureGroupEntity featureGroup) {
611 if (entitlementPoolIds != null) {
612 for (String entitlementPoolId : entitlementPoolIds) {
613 entitlementPoolDao.addReferencingFeatureGroup(
614 new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(),
615 featureGroup.getVersion(), entitlementPoolId), featureGroup.getId());
620 protected void removeEntitlementPoolsToFeatureGroupsRef(Set<String> entitlementPoolIds,
621 FeatureGroupEntity featureGroup) {
622 if (entitlementPoolIds != null) {
623 for (String entitlementPoolId : entitlementPoolIds) {
624 entitlementPoolDao.removeReferencingFeatureGroup(
625 new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(),
626 featureGroup.getVersion(), entitlementPoolId), featureGroup.getId());
631 protected void updateUniqueName(String uniqueValueType, String oldName, String newName, String...
634 .updateUniqueValue(uniqueValueType, oldName, newName, context);
637 protected void deleteUniqueName(String uniqueValueType, String... uniqueCombination) {
638 uniqueValueUtil.deleteUniqueValue(uniqueValueType, uniqueCombination);