Skip to content

Commit

Permalink
Add description in parameter element creation (#109)
Browse files Browse the repository at this point in the history
Signed-off-by: David BRAQUART <david.braquart@rte-france.com>
  • Loading branch information
dbraquart authored Oct 29, 2024
1 parent b7ab272 commit 86c1a51
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,10 @@ public ResponseEntity<Void> updateContingencyList(
public ResponseEntity<Void> createParameters(@RequestBody String parameters,
@RequestParam("name") String parametersName,
@RequestParam(name = QUERY_PARAM_TYPE, defaultValue = "") ParametersType parametersType,
@RequestParam(QUERY_PARAM_DESCRIPTION) String description,
@RequestParam(QUERY_PARAM_PARENT_DIRECTORY_ID) UUID parentDirectoryUuid,
@RequestHeader(QUERY_PARAM_USER_ID) String userId) {
exploreService.createParameters(parameters, parametersType, parametersName, parentDirectoryUuid, userId);
exploreService.createParameters(parameters, parametersType, parametersName, description, parentDirectoryUuid, userId);
return ResponseEntity.ok().build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,21 +226,16 @@ private void updateElementName(UUID id, String name, String userId) {
}

private String getProperPath(ContingencyListType contingencyListType) {
switch (contingencyListType) {
case SCRIPT:
return "/script-contingency-lists/{id}";
case FORM:
return "/form-contingency-lists/{id}";
case IDENTIFIERS:
return "/identifier-contingency-lists/{id}";
default:
throw new ExploreException(UNKNOWN_ELEMENT_TYPE);
}
return switch (contingencyListType) {
case SCRIPT -> "/script-contingency-lists/{id}";
case FORM -> "/form-contingency-lists/{id}";
case IDENTIFIERS -> "/identifier-contingency-lists/{id}";
};
}

public void createParameters(String parameters, ParametersType parametersType, String parametersName, UUID parentDirectoryUuid, String userId) {
public void createParameters(String parameters, ParametersType parametersType, String parametersName, String description, UUID parentDirectoryUuid, String userId) {
UUID parametersUuid = parametersService.createParameters(parameters, parametersType);
ElementAttributes elementAttributes = new ElementAttributes(parametersUuid, parametersName, parametersType.name(), userId, 0, null);
ElementAttributes elementAttributes = new ElementAttributes(parametersUuid, parametersName, parametersType.name(), userId, 0, description);
directoryService.createElement(elementAttributes, parentDirectoryUuid, userId);
}

Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/gridsuite/explore/server/ExploreTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,8 @@ void testCreateFilter() throws Exception {

@Test
void testCreateParameters() throws Exception {
mockMvc.perform(post("/v1/explore/parameters?name={name}&type={type}&parentDirectoryUuid={parentDirectoryUuid}",
"", ParametersType.VOLTAGE_INIT_PARAMETERS.name(), PARENT_DIRECTORY_UUID)
mockMvc.perform(post("/v1/explore/parameters?name={name}&type={type}&description={description}&parentDirectoryUuid={parentDirectoryUuid}",
"paramName", ParametersType.VOLTAGE_INIT_PARAMETERS.name(), "comment", PARENT_DIRECTORY_UUID)
.header("userId", USER1)
.contentType(MediaType.APPLICATION_JSON)
.content("\"Parameters content\"")
Expand Down

0 comments on commit 86c1a51

Please sign in to comment.