description template new version state handle by code
This commit is contained in:
parent
f7efebf295
commit
9a6da41ecd
|
@ -180,7 +180,6 @@ public class DescriptionTemplatePersist {
|
|||
.must(() -> this.lessEqualLength(item.getLabel(), DescriptionTemplateEntity._labelLength))
|
||||
.failOn(DescriptionTemplatePersist._label).failWith(this.messageSource.getMessage("Validation_MaxLength", new Object[]{DescriptionTemplatePersist._label}, LocaleContextHolder.getLocale())),
|
||||
this.spec()
|
||||
.iff(() -> item.getStatus() == DescriptionTemplateStatus.Finalized)
|
||||
.must(() -> !this.isEmpty(item.getCode()))
|
||||
.failOn(DescriptionTemplatePersist._code).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._code}, LocaleContextHolder.getLocale())),
|
||||
this.spec()
|
||||
|
|
|
@ -763,6 +763,13 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
|||
.groupIds(groupId)
|
||||
.count() : 0;
|
||||
|
||||
if (activeDescriptionTemplatesForTheGroup == 0 && !this.conventionService.isNullOrEmpty(importXml.getCode())) {
|
||||
activeDescriptionTemplatesForTheGroup = this.queryFactory.query(DescriptionTemplateQuery.class).disableTracking()
|
||||
.isActive(IsActive.Active)
|
||||
.codes(importXml.getCode())
|
||||
.count();
|
||||
}
|
||||
|
||||
if (activeDescriptionTemplatesForTheGroup == 0) {
|
||||
DescriptionTemplatePersist persist = new DescriptionTemplatePersist();
|
||||
persist.setLabel(label);
|
||||
|
@ -775,12 +782,23 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
|||
this.validatorFactory.validator(DescriptionTemplatePersist.DescriptionTemplatePersistValidator.class).validateForce(persist);
|
||||
return this.persist(persist, groupId, fields);
|
||||
} else {
|
||||
DescriptionTemplateEntity latestVersionDescriptionTemplate = this.queryFactory.query(DescriptionTemplateQuery.class).disableTracking()
|
||||
.versionStatuses(DescriptionTemplateVersionStatus.Current)
|
||||
.isActive(IsActive.Active)
|
||||
.statuses(DescriptionTemplateStatus.Finalized)
|
||||
.groupIds(groupId)
|
||||
.first();
|
||||
DescriptionTemplateEntity latestVersionDescriptionTemplate = null;
|
||||
if (groupId != null) {
|
||||
latestVersionDescriptionTemplate = this.queryFactory.query(DescriptionTemplateQuery.class).disableTracking()
|
||||
.versionStatuses(DescriptionTemplateVersionStatus.Current)
|
||||
.isActive(IsActive.Active)
|
||||
.statuses(DescriptionTemplateStatus.Finalized)
|
||||
.groupIds(groupId)
|
||||
.first();
|
||||
}
|
||||
if (latestVersionDescriptionTemplate == null && !this.conventionService.isNullOrEmpty(importXml.getCode())) {
|
||||
latestVersionDescriptionTemplate = this.queryFactory.query(DescriptionTemplateQuery.class).disableTracking()
|
||||
.versionStatuses(DescriptionTemplateVersionStatus.Current)
|
||||
.isActive(IsActive.Active)
|
||||
.statuses(DescriptionTemplateStatus.Finalized)
|
||||
.codes(importXml.getCode())
|
||||
.first();
|
||||
}
|
||||
if (latestVersionDescriptionTemplate == null) throw new MyValidationException(this.errors.getDescriptionTemplateIsNotFinalized().getCode(), this.errors.getDescriptionTemplateIsNotFinalized().getMessage());
|
||||
|
||||
NewVersionDescriptionTemplatePersist persist = new NewVersionDescriptionTemplatePersist();
|
||||
|
|
Loading…
Reference in New Issue