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
.transaction
.annotation
.Transactional
;
17 import eu
.etaxonomy
.cdm
.api
.service
.pager
.Pager
;
18 import eu
.etaxonomy
.cdm
.api
.service
.pager
.impl
.DefaultPagerImpl
;
19 import eu
.etaxonomy
.cdm
.model
.common
.AnnotatableEntity
;
20 import eu
.etaxonomy
.cdm
.model
.common
.Annotation
;
21 import eu
.etaxonomy
.cdm
.model
.common
.Marker
;
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 public abstract class AnnotatableServiceBase
<T
extends AnnotatableEntity
,DAO
extends IAnnotatableDao
<T
>>
27 extends VersionableServiceBase
<T
, DAO
>
28 implements IAnnotatableService
<T
> {
31 @Transactional(readOnly
= true)
32 public Pager
<Annotation
> getAnnotations(T annotatedObj
, MarkerType status
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
) {
33 long numberOfResults
= dao
.countAnnotations(annotatedObj
, status
);
35 List
<Annotation
> results
= new ArrayList
<>();
36 if(numberOfResults
> 0) { // no point checking again //TODO use AbstractPagerImpl.hasResultsInRange(numberOfResults, pageNumber, pageSize)
37 results
= dao
.getAnnotations(annotatedObj
, status
, pageSize
, pageNumber
, orderHints
, propertyPaths
);
40 return new DefaultPagerImpl
<>(pageNumber
, numberOfResults
, pageSize
, results
);
44 @Transactional(readOnly
= true)
45 public Pager
<Marker
> getMarkers(T annotatableEntity
, Boolean technical
, Integer pageSize
, Integer pageNumber
, List
<OrderHint
> orderHints
, List
<String
> propertyPaths
) {
46 long numberOfResults
= dao
.countMarkers(annotatableEntity
, technical
);
48 List
<Marker
> results
= new ArrayList
<>();
49 if(numberOfResults
> 0) { // no point checking again //TODO use AbstractPagerImpl.hasResultsInRange(numberOfResults, pageNumber, pageSize)
50 results
= dao
.getMarkers(annotatableEntity
, technical
, pageSize
, pageNumber
, orderHints
, propertyPaths
);
53 return new DefaultPagerImpl
<>(pageNumber
, numberOfResults
, pageSize
, results
);
58 @Transactional(readOnly
= true)
59 public List
<Object
[]> groupMarkers(Class
<?
extends T
> clazz
, Boolean technical
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
) {
60 return dao
.groupMarkers(clazz
, technical
, pageSize
, pageNumber
, propertyPaths
);
64 @Transactional(readOnly
= true)
65 public int countMarkers(Class
<?
extends T
> clazz
, Boolean technical
) {
66 return dao
.countMarkers(clazz
, technical
);