1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kim.dao.impl; |
17 | |
|
18 | |
import java.util.ArrayList; |
19 | |
import java.util.Collection; |
20 | |
import java.util.List; |
21 | |
|
22 | |
import org.apache.ojb.broker.query.Criteria; |
23 | |
import org.apache.ojb.broker.query.Query; |
24 | |
import org.apache.ojb.broker.query.QueryFactory; |
25 | |
import org.kuali.rice.kim.bo.role.KimPermission; |
26 | |
import org.kuali.rice.kim.bo.role.impl.RolePermissionImpl; |
27 | |
import org.kuali.rice.kim.dao.KimPermissionDao; |
28 | |
import org.kuali.rice.kns.dao.impl.PlatformAwareDaoBaseOjb; |
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | 0 | public class KimPermissionDaoOjb extends PlatformAwareDaoBaseOjb implements KimPermissionDao { |
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
@SuppressWarnings("unchecked") |
42 | |
public List<String> getRoleIdsForPermissions(Collection<? extends KimPermission> permissions) { |
43 | 0 | if ( permissions.isEmpty() ) { |
44 | 0 | return new ArrayList<String>(0); |
45 | |
} |
46 | 0 | List<String> permissionIds = new ArrayList<String>( permissions.size() ); |
47 | 0 | for ( KimPermission kp : permissions ) { |
48 | 0 | permissionIds.add( kp.getPermissionId() ); |
49 | |
} |
50 | 0 | Criteria c = new Criteria(); |
51 | 0 | c.addIn( "permissionId", permissionIds ); |
52 | 0 | c.addEqualTo( "active", true ); |
53 | |
|
54 | 0 | Query query = QueryFactory.newQuery( RolePermissionImpl.class, c, true ); |
55 | 0 | Collection<RolePermissionImpl> coll = getPersistenceBrokerTemplate().getCollectionByQuery(query); |
56 | 0 | List<String> roleIds = new ArrayList<String>( coll.size() ); |
57 | 0 | for ( RolePermissionImpl rp : coll ) { |
58 | 0 | roleIds.add( rp.getRoleId() ); |
59 | |
} |
60 | 0 | return roleIds; |
61 | |
} |
62 | |
|
63 | |
} |