diff --git a/backend/core/src/main/java/org/opencdmp/model/descriptiontemplate/Definition.java b/backend/core/src/main/java/org/opencdmp/model/descriptiontemplate/Definition.java index 426ed846d..2a8f633c8 100644 --- a/backend/core/src/main/java/org/opencdmp/model/descriptiontemplate/Definition.java +++ b/backend/core/src/main/java/org/opencdmp/model/descriptiontemplate/Definition.java @@ -1,6 +1,5 @@ package org.opencdmp.model.descriptiontemplate; -import java.util.ArrayList; import java.util.List; public class Definition { @@ -16,31 +15,4 @@ public class Definition { this.pages = pages; } - public List getAllField(){ - List fields = new ArrayList<>(); - if (this.getPages() != null){ - for (Page page: this.getPages()) { - fields.addAll(page.getAllField()); - } - } - return fields; - } - - public List
getAllFieldSets(){ - List
fieldSets = new ArrayList<>(); - if (this.getPages() != null){ - for (Page page: this.getPages()) { - fieldSets.addAll(page.getAllFieldSets()); - } - } - return fieldSets; - } - - public List
getFieldSetById(String id) { - return this.getAllFieldSets().stream().filter(x-> id.equals(x.getId())).toList(); - } - - public List getFieldById(String id) { - return this.getAllField().stream().filter(x-> id.equals(x.getId())).toList(); - } } diff --git a/backend/core/src/main/java/org/opencdmp/model/descriptiontemplate/FieldSet.java b/backend/core/src/main/java/org/opencdmp/model/descriptiontemplate/FieldSet.java index b80a94efd..c6e130cd3 100644 --- a/backend/core/src/main/java/org/opencdmp/model/descriptiontemplate/FieldSet.java +++ b/backend/core/src/main/java/org/opencdmp/model/descriptiontemplate/FieldSet.java @@ -1,6 +1,5 @@ package org.opencdmp.model.descriptiontemplate; -import java.util.ArrayList; import java.util.List; public class FieldSet { @@ -115,11 +114,4 @@ public class FieldSet { this.fields = fields; } - public List getAllField() { - return this.getFields() == null ? new ArrayList<>() : this.getFields(); - } - - public List getFieldById(String id) { - return this.getAllField().stream().filter(x-> id.equals(x.getId())).toList(); - } } diff --git a/backend/core/src/main/java/org/opencdmp/model/descriptiontemplate/Page.java b/backend/core/src/main/java/org/opencdmp/model/descriptiontemplate/Page.java index cf72f317d..16749abb9 100644 --- a/backend/core/src/main/java/org/opencdmp/model/descriptiontemplate/Page.java +++ b/backend/core/src/main/java/org/opencdmp/model/descriptiontemplate/Page.java @@ -1,7 +1,6 @@ package org.opencdmp.model.descriptiontemplate; -import java.util.ArrayList; import java.util.List; public class Page { @@ -54,25 +53,6 @@ public class Page { this.sections = sections; } - public List getAllField(){ - List fields = new ArrayList<>(); - if (this.getSections() != null){ - for (Section section: this.getSections()) { - fields.addAll(section.getAllField()); - } - } - return fields; - } - - public List
getAllFieldSets(){ - List
fieldSets = new ArrayList<>(); - if (this.getSections() != null){ - for (Section section: this.getSections()) { - fieldSets.addAll(section.getAllFieldSets()); - } - } - return fieldSets; - } } diff --git a/backend/core/src/main/java/org/opencdmp/model/descriptiontemplate/Section.java b/backend/core/src/main/java/org/opencdmp/model/descriptiontemplate/Section.java index 62ae2f60c..0613040d6 100644 --- a/backend/core/src/main/java/org/opencdmp/model/descriptiontemplate/Section.java +++ b/backend/core/src/main/java/org/opencdmp/model/descriptiontemplate/Section.java @@ -1,7 +1,6 @@ package org.opencdmp.model.descriptiontemplate; -import java.util.ArrayList; import java.util.List; public class Section { @@ -82,34 +81,6 @@ public class Section { public void setFieldSets(List
fieldSets) { this.fieldSets = fieldSets; } - - public List getAllField(){ - List fields = new ArrayList<>(); - if (this.getFieldSets() != null){ - for (FieldSet fieldSet: this.getFieldSets()) { - fields.addAll(fieldSet.getAllField()); - } - } - if (this.getSections() != null){ - for (Section sectionEntity: this.getSections()) { - fields.addAll(sectionEntity.getAllField()); - } - } - return fields; - } - - public List
getAllFieldSets(){ - List
fieldSet = new ArrayList<>(); - if (this.getFieldSets() != null){ - fieldSet.addAll(this.getFieldSets()); - } - if (this.getSections() != null){ - for (Section section: this.getSections()) { - fieldSet.addAll(section.getAllFieldSets()); - } - } - return fieldSet; - } } 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 db19c37b5..cb4010e0f 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 @@ -55,7 +55,6 @@ import org.opencdmp.model.persist.descriptiontemplatedefinition.fielddata.BaseFi import org.opencdmp.model.user.User; import org.opencdmp.query.DescriptionTemplateQuery; import org.opencdmp.query.DescriptionTemplateTypeQuery; -import org.opencdmp.query.ReferenceTypeQuery; import org.opencdmp.query.UserDescriptionTemplateQuery; import org.opencdmp.service.accounting.AccountingService; import org.opencdmp.service.descriptiontemplatetype.DescriptionTemplateTypeService; @@ -558,7 +557,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic return; Map visibilityRulesMap = new HashMap<>(); - List fields = model.getAllField(); + List fields = this.getAllFieldByDefinition(model); if (!this.conventionService.isListNullOrEmpty(fields)){ for (Field field: fields) { if (!this.conventionService.isListNullOrEmpty(field.getVisibilityRules())){ @@ -575,7 +574,7 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic } } - for (Field field: model.getAllField()) { + for (Field field: this.getAllFieldByDefinition(model)) { if (!this.conventionService.isListNullOrEmpty(field.getVisibilityRules())){ for (Rule rule: field.getVisibilityRules()) { if (visibilityRulesMap.containsKey(rule.getTarget())) rule.setTarget(visibilityRulesMap.get(rule.getTarget())); @@ -638,6 +637,36 @@ public class DescriptionTemplateServiceImpl implements DescriptionTemplateServic } } + private List getAllFieldByDefinition(Definition definition){ + List fields = new ArrayList<>(); + if (definition == null) return fields; + + if (definition.getPages() != null){ + for (Page page: definition.getPages()) { + fields.addAll(this.getAllFieldBySections(page.getSections())); + } + } + return fields; + } + + + private List getAllFieldBySections(List
sections){ + List fields = new ArrayList<>(); + + if (sections != null){ + for (Section section: sections) { + if (section.getSections() != null) fields.addAll(this.getAllFieldBySections(section.getSections())); + if (section.getFieldSets() != null) { + for (org.opencdmp.model.descriptiontemplate.FieldSet fieldSet: section.getFieldSets()) { + fields.addAll(fieldSet.getFields()); + } + } + + } + } + return fields; + } + //endregion //region NewVersion