Skip to content

Commit e1a4922

Browse files
review
1 parent 4240325 commit e1a4922

File tree

3 files changed

+16
-108
lines changed

3 files changed

+16
-108
lines changed

src/main/java/org/gridsuite/shortcircuit/server/ParametersController.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import static org.springframework.http.MediaType.TEXT_PLAIN_VALUE;
2323

2424
@RestController
25-
@RequestMapping(path = "/" + ShortCircuitApi.API_VERSION + "/parameters")
25+
@RequestMapping(path = "/" + ShortCircuitApi.API_VERSION + "/parameters", produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
2626
@Tag(name = "Short circuit server analysis parameters")
2727
public class ParametersController {
2828
private final ShortCircuitService shortCircuitService;
@@ -31,23 +31,29 @@ public ParametersController(ShortCircuitService shortCircuitService) {
3131
this.shortCircuitService = shortCircuitService;
3232
}
3333

34-
@GetMapping(path = "/{parametersUuid}", produces = APPLICATION_JSON_VALUE)
34+
@GetMapping(path = "/{parametersUuid}")
3535
@Operation(summary = "Get the parameters for an analysis")
3636
@ApiResponse(responseCode = "200", description = "The parameters asked")
3737
@ApiResponse(responseCode = "404", description = "The parameters don't exists")
3838
public ResponseEntity<ShortCircuitParametersInfos> getParameters(@Parameter(description = "UUID of parameters") @PathVariable("parametersUuid") UUID parametersUuid) {
3939
return ResponseEntity.of(shortCircuitService.getParameters(parametersUuid));
4040
}
4141

42-
@PostMapping(produces = TEXT_PLAIN_VALUE, consumes = APPLICATION_JSON_VALUE)
43-
@Operation(summary = "Create a new set of parameters for an analysis using default parameters if none given")
42+
@PostMapping
43+
@Operation(summary = "Create a new set of parameters for an analysis using given parameters")
4444
@ApiResponse(responseCode = "200", description = "The new parameters entity ID")
45-
public ResponseEntity<UUID> createParameters(@Parameter(description = "Parameters to save instead of default ones", schema = @Schema(implementation = ShortCircuitParametersInfos.class))
46-
@RequestBody(required = false) ShortCircuitParametersInfos parameters) {
45+
public ResponseEntity<UUID> createParameters(@Parameter(description = "Parameters to save") @RequestBody(required = false) ShortCircuitParametersInfos parameters) {
4746
return ResponseEntity.ok(shortCircuitService.createParameters(parameters));
4847
}
4948

50-
@PostMapping(params = { "duplicateFrom" }, produces = TEXT_PLAIN_VALUE)
49+
@PostMapping(path = "/default")
50+
@Operation(summary = "Create a new set of parameters for an analysis using default parameters")
51+
@ApiResponse(responseCode = "200", description = "The new parameters entity ID")
52+
public ResponseEntity<UUID> createDefaultParameters() {
53+
return ResponseEntity.ok(shortCircuitService.createParameters(null));
54+
}
55+
56+
@PostMapping(params = { "duplicateFrom" })
5157
@Operation(summary = "Duplicate the parameters of an analysis")
5258
@ApiResponse(responseCode = "200", description = "The new parameters ID")
5359
@ApiResponse(responseCode = "404", description = "The parameters don't exist")
@@ -63,7 +69,7 @@ public ResponseEntity<Void> deleteParameters(@Parameter(description = "UUID of p
6369
return shortCircuitService.deleteParameters(parametersUuid) ? ResponseEntity.noContent().build() : ResponseEntity.notFound().build();
6470
}
6571

66-
@PutMapping(path = "/{parametersUuid}", consumes = APPLICATION_JSON_VALUE)
72+
@PutMapping(path = "/{parametersUuid}")
6773
@Operation(summary = "Update a set of parameters for an analysis or reset them to default ones")
6874
@ApiResponse(responseCode = "204", description = "The parameters are successfully updated")
6975
@ApiResponse(responseCode = "404", description = "The parameters don't exists")

src/main/java/org/gridsuite/shortcircuit/server/ShortCircuitController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public ShortCircuitController(ShortCircuitService shortCircuitService) {
4444
this.shortCircuitService = shortCircuitService;
4545
}
4646

47-
@PostMapping(value = "/networks/{networkUuid}/run-and-save", produces = TEXT_PLAIN_VALUE, consumes = APPLICATION_JSON_VALUE)
47+
@PostMapping(value = "/networks/{networkUuid}/run-and-save", produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
4848
@Operation(summary = "Run a short circuit analysis on a network")
4949
@ApiResponse(responseCode = "200", description = "The short circuit analysis has been performed")
5050
public ResponseEntity<UUID> runAndSave(@Parameter(description = "Network UUID") @PathVariable("networkUuid") UUID networkUuid,
@@ -58,7 +58,7 @@ public ResponseEntity<UUID> runAndSave(@Parameter(description = "Network UUID")
5858
@Parameter(description = "Parameters (full or partial) to use on top of the ones designed by parametersUuid", schema = @Schema(implementation = ShortCircuitParameters.class))
5959
@RequestBody(required = false) Optional<ShortCircuitParametersInfos> parameters,
6060
@RequestHeader(HEADER_USER_ID) String userId) {
61-
return ResponseEntity.ok().contentType(TEXT_PLAIN).body(shortCircuitService.runAndSaveResult(networkUuid, variantId, receiver, reportUuid, reporterId, reportType, userId, busId, parametersUuid, parameters));
61+
return ResponseEntity.ok().contentType(APPLICATION_JSON).body(shortCircuitService.runAndSaveResult(networkUuid, variantId, receiver, reportUuid, reporterId, reportType, userId, busId, parametersUuid, parameters));
6262
}
6363

6464
@GetMapping(value = "/results/{resultUuid}", produces = APPLICATION_JSON_VALUE)

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

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

0 commit comments

Comments
 (0)