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.Properties;
20  
21  import org.kuali.kfs.coa.businessobject.SubObjectCode;
22  import org.kuali.rice.kns.lookup.HtmlData;
23  import org.kuali.rice.kns.lookup.HtmlData.AnchorHtmlData;
24  import org.kuali.rice.kns.lookup.KualiLookupableHelperServiceImpl;
25  import org.kuali.rice.krad.bo.BusinessObject;
26  import org.kuali.rice.krad.util.KRADConstants;
27  import org.kuali.rice.krad.util.UrlFactory;
28  
29  public class SubObjectCodeLookupableHelper extends KualiLookupableHelperServiceImpl {
30  
31  	private static final long serialVersionUID = -1851652201286445549L;
32  
33  	@Override
34  	public List<HtmlData> getCustomActionUrls(BusinessObject businessObject, List pkNames) {
35  		List<HtmlData> customActionUrls = super.getCustomActionUrls(businessObject, pkNames);
36  		
37  		SubObjectCode subObjectCode = (SubObjectCode) businessObject;
38  		String financialSubObjectCode = subObjectCode.getFinancialSubObjectCode();
39  		String financialObjectCode = subObjectCode.getFinancialObjectCode();
40  		String accountNumber = subObjectCode.getAccountNumber();
41  		String universityFiscalYear = String.valueOf(subObjectCode.getUniversityFiscalYear());
42  		String chartOfAccountsCode = subObjectCode.getChartOfAccountsCode();
43  		
44  		Properties params = new Properties();
45  		params.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, getBusinessObjectClass().getName());
46  		params.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, KRADConstants.MAINTENANCE_NEW_METHOD_TO_CALL);
47  		params.put("financialSubObjectCode", financialSubObjectCode);
48  		params.put("financialObjectCode", financialObjectCode);
49  		params.put("accountNumber", accountNumber);
50  		params.put("universityFiscalYear", universityFiscalYear);
51  		params.put("hrEarnCodeSecurityId", chartOfAccountsCode);
52  		AnchorHtmlData viewUrl = new AnchorHtmlData(UrlFactory.parameterizeUrl(KRADConstants.INQUIRY_ACTION, params), "view");
53  		viewUrl.setDisplayText("view");
54  		viewUrl.setTarget(AnchorHtmlData.TARGET_BLANK);
55  		customActionUrls.add(viewUrl);
56  		
57  		return customActionUrls;
58  	}
59  	
60  }