View Javadoc

1   /**
2    * Copyright 2004-2013 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.hr.time.overtime.daily.rule.service;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  import java.util.Properties;
21  
22  import org.apache.commons.lang.StringUtils;
23  import org.kuali.hr.time.HrEffectiveDateActiveLookupableHelper;
24  import org.kuali.hr.time.overtime.daily.rule.DailyOvertimeRule;
25  import org.kuali.hr.time.util.TKContext;
26  import org.kuali.hr.time.util.TKUser;
27  import org.kuali.rice.kns.lookup.HtmlData;
28  import org.kuali.rice.kns.lookup.HtmlData.AnchorHtmlData;
29  import org.kuali.rice.krad.bo.BusinessObject;
30  import org.kuali.rice.krad.util.KRADConstants;
31  import org.kuali.rice.krad.util.UrlFactory;
32  
33  public class DailyOvertimeRuleLookupableHelper extends HrEffectiveDateActiveLookupableHelper {
34  
35  	private static final long serialVersionUID = 2720495398967391250L;
36  
37  
38  	@SuppressWarnings("rawtypes")
39  	@Override
40  	public List<HtmlData> getCustomActionUrls(BusinessObject businessObject, List pkNames) {
41  		List<HtmlData> customActionUrls = new ArrayList<HtmlData>();
42  		
43  		List<HtmlData> defaultCustomActionUrls = super.getCustomActionUrls(businessObject, pkNames);
44  		
45  		DailyOvertimeRule dailyOvertimeRule = (DailyOvertimeRule) businessObject;
46  		String tkDailyOvertimeRuleId = dailyOvertimeRule.getTkDailyOvertimeRuleId();
47  		
48  		boolean systemAdmin = TKUser.isSystemAdmin();
49  
50  		for (HtmlData defaultCustomActionUrl : defaultCustomActionUrls){
51  			if (StringUtils.equals(defaultCustomActionUrl.getMethodToCall(), "edit")) {
52  				if (systemAdmin) {
53  					customActionUrls.add(defaultCustomActionUrl);
54  				}
55  			} else {
56  				customActionUrls.add(defaultCustomActionUrl);
57  			}
58  		}
59  		
60  		Properties params = new Properties();
61  		params.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, getBusinessObjectClass().getName());
62  		params.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, KRADConstants.MAINTENANCE_NEW_METHOD_TO_CALL);
63  		params.put("tkDailyOvertimeRuleId", tkDailyOvertimeRuleId);
64  		AnchorHtmlData viewUrl = new AnchorHtmlData(UrlFactory.parameterizeUrl(KRADConstants.INQUIRY_ACTION, params), "view");
65  		viewUrl.setDisplayText("view");
66  		viewUrl.setTarget(AnchorHtmlData.TARGET_BLANK);
67  		customActionUrls.add(viewUrl);
68  		
69  		return customActionUrls;
70  	}
71  
72  
73  	@Override
74  	protected void validateSearchParameterWildcardAndOperators(
75  			String attributeName, String attributeValue) {
76  		if (!StringUtils.equals(attributeValue, "%")) {
77  			super.validateSearchParameterWildcardAndOperators(attributeName,
78  					attributeValue);
79  		}
80  	}
81  }