-
Notifications
You must be signed in to change notification settings - Fork 160
/
JpaExecutionInstanceData.java
175 lines (139 loc) · 5.33 KB
/
JpaExecutionInstanceData.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
/*******************************************************************************
* Copyright (c) 2019 Eurotech and/or its affiliates and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Eurotech - initial API and implementation
*******************************************************************************/
package org.eclipse.kapua.job.engine.jbatch.persistence.jpa;
import com.ibm.jbatch.container.jobinstance.JobOperatorJobExecution;
import javax.batch.runtime.BatchStatus;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import java.sql.Timestamp;
import java.util.Date;
import java.util.Properties;
@Entity(name = "ExecutionInstanceData")
@Table(name = "jbtc_execution_instance_data")
@NamedQueries({
@NamedQuery(name = "ExecutionInstanceData.getByJobInstance",
query = "SELECT eid FROM ExecutionInstanceData eid WHERE eid.jobInstanceId = :jobInstanceId ORDER BY eid.createTime DESC"),
@NamedQuery(name = "ExecutionInstanceData.getRunningByJobName",
query = "SELECT eid.id FROM ExecutionInstanceData eid INNER JOIN JobInstanceData jid ON eid.jobInstanceId = jid.id WHERE eid.batchStatus IN (:status1, :status2, :status3) AND jid.name = :jobName")
})
public class JpaExecutionInstanceData extends AbstractJpaJbatchEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "jobexecid", updatable = false, nullable = false)
private long id;
@Column(name = "jobinstanceid", updatable = false, nullable = false)
private long jobInstanceId;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "createtime")
private Date createTime;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "starttime")
private Date startTime;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "endtime")
private Date endTime;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "updatetime")
private Date updateTime;
@Lob
@Column(name = "parameters")
private byte[] parameters;
@Enumerated(EnumType.STRING)
@Column(name = "batchstatus")
private BatchStatus batchStatus;
@Column(name = "exitstatus")
private String exitStatus;
public JpaExecutionInstanceData() {
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public long getJobInstanceId() {
return jobInstanceId;
}
public void setJobInstanceId(long jobInstanceId) {
this.jobInstanceId = jobInstanceId;
}
public Timestamp getCreateTime() {
return createTime != null ? new Timestamp(createTime.getTime()) : null;
}
public void setCreateTime(Timestamp createTime) {
this.createTime = createTime;
}
public Timestamp getStartTime() {
return startTime != null ? new Timestamp(startTime.getTime()) : null;
}
public void setStartTime(Timestamp startTime) {
this.startTime = startTime;
}
public Timestamp getEndTime() {
return endTime != null ? new Timestamp(endTime.getTime()) : null;
}
public void setEndTime(Timestamp endTime) {
this.endTime = endTime;
}
public Timestamp getUpdateTime() {
return updateTime != null ? new Timestamp(updateTime.getTime()) : null;
}
public void setUpdateTime(Timestamp updateTime) {
this.updateTime = updateTime;
}
public byte[] getParameters() {
return parameters;
}
public Properties getParametersAsProperties() {
return readObject(getParameters());
}
public void setParameters(byte[] parameters) {
this.parameters = parameters;
}
public void setParameters(Properties parameters) {
setParameters(writeObject(parameters));
}
public BatchStatus getBatchStatus() {
return batchStatus;
}
public void setBatchStatus(BatchStatus batchStatus) {
this.batchStatus = batchStatus;
}
public String getExitStatus() {
return exitStatus;
}
public void setExitStatus(String exitStatus) {
this.exitStatus = exitStatus;
}
public JobOperatorJobExecution toJobExecution() {
JobOperatorJobExecution jobOperatorJobExecution = new JobOperatorJobExecution(getId(), getJobInstanceId());
jobOperatorJobExecution.setCreateTime(getCreateTime());
jobOperatorJobExecution.setStartTime(getStartTime());
jobOperatorJobExecution.setEndTime(getEndTime());
jobOperatorJobExecution.setLastUpdateTime(getUpdateTime());
jobOperatorJobExecution.setJobParameters(getParametersAsProperties());
jobOperatorJobExecution.setBatchStatus(getBatchStatus().name());
jobOperatorJobExecution.setExitStatus(getExitStatus());
return jobOperatorJobExecution;
}
}