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.service.impl;
17  
18  import java.util.Map;
19  import java.util.Properties;
20  
21  import org.apache.struts.action.ActionForward;
22  import org.apache.struts.action.ActionMapping;
23  import org.kuali.ole.sys.businessobject.ElectronicPaymentClaim;
24  import org.kuali.ole.sys.service.ElectronicFundTransferActionHelper;
25  import org.kuali.ole.sys.service.ElectronicPaymentClaimingService;
26  import org.kuali.ole.sys.web.struts.ElectronicFundTransferForm;
27  import org.kuali.rice.krad.util.KRADConstants;
28  import org.kuali.rice.krad.util.UrlFactory;
29  
30  /**
31   * An action for Electronic Fund Transfer that simply redirects to either the claiming or non-claiming lookup.
32   */
33  public class ElectronicFundTransferStartActionHelper implements ElectronicFundTransferActionHelper {
34      private ElectronicPaymentClaimingService electronicPaymentClaimingService;
35  
36      /**
37       * @see org.kuali.ole.sys.service.ElectronicFundTransferActionHelper#performAction(org.kuali.ole.sys.web.struts.ElectronicFundTransferForm, org.apache.struts.action.ActionMapping, java.util.Map)
38       */
39      public ActionForward performAction(ElectronicFundTransferForm form, ActionMapping mapping, Map parameterMap, String basePath) {
40          return new ActionForward((form.hasAvailableClaimingDocumentStrategies() ? getClaimingLookupUrl(form, basePath) : getNonClaimingLookupUrl(form, basePath) ), true);
41      }
42      
43      /**
44       * @return URL for non-claiming EFT search
45       */
46      protected String getNonClaimingLookupUrl(ElectronicFundTransferForm form, String basePath) {        
47          Properties props = getCommonLookupProperties(form);
48          props.put(KRADConstants.HIDE_LOOKUP_RETURN_LINK, Boolean.toString(true));
49          props.put(KRADConstants.RETURN_LOCATION_PARAMETER, basePath + "/" + getNonClaimingReturnLocation());
50          props.put(KRADConstants.BACK_LOCATION, basePath + "/" + getNonClaimingReturnLocation());
51          return UrlFactory.parameterizeUrl(basePath + "/kr/" + KRADConstants.LOOKUP_ACTION, props);
52      }
53      
54      /**
55       * @return URL for claiming EFT search
56       */
57      protected String getClaimingLookupUrl(ElectronicFundTransferForm form, String basePath) {
58          Properties props = getCommonLookupProperties(form);
59          props.put(KRADConstants.MULTIPLE_VALUE, Boolean.toString(true));
60          props.put(KRADConstants.LOOKUP_ANCHOR, KRADConstants.ANCHOR_TOP_OF_FORM);
61          props.put(KRADConstants.LOOKED_UP_COLLECTION_NAME, "claims");
62          props.put(KRADConstants.RETURN_LOCATION_PARAMETER, basePath + "/" + getClaimingReturnLocation());
63          props.put(KRADConstants.BACK_LOCATION, basePath + "/" + getClaimingReturnLocation());
64          return UrlFactory.parameterizeUrl(basePath + "/kr/" + KRADConstants.MULTIPLE_VALUE_LOOKUP_ACTION, props);
65      }
66      
67      /**
68       * @return a set of Properties common to both claiming and non-claiming lookup
69       */
70      protected Properties getCommonLookupProperties(ElectronicFundTransferForm form) {
71          Properties props = new Properties();
72          props.put(KRADConstants.SUPPRESS_ACTIONS, Boolean.toString(true));
73          props.put(KRADConstants.DOC_FORM_KEY, "88888888");
74          props.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, ElectronicPaymentClaim.class.getName());
75          props.put(KRADConstants.METHOD_TO_CALL_ATTRIBUTE, "start");
76          return props;
77      }
78      
79      /**
80       * @return the location where the search should return to for claiming
81       */
82      protected String getClaimingReturnLocation() {
83          return "electronicFundTransfer.do";
84      }
85      
86      /**
87       * @return the location where the search should return to for non-claiming - ie, the portal!
88       */
89      protected String getNonClaimingReturnLocation() {
90          return "portal.do";
91      }
92      
93      /**
94       * Sets the electronicPaymentClaimingService attribute value.
95       * @param electronicPaymentClaimingService The electronicPaymentClaimingService to set.
96       */
97      public void setElectronicPaymentClaimingService(ElectronicPaymentClaimingService electronicPaymentClaimingService) {
98          this.electronicPaymentClaimingService = electronicPaymentClaimingService;
99      }
100     
101 }
102