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.tklm.time.batch;
17  
18  import java.text.DateFormat;
19  import java.text.SimpleDateFormat;
20  import java.util.Date;
21  import java.util.List;
22  import java.util.Map;
23  
24  import org.apache.commons.lang.StringUtils;
25  import org.kuali.kpme.tklm.time.service.TkServiceLocator;
26  import org.kuali.rice.krad.lookup.LookupableImpl;
27  import org.kuali.rice.krad.util.ObjectUtils;
28  import org.kuali.rice.krad.web.form.LookupForm;
29  import org.quartz.SchedulerException;
30  
31  public class BatchJobLookupableImpl extends LookupableImpl {
32  
33  	@Override
34  	protected List<?> getSearchResults(LookupForm form,
35  			Map<String, String> searchCriteria, boolean unbounded) {
36  		// TODO Auto-generated method stub
37  		Date fromDate = null;
38  		Date toDate = null;
39  		String fromDateString = searchCriteria.get("startDate");
40  		String toDateString = searchCriteria.get("endDate");
41  		String jobName = searchCriteria.get("name");
42  		String jobStatus = searchCriteria.get("status");
43  		String hrCalendarEntryId = searchCriteria.get("hrCalendarEntryId");
44  		try {
45  			if (ObjectUtils.isNotNull(fromDateString) && StringUtils.isNotEmpty(fromDateString.trim())) {
46  	            DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
47  	            dateFormat.setLenient(false);
48  	            fromDate = dateFormat.parse(fromDateString);
49  	        }
50  			if (ObjectUtils.isNotNull(toDateString) && StringUtils.isNotEmpty(toDateString.trim())) {
51  	            DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
52  	            dateFormat.setLenient(false);
53  	            toDate = dateFormat.parse(toDateString);
54  	        }
55  			return TkServiceLocator.getBatchJobService().getJobs(jobName, jobStatus, hrCalendarEntryId, fromDate, toDate);
56  		} catch (Exception e) {
57  			// TODO Auto-generated catch block
58  			e.printStackTrace();
59  		}
60  		return null;
61  	}
62  
63  	
64  }