-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring of security analysis api (#1766)
* Remove deprecated code (#1579) * Use ServiceLoader to create SecurityAnalysis (#1585) * Add SecurityAnalysisProvider * Add FIXME to rename later and fix comments issues * Remove runWithLog method in SecurityAnalysisProvider * Replace SecurityAnalysis factory uses by loaded SecurityAnalysisProvider (#1618) * Refactoring security-analysis-api : SecurityAnalysisImpl (issue 1604) (#1648) * Refactoring security-analysis-api : Remove WithLog suffixed methods (#1667) * Remove SecurityAnalysisResultWithLog class * Replace WithLog methods with bollean usage * Add SecurityAnalysisReport composed by SecurityAnalysisResult & LogBytes Signed-off-by: Thomas ADAM <[email protected]> * After rebasing: bump to 4.2.0-SNAPSHOT version + do not use "default" word in automatic module name (forbidden) * Add default impl of API AS in distribution core * Bump to 4.3.0-SNAPSHOT Signed-off-by: RALAMBOTIANA MIORA <[email protected]> * Monitor security analysis (#1737) * On demand results for specific equipments Signed-off-by: Etienne Lesot <[email protected]> * Corrections following reviewer's comments: - Rename SecurityAnalysisResult.getPreContingencyLimitViolationsResult - Use only pre/post contingency in javadoc - Put methods in StateMonitorJson in StateMonitor - Clear before addAll in setMonitors * Corrections following reviewer's comments: - PreContingencyResult constructor requires Collections, not Maps - Correct SecurityAnalysisResult deserializer and test files - Optimize monitor merging in StateMonitorIndex - Add ID-based getters in PreContingencyResult - Delete redundant methods in SecurityAnalysisResult - If a monitored ID does not exist, ignore it - Add tests * Rebasing from master and resolving conflicts Co-authored-by: RALAMBOTIANA MIORA <[email protected]> Co-authored-by: EtienneLt <[email protected]>
- Loading branch information
Showing
181 changed files
with
3,281 additions
and
1,758 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
contingency/contingency-api/src/main/java/com/powsybl/contingency/ContingencyContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/** | ||
* Copyright (c) 2021, 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 com.powsybl.contingency; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com> | ||
* @author Etienne Lesot <etienne.lesot at rte-france.com> | ||
* <p> | ||
* provide the context to get information of the network after a security analysis | ||
* it contains a contingency's id and a context type. Context type defines | ||
* if we want the information in a pre-contingency state, a post-contingency state or both. | ||
* contingency's id is defined if informations are needed after | ||
* a specific contingency computation | ||
*/ | ||
public class ContingencyContext { | ||
|
||
private final String contingencyId; | ||
|
||
/** | ||
* Define if informations needed are in N_Situation, N-k Situation or both | ||
* if it is N_situation contingencyid is null | ||
*/ | ||
private final ContingencyContextType contextType; | ||
|
||
public ContingencyContext(@JsonProperty("contingencyId") String contingencyId, | ||
@JsonProperty("contextType") ContingencyContextType contingencyContextType) { | ||
this.contextType = Objects.requireNonNull(contingencyContextType); | ||
this.contingencyId = contingencyId; | ||
} | ||
|
||
public String getContingencyId() { | ||
return contingencyId; | ||
} | ||
|
||
public ContingencyContextType getContextType() { | ||
return contextType; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
ContingencyContext that = (ContingencyContext) o; | ||
return Objects.equals(contingencyId, that.contingencyId) && | ||
contextType == that.contextType; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(contingencyId, contextType); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "ContingencyContext(" + | ||
"contingencyId='" + Objects.toString(contingencyId, "") + '\'' + | ||
", contextType=" + contextType + | ||
')'; | ||
} | ||
|
||
public static ContingencyContext all() { | ||
return new ContingencyContext(null, ContingencyContextType.ALL); | ||
} | ||
|
||
public static ContingencyContext none() { | ||
return new ContingencyContext(null, ContingencyContextType.NONE); | ||
} | ||
|
||
public static ContingencyContext specificContingency(String contingencyId) { | ||
return new ContingencyContext(contingencyId, ContingencyContextType.SPECIFIC); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...ingency/contingency-api/src/main/java/com/powsybl/contingency/ContingencyContextType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* Copyright (c) 2021, 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 com.powsybl.contingency; | ||
|
||
/** | ||
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com> | ||
* @author Etienne Lesot <etienne.lesot at rte-france.com> | ||
* | ||
* Define for a contingencyContext the type of information asked. | ||
* It can be a pre-contingency state, a post-contingency state on a specific contingency (SPECIFIC) or both (ALL) | ||
*/ | ||
|
||
public enum ContingencyContextType { | ||
/** | ||
* Corresponds to all contingencies and pre-contingency situation | ||
*/ | ||
ALL, | ||
/** | ||
* Corresponds to pre-contingency situation | ||
*/ | ||
NONE, | ||
/** | ||
* Corresponds to one contingency his id is specified in the contingencyContext | ||
*/ | ||
SPECIFIC, | ||
} |
23 changes: 23 additions & 0 deletions
23
...ingency/contingency-api/src/test/java/com/powsybl/contingency/ContingencyContextTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* Copyright (c) 2021, 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 com.powsybl.contingency; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
/** | ||
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com> | ||
*/ | ||
public class ContingencyContextTest { | ||
|
||
@Test | ||
public void test() { | ||
ContingencyContext context = new ContingencyContext("c1", ContingencyContextType.SPECIFIC); | ||
assertEquals("ContingencyContext(contingencyId='c1', contextType=SPECIFIC)", context.toString()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 0 additions & 19 deletions
19
security-analysis-api/src/main/java/com/powsybl/security/AbstractLimitViolationDetector.java
This file was deleted.
Oops, something went wrong.
59 changes: 0 additions & 59 deletions
59
security-analysis-api/src/main/java/com/powsybl/security/AbstractSecurityAnalysis.java
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
security-analysis-api/src/main/java/com/powsybl/security/DefaultLimitViolationDetector.java
This file was deleted.
Oops, something went wrong.
45 changes: 0 additions & 45 deletions
45
security-analysis-api/src/main/java/com/powsybl/security/PostContingencyResult.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.