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.fp.document.authorization;
17  
18  import java.util.Map;
19  
20  import org.kuali.ole.sys.OLEConstants;
21  import org.kuali.ole.sys.OLEKeyConstants;
22  import org.kuali.ole.sys.businessobject.AccountingLine;
23  import org.kuali.ole.sys.document.authorization.AccountingLineAuthorizerBase;
24  import org.kuali.ole.sys.document.web.AccountingLineRenderingContext;
25  import org.kuali.ole.sys.document.web.AccountingLineViewAction;
26  
27  /**
28   * The default implementation of AccountingLineAuthorizer
29   */
30  public class FinancialTransactionalDocumentAccountingLineAuthorizerBase extends AccountingLineAuthorizerBase {
31      
32      /**
33       * adds refresh method to the action map.
34       * @see org.kuali.ole.sys.document.authorization.AccountingLineAuthorizerBase#getActionMap(org.kuali.ole.sys.document.web.AccountingLineRenderingContext, java.lang.String, java.lang.Integer, java.lang.String)
35       */
36      @Override
37      protected Map<String, AccountingLineViewAction> getActionMap(AccountingLineRenderingContext accountingLineRenderingContext, String accountingLinePropertyName, Integer accountingLineIndex, String groupTitle) {
38      
39          Map<String, AccountingLineViewAction> actionMap = super.getActionMap(accountingLineRenderingContext, accountingLinePropertyName, accountingLineIndex, groupTitle);
40  
41          if (accountingLineIndex != null) {
42              AccountingLineViewAction refreshAction = this.getRefreshAction(accountingLineRenderingContext.getAccountingLine(), accountingLinePropertyName, accountingLineIndex, groupTitle);
43              actionMap.put(OLEConstants.RETURN_METHOD_TO_CALL, refreshAction);
44          }
45          
46          return actionMap;
47      }
48      
49      /**
50       * constructs a refresh action image and action
51       * 
52       * @param accountingLine
53       * @param accountingLinePropertyName
54       * @param accountingLineIndex
55       * @param groupTitle
56       * @return
57       */
58      protected AccountingLineViewAction getRefreshAction(AccountingLine accountingLine, String accountingLinePropertyName, Integer accountingLineIndex, String groupTitle) {
59          String actionMethod = this.getRefreshLineMethod(accountingLine, accountingLinePropertyName, accountingLineIndex);
60          String actionLabel = getActionLabel(OLEKeyConstants.AccountingLineViewRendering.ACCOUNTING_LINE_REFRESH_ACTION_LABEL, groupTitle, accountingLineIndex + 1);
61  
62          String actionImageName = getRiceImagePath() + "tinybutton-refresh.gif";
63  
64          return new AccountingLineViewAction(actionMethod, actionLabel, actionImageName);
65      }
66      
67      /**
68       * constructs a refresh line method
69       * 
70       * @param accountingLine
71       * @param accountingLineProperty
72       * @param accountingLineIndex
73       * @return
74       */
75      protected String getRefreshLineMethod(AccountingLine accountingLine, String accountingLineProperty, Integer accountingLineIndex) {
76          final String infix = getActionInfixForExtantAccountingLine(accountingLine, accountingLineProperty);
77          return "refresh.line" + accountingLineIndex + ".anchoraccounting" + infix + "Anchor";
78      }
79  }