Search in sources :

Example 1 with SpatiaLiteSchemaReader

use of eu.esdihumboldt.hale.io.jdbc.spatialite.reader.internal.SpatiaLiteSchemaReader in project hale by halestudio.

the class SpatiaLiteTestSuite method readSchema.

/**
 * Reads a schema from a SpatiaLite database file.
 *
 * @param sourceFilePath the path to the source database file
 * @return the schema
 * @throws Exception any exception thrown by {@link SpatiaLiteSchemaReader}
 */
public Schema readSchema(String sourceFilePath) throws Exception {
    SpatiaLiteSchemaReader schemaReader = new SpatiaLiteSchemaReader();
    schemaReader.setSource(new FileIOSupplier(new File(sourceFilePath)));
    IOReport report = schemaReader.execute(new LogProgressIndicator());
    assertTrue(report.isSuccess());
    return schemaReader.getSchema();
}
Also used : 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)

Example 2 with SpatiaLiteSchemaReader

use of eu.esdihumboldt.hale.io.jdbc.spatialite.reader.internal.SpatiaLiteSchemaReader 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)

Aggregations

LogProgressIndicator (eu.esdihumboldt.hale.common.core.io.impl.LogProgressIndicator)2 IOReport (eu.esdihumboldt.hale.common.core.io.report.IOReport)2 FileIOSupplier (eu.esdihumboldt.hale.common.core.io.supplier.FileIOSupplier)2 SpatiaLiteSchemaReader (eu.esdihumboldt.hale.io.jdbc.spatialite.reader.internal.SpatiaLiteSchemaReader)2 File (java.io.File)2 Schema (eu.esdihumboldt.hale.common.schema.model.Schema)1 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)1 HashSet (java.util.HashSet)1