use of eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier in project hale by halestudio.
the class PredefinedSchemaImpl method getLocation.
/**
* @see eu.esdihumboldt.hale.common.schema.presets.extension.SchemaPreset#getLocation()
*/
@Override
public LocatableInputSupplier<? extends InputStream> getLocation() {
IConfigurationElement[] children = element.getChildren("uri");
if (children != null && children.length > 0) {
IConfigurationElement uri = children[0];
URI location = URI.create(uri.getAttribute("value"));
return new DefaultInputSupplier(location);
}
return null;
}
use of eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier in project hale by halestudio.
the class TestUtil method loadAlignment.
/**
* Loads the specified alignment. Assumes that its base alignments don't
* need a location update.
*
* @param location the URI specifying the location of the alignment
* @param sourceTypes the source type index
* @param targetTypes the target type index
* @return the loaded alignment
* @throws Exception if the alignment or other resources could not be loaded
*/
public static Alignment loadAlignment(final URI location, Schema sourceTypes, Schema targetTypes) throws Exception {
DefaultInputSupplier input = new DefaultInputSupplier(location);
IOReporter report = new DefaultIOReporter(new Locatable() {
@Override
public URI getLocation() {
return location;
}
}, "Load alignment", AlignmentIO.ACTION_LOAD_ALIGNMENT, true);
Alignment alignment;
try {
alignment = CastorAlignmentIO.load(input.getInput(), report, sourceTypes, targetTypes, new PathUpdate(null, null));
} catch (Exception e) {
alignment = JaxbAlignmentIO.load(input.getInput(), report, sourceTypes, targetTypes, new PathUpdate(null, null), null, null);
}
assertTrue("Errors are contained in the report", report.getErrors().isEmpty());
return alignment;
}
use of eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier in project hale by halestudio.
the class SkosCodeListTest method readCodeList.
private CodeList readCodeList(URI source) throws Exception {
CodeListReader reader = new SkosCodeListReader();
reader.setSource(new DefaultInputSupplier(source));
IOReport report = reader.execute(new LogProgressIndicator());
assertTrue(report.isSuccess());
return reader.getCodeList();
}
use of eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier in project hale by halestudio.
the class CSVInstanceReaderTest method readCSVSchema.
private Schema readCSVSchema(String sourceLocation, String typeName, String paramPropertyType, String propertyNames, String seperator, String quote, String escape, String decimal) throws Exception {
CSVSchemaReader schemaReader = new CSVSchemaReader();
schemaReader.setSource(new DefaultInputSupplier(getClass().getResource(sourceLocation).toURI()));
schemaReader.setParameter(CommonSchemaConstants.PARAM_TYPENAME, Value.of(typeName));
schemaReader.setParameter(CSVSchemaReader.PARAM_PROPERTY, Value.of(propertyNames));
schemaReader.setParameter(CSVSchemaReader.PARAM_PROPERTYTYPE, Value.of(paramPropertyType));
schemaReader.setParameter(CSVSchemaReader.PARAM_SEPARATOR, Value.of(seperator));
schemaReader.setParameter(CSVSchemaReader.PARAM_QUOTE, Value.of(quote));
schemaReader.setParameter(CSVSchemaReader.PARAM_ESCAPE, Value.of(escape));
schemaReader.setParameter(CSVSchemaReader.PARAM_DECIMAL, Value.of(decimal));
IOReport report = schemaReader.execute(new LogProgressIndicator());
assertTrue(report.isSuccess());
return schemaReader.getSchema();
}
use of eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier in project hale by halestudio.
the class CSVSchemaReaderTest method testRead2.
/**
* Test for no given property names and property types (using default
* settings)
*
* @throws Exception the Exception thrown if the test fails
*/
@Test
public void testRead2() throws Exception {
String prop = "Name,Xcoord,Ycoord,id";
CSVSchemaReader schemaReader = new CSVSchemaReader();
schemaReader.setSource(new DefaultInputSupplier(getClass().getResource("/data/test1.csv").toURI()));
schemaReader.setParameter(CommonSchemaConstants.PARAM_TYPENAME, Value.of("TestTyp"));
schemaReader.setParameter(CSVSchemaReader.PARAM_PROPERTY, null);
schemaReader.setParameter(CSVSchemaReader.PARAM_PROPERTYTYPE, null);
schemaReader.setParameter(CSVSchemaReader.PARAM_SEPARATOR, null);
schemaReader.setParameter(CSVSchemaReader.PARAM_QUOTE, null);
schemaReader.setParameter(CSVSchemaReader.PARAM_ESCAPE, null);
IOReport report = schemaReader.execute(new LogProgressIndicator());
assertTrue(report.isSuccess());
Schema schema = schemaReader.getSchema();
assertEquals(1, schema.getMappingRelevantTypes().size());
TypeDefinition type = schema.getMappingRelevantTypes().iterator().next();
assertTrue(type.getName().getLocalPart().equals("TestTyp"));
Iterator<? extends ChildDefinition<?>> it = type.getChildren().iterator();
while (it.hasNext()) {
assertTrue(prop.contains(it.next().getName().getLocalPart()));
}
}
Aggregations