From 57a7d502f44216f08cb394684e7574980d74dcc2 Mon Sep 17 00:00:00 2001 From: "CITE\\spapacharalampous" Date: Fri, 19 Jul 2024 14:09:17 +0300 Subject: [PATCH] fix on plan-new-version --- .../service/plan/PlanServiceImpl.java | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/backend/core/src/main/java/org/opencdmp/service/plan/PlanServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/plan/PlanServiceImpl.java index 31fa61dbc..dc7af9319 100644 --- a/backend/core/src/main/java/org/opencdmp/service/plan/PlanServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/plan/PlanServiceImpl.java @@ -524,20 +524,18 @@ public class PlanServiceImpl implements PlanService { for (SectionEntity section: sections) { if (!this.conventionService.isListNullOrEmpty(section.getDescriptionTemplates())){ for (DescriptionTemplateEntity blueprintDescriptionTemplate: section.getDescriptionTemplates()) { - if (model.getDescriptions().stream().map(NewVersionPlanDescriptionPersist::getBlueprintSectionId).toList().contains(section.getId())){ - PlanDescriptionTemplateEntity existingBlueprintDescriptionTemplateEntity = newPlanDescriptionTemplateEntities.stream().filter(x -> x.getSectionId().equals(section.getId()) && x.getDescriptionTemplateGroupId().equals(blueprintDescriptionTemplate.getDescriptionTemplateGroupId())).findFirst().orElse(null); - if (existingBlueprintDescriptionTemplateEntity == null){ - PlanDescriptionTemplateEntity newTemplate = new PlanDescriptionTemplateEntity(); - newTemplate.setId(UUID.randomUUID()); - newTemplate.setPlanId(newPlan.getId()); - newTemplate.setDescriptionTemplateGroupId(blueprintDescriptionTemplate.getDescriptionTemplateGroupId()); - newTemplate.setSectionId(section.getId()); - newTemplate.setCreatedAt(Instant.now()); - newTemplate.setUpdatedAt(Instant.now()); - newTemplate.setIsActive(IsActive.Active); - this.entityManager.persist(newTemplate); - this.entityManager.flush(); - } + PlanDescriptionTemplateEntity existingBlueprintDescriptionTemplateEntity = newPlanDescriptionTemplateEntities.stream().filter(x -> x.getSectionId().equals(section.getId()) && x.getDescriptionTemplateGroupId().equals(blueprintDescriptionTemplate.getDescriptionTemplateGroupId())).findFirst().orElse(null); + if (existingBlueprintDescriptionTemplateEntity == null){ + PlanDescriptionTemplateEntity newTemplate = new PlanDescriptionTemplateEntity(); + newTemplate.setId(UUID.randomUUID()); + newTemplate.setPlanId(newPlan.getId()); + newTemplate.setDescriptionTemplateGroupId(blueprintDescriptionTemplate.getDescriptionTemplateGroupId()); + newTemplate.setSectionId(section.getId()); + newTemplate.setCreatedAt(Instant.now()); + newTemplate.setUpdatedAt(Instant.now()); + newTemplate.setIsActive(IsActive.Active); + this.entityManager.persist(newTemplate); + this.entityManager.flush(); } } }