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))
|
.must(() -> this.lessEqualLength(item.getLabel(), DescriptionTemplateEntity._labelLength))
|
||||||
.failOn(DescriptionTemplatePersist._label).failWith(this.messageSource.getMessage("Validation_MaxLength", new Object[]{DescriptionTemplatePersist._label}, LocaleContextHolder.getLocale())),
|
.failOn(DescriptionTemplatePersist._label).failWith(this.messageSource.getMessage("Validation_MaxLength", new Object[]{DescriptionTemplatePersist._label}, LocaleContextHolder.getLocale())),
|
||||||
this.spec()
|
this.spec()
|
||||||
.iff(() -> item.getStatus() == DescriptionTemplateStatus.Finalized)
|
|
||||||
.must(() -> !this.isEmpty(item.getCode()))
|
.must(() -> !this.isEmpty(item.getCode()))
|
||||||
.failOn(DescriptionTemplatePersist._code).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._code}, LocaleContextHolder.getLocale())),
|
.failOn(DescriptionTemplatePersist._code).failWith(messageSource.getMessage("Validation_Required", new Object[]{DescriptionTemplatePersist._code}, LocaleContextHolder.getLocale())),
|
||||||
this.spec()
|
this.spec()
|
||||||
|
|
|
@ -763,6 +763,13 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
.groupIds(groupId)
|
.groupIds(groupId)
|
||||||
.count() : 0;
|
.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) {
|
if (activeDescriptionTemplatesForTheGroup == 0) {
|
||||||
DescriptionTemplatePersist persist = new DescriptionTemplatePersist();
|
DescriptionTemplatePersist persist = new DescriptionTemplatePersist();
|
||||||
persist.setLabel(label);
|
persist.setLabel(label);
|
||||||
|
@ -775,12 +782,23 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic
|
||||||
this.validatorFactory.validator(DescriptionTemplatePersist.DescriptionTemplatePersistValidator.class).validateForce(persist);
|
this.validatorFactory.validator(DescriptionTemplatePersist.DescriptionTemplatePersistValidator.class).validateForce(persist);
|
||||||
return this.persist(persist, groupId, fields);
|
return this.persist(persist, groupId, fields);
|
||||||
} else {
|
} else {
|
||||||
DescriptionTemplateEntity latestVersionDescriptionTemplate = this.queryFactory.query(DescriptionTemplateQuery.class).disableTracking()
|
DescriptionTemplateEntity latestVersionDescriptionTemplate = null;
|
||||||
|
if (groupId != null) {
|
||||||
|
latestVersionDescriptionTemplate = this.queryFactory.query(DescriptionTemplateQuery.class).disableTracking()
|
||||||
.versionStatuses(DescriptionTemplateVersionStatus.Current)
|
.versionStatuses(DescriptionTemplateVersionStatus.Current)
|
||||||
.isActive(IsActive.Active)
|
.isActive(IsActive.Active)
|
||||||
.statuses(DescriptionTemplateStatus.Finalized)
|
.statuses(DescriptionTemplateStatus.Finalized)
|
||||||
.groupIds(groupId)
|
.groupIds(groupId)
|
||||||
.first();
|
.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());
|
if (latestVersionDescriptionTemplate == null) throw new MyValidationException(this.errors.getDescriptionTemplateIsNotFinalized().getCode(), this.errors.getDescriptionTemplateIsNotFinalized().getMessage());
|
||||||
|
|
||||||
NewVersionDescriptionTemplatePersist persist = new NewVersionDescriptionTemplatePersist();
|
NewVersionDescriptionTemplatePersist persist = new NewVersionDescriptionTemplatePersist();
|
||||||
|
|
Loading…
Reference in New Issue