-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
init csa profile contingencies import (#763)
* init csa profile contingencies import * add test files * add example data zip and some classes * add contingency creation * corrections * corrections sparql file * correcti disclaimer format * update sparql requests and unit tests * update contingency creator + tu * pom.xml cleaning * add new test files + update exists method and ids * add tie line processing * TU for contingencies integration from CSA_TestConfiguration_TC2_Draft_v14Apr2023.zip * removing unzipped test case, changes oncontingencies integration * add doc, error case for invalid head of files, TU * updates for code review * add contingencyId in CsaProfileContingencyCreationContext * updates after code reviews * updates after master merge * update for tie-lines and logger * createAndAddContingencies private * updates after code reviews
- Loading branch information
Showing
27 changed files
with
1,652 additions
and
21 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Copyright (c) 2022, 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/. | ||
--> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>farao-crac-creation</artifactId> | ||
<groupId>com.farao-community.farao</groupId> | ||
<version>4.5.0-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>farao-crac-creator-csa-profiles</artifactId> | ||
<name>CRAC creator - CSA Profiles</name> | ||
<description>CRAC creator implementation for CRAC specific to CSA profiles</description> | ||
<packaging>jar</packaging> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.jvnet.jaxb2.maven2</groupId> | ||
<artifactId>maven-jaxb2-plugin</artifactId> | ||
<configuration> | ||
<args> | ||
<arg>-Xinheritance</arg> | ||
</args> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.jvnet.jaxb2_commons</groupId> | ||
<artifactId>jaxb2-basics</artifactId> | ||
<version>${maven.jvnet.jaxb2-basics.version}</version> | ||
</plugin> | ||
</plugins> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>farao-crac-creator-api</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>farao-crac-creation-util</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>farao-crac-io-api</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>farao-crac-util</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.rdf4j</groupId> | ||
<artifactId>rdf4j-rio-rdfxml</artifactId> | ||
<version>4.2.2</version> | ||
</dependency> | ||
|
||
<!-- Runtime dependencies --> | ||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>farao-crac-impl</artifactId> | ||
<version>${project.version}</version> | ||
<scope>runtime</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.powsybl</groupId> | ||
<artifactId>powsybl-triple-store-impl-rdf4j</artifactId> | ||
<version>${powsybl.core.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.powsybl</groupId> | ||
<artifactId>powsybl-iidm-impl</artifactId> | ||
<version>${powsybl.core.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.powsybl</groupId> | ||
<artifactId>powsybl-cgmes-conversion</artifactId> | ||
<version>${powsybl.core.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.mockito</groupId> | ||
<artifactId>mockito-inline</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
86 changes: 86 additions & 0 deletions
86
...java/com/farao_community/farao/data/crac_creation/creator/csa_profile/CsaProfileCrac.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,86 @@ | ||
/* | ||
* 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 com.farao_community.farao.data.crac_creation.creator.csa_profile; | ||
|
||
import com.farao_community.farao.commons.logs.FaraoLoggerProvider; | ||
import com.farao_community.farao.data.crac_creation.creator.csa_profile.crac_creator.CsaProfileConstants; | ||
import com.farao_community.farao.data.native_crac_api.NativeCrac; | ||
import com.powsybl.triplestore.api.PropertyBags; | ||
import com.powsybl.triplestore.api.QueryCatalog; | ||
import com.powsybl.triplestore.api.TripleStore; | ||
|
||
import java.util.Arrays; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
/** | ||
* @author Jean-Pierre Arnould {@literal <jean-pierre.arnould at rte-france.com>} | ||
*/ | ||
public class CsaProfileCrac implements NativeCrac { | ||
|
||
private final TripleStore tripleStoreCsaProfileCrac; | ||
|
||
private final QueryCatalog queryCatalogCsaProfileCrac; | ||
|
||
public CsaProfileCrac(TripleStore tripleStoreCsaProfileCrac) { | ||
this.tripleStoreCsaProfileCrac = tripleStoreCsaProfileCrac; | ||
this.queryCatalogCsaProfileCrac = new QueryCatalog(CsaProfileConstants.SPARQL_FILE_CSA_PROFILE); | ||
} | ||
|
||
@Override | ||
public String getFormat() { | ||
return "CsaProfileCrac"; | ||
} | ||
|
||
public PropertyBags getContingencies() { | ||
return this.queryTripleStore(Arrays.asList(CsaProfileConstants.REQUEST_ORDINARY_CONTINGENCY, CsaProfileConstants.REQUEST_EXCEPTIONAL_CONTINGENCY, CsaProfileConstants.REQUEST_OUT_OF_RANGE_CONTINGENCY), tripleStoreCsaProfileCrac.contextNames()); | ||
} | ||
|
||
public PropertyBags getContingencyEquipments() { | ||
return this.queryTripleStore(CsaProfileConstants.REQUEST_CONTINGENCY_EQUIPMENT); | ||
} | ||
|
||
private PropertyBags queryTripleStore(String queryKey) { | ||
return this.queryTripleStore(queryKey, new HashSet<>()); | ||
} | ||
|
||
private PropertyBags queryTripleStore(List<String> queryKeys, Set<String> contexts) { | ||
PropertyBags mergedPropertyBags = new PropertyBags(); | ||
for (String queryKey : queryKeys) { | ||
mergedPropertyBags.addAll(queryTripleStore(queryKey, contexts)); | ||
} | ||
return mergedPropertyBags; | ||
} | ||
|
||
/** | ||
* execute query on the whole tripleStore or on each context included in the set | ||
* | ||
* @param queryKey : query name in the sparql file | ||
* @param contexts : list of contexts where the query will be executed (if empty, the query is executed on the whole tripleStore | ||
* @return | ||
*/ | ||
private PropertyBags queryTripleStore(String queryKey, Set<String> contexts) { | ||
String query = queryCatalogCsaProfileCrac.get(queryKey); | ||
if (query == null) { | ||
FaraoLoggerProvider.TECHNICAL_LOGS.warn("Query [{}] not found in catalog", queryKey); | ||
return new PropertyBags(); | ||
} | ||
|
||
if (contexts.isEmpty()) { | ||
return tripleStoreCsaProfileCrac.query(query); | ||
} | ||
|
||
PropertyBags multiContextsPropertyBags = new PropertyBags(); | ||
for (String context : contexts) { | ||
String contextQuery = String.format(query, context); | ||
multiContextsPropertyBags.addAll(tripleStoreCsaProfileCrac.query(contextQuery)); | ||
} | ||
return multiContextsPropertyBags; | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
...munity/farao/data/crac_creation/creator/csa_profile/crac_creator/CsaProfileConstants.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,72 @@ | ||
/* | ||
* 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 com.farao_community.farao.data.crac_creation.creator.csa_profile.crac_creator; | ||
|
||
/** | ||
* @author Jean-Pierre Arnould {@literal <jean-pierre.arnould at rte-france.com>} | ||
*/ | ||
public final class CsaProfileConstants { | ||
|
||
private CsaProfileConstants() { | ||
} | ||
|
||
/** | ||
* constants to read rdf files | ||
*/ | ||
|
||
public static final String EXTENSION_FILE_CSA_PROFILE = "zip"; | ||
|
||
public static final String RDF_BASE_URL = "http://entsoe.eu"; | ||
|
||
public static final String TRIPLESTORE_RDF4J_NAME = "rdf4j"; | ||
|
||
/** | ||
* constants to access triplestore data | ||
*/ | ||
|
||
public static final String SPARQL_FILE_CSA_PROFILE = "csa_profile.sparql"; | ||
|
||
/** | ||
* constants to request file headers | ||
*/ | ||
|
||
public static final String REQUEST_HEADER_START_DATE = "startDate"; | ||
|
||
public static final String REQUEST_HEADER_END_DATE = "endDate"; | ||
|
||
public static final String REQUEST_HEADER_KEYWORD = "keyword"; | ||
|
||
/** | ||
* constants to request contingencies | ||
*/ | ||
|
||
public static final String REQUEST_CONTINGENCY = "contingency"; | ||
|
||
public static final String REQUEST_ORDINARY_CONTINGENCY = "ordinaryContingency"; | ||
|
||
public static final String REQUEST_EXCEPTIONAL_CONTINGENCY = "exceptionalContingency"; | ||
|
||
public static final String REQUEST_OUT_OF_RANGE_CONTINGENCY = "outOfRangeContingency"; | ||
|
||
public static final String REQUEST_CONTINGENCY_EQUIPMENT = "contingencyEquipment"; | ||
|
||
public static final String REQUEST_CONTINGENCIES_NAME = "name"; | ||
|
||
public static final String REQUEST_CONTINGENCIES_EQUIPMENT_OPERATOR = "idEquipmentOperator"; | ||
|
||
public static final String REQUEST_CONTINGENCIES_EQUIPMENT_ID = "contingencyEquipmentId"; | ||
|
||
public static final String REQUEST_CONTINGENCIES_MUST_STUDY = "normalMustStudy"; | ||
|
||
public static final String REQUEST_CONTINGENCIES_CONTINGENT_STATUS = "contingentStatus"; | ||
|
||
public static final String IMPORTED_CONTINGENT_STATUS = "http://iec.ch/TC57/CIM100#ContingencyEquipmentStatusKind.outOfService"; | ||
|
||
public static final String CONTINGENCY_FILE_KEYWORD = "CO"; | ||
|
||
} |
Oops, something went wrong.