Skip to content

Package: ManagementOperationNotificationDAO

ManagementOperationNotificationDAO

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, ManagementOperationNotificationCreator)
M: 35 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 8 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) 2017, 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.device.management.registry.operation.notification.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.internal.ServiceDAO;
19: import org.eclipse.kapua.model.id.KapuaId;
20: import org.eclipse.kapua.model.query.KapuaQuery;
21: import org.eclipse.kapua.service.device.management.registry.operation.notification.ManagementOperationNotification;
22: import org.eclipse.kapua.service.device.management.registry.operation.notification.ManagementOperationNotificationCreator;
23: import org.eclipse.kapua.service.device.management.registry.operation.notification.ManagementOperationNotificationListResult;
24:
25: /**
26: * DeviceManagementOperationNotification DAO
27: *
28: * @since 1.0
29: */
30: public class ManagementOperationNotificationDAO {
31:
32: private ManagementOperationNotificationDAO() {
33: }
34:
35: /**
36: * Creates and return new DeviceManagementOperationNotification
37: *
38: * @param em
39: * @param managementOperationNotificationCreator
40: * @return
41: * @throws KapuaException
42: */
43: public static ManagementOperationNotification create(EntityManager em, ManagementOperationNotificationCreator managementOperationNotificationCreator)
44: throws KapuaException {
45: //
46: // Create DeviceManagementOperationNotification
47: ManagementOperationNotificationImpl managementOperationNotification = new ManagementOperationNotificationImpl(managementOperationNotificationCreator.getScopeId());
48: managementOperationNotification.setOperationId(managementOperationNotificationCreator.getOperationId());
49: managementOperationNotification.setSentOn(managementOperationNotificationCreator.getSentOn());
50: managementOperationNotification.setStatus(managementOperationNotificationCreator.getStatus());
51: managementOperationNotification.setResource(managementOperationNotificationCreator.getResource());
52: managementOperationNotification.setProgress(managementOperationNotificationCreator.getProgress());
53: managementOperationNotification.setMessage(managementOperationNotificationCreator.getMessage());
54:
55: return ServiceDAO.create(em, managementOperationNotification);
56: }
57:
58: /**
59: * Deletes the stepDefinition by stepDefinition identifier
60: *
61: * @param em
62: * @param scopeId
63: * @param stepDefinitionId
64: * @return deleted entity
65: * @throws KapuaEntityNotFoundException If the {@link ManagementOperationNotification} is not found
66: */
67: public static ManagementOperationNotification delete(EntityManager em, KapuaId scopeId, KapuaId stepDefinitionId) throws KapuaEntityNotFoundException {
68: return ServiceDAO.delete(em, ManagementOperationNotificationImpl.class, scopeId, stepDefinitionId);
69: }
70:
71: /**
72: * Finds the stepDefinition by stepDefinition identifier
73: */
74: public static ManagementOperationNotification find(EntityManager em, KapuaId scopeId, KapuaId stepDefinitionId) {
75: return ServiceDAO.find(em, ManagementOperationNotificationImpl.class, scopeId, stepDefinitionId);
76: }
77:
78: /**
79: * Returns the stepDefinition list matching the provided query
80: *
81: * @param em
82: * @param stepDefinitionQuery
83: * @return
84: * @throws KapuaException
85: */
86: public static ManagementOperationNotificationListResult query(EntityManager em, KapuaQuery stepDefinitionQuery)
87: throws KapuaException {
88: return ServiceDAO.query(em, ManagementOperationNotification.class, ManagementOperationNotificationImpl.class, new ManagementOperationNotificationListResultImpl(), stepDefinitionQuery);
89: }
90:
91: /**
92: * Returns the stepDefinition count matching the provided query
93: *
94: * @param em
95: * @param stepDefinitionQuery
96: * @return
97: * @throws KapuaException
98: */
99: public static long count(EntityManager em, KapuaQuery stepDefinitionQuery)
100: throws KapuaException {
101: return ServiceDAO.count(em, ManagementOperationNotification.class, ManagementOperationNotificationImpl.class, stepDefinitionQuery);
102: }
103:
104: }