use of eu.esdihumboldt.hale.common.core.io.impl.LogProgressIndicator in project hale by halestudio.
the class MsAccessDataReaderTestSuit method schemaReaderTest.
/**
* Test - reads a sample MsAccess Database schema. UCanAccess lib should not
* throw any error.
*
* @throws Exception if an error occurs
*/
public void schemaReaderTest() throws Exception {
MsAccessSchemaReader schemaReader = new MsAccessSchemaReader();
schemaReader.setSource(new FileIOSupplier(getSourceTempFilePath()));
schemaReader.setParameter(JDBCSchemaReader.PARAM_USER, Value.of(USER_NAME));
schemaReader.setParameter(JDBCSchemaReader.PARAM_PASSWORD, Value.of(PASSWORD));
IOReport report = schemaReader.execute(new LogProgressIndicator());
assertTrue(report.isSuccess());
TEMP_SOURCE_FILE_NAME = null;
Schema schema = schemaReader.getSchema();
assertTrue(schema != null);
Collection<? extends TypeDefinition> k = schema.getMappingRelevantTypes();
for (TypeDefinition def : k) System.out.println(def.getDisplayName());
checkTables(k);
}
use of eu.esdihumboldt.hale.common.core.io.impl.LogProgressIndicator 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();
}
use of eu.esdihumboldt.hale.common.core.io.impl.LogProgressIndicator in project hale by halestudio.
the class MsSQLServer14Test method readInstances.
/**
* Reads instances from from a MsAccess database file with the provided
* schema.
*
* @param sourceSchema the schema of the source database
* @return the read instances
* @throws Exception any exception thrown by {@link JDBCInstanceReader}
*/
private InstanceCollection readInstances(Schema sourceSchema) throws Exception {
JDBCInstanceReader instanceReader = new JDBCInstanceReader();
JDBCURI = new MsSqlURIBuilder().createJdbcUri(HOST, DATABASE);
instanceReader.setSource(new NoStreamInputSupplier(JDBCURI));
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();
}
use of eu.esdihumboldt.hale.common.core.io.impl.LogProgressIndicator in project hale by halestudio.
the class SpatiaLiteTestSuite method schemaReaderTest.
/**
* Test - reads a sample SpatiaLite schema
*
* @throws Exception if an error occurs
*/
public void schemaReaderTest() throws Exception {
if (!isSpatiaLiteExtensionAvailable()) {
log.info("Skipping test because SpatiaLite extension is not available");
return;
}
Set<String> propertyNames = new HashSet<String>(Arrays.asList(SOUURCE_TYPE_PROPERTY_NAMES));
SpatiaLiteSchemaReader schemaReader = new SpatiaLiteSchemaReader();
schemaReader.setSource(new FileIOSupplier(new File(getSourceTempFilePath())));
IOReport report = schemaReader.execute(new LogProgressIndicator());
assertTrue(report.isSuccess());
Schema schema = schemaReader.getSchema();
assertEquals(1, schema.getMappingRelevantTypes().size());
TypeDefinition type = schema.getMappingRelevantTypes().iterator().next();
checkType(type, SOUURCE_TYPE_LOCAL_NAME, propertyNames);
}
use of eu.esdihumboldt.hale.common.core.io.impl.LogProgressIndicator in project hale by halestudio.
the class SpatiaLiteTestSuite method writeInstances.
/**
* Writes the provided instances to a SpatiaLite database.
*
* @param schema the target schema
* @param targetFilePath the path to the target database file
* @param instances the instances to write
* @throws Exception any exception thrown by
* {@link SpatiaLiteInstanceWriter}
*/
public void writeInstances(Schema schema, String targetFilePath, InstanceCollection instances) throws Exception {
SpatiaLiteInstanceWriter instanceWriter = new SpatiaLiteInstanceWriter();
instanceWriter.setInstances(instances);
DefaultSchemaSpace ss = new DefaultSchemaSpace();
ss.addSchema(schema);
instanceWriter.setTargetSchema(ss);
instanceWriter.setTarget(new FileIOSupplier(new File(targetFilePath)));
// Test instances
IOReport report = instanceWriter.execute(new LogProgressIndicator());
assertTrue("Data export was not successfull.", report.isSuccess());
}
Aggregations