View Javadoc

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