Skip to content

Package: AccessPermissionDAO

AccessPermissionDAO

nameinstructionbranchcomplexitylinemethod
AccessPermissionDAO()
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, AccessPermissionCreator)
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.AccessPermission;
21: import org.eclipse.kapua.service.authorization.access.AccessPermissionCreator;
22: import org.eclipse.kapua.service.authorization.access.AccessPermissionListResult;
23:
24: /**
25: * {@link AccessPermission} {@link ServiceDAO}
26: *
27: * @since 1.0
28: *
29: */
30: public class AccessPermissionDAO extends ServiceDAO {
31:
32: /**
33: * Creates and return new access permission
34: *
35: * @param em
36: * @param creator
37: * @return
38: * @throws KapuaException
39: */
40: public static AccessPermission create(EntityManager em, AccessPermissionCreator creator)
41: throws KapuaException {
42: AccessPermission accessPermission = new AccessPermissionImpl(creator.getScopeId());
43:
44: accessPermission.setAccessInfoId(creator.getAccessInfoId());
45: accessPermission.setPermission(creator.getPermission());
46:
47: return ServiceDAO.create(em, accessPermission);
48: }
49:
50: /**
51: * Find the access info by access permission identifier
52: *
53: * @param em
54: * @param scopeId
55: * @param accessPermissionId
56: * @return
57: */
58: public static AccessPermission find(EntityManager em, KapuaId scopeId, KapuaId accessPermissionId) {
59: return ServiceDAO.find(em, AccessPermissionImpl.class, scopeId, accessPermissionId);
60: }
61:
62: /**
63: * Return the {@link AccessPermission}s list matching the provided query
64: *
65: * @param em
66: * @param accessInfoPermissionQuery
67: * @return
68: * @throws KapuaException
69: */
70: public static AccessPermissionListResult query(EntityManager em, KapuaQuery accessInfoPermissionQuery)
71: throws KapuaException {
72: return ServiceDAO.query(em, AccessPermission.class, AccessPermissionImpl.class, new AccessPermissionListResultImpl(), accessInfoPermissionQuery);
73: }
74:
75: /**
76: * Return the count of {@link AccessPermission} matching the provided query
77: *
78: * @param em
79: * @param accessPermissionQuery
80: * @return
81: * @throws KapuaException
82: */
83: public static long count(EntityManager em, KapuaQuery accessPermissionQuery)
84: throws KapuaException {
85: return ServiceDAO.count(em, AccessPermission.class, AccessPermissionImpl.class, accessPermissionQuery);
86: }
87:
88: /**
89: * Delete the access permission by access permission id.
90: *
91: * @param em
92: * @param scopeId
93: * @param accessPermissionId
94: * @return the deleted {@link AccessPermission}
95: * @throws KapuaEntityNotFoundException
96: * If {@link AccessPermission} is not found.
97: */
98: public static AccessPermission delete(EntityManager em, KapuaId scopeId, KapuaId accessPermissionId) throws KapuaEntityNotFoundException {
99: return ServiceDAO.delete(em, AccessPermissionImpl.class, scopeId, accessPermissionId);
100: }
101: }