Project

General

Profile

Download (1.42 KB) Statistics
| Branch: | Tag: | Revision:
1
package eu.etaxonomy.cdm.api.service;
2

    
3
import java.util.ArrayList;
4
import java.util.List;
5

    
6
import org.springframework.beans.factory.annotation.Autowired;
7
import org.springframework.stereotype.Service;
8
import org.springframework.transaction.annotation.Propagation;
9
import org.springframework.transaction.annotation.Transactional;
10

    
11
import eu.etaxonomy.cdm.api.service.pager.Pager;
12
import eu.etaxonomy.cdm.api.service.pager.impl.DefaultPagerImpl;
13
import eu.etaxonomy.cdm.model.description.IIdentificationKey;
14
import eu.etaxonomy.cdm.persistence.dao.description.IIdentificationKeyDao;
15

    
16
@Service
17
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
18
public class IdentificationKeyServiceImpl implements IIdentificationKeyService {
19
	
20
	IIdentificationKeyDao dao;
21
	
22
	@Autowired
23
	public void setDao(IIdentificationKeyDao dao) {
24
		this.dao = dao;
25
	}
26

    
27
	public Pager<IIdentificationKey> page(Integer pageSize, Integer pageNumber,	List<String> propertyPaths) {
28
		Integer numberOfResults = dao.count();
29
		List<IIdentificationKey> results = new ArrayList<IIdentificationKey>();
30
		pageNumber = pageNumber == null ? 0 : pageNumber;
31
		if(numberOfResults > 0) { // no point checking again
32
			Integer start = pageSize == null ? 0 : pageSize * pageNumber;
33
			results = dao.list(pageSize, start, propertyPaths);
34
		}
35
		return new DefaultPagerImpl<IIdentificationKey>(pageNumber, numberOfResults, pageSize, results);
36
	}
37

    
38
}
(45-45/65)