Skip to content

Package: AccessRoleDAO

AccessRoleDAO

nameinstructionbranchcomplexitylinemethod
AccessRoleDAO()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
count(EntityManager, KapuaQuery)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
create(EntityManager, AccessRoleCreator)
M: 19 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
delete(EntityManager, KapuaId, KapuaId)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
find(EntityManager, KapuaId, KapuaId)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
query(EntityManager, KapuaQuery)
M: 10 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2016, 2020 Eurotech and/or its affiliates and others
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License v1.0
6: * which accompanies this distribution, and is available at
7: * http://www.eclipse.org/legal/epl-v10.html
8: *
9: * Contributors:
10: * Eurotech - initial API and implementation
11: *******************************************************************************/
12: package org.eclipse.kapua.service.authorization.access.shiro;
13:
14: import org.eclipse.kapua.KapuaEntityNotFoundException;
15: import org.eclipse.kapua.KapuaException;
16: import org.eclipse.kapua.commons.jpa.EntityManager;
17: import org.eclipse.kapua.commons.service.internal.ServiceDAO;
18: import org.eclipse.kapua.model.id.KapuaId;
19: import org.eclipse.kapua.model.query.KapuaQuery;
20: import org.eclipse.kapua.service.authorization.access.AccessRole;
21: import org.eclipse.kapua.service.authorization.access.AccessRoleCreator;
22: import org.eclipse.kapua.service.authorization.access.AccessRoleListResult;
23:
24: /**
25: * {@link AccessRole} {@link ServiceDAO}
26: *
27: * @since 1.0
28: */
29: public class AccessRoleDAO extends ServiceDAO {
30:
31: /**
32: * Creates and return new access permission
33: *
34: * @param em
35: * @param creator
36: * @return
37: * @throws KapuaException
38: */
39: public static AccessRole create(EntityManager em, AccessRoleCreator creator)
40: throws KapuaException {
41: AccessRole accessRole = new AccessRoleImpl(creator.getScopeId());
42:
43: accessRole.setAccessInfoId(creator.getAccessInfoId());
44: accessRole.setRoleId(creator.getRoleId());
45:
46: return ServiceDAO.create(em, accessRole);
47: }
48:
49: /**
50: * Find the access info by access permission identifier
51: *
52: * @param em
53: * @param scopeId
54: * @param accessRoleId
55: * @return
56: */
57: public static AccessRole find(EntityManager em, KapuaId scopeId, KapuaId accessRoleId) {
58: return ServiceDAO.find(em , AccessRoleImpl.class, scopeId, accessRoleId);
59: }
60:
61: /**
62: * Return the {@link AccessRole}s list matching the provided query
63: *
64: * @param em
65: * @param accessInfoPermissionQuery
66: * @return
67: * @throws KapuaException
68: */
69: public static AccessRoleListResult query(EntityManager em, KapuaQuery accessInfoPermissionQuery)
70: throws KapuaException {
71: return ServiceDAO.query(em, AccessRole.class, AccessRoleImpl.class, new AccessRoleListResultImpl(), accessInfoPermissionQuery);
72: }
73:
74: /**
75: * Return the count of {@link AccessRole} matching the provided query
76: *
77: * @param em
78: * @param accessPermissionQuery
79: * @return
80: * @throws KapuaException
81: */
82: public static long count(EntityManager em, KapuaQuery accessPermissionQuery)
83: throws KapuaException {
84: return ServiceDAO.count(em, AccessRole.class, AccessRoleImpl.class, accessPermissionQuery);
85: }
86:
87: /**
88: * Delete the access permission by access permission id.
89: *
90: * @param em
91: * @param scopeId
92: * @param accessRoleId
93: * @return the deleted {@link AccessRole}
94: * @throws KapuaEntityNotFoundException
95: * If {@link AccessRole} is not found.
96: */
97: public static AccessRole delete(EntityManager em, KapuaId scopeId, KapuaId accessRoleId) throws KapuaEntityNotFoundException {
98: return ServiceDAO.delete(em, AccessRoleImpl.class, scopeId, accessRoleId);
99: }
100: }