1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.sys.batch;
17
18 import java.sql.Timestamp;
19 import java.util.Calendar;
20 import java.util.Date;
21
22 import org.kuali.ole.sys.OLEConstants;
23 import org.kuali.ole.sys.service.impl.OleParameterConstants;
24 import org.kuali.rice.kns.lookup.LookupResultsService;
25
26 public class PurgeOldLookupResultsStep extends AbstractStep {
27 private LookupResultsService lookupResultsService;
28
29 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(PurgeOldLookupResultsStep.class);
30
31
32
33
34 public boolean execute(String jobName, Date jobRunDate) {
35 try {
36 LOG.info("executing PurgeOldLookupResultsStep");
37
38 String maxAgeInSecondsStr = getParameterService().getParameterValueAsString(OleParameterConstants.NERVOUS_SYSTEM_LOOKUP.class, OLEConstants.SystemGroupParameterNames.MULTIPLE_VALUE_LOOKUP_RESULTS_EXPIRATION_AGE);
39 int maxAgeInSeconds = Integer.parseInt(maxAgeInSecondsStr);
40
41 Calendar expirationCal = getDateTimeService().getCurrentCalendar();
42 expirationCal.add(Calendar.SECOND, -maxAgeInSeconds);
43 Timestamp expirationDate = new Timestamp(expirationCal.getTime().getTime());
44
45 lookupResultsService.deleteOldLookupResults(expirationDate);
46 lookupResultsService.deleteOldSelectedObjectIds(expirationDate);
47 return true;
48 }
49 catch (Exception e) {
50 LOG.error("error occured trying to purge old lookup results: ", e);
51 return false;
52 }
53 }
54
55 public LookupResultsService getLookupResultsService() {
56 return lookupResultsService;
57 }
58
59 public void setLookupResultsService(LookupResultsService lookupResultsService) {
60 this.lookupResultsService = lookupResultsService;
61 }
62
63
64 }