Skip to content

Package: EventStoreDAO

EventStoreDAO

nameinstructionbranchcomplexitylinemethod
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, EventStoreRecord)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 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%
update(EntityManager, EventStoreRecord)
M: 9 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2016, 2022 Eurotech and/or its affiliates and others
3: *
4: * This program and the accompanying materials are made
5: * available under the terms of the Eclipse Public License 2.0
6: * which is available at https://www.eclipse.org/legal/epl-2.0/
7: *
8: * SPDX-License-Identifier: EPL-2.0
9: *
10: * Contributors:
11: * Eurotech - initial API and implementation
12: *******************************************************************************/
13: package org.eclipse.kapua.commons.service.event.store.internal;
14:
15: import org.eclipse.kapua.KapuaEntityNotFoundException;
16: import org.eclipse.kapua.KapuaException;
17: import org.eclipse.kapua.commons.jpa.EntityManager;
18: import org.eclipse.kapua.commons.service.event.store.api.EventStoreRecord;
19: import org.eclipse.kapua.commons.service.event.store.api.EventStoreRecordListResult;
20: import org.eclipse.kapua.commons.service.internal.ServiceDAO;
21: import org.eclipse.kapua.model.id.KapuaId;
22: import org.eclipse.kapua.model.query.KapuaQuery;
23:
24: public class EventStoreDAO {
25:
26: private EventStoreDAO() {
27: }
28:
29: /**
30: * Creates and return new KapuaEvent
31: *
32: * @param em
33: * @param kapuaEvent
34: * @return
35: * @throws KapuaException
36: */
37: public static EventStoreRecord create(EntityManager em, EventStoreRecord kapuaEvent)
38: throws KapuaException {
39: return ServiceDAO.create(em, kapuaEvent);
40: }
41:
42: /**
43: * Updates the provided KapuaEvent
44: *
45: * @param em
46: * @param kapuaEvent
47: * @return
48: * @throws KapuaException
49: */
50: public static EventStoreRecord update(EntityManager em, EventStoreRecord kapuaEvent)
51: throws KapuaException {
52:
53: EventStoreRecordImpl kapuaEventImpl = (EventStoreRecordImpl) kapuaEvent;
54:
55: return ServiceDAO.update(em, EventStoreRecordImpl.class, kapuaEventImpl);
56: }
57:
58: /**
59: * Finds the event by event identifier
60: *
61: * @param em
62: * @param scopeId
63: * @param eventId
64: * @return
65: */
66: public static EventStoreRecord find(EntityManager em, KapuaId scopeId, KapuaId eventId) {
67: return ServiceDAO.find(em, EventStoreRecordImpl.class, scopeId, eventId);
68: }
69:
70: /**
71: * Returns the kapuaEvent list matching the provided query
72: *
73: * @param em
74: * @param kapuaEventQuery
75: * @return
76: * @throws KapuaException
77: */
78: public static EventStoreRecordListResult query(EntityManager em, KapuaQuery kapuaEventQuery)
79: throws KapuaException {
80: return ServiceDAO.query(em, EventStoreRecord.class, EventStoreRecordImpl.class, new EventStoreRecordListResultImpl(), kapuaEventQuery);
81: }
82:
83: /**
84: * Returns the kapuaEvent count matching the provided query
85: *
86: * @param em
87: * @param kapuaEventQuery
88: * @return
89: * @throws KapuaException
90: */
91: public static long count(EntityManager em, KapuaQuery kapuaEventQuery)
92: throws KapuaException {
93: return ServiceDAO.count(em, EventStoreRecord.class, EventStoreRecordImpl.class, kapuaEventQuery);
94: }
95:
96: /**
97: * Deletes the kapua event by event identifier
98: *
99: * @param em
100: * @param scopeId
101: * @param eventId
102: * @return deleted entity
103: * @throws KapuaEntityNotFoundException
104: */
105: public static EventStoreRecord delete(EntityManager em, KapuaId scopeId, KapuaId eventId) throws KapuaEntityNotFoundException {
106: return ServiceDAO.delete(em, EventStoreRecordImpl.class, scopeId, eventId);
107: }
108: }