Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,19 @@ public ResponseEntity<Void> renameSpreadsheetConfig(
return ResponseEntity.noContent().build();
}

@PutMapping("/{id}/sort")
@Operation(summary = "Update the spreadsheet configuration sort",
description = "Update the spreadsheet configuration sort")
@ApiResponse(responseCode = "204", description = "Configuration sort updated")
@ApiResponse(responseCode = "404", description = "Configuration not found")
public ResponseEntity<Void> updateSpreadsheetConfigSort(
@PathVariable("studyUuid") UUID studyUuid,
@Parameter(description = "ID of the configuration to update") @PathVariable UUID id,
@Parameter(description = "New sort configuration") @RequestBody String sortConfig) {
studyService.updateSpreadsheetConfigSort(studyUuid, id, sortConfig);
return ResponseEntity.noContent().build();
}

@PutMapping("/{id}/reset-filters")
@Operation(summary = "Reset global and column filters",
description = "Reset all columns filters in a spreadsheet configuration as well as the global filter")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,15 @@ public void renameSpreadsheetConfig(UUID configUuid, String newName) {
restTemplate.exchange(studyConfigServerBaseUri + path, HttpMethod.PUT, httpEntity, String.class);
}

public void updateSpreadsheetConfigSort(UUID configUuid, String sortConfig) {
var uriBuilder = UriComponentsBuilder.fromPath(DELIMITER + STUDY_CONFIG_API_VERSION + SPREADSHEET_CONFIG_WITH_ID_URI + "/sort");
String path = uriBuilder.buildAndExpand(configUuid).toUriString();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<String> httpEntity = new HttpEntity<>(sortConfig, headers);
restTemplate.exchange(studyConfigServerBaseUri + path, HttpMethod.PUT, httpEntity, String.class);
}

public void updateSpreadsheetConfig(UUID configUuid, String spreadsheetConfigInfos) {
var uriBuilder = UriComponentsBuilder.fromPath(DELIMITER + STUDY_CONFIG_API_VERSION + SPREADSHEET_CONFIG_WITH_ID_URI);
String path = uriBuilder.buildAndExpand(configUuid).toUriString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3622,6 +3622,11 @@ public void renameSpreadsheetConfig(UUID studyUuid, UUID configUuid, String newN
notificationService.emitSpreadsheetConfigChanged(studyUuid, configUuid);
}

public void updateSpreadsheetConfigSort(UUID studyUuid, UUID configUuid, String sortConfig) {
studyConfigService.updateSpreadsheetConfigSort(configUuid, sortConfig);
notificationService.emitSpreadsheetConfigChanged(studyUuid, configUuid);
}

public void updateSpreadsheetConfig(UUID studyUuid, UUID configUuid, String spreadsheetConfigInfos) {
studyConfigService.updateSpreadsheetConfig(configUuid, spreadsheetConfigInfos);
notificationService.emitSpreadsheetConfigChanged(studyUuid, configUuid);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,35 @@ void testRename() throws Exception {
WireMockUtils.verifyPutRequest(wireMockServer, stubId, configServerUrl, false, Map.of(), body);
}

@Test
void testUpdateSort() throws Exception {
StudyEntity studyEntity = insertStudy();
String configServerUrl = "/v1/spreadsheet-configs/" + SPREADSHEET_CONFIG_UUID + "/sort";

UUID stubId = wireMockServer.stubFor(WireMock.put(WireMock.urlPathEqualTo(configServerUrl))
.willReturn(WireMock.noContent())).getId();

String body = objectMapper.writeValueAsString("some parameters");
mockMvc.perform(put("/v1/studies/{studyUuid}/spreadsheet-config/{configUuid}/sort", studyEntity.getId(), SPREADSHEET_CONFIG_UUID)
.header("content-type", "application/json")
.content(body))
.andExpect(status().isNoContent())
.andReturn();
checkSpreadsheetTabUpdateMessageReceived(studyEntity.getId());
WireMockUtils.verifyPutRequest(wireMockServer, stubId, configServerUrl, false, Map.of(), body);

stubId = wireMockServer.stubFor(WireMock.put(WireMock.urlPathEqualTo(configServerUrl))
.willReturn(WireMock.notFound())).getId();

body = objectMapper.writeValueAsString("some parameters");
mockMvc.perform(put("/v1/studies/{studyUuid}/spreadsheet-config/{configUuid}/sort", studyEntity.getId(), SPREADSHEET_CONFIG_UUID)
.header("content-type", "application/json")
.content(body))
.andExpect(status().isNotFound())
.andReturn();
WireMockUtils.verifyPutRequest(wireMockServer, stubId, configServerUrl, false, Map.of(), body);
}

@Test
void testDeleteColumn() throws Exception {
StudyEntity studyEntity = insertStudy();
Expand Down