remove get all field functions from description template model
This commit is contained in:
parent
5142932165
commit
cc877d8e53
|
@ -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<Field> getAllField(){
|
||||
List<Field> fields = new ArrayList<>();
|
||||
if (this.getPages() != null){
|
||||
for (Page page: this.getPages()) {
|
||||
fields.addAll(page.getAllField());
|
||||
}
|
||||
}
|
||||
return fields;
|
||||
}
|
||||
|
||||
public List<FieldSet> getAllFieldSets(){
|
||||
List<FieldSet> fieldSets = new ArrayList<>();
|
||||
if (this.getPages() != null){
|
||||
for (Page page: this.getPages()) {
|
||||
fieldSets.addAll(page.getAllFieldSets());
|
||||
}
|
||||
}
|
||||
return fieldSets;
|
||||
}
|
||||
|
||||
public List<FieldSet> getFieldSetById(String id) {
|
||||
return this.getAllFieldSets().stream().filter(x-> id.equals(x.getId())).toList();
|
||||
}
|
||||
|
||||
public List<Field> getFieldById(String id) {
|
||||
return this.getAllField().stream().filter(x-> id.equals(x.getId())).toList();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<Field> getAllField() {
|
||||
return this.getFields() == null ? new ArrayList<>() : this.getFields();
|
||||
}
|
||||
|
||||
public List<Field> getFieldById(String id) {
|
||||
return this.getAllField().stream().filter(x-> id.equals(x.getId())).toList();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<Field> getAllField(){
|
||||
List<Field> fields = new ArrayList<>();
|
||||
if (this.getSections() != null){
|
||||
for (Section section: this.getSections()) {
|
||||
fields.addAll(section.getAllField());
|
||||
}
|
||||
}
|
||||
return fields;
|
||||
}
|
||||
|
||||
public List<FieldSet> getAllFieldSets(){
|
||||
List<FieldSet> fieldSets = new ArrayList<>();
|
||||
if (this.getSections() != null){
|
||||
for (Section section: this.getSections()) {
|
||||
fieldSets.addAll(section.getAllFieldSets());
|
||||
}
|
||||
}
|
||||
return fieldSets;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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<FieldSet> fieldSets) {
|
||||
this.fieldSets = fieldSets;
|
||||
}
|
||||
|
||||
public List<Field> getAllField(){
|
||||
List<Field> 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<FieldSet> getAllFieldSets(){
|
||||
List<FieldSet> 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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<String, String> visibilityRulesMap = new HashMap<>();
|
||||
List<Field> fields = model.getAllField();
|
||||
List<Field> 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<Field> getAllFieldByDefinition(Definition definition){
|
||||
List<Field> 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<Field> getAllFieldBySections(List<Section> sections){
|
||||
List<Field> 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
|
||||
|
|
Loading…
Reference in New Issue