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 params.put("hrSalGroup", salGroup.getHrSalGroup());
049 AnchorHtmlData viewUrl = new AnchorHtmlData(UrlFactory.parameterizeUrl(KRADConstants.INQUIRY_ACTION, params), "view");
050 viewUrl.setDisplayText("view");
051 viewUrl.setTarget(AnchorHtmlData.TARGET_BLANK);
052 customActionUrls.add(viewUrl);
053
054 return customActionUrls;
055 }
056
057 @Override
058 public List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues){
059 String hrSalGroup = fieldValues.get("hrSalGroup");
060 String descr = fieldValues.get("descr");
061 String fromEffdt = TKUtils.getFromDateString(fieldValues.get("effectiveDate"));
062 String toEffdt = TKUtils.getToDateString(fieldValues.get("effectiveDate"));
063 String active = fieldValues.get("active");
064 String showHist = fieldValues.get("history");
065
066 if (StringUtils.equals(hrSalGroup, "%")) {
067 hrSalGroup = "";
068 }
069
070 return TkServiceLocator.getSalGroupService().getSalGroups(hrSalGroup, descr, TKUtils.formatDateString(fromEffdt),
071 TKUtils.formatDateString(toEffdt), active, showHist);
072 }
073
074 }