Merge branch 'master' into rel_7_1_tracking

This commit is contained in:
dotasek.dev
2024-04-29 09:23:49 -04:00
11 changed files with 132 additions and 31 deletions

View File

@@ -0,0 +1,42 @@
package ca.uhn.fhir.jpa.starter.web;
import ca.uhn.fhir.batch2.api.IJobCoordinator;
import ca.uhn.fhir.batch2.api.JobOperationResultJson;
import ca.uhn.fhir.batch2.model.JobInstance;
import ca.uhn.fhir.batch2.model.StatusEnum;
import ca.uhn.fhir.batch2.models.JobInstanceFetchRequest;
import jakarta.validation.constraints.Min;
import org.springframework.data.domain.Sort;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("control")
public class JobController {
private final IJobCoordinator theJobCoordinator;
public JobController(IJobCoordinator theJobCoordinator) {
this.theJobCoordinator = theJobCoordinator;
}
@RequestMapping(value = JobController.JOBS, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public List<JobInstance> getAllJobs(@RequestParam(name = "pageStart") @Min(0) int pageStart, @RequestParam(name = "batchSize") int batchSize, @RequestParam(name = "jobStatus", required = false) StatusEnum jobStatus) {
JobInstanceFetchRequest jobInstanceFetchRequest = new JobInstanceFetchRequest();
jobInstanceFetchRequest.setPageStart(pageStart);
jobInstanceFetchRequest.setBatchSize(batchSize);
jobInstanceFetchRequest.setJobStatus(jobStatus != null ? jobStatus.toString() : "");
jobInstanceFetchRequest.setSort(Sort.by(Sort.Direction.DESC, JobController.MY_CREATE_TIME));
return theJobCoordinator.fetchAllJobInstances(jobInstanceFetchRequest).getContent();
}
@RequestMapping(value = JobController.JOBS, method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
public JobOperationResultJson cancelInstance(@RequestParam(name = "instanceId") String instanceId) {
return theJobCoordinator.cancelInstance(instanceId);
}
public static final String JOBS = "jobs";
public static final String MY_CREATE_TIME = "myCreateTime";
}

View File

@@ -1,7 +1,8 @@
#Uncomment the following lines to enable the fhir endpoint to be available at /example/path/fhir instead of /fhir
#server:
#Uncomment the "servlet" and "context-path" lines below to make the fhir endpoint available at /example/path/fhir instead of the default value of /fhir
server:
# servlet:
# context-path: /example/path
port: 8080
#Adds the option to go to eg. http://localhost:8080/actuator/health for seeing the running configuration
#see https://docs.spring.io/spring-boot/docs/current/reference/html/actuator.html#actuator.endpoints
management: