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();
}
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);
}
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();
}
Aggregations