[security-dev] Sorting support in IDM

Marek Posolda mposolda at redhat.com
Wed Feb 6 08:38:00 EST 2013


I've looked that currently there is no support for sorting of query 
results by some attributes. So I've added some support for sorting into 
IDM API into IdentityQuery class. Especially those four methods:

      * Parameters used to sort the results. First parameter has biggest 
      * For example: setSortParameter(User.LAST_NAME, User.FIRST_NAME) 
means that results will be sorted primarily by lastName
      * and firstName will be used to sort only records with same lastName
      * @param sortParameters parameters to specify sort criteria
      * @return this query
     IdentityQuery<T> setSortParameters(QueryParameter... sortParameters);

      * @see #setSortParameters(QueryParameter...)
     QueryParameter[] getSortParameters();

      * Specify if sorting will be ascending (true) or descending (false)
      * @param sortAscending to specify if sorting will be ascending or 
      * @return this query
     IdentityQuery<T> setSortAscending(boolean sortAscending);

      * @return true if sorting will be ascending
      * @see #setSortAscending(boolean)
     boolean isSortAscending();

This adds support for sort by more attributes (if attribute1 has same 
value for some records, attribute2 will be used) and I hope that having 
this in API is sufficient to cover majority of usecases. WDYT?

I've added support for sorting into JPAIdentityStore for now. Will try 
to add support also into FileIdentityStore and LDAPIdentityStore if you 
are ok with my proposal. I've added some unit tests to test this (they 
are enabled only for JPAIdentityStoreTestSuite now because it's 
implemented only here)



More information about the security-dev mailing list