001 /* 002 * Copyright 2011 The Kuali Foundation. 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.kfs.sys.web.struts; 017 018 import java.util.Map; 019 020 import javax.servlet.http.HttpServletRequest; 021 import javax.servlet.http.HttpServletResponse; 022 023 import org.apache.struts.action.ActionForm; 024 import org.apache.struts.action.ActionForward; 025 import org.apache.struts.action.ActionMapping; 026 import org.kuali.kfs.sys.context.SpringContext; 027 import org.kuali.kfs.sys.service.ElectronicFundTransferActionHelper; 028 import org.kuali.kfs.sys.service.ElectronicPaymentClaimingService; 029 import org.kuali.rice.kns.util.GlobalVariables; 030 import org.kuali.rice.kns.web.struts.action.KualiAction; 031 032 public class ElectronicFundTransferAction extends KualiAction { 033 private final static String START_BEAN = "electronicFundTransferStartAction"; 034 private final static String REFRESH_BEAN = "electronicFundTransferRefreshAction"; 035 private final static String CLAIM_BEAN = "electronicFundTransferClaimAction"; 036 private final static String CANCEL_BEAN = "electronicFundTransferCancelAction"; 037 038 /** 039 * @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) 040 */ 041 @Override 042 public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { 043 ElectronicFundTransferForm eftForm = (ElectronicFundTransferForm)form; 044 eftForm.setAvailableClaimingDocumentStrategies(SpringContext.getBean(ElectronicPaymentClaimingService.class).getClaimingDocumentChoices(GlobalVariables.getUserSession().getPerson())); 045 return super.execute(mapping, form, request, response); 046 } 047 048 /** 049 * The action that sends the user to the correct lookup for them 050 * @param mapping 051 * @param form 052 * @param request 053 * @param response 054 * @return 055 * @throws Exception 056 */ 057 public ActionForward start(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { 058 return getActionHelpers().get(ElectronicFundTransferAction.START_BEAN).performAction((ElectronicFundTransferForm)form, mapping, request.getParameterMap(), getBasePath(request)); 059 } 060 061 /** 062 * The action that is called when a document is loaded, after returning from the multivalue select 063 * @param mapping 064 * @param form 065 * @param request 066 * @param response 067 * @return 068 * @throws Exception 069 */ 070 public ActionForward refresh(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { 071 return getActionHelpers().get(ElectronicFundTransferAction.REFRESH_BEAN).performAction((ElectronicFundTransferForm)form, mapping, request.getParameterMap(), getBasePath(request)); 072 } 073 074 /** 075 * The response to the "claim" request 076 * @param mapping 077 * @param form 078 * @param request 079 * @param response 080 * @return 081 * @throws Exception 082 */ 083 public ActionForward claim(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { 084 return getActionHelpers().get(ElectronicFundTransferAction.CLAIM_BEAN).performAction((ElectronicFundTransferForm)form, mapping, request.getParameterMap(), getBasePath(request)); 085 } 086 087 /** 088 * The response to the "cancel" request 089 * @param mapping 090 * @param form 091 * @param request 092 * @param response 093 * @return 094 * @throws Exception 095 */ 096 public ActionForward cancel(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { 097 return getActionHelpers().get(ElectronicFundTransferAction.CANCEL_BEAN).performAction((ElectronicFundTransferForm)form, mapping, request.getParameterMap(), getBasePath(request)); 098 } 099 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