ref #7099 rename model.rights to model.permission
[cdmlib.git] / cdmlib-persistence / src / main / java / eu / etaxonomy / cdm / persistence / dao / hibernate / common / AnnotationDaoImpl.java
index fbb99030f997cd1d3745847c3d92ef1c0cef95e0..109ef805e73131089fb37b64dd18db0f8adea223 100644 (file)
@@ -5,7 +5,7 @@
 *
 * The contents of this file are subject to the Mozilla Public License Version 1.1
 * See LICENSE.TXT at the top of this package for the full license terms.
-*/ 
+*/
 
 package eu.etaxonomy.cdm.persistence.dao.hibernate.common;
 
@@ -19,7 +19,7 @@ import org.springframework.stereotype.Repository;
 import eu.etaxonomy.cdm.model.agent.Person;
 import eu.etaxonomy.cdm.model.common.Annotation;
 import eu.etaxonomy.cdm.model.common.MarkerType;
-import eu.etaxonomy.cdm.model.common.User;
+import eu.etaxonomy.cdm.model.permission.User;
 import eu.etaxonomy.cdm.persistence.dao.common.IAnnotationDao;
 import eu.etaxonomy.cdm.persistence.query.OrderHint;
 
@@ -30,86 +30,90 @@ public class AnnotationDaoImpl extends LanguageStringBaseDaoImpl<Annotation> imp
                super(Annotation.class);
        }
 
-       public int count(Person commentator, MarkerType status) {
+       @Override
+       public long count(Person commentator, MarkerType status) {
                checkNotInPriorView("AnnotationDaoImpl.count(Person commentator, MarkerType status)");
                Criteria criteria = getSession().createCriteria(Annotation.class);
-               
+
                 if(commentator != null) {
                criteria.add(Restrictions.eq("commentator",commentator));
             }
-                       
+
                if(status != null) {
                        criteria.createCriteria("markers").add(Restrictions.eq("markerType", status));
-               } 
-               
+               }
+
                criteria.setProjection(Projections.countDistinct("id"));
-               
-               return ((Number)criteria.uniqueResult()).intValue();
+
+               return (Long)criteria.uniqueResult();
        }
 
-       public List<Annotation> list(Person commentator, MarkerType status,     Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths) {
+       @Override
+    public List<Annotation> list(Person commentator, MarkerType status,        Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths) {
                checkNotInPriorView("AnnotationDaoImpl.list(Person commentator, MarkerType status,      Integer pageSize, Integer pageNumber)");
         Criteria criteria = getSession().createCriteria(Annotation.class);
-        
+
         if(commentator != null) {
             criteria.add(Restrictions.eq("commentator",commentator));
         }
-               
+
                if(status != null) {
                        criteria.createCriteria("markers").add(Restrictions.eq("markerType", status));
-               } 
-               
+               }
+
                if(pageSize != null) {
                        criteria.setMaxResults(pageSize);
                    if(pageNumber != null) {
                        criteria.setFirstResult(pageNumber * pageSize);
                    }
                }
-               
+
                addOrder(criteria, orderHints);
-               List<Annotation> results = (List<Annotation>)criteria.list();           
+               List<Annotation> results = criteria.list();
                defaultBeanInitializer.initializeAll(results, propertyPaths);
                return results;
        }
 
-       public int count(User creator, MarkerType status) {
+       @Override
+    public long count(User creator, MarkerType status) {
                checkNotInPriorView("AnnotationDaoImpl.count(User creator, MarkerType statu)");
                Criteria criteria = getSession().createCriteria(Annotation.class);
-               
+
                 if(creator != null) {
                criteria.add(Restrictions.eq("createdBy",creator));
             }
-                       
+
                if(status != null) {
                        criteria.createCriteria("markers").add(Restrictions.eq("markerType", status));
-               } 
-               
+               }
+
                criteria.setProjection(Projections.countDistinct("id"));
-               
-               return ((Number)criteria.uniqueResult()).intValue();
+
+               return (Long)criteria.uniqueResult();
        }
 
-       public List<Annotation> list(User creator, MarkerType status, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths) {
+       @Override
+    public List<Annotation> list(User creator, MarkerType status, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints,    List<String> propertyPaths) {
                checkNotInPriorView("AnnotationDaoImpl.list(User creator, MarkerType status,    Integer pageSize, Integer pageNumber)");
         Criteria criteria = getSession().createCriteria(Annotation.class);
-        
+
         if(creator != null) {
             criteria.add(Restrictions.eq("createdBy",creator));
         }
-               
+
                if(status != null) {
                        criteria.createCriteria("markers").add(Restrictions.eq("markerType", status));
-               } 
-               
+               }
+
                if(pageSize != null) {
                        criteria.setMaxResults(pageSize);
                    if(pageNumber != null) {
                        criteria.setFirstResult(pageNumber * pageSize);
                    }
                }
-               
+
                addOrder(criteria, orderHints);
-               List<Annotation> results = (List<Annotation>)criteria.list();           
+               List<Annotation> results = criteria.list();
                defaultBeanInitializer.initializeAll(results, propertyPaths);
                return results;
        }