Skip to content

Package: JobExecutionImpl

JobExecutionImpl

nameinstructionbranchcomplexitylinemethod
JobExecutionImpl()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
JobExecutionImpl(JobExecution)
M: 24 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 7 C: 0
0%
M: 1 C: 0
0%
JobExecutionImpl(KapuaId)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
getEndedOn()
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%
getJobId()
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%
getLog()
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%
getStartedOn()
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%
getTargetIds()
M: 28 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 6 C: 0
0%
M: 1 C: 0
0%
setEndedOn(Date)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
setJobId(KapuaId)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
setLog(String)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
setStartedOn(Date)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
setTargetIds(Set)
M: 25 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 6 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.commons.model.AbstractKapuaUpdatableEntity;
16: import org.eclipse.kapua.commons.model.id.KapuaEid;
17: import org.eclipse.kapua.model.id.KapuaId;
18: import org.eclipse.kapua.service.job.execution.JobExecution;
19:
20: import javax.persistence.AttributeOverride;
21: import javax.persistence.AttributeOverrides;
22: import javax.persistence.CollectionTable;
23: import javax.persistence.Column;
24: import javax.persistence.ElementCollection;
25: import javax.persistence.Embedded;
26: import javax.persistence.Entity;
27: import javax.persistence.JoinColumn;
28: import javax.persistence.Lob;
29: import javax.persistence.Table;
30: import javax.persistence.Temporal;
31: import javax.persistence.TemporalType;
32: import java.util.Date;
33: import java.util.HashSet;
34: import java.util.Set;
35:
36: /**
37: * {@link JobExecution} implementation
38: *
39: * @since 1.0.0
40: */
41: @Entity(name = "JobExecution")
42: @Table(name = "job_job_execution")
43: public class JobExecutionImpl extends AbstractKapuaUpdatableEntity implements JobExecution {
44:
45: private static final long serialVersionUID = -5686107367635300337L;
46:
47: @Embedded
48: @AttributeOverrides({
49: @AttributeOverride(name = "eid", column = @Column(name = "job_id", nullable = false, updatable = false))
50: })
51: private KapuaEid jobId;
52:
53: @Temporal(TemporalType.TIMESTAMP)
54: @Column(name = "started_on", nullable = false, updatable = false)
55: private Date startedOn;
56:
57: @Temporal(TemporalType.TIMESTAMP)
58: @Column(name = "ended_on", nullable = true, updatable = true)
59: private Date endedOn;
60:
61: @ElementCollection
62: @CollectionTable(name = "job_job_execution_target", joinColumns = @JoinColumn(name = "execution_id", referencedColumnName = "id"))
63: @AttributeOverrides({
64: @AttributeOverride(name = "eid", column = @Column(name = "target_id", nullable = false, updatable = false))
65: })
66: private Set<KapuaEid> targetIds;
67:
68: @Lob
69: @Column(name = "log", nullable = true, updatable = true)
70: private String log;
71:
72: /**
73: * Constructor.
74: *
75: * @since 1.0.0
76: */
77: public JobExecutionImpl() {
78: }
79:
80: /**
81: * Constructor.
82: *
83: * @param scopeId The scope {@link KapuaId} to set into the {@link JobExecution}.
84: * @since 1.0.0
85: */
86: public JobExecutionImpl(KapuaId scopeId) {
87: super(scopeId);
88: }
89:
90: /**
91: * Clone constructor.
92: *
93: * @param jobExecution The {@link JobExecution} to clone.
94: * @since 1.1.0
95: */
96: public JobExecutionImpl(JobExecution jobExecution) {
97: super(jobExecution);
98:
99: setJobId(jobExecution.getJobId());
100: setStartedOn(jobExecution.getStartedOn());
101: setEndedOn(jobExecution.getEndedOn());
102: setTargetIds(jobExecution.getTargetIds());
103: setLog(jobExecution.getLog());
104: }
105:
106: @Override
107: public KapuaId getJobId() {
108: return jobId;
109: }
110:
111: @Override
112: public void setJobId(KapuaId jobId) {
113: this.jobId = KapuaEid.parseKapuaId(jobId);
114: }
115:
116: @Override
117: public Date getStartedOn() {
118: return startedOn;
119: }
120:
121: @Override
122: public void setStartedOn(Date startedOn) {
123: this.startedOn = startedOn;
124: }
125:
126: @Override
127: public Date getEndedOn() {
128: return endedOn;
129: }
130:
131: @Override
132: public void setEndedOn(Date endedOn) {
133: this.endedOn = endedOn;
134: }
135:
136:
137: @Override
138: public void setTargetIds(Set<KapuaId> tagIds) {
139: this.targetIds = new HashSet<>();
140:
141:• if (tagIds != null) {
142:• for (KapuaId id : tagIds) {
143: this.targetIds.add(KapuaEid.parseKapuaId(id));
144: }
145: }
146: }
147:
148: @Override
149: public Set<KapuaId> getTargetIds() {
150: Set<KapuaId> tagIds = new HashSet<>();
151:
152:• if (this.targetIds != null) {
153:• for (KapuaId deviceTagId : this.targetIds) {
154: tagIds.add(new KapuaEid(deviceTagId));
155: }
156: }
157:
158: return tagIds;
159: }
160:
161: @Override
162: public String getLog() {
163: return log;
164: }
165:
166: @Override
167: public void setLog(String log) {
168: this.log = log;
169: }
170: }