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