Skip to content

Commit 8de90e0

Browse files
review
1 parent c9e3536 commit 8de90e0

File tree

3 files changed

+12
-115
lines changed

3 files changed

+12
-115
lines changed

src/main/java/org/gridsuite/study/server/StudyController.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import com.powsybl.timeseries.DoubleTimeSeries;
1212
import io.swagger.v3.oas.annotations.Operation;
1313
import io.swagger.v3.oas.annotations.Parameter;
14-
import io.swagger.v3.oas.annotations.media.Content;
1514
import io.swagger.v3.oas.annotations.responses.ApiResponse;
1615
import io.swagger.v3.oas.annotations.responses.ApiResponses;
1716
import io.swagger.v3.oas.annotations.tags.Tag;
@@ -908,7 +907,6 @@ public ResponseEntity<String> getDynamicSimulationProvider(@PathVariable("studyU
908907

909908
@PostMapping(value = "/studies/{studyUuid}/short-circuit-analysis/parameters", consumes = MediaType.APPLICATION_JSON_VALUE)
910909
@Operation(summary = "set short-circuit analysis parameters on study, reset to default ones if empty body")
911-
//@io.swagger.v3.oas.annotations.parameters.RequestBody(required = false, content = @Content(schema = @Schema(implementation = ShortCircuitParametersInfos.class)))
912910
@ApiResponse(responseCode = "200", description = "The short-circuit analysis parameters are set")
913911
public ResponseEntity<Void> setShortCircuitParameters(
914912
@PathVariable("studyUuid") UUID studyUuid,
@@ -918,12 +916,11 @@ public ResponseEntity<Void> setShortCircuitParameters(
918916
return ResponseEntity.ok().build();
919917
}
920918

921-
@GetMapping(value = "/studies/{studyUuid}/short-circuit-analysis/parameters")
919+
@GetMapping(value = "/studies/{studyUuid}/short-circuit-analysis/parameters", produces = MediaType.APPLICATION_JSON_VALUE)
922920
@Operation(summary = "Get short-circuit analysis parameters on study")
923-
@ApiResponse(responseCode = "200", description = "The short-circuit analysis parameters", content = {
924-
@Content(mediaType = MediaType.APPLICATION_JSON_VALUE /*, schema = ...*/)})
921+
@ApiResponse(responseCode = "200", description = "The short-circuit analysis parameters return by shortcircuit-server")
925922
public ResponseEntity<String> getShortCircuitParameters(@PathVariable("studyUuid") UUID studyUuid) {
926-
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(studyService.getShortCircuitParametersInfo(studyUuid));
923+
return ResponseEntity.ok().body(studyService.getShortCircuitParametersInfo(studyUuid));
927924
}
928925

929926
@GetMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/network/substations/{substationId}/svg")
@@ -1766,7 +1763,7 @@ public ResponseEntity<Void> invalidateShortCircuitStatus(@Parameter(description
17661763
return ResponseEntity.ok().build();
17671764
}
17681765

1769-
@PostMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/non-evacuated-energy/run", produces = MediaType.APPLICATION_JSON_VALUE)
1766+
@PostMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/non-evacuated-energy/run")
17701767
@Operation(summary = "run sensitivity analysis non evacuated energy on study")
17711768
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The sensitivity analysis non evacuated energy has started")})
17721769
public ResponseEntity<UUID> runNonEvacuatedEnergy(@Parameter(description = "studyUuid") @PathVariable("studyUuid") UUID studyUuid,

src/main/java/org/gridsuite/study/server/converter/UuidHttpConverter.java

Lines changed: 0 additions & 98 deletions
This file was deleted.

src/main/java/org/gridsuite/study/server/service/shortcircuit/ShortCircuitService.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public UUID runShortCircuit(UUID studyUuid, UUID nodeUuid, Optional<String> busI
8989
HttpHeaders headers = new HttpHeaders();
9090
headers.set(HEADER_USER_ID, userId);
9191
headers.setAccept(List.of(MediaType.TEXT_PLAIN));
92-
return UUID.fromString(restTemplate.postForObject(path, new HttpEntity<>(headers), String.class));
92+
return restTemplate.postForObject(path, new HttpEntity<>(headers), UUID.class);
9393
}
9494

9595
private String getShortCircuitAnalysisResultResourcePath(UUID nodeUuid, ShortcircuitAnalysisType type) {
@@ -281,18 +281,16 @@ public List<String> getEnumValues(String enumName, UUID resultUuid) {
281281
}
282282

283283
public UUID createParameters(@Nullable final String parametersInfos) {
284-
final URI uri = UriComponentsBuilder.fromUriString(shortCircuitServerBaseUri)
285-
.pathSegment(SHORT_CIRCUIT_API_VERSION, "parameters")
286-
.build()
287-
.toUri();
284+
final UriComponentsBuilder uri = UriComponentsBuilder.fromUriString(shortCircuitServerBaseUri)
285+
.pathSegment(SHORT_CIRCUIT_API_VERSION, "parameters");
288286
try {
289287
HttpHeaders headers = new HttpHeaders();
290288
headers.setAccept(List.of(MediaType.TEXT_PLAIN));
291289
if (StringUtils.isBlank(parametersInfos)) {
292-
return UUID.fromString(restTemplate.postForObject(uri, new HttpEntity<>(headers), String.class));
290+
return restTemplate.postForObject(uri.pathSegment("default").build().toUri(), new HttpEntity<>(headers), UUID.class);
293291
} else {
294292
headers.setContentType(MediaType.APPLICATION_JSON);
295-
return UUID.fromString(restTemplate.postForObject(uri, new HttpEntity<>(parametersInfos, headers), String.class));
293+
return restTemplate.postForObject(uri.build().toUri(), new HttpEntity<>(parametersInfos, headers), UUID.class);
296294
}
297295
} catch (final HttpStatusCodeException e) {
298296
throw handleHttpError(e, CREATE_SHORTCIRCUIT_PARAMETERS_FAILED);
@@ -329,11 +327,11 @@ public UUID duplicateParameters(UUID parametersUuid) {
329327
try {
330328
HttpHeaders headers = new HttpHeaders();
331329
headers.setAccept(List.of(MediaType.TEXT_PLAIN));
332-
return UUID.fromString(restTemplate.postForObject(UriComponentsBuilder.fromUriString(shortCircuitServerBaseUri)
330+
return restTemplate.postForObject(UriComponentsBuilder.fromUriString(shortCircuitServerBaseUri)
333331
.pathSegment(SHORT_CIRCUIT_API_VERSION, "parameters")
334332
.queryParam("duplicateFrom", parametersUuid)
335-
.buildAndExpand()
336-
.toUri(), new HttpEntity<>(headers), String.class));
333+
.build()
334+
.toUri(), new HttpEntity<>(headers), UUID.class);
337335
} catch (final HttpStatusCodeException e) {
338336
throw handleHttpError(e, CREATE_SHORTCIRCUIT_PARAMETERS_FAILED);
339337
}

0 commit comments

Comments
 (0)