@Test public void copy() throws Exception { importer.copy(new FileDataSource(fileSystem.getPath("/"), "test0"), new FileDataSource(fileSystem.getPath("/"), "test0_copy")); assertTrue(Files.exists(fileSystem.getPath("/test0_copy.xiidm"))); assertEquals(Files.readAllLines(fileSystem.getPath("/test0.xiidm"), StandardCharsets.UTF_8), Files.readAllLines(fileSystem.getPath("/test0_copy.xiidm"), StandardCharsets.UTF_8)); importer.copy(new FileDataSource(fileSystem.getPath("/"), "test6"), new FileDataSource(fileSystem.getPath("/"), "test6_copy")); assertTrue(Files.exists(fileSystem.getPath("/test6_copy.xiidm"))); assertTrue(Files.exists(fileSystem.getPath("/test6_copy_mapping.csv"))); assertEquals(Files.readAllLines(fileSystem.getPath("/test6.xiidm"), StandardCharsets.UTF_8), Files.readAllLines(fileSystem.getPath("/test6_copy.xiidm"), StandardCharsets.UTF_8)); assertEquals(Files.readAllLines(fileSystem.getPath("/test6_mapping.csv"), StandardCharsets.UTF_8), Files.readAllLines(fileSystem.getPath("/test6_copy_mapping.csv"), StandardCharsets.UTF_8)); }
@Override public void copy(ReadOnlyDataSource fromDataSource, DataSource toDataSource) { try { String ext = findExtension(fromDataSource); if (!exists(fromDataSource, ext)) { throw new PowsyblException("From data source is not importable"); } try (InputStream is = fromDataSource.newInputStream(null, ext); OutputStream os = toDataSource.newOutputStream(null, ext, false)) { ByteStreams.copy(is, os); } if (fromDataSource.exists(SUFFIX_MAPPING, "csv")) { try (InputStream is = fromDataSource.newInputStream(SUFFIX_MAPPING, "csv"); OutputStream os = toDataSource.newOutputStream(SUFFIX_MAPPING, "csv", false)) { ByteStreams.copy(is, os); } } } catch (IOException e) { throw new UncheckedIOException(e); } }
XMLImporter implements Importer { @Override public void copy(ReadOnlyDataSource fromDataSource, DataSource toDataSource) { try { String ext = findExtension(fromDataSource); if (!exists(fromDataSource, ext)) { throw new PowsyblException("From data source is not importable"); } try (InputStream is = fromDataSource.newInputStream(null, ext); OutputStream os = toDataSource.newOutputStream(null, ext, false)) { ByteStreams.copy(is, os); } if (fromDataSource.exists(SUFFIX_MAPPING, "csv")) { try (InputStream is = fromDataSource.newInputStream(SUFFIX_MAPPING, "csv"); OutputStream os = toDataSource.newOutputStream(SUFFIX_MAPPING, "csv", false)) { ByteStreams.copy(is, os); } } } catch (IOException e) { throw new UncheckedIOException(e); } } }
XMLImporter implements Importer { @Override public void copy(ReadOnlyDataSource fromDataSource, DataSource toDataSource) { try { String ext = findExtension(fromDataSource); if (!exists(fromDataSource, ext)) { throw new PowsyblException("From data source is not importable"); } try (InputStream is = fromDataSource.newInputStream(null, ext); OutputStream os = toDataSource.newOutputStream(null, ext, false)) { ByteStreams.copy(is, os); } if (fromDataSource.exists(SUFFIX_MAPPING, "csv")) { try (InputStream is = fromDataSource.newInputStream(SUFFIX_MAPPING, "csv"); OutputStream os = toDataSource.newOutputStream(SUFFIX_MAPPING, "csv", false)) { ByteStreams.copy(is, os); } } } catch (IOException e) { throw new UncheckedIOException(e); } } XMLImporter();  XMLImporter(PlatformConfig platformConfig); }
XMLImporter implements Importer { @Override public void copy(ReadOnlyDataSource fromDataSource, DataSource toDataSource) { try { String ext = findExtension(fromDataSource); if (!exists(fromDataSource, ext)) { throw new PowsyblException("From data source is not importable"); } try (InputStream is = fromDataSource.newInputStream(null, ext); OutputStream os = toDataSource.newOutputStream(null, ext, false)) { ByteStreams.copy(is, os); } if (fromDataSource.exists(SUFFIX_MAPPING, "csv")) { try (InputStream is = fromDataSource.newInputStream(SUFFIX_MAPPING, "csv"); OutputStream os = toDataSource.newOutputStream(SUFFIX_MAPPING, "csv", false)) { ByteStreams.copy(is, os); } } } catch (IOException e) { throw new UncheckedIOException(e); } } XMLImporter();  XMLImporter(PlatformConfig platformConfig); @Override String getFormat(); @Override List<Parameter> getParameters(); @Override String getComment(); @Override boolean exists(ReadOnlyDataSource dataSource); @Override void copy(ReadOnlyDataSource fromDataSource, DataSource toDataSource); @Override Network importData(ReadOnlyDataSource dataSource, NetworkFactory networkFactory, Properties parameters); }
XMLImporter implements Importer { @Override public void copy(ReadOnlyDataSource fromDataSource, DataSource toDataSource) { try { String ext = findExtension(fromDataSource); if (!exists(fromDataSource, ext)) { throw new PowsyblException("From data source is not importable"); } try (InputStream is = fromDataSource.newInputStream(null, ext); OutputStream os = toDataSource.newOutputStream(null, ext, false)) { ByteStreams.copy(is, os); } if (fromDataSource.exists(SUFFIX_MAPPING, "csv")) { try (InputStream is = fromDataSource.newInputStream(SUFFIX_MAPPING, "csv"); OutputStream os = toDataSource.newOutputStream(SUFFIX_MAPPING, "csv", false)) { ByteStreams.copy(is, os); } } } catch (IOException e) { throw new UncheckedIOException(e); } } XMLImporter();  XMLImporter(PlatformConfig platformConfig); @Override String getFormat(); @Override List<Parameter> getParameters(); @Override String getComment(); @Override boolean exists(ReadOnlyDataSource dataSource); @Override void copy(ReadOnlyDataSource fromDataSource, DataSource toDataSource); @Override Network importData(ReadOnlyDataSource dataSource, NetworkFactory networkFactory, Properties parameters); static final String THROW_EXCEPTION_IF_EXTENSION_NOT_FOUND; static final String EXTENSIONS_LIST; }