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.lm.employeeoverride.service;
017    
018    import java.util.List;
019    import java.util.Map;
020    import java.util.Properties;
021    
022    import org.kuali.hr.lm.employeeoverride.EmployeeOverride;
023    import org.kuali.hr.time.HrEffectiveDateActiveLookupableHelper;
024    import org.kuali.hr.time.service.base.TkServiceLocator;
025    import org.kuali.hr.time.util.TKUtils;
026    import org.kuali.rice.kns.lookup.HtmlData;
027    import org.kuali.rice.kns.lookup.HtmlData.AnchorHtmlData;
028    import org.kuali.rice.krad.bo.BusinessObject;
029    import org.kuali.rice.krad.util.KRADConstants;
030    import org.kuali.rice.krad.util.UrlFactory;
031    
032    public class EmployeeOverrideLookupableHelper extends HrEffectiveDateActiveLookupableHelper  {
033    
034            private static final long serialVersionUID = -2208016099188014844L;
035    
036            @Override
037            public List<HtmlData> getCustomActionUrls(BusinessObject businessObject, List pkNames) {
038                    List<HtmlData> customActionUrls = super.getCustomActionUrls(businessObject, pkNames);
039                    
040                    EmployeeOverride employeeOverride = (EmployeeOverride) businessObject;
041                    String lmEmployeeOverrideId = employeeOverride.getLmEmployeeOverrideId();
042                    
043                    Properties params = new Properties();
044                    params.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, getBusinessObjectClass().getName());
045                    params.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, KRADConstants.MAINTENANCE_NEW_METHOD_TO_CALL);
046                    params.put("lmEmployeeOverrideId", lmEmployeeOverrideId);
047                    AnchorHtmlData viewUrl = new AnchorHtmlData(UrlFactory.parameterizeUrl(KRADConstants.INQUIRY_ACTION, params), "view");
048                    viewUrl.setDisplayText("view");
049                    viewUrl.setTarget(AnchorHtmlData.TARGET_BLANK);
050                    customActionUrls.add(viewUrl);
051                    
052                    return customActionUrls;
053            }
054    
055        @Override
056        public List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues) {
057            String principalId = fieldValues.get("principalId");
058            String leavePlan = fieldValues.get("leavePlan");
059            String accrualCategory = fieldValues.get("accrualCategory");
060            String overrideType = fieldValues.get("overrideType");
061            String fromEffdt = TKUtils.getFromDateString(fieldValues.get("effectiveDate"));
062            String toEffdt = TKUtils.getToDateString(fieldValues.get("effectiveDate"));
063            String active = fieldValues.get("active");
064    
065            return TkServiceLocator.getEmployeeOverrideService().getEmployeeOverrides(principalId, leavePlan, accrualCategory, overrideType, 
066                            TKUtils.formatDateString(fromEffdt), TKUtils.formatDateString(toEffdt), active);
067        }
068            
069    }