use of jodd.io.filter.WildcardFileFilter in project pathling by aehrc.
the class TestDataImporter method run.
@Override
public void run(final String... args) {
final String sourcePath = args[0];
final File srcNdJsonDir = new File(sourcePath);
final FileFilter fileFilter = new WildcardFileFilter("*.ndjson");
final File[] srcNdJsonFiles = srcNdJsonDir.listFiles(fileFilter);
final List<ParametersParameterComponent> sources = Stream.of(Objects.requireNonNull(srcNdJsonFiles)).map(file -> {
final String resourceName = FilenameUtils.getBaseName(file.getName());
final ResourceType subjectResource = ResourceType.valueOf(resourceName.toUpperCase());
final ParametersParameterComponent source = new ParametersParameterComponent();
source.setName("source");
final ParametersParameterComponent resourceType = new ParametersParameterComponent();
resourceType.setName("resourceType");
resourceType.setValue(new CodeType(subjectResource.toCode()));
source.addPart(resourceType);
final ParametersParameterComponent url = new ParametersParameterComponent();
url.setName("url");
url.setValue(new UrlType("file://" + file.toPath()));
source.addPart(url);
return source;
}).collect(Collectors.toList());
final Parameters parameters = new Parameters();
parameters.setParameter(sources);
importExecutor.execute(parameters);
}
Aggregations