1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.batch.dao;
17
18 import java.util.ArrayList;
19 import java.util.Collection;
20 import java.util.List;
21
22 import org.apache.ojb.broker.query.Criteria;
23 import org.apache.ojb.broker.query.Query;
24 import org.apache.ojb.broker.query.QueryFactory;
25 import org.kuali.hr.time.batch.BatchJob;
26 import org.kuali.hr.time.service.base.TkServiceLocator;
27 import org.kuali.rice.core.framework.persistence.ojb.dao.PlatformAwareDaoBaseOjb;
28 import org.springframework.transaction.TransactionStatus;
29 import org.springframework.transaction.support.TransactionCallbackWithoutResult;
30
31 public class BatchJobDaoSpringOjbImpl extends PlatformAwareDaoBaseOjb implements BatchJobDao {
32
33 public void saveOrUpdate(final BatchJob batchJob) {
34 TkServiceLocator.getTransactionTemplate().execute(new TransactionCallbackWithoutResult() {
35 @Override
36 protected void doInTransactionWithoutResult(TransactionStatus status) {
37 getPersistenceBrokerTemplate().store(batchJob);
38 }
39 });
40 }
41
42 public BatchJob getBatchJob(Long batchJobId){
43 Criteria currentRecordCriteria = new Criteria();
44 currentRecordCriteria.addEqualTo("tkBatchJobId", batchJobId);
45
46 return (BatchJob) this.getPersistenceBrokerTemplate().getObjectByQuery(QueryFactory.newQuery(BatchJob.class, currentRecordCriteria));
47 }
48
49 @Override
50 public List<BatchJob> getBatchJobs(String hrPyCalendarEntryId) {
51 Criteria root = new Criteria();
52 root.addEqualTo("hrPyCalendarEntryId", hrPyCalendarEntryId);
53 Query query = QueryFactory.newQuery(BatchJob.class, root);
54
55 Collection c = this.getPersistenceBrokerTemplate().getCollectionByQuery(query);
56 List<BatchJob> jobs = new ArrayList<BatchJob>();
57 jobs.addAll(c);
58
59 return jobs;
60 }
61
62 @Override
63 public List<BatchJob> getPayCalendarEntries(String hrPyCalendarEntryId, String batchJobStatus) {
64 Criteria root = new Criteria();
65 root.addEqualTo("hrPyCalendarEntryId", hrPyCalendarEntryId);
66 root.addEqualTo("batchJobStatus", batchJobStatus);
67 Query query = QueryFactory.newQuery(BatchJob.class, root);
68
69 Collection c = this.getPersistenceBrokerTemplate().getCollectionByQuery(query);
70 List<BatchJob> jobs = new ArrayList<BatchJob>();
71 jobs.addAll(c);
72
73 return jobs;
74 }
75 }