Skip to content

Package: JobStepDAO

JobStepDAO

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, JobStepCreator)
M: 36 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%
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, JobStep)
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.step.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.step.JobStep;
23: import org.eclipse.kapua.service.job.step.JobStepCreator;
24: import org.eclipse.kapua.service.job.step.JobStepListResult;
25:
26: /**
27: * JobStep DAO
28: *
29: * @since 1.0
30: */
31: public class JobStepDAO {
32:
33: private JobStepDAO() {
34: }
35:
36: /**
37: * Creates and return new JobStep
38: *
39: * @param em
40: * @param jobStepCreator
41: * @return
42: * @throws KapuaException
43: */
44: public static JobStep create(EntityManager em, JobStepCreator jobStepCreator)
45: throws KapuaException {
46: //
47: // Create JobStep
48:
49: JobStepImpl jobStepImpl = new JobStepImpl(jobStepCreator.getScopeId());
50: jobStepImpl.setName(jobStepCreator.getName());
51: jobStepImpl.setDescription(jobStepCreator.getDescription());
52: jobStepImpl.setJobId(jobStepCreator.getJobId());
53: jobStepImpl.setJobStepDefinitionId(jobStepCreator.getJobStepDefinitionId());
54: jobStepImpl.setStepIndex(jobStepCreator.getStepIndex());
55: jobStepImpl.setStepProperties(jobStepCreator.getStepProperties());
56:
57: return ServiceDAO.create(em, jobStepImpl);
58: }
59:
60: /**
61: * Updates the provided jobStep
62: *
63: * @param em
64: * @param jobStep
65: * @return
66: * @throws KapuaException
67: */
68: public static JobStep update(EntityManager em, JobStep jobStep)
69: throws KapuaException {
70: //
71: // Update jobStep
72: JobStepImpl jobStepImpl = (JobStepImpl) jobStep;
73:
74: return ServiceDAO.update(em, JobStepImpl.class, jobStepImpl);
75: }
76:
77: /**
78: * Finds the jobStep by jobStep identifier
79: *
80: * @param em
81: * @param scopeId
82: * @param jobStepId
83: * @return
84: */
85: public static JobStep find(EntityManager em, KapuaId scopeId, KapuaId jobStepId) {
86: return ServiceDAO.find(em, JobStepImpl.class, scopeId, jobStepId);
87: }
88:
89: /**
90: * Finds the jobStep by name
91: *
92: * @param em
93: * @param name
94: * @return
95: */
96: public static JobStep findByName(EntityManager em, String name) {
97: return ServiceDAO.findByField(em, JobStepImpl.class, KapuaNamedEntityAttributes.NAME, name);
98: }
99:
100: /**
101: * Returns the jobStep list matching the provided query
102: *
103: * @param em
104: * @param jobStepQuery
105: * @return
106: * @throws KapuaException
107: */
108: public static JobStepListResult query(EntityManager em, KapuaQuery jobStepQuery)
109: throws KapuaException {
110: return ServiceDAO.query(em, JobStep.class, JobStepImpl.class, new JobStepListResultImpl(), jobStepQuery);
111: }
112:
113: /**
114: * Returns the jobStep count matching the provided query
115: *
116: * @param em
117: * @param jobStepQuery
118: * @return
119: * @throws KapuaException
120: */
121: public static long count(EntityManager em, KapuaQuery jobStepQuery)
122: throws KapuaException {
123: return ServiceDAO.count(em, JobStep.class, JobStepImpl.class, jobStepQuery);
124: }
125:
126:
127: /**
128: * Deletes the jobStep by jobStep identifier
129: *
130: * @param em
131: * @param scopeId
132: * @param jobStepId
133: * @return the deleted entity
134: * @throws KapuaEntityNotFoundException If the {@link JobStep} is not found
135: */
136: public static JobStep delete(EntityManager em, KapuaId scopeId, KapuaId jobStepId) throws KapuaEntityNotFoundException {
137: return ServiceDAO.delete(em, JobStepImpl.class, scopeId, jobStepId);
138: }
139: }