1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  package org.kuali.ole.fp.document.authorization;
17  
18  import org.apache.commons.lang.StringUtils;
19  import org.kuali.ole.fp.businessobject.ProcurementCardTargetAccountingLine;
20  import org.kuali.ole.sys.OLEConstants;
21  import org.kuali.ole.sys.businessobject.AccountingLine;
22  import org.kuali.rice.krad.util.KRADConstants;
23  
24  public class ProcurementCardAccountingLineAuthorizer extends FinancialProcessingAccountingLineAuthorizer {
25      private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ProcurementCardAccountingLineAuthorizer.class);
26  
27      
28  
29  
30      @Override
31      protected String getKimHappyPropertyNameForField(String convertedName) {
32          String name = stripDocumentPrefixFromName(convertedName);
33          name = name.replaceAll("\\[\\d+\\]", StringUtils.EMPTY);
34          name = name.replaceFirst("(.)*transactionEntries\\.", StringUtils.EMPTY);
35  
36          return name;
37      }
38  
39      
40  
41  
42  
43      @Override
44      protected String getDeleteLineMethod(AccountingLine accountingLine, String accountingLineProperty, Integer accountingLineIndex) {
45          final String infix = getActionInfixForExtantAccountingLine(accountingLine, accountingLineProperty);
46          String lineIndex = this.getLineContainerIndex(accountingLineProperty);
47          String lineContainer = this.getLineContainer(accountingLineProperty) + ".";
48  
49          return KRADConstants.DELETE_METHOD + infix + "Line." + lineContainer + "line" + accountingLineIndex + ".anchoraccounting" + infix + "Anchor";
50      }
51  
52      
53  
54  
55  
56      @Override
57      protected String getAddMethod(AccountingLine accountingLine, String accountingLineProperty) {
58          Integer lineIndex = ((ProcurementCardTargetAccountingLine) accountingLine).getTransactionContainerIndex();
59          String lineIndexString = lineIndex.toString();
60  
61          String infix = getActionInfixForNewAccountingLine(accountingLine, accountingLineProperty);
62  
63          return OLEConstants.INSERT_METHOD + infix + "Line" + ".transactionEntries[" + lineIndex + "]";
64      }
65  
66      
67  
68  
69  
70      @Override
71      protected String getBalanceInquiryMethod(AccountingLine accountingLine, String accountingLineProperty, Integer accountingLineIndex) {
72          String infix = getActionInfixForExtantAccountingLine(accountingLine, accountingLineProperty);
73          String lineContainer = this.getLineContainer(accountingLineProperty) + ".";
74  
75          return OLEConstants.PERFORMANCE_BALANCE_INQUIRY_FOR_METHOD + infix + "Line." + lineContainer + "line" + accountingLineIndex + ".anchoraccounting" + infix + "existingLineLineAnchor" + accountingLineIndex;
76      }
77  
78      protected String getLineContainer(String accountingLineProperty) {
79          String lineContainer = stripDocumentPrefixFromName(accountingLineProperty);
80          return StringUtils.substringBeforeLast(lineContainer, ".");
81      }
82  
83      protected String getLineContainerIndex(String accountingLineProperty) {
84          String lineContainer = this.getLineContainer(accountingLineProperty);
85          return StringUtils.substringBetween(lineContainer, "[", "]");
86      }
87  }