Search in sources :

Example 51 with IOReport

use of eu.esdihumboldt.hale.common.core.io.report.IOReport in project hale by halestudio.

the class MsAccessDataReaderTestSuit method readSchema.

/**
 * Reads a schema from a MsAccess database file.
 *
 * @param sourceFile the file of the source database.
 * @return the schema
 * @throws Exception any exception thrown by {@link MsAccessSchemaReader}
 */
public Schema readSchema(File sourceFile) throws Exception {
    MsAccessSchemaReader schemaReader = new MsAccessSchemaReader();
    schemaReader.setSource(new FileIOSupplier(sourceFile));
    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());
    return schemaReader.getSchema();
}
Also used : 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)

Example 52 with IOReport

use of eu.esdihumboldt.hale.common.core.io.report.IOReport in project hale by halestudio.

the class MsSQLServer14Test method readSchema.

/**
 * Reads a schema from a MS SQL database.
 *
 * @return the schema
 * @throws Exception any exception thrown by {@link JDBCSchemaReader}
 */
private Schema readSchema() throws Exception {
    JDBCSchemaReader schemaReader = new JDBCSchemaReader();
    JDBCURI = new MsSqlURIBuilder().createJdbcUri(HOST, DATABASE);
    schemaReader.setSource(new NoStreamInputSupplier(JDBCURI));
    schemaReader.setParameter(JDBCSchemaReader.PARAM_USER, Value.of(USER_NAME));
    schemaReader.setParameter(JDBCSchemaReader.PARAM_PASSWORD, Value.of(PASSWORD));
    // This is set for setting inclusion rule for reading schema
    schemaReader.setParameter(JDBCSchemaReader.SCHEMAS, Value.of(SCHEMA));
    IOReport report = schemaReader.execute(new LogProgressIndicator());
    assertTrue(report.isSuccess());
    assertTrue(report.getErrors().isEmpty());
    Schema schema = schemaReader.getSchema();
    assertNotNull(schema);
    return schema;
}
Also used : MsSqlURIBuilder(eu.esdihumboldt.hale.io.jdbc.mssql.MsSqlURIBuilder) Schema(eu.esdihumboldt.hale.common.schema.model.Schema) IOReport(eu.esdihumboldt.hale.common.core.io.report.IOReport) LogProgressIndicator(eu.esdihumboldt.hale.common.core.io.impl.LogProgressIndicator) JDBCSchemaReader(eu.esdihumboldt.hale.io.jdbc.JDBCSchemaReader) NoStreamInputSupplier(eu.esdihumboldt.hale.common.core.io.supplier.NoStreamInputSupplier)

Example 53 with IOReport

use of eu.esdihumboldt.hale.common.core.io.report.IOReport in project hale by halestudio.

the class MsSqlDataReaderTest method readSchema.

/**
 * Reads a schema from a MS SQL database.
 *
 * @return the schema
 * @throws Exception any exception thrown by {@link JDBCSchemaReader}
 */
private Schema readSchema() throws Exception {
    JDBCSchemaReader schemaReader = new JDBCSchemaReader();
    JDBCURI = new MsSqlURIBuilder().createJdbcUri(HOST, DATABASE);
    schemaReader.setSource(new NoStreamInputSupplier(JDBCURI));
    schemaReader.setParameter(JDBCSchemaReader.PARAM_USER, Value.of(USER_NAME));
    schemaReader.setParameter(JDBCSchemaReader.PARAM_PASSWORD, Value.of(PASSWORD));
    // This is set for setting inclusion rule for reading schema
    schemaReader.setParameter(JDBCSchemaReader.SCHEMAS, Value.of(SCHEMA));
    IOReport report = schemaReader.execute(new LogProgressIndicator());
    assertTrue(report.isSuccess());
    assertTrue(report.getErrors().isEmpty());
    Schema schema = schemaReader.getSchema();
    assertNotNull(schema);
    return schema;
}
Also used : MsSqlURIBuilder(eu.esdihumboldt.hale.io.jdbc.mssql.MsSqlURIBuilder) Schema(eu.esdihumboldt.hale.common.schema.model.Schema) IOReport(eu.esdihumboldt.hale.common.core.io.report.IOReport) LogProgressIndicator(eu.esdihumboldt.hale.common.core.io.impl.LogProgressIndicator) JDBCSchemaReader(eu.esdihumboldt.hale.io.jdbc.JDBCSchemaReader) NoStreamInputSupplier(eu.esdihumboldt.hale.common.core.io.supplier.NoStreamInputSupplier)

