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.web.struts;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  
21  import org.apache.commons.lang.StringUtils;
22  import org.kuali.ole.sys.OLEKeyConstants;
23  import org.kuali.ole.sys.businessobject.ElectronicPaymentClaim;
24  import org.kuali.ole.sys.context.SpringContext;
25  import org.kuali.ole.sys.service.ElectronicPaymentClaimingDocumentGenerationStrategy;
26  import org.kuali.ole.sys.service.ElectronicPaymentClaimingService;
27  import org.kuali.rice.kim.api.identity.Person;
28  import org.kuali.rice.kns.web.struts.form.KualiForm;
29  import org.kuali.rice.krad.util.GlobalVariables;
30  
31  public class ElectronicFundTransferForm extends KualiForm {
32      private List<ElectronicPaymentClaim> claims;
33      private List<ElectronicPaymentClaimingDocumentGenerationStrategy> availableClaimingDocumentStrategies;
34      private List<ElectronicPaymentClaimClaimedHelper> claimedByCheckboxHelpers;
35      private String chosenElectronicPaymentClaimingDocumentCode;
36      private String hasDocumentation;
37      
38      /**
39       * Constructs a ElectronicFundTransferForm
40       */
41      public ElectronicFundTransferForm() {
42          claims = new ArrayList<ElectronicPaymentClaim>();
43          claimedByCheckboxHelpers = new ArrayList<ElectronicPaymentClaimClaimedHelper>();
44      }
45      
46      /**
47       * Gets the availableClaimingDocumentStrategies attribute. 
48       * @return Returns the availableClaimingDocumentStrategies.
49       */
50      public List<ElectronicPaymentClaimingDocumentGenerationStrategy> getAvailableClaimingDocumentStrategies() {
51          return availableClaimingDocumentStrategies;
52      }
53      /**
54       * Sets the availableClaimingDocumentStrategies attribute value.
55       * @param availableClaimingDocumentStrategies The availableClaimingDocumentStrategies to set.
56       */
57      public void setAvailableClaimingDocumentStrategies(List<ElectronicPaymentClaimingDocumentGenerationStrategy> availableClaimingDocuments) {
58          this.availableClaimingDocumentStrategies = availableClaimingDocuments;
59      }
60      
61      public boolean hasAvailableClaimingDocumentStrategies() {
62          return availableClaimingDocumentStrategies !=null && !availableClaimingDocumentStrategies.isEmpty();
63      }
64      /**
65       * Gets the chosenElectronicPaymentClaimingDocumentCode attribute. 
66       * @return Returns the chosenElectronicPaymentClaimingDocumentCode.
67       */
68      public String getChosenElectronicPaymentClaimingDocumentCode() {
69          return chosenElectronicPaymentClaimingDocumentCode;
70      }
71      /**
72       * Sets the chosenElectronicPaymentClaimingDocumentCode attribute value.
73       * @param chosenElectronicPaymentClaimingDocumentCode The chosenElectronicPaymentClaimingDocumentCode to set.
74       */
75      public void setChosenElectronicPaymentClaimingDocumentCode(String chosenElectronicPaymentClaimingDocumentCode) {
76          this.chosenElectronicPaymentClaimingDocumentCode = chosenElectronicPaymentClaimingDocumentCode;
77      }
78      /**
79       * Gets the claims attribute. 
80       * @return Returns the claims.
81       */
82      public List<ElectronicPaymentClaim> getClaims() {
83          return claims;
84      }
85      /**
86       * Returns the claim at the specified index in the list of claims.
87       * @param i index of the claim to return
88       * @return the claim at the index
89       */
90      public ElectronicPaymentClaim getClaim(int i) {
91          while (claims.size() <= i) {
92              claims.add(new ElectronicPaymentClaim());
93          }
94          return claims.get(i);
95      }
96      /**
97       * Puts an ElectronicPaymentClaim record in the claims array at a specified point
98       * @param claim the claim to add
99       * @param i the index in the list to add the record at
100      */
101     public void setClaim(ElectronicPaymentClaim claim, int i) {
102         while (claims.size() <= i) {
103             claims.add(new ElectronicPaymentClaim());
104         }
105         claims.add(i, claim);
106     }
107     /**
108      * Sets the claims attribute value.
109      * @param claims The claims to set.
110      */
111     public void setClaims(List<ElectronicPaymentClaim> claims) {
112         this.claims = claims;
113     }
114 
115     /**
116      * Gets the hasDocumentation attribute. 
117      * @return Returns the hasDocumentation.
118      */
119     public String getHasDocumentation() {
120         return hasDocumentation;
121     }
122 
123     /**
124      * Sets the hasDocumentation attribute value.
125      * @param hasDocumentation The hasDocumentation to set.
126      */
127     public void setHasDocumentation(String hasDocumentation) {
128         this.hasDocumentation = hasDocumentation;
129     }
130     
131     /**
132      * Returns a boolean whether the user has stated that documentation exists for the claims about to be made or not
133      * @return true if has documentation, false otherwise
134      */
135     public boolean isProperlyDocumented() {
136         return StringUtils.isNotBlank(this.hasDocumentation) && this.hasDocumentation.equals("Yep");
137     }
138     
139     /**
140      * Returns whether the current user has administrative powers for Electronic Funds Transfer or not
141      * @return true if administrative powers exist, false otherwise
142      */
143     public boolean isAllowElectronicFundsTransferAdministration() {
144         Person currentUser = GlobalVariables.getUserSession().getPerson();        
145         
146         return SpringContext.getBean(ElectronicPaymentClaimingService.class).isAuthorizedForClaimingElectronicPayment(currentUser, null);
147     }
148     
149     /**
150      * @return the key to the EFT documentation message
151      */
152     public String getDocumentationMessageKey() {
153         return OLEKeyConstants.ElectronicPaymentClaim.MESSAGE_EFT_CLAIMING_DOCUMENTATION;
154     }
155     
156     /**
157      * @return the key to the EFT document choice message
158      */
159     public String getDocumentChoiceMessageKey() {
160         return OLEKeyConstants.ElectronicPaymentClaim.MESSAGE_EFT_DOCUMENT_CHOICE;
161     }
162     
163     /**
164      * @return the key to the EFT "previously claimed" message for the table header
165      */
166     public String getPreviouslyClaimedHeaderKey() {
167         return OLEKeyConstants.ElectronicPaymentClaim.MESSAGE_EFT_PREVIOUSLY_CLAIMED_HEADER;
168     }
169     
170     /**
171      * @return the key to the EFT "claiming document number" message for the table header
172      */
173     public String getClaimingDocumentNumberHeaderKey() {
174         return OLEKeyConstants.ElectronicPaymentClaim.MESSAGE_EFT_CLAIMING_DOCUMENT_NUMBER_HEADER;
175     }
176 
177     /**
178      * Gets the claimedByCheckboxHelpers attribute. 
179      * @return Returns the claimedByCheckboxHelpers.
180      */
181     public List<ElectronicPaymentClaimClaimedHelper> getClaimedByCheckboxHelpers() {
182         return claimedByCheckboxHelpers;
183     }
184 
185     /**
186      * Sets the claimedByCheckboxHelpers attribute value.
187      * @param claimedByCheckboxHelpers The claimedByCheckboxHelpers to set.
188      */
189     public void setClaimedByCheckboxHelpers(List<ElectronicPaymentClaimClaimedHelper> claimedByCheckboxHelpers) {
190         this.claimedByCheckboxHelpers = claimedByCheckboxHelpers;
191     }
192     
193     /**
194      * Sets the claimedHelper at the given index
195      * @param claimedHelper the claimedCheckboxHelper to set
196      * @param index where in the list it belongs
197      */
198     public void setClaimedByCheckboxHelper(ElectronicPaymentClaimClaimedHelper claimedHelper, int index) {
199         while (claimedByCheckboxHelpers.size() <= index) {
200             claimedByCheckboxHelpers.add(new ElectronicPaymentClaimClaimedHelper());
201         }
202         claimedByCheckboxHelpers.set(index, claimedHelper);
203     }
204     
205     /**
206      * @param index location in the list of ElectronicPaymentClaimClaimedHelpers to return the helper at
207      * @return the ElectronicPaymentClaimClaimedHelper at the given location
208      */
209     public ElectronicPaymentClaimClaimedHelper getClaimedByCheckboxHelper(int index) {
210         while (claimedByCheckboxHelpers.size() <= index) {
211             claimedByCheckboxHelpers.add(new ElectronicPaymentClaimClaimedHelper());
212         }
213         return claimedByCheckboxHelpers.get(index);
214     }
215 }
216