+// $Id$\r
+/**\r
+ * Copyright (C) 2007 EDIT\r
+ * European Distributed Institute of Taxonomy \r
+ * http://www.e-taxonomy.eu\r
+ * \r
+ * The contents of this file are subject to the Mozilla Public License Version 1.1\r
+ * See LICENSE.TXT at the top of this package for the full license terms.\r
+ */\r
+\r
package eu.etaxonomy.cdm.api.service;\r
\r
import java.util.ArrayList;\r
\r
import org.springframework.beans.factory.annotation.Autowired;\r
import org.springframework.stereotype.Service;\r
+import org.springframework.transaction.annotation.Propagation;\r
import org.springframework.transaction.annotation.Transactional;\r
\r
import eu.etaxonomy.cdm.api.service.pager.Pager;\r
import eu.etaxonomy.cdm.model.agent.Person;\r
import eu.etaxonomy.cdm.model.common.Annotation;\r
import eu.etaxonomy.cdm.model.common.MarkerType;\r
+import eu.etaxonomy.cdm.model.common.User;\r
import eu.etaxonomy.cdm.persistence.dao.hibernate.common.AnnotationDaoImpl;\r
+import eu.etaxonomy.cdm.persistence.query.OrderHint;\r
\r
@Service\r
-@Transactional\r
+@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)\r
public class AnnotationService extends AnnotatableServiceBase<Annotation, AnnotationDaoImpl> implements\r
IAnnotationService {\r
\r
return dao.count(commentator, status);\r
}\r
\r
- public Pager<Annotation> list(Person commentator, MarkerType status,Integer pageSize, Integer pageNumber) {\r
+ public Pager<Annotation> list(Person commentator, MarkerType status,Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths) {\r
Integer numberOfResults = dao.count(commentator, status);\r
\r
List<Annotation> results = new ArrayList<Annotation>();\r
- if(numberOfResults > 0) { // no point checking again\r
- results = dao.list(commentator, status, pageSize, pageNumber);\r
+ if(numberOfResults > 0) { // no point checking again //TODO use AbstractPagerImpl.hasResultsInRange(numberOfResults, pageNumber, pageSize)\r
+ results = dao.list(commentator, status, pageSize, pageNumber, orderHints, propertyPaths);\r
+ }\r
+ \r
+ return new DefaultPagerImpl<Annotation>(pageNumber, numberOfResults, pageSize, results);\r
+ }\r
+\r
+ public int count(User creator, MarkerType status) {\r
+ return dao.count(creator, status);\r
+ }\r
+\r
+ public Pager<Annotation> list(User creator, MarkerType status, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints,\r
+ List<String> propertyPaths) {\r
+ Integer numberOfResults = dao.count(creator, status);\r
+ \r
+ List<Annotation> results = new ArrayList<Annotation>();\r
+ if(numberOfResults > 0) { // no point checking again //TODO use AbstractPagerImpl.hasResultsInRange(numberOfResults, pageNumber, pageSize)\r
+ results = dao.list(creator, status, pageSize, pageNumber, orderHints, propertyPaths);\r
}\r
\r
return new DefaultPagerImpl<Annotation>(pageNumber, numberOfResults, pageSize, results);\r