← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18353: minor refactor, adds QueryService.getQueryFromUrl(...) and adds defaultOrder method to Query

 

------------------------------------------------------------
revno: 18353
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-02-20 16:14:02 +0700
message:
  minor refactor, adds QueryService.getQueryFromUrl(...) and adds defaultOrder method to Query
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/query/Query.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/query/QueryService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/DefaultQueryService.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/objectfilter/DefaultObjectFilterService.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/objectfilter/ObjectFilterService.java
  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/DashboardItemController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DimensionController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/InterpretationController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/MessageConversationController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/TranslationController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/CategoryOptionComboController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/DataElementOperandController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/ProgramController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/ProgramStageController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/TrackedEntityAttributeController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/mapping/MapViewController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/organisationunit/OrganisationUnitController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/user/UserController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/user/UserRoleController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/validation/ValidationRuleController.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-api/src/main/java/org/hisp/dhis/query/Query.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/query/Query.java	2015-02-20 08:28:01 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/query/Query.java	2015-02-20 09:14:02 +0000
@@ -154,6 +154,30 @@
         return this;
     }
 
+    public Query forceDefaultOrder()
+    {
+        orders.clear();
+        return setDefaultOrder();
+    }
+
+    public Query setDefaultOrder()
+    {
+        if ( !orders.isEmpty() )
+        {
+            return this;
+        }
+
+        if ( schema.haveProperty( "name" ) && schema.getProperty( "name" ).isPersisted() )
+        {
+            addOrder( Order.asc( schema.getProperty( "name" ) ) );
+        }
+        else
+        {
+            addOrder( Order.desc( schema.getProperty( "created" ) ) );
+        }
+
+        return this;
+    }
 
     @Override
     public String toString()

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/query/QueryService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/query/QueryService.java	2015-02-18 13:08:37 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/query/QueryService.java	2015-02-20 09:14:02 +0000
@@ -28,6 +28,8 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import java.util.List;
+
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
  */
@@ -36,4 +38,6 @@
     Result query( Query query );
 
     Result query( Query query, ResultTransformer transformer );
+
+    Query getQueryFromUrl( Class<?> klass, List<String> filters, List<Order> orders );
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/DefaultQueryService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/DefaultQueryService.java	2015-02-18 13:08:37 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/query/DefaultQueryService.java	2015-02-20 09:14:02 +0000
@@ -29,8 +29,13 @@
  */
 
 import org.hisp.dhis.common.IdentifiableObject;
+import org.hisp.dhis.schema.Property;
+import org.hisp.dhis.schema.Schema;
+import org.hisp.dhis.schema.SchemaService;
 import org.springframework.beans.factory.annotation.Autowired;
 
