1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.gl.businessobject.lookup;
17
18 import java.util.Iterator;
19 import java.util.List;
20 import java.util.Map;
21
22 import org.kuali.ole.gl.Constant;
23 import org.kuali.ole.gl.GeneralLedgerConstants;
24 import org.kuali.ole.gl.businessobject.AccountBalance;
25 import org.kuali.ole.gl.businessobject.TransientBalanceInquiryAttributes;
26 import org.kuali.ole.gl.businessobject.inquiry.AccountBalanceByObjectInquirableImpl;
27 import org.kuali.ole.gl.businessobject.inquiry.AccountBalanceInquirableImpl;
28 import org.kuali.ole.gl.service.AccountBalanceService;
29 import org.kuali.ole.sys.OLEConstants;
30 import org.kuali.ole.sys.OLEPropertyConstants;
31 import org.kuali.rice.kns.lookup.HtmlData;
32 import org.kuali.rice.kns.lookup.KualiLookupableImpl;
33 import org.kuali.rice.krad.bo.PersistableBusinessObject;
34 import org.kuali.rice.krad.lookup.CollectionIncomplete;
35
36
37
38
39 public class AccountBalanceByObjectLookupableImpl extends KualiLookupableImpl {
40 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(AccountBalanceByObjectLookupableImpl.class);
41
42 private AccountBalanceService accountBalanceService;
43
44 public void setAccountBalanceService(AccountBalanceService abs) {
45 accountBalanceService = abs;
46 }
47
48
49
50
51
52
53
54
55 public HtmlData getInquiryUrl(PersistableBusinessObject bo, String propertyName) {
56 if (GeneralLedgerConstants.DummyBusinessObject.LINK_BUTTON_OPTION.equals(propertyName)) {
57 return (new AccountBalanceByObjectInquirableImpl()).getInquiryUrl(bo, propertyName);
58 }
59 return (new AccountBalanceInquirableImpl()).getInquiryUrl(bo, propertyName);
60 }
61
62
63
64
65
66
67
68 public List getSearchResults(Map fieldValues) {
69 LOG.debug("getSearchResults() started");
70
71 setBackLocation((String) fieldValues.get(OLEConstants.BACK_LOCATION));
72 setDocFormKey((String) fieldValues.get(OLEConstants.DOC_FORM_KEY));
73
74 BusinessObjectFieldConverter.escapeSingleQuote(fieldValues);
75
76 String costShareOption = (String) fieldValues.get(GeneralLedgerConstants.DummyBusinessObject.COST_SHARE_OPTION);
77 String pendingEntryOption = (String) fieldValues.get(GeneralLedgerConstants.DummyBusinessObject.PENDING_ENTRY_OPTION);
78 String consolidationOption = (String) fieldValues.get(GeneralLedgerConstants.DummyBusinessObject.CONSOLIDATION_OPTION);
79 boolean isCostShareExcluded = Constant.COST_SHARE_EXCLUDE.equals(costShareOption);
80 int pendingEntryCode = AccountBalanceService.PENDING_NONE;
81 if (GeneralLedgerConstants.PendingEntryOptions.APPROVED.equals(pendingEntryOption)) {
82 pendingEntryCode = AccountBalanceService.PENDING_APPROVED;
83 }
84 else if (GeneralLedgerConstants.PendingEntryOptions.ALL.equals(pendingEntryOption)) {
85 pendingEntryCode = AccountBalanceService.PENDING_ALL;
86 }
87 boolean isConsolidated = Constant.CONSOLIDATION.equals(consolidationOption);
88
89 String chartOfAccountsCode = (String) fieldValues.get(OLEPropertyConstants.CHART_OF_ACCOUNTS_CODE);
90 String accountNumber = (String) fieldValues.get(OLEPropertyConstants.ACCOUNT_NUMBER);
91 String subAccountNumber = (String) fieldValues.get(OLEPropertyConstants.SUB_ACCOUNT_NUMBER);
92 String financialObjectLevelCode = (String) fieldValues.get(GeneralLedgerConstants.BalanceInquiryDrillDowns.OBJECT_LEVEL_CODE);
93 String financialReportingSortCode = (String) fieldValues.get(GeneralLedgerConstants.BalanceInquiryDrillDowns.REPORTING_SORT_CODE);
94
95
96 if (OLEConstants.getDashSubAccountNumber().equals(subAccountNumber)) {
97 subAccountNumber = "";
98 }
99
100 String ufy = (String) fieldValues.get(OLEPropertyConstants.UNIVERSITY_FISCAL_YEAR);
101
102
103 Integer universityFiscalYear = new Integer(Integer.parseInt(ufy));
104
105 List results = accountBalanceService.findAccountBalanceByObject(universityFiscalYear, chartOfAccountsCode, accountNumber, subAccountNumber, financialObjectLevelCode, financialReportingSortCode, isCostShareExcluded, isConsolidated, pendingEntryCode);
106
107
108 for (Iterator iter = results.iterator(); iter.hasNext();) {
109 AccountBalance ab = (AccountBalance) iter.next();
110
111 TransientBalanceInquiryAttributes dbo = ab.getDummyBusinessObject();
112 dbo.setConsolidationOption(consolidationOption);
113 dbo.setCostShareOption(costShareOption);
114 dbo.setPendingEntryOption(pendingEntryOption);
115 dbo.setLinkButtonOption(Constant.LOOKUP_BUTTON_VALUE);
116 }
117 return new CollectionIncomplete(results, new Long(results.size()));
118 }
119 }