001 /**
002 * Copyright 2004-2013 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.kuali.kfs.coa.businessobject.service;
017
018 import java.util.List;
019 import java.util.Map;
020 import java.util.Properties;
021
022 import org.apache.commons.lang.StringUtils;
023 import org.kuali.kfs.coa.businessobject.Account;
024 import org.kuali.rice.kns.lookup.HtmlData;
025 import org.kuali.rice.kns.lookup.HtmlData.AnchorHtmlData;
026 import org.kuali.rice.kns.lookup.KualiLookupableHelperServiceImpl;
027 import org.kuali.rice.krad.bo.BusinessObject;
028 import org.kuali.rice.krad.util.KRADConstants;
029 import org.kuali.rice.krad.util.UrlFactory;
030
031 public class AccountLookupableHelper extends KualiLookupableHelperServiceImpl {
032
033 private static final long serialVersionUID = 2900185403539471985L;
034
035 @Override
036 public List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues) {
037 if (fieldValues.containsKey("closed")) {
038 String closedValue = fieldValues.get("closed");
039 if (StringUtils.isNotEmpty(closedValue)) {
040 fieldValues.put("active", StringUtils.equals(closedValue, "Y") ? "N" : "Y");
041 }
042 fieldValues.remove("closed");
043 }
044 return super.getSearchResults(fieldValues); //To change body of overridden methods use File | Settings | File Templates.
045 }
046
047 @Override
048 public List<HtmlData> getCustomActionUrls(BusinessObject businessObject, List pkNames) {
049 List<HtmlData> customActionUrls = super.getCustomActionUrls(businessObject, pkNames);
050
051 Account account = (Account) businessObject;
052 String accountNumber = account.getAccountNumber();
053 String chartOfAccountsCode = account.getChartOfAccountsCode();
054
055 Properties params = new Properties();
056 params.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, getBusinessObjectClass().getName());
057 params.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, KRADConstants.MAINTENANCE_NEW_METHOD_TO_CALL);
058 params.put("accountNumber", accountNumber);
059 params.put("chartOfAccountsCode", chartOfAccountsCode);
060 AnchorHtmlData viewUrl = new AnchorHtmlData(UrlFactory.parameterizeUrl(KRADConstants.INQUIRY_ACTION, params), "view");
061 viewUrl.setDisplayText("view");
062 viewUrl.setTarget(AnchorHtmlData.TARGET_BLANK);
063 customActionUrls.add(viewUrl);
064
065 return customActionUrls;
066 }
067
068 }