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.apache.commons.lang3.StringUtils;
20 import org.openecomp.core.dao.UniqueValueDao;
21 import org.openecomp.core.util.UniqueValueUtil;
22 import org.openecomp.core.utilities.CommonMethods;
23 import org.openecomp.sdc.common.errors.CoreException;
24 import org.openecomp.sdc.common.errors.ErrorCode;
25 import org.openecomp.sdc.vendorlicense.VendorLicenseConstants;
26 import org.openecomp.sdc.vendorlicense.VendorLicenseManager;
27 import org.openecomp.sdc.vendorlicense.dao.EntitlementPoolDao;
28 import org.openecomp.sdc.vendorlicense.dao.FeatureGroupDao;
29 import org.openecomp.sdc.vendorlicense.dao.LicenseAgreementDao;
30 import org.openecomp.sdc.vendorlicense.dao.LicenseKeyGroupDao;
31 import org.openecomp.sdc.vendorlicense.dao.LimitDao;
32 import org.openecomp.sdc.vendorlicense.dao.VendorLicenseModelDao;
33 import org.openecomp.sdc.vendorlicense.dao.types.EntitlementPoolEntity;
34 import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupEntity;
35 import org.openecomp.sdc.vendorlicense.dao.types.FeatureGroupModel;
36 import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity;
37 import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementModel;
38 import org.openecomp.sdc.vendorlicense.dao.types.LicenseKeyGroupEntity;
39 import org.openecomp.sdc.vendorlicense.dao.types.LimitEntity;
40 import org.openecomp.sdc.vendorlicense.dao.types.LimitType;
41 import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity;
42 import org.openecomp.sdc.vendorlicense.errors.InvalidDateErrorBuilder;
43 import org.openecomp.sdc.vendorlicense.errors.LimitErrorBuilder;
44 import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
45 import org.openecomp.sdc.versioning.VersioningUtil;
46 import org.openecomp.sdc.versioning.dao.types.Version;
48 import java.time.LocalDate;
49 import java.time.format.DateTimeFormatter;
50 import java.util.Collection;
51 import java.util.Optional;
54 public class VendorLicenseManagerImpl implements VendorLicenseManager {
55 private UniqueValueUtil uniqueValueUtil;
56 private VendorLicenseFacade vendorLicenseFacade;
57 private VendorLicenseModelDao vendorLicenseModelDao;
58 private LicenseAgreementDao licenseAgreementDao;
59 private FeatureGroupDao featureGroupDao;
60 private EntitlementPoolDao entitlementPoolDao;
61 private LicenseKeyGroupDao licenseKeyGroupDao;
62 private LimitDao limitDao;
64 private static final String EP_POOL_START_TIME = "T00:00:00Z";
65 private static final String EP_POOL_EXPIRY_TIME = "T23:59:59Z";
66 private static final DateTimeFormatter FORMATTER
67 = DateTimeFormatter.ofPattern("MM/dd/yyyy'T'HH:mm:ss'Z'");
68 public VendorLicenseManagerImpl(VendorLicenseFacade vendorLicenseFacade,
69 VendorLicenseModelDao vendorLicenseModelDao,
70 LicenseAgreementDao licenseAgreementDao,
71 FeatureGroupDao featureGroupDao,
72 EntitlementPoolDao entitlementPoolDao,
73 LicenseKeyGroupDao licenseKeyGroupDao,
75 UniqueValueDao uniqueValueDao) {
76 this.vendorLicenseFacade = vendorLicenseFacade;
77 this.vendorLicenseModelDao = vendorLicenseModelDao;
78 this.licenseAgreementDao = licenseAgreementDao;
79 this.featureGroupDao = featureGroupDao;
80 this.entitlementPoolDao = entitlementPoolDao;
81 this.licenseKeyGroupDao = licenseKeyGroupDao;
82 this.limitDao = limitDao;
83 this.uniqueValueUtil = new UniqueValueUtil(uniqueValueDao);
88 public void validate(String vendorLicenseModelId, Version version) {
89 vendorLicenseFacade.validate(vendorLicenseModelId, version);
93 public VendorLicenseModelEntity createVendorLicenseModel(
94 VendorLicenseModelEntity vendorLicenseModelEntity) {
95 vendorLicenseModelDao.create(vendorLicenseModelEntity);
96 return vendorLicenseModelEntity;
100 public void updateVendorLicenseModel(VendorLicenseModelEntity vendorLicenseModelEntity) {
101 VendorLicenseModelEntity retrieved = vendorLicenseModelDao.get(vendorLicenseModelEntity);
102 if (retrieved == null){
103 throw new CoreException((new ErrorCode.ErrorCodeBuilder()
104 .withMessage(String.format("Vlm with id %s and version %s does not exist.",
105 vendorLicenseModelEntity.getId(), vendorLicenseModelEntity.getVersion().getId()))).build());
108 String existingVendorName = retrieved.getVendorName();
110 updateUniqueName(VendorLicenseConstants.UniqueValues.VENDOR_NAME, existingVendorName,
111 vendorLicenseModelEntity.getVendorName());
112 vendorLicenseModelDao.update(vendorLicenseModelEntity);
116 public VendorLicenseModelEntity getVendorLicenseModel(String vlmId, Version version) {
117 return vendorLicenseFacade.getVendorLicenseModel(vlmId, version);
121 public void deleteVendorLicenseModel(String vlmId, Version version) {
122 throw new UnsupportedOperationException(VendorLicenseConstants.UNSUPPORTED_OPERATION_ERROR);
126 public Collection<LicenseAgreementEntity> listLicenseAgreements(String vlmId, Version version) {
127 return licenseAgreementDao.list(new LicenseAgreementEntity(vlmId, version, null));
131 public LicenseAgreementEntity createLicenseAgreement(LicenseAgreementEntity licenseAgreement) {
132 return vendorLicenseFacade.createLicenseAgreement(licenseAgreement);
136 public void updateLicenseAgreement(LicenseAgreementEntity licenseAgreement,
137 Set<String> addedFeatureGroupIds,
138 Set<String> removedFeatureGroupIds) {
139 LicenseAgreementEntity retrieved = licenseAgreementDao.get(licenseAgreement);
141 .validateEntityExistence(retrieved, licenseAgreement, VendorLicenseModelEntity.ENTITY_TYPE);
142 VersioningUtil.validateContainedEntitiesExistence(new FeatureGroupEntity().getEntityType(),
143 removedFeatureGroupIds, retrieved, retrieved.getFeatureGroupIds());
144 VersioningUtil.validateEntitiesExistence(addedFeatureGroupIds,
145 new FeatureGroupEntity(licenseAgreement.getVendorLicenseModelId(),
146 licenseAgreement.getVersion(),
148 featureGroupDao, VendorLicenseModelEntity.ENTITY_TYPE);
150 updateUniqueName(VendorLicenseConstants.UniqueValues.LICENSE_AGREEMENT_NAME,
151 retrieved.getName(), licenseAgreement.getName(), licenseAgreement.getVendorLicenseModelId(),
152 licenseAgreement.getVersion().getId());
153 licenseAgreementDao.updateColumnsAndDeltaFeatureGroupIds(licenseAgreement, addedFeatureGroupIds,
154 removedFeatureGroupIds);
156 addFeatureGroupsToLicenseAgreementRef(addedFeatureGroupIds, licenseAgreement);
157 removeFeatureGroupsToLicenseAgreementRef(removedFeatureGroupIds, licenseAgreement);
161 public LicenseAgreementModel getLicenseAgreementModel(String vlmId, Version version,
162 String licenseAgreementId) {
163 return vendorLicenseFacade.getLicenseAgreementModel(vlmId, version, licenseAgreementId);
167 public void deleteLicenseAgreement(String vlmId, Version version, String licenseAgreementId) {
168 LicenseAgreementEntity input =
169 new LicenseAgreementEntity(vlmId, version, licenseAgreementId);
170 LicenseAgreementEntity retrieved = licenseAgreementDao.get(input);
171 VersioningUtil.validateEntityExistence(retrieved, input, VendorLicenseModelEntity.ENTITY_TYPE);
173 removeFeatureGroupsToLicenseAgreementRef(retrieved.getFeatureGroupIds(), retrieved);
175 licenseAgreementDao.delete(retrieved);
177 deleteUniqueName(VendorLicenseConstants.UniqueValues.LICENSE_AGREEMENT_NAME,
178 retrieved.getVendorLicenseModelId(), retrieved.getVersion().toString(),
179 retrieved.getName());
183 public Collection<FeatureGroupEntity> listFeatureGroups(String vlmId, Version version) {
184 return vendorLicenseFacade.listFeatureGroups(vlmId, version);
188 public FeatureGroupEntity createFeatureGroup(FeatureGroupEntity featureGroup) {
189 return vendorLicenseFacade.createFeatureGroup(featureGroup);
193 public void updateFeatureGroup(FeatureGroupEntity featureGroup,
194 Set<String> addedLicenseKeyGroups,
195 Set<String> removedLicenseKeyGroups,
196 Set<String> addedEntitlementPools,
197 Set<String> removedEntitlementPools) {
198 FeatureGroupEntity retrieved = featureGroupDao.get(featureGroup);
200 .validateEntityExistence(retrieved, featureGroup, VendorLicenseModelEntity.ENTITY_TYPE);
202 VersioningUtil.validateContainedEntitiesExistence(new LicenseKeyGroupEntity().getEntityType(),
203 removedLicenseKeyGroups, retrieved, retrieved.getLicenseKeyGroupIds());
204 VersioningUtil.validateContainedEntitiesExistence(new EntitlementPoolEntity().getEntityType(),
205 removedEntitlementPools, retrieved, retrieved.getEntitlementPoolIds());
207 VersioningUtil.validateEntitiesExistence(addedLicenseKeyGroups,
208 new LicenseKeyGroupEntity(featureGroup.getVendorLicenseModelId(), featureGroup.getVersion(),
210 licenseKeyGroupDao, VendorLicenseModelEntity.ENTITY_TYPE);
211 VersioningUtil.validateEntitiesExistence(addedEntitlementPools,
212 new EntitlementPoolEntity(featureGroup.getVendorLicenseModelId(), featureGroup.getVersion(),
214 entitlementPoolDao, VendorLicenseModelEntity.ENTITY_TYPE);
216 updateUniqueName(VendorLicenseConstants.UniqueValues.FEATURE_GROUP_NAME,
217 retrieved.getName(), featureGroup.getName(), featureGroup.getVendorLicenseModelId(),
218 featureGroup.getVersion().getId());
220 addLicenseKeyGroupsToFeatureGroupsRef(addedLicenseKeyGroups, featureGroup);
221 removeLicenseKeyGroupsToFeatureGroupsRef(removedLicenseKeyGroups, featureGroup);
222 addEntitlementPoolsToFeatureGroupsRef(addedEntitlementPools, featureGroup);
223 removeEntitlementPoolsToFeatureGroupsRef(removedEntitlementPools, featureGroup);
225 featureGroupDao.updateFeatureGroup(featureGroup, addedEntitlementPools, removedEntitlementPools,
226 addedLicenseKeyGroups, removedLicenseKeyGroups);
231 public FeatureGroupModel getFeatureGroupModel(FeatureGroupEntity featureGroup) {
232 return vendorLicenseFacade.getFeatureGroupModel(featureGroup);
236 public void deleteFeatureGroup(FeatureGroupEntity featureGroup) {
237 FeatureGroupEntity retrieved = featureGroupDao.get(featureGroup);
239 .validateEntityExistence(retrieved, featureGroup, VendorLicenseModelEntity.ENTITY_TYPE);
241 removeLicenseKeyGroupsToFeatureGroupsRef(retrieved.getLicenseKeyGroupIds(), featureGroup);
242 removeEntitlementPoolsToFeatureGroupsRef(retrieved.getEntitlementPoolIds(), featureGroup);
244 for (String licenceAgreementId : retrieved.getReferencingLicenseAgreements()) {
245 licenseAgreementDao.removeFeatureGroup(
246 new LicenseAgreementEntity(featureGroup.getVendorLicenseModelId(),
247 featureGroup.getVersion(),
248 licenceAgreementId), featureGroup.getId());
251 featureGroupDao.delete(featureGroup);
253 deleteUniqueName(VendorLicenseConstants.UniqueValues.FEATURE_GROUP_NAME,
254 retrieved.getVendorLicenseModelId(), retrieved.getVersion().toString(),
255 retrieved.getName());
259 public Collection<EntitlementPoolEntity> listEntitlementPools(String vlmId, Version version) {
260 return vendorLicenseFacade.listEntitlementPools(vlmId, version);
264 public EntitlementPoolEntity createEntitlementPool(EntitlementPoolEntity entitlementPool) {
265 entitlementPool.setStartDate(getDate(entitlementPool.getStartDate(), EP_POOL_START_TIME));
266 entitlementPool.setExpiryDate(getDate(entitlementPool.getExpiryDate(), EP_POOL_EXPIRY_TIME));
267 validateCreateDate(entitlementPool.getStartDate(), entitlementPool.getExpiryDate(),
268 entitlementPool.getVendorLicenseModelId());
269 return vendorLicenseFacade.createEntitlementPool(entitlementPool);
272 private String getDate(String date, String poolTime){
273 return date != null ? (!date.trim().isEmpty() ? date + poolTime: null) : null;
276 private void validateCreateDate(String startDate, String expiryDate,
277 String vendorLicenseModelId) {
278 //original logic allows both nulls
279 if(StringUtils.isEmpty(startDate) && StringUtils.isEmpty(expiryDate)){
283 Optional<LocalDate> parsedStartDate = parseLocalDate(startDate);
284 Optional<LocalDate> parsedExpiryDate = parseLocalDate(expiryDate);
285 if (!parsedStartDate.isPresent()) {
286 throw new CoreException(
287 new InvalidDateErrorBuilder(vendorLicenseModelId)
291 if (!parsedExpiryDate.isPresent()
292 && parsedStartDate.get().atStartOfDay().isBefore
293 (LocalDate.now().atStartOfDay())) {
294 throw new CoreException(
295 new InvalidDateErrorBuilder(vendorLicenseModelId)
299 if(parsedExpiryDate.isPresent() && isNotValidatStartAndExpiryDate(parsedStartDate.get(), parsedExpiryDate.get())){
300 throw new CoreException(
301 new InvalidDateErrorBuilder(vendorLicenseModelId)
306 private boolean isNotValidatStartAndExpiryDate(LocalDate parsedStartDate,
307 LocalDate parsedExpiryDate) {
308 return parsedStartDate.atStartOfDay().isBefore(LocalDate.now().atStartOfDay())
309 || parsedExpiryDate.atStartOfDay().isEqual(parsedStartDate.atStartOfDay())
310 || parsedExpiryDate.isBefore(parsedStartDate);
313 private static Optional<LocalDate> parseLocalDate(String date) {
314 if (StringUtils.isEmpty(date)) {
315 return Optional.empty();
318 return Optional.of(LocalDate.parse(date, FORMATTER ));
321 private void validateUpdateDate(String startDate, String expiryDate,
322 String vendorLicenseModelId) {
323 Optional<LocalDate> parsedStartDate = parseLocalDate(startDate);
324 Optional<LocalDate> parsedExpiryDate = parseLocalDate(expiryDate);
326 if (parsedStartDate.isPresent() && parsedExpiryDate.isPresent()
327 && (parsedExpiryDate.get().atStartOfDay()
328 .isEqual(parsedStartDate.get().atStartOfDay())
329 || parsedExpiryDate.get().isBefore(parsedStartDate.get() ))) {
330 throw new CoreException(
331 new InvalidDateErrorBuilder(vendorLicenseModelId)
335 if (startDate == null && expiryDate != null) {
336 throw new CoreException(
337 new InvalidDateErrorBuilder(vendorLicenseModelId)
343 public void updateEntitlementPool(EntitlementPoolEntity entitlementPool) {
344 entitlementPool.setStartDate(getDate(entitlementPool.getStartDate(), EP_POOL_START_TIME));
345 entitlementPool.setExpiryDate(getDate(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);