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 javax.persistence.EntityManager; |
23 |
|
import javax.persistence.PersistenceContext; |
24 |
|
|
25 |
|
import org.kuali.rice.core.framework.persistence.jpa.criteria.Criteria; |
26 |
|
import org.kuali.rice.core.framework.persistence.jpa.criteria.QueryByCriteria; |
27 |
|
import org.kuali.rice.kim.bo.role.KimPermission; |
28 |
|
import org.kuali.rice.kim.bo.role.impl.RolePermissionImpl; |
29 |
|
import org.kuali.rice.kim.dao.KimPermissionDao; |
30 |
|
; |
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
@author |
36 |
|
|
37 |
|
|
|
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 4 |
Complexity Density: 0.27 |
|
38 |
|
public class KimPermissionDaoJpa implements KimPermissionDao { |
39 |
|
|
40 |
|
@PersistenceContext(unitName="kim-unit") |
41 |
|
private EntityManager entityManager; |
42 |
|
|
43 |
|
|
44 |
|
@see |
45 |
|
|
|
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 2 |
Complexity Density: 0.15 |
|
46 |
0
|
@SuppressWarnings("unchecked")... |
47 |
|
public List<String> getRoleIdsForPermissions(Collection<? extends KimPermission> permissions) { |
48 |
0
|
if ( permissions.isEmpty() ) { |
49 |
0
|
return new ArrayList<String>(0); |
50 |
|
} |
51 |
0
|
List<String> permissionIds = new ArrayList<String>( permissions.size() ); |
52 |
0
|
for ( KimPermission kp : permissions ) { |
53 |
0
|
permissionIds.add( kp.getPermissionId() ); |
54 |
|
} |
55 |
0
|
Criteria c = new Criteria(RolePermissionImpl.class.getName()); |
56 |
0
|
c.in( "permissionId", permissionIds ); |
57 |
0
|
c.eq( "active", true ); |
58 |
|
|
59 |
0
|
ArrayList<RolePermissionImpl> coll = (ArrayList<RolePermissionImpl>) new QueryByCriteria(entityManager, c).toQuery().getResultList(); |
60 |
0
|
List<String> roleIds = new ArrayList<String>( coll.size() ); |
61 |
0
|
for ( RolePermissionImpl rp : coll ) { |
62 |
0
|
roleIds.add( rp.getRoleId() ); |
63 |
|
} |
64 |
0
|
return roleIds; |
65 |
|
} |
66 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
67 |
0
|
public EntityManager getEntityManager() {... |
68 |
0
|
return this.entityManager; |
69 |
|
} |
70 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
71 |
0
|
public void setEntityManager(EntityManager entityManager) {... |
72 |
0
|
this.entityManager = entityManager; |
73 |
|
} |
74 |
|
} |