use of ch.interlis.iom_j.itf.ItfReader in project ili2db by claeis.
the class TranslationTest method exportItf10lineTable.
// @Test
public void exportItf10lineTable() throws Exception {
Connection jdbcConnection = null;
try {
EhiLogger.getInstance().setTraceFilter(false);
Class driverClass = Class.forName("org.postgresql.Driver");
jdbcConnection = DriverManager.getConnection(dburl, dbuser, dbpwd);
Statement stmt = jdbcConnection.createStatement();
stmt.execute("DROP SCHEMA IF EXISTS " + DBSCHEMA + " CASCADE");
DbUtility.executeSqlScript(jdbcConnection, new java.io.FileReader("test/data/Translation/CreateTableItf10LineTable.sql"));
DbUtility.executeSqlScript(jdbcConnection, new java.io.FileReader("test/data/Translation/InsertIntoTableItf10LineTable.sql"));
{
File data = new File("test/data/Translation/ModelAsimple10a-out.itf");
Config config = initConfig(data.getPath(), DBSCHEMA, data.getPath() + ".log");
config.setFunction(Config.FC_EXPORT);
config.setDatasetName("ModelAsimple10");
Ili2db.readSettingsFromDb(config);
Ili2db.run(config, null);
}
{
File data = new File("test/data/Translation/ModelBsimple10a-out.itf");
Config config = initConfig(data.getPath(), DBSCHEMA, data.getPath() + ".log");
config.setFunction(Config.FC_EXPORT);
config.setDatasetName("ModelBsimple10");
Ili2db.readSettingsFromDb(config);
Ili2db.run(config, null);
HashMap<String, IomObject> objs = new HashMap<String, IomObject>();
ItfReader reader = new ItfReader(data);
IoxEvent event = null;
do {
event = reader.read();
if (event instanceof StartTransferEvent) {
} else if (event instanceof StartBasketEvent) {
} else if (event instanceof ObjectEvent) {
IomObject iomObj = ((ObjectEvent) event).getIomObject();
if (iomObj.getobjectoid() != null) {
objs.put(iomObj.getobjectoid(), iomObj);
}
} else if (event instanceof EndBasketEvent) {
} else if (event instanceof EndTransferEvent) {
}
} while (!(event instanceof EndTransferEvent));
{
IomObject obj0 = objs.get("21");
Assert.assertNotNull(obj0);
Assert.assertEquals("ModelBsimple10.TopicB.ClassB", obj0.getobjecttag());
}
{
IomObject obj0 = objs.get("20");
Assert.assertNotNull(obj0);
Assert.assertEquals("ModelBsimple10.TopicB.ClassB", obj0.getobjecttag());
}
{
IomObject obj0 = objs.get("22");
Assert.assertNotNull(obj0);
Assert.assertEquals("ModelBsimple10.TopicB.ClassB2", obj0.getobjecttag());
}
{
IomObject obj0 = objs.get("25");
Assert.assertNotNull(obj0);
Assert.assertEquals("ModelBsimple10.TopicB.ClassB3", obj0.getobjecttag());
}
{
IomObject obj0 = objs.get("26");
Assert.assertNotNull(obj0);
Assert.assertEquals("ModelBsimple10.TopicB.ClassB2_geomB", obj0.getobjecttag());
}
{
IomObject obj0 = objs.get("27");
Assert.assertNotNull(obj0);
Assert.assertEquals("ModelBsimple10.TopicB.ClassB3_geomB", obj0.getobjecttag());
}
}
} finally {
if (jdbcConnection != null) {
jdbcConnection.close();
}
}
}
Aggregations