From 55be58d39aabc8d4b2c7e311f54c61a8e763b6f6 Mon Sep 17 00:00:00 2001 From: "CITE\\amentis" Date: Mon, 29 Jul 2024 14:10:02 +0300 Subject: [PATCH] description template clone fix --- .../DescriptionTemplateServiceImpl.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/backend/core/src/main/java/org/opencdmp/service/descriptiontemplate/DescriptionTemplateServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/descriptiontemplate/DescriptionTemplateServiceImpl.java index 8f86e88ad..ee00dbd94 100644 --- a/backend/core/src/main/java/org/opencdmp/service/descriptiontemplate/DescriptionTemplateServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/descriptiontemplate/DescriptionTemplateServiceImpl.java @@ -571,11 +571,10 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic for (Field field: fields) { if (!this.conventionService.isListNullOrEmpty(field.getVisibilityRules())){ field.getVisibilityRules().stream().map(x -> x.getTarget()).collect(Collectors.toList()).forEach(y -> { - visibilityRulesMap.put(y, null); + if (!visibilityRulesMap.containsKey(y)) visibilityRulesMap.put(y, null); }); } } - } if (model.getPages() != null) { for (Page page : model.getPages()) { @@ -625,7 +624,14 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic private void reassignFieldSet(org.opencdmp.model.descriptiontemplate.FieldSet model, Map visibilityRulesMap) { if (model == null) return; - model.setId(UUID.randomUUID().toString()); + + String oldFieldSetId = model.getId(); + if (visibilityRulesMap != null && visibilityRulesMap.containsKey(oldFieldSetId)){ + model.setId(UUID.randomUUID().toString()); + visibilityRulesMap.put(oldFieldSetId, model.getId()); + } else { + model.setId(UUID.randomUUID().toString()); + } if (model.getFields() != null) { for (Field field : model.getFields()) {