1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2007 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
7
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
8
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
9
|
*/
|
10
|
package eu.etaxonomy.cdm.api.service;
|
11
|
|
12
|
import java.util.ArrayList;
|
13
|
import java.util.List;
|
14
|
import java.util.UUID;
|
15
|
|
16
|
import org.joda.time.DateTime;
|
17
|
import org.springframework.beans.factory.annotation.Autowired;
|
18
|
import org.springframework.stereotype.Service;
|
19
|
import org.springframework.transaction.annotation.Transactional;
|
20
|
|
21
|
import eu.etaxonomy.cdm.api.service.pager.Pager;
|
22
|
import eu.etaxonomy.cdm.api.service.pager.impl.DefaultPagerImpl;
|
23
|
import eu.etaxonomy.cdm.model.view.AuditEvent;
|
24
|
import eu.etaxonomy.cdm.persistence.dao.common.AuditEventSort;
|
25
|
import eu.etaxonomy.cdm.persistence.view.IAuditEventDao;
|
26
|
|
27
|
@Service
|
28
|
@Transactional(readOnly = true)
|
29
|
public class AuditEventService implements IAuditEventService {
|
30
|
|
31
|
IAuditEventDao dao;
|
32
|
|
33
|
@Autowired
|
34
|
public void setDao(IAuditEventDao dao) {
|
35
|
this.dao = dao;
|
36
|
}
|
37
|
|
38
|
public boolean exists(UUID uuid) {
|
39
|
return dao.exists(uuid);
|
40
|
}
|
41
|
|
42
|
public AuditEvent find(Integer id) {
|
43
|
return dao.findById(id);
|
44
|
}
|
45
|
|
46
|
public AuditEvent find(UUID uuid) {
|
47
|
return dao.findByUuid(uuid);
|
48
|
}
|
49
|
|
50
|
public AuditEvent getNextAuditEvent(AuditEvent auditEvent) {
|
51
|
return dao.getNextAuditEvent(auditEvent);
|
52
|
}
|
53
|
|
54
|
public AuditEvent getPreviousAuditEvent(AuditEvent auditEvent) {
|
55
|
return dao.getPreviousAuditEvent(auditEvent);
|
56
|
}
|
57
|
|
58
|
public Pager<AuditEvent> list(Integer pageNumber, Integer pageSize, AuditEventSort sort) {
|
59
|
Integer numberOfResults = dao.count();
|
60
|
|
61
|
List<AuditEvent> results = new ArrayList<AuditEvent>();
|
62
|
if(numberOfResults > 0) { // no point checking again //TODO use AbstractPagerImpl.hasResultsInRange(numberOfResults, pageNumber, pageSize)
|
63
|
results = dao.list(pageNumber, pageSize, sort);
|
64
|
}
|
65
|
|
66
|
return new DefaultPagerImpl<AuditEvent>(pageNumber, numberOfResults, pageSize, results);
|
67
|
}
|
68
|
|
69
|
public AuditEvent find(DateTime dateTime) {
|
70
|
return dao.findByDate(dateTime);
|
71
|
}
|
72
|
}
|