-
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.
CGMES import parameter for IIDM id source: mRID or rdfID (#2180)
Signed-off-by: Luma <[email protected]>
- Loading branch information
1 parent
4bd7300
commit 4e79c26
Showing
9 changed files
with
205 additions
and
18 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
64 changes: 64 additions & 0 deletions
64
...version/src/test/java/com/powsybl/cgmes/conversion/test/SourceForIidmIdentifiersTest.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,64 @@ | ||
/** | ||
* 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/. | ||
*/ | ||
|
||
package com.powsybl.cgmes.conversion.test; | ||
|
||
import com.powsybl.cgmes.conformity.CgmesConformity1Catalog; | ||
import com.powsybl.cgmes.conversion.CgmesImport; | ||
import com.powsybl.iidm.import_.Importers; | ||
import com.powsybl.iidm.network.Network; | ||
import com.powsybl.triplestore.api.TripleStore; | ||
import com.powsybl.triplestore.api.TripleStoreFactory; | ||
import com.powsybl.triplestore.api.TripleStoreOptions; | ||
import org.junit.Test; | ||
|
||
import java.util.Properties; | ||
|
||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
/** | ||
* @author Luma Zamarreño <zamarrenolm at aia.es> | ||
*/ | ||
public class SourceForIidmIdentifiersTest { | ||
|
||
@Test | ||
public void microGridMasterResourceIdsExplicit() { | ||
Properties importParams = new Properties(); | ||
importParams.put(CgmesImport.SOURCE_FOR_IIDM_ID, CgmesImport.SOURCE_FOR_IIDM_ID_MRID); | ||
Network network = Importers.importData("CGMES", CgmesConformity1Catalog.microGridBaseCaseBE().dataSource(), importParams); | ||
network.getIdentifiables().forEach(idf -> assertFalse(idf.getId().startsWith("_"))); | ||
} | ||
|
||
@Test | ||
public void microGridMasterResourceIdsDefault() { | ||
Network network = Importers.importData("CGMES", CgmesConformity1Catalog.microGridBaseCaseBE().dataSource(), null); | ||
network.getIdentifiables().forEach(idf -> assertFalse(idf.getId().startsWith("_"))); | ||
} | ||
|
||
@Test | ||
public void microGridRDFIds() { | ||
Properties importParams = new Properties(); | ||
importParams.put(CgmesImport.SOURCE_FOR_IIDM_ID, CgmesImport.SOURCE_FOR_IIDM_ID_RDFID); | ||
Network network = Importers.importData("CGMES", CgmesConformity1Catalog.microGridBaseCaseBE().dataSource(), importParams); | ||
network.getIdentifiables().forEach(idf -> assertTrue(idf.getId().startsWith("_") || idf.getId().startsWith("urn:uuid:"))); | ||
} | ||
|
||
@Test | ||
public void tipleStoreOptions() { | ||
TripleStoreOptions options0 = new TripleStoreOptions(); | ||
assertTrue(options0.isRemoveInitialUnderscoreForIdentifiers()); | ||
TripleStoreOptions options1 = new TripleStoreOptions(true); | ||
assertTrue(options1.isRemoveInitialUnderscoreForIdentifiers()); | ||
TripleStoreOptions options2 = new TripleStoreOptions(false); | ||
assertFalse(options2.isRemoveInitialUnderscoreForIdentifiers()); | ||
|
||
TripleStore ts = TripleStoreFactory.create(options2); | ||
assertFalse(ts.getOptions().isRemoveInitialUnderscoreForIdentifiers()); | ||
} | ||
|
||
} |
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
31 changes: 31 additions & 0 deletions
31
...-store/triple-store-api/src/main/java/com/powsybl/triplestore/api/TripleStoreOptions.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) 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/. | ||
*/ | ||
package com.powsybl.triplestore.api; | ||
|
||
/** | ||
* @author Luma Zamarreño <zamarrenolm at aia.es> | ||
*/ | ||
public class TripleStoreOptions { | ||
|
||
private boolean removeInitialUnderscoreForIdentifiers = true; | ||
|
||
public TripleStoreOptions() { | ||
} | ||
|
||
public TripleStoreOptions(boolean removeInitialUnderscoreForIdentifiers) { | ||
this.removeInitialUnderscoreForIdentifiers = removeInitialUnderscoreForIdentifiers; | ||
} | ||
|
||
public TripleStoreOptions setRemoveInitialUnderscoreForIdentifiers(boolean removeInitialUnderscoreForIdentifiers) { | ||
this.removeInitialUnderscoreForIdentifiers = removeInitialUnderscoreForIdentifiers; | ||
return this; | ||
} | ||
|
||
public boolean isRemoveInitialUnderscoreForIdentifiers() { | ||
return removeInitialUnderscoreForIdentifiers; | ||
} | ||
} |
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