+import java.util.ArrayList;
+import java.util.Iterator;
 import java.util.List;
 
 /**
@@ -41,6 +46,9 @@
     @Autowired
     private QueryEngine queryEngine;
 
+    @Autowired
+    private SchemaService schemaService;
+
     @Override
     public Result query( Query query )
     {
@@ -60,4 +68,128 @@
 
         return new Result( objects );
     }
+
+    @Override
+    public Query getQueryFromUrl( Class<?> klass, List<String> filters, List<Order> orders )
+    {
+        Query query = Query.from( schemaService.getDynamicSchema( klass ) );
+        query.add( getRestrictions( query.getSchema(), filters ) );
+        query.addOrders( orders );
+
+        return query;
+    }
+
+    //--------------------------------------------------------------------------
+    // Helpers
+    //--------------------------------------------------------------------------
+
+    private List<Restriction> getRestrictions( Schema schema, List<String> filters )
+    {
+        List<Restriction> restrictions = new ArrayList<>();
+        List<String> candidates = getRestrictionCandidates( schema, filters );
+
+        if ( candidates.isEmpty() )
+        {
+            return restrictions;
+        }
+
+        for ( String candidate : candidates )
+        {
+            restrictions.add( getRestriction( schema, candidate ) );
+        }
+
+        return restrictions;
+    }
+
+    private List<String> getRestrictionCandidates( Schema schema, List<String> filters )
+    {
+        List<String> candidates = new ArrayList<>();
+
+        Iterator<String> iterator = filters.iterator();
+
+        while ( iterator.hasNext() )
+        {
+            String candidate = iterator.next();
+
+            if ( !candidate.contains( "." ) && getRestriction( schema, candidate ) != null )
+            {
+                candidates.add( candidate );
+                iterator.remove();
+            }
+        }
+
+        return candidates;
+    }
+
+    private Restriction getRestriction( Schema schema, String filter )
+    {
+        if ( filter == null )
+        {
+            return null;
+        }
+
+        String[] split = filter.split( ":" );
+
+        if ( split.length != 3 )
+        {
+            return null;
+        }
+
+        Property property = schema.getProperty( split[0] );
+
+        if ( property == null || !property.isPersisted() || !property.isSimple() )
+        {
+            return null;
+        }
+
+        switch ( split[1] )
+        {
+            case "eq":
+            {
+                return Restrictions.eq( split[0], split[2] );
+            }
+            case "ne":
+            {
+                return Restrictions.ne( split[0], split[2] );
+            }
+            case "neq":
+            {
+                return Restrictions.ne( split[0], split[2] );
+            }
+            case "gt":
+            {
+                return Restrictions.gt( split[0], split[2] );
+            }
+            case "lt":
+            {
+                return Restrictions.lt( split[0], split[2] );
+            }
+            case "gte":
+            {
+                return Restrictions.ge( split[0], split[2] );
+            }
+            case "ge":
+            {
+                return Restrictions.ge( split[0], split[2] );
+            }
+            case "lte":
+            {
+                return Restrictions.le( split[0], split[2] );
+            }
+            case "le":
+            {
+                return Restrictions.le( split[0], split[2] );
+            }
+            case "like":
+            {
+                return Restrictions.like( split[0], "%" + split[2] + "%" );
+            }
+            case "ilike":
+            {
+                return Restrictions.ilike( split[0], "%" + split[2] + "%" );
+            }
+        }
+
+        return null;
+    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/objectfilter/DefaultObjectFilterService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/objectfilter/DefaultObjectFilterService.java	2015-02-20 08:38:07 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/objectfilter/DefaultObjectFilterService.java	2015-02-20 09:14:02 +0000
@@ -29,24 +29,17 @@
  */
 
 import com.google.common.collect.Lists;
-import org.hisp.dhis.common.IdentifiableObject;
 import org.hisp.dhis.dxf2.objectfilter.ops.Op;
 import org.hisp.dhis.dxf2.objectfilter.ops.OpStatus;
 import org.hisp.dhis.dxf2.parser.ParserService;
-import org.hisp.dhis.query.Order;
-import org.hisp.dhis.query.Query;
 import org.hisp.dhis.query.QueryService;
-import org.hisp.dhis.query.Restriction;
-import org.hisp.dhis.query.Restrictions;
 import org.hisp.dhis.schema.Property;
 import org.hisp.dhis.schema.Schema;
 import org.hisp.dhis.schema.SchemaService;
 import org.hisp.dhis.system.util.ReflectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 
-import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
@@ -65,137 +58,6 @@
     private QueryService queryService;
 
     @Override
