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 org.kuali.ole.sys.businessobject.AccountingLine;
19 import org.kuali.ole.sys.context.SpringContext;
20 import org.kuali.ole.sys.document.service.AccountingLineRenderingService;
21 import org.kuali.ole.sys.document.web.AccountingLineViewDebitCreditAmountLayoutElement;
22 import org.kuali.ole.sys.document.web.TableJoining;
23 import org.kuali.rice.kns.datadictionary.MaintainableFieldDefinition;
24 import org.kuali.rice.kns.service.DataDictionaryService;
25 import org.kuali.rice.kns.util.FieldUtils;
26 import org.kuali.rice.kns.web.ui.Field;
27 import org.kuali.rice.kns.web.ui.FieldBridge;
28
29
30
31
32
33
34
35 public class AccountingLineViewDebitCreditAmountFieldDefinition extends MaintainableFieldDefinition implements AccountingLineViewRenderableElementDefinition {
36 private String newLineDebitAmountProperty = "newSourceLineDebit";
37 private String newLineCreditAmountProperty = "newSourceLineCredit";
38 private String voucherLineHelperProperty = "voucherLineHelper";
39 private boolean useShortLabels = true;
40 private String amountFieldName = "amount";
41
42
43
44
45 public TableJoining createLayoutElement(Class<? extends AccountingLine> accountingLineClass) {
46 AccountingLineViewDebitCreditAmountLayoutElement layoutElement = new AccountingLineViewDebitCreditAmountLayoutElement();
47
48 layoutElement.setDebitAmountField(createFieldForPropertyName(amountFieldName, accountingLineClass));
49 layoutElement.setDebitFieldDefinition(createFieldDefinitionForProperty(amountFieldName));
50
51 layoutElement.setCreditAmountField(createFieldForPropertyName(amountFieldName, accountingLineClass));
52 layoutElement.setCreditFieldDefinition(createFieldDefinitionForProperty(amountFieldName));
53
54 layoutElement.setDefinition(this);
55
56 return layoutElement;
57 }
58
59
60
61
62
63
64
65 protected Field createFieldForPropertyName(String propertyName, Class<? extends AccountingLine> accountingLineClass) {
66 Field realField = FieldUtils.getPropertyField(accountingLineClass, propertyName, false);
67 FieldBridge.setupField(realField, this, null);
68 if (useShortLabels) {
69 org.kuali.rice.krad.datadictionary.BusinessObjectEntry boEntry = SpringContext.getBean(DataDictionaryService.class).getDataDictionary().getBusinessObjectEntry(accountingLineClass.getName());
70 realField.setFieldLabel(boEntry.getAttributeDefinition(propertyName).getShortLabel());
71 }
72 return realField;
73 }
74
75
76
77
78
79
80 protected AccountingLineViewFieldDefinition createFieldDefinitionForProperty(String propertyName) {
81 AccountingLineViewFieldDefinition fieldDefinition = SpringContext.getBean(AccountingLineRenderingService.class).createGenericAccountingLineViewFieldDefinition(this);
82 fieldDefinition.setName(propertyName);
83 return fieldDefinition;
84 }
85
86
87
88
89
90 public String getNewLineCreditAmountProperty() {
91 return newLineCreditAmountProperty;
92 }
93
94
95
96
97
98 public void setNewLineCreditAmountProperty(String newLineCreditAmountProperty) {
99 this.newLineCreditAmountProperty = newLineCreditAmountProperty;
100 }
101
102
103
104
105
106 public String getNewLineDebitAmountProperty() {
107 return newLineDebitAmountProperty;
108 }
109
110
111
112
113
114 public void setNewLineDebitAmountProperty(String newLineDebitAmountProperty) {
115 this.newLineDebitAmountProperty = newLineDebitAmountProperty;
116 }
117
118
119
120
121
122 public String getVoucherLineHelperProperty() {
123 return voucherLineHelperProperty;
124 }
125
126
127
128
129
130 public void setVoucherLineHelperProperty(String voucherLineHelpersProperty) {
131 this.voucherLineHelperProperty = voucherLineHelpersProperty;
132 }
133
134
135
136
137
138 public boolean shouldUseShortLabels() {
139 return useShortLabels;
140 }
141
142
143
144
145
146 public void setUseShortLabels(boolean useShortLabels) {
147 this.useShortLabels = useShortLabels;
148 }
149
150
151
152
153
154 public String getAmountFieldName() {
155 return amountFieldName;
156 }
157
158
159
160
161
162 public void setAmountFieldName(String amountFieldName) {
163 this.amountFieldName = amountFieldName;
164 }
165
166 }