1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.sys.document.datadictionary;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21 import org.apache.commons.lang.StringUtils;
22 import org.kuali.ole.sys.businessobject.AccountingLine;
23 import org.kuali.ole.sys.document.web.AccountingLineViewColumns;
24 import org.kuali.ole.sys.document.web.AccountingLineViewField;
25 import org.kuali.ole.sys.document.web.AccountingLineViewLineFillingElement;
26 import org.kuali.ole.sys.document.web.TableJoining;
27 import org.kuali.rice.krad.datadictionary.DataDictionaryDefinitionBase;
28 import org.kuali.rice.krad.datadictionary.exception.AttributeValidationException;
29
30
31
32
33 public class AccountingLineViewColumnsDefinition extends DataDictionaryDefinitionBase implements AccountingLineViewLineFillingDefinition {
34 private int columnCount = 1;
35 private List<AccountingLineViewFieldDefinition> fields;
36 private String name;
37
38
39
40
41
42 public TableJoining createLayoutElement(Class<? extends AccountingLine> accountingLineClass) {
43 List<AccountingLineViewField> layoutFields = new ArrayList<AccountingLineViewField>();
44
45 for (AccountingLineViewFieldDefinition fieldDefinition : fields) {
46 final AccountingLineViewField field = (AccountingLineViewField)fieldDefinition.createLayoutElement(accountingLineClass);
47 if (field != null) {
48 layoutFields.add(field);
49 }
50 }
51
52 return new AccountingLineViewColumns(this, layoutFields);
53 }
54
55
56
57
58 public AccountingLineViewLineFillingElement createLineFillingLayoutElement(Class<? extends AccountingLine> accountingLineClass) {
59 return (AccountingLineViewLineFillingElement)createLayoutElement(accountingLineClass);
60 }
61
62
63
64
65
66 public void completeValidation(Class rootBusinessObjectClass, Class otherBusinessObjectClass) {
67 if (StringUtils.isBlank(name)) {
68 throw new AttributeValidationException("name for "+rootBusinessObjectClass.getName()+" accounting line view columns definition must be defined");
69 }
70 if (columnCount < 1) {
71 throw new AttributeValidationException("columnCount for "+rootBusinessObjectClass.getName()+" accounting line view columns data dictionary definition must be one or greater");
72 }
73 if (fields == null || fields.size() == 0) {
74 throw new AttributeValidationException("Please add at least one field to the "+rootBusinessObjectClass.getName()+" accounting line view columns definition");
75 }
76 }
77
78
79
80
81
82 public int getColumnCount() {
83 return columnCount;
84 }
85
86
87
88
89
90 public void setColumnCount(int columnCount) {
91 this.columnCount = columnCount;
92 }
93
94
95
96
97
98 public List<AccountingLineViewFieldDefinition> getFields() {
99 return fields;
100 }
101
102
103
104
105
106 public void setFields(List<AccountingLineViewFieldDefinition> fields) {
107 this.fields = fields;
108 }
109
110
111
112
113
114 public String getName() {
115 return name;
116 }
117
118
119
120
121
122 public void setName(String name) {
123 this.name = name;
124 }
125
126 }