Search in sources :

Example 1 with LogProgressIndicator

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);
}
Also used : Schema(eu.esdihumboldt.hale.common.schema.model.Schema) 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) MsAccessSchemaReader(eu.esdihumboldt.hale.io.jdbc.msaccess.MsAccessSchemaReader) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition)

Example 2 with LogProgressIndicator

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();
}
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)

Example 3 with LogProgressIndicator

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();
}
Also used : MsSqlURIBuilder(eu.esdihumboldt.hale.io.jdbc.mssql.MsSqlURIBuilder) JDBCInstanceReader(eu.esdihumboldt.hale.io.jdbc.JDBCInstanceReader) IOReport(eu.esdihumboldt.hale.common.core.io.report.IOReport) LogProgressIndicator(eu.esdihumboldt.hale.common.core.io.impl.LogProgressIndicator) NoStreamInputSupplier(eu.esdihumboldt.hale.common.core.io.supplier.NoStreamInputSupplier)

Example 4 with LogProgressIndicator

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);
}
Also used : Schema(eu.esdihumboldt.hale.common.schema.model.Schema) 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) HashSet(java.util.HashSet) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition)

Example 5 with LogProgressIndicator

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());
}
Also used : DefaultSchemaSpace(eu.esdihumboldt.hale.common.schema.model.impl.DefaultSchemaSpace) 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) SpatiaLiteInstanceWriter(eu.esdihumboldt.hale.io.jdbc.spatialite.writer.internal.SpatiaLiteInstanceWriter)

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