use of bio.terra.workspace.generated.model.ApiJobReport in project terra-workspace-manager by DataBiosphere.
the class JobService method retrieveAsyncJobResult.
/**
* Retrieves the result of an asynchronous job.
*
* <p>Stairway has no concept of synchronous vs asynchronous flights. However, MC Terra has a
* service-level standard result for asynchronous jobs which includes a ApiJobReport and either a
* result or error if the job is complete. This is a convenience for callers who would otherwise
* need to construct their own AsyncJobResult object.
*
* <p>Unlike retrieveJobResult, this will not throw for a flight in progress. Instead, it will
* return a ApiJobReport without a result or error.
*/
public <T> AsyncJobResult<T> retrieveAsyncJobResult(String jobId, Class<T> resultClass, AuthenticatedUserRequest userRequest) {
try {
// jobId=flightId
verifyUserAccess(jobId, userRequest);
ApiJobReport jobReport = retrieveJob(jobId, userRequest);
if (jobReport.getStatus().equals(StatusEnum.RUNNING)) {
return new AsyncJobResult<T>().jobReport(jobReport);
}
JobResultOrException<T> resultOrException = retrieveJobResultWorker(jobId, resultClass);
final ApiErrorReport errorReport;
if (jobReport.getStatus().equals(StatusEnum.FAILED)) {
errorReport = ErrorReportUtils.buildApiErrorReport(resultOrException.getException());
} else {
errorReport = null;
}
return new AsyncJobResult<T>().jobReport(jobReport).result(resultOrException.getResult()).errorReport(errorReport);
} catch (StairwayException | InterruptedException stairwayEx) {
throw new InternalStairwayException(stairwayEx);
}
}
use of bio.terra.workspace.generated.model.ApiJobReport in project terra-workspace-manager by DataBiosphere.
the class JobServiceTest method testEnumRange.
// Get some range and compare it with the fids
private void testEnumRange(List<String> fids, int offset, int limit) {
List<ApiJobReport> jobList = jobService.enumerateJobs(offset, limit, testUser);
assertThat(jobList, notNullValue());
int index = offset;
for (ApiJobReport job : jobList) {
validateJobReport(job, index, fids);
index++;
}
}
Aggregations