@Override public MultiFileImporterImpl importFile(final InputFile file) { final int itemCountBefore = this.specItemBuilder.getItemCount(); createImporter(file, this.specItemBuilder).runImport(); final int itemCountImported = this.specItemBuilder.getItemCount() - itemCountBefore; LOG.fine(() -> "Imported " + itemCountImported + " items from '" + file + "'."); return this; }
@Override public MultiFileImporter importRecursiveDir(final Path dir, final String glob) { final PathMatcher matcher = dir.getFileSystem().getPathMatcher("glob:" + glob); final AtomicInteger fileCount = new AtomicInteger(0); final int itemCountBefore = this.specItemBuilder.getItemCount(); try (Stream<Path> fileStream = Files.walk(dir)) { fileStream.filter(path -> !path.toFile().isDirectory()) // .filter(matcher::matches) // .map(path -> RealFileInput.forPath(path, DEFAULT_CHARSET)) .filter(this.factoryLoader::supportsFile) .map(file -> createImporter(file, this.specItemBuilder)).forEach(importer -> { importer.runImport(); fileCount.incrementAndGet(); }); } catch (final IOException e) { throw new ImporterException("Error walking directory " + dir, e); } final int itemCountImported = this.specItemBuilder.getItemCount() - itemCountBefore; LOG.fine(() -> "Imported " + fileCount + " files containing " + itemCountImported + " items from '" + dir + "'."); return this; }
@Override public MultiFileImporterImpl importFile(final InputFile file) { final int itemCountBefore = this.specItemBuilder.getItemCount(); createImporter(file, this.specItemBuilder).runImport(); final int itemCountImported = this.specItemBuilder.getItemCount() - itemCountBefore; LOG.fine(() -> "Imported " + itemCountImported + " items from '" + file + "'."); return this; }
@Override public MultiFileImporter importRecursiveDir(final Path dir, final String glob) { final PathMatcher matcher = dir.getFileSystem().getPathMatcher("glob:" + glob); final AtomicInteger fileCount = new AtomicInteger(0); final int itemCountBefore = this.specItemBuilder.getItemCount(); try (Stream<Path> fileStream = Files.walk(dir)) { fileStream.filter(path -> !path.toFile().isDirectory()) // .filter(matcher::matches) // .map(path -> RealFileInput.forPath(path, DEFAULT_CHARSET)) .filter(this.factoryLoader::supportsFile) .map(file -> createImporter(file, this.specItemBuilder)).forEach(importer -> { importer.runImport(); fileCount.incrementAndGet(); }); } catch (final IOException e) { throw new ImporterException("Error walking directory " + dir, e); } final int itemCountImported = this.specItemBuilder.getItemCount() - itemCountBefore; LOG.fine(() -> "Imported " + fileCount + " files containing " + itemCountImported + " items from '" + dir + "'."); return this; }