1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.kfs.coa.businessobject.service;
17
18 import java.util.List;
19 import java.util.Map;
20 import java.util.Properties;
21
22 import org.apache.commons.lang.StringUtils;
23 import org.kuali.kfs.coa.businessobject.Account;
24 import org.kuali.rice.kns.lookup.HtmlData;
25 import org.kuali.rice.kns.lookup.HtmlData.AnchorHtmlData;
26 import org.kuali.rice.kns.lookup.KualiLookupableHelperServiceImpl;
27 import org.kuali.rice.krad.bo.BusinessObject;
28 import org.kuali.rice.krad.util.KRADConstants;
29 import org.kuali.rice.krad.util.UrlFactory;
30
31 public class AccountLookupableHelper extends KualiLookupableHelperServiceImpl {
32
33 private static final long serialVersionUID = 2900185403539471985L;
34
35 @Override
36 public List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues) {
37 if (fieldValues.containsKey("closed")) {
38 String closedValue = fieldValues.get("closed");
39 if (StringUtils.isNotEmpty(closedValue)) {
40 fieldValues.put("active", StringUtils.equals(closedValue, "Y") ? "N" : "Y");
41 }
42 fieldValues.remove("closed");
43 }
44 return super.getSearchResults(fieldValues);
45 }
46
47 @Override
48 public List<HtmlData> getCustomActionUrls(BusinessObject businessObject, List pkNames) {
49 List<HtmlData> customActionUrls = super.getCustomActionUrls(businessObject, pkNames);
50
51 Account account = (Account) businessObject;
52 String accountNumber = account.getAccountNumber();
53 String chartOfAccountsCode = account.getChartOfAccountsCode();
54
55 Properties params = new Properties();
56 params.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, getBusinessObjectClass().getName());
57 params.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, KRADConstants.MAINTENANCE_NEW_METHOD_TO_CALL);
58 params.put("accountNumber", accountNumber);
59 params.put("chartOfAccountsCode", chartOfAccountsCode);
60 AnchorHtmlData viewUrl = new AnchorHtmlData(UrlFactory.parameterizeUrl(KRADConstants.INQUIRY_ACTION, params), "view");
61 viewUrl.setDisplayText("view");
62 viewUrl.setTarget(AnchorHtmlData.TARGET_BLANK);
63 customActionUrls.add(viewUrl);
64
65 return customActionUrls;
66 }
67
68 }