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.core.framework.persistence.ojb.dao.PlatformAwareDaoBaseOjb; |
26 | |
import org.kuali.rice.kim.api.permission.Permission; |
27 | |
import org.kuali.rice.kim.dao.KimPermissionDao; |
28 | |
import org.kuali.rice.kim.impl.permission.PermissionBo; |
29 | |
import org.kuali.rice.kim.impl.role.RolePermissionBo; |
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | 0 | public class KimPermissionDaoOjb extends PlatformAwareDaoBaseOjb implements KimPermissionDao { |
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
@SuppressWarnings("unchecked") |
43 | |
public List<String> getRoleIdsForPermissions(Collection<PermissionBo> permissions) { |
44 | 0 | if ( permissions.isEmpty() ) { |
45 | 0 | return new ArrayList<String>(0); |
46 | |
} |
47 | 0 | List<String> permissionIds = new ArrayList<String>( permissions.size() ); |
48 | 0 | for ( PermissionBo kp : permissions ) { |
49 | 0 | permissionIds.add( kp.getId() ); |
50 | |
} |
51 | 0 | Criteria c = new Criteria(); |
52 | 0 | c.addIn( "permissionId", permissionIds ); |
53 | 0 | c.addEqualTo( "active", true ); |
54 | |
|
55 | 0 | Query query = QueryFactory.newQuery( RolePermissionBo.class, c, true ); |
56 | 0 | Collection<RolePermissionBo> coll = getPersistenceBrokerTemplate().getCollectionByQuery(query); |
57 | 0 | List<String> roleIds = new ArrayList<String>( coll.size() ); |
58 | 0 | for ( RolePermissionBo rp : coll ) { |
59 | 0 | roleIds.add( rp.getRoleId() ); |
60 | |
} |
61 | 0 | return roleIds; |
62 | |
} |
63 | |
|
64 | |
} |