Search in sources :

Example 1 with WildcardFileFilter

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);
}
Also used : ParametersParameterComponent(org.hl7.fhir.r4.model.Parameters.ParametersParameterComponent) UrlType(org.hl7.fhir.r4.model.UrlType) SpringBootApplication(org.springframework.boot.autoconfigure.SpringBootApplication) Autowired(org.springframework.beans.factory.annotation.Autowired) ResourceType(org.hl7.fhir.r4.model.Enumerations.ResourceType) Collectors(java.util.stream.Collectors) Profile(org.springframework.context.annotation.Profile) File(java.io.File) ComponentScan(org.springframework.context.annotation.ComponentScan) ImportExecutor(au.csiro.pathling.update.ImportExecutor) Objects(java.util.Objects) SpringApplication(org.springframework.boot.SpringApplication) List(java.util.List) Slf4j(lombok.extern.slf4j.Slf4j) FileFilter(java.io.FileFilter) Stream(java.util.stream.Stream) WildcardFileFilter(jodd.io.filter.WildcardFileFilter) Parameters(org.hl7.fhir.r4.model.Parameters) CodeType(org.hl7.fhir.r4.model.CodeType) CommandLineRunner(org.springframework.boot.CommandLineRunner) Nonnull(javax.annotation.Nonnull) FilenameUtils(org.apache.commons.io.FilenameUtils) SparkSession(org.apache.spark.sql.SparkSession) Parameters(org.hl7.fhir.r4.model.Parameters) CodeType(org.hl7.fhir.r4.model.CodeType) ResourceType(org.hl7.fhir.r4.model.Enumerations.ResourceType) FileFilter(java.io.FileFilter) WildcardFileFilter(jodd.io.filter.WildcardFileFilter) File(java.io.File) WildcardFileFilter(jodd.io.filter.WildcardFileFilter) UrlType(org.hl7.fhir.r4.model.UrlType) ParametersParameterComponent(org.hl7.fhir.r4.model.Parameters.ParametersParameterComponent)

Aggregations

ImportExecutor (au.csiro.pathling.update.ImportExecutor)1 File (java.io.File)1 FileFilter (java.io.FileFilter)1 List (java.util.List)1 Objects (java.util.Objects)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 Nonnull (javax.annotation.Nonnull)1 WildcardFileFilter (jodd.io.filter.WildcardFileFilter)1 Slf4j (lombok.extern.slf4j.Slf4j)1 FilenameUtils (org.apache.commons.io.FilenameUtils)1 SparkSession (org.apache.spark.sql.SparkSession)1 CodeType (org.hl7.fhir.r4.model.CodeType)1 ResourceType (org.hl7.fhir.r4.model.Enumerations.ResourceType)1 Parameters (org.hl7.fhir.r4.model.Parameters)1 ParametersParameterComponent (org.hl7.fhir.r4.model.Parameters.ParametersParameterComponent)1 UrlType (org.hl7.fhir.r4.model.UrlType)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 CommandLineRunner (org.springframework.boot.CommandLineRunner)1 SpringApplication (org.springframework.boot.SpringApplication)1