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
.transaction
.annotation
.Transactional
;
18 import eu
.etaxonomy
.cdm
.api
.service
.pager
.Pager
;
19 import eu
.etaxonomy
.cdm
.api
.service
.pager
.impl
.DefaultPagerImpl
;
20 import eu
.etaxonomy
.cdm
.model
.common
.AnnotatableEntity
;
21 import eu
.etaxonomy
.cdm
.model
.common
.Annotation
;
22 import eu
.etaxonomy
.cdm
.model
.common
.MarkerType
;
23 import eu
.etaxonomy
.cdm
.persistence
.dao
.common
.IAnnotatableDao
;
24 import eu
.etaxonomy
.cdm
.persistence
.query
.OrderHint
;
26 @Transactional(readOnly
= true)
27 public abstract class AnnotatableServiceBase
<T
extends AnnotatableEntity
,DAO
extends IAnnotatableDao
<T
>> extends VersionableServiceBase
<T
, DAO
>
28 implements IAnnotatableService
<T
> {
30 public Pager
<Annotation
> getAnnotations(T annotatedObj
, MarkerType status
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
) {
31 Integer numberOfResults
= dao
.countAnnotations(annotatedObj
, status
);
33 List
<Annotation
> results
= new ArrayList
<Annotation
>();
34 if(numberOfResults
> 0) { // no point checking again
35 results
= dao
.getAnnotations(annotatedObj
, status
, pageSize
, pageNumber
, orderHints
, propertyPaths
);
38 return new DefaultPagerImpl
<Annotation
>(pageNumber
, numberOfResults
, pageSize
, results
);