Example 54 with IOReport

use of eu.esdihumboldt.hale.common.core.io.report.IOReport in project hale by halestudio.

the class MsSqlDataReaderTest 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 55 with IOReport

use of eu.esdihumboldt.hale.common.core.io.report.IOReport in project hale by halestudio.

the class AbstractDBTest method writeInstances.

/**
 * Write instances to the database.
 *
 * @param instances the collection of instances
 * @param schema the target schema
 * @throws Exception if writing the instances fails
 */
protected void writeInstances(InstanceCollection instances, Schema schema) throws Exception {
    JDBCInstanceWriter writer = new JDBCInstanceWriter();
    writer.setTarget(new NoStreamOutputSupplier(jdbcUri));
    writer.setParameter(JDBCInstanceWriter.PARAM_USER, Value.of(dbi.getUser()));
    writer.setParameter(JDBCInstanceWriter.PARAM_PASSWORD, Value.of(dbi.getPassword()));
    writer.setInstances(instances);
    DefaultSchemaSpace targetSchema = new DefaultSchemaSpace();
    targetSchema.addSchema(schema);
    writer.setTargetSchema(targetSchema);
    IOReport report = writer.execute(null);
    assertTrue(report.isSuccess());
    assertTrue(report.getErrors().isEmpty());
}
Also used : DefaultSchemaSpace(eu.esdihumboldt.hale.common.schema.model.impl.DefaultSchemaSpace) IOReport(eu.esdihumboldt.hale.common.core.io.report.IOReport) NoStreamOutputSupplier(eu.esdihumboldt.hale.common.core.io.supplier.NoStreamOutputSupplier) JDBCInstanceWriter(eu.esdihumboldt.hale.io.jdbc.JDBCInstanceWriter)

Aggregations

IOReport (eu.esdihumboldt.hale.common.core.io.report.IOReport)102 DefaultInputSupplier (eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier)34 Test (org.junit.Test)33 LogProgressIndicator (eu.esdihumboldt.hale.common.core.io.impl.LogProgressIndicator)25 List (java.util.List)23 QName (javax.xml.namespace.QName)23 FileIOSupplier (eu.esdihumboldt.hale.common.core.io.supplier.FileIOSupplier)22 Schema (eu.esdihumboldt.hale.common.schema.model.Schema)22 HashMap (java.util.HashMap)22 File (java.io.File)14 MultiPolygon (com.vividsolutions.jts.geom.MultiPolygon)11 XmlSchemaReader (eu.esdihumboldt.hale.io.xsd.reader.XmlSchemaReader)11 SchemaReader (eu.esdihumboldt.hale.common.schema.io.SchemaReader)10 IOProviderConfigurationException (eu.esdihumboldt.hale.common.core.io.IOProviderConfigurationException)8 IOProviderDescriptor (eu.esdihumboldt.hale.common.core.io.extension.IOProviderDescriptor)8 IOMessageImpl (eu.esdihumboldt.hale.common.core.io.report.impl.IOMessageImpl)8 IOException (java.io.IOException)8 Ignore (org.junit.Ignore)8 MultiLineString (com.vividsolutions.jts.geom.MultiLineString)7 IOReporter (eu.esdihumboldt.hale.common.core.io.report.IOReporter)7