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
.Propagation
;
20 import org
.springframework
.transaction
.annotation
.Transactional
;
22 import eu
.etaxonomy
.cdm
.api
.service
.pager
.Pager
;
23 import eu
.etaxonomy
.cdm
.api
.service
.pager
.impl
.DefaultPagerImpl
;
24 import eu
.etaxonomy
.cdm
.model
.view
.AuditEvent
;
25 import eu
.etaxonomy
.cdm
.persistence
.dao
.common
.AuditEventSort
;
26 import eu
.etaxonomy
.cdm
.persistence
.view
.IAuditEventDao
;
29 @Transactional(readOnly
= true)
30 public class AuditEventService
implements IAuditEventService
{
35 public void setDao(IAuditEventDao dao
) {
39 public boolean exists(UUID uuid
) {
40 return dao
.exists(uuid
);
43 public AuditEvent
find(Integer id
) {
44 return dao
.findById(id
);
47 public AuditEvent
find(UUID uuid
) {
48 return dao
.findByUuid(uuid
);
51 public AuditEvent
getNextAuditEvent(AuditEvent auditEvent
) {
52 return dao
.getNextAuditEvent(auditEvent
);
55 public AuditEvent
getPreviousAuditEvent(AuditEvent auditEvent
) {
56 return dao
.getPreviousAuditEvent(auditEvent
);
59 public Pager
<AuditEvent
> list(Integer pageNumber
, Integer pageSize
, AuditEventSort sort
) {
60 Integer numberOfResults
= dao
.count();
62 List
<AuditEvent
> results
= new ArrayList
<AuditEvent
>();
63 if(numberOfResults
> 0) { // no point checking again //TODO use AbstractPagerImpl.hasResultsInRange(numberOfResults, pageNumber, pageSize)
64 results
= dao
.list(pageNumber
, pageSize
, sort
);
67 return new DefaultPagerImpl
<AuditEvent
>(pageNumber
, numberOfResults
, pageSize
, results
);
70 public AuditEvent
find(DateTime dateTime
) {
71 return dao
.findByDate(dateTime
);