Skip to content

Package: AccessInfoDAO

AccessInfoDAO

nameinstructionbranchcomplexitylinemethod
AccessInfoDAO()
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, AccessInfoCreator)
M: 15 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 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.AccessInfo;
21: import org.eclipse.kapua.service.authorization.access.AccessInfoCreator;
22: import org.eclipse.kapua.service.authorization.access.AccessInfoListResult;
23:
24: /**
25: * {@link AccessInfo} DAO
26: *
27: * @since 1.0.0
28: */
29: public class AccessInfoDAO extends ServiceDAO {
30:
31: /**
32: * Creates and return new {@link AccessInfo}
33: *
34: * @param em
35: * @param creator
36: * @return
37: * @throws KapuaException
38: * @since 1.0.0
39: */
40: public static AccessInfo create(EntityManager em, AccessInfoCreator creator)
41: throws KapuaException {
42: AccessInfo accessInfo = new AccessInfoImpl(creator.getScopeId());
43: accessInfo.setUserId(creator.getUserId());
44: return ServiceDAO.create(em, accessInfo);
45: }
46:
47: /**
48: * Find the {@link AccessInfo} by user {@link AccessInfo} identifier
49: *
50: * @param em
51: * @param scopeId
52: * @param accessInfoId
53: * @return
54: * @since 1.0.0
55: */
56: public static AccessInfo find(EntityManager em, KapuaId scopeId, KapuaId accessInfoId) {
57: return ServiceDAO.find(em, AccessInfoImpl.class, scopeId, accessInfoId);
58: }
59:
60: /**
61: * Return the {@link AccessInfo} list matching the provided query
62: *
63: * @param em
64: * @param accessInfoQuery
65: * @return
66: * @throws KapuaException
67: * @since 1.0.0
68: */
69: public static AccessInfoListResult query(EntityManager em, KapuaQuery accessInfoQuery)
70: throws KapuaException {
71: return ServiceDAO.query(em, AccessInfo.class, AccessInfoImpl.class, new AccessInfoListResultImpl(), accessInfoQuery);
72: }
73:
74: /**
75: * Return the {@link AccessInfo} count matching the provided query
76: *
77: * @param em
78: * @param accessInfoQuery
79: * @return
80: * @throws KapuaException
81: * @since 1.0.0
82: */
83: public static long count(EntityManager em, KapuaQuery accessInfoQuery)
84: throws KapuaException {
85: return ServiceDAO.count(em, AccessInfo.class, AccessInfoImpl.class, accessInfoQuery);
86: }
87:
88: /**
89: * Delete the {@link AccessInfo} by {@link AccessInfo} identifier
90: *
91: * @param em
92: * @param scopeId
93: * @param accessInfoId
94: * @return the deleted {@link AccessInfo}
95: * @throws KapuaEntityNotFoundException If {@link AccessInfo} is nott found.
96: * @since 1.0.0
97: */
98: public static AccessInfo delete(EntityManager em, KapuaId scopeId, KapuaId accessInfoId) throws KapuaEntityNotFoundException {
99: return ServiceDAO.delete(em, AccessInfoImpl.class, scopeId, accessInfoId);
100: }
101:
102: }