Skip to content

Commit

Permalink
[Fix partially kbss-cvut/record-manager-ui#180] Add publish rest api
Browse files Browse the repository at this point in the history
  • Loading branch information
kostobog authored and blcham committed Jul 21, 2024
1 parent 86e9419 commit 228584a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/main/java/cz/cvut/kbss/study/rest/PatientRecordController.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,24 @@ public ResponseEntity<Void> createRecord(@RequestBody PatientRecord record) {
return new ResponseEntity<>(headers, HttpStatus.CREATED);
}

@PreAuthorize(
"hasRole('" + SecurityConstants.ROLE_ADMIN + "') or @securityUtils.isMemberOfInstitution(#institutionKey)")
@PostMapping(value = "/publish", produces = {MediaType.APPLICATION_JSON_VALUE})
public RecordImportResult publishRecords(
@RequestParam(name = "institution", required = false) String institutionKey,
@RequestParam(required = false) MultiValueMap<String, String> params){
// final Page<PatientRecord> result = recordService.findAllFull(RecordFilterMapper.constructRecordFilter(params),
// RestUtils.resolvePaging(params));
// List<PatientRecord> records = result.getContent();
List<PatientRecord> records = new ArrayList<>();
String publishServiceUrl = configReader.getConfig(ConfigParam.PUBLISH_SERVICE_URL);
LOG.debug("Publishing records.");
RecordImportResult response = restTemplate.postForEntity(URI.create(publishServiceUrl), records, RecordImportResult.class).getBody();

LOG.debug("Publish server response: ", response);
return response;
}

@PostMapping(value = "/import/json", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public RecordImportResult importRecordsJson(@RequestPart("file") MultipartFile file,
@RequestParam(name = "phase", required = false) String phase) {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/cz/cvut/kbss/study/util/ConfigParam.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public enum ConfigParam {
FORM_GEN_SERVICE_URL("formGenServiceUrl"),

ON_UPDATE_RECORD_SERVICE_URL("onRecordUpdateServiceUrl"),
PUBLISH_SERVICE_URL("publishServiceUrl"),
EXCEL_IMPORT_SERVICE_URL("excelImportServiceUrl"),

APP_CONTEXT("appContext"),
Expand Down

0 comments on commit 228584a

Please sign in to comment.