001 /**
002 * Copyright 2004-2013 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.lm.leavecode.service;
017
018 import java.util.ArrayList;
019 import java.util.List;
020
021 import org.apache.commons.lang.StringUtils;
022 import org.kuali.hr.lm.leavecode.LeaveCode;
023 import org.kuali.hr.time.HrEffectiveDateActiveLookupableHelper;
024 import org.kuali.hr.time.util.TKContext;
025 import org.kuali.rice.kns.lookup.HtmlData;
026 import org.kuali.rice.krad.bo.BusinessObject;
027
028 /**
029 * Used to override lookup functionality for the leave accrual category lookup
030 *
031 *
032 */
033 public class LeaveCodeLookupableHelper extends
034 HrEffectiveDateActiveLookupableHelper {
035 /**
036 *
037 */
038 private static final long serialVersionUID = 1L;
039
040 @Override
041 public List<HtmlData> getCustomActionUrls(BusinessObject businessObject,
042 List pkNames) {
043 List<HtmlData> customActionUrls = super.getCustomActionUrls(
044 businessObject, pkNames);
045 List<HtmlData> overrideUrls = new ArrayList<HtmlData>();
046 for(HtmlData actionUrl : customActionUrls){
047 if(!StringUtils.equals(actionUrl.getMethodToCall(), "copy")){
048 overrideUrls.add(actionUrl);
049 }
050 }
051
052 if (TKContext.getUser().isSystemAdmin()) {
053 LeaveCode leaveCode = (LeaveCode) businessObject;
054 final String className = this.getBusinessObjectClass().getName();
055 final String lmLeaveCodeId = leaveCode
056 .getLmLeaveCodeId();
057 HtmlData htmlData = new HtmlData() {
058
059 @Override
060 public String constructCompleteHtmlTag() {
061 return "<a target=\"_blank\" href=\"inquiry.do?businessObjectClassName="
062 + className
063 + "&methodToCall=start&lmLeaveCodeId="
064 + lmLeaveCodeId + "\">view</a>";
065 }
066 };
067 overrideUrls.add(htmlData);
068 } else if (overrideUrls.size() != 0) {
069 overrideUrls.remove(0);
070 }
071 return overrideUrls;
072 }
073
074 }