Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
Tristan-WorkGH committed Jun 10, 2024
1 parent c9e3536 commit 8de90e0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 115 deletions.
11 changes: 4 additions & 7 deletions src/main/java/org/gridsuite/study/server/StudyController.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import com.powsybl.timeseries.DoubleTimeSeries;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
Expand Down Expand Up @@ -908,7 +907,6 @@ public ResponseEntity<String> getDynamicSimulationProvider(@PathVariable("studyU

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

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

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

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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public UUID runShortCircuit(UUID studyUuid, UUID nodeUuid, Optional<String> busI
HttpHeaders headers = new HttpHeaders();
headers.set(HEADER_USER_ID, userId);
headers.setAccept(List.of(MediaType.TEXT_PLAIN));
return UUID.fromString(restTemplate.postForObject(path, new HttpEntity<>(headers), String.class));
return restTemplate.postForObject(path, new HttpEntity<>(headers), UUID.class);
}

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

public UUID createParameters(@Nullable final String parametersInfos) {
final URI uri = UriComponentsBuilder.fromUriString(shortCircuitServerBaseUri)
.pathSegment(SHORT_CIRCUIT_API_VERSION, "parameters")
.build()
.toUri();
final UriComponentsBuilder uri = UriComponentsBuilder.fromUriString(shortCircuitServerBaseUri)
.pathSegment(SHORT_CIRCUIT_API_VERSION, "parameters");
try {
HttpHeaders headers = new HttpHeaders();
headers.setAccept(List.of(MediaType.TEXT_PLAIN));
if (StringUtils.isBlank(parametersInfos)) {
return UUID.fromString(restTemplate.postForObject(uri, new HttpEntity<>(headers), String.class));
return restTemplate.postForObject(uri.pathSegment("default").build().toUri(), new HttpEntity<>(headers), UUID.class);
} else {
headers.setContentType(MediaType.APPLICATION_JSON);
return UUID.fromString(restTemplate.postForObject(uri, new HttpEntity<>(parametersInfos, headers), String.class));
return restTemplate.postForObject(uri.build().toUri(), new HttpEntity<>(parametersInfos, headers), UUID.class);
}
} catch (final HttpStatusCodeException e) {
throw handleHttpError(e, CREATE_SHORTCIRCUIT_PARAMETERS_FAILED);
Expand Down Expand Up @@ -329,11 +327,11 @@ public UUID duplicateParameters(UUID parametersUuid) {
try {
HttpHeaders headers = new HttpHeaders();
headers.setAccept(List.of(MediaType.TEXT_PLAIN));
return UUID.fromString(restTemplate.postForObject(UriComponentsBuilder.fromUriString(shortCircuitServerBaseUri)
return restTemplate.postForObject(UriComponentsBuilder.fromUriString(shortCircuitServerBaseUri)
.pathSegment(SHORT_CIRCUIT_API_VERSION, "parameters")
.queryParam("duplicateFrom", parametersUuid)
.buildAndExpand()
.toUri(), new HttpEntity<>(headers), String.class));
.build()
.toUri(), new HttpEntity<>(headers), UUID.class);
} catch (final HttpStatusCodeException e) {
throw handleHttpError(e, CREATE_SHORTCIRCUIT_PARAMETERS_FAILED);
}
Expand Down

0 comments on commit 8de90e0

Please sign in to comment.