From b222828026dac33d3439adb9acbdfbbcdc38b05b Mon Sep 17 00:00:00 2001 From: ramari16 Date: Wed, 21 Aug 2024 15:22:02 -0400 Subject: [PATCH] ALS-7132: Revert change breaking query sync for dataframes (#117) --- .../dbmi/avillach/hpds/service/PicSureService.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/service/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/service/PicSureService.java b/service/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/service/PicSureService.java index b88c97f7..a32839ad 100644 --- a/service/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/service/PicSureService.java +++ b/service/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/service/PicSureService.java @@ -296,6 +296,19 @@ private ResponseEntity _querySync(QueryRequest resultRequest) throws IOException case DATAFRAME: case SECRET_ADMIN_DATAFRAME: + QueryStatus status = query(resultRequest).getBody(); + while (status.getResourceStatus().equalsIgnoreCase("RUNNING") + || status.getResourceStatus().equalsIgnoreCase("PENDING")) { + status = queryStatus(UUID.fromString(status.getResourceResultId()), null); + } + log.info(status.toString()); + + AsyncResult result = queryService.getResultFor(status.getResourceResultId()); + if (result.getStatus() == AsyncResult.Status.SUCCESS) { + result.getStream().open(); + return queryOkResponse(new String(result.getStream().readAllBytes(), StandardCharsets.UTF_8), incomingQuery, MediaType.TEXT_PLAIN); + } + return ResponseEntity.status(400).contentType(MediaType.APPLICATION_JSON).body("Status : " + result.getStatus().name()); case CROSS_COUNT: return queryOkResponse(countProcessor.runCrossCounts(incomingQuery), incomingQuery, MediaType.APPLICATION_JSON);