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