| 1 |
|
package org.itracker.persistence.dao; |
| 2 |
|
|
| 3 |
|
import java.util.List; |
| 4 |
|
|
| 5 |
|
import org.hibernate.HibernateException; |
| 6 |
|
import org.hibernate.Query; |
| 7 |
|
import org.itracker.model.Permission; |
| 8 |
|
import org.itracker.model.Project; |
| 9 |
|
import org.itracker.model.User; |
| 10 |
|
|
|
|
|
| 0% |
Uncovered Elements: 25 (25) |
Complexity: 6 |
Complexity Density: 0.32 |
|
| 11 |
|
public class PermissionDAOImpl extends BaseHibernateDAOImpl<Permission> |
| 12 |
|
implements PermissionDAO { |
| 13 |
|
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0.33 |
|
| 14 |
0
|
@SuppressWarnings("unchecked")... |
| 15 |
|
public List<Permission> findByUserId(Integer userId) { |
| 16 |
0
|
List<Permission> permissions; |
| 17 |
|
|
| 18 |
0
|
if (getSession().get(User.class, userId) == null) { |
| 19 |
0
|
throw new NoSuchEntityException("User " + userId + " not found."); |
| 20 |
|
} |
| 21 |
|
|
| 22 |
0
|
try { |
| 23 |
0
|
Query query = getSession().getNamedQuery( |
| 24 |
|
"PermissionsByUserQuery"); |
| 25 |
0
|
query.setInteger("userId", userId); |
| 26 |
0
|
permissions = query.list(); |
| 27 |
|
} catch (HibernateException ex) { |
| 28 |
0
|
throw convertHibernateAccessException(ex); |
| 29 |
|
} |
| 30 |
0
|
return permissions; |
| 31 |
|
} |
| 32 |
|
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 3 |
Complexity Density: 0.3 |
|
| 33 |
0
|
@SuppressWarnings("unchecked")... |
| 34 |
|
public List<Permission> findByProjectIdAndPermission(Integer projectId, |
| 35 |
|
int permissionType) { |
| 36 |
0
|
List<Permission> permissions; |
| 37 |
|
|
| 38 |
0
|
if (getSession().get(Project.class, projectId) == null) { |
| 39 |
0
|
throw new NoSuchEntityException("Project " + projectId + " not found."); |
| 40 |
|
} |
| 41 |
|
|
| 42 |
0
|
try { |
| 43 |
0
|
Query query = getSession().getNamedQuery( |
| 44 |
|
"PermissionsByProjectAndTypeQuery"); |
| 45 |
0
|
query.setInteger("projectId", projectId); |
| 46 |
0
|
query.setInteger("permissionType", permissionType); |
| 47 |
0
|
permissions = query.list(); |
| 48 |
|
} catch (HibernateException ex) { |
| 49 |
0
|
throw convertHibernateAccessException(ex); |
| 50 |
|
} |
| 51 |
0
|
return permissions; |
| 52 |
|
} |
| 53 |
|
|
| 54 |
|
} |