Search in sources :

Example 1 with MsAccessInstanceReader

use of eu.esdihumboldt.hale.io.jdbc.msaccess.MsAccessInstanceReader in project hale by halestudio.

the class MsAccessDataReaderTestSuit method readInstances.

/**
 * Reads instances from from a MsAccess database file with the provided
 * schema.
 *
 * @param sourceSchema the schema of the source database
 * @param sourceFile the file of the source database.
 * @return the read instances
 * @throws Exception any exception thrown by {@link MsAccessInstanceReader}
 */
public InstanceCollection readInstances(Schema sourceSchema, File sourceFile) throws Exception {
    MsAccessInstanceReader instanceReader = new MsAccessInstanceReader();
    instanceReader.setSource(new FileIOSupplier(sourceFile));
    instanceReader.setSourceSchema(sourceSchema);
    instanceReader.setParameter(JDBCInstanceReader.PARAM_USER, Value.of(USER_NAME));
    instanceReader.setParameter(JDBCInstanceReader.PARAM_PASSWORD, Value.of(PASSWORD));
    // Test instances
    IOReport report = instanceReader.execute(new LogProgressIndicator());
    assertTrue("Data import was not successfull.", report.isSuccess());
    return instanceReader.getInstances();
}
Also used : MsAccessInstanceReader(eu.esdihumboldt.hale.io.jdbc.msaccess.MsAccessInstanceReader) 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)

Aggregations

LogProgressIndicator (eu.esdihumboldt.hale.common.core.io.impl.LogProgressIndicator)1 IOReport (eu.esdihumboldt.hale.common.core.io.report.IOReport)1 FileIOSupplier (eu.esdihumboldt.hale.common.core.io.supplier.FileIOSupplier)1 MsAccessInstanceReader (eu.esdihumboldt.hale.io.jdbc.msaccess.MsAccessInstanceReader)1