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()) {