← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18588: paging fix for web-api

 

------------------------------------------------------------
revno: 18588
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-03-12 14:52:48 +0530
message:
  paging fix for web-api
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java	2015-03-09 06:27:56 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java	2015-03-12 09:22:48 +0000
@@ -775,6 +775,7 @@
     protected List<T> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters, List<Order> orders )
     {
         List<T> entityList;
+        boolean haveFilters = !filters.isEmpty();
         Query query = queryService.getQueryFromUrl( getEntityClass(), filters, orders );
         query.setDefaultOrder();
 
@@ -782,7 +783,7 @@
         {
             entityList = Lists.newArrayList( manager.filter( getEntityClass(), options.getOptions().get( "query" ) ) );
         }
-        else if ( options.hasPaging() && filters.isEmpty() )
+        else if ( options.hasPaging() && !haveFilters )
         {
             int count = manager.getCount( getEntityClass() );
 
@@ -792,6 +793,8 @@
             query.setFirstResult( pager.getOffset() );
             query.setMaxResults( pager.getPageSize() );
             entityList = (List<T>) queryService.query( query ).getItems();
+
+            metaData.setPager( new Pager( options.getPage(), entityList.size(), options.getPageSize() ) );
         }
         else
         {