Search in sources :

Example 11 with IOReport

use of eu.esdihumboldt.hale.common.core.io.report.IOReport 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 12 with IOReport

use of eu.esdihumboldt.hale.common.core.io.report.IOReport 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 13 with IOReport

use of eu.esdihumboldt.hale.common.core.io.report.IOReport 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)

Example 14 with IOReport

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

the class GmlInstanceCollectionTest method loadInstances.

private GmlInstanceCollection loadInstances(URI schemaLocation, URI xmlLocation, boolean restrictToFeatures, boolean ignoreNamespace) throws IOException, IOProviderConfigurationException {
    SchemaReader reader = new XmlSchemaReader();
    reader.setSharedTypes(null);
    reader.setSource(new DefaultInputSupplier(schemaLocation));
    IOReport schemaReport = reader.execute(null);
    assertTrue(schemaReport.isSuccess());
    Schema sourceSchema = reader.getSchema();
    return new GmlInstanceCollection(new DefaultInputSupplier(xmlLocation), sourceSchema, restrictToFeatures, false, true, ignoreNamespace, null, reader);
}
Also used : SchemaReader(eu.esdihumboldt.hale.common.schema.io.SchemaReader) XmlSchemaReader(eu.esdihumboldt.hale.io.xsd.reader.XmlSchemaReader) XmlSchemaReader(eu.esdihumboldt.hale.io.xsd.reader.XmlSchemaReader) DefaultInputSupplier(eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier) Schema(eu.esdihumboldt.hale.common.schema.model.Schema) IOReport(eu.esdihumboldt.hale.common.core.io.report.IOReport)

Example 15 with IOReport

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

the class StreamGmlWriterTest method testGeometryPrimitive_31_Polygon.

/**
 * Test writing a {@link Polygon} to a GML 3.1 geometry primitive type
 *
 * @throws Exception if an error occurs
 */
// @Ignore // loading Polygons not yet supported
@Test
public void testGeometryPrimitive_31_Polygon() throws Exception {
    // create the geometry
    Polygon polygon = createPolygon(0.0);
    Map<List<QName>, Object> values = new HashMap<List<QName>, Object>();
    // $NON-NLS-1$
    values.put(GEOMETRY_PROPERTY, polygon);
    IOReport report = fillFeatureTest(// $NON-NLS-1$
    "PrimitiveTest", // $NON-NLS-1$
    getClass().getResource("/data/geom_schema/geom-gml31.xsd").toURI(), // $NON-NLS-1$
    values, // $NON-NLS-1$
    "geometryPrimitive_31_Polygon", // $NON-NLS-1$
    DEF_SRS_NAME, true, false);
    // $NON-NLS-1$
    assertTrue("Expected GML output to be valid", report.isSuccess());
}
Also used : HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) IOReport(eu.esdihumboldt.hale.common.core.io.report.IOReport) List(java.util.List) MultiPolygon(com.vividsolutions.jts.geom.MultiPolygon) Polygon(com.vividsolutions.jts.geom.Polygon) Test(org.junit.Test)

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