1
|
package eu.etaxonomy.cdm.api.service;
|
2
|
|
3
|
import java.util.ArrayList;
|
4
|
import java.util.List;
|
5
|
import java.util.UUID;
|
6
|
|
7
|
import org.springframework.beans.factory.annotation.Autowired;
|
8
|
import org.springframework.stereotype.Service;
|
9
|
|
10
|
import eu.etaxonomy.cdm.api.service.pager.Pager;
|
11
|
import eu.etaxonomy.cdm.api.service.pager.impl.DefaultPagerImpl;
|
12
|
import eu.etaxonomy.cdm.model.view.AuditEvent;
|
13
|
import eu.etaxonomy.cdm.persistence.dao.common.AuditEventSort;
|
14
|
import eu.etaxonomy.cdm.persistence.view.IAuditEventDao;
|
15
|
|
16
|
@Service
|
17
|
public class AuditEventService implements IAuditEventService {
|
18
|
|
19
|
IAuditEventDao dao;
|
20
|
|
21
|
@Autowired
|
22
|
public void setDao(IAuditEventDao dao) {
|
23
|
this.dao = dao;
|
24
|
}
|
25
|
|
26
|
public boolean exists(UUID uuid) {
|
27
|
return dao.exists(uuid);
|
28
|
}
|
29
|
|
30
|
public AuditEvent findById(Integer id) {
|
31
|
return dao.findById(id);
|
32
|
}
|
33
|
|
34
|
public AuditEvent findByUuid(UUID uuid) {
|
35
|
return dao.findByUuid(uuid);
|
36
|
}
|
37
|
|
38
|
public AuditEvent getNextAuditEvent(AuditEvent auditEvent) {
|
39
|
return dao.getNextAuditEvent(auditEvent);
|
40
|
}
|
41
|
|
42
|
public AuditEvent getPreviousAuditEvent(AuditEvent auditEvent) {
|
43
|
return dao.getPreviousAuditEvent(auditEvent);
|
44
|
}
|
45
|
|
46
|
public Pager<AuditEvent> list(Integer pageNumber, Integer pageSize, AuditEventSort sort) {
|
47
|
Integer numberOfResults = dao.count();
|
48
|
|
49
|
List<AuditEvent> results = new ArrayList<AuditEvent>();
|
50
|
if(numberOfResults > 0) { // no point checking again
|
51
|
results = dao.list(pageNumber, pageSize, sort);
|
52
|
}
|
53
|
|
54
|
return new DefaultPagerImpl<AuditEvent>(pageNumber, numberOfResults, pageSize, results);
|
55
|
}
|
56
|
}
|