View Javadoc

1   /**
2    * Copyright 2004-2013 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.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);    //To change body of overridden methods use File | Settings | File Templates.
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  }