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.pdp.web.struts;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  
21  import javax.servlet.http.HttpServletRequest;
22  
23  import org.apache.struts.action.ActionMapping;
24  import org.kuali.ole.pdp.businessobject.CustomerProfile;
25  import org.kuali.ole.pdp.businessobject.DisbursementNumberFormatter;
26  import org.kuali.ole.pdp.businessobject.DisbursementNumberRange;
27  import org.kuali.ole.pdp.businessobject.FormatProcessSummary;
28  import org.kuali.rice.core.web.format.CurrencyFormatter;
29  import org.kuali.rice.kns.web.struts.form.KualiForm;
30  
31  /**
32   * Struts Action Form for Format Checks/ACH
33   */
34  public class FormatForm extends KualiForm {
35  
36      private String campus;
37      private String paymentDate;
38      private String paymentTypes;
39  
40      private FormatProcessSummary formatProcessSummary;
41  
42      private List<CustomerProfile> customers;
43      private List<DisbursementNumberRange> ranges;
44  
45      /**
46       * Constructs a FormatForm.
47       */
48      public FormatForm() {
49          super();
50          customers = new ArrayList<CustomerProfile>();
51          ranges = new ArrayList<DisbursementNumberRange>();        
52          
53           this.setFormatterType("range.lastAssignedDisbNbr", DisbursementNumberFormatter.class);
54      }
55  
56      /**
57       * This method gets campus
58       * 
59       * @return campus
60       */
61      public String getCampus() {
62          return campus;
63      }
64  
65      /**
66       * This method sets campus
67       * 
68       * @param campus
69       */
70      public void setCampus(String campus) {
71          this.campus = campus;
72      }
73  
74      /**
75       * This method gets payment types
76       * 
77       * @return paymentTypes
78       */
79      public String getPaymentTypes() {
80          return paymentTypes;
81      }
82  
83      /**
84       * This method sets paymentTypes
85       * 
86       * @param paymentTypes
87       */
88      public void setPaymentTypes(String paymentTypes) {
89          this.paymentTypes = paymentTypes;
90      }
91  
92      /**
93       * This method gets customers
94       * 
95       * @return customers
96       */
97      public List<CustomerProfile> getCustomers() {
98          return customers;
99      }
100 
101     /**
102      * This method sets customers
103      * 
104      * @param customers
105      */
106     public void setCustomers(List<CustomerProfile> customers) {
107         this.customers = customers;
108     }
109 
110     /**
111      * This method retrieves a specific customer profile from the list, by index
112      * 
113      * @param index the index of the customers to retrieve the customer profile from
114      * @return a CustomerProfile
115      */
116     public CustomerProfile getCustomer(int index) {
117         if (index >= customers.size()) {
118             for (int i = customers.size(); i <= index; i++) {
119                 customers.add(new CustomerProfile());
120             }
121         }
122         return (CustomerProfile) customers.get(index);
123     }
124 
125     /**
126      * This method sets a customer profile.
127      * 
128      * @param key the index of the value
129      * @param value the new value
130      */
131     public void setCustomer(int key, CustomerProfile value) {
132         customers.set(key, value);
133     }
134 
135 
136     /**
137      * This method gets the ranges.
138      * 
139      * @return ranges list
140      */
141     public List<DisbursementNumberRange> getRanges() {
142         return ranges;
143     }
144 
145     /**
146      * This method sets ranges list.
147      * 
148      * @param ranges
149      */
150     public void setRanges(List<DisbursementNumberRange> ranges) {
151         this.ranges = ranges;
152     }
153 
154     /**
155      * This method retrieves a specific disbursement number range from the list, by index
156      * 
157      * @param index the index of the ranges to retrieve the disbursement number range from
158      * @return a DisbursementNumberRange
159      */
160     public DisbursementNumberRange getRange(int index) {
161         if (index >= ranges.size()) {
162             for (int i = ranges.size(); i <= index; i++) {
163                 ranges.add(new DisbursementNumberRange());
164             }
165         }
166         return (DisbursementNumberRange) ranges.get(index);
167     }
168 
169     /**
170      * This method gets the currency formated value of the total amount.
171      * 
172      * @return the currency formated value of the total amount
173      */
174     public String getCurrencyFormattedTotalAmount() {
175         return (String) new CurrencyFormatter().format(formatProcessSummary.getTotalAmount());
176     }
177 
178     /**
179      * This method gets the payment date.
180      * 
181      * @return paymentDate
182      */
183     public String getPaymentDate() {
184         return paymentDate;
185     }
186 
187     /**
188      * This method sets the payment date.
189      * 
190      * @param paymentDate
191      */
192     public void setPaymentDate(String paymentDate) {
193         this.paymentDate = paymentDate;
194     }
195 
196     /**
197      * This method gets the format process summary.
198      * 
199      * @return formatProcessSummary
200      */
201     public FormatProcessSummary getFormatProcessSummary() {
202         return formatProcessSummary;
203     }
204 
205     /**
206      * This method sets the format process summary.
207      * 
208      * @param formatProcessSummary
209      */
210     public void setFormatProcessSummary(FormatProcessSummary formatProcessSummary) {
211         this.formatProcessSummary = formatProcessSummary;
212     }
213     
214     /**
215      * @see org.apache.struts.action.ActionForm#reset(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest)
216      */
217     @Override
218     public void reset(ActionMapping arg0, HttpServletRequest arg1) {
219         super.reset(arg0, arg1);
220 
221         for (CustomerProfile customer : customers) {
222             customer.setSelectedForFormat(false);
223         }
224     }
225 }