-    @SuppressWarnings( "unchecked" )
-    public <T extends IdentifiableObject> List<T> query( Class<? extends IdentifiableObject> klass, List<String> filters, int first, int max )
-    {
-        Schema schema = schemaService.getDynamicSchema( klass );
-        Query query = Query.from( schema );
-        query.setFirstResult( first ).setMaxResults( max );
-        query.add( getRestrictions( schema, filters ) );
-
-        if ( schema.haveProperty( "name" ) && schema.getProperty( "name" ).isPersisted() )
-        {
-            query.addOrder( Order.asc( schema.getProperty( "name" ) ) );
-        }
-        else
-        {
-            query.addOrder( Order.desc( schema.getProperty( "created" ) ) );
-        }
-
-        return (List<T>) queryService.query( query ).getItems();
-    }
-
-    private List<Restriction> getRestrictions( Schema schema, List<String> filters )
-    {
-        List<Restriction> restrictions = new ArrayList<>();
-        List<String> candidates = getRestrictionCandidates( schema, filters );
-
-        if ( candidates.isEmpty() )
-        {
-            return restrictions;
-        }
-
-        for ( String candidate : candidates )
-        {
-            restrictions.add( getRestriction( schema, candidate ) );
-        }
-
-        return restrictions;
-    }
-
-    private List<String> getRestrictionCandidates( Schema schema, List<String> filters )
-    {
-        List<String> candidates = new ArrayList<>();
-
-        Iterator<String> iterator = filters.iterator();
-
-        while ( iterator.hasNext() )
-        {
-            String candidate = iterator.next();
-
-            if ( !candidate.contains( "." ) && getRestriction( schema, candidate ) != null )
-            {
-                candidates.add( candidate );
-                iterator.remove();
-            }
-        }
-
-        return candidates;
-    }
-
-    private Restriction getRestriction( Schema schema, String filter )
-    {
-        if ( filter == null )
-        {
-            return null;
-        }
-
-        String[] split = filter.split( ":" );
-
-        if ( split.length != 3 )
-        {
-            return null;
-        }
-
-        Property property = schema.getProperty( split[0] );
-
-        if ( property == null || !property.isPersisted() || !property.isSimple() )
-        {
-            return null;
-        }
-
-        switch ( split[1] )
-        {
-            case "eq":
-            {
-                return Restrictions.eq( split[0], split[2] );
-            }
-            case "ne":
-            {
-                return Restrictions.ne( split[0], split[2] );
-            }
-            case "neq":
-            {
-                return Restrictions.ne( split[0], split[2] );
-            }
-            case "gt":
-            {
-                return Restrictions.gt( split[0], split[2] );
-            }
-            case "lt":
-            {
-                return Restrictions.lt( split[0], split[2] );
-            }
-            case "gte":
-            {
-                return Restrictions.ge( split[0], split[2] );
-            }
-            case "ge":
-            {
-                return Restrictions.ge( split[0], split[2] );
-            }
-            case "lte":
-            {
-                return Restrictions.le( split[0], split[2] );
-            }
-            case "le":
-            {
-                return Restrictions.le( split[0], split[2] );
-            }
-            case "like":
-            {
-                return Restrictions.like( split[0], "%" + split[2] + "%" );
-            }
-            case "ilike":
-            {
-                return Restrictions.ilike( split[0], "%" + split[2] + "%" );
-            }
-        }
-
-        return null;
-    }
-
-    @Override
     public <T> List<T> filter( List<T> objects, List<String> filters )
     {
         if ( objects == null || objects.isEmpty() )

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/objectfilter/ObjectFilterService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/objectfilter/ObjectFilterService.java	2015-02-20 08:28:01 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/objectfilter/ObjectFilterService.java	2015-02-20 09:14:02 +0000
@@ -29,6 +29,7 @@
  */
 
 import org.hisp.dhis.common.IdentifiableObject;
+import org.hisp.dhis.query.Query;
 
 import java.util.List;
 
@@ -38,17 +39,6 @@
 public interface ObjectFilterService
 {
     /**
-     * Splits out candidates for DB query, and returns result.
-     * <p/>
-     * WARNING: filters list will be modified, filters that have been taken care of using Query will be removed.
-     *
-     * @param klass   Class to query
-     * @param filters Filter string
-     * @return Filtered object list
-     */
-    <T extends IdentifiableObject> List<T> query( Class<? extends IdentifiableObject> klass, List<String> filters, int first, int max );
-
-    /**
      * Filter a list of objects based on un-parsed filter string.
      * In-memory filter
      *

=== 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-02-20 08:28:01 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java	2015-02-20 09:14:02 +0000
@@ -58,6 +58,8 @@
 import org.hisp.dhis.node.types.RootNode;
 import org.hisp.dhis.node.types.SimpleNode;
 import org.hisp.dhis.query.Order;
+import org.hisp.dhis.query.Query;
+import org.hisp.dhis.query.QueryService;
 import org.hisp.dhis.schema.Property;
 import org.hisp.dhis.schema.Schema;
 import org.hisp.dhis.schema.SchemaService;
@@ -132,6 +134,9 @@
     @Autowired
     protected I18nService i18nService;
 
+    @Autowired
+    protected QueryService queryService;
+
     //--------------------------------------------------------------------------
     // GET
     //--------------------------------------------------------------------------
@@ -154,7 +159,7 @@
             fields.add( ":identifiable" );
         }
 
-        List<T> entities = getEntityList( metaData, options, filters );
+        List<T> entities = getEntityList( metaData, options, filters, orders );
         Pager pager = metaData.getPager();
 
         entities = objectFilterService.filter( entities, filters );
@@ -742,10 +747,14 @@
     // Helpers
     //--------------------------------------------------------------------------
 
-    protected List<T> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters )
+    @SuppressWarnings( "unchecked" )
+    protected List<T> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters, List<Order> orders )
     {
         List<T> entityList;
 
+        Query query = queryService.getQueryFromUrl( getEntityClass(), filters, orders );
+        query.setDefaultOrder();
+
         if ( options.getOptions().containsKey( "query" ) )
         {
             entityList = Lists.newArrayList( manager.filter( getEntityClass(), options.getOptions().get( "query" ) ) );
@@ -757,11 +766,13 @@
             Pager pager = new Pager( options.getPage(), count, options.getPageSize() );
             metaData.setPager( pager );
 
-            entityList = objectFilterService.query( getEntityClass(), filters, pager.getOffset(), pager.getPageSize() );
+            query.setFirstResult( pager.getOffset() );
+            query.setMaxResults( pager.getPageSize() );
+            entityList = (List<T>) queryService.query( query ).getItems();
         }
         else
         {
-            entityList = objectFilterService.query( getEntityClass(), filters, 0, Integer.MAX_VALUE );
+            entityList = (List<T>) queryService.query( query ).getItems();
         }
 
         return entityList;

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DashboardItemController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DashboardItemController.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DashboardItemController.java	2015-02-20 09:14:02 +0000
@@ -36,6 +36,7 @@
 import org.hisp.dhis.common.Pager;
 import org.hisp.dhis.dashboard.DashboardItem;
 import org.hisp.dhis.dashboard.DashboardService;
+import org.hisp.dhis.query.Order;
 import org.hisp.dhis.schema.descriptors.DashboardItemSchemaDescriptor;
 import org.hisp.dhis.webapi.utils.ContextUtils;
 import org.hisp.dhis.webapi.webdomain.WebMetaData;
@@ -60,7 +61,7 @@
     private DashboardService dashboardService;
     
     @Override
-    protected List<DashboardItem> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters )
+    protected List<DashboardItem> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters, List<Order> orders )
     {
         List<DashboardItem> entityList;
 

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DimensionController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DimensionController.java	2015-02-17 06:00:52 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DimensionController.java	2015-02-20 09:14:02 +0000
@@ -48,6 +48,7 @@
 import org.hisp.dhis.node.NodeUtils;
 import org.hisp.dhis.node.types.CollectionNode;
 import org.hisp.dhis.node.types.RootNode;
+import org.hisp.dhis.query.Order;
 import org.hisp.dhis.webapi.utils.ContextUtils;
 import org.hisp.dhis.webapi.webdomain.WebMetaData;
 import org.hisp.dhis.webapi.webdomain.WebOptions;
@@ -84,7 +85,7 @@
     // -------------------------------------------------------------------------
 
     @Override
-    protected List<DimensionalObject> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters )
+    protected List<DimensionalObject> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters, List<Order> orders )
     {
         return dimensionService.getAllDimensions();
     }

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/InterpretationController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/InterpretationController.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/InterpretationController.java	2015-02-20 09:14:02 +0000
@@ -43,6 +43,7 @@
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodType;
+import org.hisp.dhis.query.Order;
 import org.hisp.dhis.reporttable.ReportTable;
 import org.hisp.dhis.reporttable.ReportTableService;
 import org.hisp.dhis.schema.descriptors.InterpretationSchemaDescriptor;
@@ -96,7 +97,7 @@
     private CurrentUserService currentUserService;
 
     @Override
-    protected List<Interpretation> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters )
+    protected List<Interpretation> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters, List<Order> orders )
     {
         List<Interpretation> entityList;
 

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/MessageConversationController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/MessageConversationController.java	2015-02-17 06:00:52 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/MessageConversationController.java	2015-02-20 09:14:02 +0000
@@ -41,6 +41,7 @@
 import org.hisp.dhis.node.types.SimpleNode;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.query.Order;
 import org.hisp.dhis.schema.descriptors.MessageConversationSchemaDescriptor;
 import org.hisp.dhis.user.CurrentUserService;
 import org.hisp.dhis.user.User;
@@ -128,7 +129,7 @@
     }
 
     @Override
-    protected List<org.hisp.dhis.message.MessageConversation> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters )
+    protected List<org.hisp.dhis.message.MessageConversation> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters, List<Order> orders )
     {
         List<org.hisp.dhis.message.MessageConversation> entityList;
 

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/TranslationController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/TranslationController.java	2015-02-13 06:16:30 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/TranslationController.java	2015-02-20 09:14:02 +0000
@@ -30,6 +30,7 @@
 
 import com.google.common.collect.Lists;
 import org.hisp.dhis.common.Pager;
+import org.hisp.dhis.query.Order;
 import org.hisp.dhis.schema.descriptors.TranslationSchemaDescriptor;
 import org.hisp.dhis.translation.Translation;
 import org.hisp.dhis.webapi.webdomain.WebMetaData;
@@ -47,7 +48,7 @@
 public class TranslationController extends AbstractCrudController<Translation>
 {
     @Override
-    protected List<Translation> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters )
+    protected List<Translation> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters, List<Order> orders )
     {
         List<Translation> entityList;
 

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/CategoryOptionComboController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/CategoryOptionComboController.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/CategoryOptionComboController.java	2015-02-20 09:14:02 +0000
@@ -30,6 +30,7 @@
 
 import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.query.Order;
 import org.hisp.dhis.schema.descriptors.CategoryOptionComboSchemaDescriptor;
 import org.hisp.dhis.webapi.controller.AbstractCrudController;
 import org.hisp.dhis.webapi.webdomain.WebMetaData;
@@ -54,7 +55,7 @@
     // name (clashes with getAllOrderedName)
     // FIXME add paging also for this?
     @Override
-    protected List<DataElementCategoryOptionCombo> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters )
+    protected List<DataElementCategoryOptionCombo> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters, List<Order> orders )
     {
         List<DataElementCategoryOptionCombo> entityList;
 

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/DataElementOperandController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/DataElementOperandController.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/DataElementOperandController.java	2015-02-20 09:14:02 +0000
@@ -38,6 +38,7 @@
 import org.hisp.dhis.dataelement.DataElementCategoryService;
 import org.hisp.dhis.dataelement.DataElementGroup;
 import org.hisp.dhis.dataelement.DataElementOperand;
+import org.hisp.dhis.query.Order;
 import org.hisp.dhis.schema.descriptors.DataElementOperandSchemaDescriptor;
 import org.hisp.dhis.webapi.controller.AbstractCrudController;
 import org.hisp.dhis.webapi.webdomain.WebMetaData;
@@ -59,7 +60,7 @@
     private DataElementCategoryService dataElementCategoryService;
 
     @Override
-    protected List<DataElementOperand> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters )
+    protected List<DataElementOperand> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters, List<Order> orders )
     {
         List<DataElementOperand> dataElementOperands;
 

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/ProgramController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/ProgramController.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/ProgramController.java	2015-02-20 09:14:02 +0000
@@ -35,6 +35,7 @@
 import org.hisp.dhis.program.ProgramInstance;
 import org.hisp.dhis.program.ProgramInstanceService;
 import org.hisp.dhis.program.ProgramService;
+import org.hisp.dhis.query.Order;
 import org.hisp.dhis.schema.descriptors.ProgramSchemaDescriptor;
 import org.hisp.dhis.webapi.controller.AbstractCrudController;
 import org.hisp.dhis.webapi.webdomain.WebMetaData;
@@ -78,7 +79,7 @@
     }
 
     @Override
-    protected List<Program> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters )
+    protected List<Program> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters, List<Order> orders )
     {
         String type = options.getOptions().get( "type" );
         String orgUnit = options.getOptions().get( "orgUnit" );

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/ProgramStageController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/ProgramStageController.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/ProgramStageController.java	2015-02-20 09:14:02 +0000
@@ -33,6 +33,7 @@
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramService;
 import org.hisp.dhis.program.ProgramStage;
+import org.hisp.dhis.query.Order;
 import org.hisp.dhis.schema.descriptors.ProgramStageSchemaDescriptor;
 import org.hisp.dhis.webapi.controller.AbstractCrudController;
 import org.hisp.dhis.webapi.webdomain.WebMetaData;
@@ -61,7 +62,7 @@
     }
 
     @Override
-    protected List<ProgramStage> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters )
+    protected List<ProgramStage> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters, List<Order> orders )
     {
         List<ProgramStage> entityList = new ArrayList<>();
 

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/TrackedEntityAttributeController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/TrackedEntityAttributeController.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/TrackedEntityAttributeController.java	2015-02-20 09:14:02 +0000
@@ -32,6 +32,7 @@
 import org.hisp.dhis.common.Pager;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramService;
+import org.hisp.dhis.query.Order;
 import org.hisp.dhis.schema.descriptors.TrackedEntityAttributeSchemaDescriptor;
 import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
 import org.hisp.dhis.trackedentity.TrackedEntityAttributeService;
@@ -60,7 +61,7 @@
     private ProgramService programService;
 
     @Override
-    protected List<TrackedEntityAttribute> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters )
+    protected List<TrackedEntityAttribute> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters, List<Order> orders )
     {
         List<TrackedEntityAttribute> entityList = new ArrayList<>();
 

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/mapping/MapViewController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/mapping/MapViewController.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/mapping/MapViewController.java	2015-02-20 09:14:02 +0000
@@ -34,6 +34,7 @@
 import org.hisp.dhis.mapping.MappingService;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.query.Order;
 import org.hisp.dhis.schema.descriptors.MapViewSchemaDescriptor;
 import org.hisp.dhis.webapi.controller.AbstractCrudController;
 import org.hisp.dhis.webapi.webdomain.WebMetaData;
@@ -117,7 +118,7 @@
     //--------------------------------------------------------------------------
 
     @Override
-    protected List<MapView> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters )
+    protected List<MapView> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters, List<Order> orders )
     {
         List<MapView> entityList;
 

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/organisationunit/OrganisationUnitController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/organisationunit/OrganisationUnitController.java	2015-02-17 06:00:52 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/organisationunit/OrganisationUnitController.java	2015-02-20 09:14:02 +0000
@@ -37,6 +37,7 @@
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.organisationunit.comparator.OrganisationUnitByLevelComparator;
+import org.hisp.dhis.query.Order;
 import org.hisp.dhis.schema.descriptors.OrganisationUnitSchemaDescriptor;
 import org.hisp.dhis.user.CurrentUserService;
 import org.hisp.dhis.user.User;
@@ -80,7 +81,7 @@
     private CurrentUserService currentUserService;
 
     @Override
-    protected List<OrganisationUnit> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters )
+    protected List<OrganisationUnit> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters, List<Order> orders )
     {
         List<OrganisationUnit> entityList;
 

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/user/UserController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/user/UserController.java	2015-02-19 09:18:17 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/user/UserController.java	2015-02-20 09:14:02 +0000
@@ -48,6 +48,7 @@
 import org.hisp.dhis.dxf2.metadata.ImportTypeSummary;
 import org.hisp.dhis.importexport.ImportStrategy;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.query.Order;
 import org.hisp.dhis.schema.descriptors.UserSchemaDescriptor;
 import org.hisp.dhis.security.RestoreOptions;
 import org.hisp.dhis.security.SecurityService;
@@ -113,7 +114,7 @@
     // -------------------------------------------------------------------------
 
     @Override
-    protected List<User> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters )
+    protected List<User> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters, List<Order> orders )
     {
         UserQueryParams params = new UserQueryParams();
         params.setQuery( options.get( "query" ) );

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/user/UserRoleController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/user/UserRoleController.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/user/UserRoleController.java	2015-02-20 09:14:02 +0000
@@ -30,6 +30,7 @@
 
 import org.hisp.dhis.hibernate.exception.DeleteAccessDeniedException;
 import org.hisp.dhis.hibernate.exception.UpdateAccessDeniedException;
+import org.hisp.dhis.query.Order;
 import org.hisp.dhis.schema.descriptors.UserRoleSchemaDescriptor;
 import org.hisp.dhis.user.User;
 import org.hisp.dhis.user.UserAuthorityGroup;
@@ -59,9 +60,9 @@
     private UserService userService;
 
     @Override
-    protected List<UserAuthorityGroup> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters )
+    protected List<UserAuthorityGroup> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters, List<Order> orders )
     {
-        List<UserAuthorityGroup> entityList = super.getEntityList( metaData, options, filters );
+        List<UserAuthorityGroup> entityList = super.getEntityList( metaData, options, filters, orders );
 
         if ( options.getOptions().containsKey( "canIssue" ) && Boolean.parseBoolean( options.getOptions().get( "canIssue" ) ) )
         {

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/validation/ValidationRuleController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/validation/ValidationRuleController.java	2015-02-11 19:41:55 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/validation/ValidationRuleController.java	2015-02-20 09:14:02 +0000
@@ -32,6 +32,7 @@
 
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.query.Order;
 import org.hisp.dhis.schema.descriptors.ValidationRuleSchemaDescriptor;
 import org.hisp.dhis.validation.ValidationRule;
 import org.hisp.dhis.validation.ValidationRuleService;
@@ -59,7 +60,7 @@
     private ValidationRuleService validationRuleService;
     
     @Override
-    protected List<ValidationRule> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters )
+    protected List<ValidationRule> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters, List<Order> orders )
     {
         if ( options.contains( "dataSet" ) )
         {            
@@ -73,6 +74,6 @@
             return Lists.newArrayList( validationRuleService.getValidationRulesByDataElements( ds.getDataElements() ) );
         }
         
-        return super.getEntityList( metaData, options, filters );
+        return super.getEntityList( metaData, options, filters, orders );
     }
 }