Search in sources :

Example 6 with LogProgressIndicator

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();
}
Also used : SpatiaLiteSchemaReader(eu.esdihumboldt.hale.io.jdbc.spatialite.reader.internal.SpatiaLiteSchemaReader) IOReport(eu.esdihumboldt.hale.common.core.io.report.IOReport) FileIOSupplier(eu.esdihumboldt.hale.common.core.io.supplier.FileIOSupplier) LogProgressIndicator(eu.esdihumboldt.hale.common.core.io.impl.LogProgressIndicator) File(java.io.File)

Example 7 with LogProgressIndicator

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();
}
Also used : SpatiaLiteInstanceReader(eu.esdihumboldt.hale.io.jdbc.spatialite.reader.internal.SpatiaLiteInstanceReader) IOReport(eu.esdihumboldt.hale.common.core.io.report.IOReport) FileIOSupplier(eu.esdihumboldt.hale.common.core.io.supplier.FileIOSupplier) LogProgressIndicator(eu.esdihumboldt.hale.common.core.io.impl.LogProgressIndicator) File(java.io.File)

Example 8 with LogProgressIndicator

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;
}
Also used : Instance(eu.esdihumboldt.hale.common.instance.model.Instance) InstanceCollection(eu.esdihumboldt.hale.common.instance.model.InstanceCollection) DefaultSchemaSpace(eu.esdihumboldt.hale.common.schema.model.impl.DefaultSchemaSpace) ArrayList(java.util.ArrayList) IOReport(eu.esdihumboldt.hale.common.core.io.report.IOReport) FileIOSupplier(eu.esdihumboldt.hale.common.core.io.supplier.FileIOSupplier) LogProgressIndicator(eu.esdihumboldt.hale.common.core.io.impl.LogProgressIndicator) File(java.io.File)

Example 9 with LogProgressIndicator

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());
}
Also used : ComplexValue(eu.esdihumboldt.hale.common.core.io.impl.ComplexValue) DataStore(eu.esdihumboldt.hale.io.appschema.impl.internal.generated.app_schema.SourceDataStoresPropertyType.DataStore) IOReport(eu.esdihumboldt.hale.common.core.io.report.IOReport) FileIOSupplier(eu.esdihumboldt.hale.common.core.io.supplier.FileIOSupplier) LogProgressIndicator(eu.esdihumboldt.hale.common.core.io.impl.LogProgressIndicator)

Example 10 with LogProgressIndicator

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();
}
Also used : SkosCodeListReader(eu.esdihumboldt.hale.io.codelist.skos.reader.SkosCodeListReader) CodeListReader(eu.esdihumboldt.hale.common.codelist.io.CodeListReader) SkosCodeListReader(eu.esdihumboldt.hale.io.codelist.skos.reader.SkosCodeListReader) DefaultInputSupplier(eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier) IOReport(eu.esdihumboldt.hale.common.core.io.report.IOReport) LogProgressIndicator(eu.esdihumboldt.hale.common.core.io.impl.LogProgressIndicator)

Aggregations

LogProgressIndicator (eu.esdihumboldt.hale.common.core.io.impl.LogProgressIndicator)26 IOReport (eu.esdihumboldt.hale.common.core.io.report.IOReport)25 DefaultInputSupplier (eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier)11 Schema (eu.esdihumboldt.hale.common.schema.model.Schema)9 FileIOSupplier (eu.esdihumboldt.hale.common.core.io.supplier.FileIOSupplier)8 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)7 CSVSchemaReader (eu.esdihumboldt.hale.io.csv.reader.internal.CSVSchemaReader)7 File (java.io.File)5 Test (org.junit.Test)5 NoStreamInputSupplier (eu.esdihumboldt.hale.common.core.io.supplier.NoStreamInputSupplier)4 MsSqlURIBuilder (eu.esdihumboldt.hale.io.jdbc.mssql.MsSqlURIBuilder)4 PathUpdate (eu.esdihumboldt.hale.common.core.io.PathUpdate)2 DefaultSchemaSpace (eu.esdihumboldt.hale.common.schema.model.impl.DefaultSchemaSpace)2 JDBCSchemaReader (eu.esdihumboldt.hale.io.jdbc.JDBCSchemaReader)2 SpatiaLiteSchemaReader (eu.esdihumboldt.hale.io.jdbc.spatialite.reader.internal.SpatiaLiteSchemaReader)2 IOException (java.io.IOException)2 ATransaction (de.fhg.igd.slf4jplus.ATransaction)1 AlignmentReader (eu.esdihumboldt.hale.common.align.io.AlignmentReader)1 JaxbAlignmentReader (eu.esdihumboldt.hale.common.align.io.impl.JaxbAlignmentReader)1 Alignment (eu.esdihumboldt.hale.common.align.model.Alignment)1