Skip to content

Package: DeviceManagementOperationDAO

DeviceManagementOperationDAO

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, DeviceManagementOperationCreator)
M: 47 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 11 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, DeviceManagementOperation)
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) 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.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.DeviceManagementOperation;
22: import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperationCreator;
23: import org.eclipse.kapua.service.device.management.registry.operation.DeviceManagementOperationListResult;
24:
25: /**
26: * DeviceManagementOperationNotification DAO
27: *
28: * @since 1.0
29: */
30: public class DeviceManagementOperationDAO {
31:
32: private DeviceManagementOperationDAO() {
33: }
34:
35: /**
36: * Creates and return new DeviceManagementOperationNotification
37: *
38: * @param em
39: * @param deviceManagementOperationCreator
40: * @return
41: * @throws KapuaException
42: */
43: public static DeviceManagementOperation create(EntityManager em, DeviceManagementOperationCreator deviceManagementOperationCreator)
44: throws KapuaException {
45: //
46: // Create DeviceManagementOperationNotification
47:
48: DeviceManagementOperationImpl deviceManagementOperationImpl = new DeviceManagementOperationImpl(deviceManagementOperationCreator.getScopeId());
49: deviceManagementOperationImpl.setStartedOn(deviceManagementOperationCreator.getStartedOn());
50: deviceManagementOperationImpl.setDeviceId(deviceManagementOperationCreator.getDeviceId());
51: deviceManagementOperationImpl.setOperationId(deviceManagementOperationCreator.getOperationId());
52: deviceManagementOperationImpl.setAppId(deviceManagementOperationCreator.getAppId());
53: deviceManagementOperationImpl.setAction(deviceManagementOperationCreator.getAction());
54: deviceManagementOperationImpl.setResource(deviceManagementOperationCreator.getResource());
55: deviceManagementOperationImpl.setStatus(deviceManagementOperationCreator.getStatus());
56: deviceManagementOperationImpl.setStatus(deviceManagementOperationCreator.getStatus());
57: deviceManagementOperationImpl.setInputProperties(deviceManagementOperationCreator.getInputProperties());
58:
59: return ServiceDAO.create(em, deviceManagementOperationImpl);
60: }
61:
62: /**
63: * Updates the provided stepDefinition
64: *
65: * @param em
66: * @param deviceManagementOperation
67: * @return
68: * @throws KapuaException
69: */
70: public static DeviceManagementOperation update(EntityManager em, DeviceManagementOperation deviceManagementOperation)
71: throws KapuaException {
72: DeviceManagementOperationImpl deviceManagementOperationImpl = (DeviceManagementOperationImpl) deviceManagementOperation;
73:
74: return ServiceDAO.update(em, DeviceManagementOperationImpl.class, deviceManagementOperationImpl);
75: }
76:
77: /**
78: * Deletes the stepDefinition by stepDefinition identifier
79: *
80: * @param em
81: * @param scopeId
82: * @param entityId
83: * @return deleted entity
84: * @throws KapuaEntityNotFoundException If the {@link DeviceManagementOperation} is not found
85: */
86: public static DeviceManagementOperation delete(EntityManager em, KapuaId scopeId, KapuaId entityId) throws KapuaEntityNotFoundException {
87: return ServiceDAO.delete(em, DeviceManagementOperationImpl.class, scopeId, entityId);
88: }
89:
90: /**
91: * Finds the stepDefinition by stepDefinition identifier
92: */
93: public static DeviceManagementOperation find(EntityManager em, KapuaId scopeId, KapuaId entityId) {
94: return ServiceDAO.find(em, DeviceManagementOperationImpl.class, scopeId, entityId);
95: }
96:
97: /**
98: * Returns the stepDefinition list matching the provided query
99: *
100: * @param em
101: * @param query
102: * @return
103: * @throws KapuaException
104: */
105: public static DeviceManagementOperationListResult query(EntityManager em, KapuaQuery query)
106: throws KapuaException {
107: return ServiceDAO.query(em, DeviceManagementOperation.class, DeviceManagementOperationImpl.class, new DeviceManagementOperationListResultImpl(), query);
108: }
109:
110: /**
111: * Returns the stepDefinition count matching the provided query
112: *
113: * @param em
114: * @param query
115: * @return
116: * @throws KapuaException
117: */
118: public static long count(EntityManager em, KapuaQuery query)
119: throws KapuaException {
120: return ServiceDAO.count(em, DeviceManagementOperation.class, DeviceManagementOperationImpl.class, query);
121: }
122:
123: }