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.web.struts;
20  
21  import java.util.Map;
22  
23  import javax.servlet.http.HttpServletRequest;
24  import javax.servlet.http.HttpServletResponse;
25  
26  import org.apache.struts.action.ActionForm;
27  import org.apache.struts.action.ActionForward;
28  import org.apache.struts.action.ActionMapping;
29  import org.kuali.kfs.sys.context.SpringContext;
30  import org.kuali.kfs.sys.service.ElectronicFundTransferActionHelper;
31  import org.kuali.kfs.sys.service.ElectronicPaymentClaimingService;
32  import org.kuali.rice.kns.web.struts.action.KualiAction;
33  import org.kuali.rice.krad.util.GlobalVariables;
34  
35  public class ElectronicFundTransferAction extends KualiAction {
36      private final static String START_BEAN = "electronicFundTransferStartAction";
37      private final static String REFRESH_BEAN = "electronicFundTransferRefreshAction";
38      private final static String CLAIM_BEAN = "electronicFundTransferClaimAction";
39      private final static String CANCEL_BEAN = "electronicFundTransferCancelAction";
40      
41      /**
42       * @see org.kuali.rice.kns.web.struts.action.KualiAction#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
43       */
44      @Override
45      public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
46          ElectronicFundTransferForm eftForm = (ElectronicFundTransferForm)form;
47          eftForm.setAvailableClaimingDocumentStrategies(SpringContext.getBean(ElectronicPaymentClaimingService.class).getClaimingDocumentChoices(GlobalVariables.getUserSession().getPerson()));
48          return super.execute(mapping, form, request, response);
49      }
50      
51      /**
52       * The action that sends the user to the correct lookup for them
53       * @param mapping
54       * @param form
55       * @param request
56       * @param response
57       * @return
58       * @throws Exception
59       */
60      public ActionForward start(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
61          return getActionHelpers().get(ElectronicFundTransferAction.START_BEAN).performAction((ElectronicFundTransferForm)form, mapping, request.getParameterMap(), getApplicationBaseUrl());
62      }
63   
64      /**
65       * The action that is called when a document is loaded, after returning from the multivalue select
66       * @param mapping
67       * @param form
68       * @param request
69       * @param response
70       * @return
71       * @throws Exception
72       */
73      public ActionForward refresh(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
74          return getActionHelpers().get(ElectronicFundTransferAction.REFRESH_BEAN).performAction((ElectronicFundTransferForm)form, mapping, request.getParameterMap(), getApplicationBaseUrl());
75      }
76      
77      /**
78       * The response to the "claim" request
79       * @param mapping
80       * @param form
81       * @param request
82       * @param response
83       * @return
84       * @throws Exception
85       */
86      public ActionForward claim(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
87          return getActionHelpers().get(ElectronicFundTransferAction.CLAIM_BEAN).performAction((ElectronicFundTransferForm)form, mapping, request.getParameterMap(), getApplicationBaseUrl());
88      }
89      
90      /**
91       * The response to the "cancel" request
92       * @param mapping
93       * @param form
94       * @param request
95       * @param response
96       * @return
97       * @throws Exception
98       */
99      public ActionForward cancel(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
100         return getActionHelpers().get(ElectronicFundTransferAction.CANCEL_BEAN).performAction((ElectronicFundTransferForm)form, mapping, request.getParameterMap(), getApplicationBaseUrl());
101     }
102     
103     /**
104      * @return all of the beans that act as ElectronicFundTransferActionHelper
105      */
106     private Map<String, ElectronicFundTransferActionHelper> getActionHelpers() {
107         return SpringContext.getBeansOfType(ElectronicFundTransferActionHelper.class);
108     }
109 }
110