1 /*
2 * Copyright 2008 The Kuali Foundation
3 *
4 * Licensed under the Educational Community License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/ecl2.php
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.kuali.ole.sys.document.datadictionary;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.ole.sys.document.web.renderers.GroupTotalRenderer;
20 import org.kuali.ole.sys.document.web.renderers.Renderer;
21 import org.kuali.rice.krad.datadictionary.exception.AttributeValidationException;
22
23 /**
24 * The definition of an accounting line group total renderer, which will display an accounting line
25 * group total as a standard "Total: " + amount.
26 */
27 public class AccountingLineGroupTotalDefinition extends TotalDefinition{
28 private String totalProperty;
29 private String representedProperty;
30 private boolean nestedProperty;
31 private String containingPropertyName;
32 private String totalLabelProperty = "accounting.line.group.total.label";
33
34 /**
35 * Gets the totalProperty attribute.
36 * @return Returns the totalProperty.
37 */
38 public String getTotalProperty() {
39 return totalProperty;
40 }
41
42 /**
43 * Sets the totalProperty attribute value.
44 * @param totalProperty The totalProperty to set.
45 */
46 public void setTotalProperty(String totalProperty) {
47 this.totalProperty = totalProperty;
48 }
49
50 /**
51 * Gets the totalLabelProperty attribute.
52 * @return Returns the totalLabelProperty.
53 */
54 public String getTotalLabelProperty() {
55 return totalLabelProperty;
56 }
57
58 /**
59 * Sets the totalLabelProperty attribute value.
60 * @param totalLabelProperty The totalLabelProperty to set.
61 */
62 public void setTotalLabelProperty(String totalLabelProperty) {
63 this.totalLabelProperty = totalLabelProperty;
64 }
65
66 /**
67 * Uses GroupTotalRenderer to render the total
68 * @see org.kuali.ole.sys.document.datadictionary.TotalDefinition#getTotalRenderer()
69 */
70 @Override
71 public Renderer getTotalRenderer() {
72 GroupTotalRenderer renderer = new GroupTotalRenderer();
73
74 renderer.setTotalLabelProperty(totalLabelProperty);
75 renderer.setRepresentedCellPropertyName(representedProperty);
76
77 final String actualTotalProperty = this.getActualPropertyName(containingPropertyName, totalProperty);
78 renderer.setTotalProperty(actualTotalProperty);
79
80 return renderer;
81 }
82
83 /**
84 * Validates that a total property has been added
85 * @see org.kuali.rice.krad.datadictionary.DataDictionaryDefinition#completeValidation(java.lang.Class, java.lang.Class)
86 */
87 public void completeValidation(Class rootBusinessObjectClass, Class otherBusinessObjectClass) {
88 if (StringUtils.isBlank(totalProperty)) {
89 throw new AttributeValidationException("Please specify a totalProperty for the AccountingLineGroupTotalRenderer");
90 }
91 }
92
93 /**
94 * Gets the representedProperty attribute.
95 * @return Returns the representedProperty.
96 */
97 public String getRepresentedProperty() {
98 return representedProperty;
99 }
100
101 /**
102 * Sets the representedProperty attribute value.
103 * @param representedProperty The representedProperty to set.
104 */
105 public void setRepresentedProperty(String representedProperty) {
106 this.representedProperty = representedProperty;
107 }
108
109 /**
110 * @see org.kuali.ole.sys.document.datadictionary.TotalDefinition#isNestedProperty()
111 */
112 public boolean isNestedProperty() {
113 return nestedProperty;
114 }
115
116 /**
117 * Sets the nestedProperty attribute value.
118 * @param nestedProperty The nestedProperty to set.
119 */
120 public void setNestedProperty(boolean nestedProperty) {
121 this.nestedProperty = nestedProperty;
122 }
123
124 /**
125 * @see org.kuali.ole.sys.document.web.NestedFieldTotaling#setContainingPropertyName(java.lang.String)
126 */
127 public void setContainingPropertyName(String containingPropertyName) {
128 this.containingPropertyName = containingPropertyName;
129 }
130 }