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.AccountingLineViewLine;
24 import org.kuali.ole.sys.document.web.AccountingLineViewLineFillingElement;
25 import org.kuali.ole.sys.document.web.RenderableElement;
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 AccountingLineViewLineDefinition extends DataDictionaryDefinitionBase implements AccountingLineViewLineFillingDefinition {
34 private List<? extends AccountingLineViewRenderableElementDefinition> cells;
35 private String elementName;
36
37
38
39
40
41
42 public void completeValidation(Class rootBusinessObjectClass, Class otherBusinessObjectClass) {
43 if (cells == null || cells.size() == 0) {
44 throw new AttributeValidationException("At least one field must be specified to live within an AccountingLineViewLine"+(!StringUtils.isBlank(elementName) ? " ("+elementName+")" : ""));
45 }
46 }
47
48
49
50
51
52 public List<? extends AccountingLineViewRenderableElementDefinition> getFields() {
53 return cells;
54 }
55
56
57
58
59
60 public void setFields(List<? extends AccountingLineViewRenderableElementDefinition> fields) {
61 this.cells = fields;
62 }
63
64
65
66
67
68 public String getElementName() {
69 return elementName;
70 }
71
72
73
74
75
76 public void setElementName(String elementName) {
77 this.elementName = elementName;
78 }
79
80
81
82
83 public TableJoining createLayoutElement(Class<? extends AccountingLine> accountingLineClass) {
84 AccountingLineViewLine line = new AccountingLineViewLine();
85 line.setDefinition(this);
86 line.setElements(getChildrenRenderableElements(accountingLineClass));
87 return line;
88 }
89
90
91
92
93
94
95 protected List<RenderableElement> getChildrenRenderableElements(Class<? extends AccountingLine> accountingLineClass) {
96 List<RenderableElement> elements = new ArrayList<RenderableElement>();
97 for (AccountingLineViewRenderableElementDefinition cellDefinition : cells) {
98 final RenderableElement element = (RenderableElement)cellDefinition.createLayoutElement(accountingLineClass);
99 if (element != null) {
100 elements.add(element);
101 }
102 }
103 return elements;
104 }
105
106
107
108
109 public AccountingLineViewLineFillingElement createLineFillingLayoutElement(Class<? extends AccountingLine> accountingLineClass) {
110 return (AccountingLineViewLineFillingElement)createLayoutElement(accountingLineClass);
111 }
112
113 }