45c315fdaf8faabf7c3d29e8886cad74293e229e
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
.persistence
.dao
.hibernate
.common
;
12 import java
.util
.List
;
14 import org
.apache
.log4j
.Logger
;
15 import org
.hibernate
.Query
;
17 import eu
.etaxonomy
.cdm
.model
.common
.AnnotatableEntity
;
18 import eu
.etaxonomy
.cdm
.model
.common
.Annotation
;
19 import eu
.etaxonomy
.cdm
.model
.common
.MarkerType
;
20 import eu
.etaxonomy
.cdm
.persistence
.dao
.common
.IAnnotatableDao
;
27 public abstract class AnnotatableDaoImpl
<T
extends AnnotatableEntity
> extends CdmEntityDaoBase
<T
> implements IAnnotatableDao
<T
> {
28 private static Logger logger
= Logger
.getLogger(AnnotatableDaoImpl
.class);
33 public AnnotatableDaoImpl(Class
<T
> type
) {
36 public int countAnnotations(T annotatableEntity
, MarkerType status
) {
40 query
= getSession().createQuery("select count(annotation) from Annotation annotation where annotation.annotatedObj = :annotatableEntity");
42 query
= getSession().createQuery("select count(annotation) from Annotation annotation join annotation.markers marker where annotation.annotatedObj = :annotatableEntity and marker.markerType = :status");
43 query
.setParameter("status",status
);
46 query
.setParameter("annotatableEntity",annotatableEntity
);
48 return ((Long
)query
.uniqueResult()).intValue();
50 public List
<Annotation
> getAnnotations(T annotatableEntity
, MarkerType status
, Integer pageSize
, Integer pageNumber
) {
54 query
= getSession().createQuery("select annotation from Annotation annotation where annotation.annotatedObj = :annotatableEntity");
56 query
= getSession().createQuery("select annotation from Annotation annotation join annotation.markers marker where annotation.annotatedObj = :annotatableEntity and marker.markerType = :status");
57 query
.setParameter("status",status
);
60 query
.setParameter("annotatableEntity",annotatableEntity
);
62 if(pageSize
!= null) {
63 query
.setMaxResults(pageSize
);
64 if(pageNumber
!= null) {
65 query
.setFirstResult(pageNumber
* pageSize
);
69 return (List
<Annotation
>)query
.list();