Skip to content

Commit

Permalink
chore(rest): expose batch id for job and historic job log to REST API
Browse files Browse the repository at this point in the history
Related to #4206
  • Loading branch information
mboskamp committed Sep 20, 2024
1 parent 552c152 commit 468ec80
Show file tree
Hide file tree
Showing 15 changed files with 61 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,17 @@
The name of the host of the Process Engine where the
job of this historic job log entry was executed."
/>


<@lib.property
name = "batchId"
type = "string"
desc = "The ID of the batch associated with this job. `null` if no batch is associated with this job. The
following jobs are associated with batches:
* Seed Jobs
* Monitor Jobs
* Batch Execution Jobs"
/>

<@lib.property
name = "creationLog"
type = "boolean"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,16 @@
type = "string"
format = "date-time"
desc = "The date on which this job has been created."
/>

<@lib.property
name = "batchId"
type = "string"
desc = "The ID of the batch associated with this job. `null` if no batch is associated with this job. The
following jobs are associated with batches:
* Seed Jobs
* Monitor Jobs
* Batch Execution Jobs"
last = true
/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"rootProcessInstanceId": "aRootProcessInstanceId",
"tenantId": null,
"hostname": "aHostname",
"batchId": "aBatchId",
"creationLog": true,
"failureLog": false,
"successLog": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"rootProcessInstanceId": "aRootProcessInstanceId",
"tenantId": null,
"hostname": "aHostname",
"batchId": "aBatchId",
"creationLog": true,
"failureLog": false,
"successLog": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"rootProcessInstanceId": "aRootProcessInstanceId",
"tenantId": null,
"hostname": "aHostname",
"batchId": "aBatchId",
"creationLog": true,
"failureLog": false,
"successLog": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"suspended": false,
"priority": 10,
"tenantId": null,
"createTime": "2018-05-05T17:00:00+0200"
"createTime": "2018-05-05T17:00:00+0200",
"batchId": "aBatchId"
},
{
"id": "anotherJobId",
Expand All @@ -65,7 +66,8 @@
"suspended": true,
"priority": 8,
"tenantId": null,
"createTime": "2018-05-05T17:00:00+0200"
"createTime": "2018-05-05T17:00:00+0200",
"batchId": null
}
]
}']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@
"suspended": false,
"priority": 10,
"tenantId": null,
"createTime": "2018-05-05T17:00:00+0200"
"createTime": "2018-05-05T17:00:00+0200",
"batchId": "aBatchId"
},
{
"id": "anotherJobId",
Expand All @@ -98,7 +99,8 @@
"suspended": true,
"priority": 8,
"tenantId": null,
"createTime": "2018-05-05T17:00:00+0200"
"createTime": "2018-05-05T17:00:00+0200",
"batchId": null
}
]
}']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"suspended": false,
"priority": 10,
"tenantId": null,
"createTime": "2018-05-05T17:00:00+0200"
"createTime": "2018-05-05T17:00:00+0200",
"batchId": "aBatchId"
}
}']
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public class HistoricJobLogDto {
protected String tenantId;
protected String hostname;
protected String rootProcessInstanceId;
protected String batchId;

protected boolean creationLog;
protected boolean failureLog;
Expand Down Expand Up @@ -140,6 +141,10 @@ public String getRootProcessInstanceId() {
return rootProcessInstanceId;
}

public String getBatchId() {
return batchId;
}

public boolean isCreationLog() {
return creationLog;
}
Expand Down Expand Up @@ -183,6 +188,7 @@ public static HistoricJobLogDto fromHistoricJobLog(HistoricJobLog historicJobLog
result.tenantId = historicJobLog.getTenantId();
result.hostname = historicJobLog.getHostname();
result.rootProcessInstanceId = historicJobLog.getRootProcessInstanceId();
result.batchId = historicJobLog.getBatchId();

result.creationLog = historicJobLog.isCreationLog();
result.failureLog = historicJobLog.isFailureLog();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class JobDto {
protected long priority;
protected String tenantId;
protected Date createTime;
protected String batchId;

public static JobDto fromJob(Job job) {
JobDto dto = new JobDto();
Expand All @@ -53,6 +54,7 @@ public static JobDto fromJob(Job job) {
dto.priority = job.getPriority();
dto.tenantId = job.getTenantId();
dto.createTime = job.getCreateTime();
dto.batchId = job.getBatchId();

return dto;
}
Expand Down Expand Up @@ -113,4 +115,8 @@ public Date getCreateTime() {
return createTime;
}

public String getBatchId() {
return batchId;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public void setUpRuntimeData() {
.jobDefinitionId(MockProvider.EXAMPLE_JOB_DEFINITION_ID)
.tenantId(MockProvider.EXAMPLE_TENANT_ID)
.createTime(DateTimeUtil.parseDate(MockProvider.EXAMPLE_JOB_CREATE_TIME))
.batchId(MockProvider.EXAMPLE_BATCH_ID)
.build();

when(mockQuery.singleResult()).thenReturn(mockedJob);
Expand Down Expand Up @@ -294,6 +295,7 @@ public void testSimpleJobGet() {
.body("jobDefinitionId", equalTo(MockProvider.EXAMPLE_JOB_DEFINITION_ID))
.body("tenantId", equalTo(MockProvider.EXAMPLE_TENANT_ID))
.body("createTime", equalTo(MockProvider.EXAMPLE_JOB_CREATE_TIME))
.body("batchId", equalTo(MockProvider.EXAMPLE_BATCH_ID))
.when()
.get(SINGLE_JOB_RESOURCE_URL);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ public void testSimpleJobQuery() {
String returnedJobDefinitionId= from(content).getString("[0].jobDefinitionId");
String returnedTenantId = from(content).getString("[0].tenantId");
String returnedCreateTime = from(content).getString("[0].createTime");
String returnedBatchId = from(content).getString("[0].batchId");

Assert.assertEquals(MockProvider.EXAMPLE_JOB_ID, returnedJobId);
Assert.assertEquals(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID, returnedProcessInstanceId);
Expand All @@ -179,6 +180,7 @@ public void testSimpleJobQuery() {
Assert.assertEquals(MockProvider.EXAMPLE_JOB_DEFINITION_ID, returnedJobDefinitionId);
Assert.assertEquals(MockProvider.EXAMPLE_TENANT_ID, returnedTenantId);
Assert.assertEquals(MockProvider.EXAMPLE_JOB_CREATE_TIME, returnedCreateTime);
Assert.assertEquals(MockProvider.EXAMPLE_BATCH_ID, returnedBatchId);
}

private interface DateParameters {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class MockJobBuilder {
protected String tenantId;
protected Date createTime;
protected String failedActivityId;
protected String batchId;

public MockJobBuilder id(String id) {
this.id = id;
Expand Down Expand Up @@ -110,6 +111,11 @@ public MockJobBuilder failedActivityId(String failedActivityId) {
return this;
}

public MockJobBuilder batchId(String batchId) {
this.batchId = batchId;
return this;
}

public Job build() {
Job mockJob = mock(Job.class);
when(mockJob.getId()).thenReturn(id);
Expand All @@ -126,6 +132,7 @@ public Job build() {
when(mockJob.getTenantId()).thenReturn(tenantId);
when(mockJob.getCreateTime()).thenReturn(createTime);
when(mockJob.getFailedActivityId()).thenReturn(failedActivityId);
when(mockJob.getBatchId()).thenReturn(batchId);
return mockJob;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1868,7 +1868,8 @@ public static MockJobBuilder mockJob() {
.priority(EXAMPLE_JOB_PRIORITY)
.jobDefinitionId(EXAMPLE_JOB_DEFINITION_ID)
.createTime(DateTimeUtil.parseDate(EXAMPLE_JOB_CREATE_TIME))
.failedActivityId(EXAMPLE_JOB_FAILED_ACTIVITY_ID);
.failedActivityId(EXAMPLE_JOB_FAILED_ACTIVITY_ID)
.batchId(EXAMPLE_BATCH_ID);
}

public static List<Job> createMockJobs() {
Expand Down Expand Up @@ -2985,6 +2986,7 @@ public static HistoricJobLog createMockHistoricJobLog(String tenantId) {
when(mock.getTenantId()).thenReturn(tenantId);
when(mock.getRootProcessInstanceId()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_ROOT_PROC_INST_ID);
when(mock.getHostname()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_HOSTNAME);
when(mock.getBatchId()).thenReturn(EXAMPLE_BATCH_ID);

when(mock.isCreationLog()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_IS_CREATION_LOG);
when(mock.isFailureLog()).thenReturn(EXAMPLE_HISTORIC_JOB_LOG_IS_FAILURE_LOG);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public void testSimpleHistoricJobLogGet() {
.body("tenantId", equalTo(MockProvider.EXAMPLE_TENANT_ID))
.body("hostname", equalTo(MockProvider.EXAMPLE_HISTORIC_JOB_LOG_HOSTNAME))
.body("rootProcessInstanceId", equalTo(MockProvider.EXAMPLE_HISTORIC_JOB_LOG_ROOT_PROC_INST_ID))
.body("batchId", equalTo(MockProvider.EXAMPLE_BATCH_ID))
.body("creationLog", equalTo(MockProvider.EXAMPLE_HISTORIC_JOB_LOG_IS_CREATION_LOG))
.body("failureLog", equalTo(MockProvider.EXAMPLE_HISTORIC_JOB_LOG_IS_FAILURE_LOG))
.body("successLog", equalTo(MockProvider.EXAMPLE_HISTORIC_JOB_LOG_IS_SUCCESS_LOG))
Expand Down

0 comments on commit 468ec80

Please sign in to comment.