diff --git a/gradle.properties b/gradle.properties index 7d06532..a547ea3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ group=org.ceskaexpedice -version=1.3-rc1 +version=1.3-rc2 diff --git a/process-manager/src/main/java/org/ceskaexpedice/processplatform/manager/api/ProcessEndpoint.java b/process-manager/src/main/java/org/ceskaexpedice/processplatform/manager/api/ProcessEndpoint.java index adbe700..3767412 100644 --- a/process-manager/src/main/java/org/ceskaexpedice/processplatform/manager/api/ProcessEndpoint.java +++ b/process-manager/src/main/java/org/ceskaexpedice/processplatform/manager/api/ProcessEndpoint.java @@ -69,7 +69,16 @@ public Response getProcess(@PathParam("processId") String processId) { } @GET - @Path("batch") + @Path("batch/{mainProcessId}") + @Produces(MediaType.APPLICATION_JSON) + public Response getBatch(@PathParam("mainProcessId") String mainProcessId) { + Batch batch = processService.getBatch(mainProcessId); + JSONObject batchJson = ProcessServiceMapper.mapBatchToJson(batch); + return APIRestUtilities.jsonPayload(batchJson.toString()); + } + + @GET + @Path("batches") @Produces(MediaType.APPLICATION_JSON) public Response getBatches( @QueryParam("offset") String offsetStr, diff --git a/process-manager/src/main/webapp/openapi/openapi.yaml b/process-manager/src/main/webapp/openapi/openapi.yaml index 081ae1e..d0a866c 100644 --- a/process-manager/src/main/webapp/openapi/openapi.yaml +++ b/process-manager/src/main/webapp/openapi/openapi.yaml @@ -678,7 +678,7 @@ paths: '404': description: Process not found - /process/batch: + /process/batches: get: tags: - Processes @@ -817,6 +817,66 @@ paths: description: Bad request - wrong parameters /process/batch/{mainProcessId}: + get: + tags: + - Processes + summary: Returns the batch specified + description: Returns the batch specified + parameters: + - name: mainProcessId + in: path + required: true + description: Main process id + schema: + type: string + example: ed25ce29-2149-439d-85c4-cc5e516e3036 + responses: + '200': + description: JSON representation of the batch + content: + application/json: + schema: + type: string + example: { + "owner" : "PePo", + "processes" : [ { + "owner" : "PePo", + "workerId" : "curatorWorker", + "processId" : "6853579d-15c1-4fb9-ad11-3e107141aedb", + "payload" : { + "surname" : "Po", + "name" : "Pe" + }, + "profileId" : "testPlugin1-big", + "description" : "NewProcessName-PePo", + "pid" : 27204, + "started" : 1755262856918, + "finished" : 1755262857087, + "planned" : 1755262848459, + "batchId" : "6853579d-15c1-4fb9-ad11-3e107141aedb", + "status" : "FINISHED" + }, { + "owner" : "PePo", + "workerId" : "curatorWorker", + "processId" : "114a8406-1788-4cc5-bb04-89ca1a8ba9fe", + "payload" : { }, + "profileId" : "testPlugin2", + "description" : "Sub process for the profile testPlugin2", + "pid" : 10900, + "started" : 1755262858373, + "finished" : 1755262858428, + "planned" : 1755262857057, + "batchId" : "6853579d-15c1-4fb9-ad11-3e107141aedb", + "status" : "FINISHED" + } ], + "mainProcessId" : "ed25ce29-2149-439d-85c4", + "started" : 1755262856918, + "finished" : 1755262857087, + "planned" : 1755262848459, + "status" : "FINISHED" + } + '404': + description: Process not found delete: tags: - Processes diff --git a/process-manager/src/test/java/org/ceskaexpedice/processplatform/manager/api/TestProcessEndpoint.java b/process-manager/src/test/java/org/ceskaexpedice/processplatform/manager/api/TestProcessEndpoint.java index 4a183e5..d5ecfa2 100644 --- a/process-manager/src/test/java/org/ceskaexpedice/processplatform/manager/api/TestProcessEndpoint.java +++ b/process-manager/src/test/java/org/ceskaexpedice/processplatform/manager/api/TestProcessEndpoint.java @@ -106,6 +106,34 @@ public void testGetProcess() throws JsonProcessingException { verify(processServiceMock, times(2)).getProcess(any()); } + @Test + public void testGetBatch() { + Batch batch = new Batch(); + batch.setMainProcessId(PROCESS1_ID); + batch.setStatus(ProcessState.WARNING); + ProcessInfo processInfo1 = new ProcessInfo(); + processInfo1.setPlanned(new Date()); + processInfo1.setProcessId(PROCESS1_ID); + processInfo1.setBatchId(PROCESS1_ID); + processInfo1.setStatus(ProcessState.FINISHED); + batch.getProcesses().add(processInfo1); + ProcessInfo processInfo2 = new ProcessInfo(); + processInfo2.setProcessId(PROCESS2_ID); + processInfo2.setBatchId(PROCESS1_ID); + processInfo2.setStatus(ProcessState.WARNING); + batch.getProcesses().add(processInfo2); + + when(processServiceMock.getBatch(eq(PROCESS1_ID))).thenReturn(batch); + + Response response = target("process/batch/" + PROCESS1_ID).request().accept(MediaType.APPLICATION_JSON_TYPE).get(); + Assertions.assertEquals(200, response.getStatus()); + String json = response.readEntity(String.class); + JSONObject jsonObject = new JSONObject(json); + Assertions.assertEquals(PROCESS1_ID, jsonObject.getString("mainProcessId")); + + verify(processServiceMock, times(1)).getBatch(eq(PROCESS1_ID)); + } + @Test public void testGetBatches() { List batches = new ArrayList<>(); @@ -138,7 +166,7 @@ public void testGetBatches() { when(processServiceMock.countBatchHeaders(any())).thenReturn(2); when(processServiceMock.getBatches(any(), eq(0), eq(10))).thenReturn(batches); - Response response = target("process/batch").request().accept(MediaType.APPLICATION_JSON_TYPE).get(); + Response response = target("process/batches").request().accept(MediaType.APPLICATION_JSON_TYPE).get(); Assertions.assertEquals(200, response.getStatus()); String json = response.readEntity(String.class); JSONObject jsonObject = new JSONObject(json);