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.lm.leaveadjustment.service;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  import java.util.Properties;
21  
22  import org.kuali.hr.lm.leaveadjustment.LeaveAdjustment;
23  import org.kuali.hr.time.HrEffectiveDateActiveLookupableHelper;
24  import org.kuali.rice.kns.lookup.HtmlData;
25  import org.kuali.rice.kns.lookup.HtmlData.AnchorHtmlData;
26  import org.kuali.rice.krad.bo.BusinessObject;
27  import org.kuali.rice.krad.util.KRADConstants;
28  import org.kuali.rice.krad.util.UrlFactory;
29  
30  public class LeaveAdjustmentLookupableHelper extends HrEffectiveDateActiveLookupableHelper {
31  
32  	private static final long serialVersionUID = 8673584702786497392L;
33  
34  	@Override
35  	public List<HtmlData> getCustomActionUrls(BusinessObject businessObject, List pkNames) {
36  		List<HtmlData> customActionUrls = super.getCustomActionUrls(businessObject, pkNames);
37  		
38  		List<HtmlData> copyOfUrls = new ArrayList<HtmlData>();
39  		copyOfUrls.addAll(customActionUrls);
40  		for(HtmlData aData : copyOfUrls) {
41  			if(aData.getMethodToCall().equals(KRADConstants.MAINTENANCE_EDIT_METHOD_TO_CALL)) {
42  				customActionUrls.remove(aData);
43  			}
44  		}
45  		
46  		LeaveAdjustment leaveAdjustment = (LeaveAdjustment) businessObject;
47  		String lmLeaveAdjustmentId = leaveAdjustment.getLmLeaveAdjustmentId();
48  		
49  		Properties params = new Properties();
50  		params.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, getBusinessObjectClass().getName());
51  		params.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, KRADConstants.MAINTENANCE_NEW_METHOD_TO_CALL);
52  		params.put("lmLeaveAdjustmentId", lmLeaveAdjustmentId);
53  		AnchorHtmlData viewUrl = new AnchorHtmlData(UrlFactory.parameterizeUrl(KRADConstants.INQUIRY_ACTION, params), "view");
54  		viewUrl.setDisplayText("view");
55  		viewUrl.setTarget(AnchorHtmlData.TARGET_BLANK);
56  		customActionUrls.add(viewUrl);
57  		
58  		return customActionUrls;
59  	}
60  	
61  }