1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kim.impl.permission; |
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.impl.role.RolePermissionBo; |
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | 0 | public class PermissionDaoOjb extends PlatformAwareDaoBaseOjb implements PermissionDao { |
36 | |
|
37 | |
@SuppressWarnings("unchecked") |
38 | |
public List<String> getRoleIdsForPermissions(Collection<Permission> permissions) { |
39 | 0 | if ( permissions.isEmpty() ) { |
40 | 0 | return new ArrayList<String>(0); |
41 | |
} |
42 | 0 | List<String> permissionIds = new ArrayList<String>( permissions.size() ); |
43 | 0 | for ( Permission permission : permissions ) { |
44 | 0 | permissionIds.add( permission.getId() ); |
45 | |
} |
46 | 0 | Criteria c = new Criteria(); |
47 | 0 | c.addIn( "permissionId", permissionIds ); |
48 | 0 | c.addEqualTo( "active", true ); |
49 | |
|
50 | 0 | Query query = QueryFactory.newQuery( RolePermissionBo.class, c, true ); |
51 | 0 | Collection<RolePermissionBo> coll = getPersistenceBrokerTemplate().getCollectionByQuery(query); |
52 | 0 | List<String> roleIds = new ArrayList<String>( coll.size() ); |
53 | 0 | for ( RolePermissionBo rp : coll ) { |
54 | 0 | roleIds.add( rp.getRoleId() ); |
55 | |
} |
56 | 0 | return roleIds; |
57 | |
} |
58 | |
|
59 | |
} |