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.workschedule.service;
17  
18  import java.util.List;
19  
20  import org.kuali.hr.time.util.TKContext;
21  import org.kuali.hr.time.workschedule.WorkSchedule;
22  import org.kuali.rice.kns.lookup.HtmlData;
23  import org.kuali.rice.kns.lookup.KualiLookupableHelperServiceImpl;
24  import org.kuali.rice.krad.bo.BusinessObject;
25  
26  public class WorkScheduleLookupableHelper extends
27  		KualiLookupableHelperServiceImpl {
28  	/**
29  	 * 
30  	 */
31  	private static final long serialVersionUID = 1L;
32  
33  	@Override
34  	public List<HtmlData> getCustomActionUrls(BusinessObject businessObject,
35  			List pkNames) {
36  		List<HtmlData> customActionUrls = super.getCustomActionUrls(
37  				businessObject, pkNames);
38  		if (TKContext.getUser().isSystemAdmin() || TKContext.getUser().isGlobalViewOnly()) {
39  			WorkSchedule workSchedule = (WorkSchedule) businessObject;
40  			final String className = this.getBusinessObjectClass().getName();
41  			final Long hrWorkScheduleId = workSchedule.getHrWorkSchedule();
42  			HtmlData htmlData = new HtmlData() {
43  
44  				@Override
45  				public String constructCompleteHtmlTag() {
46  					return "<a target=\"_blank\" href=\"inquiry.do?businessObjectClassName="
47  							+ className
48  							+ "&methodToCall=start&hrWorkScheduleId="
49  							+ hrWorkScheduleId + "\">view</a>";
50  				}
51  			};
52  			customActionUrls.add(htmlData);
53  		} else if (customActionUrls.size() != 0) {
54  			customActionUrls.remove(0);
55  		}
56  		return customActionUrls;
57  	}
58  
59  }