Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import static org.gridsuite.study.server.StudyConstants.HEADER_USER_ID;
import static org.gridsuite.study.server.dto.ComputationType.STATE_ESTIMATION;
import static org.gridsuite.study.server.nodeactivity.NodeActivityType.COMPUTE;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;

/**
* @author Bassel El Cheikh <bassel.el-cheikh_externe at rte-france.com>
Expand Down Expand Up @@ -96,4 +97,16 @@ public ResponseEntity<Void> stopStateEstimation(@Parameter(description = "Study
rootNetworkNodeInfoService.stopStateEstimation(studyUuid, nodeUuid, rootNetworkUuid);
return ResponseEntity.ok().build();
}

@PostMapping(value = "/logical-controls", produces = APPLICATION_JSON_VALUE)
@Operation(summary = "Run logical controls on a study node")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The computation has been done and the results are returned")})
Comment thread
dbraquart marked this conversation as resolved.
public ResponseEntity<String> computeLogicalControls(@Parameter(description = "studyUuid") @PathVariable("studyUuid") UUID studyUuid,
@PathVariable("rootNetworkUuid") UUID rootNetworkUuid,
@Parameter(description = "nodeUuid") @PathVariable("nodeUuid") UUID nodeUuid) {
studyService.assertIsNodeNotReadOnly(nodeUuid); // can be rm ?
// no quota on this small synchronous computation
String result = stateEstimationService.computeLogicalControls(studyUuid, nodeUuid, rootNetworkUuid);
return result != null ? ResponseEntity.ok().body(result) : ResponseEntity.noContent().build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -232,4 +232,21 @@ public ResponseEntity<Resource> downloadDebugFile(UUID resultUuid) {
.buildAndExpand(resultUuid).toUriString();
return getRestTemplate().exchange(getBaseUri() + path, HttpMethod.GET, null, Resource.class);
}

public String runLogicalComputation(UUID networkUuid, String variantId, UUID parametersUuid) {
var uriComponentsBuilder = UriComponentsBuilder.fromPath(DELIMITER + STATE_ESTIMATION_API_VERSION + "/networks/{networkUuid}/logical-controls");
if (parametersUuid != null) {
uriComponentsBuilder.queryParam("parametersUuid", parametersUuid.toString());
}
if (!StringUtils.isBlank(variantId)) {
uriComponentsBuilder.queryParam(QUERY_PARAM_VARIANT_ID, variantId);
}
var path = uriComponentsBuilder.buildAndExpand(networkUuid).toUriString();

HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<Void> httpEntity = new HttpEntity<>(null, headers);

return restTemplate.exchange(baseUri + path, HttpMethod.POST, httpEntity, String.class).getBody();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,11 @@ public ResponseEntity<Resource> downloadDebugFile(UUID resultUuid) {
return stateEstimationRestService.downloadDebugFile(resultUuid);
}

public String computeLogicalControls(@NonNull UUID studyUuid, @NonNull UUID nodeUuid, @NonNull UUID rootNetworkUuid) {
StudyEntity studyEntity = getStudy(studyUuid);
UUID networkUuid = rootNetworkService.getNetworkUuid(rootNetworkUuid);
String variantId = networkModificationTreeService.getVariantId(nodeUuid, rootNetworkUuid);
UUID paramsUuid = studyEntity.getStateEstimationParametersUuid();
return stateEstimationRestService.runLogicalComputation(networkUuid, variantId, paramsUuid);
}
}
Loading