-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add a request param to target one of the 3 security-analysis-server endpoints #454
Changes from 5 commits
862997b
d8de1ce
5b4f965
311e7da
ffab7cf
a2f8a51
8c40c6d
d1e8690
b415b34
50eecfa
4d6842c
ebcb5b4
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* Copyright (c) 2023, RTE (http://www.rte-france.com) | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
package org.gridsuite.study.server.service.securityanalysis; | ||
/** | ||
* @author Kevin Le Saulnier <kevin.lesaulnier at rte-france.com> | ||
*/ | ||
|
||
public enum SecurityAnalysisResultType { | ||
N, | ||
NMK_CONTINGENCIES, | ||
NMK_CONSTRAINTS | ||
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. NMK_LIMIT_VIOLATIONS ? 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. fixed |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
package org.gridsuite.study.server.service; | ||
package org.gridsuite.study.server.service.securityanalysis; | ||
|
||
/** | ||
* @author Kevin Le Saulnier <kevin.lesaulnier at rte-france.com> | ||
|
@@ -21,6 +21,8 @@ | |
import org.gridsuite.study.server.dto.SecurityAnalysisParametersValues; | ||
import org.gridsuite.study.server.dto.SecurityAnalysisStatus; | ||
import org.gridsuite.study.server.repository.SecurityAnalysisParametersEntity; | ||
import org.gridsuite.study.server.service.NetworkModificationTreeService; | ||
import org.gridsuite.study.server.service.RemoteServicesProperties; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.*; | ||
import org.springframework.stereotype.Service; | ||
|
@@ -62,14 +64,14 @@ public class SecurityAnalysisService { | |
|
||
@Autowired | ||
public SecurityAnalysisService(RemoteServicesProperties remoteServicesProperties, | ||
NetworkModificationTreeService networkModificationTreeService, | ||
ObjectMapper objectMapper) { | ||
NetworkModificationTreeService networkModificationTreeService, | ||
ObjectMapper objectMapper) { | ||
this.securityAnalysisServerBaseUri = remoteServicesProperties.getServiceUri("security-analysis-server"); | ||
this.networkModificationTreeService = networkModificationTreeService; | ||
this.objectMapper = objectMapper; | ||
} | ||
|
||
public String getSecurityAnalysisResult(UUID nodeUuid, List<String> limitTypes) { | ||
public String getSecurityAnalysisResult(UUID nodeUuid, SecurityAnalysisResultType resultType, List<String> limitTypes) { | ||
Objects.requireNonNull(limitTypes); | ||
String result; | ||
Optional<UUID> resultUuidOpt = networkModificationTreeService.getSecurityAnalysisResultUuid(nodeUuid); | ||
|
@@ -78,7 +80,7 @@ public String getSecurityAnalysisResult(UUID nodeUuid, List<String> limitTypes) | |
return null; | ||
} | ||
|
||
String path = UriComponentsBuilder.fromPath(DELIMITER + SECURITY_ANALYSIS_API_VERSION + "/results/{resultUuid}") | ||
String path = UriComponentsBuilder.fromPath(DELIMITER + SECURITY_ANALYSIS_API_VERSION + "/results/{resultUuid}/" + getPathFromResultType(resultType)) | ||
.queryParam("limitType", limitTypes).buildAndExpand(resultUuidOpt.get()).toUriString(); | ||
try { | ||
result = restTemplate.getForObject(securityAnalysisServerBaseUri + path, String.class); | ||
|
@@ -93,6 +95,14 @@ public String getSecurityAnalysisResult(UUID nodeUuid, List<String> limitTypes) | |
return result; | ||
} | ||
|
||
private String getPathFromResultType(SecurityAnalysisResultType resultType) { | ||
switch (resultType) { | ||
case NMK_CONTINGENCIES : return "nmk-contingencies-result"; | ||
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. Add path in the enum ? 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. I don't think it's a good idea, we could use this enum for somethings else than just the path |
||
case NMK_CONSTRAINTS : return "nmk-constraints-result"; | ||
default: return "n-result"; //N case | ||
} | ||
} | ||
|
||
public UUID runSecurityAnalysis(UUID networkUuid, UUID reportUuid, UUID nodeUuid, String variantId, String provider, List<String> contingencyListNames, SecurityAnalysisParametersInfos securityAnalysisParameters, | ||
String receiver) { | ||
var uriComponentsBuilder = UriComponentsBuilder | ||
|
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.
Add license header and author
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.
fixed