Skip to content

Commit

Permalink
changes XML format name to XIIDM
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Biasuzzi committed Sep 27, 2016
1 parent 3bc67e5 commit 2193cc0
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public EntsoeAndXmlCaseRepository(EntsoeCaseRepositoryConfig config, Computation
super(config,
Arrays.asList(new EntsoeFormat(Importers.getImporter("CIM1", computationManager), "CIM"),
new EntsoeFormat(Importers.getImporter("UCTE", computationManager), "UCT"), // official ENTSOE formats)
new EntsoeFormat(Importers.getImporter("XML", computationManager), "IIDM")), // IIDM XML format
new EntsoeFormat(Importers.getImporter("XIIDM", computationManager), "IIDM")), // XIIDM format
(directory, baseName) -> new GenericReadOnlyDataSource(directory, baseName));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public void setUp() throws Exception {
return ((Files.isRegularFile(file_xiidm)) || Files.isRegularFile(file_xml));
});
Mockito.when(iidmImporter.getFormat())
.thenReturn("XML");
.thenReturn("XIIDM");
xmlNetwork = Mockito.mock(Network.class);
Mockito.when(iidmImporter.import_(Matchers.isA(DataSource.class), Matchers.any()))
.thenReturn(xmlNetwork);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class CimHistoImporter {
} else {
log.warn("CIM importer implementation not found");
}
importerXml = Importers.getImporter("XML", computationManager);
importerXml = Importers.getImporter("XIIDM", computationManager);
if (importerXml!=null) {
importers.add(importerXml);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,8 @@ public static ReadOnlyDataSource createReadOnly(Path directory, String fileNameO
return new ZipFileDataSource(directory, getBaseName(fileNameOrBaseName.substring(0, fileNameOrBaseName.length() - 4)));
} else if (fileNameOrBaseName.endsWith(".gz")) {
return new GzFileDataSource(directory, getBaseName(fileNameOrBaseName.substring(0, fileNameOrBaseName.length() - 3)));
} else if (fileNameOrBaseName.endsWith(".bz2")) {
return new Bzip2FileDataSource(directory, getBaseName(fileNameOrBaseName.substring(0, fileNameOrBaseName.length() - 4)));
} else {
return new FileDataSource(directory, getBaseName(fileNameOrBaseName));
}
Expand Down
2 changes: 1 addition & 1 deletion iidm-xml-import-export/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<artifactId>iidm-xml-import-export</artifactId>

<name>XML import export</name>
<name>IIDM XML import export</name>

<dependencies>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public class XMLExporter implements Exporter, XmlConstants {

@Override
public String getFormat() {
return "XML";
return "XIIDM";
}

@Override
Expand Down Expand Up @@ -101,7 +101,7 @@ public void export(Network network, Properties parameters, DataSource dataSource
NetworkXml.write(network, options, bos);
}

LOGGER.debug("XML export done in {} ms", (System.currentTimeMillis() - startTime));
LOGGER.debug("XIIDM export done in {} ms", (System.currentTimeMillis() - startTime));
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class XMLImporter implements Importer, XmlConstants {

@Override
public String getFormat() {
return "XML";
return "XIIDM";
}

@Override
Expand Down Expand Up @@ -123,7 +123,7 @@ public Network import_(ReadOnlyDataSource dataSource, Properties parameters) {
try (InputStream is = dataSource.newInputStream(null, ext)) {
network = NetworkXml.read(is, new XmlImportConfig(throwExceptionIfExtensionNotFound));
}
LOGGER.debug("XML import done in {} ms", (System.currentTimeMillis() - startTime));
LOGGER.debug("XIIDM import done in {} ms", (System.currentTimeMillis() - startTime));
} catch (IOException e) {
throw new ITeslaException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,7 @@ public void storeState(String workflowId, Integer stateId, Network network) {
parameters.setProperty("iidm.export.xml.with-branch-state-variables", "true");
parameters.setProperty("iidm.export.xml.with-breakers", "true");
parameters.setProperty("iidm.export.xml.with-properties", "true");
Exporters.export("XML", network, parameters, dataSource);
Exporters.export("XIIDM", network, parameters, dataSource);
// store network state values, for later serialization
Map<HistoDbAttributeId, Object> networkValues = IIDM2DB.extractCimValues(network, new IIDM2DB.Config(network.getId(), true, true)).getSingleValueMap();
ConcurrentHashMap<Integer, Map<HistoDbAttributeId, Object>> workflowStates = new ConcurrentHashMap<Integer, Map<HistoDbAttributeId,Object>>();
Expand Down Expand Up @@ -1116,9 +1116,9 @@ public Network getState(String workflowId, Integer stateId) {
if ( stateFileName.endsWith(".xml"));
String basename = stateFileName.substring(0, stateFileName.length()-4);
DataSource dataSource = new FileDataSource(stateFolder, basename);
//Network network = Importers.import_("XML", dataSource, null);
//Network network = Importers.import_("XIIDM", dataSource, null);
// with the new post processors configuration, the post processing is applied also to xml import
Importer xmlImporter = Importers.getImporter("XML");
Importer xmlImporter = Importers.getImporter("XIIDM");
Importer noppImporter = Importers.removePostProcessors(xmlImporter);
Network network = noppImporter.import_(dataSource, null);
return network;
Expand Down

0 comments on commit 2193cc0

Please sign in to comment.