Search in sources :

Example 1 with SpatiaLiteInstanceWriter

use of eu.esdihumboldt.hale.io.jdbc.spatialite.writer.internal.SpatiaLiteInstanceWriter 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)1 IOReport (eu.esdihumboldt.hale.common.core.io.report.IOReport)1 FileIOSupplier (eu.esdihumboldt.hale.common.core.io.supplier.FileIOSupplier)1 DefaultSchemaSpace (eu.esdihumboldt.hale.common.schema.model.impl.DefaultSchemaSpace)1 SpatiaLiteInstanceWriter (eu.esdihumboldt.hale.io.jdbc.spatialite.writer.internal.SpatiaLiteInstanceWriter)1 File (java.io.File)1