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.Properties;
020    
021    import org.kuali.kfs.coa.businessobject.SubObjectCode;
022    import org.kuali.rice.kns.lookup.HtmlData;
023    import org.kuali.rice.kns.lookup.HtmlData.AnchorHtmlData;
024    import org.kuali.rice.kns.lookup.KualiLookupableHelperServiceImpl;
025    import org.kuali.rice.krad.bo.BusinessObject;
026    import org.kuali.rice.krad.util.KRADConstants;
027    import org.kuali.rice.krad.util.UrlFactory;
028    
029    public class SubObjectCodeLookupableHelper extends KualiLookupableHelperServiceImpl {
030    
031            private static final long serialVersionUID = -1851652201286445549L;
032    
033            @Override
034            public List<HtmlData> getCustomActionUrls(BusinessObject businessObject, List pkNames) {
035                    List<HtmlData> customActionUrls = super.getCustomActionUrls(businessObject, pkNames);
036                    
037                    SubObjectCode subObjectCode = (SubObjectCode) businessObject;
038                    String financialSubObjectCode = subObjectCode.getFinancialSubObjectCode();
039                    String financialObjectCode = subObjectCode.getFinancialObjectCode();
040                    String accountNumber = subObjectCode.getAccountNumber();
041                    String universityFiscalYear = String.valueOf(subObjectCode.getUniversityFiscalYear());
042                    String chartOfAccountsCode = subObjectCode.getChartOfAccountsCode();
043                    
044                    Properties params = new Properties();
045                    params.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, getBusinessObjectClass().getName());
046                    params.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, KRADConstants.MAINTENANCE_NEW_METHOD_TO_CALL);
047                    params.put("financialSubObjectCode", financialSubObjectCode);
048                    params.put("financialObjectCode", financialObjectCode);
049                    params.put("accountNumber", accountNumber);
050                    params.put("universityFiscalYear", universityFiscalYear);
051                    params.put("hrEarnCodeSecurityId", chartOfAccountsCode);
052                    AnchorHtmlData viewUrl = new AnchorHtmlData(UrlFactory.parameterizeUrl(KRADConstants.INQUIRY_ACTION, params), "view");
053                    viewUrl.setDisplayText("view");
054                    viewUrl.setTarget(AnchorHtmlData.TARGET_BLANK);
055                    customActionUrls.add(viewUrl);
056                    
057                    return customActionUrls;
058            }
059            
060    }