fix on plan-new-version

This commit is contained in:
CITE\spapacharalampous 2024-07-19 14:09:17 +03:00
parent 0789653fb2
commit 57a7d502f4
1 changed files with 12 additions and 14 deletions

View File

@ -524,20 +524,18 @@ public class PlanServiceImpl implements PlanService {
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()) {
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);
PlanDescriptionTemplateEntity existingBlueprintDescriptionTemplateEntity = newPlanDescriptionTemplateEntities.stream().filter(x -> x.getSectionId().equals(section.getId()) && x.getDescriptionTemplateGroupId().equals(blueprintDescriptionTemplate.getDescriptionTemplateGroupId())).findFirst().orElse(null); if (existingBlueprintDescriptionTemplateEntity == null){
if (existingBlueprintDescriptionTemplateEntity == null){ PlanDescriptionTemplateEntity newTemplate = new PlanDescriptionTemplateEntity();
PlanDescriptionTemplateEntity newTemplate = new PlanDescriptionTemplateEntity(); newTemplate.setId(UUID.randomUUID());
newTemplate.setId(UUID.randomUUID()); newTemplate.setPlanId(newPlan.getId());
newTemplate.setPlanId(newPlan.getId()); newTemplate.setDescriptionTemplateGroupId(blueprintDescriptionTemplate.getDescriptionTemplateGroupId());
newTemplate.setDescriptionTemplateGroupId(blueprintDescriptionTemplate.getDescriptionTemplateGroupId()); newTemplate.setSectionId(section.getId());
newTemplate.setSectionId(section.getId()); newTemplate.setCreatedAt(Instant.now());
newTemplate.setCreatedAt(Instant.now()); newTemplate.setUpdatedAt(Instant.now());
newTemplate.setUpdatedAt(Instant.now()); newTemplate.setIsActive(IsActive.Active);
newTemplate.setIsActive(IsActive.Active); this.entityManager.persist(newTemplate);
this.entityManager.persist(newTemplate); this.entityManager.flush();
this.entityManager.flush();
}
} }
} }
} }