fixes
This commit is contained in:
parent
9f7878c15f
commit
3d8a654dbd
|
@ -95,10 +95,10 @@ public class UsageLimitServiceImpl implements UsageLimitService {
|
|||
|
||||
this.authorizationService.authorizeForce(Permission.EditUsageLimit);
|
||||
|
||||
List<UsageLimitEntity> existingUsageLimits;
|
||||
try {
|
||||
this.tenantEntityManager.loadExplicitTenantFilters();
|
||||
UsageLimitQuery query = this.queryFactory.query(UsageLimitQuery.class).disableTracking().usageLimitTargetMetrics(model.getTargetMetric()).isActive(IsActive.Active);
|
||||
if (query != null && query.count() > 0) throw new MyValidationException(this.errors.getUsageLimitMetricAlreadyExists().getCode(), this.errors.getUsageLimitMetricAlreadyExists().getMessage());
|
||||
existingUsageLimits = this.queryFactory.query(UsageLimitQuery.class).disableTracking().isActive(IsActive.Active).collectAs((new BaseFieldSet().ensure(UsageLimit._label).ensure(UsageLimit._targetMetric).ensure(UsageLimit._value)));
|
||||
|
||||
} catch (InvalidApplicationException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
|
@ -113,8 +113,11 @@ public class UsageLimitServiceImpl implements UsageLimitService {
|
|||
if (isUpdate) {
|
||||
data = this.entityManager.find(UsageLimitEntity.class, model.getId());
|
||||
if (data == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), UsageLimit.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||
if (!data.getTargetMetric().equals(model.getTargetMetric()) && existingUsageLimits != null && !existingUsageLimits.isEmpty() && existingUsageLimits.stream().filter(x -> x.getTargetMetric().equals(model.getTargetMetric())).findFirst().orElse(null) != null) throw new MyValidationException(this.errors.getUsageLimitMetricAlreadyExists().getCode(), this.errors.getUsageLimitMetricAlreadyExists().getMessage());
|
||||
if (!this.conventionService.hashValue(data.getUpdatedAt()).equals(model.getHash())) throw new MyValidationException(this.errors.getHashConflict().getCode(), this.errors.getHashConflict().getMessage());
|
||||
} else {
|
||||
if (existingUsageLimits != null && !existingUsageLimits.isEmpty() && existingUsageLimits.stream().filter(x -> x.getTargetMetric().equals(model.getTargetMetric())).findFirst().orElse(null) != null) throw new MyValidationException(this.errors.getUsageLimitMetricAlreadyExists().getCode(), this.errors.getUsageLimitMetricAlreadyExists().getMessage());
|
||||
|
||||
data = new UsageLimitEntity();
|
||||
data.setId(UUID.randomUUID());
|
||||
data.setIsActive(IsActive.Active);
|
||||
|
|
|
@ -42,7 +42,7 @@ queue:
|
|||
annotation-entities-touch-topic: annotation.entities.touch
|
||||
annotation-entities-removal-topic: annotation.entities.remove
|
||||
what-you-know-about-me-completed-topic: whatyouknowaboutme.completed
|
||||
accounting-entry-created-topic: accountingentry.created
|
||||
accounting-entry-created-topic: accountingentry.create
|
||||
generate-file-topic: generate.file
|
||||
rabbitmq:
|
||||
enable: true
|
||||
|
|
Loading…
Reference in New Issue