001 /** 002 * Copyright 2004-2012 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.hr.time.earngroup.service; 017 018 import org.apache.commons.lang.StringUtils; 019 import org.kuali.hr.time.HrEffectiveDateActiveLookupableHelper; 020 import org.kuali.hr.time.earngroup.EarnGroup; 021 import org.kuali.hr.time.util.TKContext; 022 import org.kuali.rice.kns.lookup.HtmlData; 023 import org.kuali.rice.krad.bo.BusinessObject; 024 025 import java.util.ArrayList; 026 import java.util.List; 027 028 public class EarnGroupLookupableHelper extends HrEffectiveDateActiveLookupableHelper { 029 /** 030 * 031 */ 032 private static final long serialVersionUID = 1L; 033 034 @Override 035 public List<HtmlData> getCustomActionUrls(BusinessObject businessObject, 036 @SuppressWarnings("rawtypes") List pkNames) { 037 List<HtmlData> customActionUrls = super.getCustomActionUrls( 038 businessObject, pkNames); 039 List<HtmlData> overrideUrls = new ArrayList<HtmlData>(); 040 for(HtmlData actionUrl : customActionUrls){ 041 if(!StringUtils.equals(actionUrl.getMethodToCall(), "copy")){ 042 overrideUrls.add(actionUrl); 043 } 044 } 045 if (TKContext.getUser().isSystemAdmin() || TKContext.getUser().isGlobalViewOnly()) { 046 EarnGroup earnGroupObj = (EarnGroup) businessObject; 047 final String className = this.getBusinessObjectClass().getName(); 048 final String earnGroup = earnGroupObj.getEarnGroup(); 049 final String hrEarnGroupId = earnGroupObj.getHrEarnGroupId(); 050 HtmlData htmlData = new HtmlData() { 051 052 /** 053 * 054 */ 055 private static final long serialVersionUID = 1L; 056 057 @Override 058 public String constructCompleteHtmlTag() { 059 return "<a target=\"_blank\" href=\"inquiry.do?businessObjectClassName=" 060 + className 061 + "&methodToCall=start&hrEarnGroupId=" 062 + hrEarnGroupId + "\">view</a>"; 063 } 064 }; 065 overrideUrls.add(htmlData); 066 } else if (overrideUrls.size() != 0) { 067 overrideUrls.remove(0); 068 } 069 return overrideUrls; 070 } 071 }