Skip to content

Commit

Permalink
Merge branch 'main' into upgrade_to_powsybl_dependencies_2024.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
FranckLecuyer authored Jan 10, 2025
2 parents 816ee84 + 85fd6ba commit 41c5eee
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,9 @@ public ResponseEntity<List<Object>> getCompositeModificationContent(@PathVariabl
@PutMapping(value = "/explore/filters/{id}", consumes = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Modify a filter")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The filter has been successfully modified")})
public ResponseEntity<Void> changeFilter(@PathVariable UUID id, @RequestBody String filter, @RequestHeader(QUERY_PARAM_USER_ID) String userId, @RequestParam("name") String name) {
exploreService.updateFilter(id, filter, userId, name);
public ResponseEntity<Void> changeFilter(@PathVariable UUID id, @RequestBody String filter, @RequestHeader(QUERY_PARAM_USER_ID) String userId,
@RequestParam("name") String name, @RequestParam("description") String description) {
exploreService.updateFilter(id, filter, userId, name, description);
return ResponseEntity.ok().build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,15 @@ public void deleteElementsFromDirectory(List<UUID> uuids, UUID parentDirectoryUu
}
}

public void updateFilter(UUID id, String filter, String userId, String name) {
public void updateFilter(UUID id, String filter, String userId, String name, String description) {
filterService.updateFilter(id, filter, userId);
updateElementName(id, name, userId);

ElementAttributes elementAttributes = new ElementAttributes();
elementAttributes.setDescription(description);
if (StringUtils.isNotBlank(name)) {
elementAttributes.setElementName(name);
}
directoryService.updateElement(id, elementAttributes, userId);
}

public void updateContingencyList(UUID id, String content, String userId, String name, ContingencyListType contingencyListType) {
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/org/gridsuite/explore/server/ExploreTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -689,11 +689,13 @@ void testCaseCreationErrorWithBadExtension() throws Exception {
void testChangeFilter(final MockWebServer server) throws Exception {
final String filter = "{\"type\":\"CRITERIA\",\"equipmentFilterForm\":{\"equipmentType\":\"BATTERY\",\"name\":\"test bbs\",\"countries\":[\"BS\"],\"nominalVoltage\":{\"type\":\"LESS_THAN\",\"value1\":545430,\"value2\":null},\"freeProperties\":{\"region\":[\"north\"],\"totallyFree\":[\"6555\"],\"tso\":[\"ceps\"]}}}";
final String name = "filter name";
final String description = "new filter description";
mockMvc.perform(put("/v1/explore/filters/{id}",
FILTER_UUID)
.contentType(APPLICATION_JSON)
.content(filter)
.param("name", name)
.param("description", description)
.header("userId", USER1)
).andExpect(status().isOk());

Expand Down

0 comments on commit 41c5eee

Please sign in to comment.