2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * 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
;
15 import org
.springframework
.beans
.factory
.annotation
.Autowired
;
16 import org
.springframework
.stereotype
.Service
;
17 import org
.springframework
.transaction
.annotation
.Transactional
;
19 import eu
.etaxonomy
.cdm
.api
.service
.pager
.Pager
;
20 import eu
.etaxonomy
.cdm
.api
.service
.pager
.impl
.DefaultPagerImpl
;
21 import eu
.etaxonomy
.cdm
.model
.agent
.Person
;
22 import eu
.etaxonomy
.cdm
.model
.common
.Annotation
;
23 import eu
.etaxonomy
.cdm
.model
.common
.MarkerType
;
24 import eu
.etaxonomy
.cdm
.model
.common
.User
;
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
35 protected void setDao(AnnotationDaoImpl dao
) {
40 public long count(Person commentator
, MarkerType status
) {
41 return dao
.count(commentator
, status
);
45 public Pager
<Annotation
> list(Person commentator
, MarkerType status
,Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
) {
46 Long numberOfResults
= dao
.count(commentator
, status
);
48 List
<Annotation
> results
= new ArrayList
<Annotation
>();
49 if(numberOfResults
> 0) { // no point checking again //TODO use AbstractPagerImpl.hasResultsInRange(numberOfResults, pageNumber, pageSize)
50 results
= dao
.list(commentator
, status
, pageSize
, pageNumber
, orderHints
, propertyPaths
);
53 return new DefaultPagerImpl
<Annotation
>(pageNumber
, numberOfResults
, pageSize
, results
);
57 public long count(User creator
, MarkerType status
) {
58 return dao
.count(creator
, status
);
62 public Pager
<Annotation
> list(User creator
, MarkerType status
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
,
63 List
<String
> propertyPaths
) {
64 long numberOfResults
= dao
.count(creator
, status
);
66 List
<Annotation
> results
= new ArrayList
<>();
67 if(numberOfResults
> 0) { // no point checking again //TODO use AbstractPagerImpl.hasResultsInRange(numberOfResults, pageNumber, pageSize)
68 results
= dao
.list(creator
, status
, pageSize
, pageNumber
, orderHints
, propertyPaths
);
71 return new DefaultPagerImpl
<Annotation
>(pageNumber
, numberOfResults
, pageSize
, results
);