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.hr.time.salgroup.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.hr.time.HrEffectiveDateActiveLookupableHelper;
024    import org.kuali.hr.time.salgroup.SalGroup;
025    import org.kuali.hr.time.service.base.TkServiceLocator;
026    import org.kuali.hr.time.util.TKUtils;
027    import org.kuali.rice.kns.lookup.HtmlData;
028    import org.kuali.rice.kns.lookup.HtmlData.AnchorHtmlData;
029    import org.kuali.rice.krad.bo.BusinessObject;
030    import org.kuali.rice.krad.util.KRADConstants;
031    import org.kuali.rice.krad.util.UrlFactory;
032    
033    public class SalaryGroupLookupableHelper extends HrEffectiveDateActiveLookupableHelper {
034    
035            private static final long serialVersionUID = 4826886027602440306L;
036    
037            @Override
038            public List<HtmlData> getCustomActionUrls(BusinessObject businessObject, List pkNames) {
039                    List<HtmlData> customActionUrls = super.getCustomActionUrls(businessObject, pkNames);             
040                    
041                    SalGroup salGroup = (SalGroup) businessObject;
042                    String hrSalGroupId = salGroup.getHrSalGroupId();
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("hrSalGroupId", hrSalGroupId);
048                    AnchorHtmlData viewUrl = new AnchorHtmlData(UrlFactory.parameterizeUrl(KRADConstants.INQUIRY_ACTION, params), "view");
049                    viewUrl.setDisplayText("view");
050                    viewUrl.setTarget(AnchorHtmlData.TARGET_BLANK);
051                    customActionUrls.add(viewUrl);
052                    
053                    return customActionUrls;
054            }
055            
056        @Override
057        public List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues){
058            String hrSalGroup = fieldValues.get("hrSalGroup");
059            String descr = fieldValues.get("descr");
060            String fromEffdt = TKUtils.getFromDateString(fieldValues.get("effectiveDate"));
061            String toEffdt = TKUtils.getToDateString(fieldValues.get("effectiveDate"));
062            String active = fieldValues.get("active");
063            String showHist = fieldValues.get("history");
064    
065            if (StringUtils.equals(hrSalGroup, "%")) {
066                hrSalGroup = "";
067            }
068            
069            return TkServiceLocator.getSalGroupService().getSalGroups(hrSalGroup, descr, TKUtils.formatDateString(fromEffdt),
070                    TKUtils.formatDateString(toEffdt), active, showHist);
071        }
072    
073    }