diff --git a/src/main/java/cz/cvut/kbss/study/rest/PatientRecordController.java b/src/main/java/cz/cvut/kbss/study/rest/PatientRecordController.java index 0a51aae2..cf4720bf 100644 --- a/src/main/java/cz/cvut/kbss/study/rest/PatientRecordController.java +++ b/src/main/java/cz/cvut/kbss/study/rest/PatientRecordController.java @@ -179,8 +179,10 @@ public RecordImportResult importRecordsJson(@RequestPart("file") MultipartFile f } @PostMapping(value = "/import/excel", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) - public RecordImportResult importRecordsExcel(@RequestPart("file") MultipartFile file, - @RequestParam(name = "phase", required = false) String phase) { + public RecordImportResult importRecordsExcel( + @RequestPart("file") MultipartFile file, + @RequestParam(name = "phase", required = false) String phase, + @RequestParam(name = "detached", required = false, defaultValue = "true") boolean detached) { List records; @@ -200,6 +202,22 @@ public RecordImportResult importRecordsExcel(@RequestPart("file") MultipartFile HttpEntity> requestEntity = new HttpEntity<>(body, headers); + if (detached) { // Implement variant where import is handled fully by external service + ResponseEntity responseEntity = restTemplate.postForEntity( + URI.create(excelImportServiceUrl), + requestEntity, + byte[].class + ); + + LOG.info("Import finished with status {}", responseEntity.getStatusCode()); + if (responseEntity.getStatusCode() == HttpStatus.OK) { + byte[] responseBody = responseEntity.getBody(); + LOG.debug("Response body length is {}", responseBody.length); + } + + return new RecordImportResult(); + } + ResponseEntity> responseEntity = restTemplate.exchange( URI.create(excelImportServiceUrl), HttpMethod.POST,