use of eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier in project hale by halestudio.
the class CityGMLPropagate method loadCityGML.
private void loadCityGML() throws IOProviderConfigurationException, IOException {
System.out.println("Loading schema...");
LocatableInputSupplier<? extends InputStream> schemaIn = new DefaultInputSupplier(context.getSourceSchema());
SchemaReader schemaReader = HaleIO.findIOProvider(SchemaReader.class, schemaIn, context.getSourceSchema().getPath());
schemaReader.setSource(schemaIn);
IOReport report = schemaReader.execute(new NullProgressIndicator());
if (!report.isSuccess() || !report.getErrors().isEmpty()) {
throw new IllegalStateException("Failed to load schema");
}
cityGMLSource = schemaReader.getSchema();
}
use of eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier in project hale by halestudio.
the class CityGMLPropagate method loadProject.
private boolean loadProject() throws IOException {
final AtomicBoolean success = new AtomicBoolean(true);
LocatableInputSupplier<? extends InputStream> projectIn = new DefaultInputSupplier(context.getProject());
ProjectTransformationEnvironment env = new ProjectTransformationEnvironment("sample", projectIn, new ReportHandler() {
@Override
public void publishReport(Report<?> report) {
if (report.isSuccess() && report.getErrors().isEmpty()) {
System.out.println(report.getSummary());
} else {
System.err.println("Error loading project: " + report.getSummary());
success.set(false);
}
}
});
if (success.get()) {
this.sourceSchema = env.getSourceSchema();
this.targetSchema = env.getTargetSchema();
this.examples = env.getAlignment();
return true;
}
return false;
}
use of eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier in project hale by halestudio.
the class SkosCodeListTest method readCodeList_WithLanguage.
private CodeList readCodeList_WithLanguage(URI source, final String language) throws Exception {
SkosCodeListReader reader = new SkosCodeListReader() {
/**
* @see eu.esdihumboldt.hale.io.codelist.skos.reader.SkosCodeListReader#getLangauge()
*/
@Override
public String getLangauge() {
return language;
}
};
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 readCSVInstances.
private InstanceCollection readCSVInstances(String sourceLocation, String typeName, boolean skipFirst, Schema sourceSchema, String seperator, String quote, String escape, String decimal) throws Exception {
InstanceReader instanceReader = new CSVInstanceReader();
instanceReader.setSource(new DefaultInputSupplier(getClass().getResource(sourceLocation).toURI()));
instanceReader.setParameter(CommonSchemaConstants.PARAM_TYPENAME, Value.of(typeName));
instanceReader.setParameter(CommonSchemaConstants.PARAM_SKIP_FIRST_LINE, Value.of(skipFirst));
instanceReader.setParameter(CSVSchemaReader.PARAM_SEPARATOR, Value.of(seperator));
instanceReader.setParameter(CSVSchemaReader.PARAM_QUOTE, Value.of(quote));
instanceReader.setParameter(CSVSchemaReader.PARAM_ESCAPE, Value.of(escape));
instanceReader.setParameter(CSVSchemaReader.PARAM_DECIMAL, Value.of(decimal));
instanceReader.setSourceSchema(sourceSchema);
// Test instances
IOReport report = instanceReader.execute(null);
assertTrue("Data import was not successfull.", report.isSuccess());
return instanceReader.getInstances();
}
use of eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier in project hale by halestudio.
the class CSVSchemaReaderTest method testRead4.
/**
* Test for given property names and property types with point as a decimal
* divisor
*
* @throws Exception the Exception thrown if the test fails
*/
@Test
public void testRead4() throws Exception {
String props = "A,B,C,D,E";
CSVSchemaReader schemaReader = new CSVSchemaReader();
schemaReader.setSource(new DefaultInputSupplier(getClass().getResource("/data/test4-commadecimal.csv").toURI()));
schemaReader.setParameter(CommonSchemaConstants.PARAM_TYPENAME, Value.of("TestTyp"));
schemaReader.setParameter(CSVSchemaReader.PARAM_PROPERTY, Value.of(props));
schemaReader.setParameter(CSVSchemaReader.PARAM_PROPERTYTYPE, Value.of("java.lang.Integer,java.lang.String,java.lang.Float,java.lang.Float,java.lang.String"));
schemaReader.setParameter(CSVSchemaReader.PARAM_SEPARATOR, Value.of(";"));
schemaReader.setParameter(CSVSchemaReader.PARAM_QUOTE, null);
schemaReader.setParameter(CSVSchemaReader.PARAM_ESCAPE, null);
schemaReader.setParameter(CSVSchemaReader.PARAM_DECIMAL, Value.of(","));
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(props.contains(it.next().getName().getLocalPart()));
}
}
Aggregations