Il 06/07/2013 11:07, morteza adi ha scritto:
hi,
I wonder why findAll() method in

http://svn.apache.org/viewvc/syncope/tags/syncope-1.1.2/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/UserDAOImpl.java?view=co

excludes user within membershib table?

the query created by this function doesn't make any sense for me
Hi, the created query doesn't exclude any user within membership table.
It checks the possibility to perform such query by the user requiring the search operation. The possibility is computed upon entitlements (roles/memberships) owned by the user.

E.g.
1. since I can search only for users in role A, the query must be created by excluding users without a membership for A. 2. since I have no memberships I can search only for users without memberships.

Take a look at UserTest.findAll() to search for all users.

Rgds,
F.

private StringBuilder getFindAllQuery(final Set<Long> adminRoles) {
         final StringBuilder queryString = new StringBuilder("SELECT id FROM 
SyncopeUser WHERE*id NOT IN*  (");

         if (adminRoles == null || adminRoles.isEmpty()) {
             queryString.append("SELECT syncopeUser_id AS id FROM Membership");
         } else {
             queryString.append("SELECT syncopeUser_id FROM Membership M1 
").append("WHERE syncopeRole_id IN (");
             queryString.append("SELECT syncopeRole_id FROM Membership M2 
").append(
                     "WHERE M2.syncopeUser_id=M1.syncopeUser_id ").append("AND 
syncopeRole_id NOT IN (");

             queryString.append("SELECT id AS syncopeRole_id FROM SyncopeRole");
             boolean firstRole = true;
             for (Long adminRoleId : adminRoles) {
                 if (firstRole) {
                     queryString.append(" WHERE");
                     firstRole = false;
                 } else {
                     queryString.append(" OR");
                 }

                 queryString.append(" id=").append(adminRoleId);
             }

             queryString.append("))");
         }
         queryString.append(")");

         return queryString;
}

* how can i query all users even those with memberships?*


Reply via email to