View Javadoc
1   /**
2    * Copyright 2004-2014 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.kpme.tklm.time.rules.overtime.daily.web;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  import java.util.Map;
21  import java.util.Properties;
22  
23  import org.apache.commons.lang.StringUtils;
24  import org.kuali.kpme.core.api.bo.HrBusinessObjectContract;
25  import org.kuali.kpme.core.lookup.KpmeHrBusinessObjectLookupableHelper;
26  import org.kuali.kpme.tklm.time.rules.overtime.daily.DailyOvertimeRule;
27  import org.kuali.kpme.tklm.time.service.TkServiceLocator;
28  import org.kuali.rice.kns.lookup.HtmlData;
29  import org.kuali.rice.krad.bo.BusinessObject;
30  import org.kuali.rice.krad.util.GlobalVariables;
31  import org.kuali.rice.krad.util.KRADConstants;
32  
33  @SuppressWarnings("deprecation")
34  public class DailyOvertimeRuleLookupableHelperServiceImpl extends KpmeHrBusinessObjectLookupableHelper {
35  
36  	private static final long serialVersionUID = 2720495398967391250L;
37  
38  	@Override
39  	@SuppressWarnings("rawtypes")
40  	public List<HtmlData> getCustomActionUrls(BusinessObject businessObject, List pkNames) {
41  		List<HtmlData> customActionUrls = super.getCustomActionUrls(businessObject, pkNames);
42  
43  		DailyOvertimeRule dailyOvertimeRule = (DailyOvertimeRule) businessObject;
44  		String tkDailyOvertimeRuleId = dailyOvertimeRule.getTkDailyOvertimeRuleId();
45  		
46  		Properties params = new Properties();
47  		params.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, getBusinessObjectClass().getName());
48  		params.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, KRADConstants.MAINTENANCE_NEW_METHOD_TO_CALL);
49  		params.put("tkDailyOvertimeRuleId", tkDailyOvertimeRuleId);
50  
51  		return customActionUrls;
52  	}
53  
54  
55  	@Override
56  	protected void validateSearchParameterWildcardAndOperators(
57  			String attributeName, String attributeValue) {
58  		if (!StringUtils.equals(attributeValue, "%")) {
59  			super.validateSearchParameterWildcardAndOperators(attributeName,
60  					attributeValue);
61  		}
62  	}
63  
64      public List<? extends HrBusinessObjectContract> getSearchResults(Map<String, String> fieldValues) {
65      	List<? extends HrBusinessObjectContract> temp = new ArrayList<HrBusinessObjectContract>();
66  		temp = super.getSearchResults(fieldValues);
67  		
68  		if ( temp != null ){
69  			List<DailyOvertimeRule> results = new ArrayList<DailyOvertimeRule>();
70  			for ( int i = 0; i < temp.size(); i++ ){
71  				DailyOvertimeRule dailyOvertimeRule = (DailyOvertimeRule)temp.get(i);
72  				results.add(dailyOvertimeRule);
73  			}
74  			
75  			return TkServiceLocator.getDailyOvertimeRuleService().getDailyOvertimeRules(GlobalVariables.getUserSession().getPrincipalId(), results);
76  		} else {
77  			return temp;
78  		}
79      }
80      
81  }