Skip to content

Commit

Permalink
Only metadata for network modifications (#458)
Browse files Browse the repository at this point in the history
* Only metadata network modifications
---------

Signed-off-by: Maissa SOUISSI <[email protected]>
Co-authored-by: Slimane AMAR <[email protected]>
  • Loading branch information
souissimai and SlimaneAmar authored Nov 6, 2023
1 parent c3aacce commit 0022dd9
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/main/java/org/gridsuite/study/server/StudyController.java
Original file line number Diff line number Diff line change
Expand Up @@ -1053,10 +1053,10 @@ public ResponseEntity<List<String>> getAvailableSvgComponentLibraries() {
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The network modifications was returned"), @ApiResponse(responseCode = "404", description = "The study/node is not found")})
public ResponseEntity<String> getNetworkModifications(@Parameter(description = "Study UUID") @PathVariable("studyUuid") UUID studyUuid,
@Parameter(description = "Node UUID") @PathVariable("nodeUuid") UUID nodeUuid,
@Parameter(description = "Stashed Modification")
@RequestParam(name = "stashed", required = false, defaultValue = "false") Boolean stashed) {
@Parameter(description = "Stashed Modification") @RequestParam(name = "stashed", required = false, defaultValue = "false") Boolean stashed,
@Parameter(description = "Only metadata") @RequestParam(name = "onlyMetadata", required = false, defaultValue = "false") Boolean onlyMetadata) {
// Return json string because modification dtos are not available here
return ResponseEntity.ok().contentType(MediaType.TEXT_PLAIN).body(networkModificationTreeService.getNetworkModifications(nodeUuid, stashed));
return ResponseEntity.ok().contentType(MediaType.TEXT_PLAIN).body(networkModificationTreeService.getNetworkModifications(nodeUuid, stashed, onlyMetadata));
}

@PostMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/network-modifications")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,12 @@ private String buildPathFrom(UUID networkUuid) {
}

// Return json string because modification dtos are not available here
public String getModifications(UUID groupUUid, boolean stashedModifications) {
public String getModifications(UUID groupUUid, boolean stashedModifications, boolean onlyMetadata) {
Objects.requireNonNull(groupUUid);
var path = UriComponentsBuilder.fromPath(GROUP_PATH + DELIMITER + MODIFICATIONS_PATH)
.queryParam(QUERY_PARAM_ERROR_ON_GROUP_NOT_FOUND, false)
.queryParam("stashed", stashedModifications)
.queryParam("stashed", stashedModifications)
.queryParam("onlyMetadata", onlyMetadata)
.buildAndExpand(groupUUid)
.toUriString();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -552,14 +552,14 @@ public UUID getModificationGroupUuid(UUID nodeUuid) {

// Return json string because modification dtos are not available here
@Transactional(readOnly = true)
public String getNetworkModifications(@NonNull UUID nodeUuid, boolean stashedModifications) {
return networkModificationService.getModifications(getModificationGroupUuid(nodeUuid), stashedModifications);
public String getNetworkModifications(@NonNull UUID nodeUuid, boolean stashedModifications, boolean onlyMetadata) {
return networkModificationService.getModifications(getModificationGroupUuid(nodeUuid), stashedModifications, onlyMetadata);
}

// Return json string because modification dtos are not available here
@Transactional(readOnly = true)
public String getNetworkModifications(@NonNull UUID nodeUuid) {
return getNetworkModifications(nodeUuid, false);
return getNetworkModifications(nodeUuid, false, true);
}

@Transactional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2137,7 +2137,7 @@ public SecurityAnalysisParameters getSecurityAnalysisParameters(UUID studyUuid)
public String getVoltageInitModifications(@NonNull UUID nodeUuid) {
// get modifications group uuid associated to voltage init results
UUID voltageInitModificationsGroupUuid = voltageInitService.getModificationsGroupUuid(nodeUuid);
return networkModificationService.getModifications(voltageInitModificationsGroupUuid, false);
return networkModificationService.getModifications(voltageInitModificationsGroupUuid, false, false);
}

public void copyVoltageInitModifications(UUID studyUuid, UUID nodeUuid, String userId) {
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/gridsuite/study/server/VoltageInitTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public MockResponse dispatch(RecordedRequest request) {
IdentifiableType.GENERATOR, "genId", Set.of("s1"));
return new MockResponse().setResponseCode(200).setBody(objectMapper.writeValueAsString(networkModificationResult))
.addHeader("Content-Type", "application/json; charset=utf-8");
} else if (path.matches("/v1/groups/" + MODIFICATIONS_GROUP_UUID + "/modifications\\?errorOnGroupNotFound=false&stashed=false")) {
} else if (path.matches("/v1/groups/" + MODIFICATIONS_GROUP_UUID + "/modifications\\?errorOnGroupNotFound=false&stashed=false&onlyMetadata=.*")) {
return new MockResponse().setResponseCode(200).setBody(objectMapper.writeValueAsString(VOLTAGE_INIT_PREVIEW_MODIFICATION_LIST))
.addHeader("Content-Type", "application/json; charset=utf-8");
} else if (path.matches("/v1/results/" + VOLTAGE_INIT_RESULT_UUID + "/stop.*")
Expand Down Expand Up @@ -470,7 +470,7 @@ public void testCopyVoltageInitModifications() throws Exception {
mockMvc.perform(get("/v1/studies/{studyUuid}/nodes/{nodeUuid}/voltage-init/modifications", studyNameUserIdUuid, modificationNode3Uuid)
.header("userId", "userId")).andExpect(status().isOk());
assertTrue(TestUtils.getRequestsDone(2, server).stream().allMatch(r ->
r.matches("/v1/groups/" + MODIFICATIONS_GROUP_UUID + "/modifications\\?errorOnGroupNotFound=false&stashed=false") ||
r.matches("/v1/groups/" + MODIFICATIONS_GROUP_UUID + "/modifications\\?errorOnGroupNotFound=false&stashed=false&onlyMetadata=false") ||
r.matches("/v1/results/" + VOLTAGE_INIT_RESULT_UUID + "/modifications-group-uuid")
));

Expand Down

0 comments on commit 0022dd9

Please sign in to comment.