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.holidaycalendar.service;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  
21  import org.apache.commons.lang.StringUtils;
22  import org.kuali.hr.time.holidaycalendar.HolidayCalendar;
23  import org.kuali.hr.time.util.TKContext;
24  import org.kuali.rice.kns.lookup.HtmlData;
25  import org.kuali.rice.kns.lookup.KualiLookupableHelperServiceImpl;
26  import org.kuali.rice.krad.bo.BusinessObject;
27  
28  public class HolidayCalendarLookupableHelper extends
29  		KualiLookupableHelperServiceImpl {
30  	/**
31  	 * 
32  	 */
33  	private static final long serialVersionUID = 1L;
34  
35  	@Override
36  	public List<HtmlData> getCustomActionUrls(BusinessObject businessObject,
37  			List pkNames) {
38  		List<HtmlData> customActionUrls = super.getCustomActionUrls(
39  				businessObject, pkNames);
40  		List<HtmlData> overrideUrls = new ArrayList<HtmlData>();
41  		for(HtmlData actionUrl : customActionUrls){
42  			if(!StringUtils.equals(actionUrl.getMethodToCall(), "copy")){
43  				overrideUrls.add(actionUrl);
44  			}
45  		}
46  		if (TKContext.getUser().isSystemAdmin() || TKContext.getUser().isGlobalViewOnly()) {
47  			HolidayCalendar holidayCalendar = (HolidayCalendar) businessObject;
48  			final String className = this.getBusinessObjectClass().getName();
49  			final String hrHolidayCalendarId = holidayCalendar
50  					.getHrHolidayCalendarId();
51  			HtmlData htmlData = new HtmlData() {
52  
53  				@Override
54  				public String constructCompleteHtmlTag() {
55  					return "<a target=\"_blank\" href=\"inquiry.do?businessObjectClassName="
56  							+ className
57  							+ "&methodToCall=start&hrHolidayCalendarId="
58  							+ hrHolidayCalendarId + "\">view</a>";
59  				}
60  			};
61  			overrideUrls.add(htmlData);
62  		} else if (overrideUrls.size() != 0) {
63  			overrideUrls.remove(0);
64  		}
65  		return overrideUrls;
66  	}
67  }