Project

General

Profile

Download (2.22 KB) Statistics
| Branch: | Tag: | Revision:
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.Propagation;
20
import org.springframework.transaction.annotation.Transactional;
21

    
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;
27

    
28
@Service
29
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
30
public class AuditEventService implements IAuditEventService {
31
	
32
	IAuditEventDao dao;
33
	
34
	@Autowired
35
	public void setDao(IAuditEventDao dao) {
36
		this.dao = dao;
37
	}
38

    
39
	public boolean exists(UUID uuid) {
40
		return dao.exists(uuid);
41
	}
42

    
43
	public AuditEvent find(Integer id) {
44
		return dao.findById(id);
45
	}
46

    
47
	public AuditEvent find(UUID uuid) {
48
		return dao.findByUuid(uuid);
49
	}
50

    
51
	public AuditEvent getNextAuditEvent(AuditEvent auditEvent) {
52
		return dao.getNextAuditEvent(auditEvent);
53
	}
54

    
55
	public AuditEvent getPreviousAuditEvent(AuditEvent auditEvent) {
56
		return dao.getPreviousAuditEvent(auditEvent);
57
	}
58

    
59
	public Pager<AuditEvent> list(Integer pageNumber, Integer pageSize,	AuditEventSort sort) {
60
		 Integer numberOfResults = dao.count();
61
			
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); 
65
		}
66
			
67
		return new DefaultPagerImpl<AuditEvent>(pageNumber, numberOfResults, pageSize, results);
68
	}
69

    
70
	public AuditEvent find(DateTime dateTime) {
71
		return dao.findByDate(dateTime);
72
	}
73
}
(6-6/76)