3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.api
.service
;
12 import java
.util
.ArrayList
;
13 import java
.util
.List
;
14 import java
.util
.UUID
;
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
;
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
;
28 @Transactional(readOnly
=true)
29 public class AuditEventService
implements IAuditEventService
{
34 public void setDao(IAuditEventDao dao
) {
38 public boolean exists(UUID uuid
) {
39 return dao
.exists(uuid
);
42 public AuditEvent
find(Integer id
) {
43 return dao
.findById(id
);
46 public AuditEvent
find(UUID uuid
) {
47 return dao
.findByUuid(uuid
);
50 public AuditEvent
getNextAuditEvent(AuditEvent auditEvent
) {
51 return dao
.getNextAuditEvent(auditEvent
);
54 public AuditEvent
getPreviousAuditEvent(AuditEvent auditEvent
) {
55 return dao
.getPreviousAuditEvent(auditEvent
);
58 public Pager
<AuditEvent
> list(Integer pageNumber
, Integer pageSize
, AuditEventSort sort
) {
59 Integer numberOfResults
= dao
.count();
61 List
<AuditEvent
> results
= new ArrayList
<AuditEvent
>();
62 if(numberOfResults
> 0) { // no point checking again
63 results
= dao
.list(pageNumber
, pageSize
, sort
);
66 return new DefaultPagerImpl
<AuditEvent
>(pageNumber
, numberOfResults
, pageSize
, results
);
69 public AuditEvent
find(DateTime dateTime
) {
70 return dao
.findByDate(dateTime
);