use of eu.esdihumboldt.hale.common.core.io.impl.LogProgressIndicator in project hale by halestudio.
the class SpatiaLiteTestSuite method readSchema.
/**
* Reads a schema from a SpatiaLite database file.
*
* @param sourceFilePath the path to the source database file
* @return the schema
* @throws Exception any exception thrown by {@link SpatiaLiteSchemaReader}
*/
public Schema readSchema(String sourceFilePath) throws Exception {
SpatiaLiteSchemaReader schemaReader = new SpatiaLiteSchemaReader();
schemaReader.setSource(new FileIOSupplier(new File(sourceFilePath)));
IOReport report = schemaReader.execute(new LogProgressIndicator());
assertTrue(report.isSuccess());
return schemaReader.getSchema();
}
use of eu.esdihumboldt.hale.common.core.io.impl.LogProgressIndicator in project hale by halestudio.
the class SpatiaLiteTestSuite method readInstances.
/**
* Reads instances from from a SpatiaLite database file with the provided
* schema.
*
* @param sourceSchema the schema of the source database
* @param sourceFilePath the path to the source database file
* @return the read instances
* @throws Exception any exception thrown by
* {@link SpatiaLiteInstanceReader}
*/
public InstanceCollection readInstances(Schema sourceSchema, String sourceFilePath) throws Exception {
SpatiaLiteInstanceReader instanceReader = new SpatiaLiteInstanceReader();
instanceReader.setSource(new FileIOSupplier(new File(sourceFilePath)));
instanceReader.setSourceSchema(sourceSchema);
// Test instances
IOReport report = instanceReader.execute(new LogProgressIndicator());
assertTrue("Data import was not successfull.", report.isSuccess());
return instanceReader.getInstances();
}
use of eu.esdihumboldt.hale.common.core.io.impl.LogProgressIndicator in project hale by halestudio.
the class XsltTransformationTest method transformData.
@Override
protected List<Instance> transformData(TransformationExample example) throws Exception {
// export alignment to XSLT
XsltExport export = new XsltExport();
export.setAlignment(example.getAlignment());
export.setSourceSchema(new DefaultSchemaSpace().addSchema(example.getSourceSchema()));
export.setTargetSchema(new DefaultSchemaSpace().addSchema(example.getTargetSchema()));
export.setParameter(XsltExport.PARAM_ROOT_ELEMENT_NAMESPACE, Value.of(example.getTargetContainerNamespace()));
export.setParameter(XsltExport.PARAM_ROOT_ELEMENT_NAME, Value.of(example.getTargetContainerName()));
File tempXsltFile = File.createTempFile("xsltest", ".xsl");
export.setTarget(new FileIOSupplier(tempXsltFile));
IOReport res = export.execute(new LogProgressIndicator());
assertTrue("XSLT export not successful", res.isSuccess());
assertTrue("Errors during XSLT export", res.getErrors().isEmpty());
// invoke XSLT on source file to produce target
File target = File.createTempFile("xsltest", ".xml");
executeXslt(example.getSourceDataInput(), tempXsltFile, target);
// load target and return instances
InstanceCollection instances = TestUtil.loadInstances(target.toURI(), example.getTargetSchema());
List<Instance> list = new ArrayList<Instance>();
ResourceIterator<Instance> it = instances.iterator();
try {
while (it.hasNext()) {
list.add(it.next());
}
} finally {
it.close();
}
// clean up
tempXsltFile.delete();
target.delete();
return list;
}
use of eu.esdihumboldt.hale.common.core.io.impl.LogProgressIndicator in project hale by halestudio.
the class AppSchemaFileWriterTest method writeAlignment.
private void writeAlignment(File targetFile, String contentType) throws IOException, IOProviderConfigurationException {
AbstractAppSchemaConfigurator alignWriter = new AppSchemaMappingFileWriter();
prepareProvider(alignWriter, project, tempDir.toURI());
alignWriter.setAlignment(alignment);
alignWriter.setSourceSchema(sourceSchemaSpace);
alignWriter.setTargetSchema(targetSchemaSpace);
alignWriter.setTarget(new FileIOSupplier(targetFile));
DataStore dataStoreParam = createDataStoreParam();
alignWriter.setParameter(AppSchemaIO.PARAM_DATASTORE, new ComplexValue(dataStoreParam));
alignWriter.setContentType(HalePlatform.getContentTypeManager().getContentType(contentType));
IOReport report = alignWriter.execute(new LogProgressIndicator());
assertNotNull(report);
assertTrue(report.isSuccess());
}
use of eu.esdihumboldt.hale.common.core.io.impl.LogProgressIndicator 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();
}
Aggregations