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.service.impl; 017 018 import java.util.Map; 019 import java.util.Properties; 020 021 import org.apache.struts.action.ActionForward; 022 import org.apache.struts.action.ActionMapping; 023 import org.kuali.kfs.sys.businessobject.ElectronicPaymentClaim; 024 import org.kuali.kfs.sys.service.ElectronicFundTransferActionHelper; 025 import org.kuali.kfs.sys.service.ElectronicPaymentClaimingService; 026 import org.kuali.kfs.sys.web.struts.ElectronicFundTransferForm; 027 import org.kuali.rice.kns.util.GlobalVariables; 028 import org.kuali.rice.kns.util.KNSConstants; 029 import org.kuali.rice.kns.util.UrlFactory; 030 031 /** 032 * An action for Electronic Fund Transfer that simply redirects to either the claiming or non-claiming lookup. 033 */ 034 public class ElectronicFundTransferStartActionHelper implements ElectronicFundTransferActionHelper { 035 private ElectronicPaymentClaimingService electronicPaymentClaimingService; 036 037 /** 038 * @see org.kuali.kfs.sys.service.ElectronicFundTransferActionHelper#performAction(org.kuali.kfs.sys.web.struts.ElectronicFundTransferForm, org.apache.struts.action.ActionMapping, java.util.Map) 039 */ 040 public ActionForward performAction(ElectronicFundTransferForm form, ActionMapping mapping, Map parameterMap, String basePath) { 041 return new ActionForward((form.hasAvailableClaimingDocumentStrategies() ? getClaimingLookupUrl(form, basePath) : getNonClaimingLookupUrl(form, basePath) ), true); 042 } 043 044 /** 045 * @return URL for non-claiming EFT search 046 */ 047 protected String getNonClaimingLookupUrl(ElectronicFundTransferForm form, String basePath) { 048 Properties props = getCommonLookupProperties(form); 049 props.put(KNSConstants.HIDE_LOOKUP_RETURN_LINK, Boolean.toString(true)); 050 props.put(KNSConstants.RETURN_LOCATION_PARAMETER, basePath + "/" + getNonClaimingReturnLocation()); 051 props.put(KNSConstants.BACK_LOCATION, basePath + "/" + getNonClaimingReturnLocation()); 052 return UrlFactory.parameterizeUrl(basePath + "/kr/" + KNSConstants.LOOKUP_ACTION, props); 053 } 054 055 /** 056 * @return URL for claiming EFT search 057 */ 058 protected String getClaimingLookupUrl(ElectronicFundTransferForm form, String basePath) { 059 Properties props = getCommonLookupProperties(form); 060 props.put(KNSConstants.MULTIPLE_VALUE, Boolean.toString(true)); 061 props.put(KNSConstants.LOOKUP_ANCHOR, KNSConstants.ANCHOR_TOP_OF_FORM); 062 props.put(KNSConstants.LOOKED_UP_COLLECTION_NAME, "claims"); 063 props.put(KNSConstants.RETURN_LOCATION_PARAMETER, basePath + "/" + getClaimingReturnLocation()); 064 props.put(KNSConstants.BACK_LOCATION, basePath + "/" + getClaimingReturnLocation()); 065 return UrlFactory.parameterizeUrl(basePath + "/kr/" + KNSConstants.MULTIPLE_VALUE_LOOKUP_ACTION, props); 066 } 067 068 /** 069 * @return a set of Properties common to both claiming and non-claiming lookup 070 */ 071 protected Properties getCommonLookupProperties(ElectronicFundTransferForm form) { 072 Properties props = new Properties(); 073 props.put(KNSConstants.SUPPRESS_ACTIONS, Boolean.toString(true)); 074 props.put(KNSConstants.DOC_FORM_KEY, "88888888"); 075 props.put(KNSConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, ElectronicPaymentClaim.class.getName()); 076 props.put(KNSConstants.METHOD_TO_CALL_ATTRIBUTE, "start"); 077 return props; 078 } 079 080 /** 081 * @return the location where the search should return to for claiming 082 */ 083 protected String getClaimingReturnLocation() { 084 return "electronicFundTransfer.do"; 085 } 086 087 /** 088 * @return the location where the search should return to for non-claiming - ie, the portal! 089 */ 090 protected String getNonClaimingReturnLocation() { 091 return "portal.do"; 092 } 093 094 /** 095 * Sets the electronicPaymentClaimingService attribute value. 096 * @param electronicPaymentClaimingService The electronicPaymentClaimingService to set. 097 */ 098 public void setElectronicPaymentClaimingService(ElectronicPaymentClaimingService electronicPaymentClaimingService) { 099 this.electronicPaymentClaimingService = electronicPaymentClaimingService; 100 } 101 102 } 103