Skip to content

Package: JobExecutionDAO

JobExecutionDAO

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, JobExecutionCreator)
M: 27 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 6 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%
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, JobExecution)
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.job.execution.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.KapuaNamedEntityAttributes;
20: import org.eclipse.kapua.model.id.KapuaId;
21: import org.eclipse.kapua.model.query.KapuaQuery;
22: import org.eclipse.kapua.service.job.execution.JobExecution;
23: import org.eclipse.kapua.service.job.execution.JobExecutionCreator;
24: import org.eclipse.kapua.service.job.execution.JobExecutionListResult;
25:
26: /**
27: * {@link JobExecution} {@link ServiceDAO}.
28: *
29: * @since 1.0.0
30: */
31: public class JobExecutionDAO {
32:
33: private JobExecutionDAO() {
34: }
35:
36: /**
37: * Creates and return new JobExecution
38: *
39: * @param em
40: * @param jobExecutionCreator
41: * @return
42: * @throws KapuaException
43: * @since 1.0.0
44: */
45: public static JobExecution create(EntityManager em, JobExecutionCreator jobExecutionCreator)
46: throws KapuaException {
47:
48: JobExecutionImpl jobExecutionImpl = new JobExecutionImpl(jobExecutionCreator.getScopeId());
49: jobExecutionImpl.setJobId(jobExecutionCreator.getJobId());
50: jobExecutionImpl.setStartedOn(jobExecutionCreator.getStartedOn());
51: jobExecutionImpl.setEntityAttributes(jobExecutionCreator.getEntityAttributes());
52: jobExecutionImpl.setTargetIds(jobExecutionCreator.getTargetIds());
53:
54: return ServiceDAO.create(em, jobExecutionImpl);
55: }
56:
57: /**
58: * Updates the provided jobExecution
59: *
60: * @param em
61: * @param jobExecution
62: * @return
63: * @throws KapuaException
64: * @since 1.0.0
65: */
66: public static JobExecution update(EntityManager em, JobExecution jobExecution)
67: throws KapuaException {
68: //
69: // Update jobExecution
70: JobExecutionImpl jobExecutionImpl = (JobExecutionImpl) jobExecution;
71:
72: return ServiceDAO.update(em, JobExecutionImpl.class, jobExecutionImpl);
73: }
74:
75: /**
76: * Finds the jobExecution by jobExecution identifier
77: *
78: * @param em
79: * @param scopeId
80: * @param jobExecutionId
81: * @return
82: * @since 1.0.0
83: */
84: public static JobExecution find(EntityManager em, KapuaId scopeId, KapuaId jobExecutionId) {
85: return ServiceDAO.find(em, JobExecutionImpl.class, scopeId, jobExecutionId);
86: }
87:
88: /**
89: * Finds the jobExecution by name
90: *
91: * @param em
92: * @param name
93: * @return
94: * @since 1.0.0
95: */
96: public static JobExecution findByName(EntityManager em, String name) {
97: return ServiceDAO.findByField(em, JobExecutionImpl.class, KapuaNamedEntityAttributes.NAME, name);
98: }
99:
100: /**
101: * Returns the jobExecution list matching the provided query
102: *
103: * @param em
104: * @param jobExecutionQuery
105: * @return
106: * @throws KapuaException
107: * @since 1.0.0
108: */
109: public static JobExecutionListResult query(EntityManager em, KapuaQuery jobExecutionQuery)
110: throws KapuaException {
111: return ServiceDAO.query(em, JobExecution.class, JobExecutionImpl.class, new JobExecutionListResultImpl(), jobExecutionQuery);
112: }
113:
114: /**
115: * Returns the jobExecution count matching the provided query
116: *
117: * @param em
118: * @param jobExecutionQuery
119: * @return
120: * @throws KapuaException
121: * @since 1.0.0
122: */
123: public static long count(EntityManager em, KapuaQuery jobExecutionQuery)
124: throws KapuaException {
125: return ServiceDAO.count(em, JobExecution.class, JobExecutionImpl.class, jobExecutionQuery);
126: }
127:
128: /**
129: * Deletes the jobExecution by jobExecution identifier
130: *
131: * @param em
132: * @param scopeId
133: * @param jobExecutionId
134: * @return deleted entity
135: * @throws KapuaEntityNotFoundException If the {@link JobExecution} is not found
136: * @since 1.0.0
137: */
138: public static JobExecution delete(EntityManager em, KapuaId scopeId, KapuaId jobExecutionId) throws KapuaEntityNotFoundException {
139: return ServiceDAO.delete(em, JobExecutionImpl.class, scopeId, jobExecutionId);
140: }
141:
142: }