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.
11 package eu
.etaxonomy
.cdm
.api
.service
;
13 import java
.util
.ArrayList
;
14 import java
.util
.List
;
16 import org
.springframework
.beans
.factory
.annotation
.Autowired
;
17 import org
.springframework
.stereotype
.Service
;
18 import org
.springframework
.transaction
.annotation
.Transactional
;
20 import eu
.etaxonomy
.cdm
.api
.service
.pager
.Pager
;
21 import eu
.etaxonomy
.cdm
.api
.service
.pager
.impl
.DefaultPagerImpl
;
22 import eu
.etaxonomy
.cdm
.model
.agent
.Person
;
23 import eu
.etaxonomy
.cdm
.model
.common
.Annotation
;
24 import eu
.etaxonomy
.cdm
.model
.common
.MarkerType
;
25 import eu
.etaxonomy
.cdm
.persistence
.dao
.hibernate
.common
.AnnotationDaoImpl
;
26 import eu
.etaxonomy
.cdm
.persistence
.query
.OrderHint
;
29 @Transactional(readOnly
=true)
30 public class AnnotationService
extends AnnotatableServiceBase
<Annotation
, AnnotationDaoImpl
> implements
34 protected void setDao(AnnotationDaoImpl dao
) {
38 public int count(Person commentator
, MarkerType status
) {
39 return dao
.count(commentator
, status
);
42 public Pager
<Annotation
> list(Person commentator
, MarkerType status
,Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
) {
43 Integer numberOfResults
= dao
.count(commentator
, status
);
45 List
<Annotation
> results
= new ArrayList
<Annotation
>();
46 if(numberOfResults
> 0) { // no point checking again
47 results
= dao
.list(commentator
, status
, pageSize
, pageNumber
, orderHints
, propertyPaths
);
50 return new DefaultPagerImpl
<Annotation
>(pageNumber
, numberOfResults
, pageSize
, results
);