View Javadoc
1   /*
2    * The Kuali Financial System, a comprehensive financial management system for higher education.
3    * 
4    * Copyright 2005-2014 The Kuali Foundation
5    * 
6    * This program is free software: you can redistribute it and/or modify
7    * it under the terms of the GNU Affero General Public License as
8    * published by the Free Software Foundation, either version 3 of the
9    * License, or (at your option) any later version.
10   * 
11   * This program is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   * GNU Affero General Public License for more details.
15   * 
16   * You should have received a copy of the GNU Affero General Public License
17   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18   */
19  package org.kuali.kfs.sys.document.datadictionary;
20  
21  import org.apache.commons.lang.StringUtils;
22  import org.apache.log4j.Logger;
23  import org.kuali.kfs.sys.document.web.renderers.DebitCreditTotalRenderer;
24  import org.kuali.kfs.sys.document.web.renderers.Renderer;
25  import org.kuali.rice.krad.datadictionary.exception.AttributeValidationException;
26  
27  /**
28   * Metadata that instructs the accounting line tags how to render debit/credit totals used in voucher documents
29   */
30  public class DebitCreditTotalDefinition extends TotalDefinition {
31      private static Logger LOG = Logger.getLogger(DebitCreditTotalDefinition.class);
32  
33      private String debitTotalProperty;
34      private String creditTotalProperty;
35      
36      private boolean nestedProperty;
37      private String containingPropertyName;
38  
39      private String representedProperty;
40  
41      private String debitTotalLabelProperty = "accounting.line.group.debitTotal.label";
42      private String creditTotalLabelProperty = "accounting.line.group.creditTotal.label";
43  
44      /**
45       * @see org.kuali.kfs.sys.document.datadictionary.TotalDefinition#getTotalRenderer()
46       */
47      @Override
48      public Renderer getTotalRenderer() {
49          DebitCreditTotalRenderer renderer = new DebitCreditTotalRenderer();
50  
51          String actualCreditTotalProperty = this.getActualPropertyName(containingPropertyName, creditTotalProperty);
52          renderer.setCreditTotalProperty(actualCreditTotalProperty);
53          
54          String actualDebitTotalProperty = this.getActualPropertyName(containingPropertyName, debitTotalProperty);
55          renderer.setDebitTotalProperty(actualDebitTotalProperty);
56  
57          renderer.setRepresentedCellPropertyName(representedProperty);
58  
59          renderer.setCreditTotalLabelProperty(creditTotalLabelProperty);
60          renderer.setDebitTotalLabelProperty(debitTotalLabelProperty);
61  
62          return renderer;
63      }
64  
65      /**
66       * Validates that total properties have been added
67       * 
68       * @see org.kuali.rice.krad.datadictionary.DataDictionaryDefinition#completeValidation(java.lang.Class, java.lang.Class)
69       */
70      public void completeValidation(Class rootBusinessObjectClass, Class otherBusinessObjectClass) {
71          if (StringUtils.isBlank(debitTotalProperty) || StringUtils.isBlank(creditTotalProperty)) {
72              throw new AttributeValidationException("Please specify both debitTotalProperty and creditTotalProperty for the AccountingLineGroupTotalRenderer");
73          }
74      }
75  
76      /**
77       * Gets the debitTotalProperty attribute.
78       * 
79       * @return Returns the debitTotalProperty.
80       */
81      public String getDebitTotalProperty() {
82          return debitTotalProperty;
83      }
84  
85      /**
86       * Sets the debitTotalProperty attribute value.
87       * 
88       * @param debitTotalProperty The debitTotalProperty to set.
89       */
90      public void setDebitTotalProperty(String debitTotalProperty) {
91          this.debitTotalProperty = debitTotalProperty;
92      }
93  
94      /**
95       * Gets the creditTotalProperty attribute.
96       * 
97       * @return Returns the creditTotalProperty.
98       */
99      public String getCreditTotalProperty() {
100         return creditTotalProperty;
101     }
102 
103     /**
104      * Sets the creditTotalProperty attribute value.
105      * 
106      * @param creditTotalProperty The creditTotalProperty to set.
107      */
108     public void setCreditTotalProperty(String creditTotalProperty) {
109         this.creditTotalProperty = creditTotalProperty;
110     }
111 
112     /**
113      * Gets the debitTotalLabelProperty attribute.
114      * 
115      * @return Returns the debitTotalLabelProperty.
116      */
117     public String getDebitTotalLabelProperty() {
118         return debitTotalLabelProperty;
119     }
120 
121     /**
122      * Sets the debitTotalLabelProperty attribute value.
123      * 
124      * @param debitTotalLabelProperty The debitTotalLabelProperty to set.
125      */
126     public void setDebitTotalLabelProperty(String debitTotalLabelProperty) {
127         this.debitTotalLabelProperty = debitTotalLabelProperty;
128     }
129 
130     /**
131      * Gets the creditTotalLabelProperty attribute.
132      * 
133      * @return Returns the creditTotalLabelProperty.
134      */
135     public String getCreditTotalLabelProperty() {
136         return creditTotalLabelProperty;
137     }
138 
139     /**
140      * Sets the creditTotalLabelProperty attribute value.
141      * 
142      * @param creditTotalLabelProperty The creditTotalLabelProperty to set.
143      */
144     public void setCreditTotalLabelProperty(String creditTotalLabelProperty) {
145         this.creditTotalLabelProperty = creditTotalLabelProperty;
146     }
147 
148     /**
149      * Gets the representedProperty attribute.
150      * 
151      * @return Returns the representedProperty.
152      */
153     public String getRepresentedProperty() {
154         return representedProperty;
155     }
156 
157     /**
158      * Sets the representedProperty attribute value.
159      * 
160      * @param representedProperty The representedProperty to set.
161      */
162     public void setRepresentedProperty(String representedProperty) {
163         this.representedProperty = representedProperty;
164     }
165 
166     /**
167      * Sets the nestedProperty attribute value.
168      * @param nestedProperty The nestedProperty to set.
169      */
170     public void setNestedProperty(boolean nestedProperty) {
171         this.nestedProperty = nestedProperty;
172     }
173 
174     /**
175      * @see org.kuali.kfs.sys.document.web.NestedFieldTotaling#setContainingPropertyName(java.lang.String)
176      */
177     public void setContainingPropertyName(String containingPropertyName) {
178         this.containingPropertyName = containingPropertyName;
179     }
180 
181     /**
182      * @see org.kuali.kfs.sys.document.web.NestedFieldTotaling#isNestedProperty()
183      */
184     public boolean isNestedProperty() {
185         return this.nestedProperty;
186     }
187 }