=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/PersonController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/PersonController.java 2014-01-28 11:18:49 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/PersonController.java 2014-01-28 12:12:50 +0000 @@ -32,6 +32,7 @@ import org.hibernate.SessionFactory; import org.hibernate.criterion.Conjunction; import org.hibernate.criterion.Disjunction; +import org.hibernate.criterion.Order; import org.hibernate.criterion.Restrictions; import org.hisp.dhis.api.controller.WebOptions; import org.hisp.dhis.api.controller.exception.NotFoundException; @@ -94,16 +95,16 @@ @PreAuthorize( "hasRole('ALL') or hasRole('F_ACCESS_PATIENT_ATTRIBUTES')" ) public String getPersons( @RequestParam( value = "orgUnit", required = false ) String orgUnitUid, @RequestParam( value = "program", required = false ) String programUid, - @RequestParam( value = "attribute", required = false ) List filters, + @RequestParam( value = "attribute", required = false ) List attributeFilters, @RequestParam( required = false ) Map parameters, Model model ) throws Exception { WebOptions options = new WebOptions( parameters ); Persons persons = new Persons(); - if ( filters != null ) + if ( attributeFilters != null ) { - persons = personsByFilter( filters, orgUnitUid ); + persons = personsByFilter( attributeFilters, orgUnitUid ); } else if ( orgUnitUid != null ) { @@ -132,7 +133,7 @@ } @SuppressWarnings( "unchecked" ) - private Persons personsByFilter( List filters, String orgUnitUid ) + private Persons personsByFilter( List attributeFilters, String orgUnitUid ) { Criteria criteria = sessionFactory.getCurrentSession().createCriteria( Patient.class ); criteria.createAlias( "attributeValues", "attributeValue" ); @@ -155,7 +156,7 @@ } // validate attributes, and build criteria - for ( String filter : filters ) + for ( String filter : attributeFilters ) { String[] split = filter.split( ":" ); @@ -219,6 +220,8 @@ } } + criteria.addOrder( Order.desc( "lastUpdated" ) ); + return personService.getPersons( criteria.list() ); }