use of ch.interlis.iom.IomObject in project ili2db by claeis.
the class ExtendedModel23Test method exportXtfOriginal.
@Test
public void exportXtfOriginal() throws Exception {
Connection jdbcConnection = null;
try {
Class driverClass = Class.forName("org.postgresql.Driver");
jdbcConnection = DriverManager.getConnection(dburl, dbuser, dbpwd);
DbUtility.executeSqlScript(jdbcConnection, new java.io.FileReader("test/data/ExtendedModel/ExtendedModelCreateTable.sql"));
DbUtility.executeSqlScript(jdbcConnection, new java.io.FileReader("test/data/ExtendedModel/ExtendedModelInsertIntoTable.sql"));
File data = new File("test/data/ExtendedModel/ExtendedModel1-out.xtf");
Config config = initConfig(data.getPath(), DBSCHEMA, data.getPath() + ".log");
config.setModels("BaseModel;ExtendedModel");
config.setFunction(Config.FC_EXPORT);
Ili2db.readSettingsFromDb(config);
Ili2db.run(config, null);
HashMap<String, IomObject> objs = new HashMap<String, IomObject>();
XtfReader reader = new XtfReader(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("32");
Assert.assertNotNull(obj0);
Assert.assertEquals("ExtendedModel.TestAp.ClassA2", obj0.getobjecttag());
Assert.assertEquals("rot.dunkel", obj0.getattrvalue("farbe"));
Assert.assertEquals("33", obj0.getattrobj("a3", 0).getobjectrefoid());
Assert.assertEquals("1.1", obj0.getattrvalue("wert"));
Assert.assertEquals("34", obj0.getattrobj("ap1", 0).getobjectrefoid());
}
} catch (Exception e) {
throw new IoxException(e);
} finally {
if (jdbcConnection != null) {
jdbcConnection.close();
}
}
}
Aggregations