dmp new version bug fix
This commit is contained in:
parent
24651aa1b0
commit
b1497c108e
|
@ -500,6 +500,35 @@ public class DmpServiceImpl implements DmpService {
|
|||
|
||||
FieldSet fieldSet = new BaseFieldSet(Description._id, BaseFieldSet.asIndexer(Description._descriptionTemplate, DescriptionTemplate._groupId));
|
||||
List<Description> models = this.builderFactory.builder(DescriptionBuilder.class).authorize(AuthorizationFlags.OwnerOrDmpAssociatedOrPermission).build(fieldSet, descriptionEntities);
|
||||
|
||||
if (!oldDmpEntity.getBlueprintId().equals(blueprintEntity.getId())){
|
||||
// add description templates if exists in new blueprint
|
||||
List<SectionEntity> sections = definition.getSections().stream().filter(x -> x.getHasTemplates()).collect(Collectors.toList());
|
||||
if (!this.conventionService.isListNullOrEmpty(sections) && !this.conventionService.isListNullOrEmpty(dmpDescriptionTemplateEntities)){
|
||||
for (SectionEntity section: sections) {
|
||||
if (!this.conventionService.isListNullOrEmpty(section.getDescriptionTemplates())){
|
||||
for (DescriptionTemplateEntity blueprintDescriptionTemplate: section.getDescriptionTemplates()) {
|
||||
if (model.getDescriptions().stream().map(x -> x.getBlueprintSectionId()).collect(Collectors.toList()).contains(section.getId())){
|
||||
DmpDescriptionTemplateEntity existingBlueprintDescriptionTemplateEntity = dmpDescriptionTemplateEntities.stream().filter(x -> x.getSectionId().equals(section.getId()) && x.getDescriptionTemplateGroupId().equals(blueprintDescriptionTemplate.getDescriptionTemplateGroupId())).findFirst().orElse(null);
|
||||
if (existingBlueprintDescriptionTemplateEntity == null){
|
||||
DmpDescriptionTemplateEntity newTemplate = new DmpDescriptionTemplateEntity();
|
||||
newTemplate.setId(UUID.randomUUID());
|
||||
newTemplate.setDmpId(newDmp.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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.conventionService.isListNullOrEmpty(dmpDescriptionTemplateEntities) && !this.conventionService.isListNullOrEmpty(models)){
|
||||
for (NewVersionDmpDescriptionPersist newVersionDmpDescriptionPersist : model.getDescriptions()) {
|
||||
Description description = models.stream().filter(x -> x.getId().equals(newVersionDmpDescriptionPersist.getDescriptionId())).findFirst().orElse(null);
|
||||
|
@ -523,30 +552,6 @@ public class DmpServiceImpl implements DmpService {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!oldDmpEntity.getBlueprintId().equals(blueprintEntity.getId())){
|
||||
// add description templates if exists in new blueprint
|
||||
List<SectionEntity> sections = definition.getSections().stream().filter(x -> x.getHasTemplates()).collect(Collectors.toList());
|
||||
if (!this.conventionService.isListNullOrEmpty(sections)){
|
||||
for (SectionEntity section: sections) {
|
||||
if (!this.conventionService.isListNullOrEmpty(section.getDescriptionTemplates())){
|
||||
for (DescriptionTemplateEntity blueprintDescriptionTemplate: section.getDescriptionTemplates()) {
|
||||
if (model.getDescriptions().stream().map(x -> x.getBlueprintSectionId()).collect(Collectors.toList()).contains(section.getId())){
|
||||
DmpDescriptionTemplateEntity newTemplate = new DmpDescriptionTemplateEntity();
|
||||
newTemplate.setId(UUID.randomUUID());
|
||||
newTemplate.setDmpId(newDmp.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();
|
||||
|
|
Loading…
Reference in New Issue