Skip to content

Package: ServiceConfigDAO

ServiceConfigDAO

nameinstructionbranchcomplexitylinemethod
ServiceConfigDAO()
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, ServiceConfigCreatorImpl)
M: 19 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 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: 2 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%
findByName(EntityManager, String)
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, ServiceConfig)
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.configuration;
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.KapuaNamedEntityAttributes;
20: import org.eclipse.kapua.model.id.KapuaId;
21: import org.eclipse.kapua.model.query.KapuaQuery;
22:
23: /**
24: * Service configuration DAO
25: *
26: * @since 1.0
27: *
28: */
29: public class ServiceConfigDAO extends ServiceDAO {
30:
31: /**
32: * Create and return new service configuration
33: *
34: * @param em
35: * @param serviceConfigCreator
36: * @return
37: * @throws KapuaException
38: */
39: public static ServiceConfigImpl create(EntityManager em, ServiceConfigCreatorImpl serviceConfigCreator)
40: throws KapuaException {
41: //
42: // Create service configuration
43: ServiceConfigImpl serviceConfigImpl = new ServiceConfigImpl(serviceConfigCreator.getScopeId());
44:
45: serviceConfigImpl.setPid(serviceConfigCreator.getPid());
46: serviceConfigImpl.setConfigurations(serviceConfigCreator.getConfigurations());
47:
48: return ServiceDAO.create(em, serviceConfigImpl);
49: }
50:
51: /**
52: * Update the provided service configuration
53: *
54: * @param em
55: * @param serviceConfig
56: * @return
57: * @throws KapuaException
58: */
59: public static ServiceConfig update(EntityManager em, ServiceConfig serviceConfig)
60: throws KapuaException {
61: //
62: // Update service configuration
63: ServiceConfigImpl serviceConfigImpl = (ServiceConfigImpl) serviceConfig;
64:
65: return ServiceDAO.update(em, ServiceConfigImpl.class, serviceConfigImpl);
66: }
67:
68: /**
69: * Find the service configuration by user identifier
70: *
71: * @param em
72: * @param scopeId
73: * @param userId
74: * @return
75: */
76: public static ServiceConfig find(EntityManager em, KapuaId scopeId, KapuaId userId) {
77: return ServiceDAO.find(em, ServiceConfigImpl.class, scopeId, userId);
78: }
79:
80: /**
81: * Find the service configuration by service name
82: *
83: * @param em
84: * @param name
85: * @return
86: */
87: public static ServiceConfig findByName(EntityManager em, String name) {
88: return ServiceDAO.findByField(em, ServiceConfigImpl.class, KapuaNamedEntityAttributes.NAME, name);
89: }
90:
91: /**
92: * Return the service configuration list matching the provided query
93: *
94: * @param em
95: * @param serviceConfigQuery
96: * @return
97: * @throws KapuaException
98: */
99: public static ServiceConfigListResult query(EntityManager em, KapuaQuery serviceConfigQuery)
100: throws KapuaException {
101: return ServiceDAO.query(em, ServiceConfig.class, ServiceConfigImpl.class, new ServiceConfigListResultImpl(), serviceConfigQuery);
102: }
103:
104: /**
105: * Return the service configuration count matching the provided query
106: *
107: * @param em
108: * @param serviceConfigQuery
109: * @return
110: * @throws KapuaException
111: */
112: public static long count(EntityManager em, KapuaQuery serviceConfigQuery)
113: throws KapuaException {
114: return ServiceDAO.count(em, ServiceConfig.class, ServiceConfigImpl.class, serviceConfigQuery);
115: }
116:
117: /**
118: * Delete the service configuration by user identifier
119: *
120: * @param em
121: * @param scopeId
122: * @param userId
123: * @throws KapuaEntityNotFoundException
124: * If {@link ServiceConfig} is not found.
125: */
126: public static void delete(EntityManager em, KapuaId scopeId, KapuaId userId) throws KapuaEntityNotFoundException {
127: ServiceDAO.delete(em, ServiceConfigImpl.class, scopeId, userId);
128: }
129:
130: }