Package: FiredTriggerDAO
FiredTriggerDAO
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
count(EntityManager, KapuaQuery) |
|
|
|
|
|
||||||||||||||||||||
create(EntityManager, FiredTriggerCreator) |
|
|
|
|
|
||||||||||||||||||||
delete(EntityManager, KapuaId, KapuaId) |
|
|
|
|
|
||||||||||||||||||||
find(EntityManager, KapuaId) |
|
|
|
|
|
||||||||||||||||||||
find(EntityManager, KapuaId, KapuaId) |
|
|
|
|
|
||||||||||||||||||||
query(EntityManager, KapuaQuery) |
|
|
|
|
|
Coverage
1: /*******************************************************************************
2: * Copyright (c) 2021, 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.service.scheduler.trigger.fired.quartz;
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.internal.ServiceDAO;
19: import org.eclipse.kapua.model.id.KapuaId;
20: import org.eclipse.kapua.model.query.KapuaQuery;
21: import org.eclipse.kapua.service.scheduler.trigger.fired.FiredTrigger;
22: import org.eclipse.kapua.service.scheduler.trigger.fired.FiredTriggerCreator;
23: import org.eclipse.kapua.service.scheduler.trigger.fired.FiredTriggerListResult;
24:
25: /**
26: * {@link FiredTrigger} DAO.
27: *
28: * @since 1.5.0
29: */
30: public class FiredTriggerDAO {
31:
32: private FiredTriggerDAO() {
33: }
34:
35: /**
36: * Creates and return new FiredTrigger
37: *
38: * @param em The {@link EntityManager} that owns the transaction.
39: * @param firedTriggerCreator The {@link FiredTriggerCreator} to persist.
40: * @return The newly created {@link FiredTrigger}.
41: * @since 1.5.0
42: */
43: public static FiredTrigger create(EntityManager em, FiredTriggerCreator firedTriggerCreator) {
44:
45: FiredTriggerImpl firedTriggerImpl = new FiredTriggerImpl(firedTriggerCreator.getScopeId());
46: firedTriggerImpl.setTriggerId(firedTriggerCreator.getTriggerId());
47: firedTriggerImpl.setFiredOn(firedTriggerCreator.getFiredOn());
48: firedTriggerImpl.setStatus(firedTriggerCreator.getStatus());
49: firedTriggerImpl.setMessage(firedTriggerCreator.getMessage());
50:
51: return ServiceDAO.create(em, firedTriggerImpl);
52: }
53:
54: /**
55: * Finds the firedTrigger by firedTrigger identifier
56: *
57: * @param em The {@link EntityManager} that owns the transaction.
58: * @param firedTriggerId The {@link FiredTrigger#getId()}.
59: * @return The found {@link FiredTrigger} or {@code null}
60: * @since 1.5.0
61: */
62: public static FiredTrigger find(EntityManager em, KapuaId firedTriggerId) {
63: return ServiceDAO.find(em, FiredTriggerImpl.class, null, firedTriggerId);
64: }
65:
66: /**
67: * Finds the {@link FiredTrigger} by {@link FiredTrigger} identifier.
68: *
69: * @param scopeId The {@link FiredTrigger#getScopeId()}.
70: * @param firedTriggerId The {@link FiredTrigger#getId()}.
71: * @return The found {@link FiredTrigger} or {@code null}.
72: * @since 1.5.0
73: */
74: public static FiredTrigger find(EntityManager em, KapuaId scopeId, KapuaId firedTriggerId) {
75: return ServiceDAO.find(em, FiredTriggerImpl.class, scopeId, firedTriggerId);
76: }
77:
78: /**
79: * Returns the firedTrigger list matching the provided query
80: *
81: * @param em The {@link EntityManager} that owns the transaction.
82: * @param firedTriggerQuery The {@link org.eclipse.kapua.service.scheduler.trigger.fired.FiredTriggerQuery} to perform.
83: * @return The {@link FiredTriggerListResult} that matches the given {@link org.eclipse.kapua.service.scheduler.trigger.fired.FiredTriggerQuery}.
84: * @throws KapuaException if error occurs while querying
85: * @since 1.5.0
86: */
87: public static FiredTriggerListResult query(EntityManager em, KapuaQuery firedTriggerQuery)
88: throws KapuaException {
89: return ServiceDAO.query(em, FiredTrigger.class, FiredTriggerImpl.class, new FiredTriggerListResultImpl(), firedTriggerQuery);
90: }
91:
92: /**
93: * Returns the firedTrigger count matching the provided query
94: *
95: * @param em The {@link EntityManager} that owns the transaction.
96: * @param firedTriggerQuery The {@link org.eclipse.kapua.service.scheduler.trigger.fired.FiredTriggerQuery} to perform.
97: * @return The {@link FiredTriggerListResult} that matches the given {@link org.eclipse.kapua.service.scheduler.trigger.fired.FiredTriggerQuery}.
98: * @throws KapuaException if error occurs while counting
99: * @since 1.5.0
100: */
101: public static long count(EntityManager em, KapuaQuery firedTriggerQuery)
102: throws KapuaException {
103: return ServiceDAO.count(em, FiredTrigger.class, FiredTriggerImpl.class, firedTriggerQuery);
104: }
105:
106: /**
107: * Deletes the firedTrigger by firedTrigger identifier
108: *
109: * @param em The {@link EntityManager} that owns the transaction.
110: * @param scopeId The {@link FiredTrigger#getScopeId()}.
111: * @param firedTriggerId The {@link FiredTrigger#getId()}.
112: * @return The deleted {@link FiredTrigger}
113: * @throws KapuaEntityNotFoundException If the {@link FiredTrigger} is not found
114: * @since 1.5.0
115: */
116: public static FiredTrigger delete(EntityManager em, KapuaId scopeId, KapuaId firedTriggerId) throws KapuaEntityNotFoundException {
117: return ServiceDAO.delete(em, FiredTriggerImpl.class, scopeId, firedTriggerId);
118: }
119:
120: }