Search in sources :

Example 11 with InstanceReader

use of eu.esdihumboldt.hale.common.instance.io.InstanceReader in project hale by halestudio.

the class FilterTest method loadXMLInstances.

private InstanceCollection loadXMLInstances(URI schemaLocation, URI xmlLocation) throws IOException, IOProviderConfigurationException {
    SchemaReader reader = new XmlSchemaReader();
    reader.setSharedTypes(null);
    reader.setSource(new DefaultInputSupplier(schemaLocation));
    IOReport schemaReport = reader.execute(null);
    assertTrue(schemaReport.isSuccess());
    Schema sourceSchema = reader.getSchema();
    // 
    InstanceReader instanceReader = new XmlInstanceReader();
    instanceReader.setSource(new DefaultInputSupplier(xmlLocation));
    instanceReader.setSourceSchema(sourceSchema);
    IOReport instanceReport = instanceReader.execute(null);
    assertTrue(instanceReport.isSuccess());
    return instanceReader.getInstances();
}
Also used : ShapeInstanceReader(eu.esdihumboldt.hale.io.shp.reader.internal.ShapeInstanceReader) InstanceReader(eu.esdihumboldt.hale.common.instance.io.InstanceReader) GmlInstanceReader(eu.esdihumboldt.hale.io.gml.reader.internal.GmlInstanceReader) XmlInstanceReader(eu.esdihumboldt.hale.io.gml.reader.internal.XmlInstanceReader) XmlSchemaReader(eu.esdihumboldt.hale.io.xsd.reader.XmlSchemaReader) ShapeSchemaReader(eu.esdihumboldt.hale.io.shp.reader.internal.ShapeSchemaReader) SchemaReader(eu.esdihumboldt.hale.common.schema.io.SchemaReader) XmlSchemaReader(eu.esdihumboldt.hale.io.xsd.reader.XmlSchemaReader) DefaultInputSupplier(eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier) XmlInstanceReader(eu.esdihumboldt.hale.io.gml.reader.internal.XmlInstanceReader) Schema(eu.esdihumboldt.hale.common.schema.model.Schema) IOReport(eu.esdihumboldt.hale.common.core.io.report.IOReport)

Example 12 with InstanceReader

use of eu.esdihumboldt.hale.common.instance.io.InstanceReader in project hale by halestudio.

the class ExecTransformation method setupReader.

private void setupReader(URI uri, int index) {
    LocatableInputSupplier<? extends InputStream> sourceIn = new DefaultInputSupplier(uri);
    // create I/O provider
    InstanceReader source = null;
    String customProvider = context.getSourceProviderIds().get(index);
    if (customProvider != null) {
        // use specified provider
        source = HaleIO.createIOProvider(InstanceReader.class, null, customProvider);
        if (source == null) {
            fail("Could not find instance reader with ID " + customProvider);
        }
    }
    if (source == null) {
        // find applicable reader
        source = HaleIO.findIOProvider(InstanceReader.class, sourceIn, uri.getPath());
    }
    if (source == null) {
        throw fail("Could not determine instance reader to use for source data");
    }
    // apply custom settings
    source.loadConfiguration(context.getSourcesSettings().get(index));
    source.setSource(sourceIn);
    // source schema is set in Transformation.transform
    // CRS provider is set in headless transformation
    sources.add(source);
}
Also used : InstanceReader(eu.esdihumboldt.hale.common.instance.io.InstanceReader) DefaultInputSupplier(eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier)

Example 13 with InstanceReader

use of eu.esdihumboldt.hale.common.instance.io.InstanceReader in project hale by halestudio.

the class PropertyResolverTest method loadXMLInstances.

private InstanceCollection loadXMLInstances(URI schemaLocation, URI xmlLocation) throws IOException, IOProviderConfigurationException {
    SchemaReader reader = new XmlSchemaReader();
    reader.setSharedTypes(null);
    reader.setSource(new DefaultInputSupplier(schemaLocation));
    IOReport schemaReport = reader.execute(null);
    assertTrue(schemaReport.isSuccess());
    Schema sourceSchema = reader.getSchema();
    // 
    InstanceReader instanceReader = new XmlInstanceReader();
    instanceReader.setParameter(XmlInstanceReader.PARAM_IGNORE_ROOT, Value.of(false));
    instanceReader.setSource(new DefaultInputSupplier(xmlLocation));
    instanceReader.setSourceSchema(sourceSchema);
    IOReport instanceReport = instanceReader.execute(null);
    assertTrue(instanceReport.isSuccess());
    return instanceReader.getInstances();
}
Also used : InstanceReader(eu.esdihumboldt.hale.common.instance.io.InstanceReader) GmlInstanceReader(eu.esdihumboldt.hale.io.gml.reader.internal.GmlInstanceReader) XmlInstanceReader(eu.esdihumboldt.hale.io.gml.reader.internal.XmlInstanceReader) XmlSchemaReader(eu.esdihumboldt.hale.io.xsd.reader.XmlSchemaReader) SchemaReader(eu.esdihumboldt.hale.common.schema.io.SchemaReader) XmlSchemaReader(eu.esdihumboldt.hale.io.xsd.reader.XmlSchemaReader) DefaultInputSupplier(eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier) XmlInstanceReader(eu.esdihumboldt.hale.io.gml.reader.internal.XmlInstanceReader) Schema(eu.esdihumboldt.hale.common.schema.model.Schema) IOReport(eu.esdihumboldt.hale.common.core.io.report.IOReport)

Aggregations

InstanceReader (eu.esdihumboldt.hale.common.instance.io.InstanceReader)13 DefaultInputSupplier (eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier)8 IOReport (eu.esdihumboldt.hale.common.core.io.report.IOReport)7 GmlInstanceReader (eu.esdihumboldt.hale.io.gml.reader.internal.GmlInstanceReader)5 SchemaReader (eu.esdihumboldt.hale.common.schema.io.SchemaReader)4 Schema (eu.esdihumboldt.hale.common.schema.model.Schema)4 XmlSchemaReader (eu.esdihumboldt.hale.io.xsd.reader.XmlSchemaReader)4 IOException (java.io.IOException)3 IOProvider (eu.esdihumboldt.hale.common.core.io.IOProvider)2 InstanceWriter (eu.esdihumboldt.hale.common.instance.io.InstanceWriter)2 XmlInstanceReader (eu.esdihumboldt.hale.io.gml.reader.internal.XmlInstanceReader)2 IOProviderDescriptor (eu.esdihumboldt.hale.common.core.io.extension.IOProviderDescriptor)1 AbstractIOAdvisor (eu.esdihumboldt.hale.common.core.io.impl.AbstractIOAdvisor)1 ProjectInfoAware (eu.esdihumboldt.hale.common.core.io.project.ProjectInfoAware)1 FileIOSupplier (eu.esdihumboldt.hale.common.core.io.supplier.FileIOSupplier)1 LocatableInputSupplier (eu.esdihumboldt.hale.common.core.io.supplier.LocatableInputSupplier)1 ProjectTransformationEnvironment (eu.esdihumboldt.hale.common.headless.impl.ProjectTransformationEnvironment)1 TransformationWorkspace (eu.esdihumboldt.hale.common.headless.transform.TransformationWorkspace)1 DefaultTransformedInstanceValidator (eu.esdihumboldt.hale.common.headless.transform.validate.impl.DefaultTransformedInstanceValidator)1 InstanceValidator (eu.esdihumboldt.hale.common.instance.io.InstanceValidator)1