Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/gridsuite/explore-server in…
Browse files Browse the repository at this point in the history
…to handle_access_rights

# Conflicts:
#	src/main/java/org/gridsuite/explore/server/services/ExploreService.java
  • Loading branch information
AAJELLAL committed Jan 17, 2025
2 parents 11db1a9 + 6707762 commit b8273c1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,12 @@ public ResponseEntity<Void> changeFilter(@PathVariable UUID id, @RequestBody Str
public ResponseEntity<Void> updateContingencyList(
@PathVariable UUID id,
@RequestParam(name = "name") String name,
@RequestParam(name = QUERY_PARAM_DESCRIPTION) String description,
@RequestParam(name = "contingencyListType") ContingencyListType contingencyListType,
@RequestBody String content,
@RequestHeader(QUERY_PARAM_USER_ID) String userId) {

exploreService.updateContingencyList(id, content, userId, name, contingencyListType);
exploreService.updateContingencyList(id, content, userId, name, description, contingencyListType);
return ResponseEntity.ok().build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,16 @@ public void updateFilter(UUID id, String filter, String userId, String name, Str
directoryService.updateElement(id, elementAttributes, userId);
}

public void updateContingencyList(UUID id, String content, String userId, String name, ContingencyListType contingencyListType) {
public void updateContingencyList(UUID id, String content, String userId, String name, String description, ContingencyListType contingencyListType) {
// check if the user have the right to update the contingency
directoryService.areDirectoryElementsUpdatable(List.of(id), userId);
contingencyListService.updateContingencyList(id, content, userId, getProperPath(contingencyListType));
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 updateCompositeModification(UUID id, String userId, String name) {
Expand Down
6 changes: 6 additions & 0 deletions src/test/java/org/gridsuite/explore/server/ExploreTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -710,11 +710,13 @@ void testChangeFilter(final MockWebServer server) throws Exception {
void testModifyScriptContingencyList(final MockWebServer server) throws Exception {
final String scriptContingency = "{\"script\":\"alert(\\\"script contingency\\\")\"}";
final String name = "script name";
final String description = "description";
mockMvc.perform(put("/v1/explore/contingency-lists/{id}",
SCRIPT_ID_BASE_FORM_CONTINGENCY_LIST_UUID)
.contentType(APPLICATION_JSON)
.content(scriptContingency)
.param("name", name)
.param("description", description)
.param("contingencyListType", ContingencyListType.SCRIPT.name())
.header("userId", USER1)
).andExpect(status().isOk());
Expand All @@ -726,11 +728,13 @@ void testModifyScriptContingencyList(final MockWebServer server) throws Exceptio
void testModifyFormContingencyList(final MockWebServer server) throws Exception {
final String formContingency = "{\"equipmentType\":\"LINE\",\"name\":\"contingency EN update1\",\"countries1\":[\"AL\"],\"countries2\":[],\"nominalVoltage1\":{\"type\":\"EQUALITY\",\"value1\":45340,\"value2\":null},\"nominalVoltage2\":null,\"freeProperties1\":{},\"freeProperties2\":{}}";
final String name = "form contingency name";
final String description = "form contingency description";
mockMvc.perform(put("/v1/explore/contingency-lists/{id}",
SCRIPT_ID_BASE_FORM_CONTINGENCY_LIST_UUID)
.contentType(APPLICATION_JSON)
.content(formContingency)
.param("name", name)
.param("description", description)
.param("contingencyListType", ContingencyListType.FORM.name())
.header("userId", USER1)
).andExpect(status().isOk());
Expand All @@ -742,12 +746,14 @@ void testModifyFormContingencyList(final MockWebServer server) throws Exception
void testModifyIdentifierContingencyList(final MockWebServer server) throws Exception {
final String identifierContingencyList = "{\"identifierContingencyList\":{\"type\":\"identifier\",\"version\":\"1.0\",\"identifiableType\":\"LINE\",\"identifiers\":[{\"type\":\"LIST\",\"identifierList\":[{\"type\":\"ID_BASED\",\"identifier\":\"34\"},{\"type\":\"ID_BASED\",\"identifier\":\"qs\"}]}]},\"type\":\"IDENTIFIERS\"}";
final String name = "identifier contingencyList name";
final String description = "identifier contingencyList description";
mockMvc.perform(put("/v1/explore/contingency-lists/{id}",
SCRIPT_ID_BASE_FORM_CONTINGENCY_LIST_UUID)
.contentType(APPLICATION_JSON)
.content(identifierContingencyList)
.param("name", name)
.param("contingencyListType", ContingencyListType.IDENTIFIERS.name())
.param("description", description)
.header("userId", USER1)
).andExpect(status().isOk());

Expand Down

0 comments on commit b8273c1

Please sign in to comment.