View Javadoc

1   /**
2    * Copyright 2004-2014 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.kpme.core.job.web;
17  
18  import java.util.List;
19  import java.util.Map;
20  import java.util.Properties;
21  
22  import org.kuali.kpme.core.job.Job;
23  import org.kuali.kpme.core.lookup.KPMELookupableHelper;
24  import org.kuali.kpme.core.service.HrServiceLocator;
25  import org.kuali.kpme.core.util.TKUtils;
26  import org.kuali.rice.kns.lookup.HtmlData;
27  import org.kuali.rice.kns.lookup.HtmlData.AnchorHtmlData;
28  import org.kuali.rice.krad.bo.BusinessObject;
29  import org.kuali.rice.krad.util.GlobalVariables;
30  import org.kuali.rice.krad.util.KRADConstants;
31  import org.kuali.rice.krad.util.UrlFactory;
32  
33  @SuppressWarnings("deprecation")
34  public class JobLookupableHelper extends KPMELookupableHelper {
35  
36  	private static final long serialVersionUID = 3233495722838070429L;
37  
38  	@Override
39  	@SuppressWarnings("rawtypes")
40      public List<HtmlData> getCustomActionUrls(BusinessObject businessObject, List pkNames) {
41      	List<HtmlData> customActionUrls = super.getCustomActionUrls(businessObject, pkNames);
42  
43  		Job job = (Job) businessObject;
44          String hrJobId = job.getHrJobId();
45  		
46  		Properties params = new Properties();
47  		params.put(KRADConstants.BUSINESS_OBJECT_CLASS_ATTRIBUTE, getBusinessObjectClass().getName());
48  		params.put(KRADConstants.DISPATCH_REQUEST_PARAMETER, KRADConstants.MAINTENANCE_NEW_METHOD_TO_CALL);
49  		
50  		params.put("hrJobId", hrJobId);
51  		
52  		AnchorHtmlData viewUrl = new AnchorHtmlData(UrlFactory.parameterizeUrl(KRADConstants.INQUIRY_ACTION, params), "view");
53  		viewUrl.setDisplayText("view");
54  		viewUrl.setTarget(AnchorHtmlData.TARGET_BLANK);
55  		customActionUrls.add(viewUrl);
56  		
57  		//	Add copy link - KPME-3059
58  		customActionUrls.add(getUrlData(job, KRADConstants.MAINTENANCE_COPY_METHOD_TO_CALL, pkNames));
59  		
60  		return customActionUrls;
61      }
62  
63      @Override
64      public List<? extends BusinessObject> getSearchResults(Map<String, String> fieldValues) {
65          String principalId = fieldValues.get("principalId");
66          String firstName = fieldValues.get("firstName");
67          String lastName = fieldValues.get("lastName");
68          String jobNumber = fieldValues.get("jobNumber");
69          String dept = fieldValues.get("dept");
70          String positionNumber = fieldValues.get("positionNumber");
71          String hrPayType = fieldValues.get("hrPayType");
72          String fromEffdt = TKUtils.getFromDateString(fieldValues.get("effectiveDate"));
73          String toEffdt = TKUtils.getToDateString(fieldValues.get("effectiveDate"));
74          String active = fieldValues.get("active");
75          String showHist = fieldValues.get("history");
76  
77          return HrServiceLocator.getJobService().getJobs(GlobalVariables.getUserSession().getPrincipalId(), principalId, firstName, lastName, jobNumber, dept, positionNumber, hrPayType, 
78          		TKUtils.formatDateString(fromEffdt), TKUtils.formatDateString(toEffdt), active, showHist);
79      }
80  
81  }