fix on plan-new-version
This commit is contained in:
parent
65f868f11f
commit
481b129111
|
@ -479,7 +479,6 @@ public class PlanServiceImpl implements PlanService {
|
||||||
|
|
||||||
this.entityManager.flush();
|
this.entityManager.flush();
|
||||||
|
|
||||||
if (model.getDescriptions() != null){
|
|
||||||
PlanBlueprintEntity blueprintEntity = this.entityManager.find(PlanBlueprintEntity.class, model.getBlueprintId(), true);
|
PlanBlueprintEntity blueprintEntity = this.entityManager.find(PlanBlueprintEntity.class, model.getBlueprintId(), true);
|
||||||
if (blueprintEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getBlueprintId(), PlanBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
if (blueprintEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{model.getBlueprintId(), PlanBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale()));
|
||||||
|
|
||||||
|
@ -491,7 +490,7 @@ public class PlanServiceImpl implements PlanService {
|
||||||
List<Description> models = this.builderFactory.builder(DescriptionBuilder.class).authorize(AuthorizationFlags.AllExceptPublic).build(fieldSet, descriptionEntities);
|
List<Description> models = this.builderFactory.builder(DescriptionBuilder.class).authorize(AuthorizationFlags.AllExceptPublic).build(fieldSet, descriptionEntities);
|
||||||
|
|
||||||
|
|
||||||
if (!this.conventionService.isListNullOrEmpty(models)){
|
if (!this.conventionService.isListNullOrEmpty(models) && !this.conventionService.isListNullOrEmpty(model.getDescriptions())){
|
||||||
for (NewVersionPlanDescriptionPersist newVersionPlanDescriptionPersist : model.getDescriptions()) {
|
for (NewVersionPlanDescriptionPersist newVersionPlanDescriptionPersist : model.getDescriptions()) {
|
||||||
Description description = models.stream().filter(x -> x.getId().equals(newVersionPlanDescriptionPersist.getDescriptionId())).findFirst().orElse(null);
|
Description description = models.stream().filter(x -> x.getId().equals(newVersionPlanDescriptionPersist.getDescriptionId())).findFirst().orElse(null);
|
||||||
if (description != null){
|
if (description != null){
|
||||||
|
@ -520,12 +519,19 @@ public class PlanServiceImpl implements PlanService {
|
||||||
if (!oldPlanEntity.getBlueprintId().equals(blueprintEntity.getId())){
|
if (!oldPlanEntity.getBlueprintId().equals(blueprintEntity.getId())){
|
||||||
// add description templates if exists in new blueprint
|
// add description templates if exists in new blueprint
|
||||||
List<SectionEntity> sections = definition.getSections().stream().filter(SectionEntity::getHasTemplates).collect(Collectors.toList());
|
List<SectionEntity> sections = definition.getSections().stream().filter(SectionEntity::getHasTemplates).collect(Collectors.toList());
|
||||||
if (!this.conventionService.isListNullOrEmpty(sections) && !this.conventionService.isListNullOrEmpty(newPlanDescriptionTemplateEntities)){
|
if (!this.conventionService.isListNullOrEmpty(sections)){
|
||||||
for (SectionEntity section: sections) {
|
for (SectionEntity section: sections) {
|
||||||
if (!this.conventionService.isListNullOrEmpty(section.getDescriptionTemplates())){
|
if (!this.conventionService.isListNullOrEmpty(section.getDescriptionTemplates())){
|
||||||
for (DescriptionTemplateEntity blueprintDescriptionTemplate: section.getDescriptionTemplates()) {
|
for (DescriptionTemplateEntity blueprintDescriptionTemplate: section.getDescriptionTemplates()) {
|
||||||
PlanDescriptionTemplateEntity existingBlueprintDescriptionTemplateEntity = newPlanDescriptionTemplateEntities.stream().filter(x -> x.getSectionId().equals(section.getId()) && x.getDescriptionTemplateGroupId().equals(blueprintDescriptionTemplate.getDescriptionTemplateGroupId())).findFirst().orElse(null);
|
|
||||||
if (existingBlueprintDescriptionTemplateEntity == null){
|
boolean isDescriptionTemplateAlreadyInPlan = false;
|
||||||
|
|
||||||
|
if (!this.conventionService.isListNullOrEmpty(newPlanDescriptionTemplateEntities)) {
|
||||||
|
PlanDescriptionTemplateEntity existingBlueprintDescriptionTemplateEntity = newPlanDescriptionTemplateEntities.stream().filter(x -> x.getSectionId().equals(section.getId()) && x.getDescriptionTemplateGroupId().equals(blueprintDescriptionTemplate.getDescriptionTemplateGroupId())).findFirst().orElse(null);
|
||||||
|
isDescriptionTemplateAlreadyInPlan = existingBlueprintDescriptionTemplateEntity != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isDescriptionTemplateAlreadyInPlan){
|
||||||
PlanDescriptionTemplateEntity newTemplate = new PlanDescriptionTemplateEntity();
|
PlanDescriptionTemplateEntity newTemplate = new PlanDescriptionTemplateEntity();
|
||||||
newTemplate.setId(UUID.randomUUID());
|
newTemplate.setId(UUID.randomUUID());
|
||||||
newTemplate.setPlanId(newPlan.getId());
|
newTemplate.setPlanId(newPlan.getId());
|
||||||
|
@ -557,7 +563,6 @@ public class PlanServiceImpl implements PlanService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
this.entityManager.flush();
|
this.entityManager.flush();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue