-
Notifications
You must be signed in to change notification settings - Fork 2
[WIP] Get computation statuses for branch #986
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,7 @@ | |
| import java.nio.charset.StandardCharsets; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.Objects; | ||
| import java.util.UUID; | ||
|
|
||
|
|
@@ -143,6 +144,22 @@ public LoadFlowStatus getLoadFlowStatus(UUID resultUuid) { | |
| return restTemplate.getForObject(loadFlowServerBaseUri + path, LoadFlowStatus.class); | ||
| } | ||
|
|
||
| public Map<UUID, LoadFlowStatus> getLoadFlowStatuses(List<UUID> resultUuids) { | ||
| if (resultUuids == null || resultUuids.isEmpty()) { | ||
| return null; | ||
| } | ||
|
|
||
| UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath(DELIMITER + LOADFLOW_API_VERSION + "/results/statuses"); | ||
| String path = uriComponentsBuilder.toUriString(); | ||
| HttpHeaders headers = new HttpHeaders(); | ||
| headers.setContentType(MediaType.APPLICATION_JSON); | ||
|
|
||
| HttpEntity<List<UUID>> httpEntity = new HttpEntity<>(resultUuids, headers); | ||
|
|
||
| return restTemplate.exchange(loadFlowServerBaseUri + path, HttpMethod.POST, httpEntity, new ParameterizedTypeReference<Map<UUID, LoadFlowStatus>>() { | ||
| }).getBody(); | ||
| } | ||
|
|
||
| public void stopLoadFlow(UUID studyUuid, UUID nodeUuid, UUID rootNetworkUuid, UUID resultUuid, String userId) { | ||
| Objects.requireNonNull(studyUuid); | ||
| Objects.requireNonNull(nodeUuid); | ||
|
|
@@ -198,6 +215,15 @@ public void assertLoadFlowNotRunning(UUID resultUuid) { | |
| } | ||
| } | ||
|
|
||
| public void assertLoadFlowsNotRunning(List<UUID> resultUuids) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rename by assertNoLoadFlowRunning ? |
||
| Map<UUID, LoadFlowStatus> loadFlowStatuses = getLoadFlowStatuses(resultUuids); | ||
| // this is O(n) complexity, maybe we should adapt endoint to simply check LoadFlowsNotRunning | ||
| // for a list of resultUuids returning boolean if encounter one RUNNING computation ? | ||
| if (loadFlowStatuses != null && loadFlowStatuses.containsValue(LoadFlowStatus.RUNNING)) { | ||
| throw new StudyException(COMPUTATION_RUNNING); | ||
| } | ||
|
Comment on lines
+222
to
+224
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
|
|
||
| public List<LimitViolationInfos> getLimitViolations(UUID resultUuid, String filters, String globalFilters, Sort sort, UUID networkUuid, String variantId) { | ||
| List<LimitViolationInfos> result = new ArrayList<>(); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Map.of() ?