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
.Propagation
;
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
.agent
.Person
;
24 import eu
.etaxonomy
.cdm
.model
.common
.Annotation
;
25 import eu
.etaxonomy
.cdm
.model
.common
.MarkerType
;
26 import eu
.etaxonomy
.cdm
.model
.common
.User
;
27 import eu
.etaxonomy
.cdm
.persistence
.dao
.hibernate
.common
.AnnotationDaoImpl
;
28 import eu
.etaxonomy
.cdm
.persistence
.query
.OrderHint
;
31 @Transactional(propagation
= Propagation
.SUPPORTS
, readOnly
= true)
32 public class AnnotationService
extends AnnotatableServiceBase
<Annotation
, AnnotationDaoImpl
> implements
36 protected void setDao(AnnotationDaoImpl dao
) {
40 public int count(Person commentator
, MarkerType status
) {
41 return dao
.count(commentator
, status
);
44 public Pager
<Annotation
> list(Person commentator
, MarkerType status
,Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
) {
45 Integer numberOfResults
= dao
.count(commentator
, status
);
47 List
<Annotation
> results
= new ArrayList
<Annotation
>();
48 if(numberOfResults
> 0) { // no point checking again
49 results
= dao
.list(commentator
, status
, pageSize
, pageNumber
, orderHints
, propertyPaths
);
52 return new DefaultPagerImpl
<Annotation
>(pageNumber
, numberOfResults
, pageSize
, results
);
55 public int count(User creator
, MarkerType status
) {
56 return dao
.count(creator
, status
);
59 public Pager
<Annotation
> list(User creator
, MarkerType status
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
,
60 List
<String
> propertyPaths
) {
61 Integer numberOfResults
= dao
.count(creator
, status
);
63 List
<Annotation
> results
= new ArrayList
<Annotation
>();
64 if(numberOfResults
> 0) { // no point checking again
65 results
= dao
.list(creator
, status
, pageSize
, pageNumber
, orderHints
, propertyPaths
);
68 return new DefaultPagerImpl
<Annotation
>(pageNumber
, numberOfResults
, pageSize
, results
);