View Javadoc
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.apache.log4j.Logger;
20  import org.kuali.ole.sys.document.web.renderers.DebitCreditTotalRenderer;
21  import org.kuali.ole.sys.document.web.renderers.Renderer;
22  import org.kuali.rice.krad.datadictionary.exception.AttributeValidationException;
23  
24  /**
25   * Metadata that instructs the accounting line tags how to render debit/credit totals used in voucher documents
26   */
27  public class DebitCreditTotalDefinition extends TotalDefinition {
28      private static Logger LOG = Logger.getLogger(DebitCreditTotalDefinition.class);
29  
30      private String debitTotalProperty;
31      private String creditTotalProperty;
32      
33      private boolean nestedProperty;
34      private String containingPropertyName;
35  
36      private String representedProperty;
37  
38      private String debitTotalLabelProperty = "accounting.line.group.debitTotal.label";
39      private String creditTotalLabelProperty = "accounting.line.group.creditTotal.label";
40  
41      /**
42       * @see org.kuali.ole.sys.document.datadictionary.TotalDefinition#getTotalRenderer()
43       */
44      @Override
45      public Renderer getTotalRenderer() {
46          DebitCreditTotalRenderer renderer = new DebitCreditTotalRenderer();
47  
48          String actualCreditTotalProperty = this.getActualPropertyName(containingPropertyName, creditTotalProperty);
49          renderer.setCreditTotalProperty(actualCreditTotalProperty);
50          
51          String actualDebitTotalProperty = this.getActualPropertyName(containingPropertyName, debitTotalProperty);
52          renderer.setDebitTotalProperty(actualDebitTotalProperty);
53  
54          renderer.setRepresentedCellPropertyName(representedProperty);
55  
56          renderer.setCreditTotalLabelProperty(creditTotalLabelProperty);
57          renderer.setDebitTotalLabelProperty(debitTotalLabelProperty);
58  
59          return renderer;
60      }
61  
62      /**
63       * Validates that total properties have been added
64       * 
65       * @see org.kuali.rice.krad.datadictionary.DataDictionaryDefinition#completeValidation(java.lang.Class, java.lang.Class)
66       */
67      public void completeValidation(Class rootBusinessObjectClass, Class otherBusinessObjectClass) {
68          if (StringUtils.isBlank(debitTotalProperty) || StringUtils.isBlank(creditTotalProperty)) {
69              throw new AttributeValidationException("Please specify both debitTotalProperty and creditTotalProperty for the AccountingLineGroupTotalRenderer");
70          }
71      }
72  
73      /**
74       * Gets the debitTotalProperty attribute.
75       * 
76       * @return Returns the debitTotalProperty.
77       */
78      public String getDebitTotalProperty() {
79          return debitTotalProperty;
80      }
81  
82      /**
83       * Sets the debitTotalProperty attribute value.
84       * 
85       * @param debitTotalProperty The debitTotalProperty to set.
86       */
87      public void setDebitTotalProperty(String debitTotalProperty) {
88          this.debitTotalProperty = debitTotalProperty;
89      }
90  
91      /**
92       * Gets the creditTotalProperty attribute.
93       * 
94       * @return Returns the creditTotalProperty.
95       */
96      public String getCreditTotalProperty() {
97          return creditTotalProperty;
98      }
99  
100     /**
101      * Sets the creditTotalProperty attribute value.
102      * 
103      * @param creditTotalProperty The creditTotalProperty to set.
104      */
105     public void setCreditTotalProperty(String creditTotalProperty) {
106         this.creditTotalProperty = creditTotalProperty;
107     }
108 
109     /**
110      * Gets the debitTotalLabelProperty attribute.
111      * 
112      * @return Returns the debitTotalLabelProperty.
113      */
114     public String getDebitTotalLabelProperty() {
115         return debitTotalLabelProperty;
116     }
117 
118     /**
119      * Sets the debitTotalLabelProperty attribute value.
120      * 
121      * @param debitTotalLabelProperty The debitTotalLabelProperty to set.
122      */
123     public void setDebitTotalLabelProperty(String debitTotalLabelProperty) {
124         this.debitTotalLabelProperty = debitTotalLabelProperty;
125     }
126 
127     /**
128      * Gets the creditTotalLabelProperty attribute.
129      * 
130      * @return Returns the creditTotalLabelProperty.
131      */
132     public String getCreditTotalLabelProperty() {
133         return creditTotalLabelProperty;
134     }
135 
136     /**
137      * Sets the creditTotalLabelProperty attribute value.
138      * 
139      * @param creditTotalLabelProperty The creditTotalLabelProperty to set.
140      */
141     public void setCreditTotalLabelProperty(String creditTotalLabelProperty) {
142         this.creditTotalLabelProperty = creditTotalLabelProperty;
143     }
144 
145     /**
146      * Gets the representedProperty attribute.
147      * 
148      * @return Returns the representedProperty.
149      */
150     public String getRepresentedProperty() {
151         return representedProperty;
152     }
153 
154     /**
155      * Sets the representedProperty attribute value.
156      * 
157      * @param representedProperty The representedProperty to set.
158      */
159     public void setRepresentedProperty(String representedProperty) {
160         this.representedProperty = representedProperty;
161     }
162 
163     /**
164      * Sets the nestedProperty attribute value.
165      * @param nestedProperty The nestedProperty to set.
166      */
167     public void setNestedProperty(boolean nestedProperty) {
168         this.nestedProperty = nestedProperty;
169     }
170 
171     /**
172      * @see org.kuali.ole.sys.document.web.NestedFieldTotaling#setContainingPropertyName(java.lang.String)
173      */
174     public void setContainingPropertyName(String containingPropertyName) {
175         this.containingPropertyName = containingPropertyName;
176     }
177 
178     /**
179      * @see org.kuali.ole.sys.document.web.NestedFieldTotaling#isNestedProperty()
180      */
181     public boolean isNestedProperty() {
182         return this.nestedProperty;
183     }
184 }