use of ch.interlis.iom.IomObject in project ili2db by claeis.
the class MultisurfaceTest method exportSmartChbaseSingleGeom.
@Test
public void exportSmartChbaseSingleGeom() throws Exception {
Connection jdbcConnection = null;
try {
Class driverClass = Class.forName("org.postgresql.Driver");
jdbcConnection = DriverManager.getConnection(dburl, dbuser, dbpwd);
stmt = jdbcConnection.createStatement();
stmt.execute("DROP SCHEMA IF EXISTS " + DBSCHEMA + " CASCADE");
DbUtility.executeSqlScript(jdbcConnection, new java.io.FileReader("test/data/MultiSurface/CreateTableSingleGeom.sql"));
DbUtility.executeSqlScript(jdbcConnection, new java.io.FileReader("test/data/MultiSurface/InsertIntoTableSingleGeom.sql"));
File data = new File("test/data/MultiSurface/MultiSurface1a-out.xtf");
Config config = initConfig(data.getPath(), DBSCHEMA, data.getPath() + ".log");
config.setModels("MultiSurface1");
config.setFunction(Config.FC_EXPORT);
config.setCreateFk(config.CREATE_FK_YES);
config.setBasketHandling(config.BASKET_HANDLING_READWRITE);
config.setCatalogueRefTrafo(null);
config.setMultiSurfaceTrafo(config.MULTISURFACE_TRAFO_COALESCE);
config.setOneGeomPerTable(true);
config.setMultilingualTrafo(null);
config.setInheritanceTrafo(null);
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));
// check oid
{
IomObject obj0 = objs.get("o1");
Assert.assertNotNull(obj0);
Assert.assertEquals("o1", obj0.getobjectoid());
}
// check objecttag
{
IomObject obj0 = objs.get("o1");
Assert.assertNotNull(obj0);
Assert.assertEquals("MultiSurface1.TestA.ClassA1", obj0.getobjecttag());
}
// check values of attrnames
{
IomObject obj0 = objs.get("o1");
Assert.assertNotNull(obj0);
Assert.assertEquals("COORD {C1 600031.0, C2 200021.0}", obj0.getattrobj("point", 0).toString());
Assert.assertEquals("GeometryCHLV03_V1.MultiSurface {Surfaces [GeometryCHLV03_V1.SurfaceStructure {Surface MULTISURFACE {surface SURFACE {boundary BOUNDARY {polyline POLYLINE {sequence SEGMENTS {segment [COORD {C1 600030.0, C2 200020.0}, COORD {C1 600045.0, C2 200040.0}, COORD {C1 600010.0, C2 200040.0}, COORD {C1 600030.0, C2 200020.0}]}}}}}}, GeometryCHLV03_V1.SurfaceStructure {Surface MULTISURFACE {surface SURFACE {boundary BOUNDARY {polyline POLYLINE {sequence SEGMENTS {segment [COORD {C1 600015.0, C2 200005.0}, COORD {C1 600040.0, C2 200010.0}, COORD {C1 600010.0, C2 200020.0}, COORD {C1 600005.0, C2 200010.0}, COORD {C1 600015.0, C2 200005.0}]}}}}}}]}", obj0.getattrobj("geom", 0).toString());
}
} finally {
if (jdbcConnection != null) {
jdbcConnection.close();
}
}
}
use of ch.interlis.iom.IomObject in project ili2db by claeis.
the class Naming1smart1Test method exportDataset.
@Test
public void exportDataset() 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/Naming1smart1/CreateTable.sql"));
DbUtility.executeSqlScript(jdbcConnection, new java.io.FileReader("test/data/Naming1smart1/InsertIntoTable.sql"));
File data = new File("test/data/Naming1smart1/Naming1a-out.xtf");
Config config = initConfig(data.getPath(), DBSCHEMA, data.getPath() + ".log");
config.setDatasetName(DATASETNAME);
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 a1 = objs.get("a1");
Assert.assertNotNull(a1);
Assert.assertEquals("Naming1.TestAttr.ClassA1", a1.getobjecttag());
Assert.assertEquals("a1 first", a1.getattrvalue("attr1"));
Assert.assertEquals("a1 second", a1.getattrvalue("Attr1"));
IomObject a2 = objs.get("a2");
Assert.assertNotNull(a2);
Assert.assertEquals("Naming1.TestAttr.ClassA1a", a2.getobjecttag());
Assert.assertEquals("a2 first", a2.getattrvalue("attr1"));
Assert.assertEquals("a2 second", a2.getattrvalue("Attr1"));
Assert.assertEquals("a2", a2.getattrvalue("attrA"));
IomObject a3 = objs.get("a3");
Assert.assertNotNull(a3);
Assert.assertEquals("Naming1.TestAttr.ClassA1b", a3.getobjecttag());
Assert.assertEquals("a3 first", a3.getattrvalue("attr1"));
Assert.assertEquals("a3 second", a3.getattrvalue("Attr1"));
Assert.assertEquals("a3", a3.getattrvalue("attrA"));
IomObject c1 = objs.get("c1");
Assert.assertNotNull(c1);
Assert.assertEquals("Naming1.TestClass.ClassA1", c1.getobjecttag());
Assert.assertEquals("attr1", c1.getattrvalue("attr1"));
IomObject c2 = objs.get("c2");
Assert.assertNotNull(c2);
Assert.assertEquals("Naming1.TestClass.Classa1", c2.getobjecttag());
Assert.assertEquals("attrA'", c2.getattrvalue("attrA"));
} finally {
if (jdbcConnection != null) {
jdbcConnection.close();
}
}
}
use of ch.interlis.iom.IomObject in project ili2db by claeis.
the class Datatypes10Test method exportItf.
@Test
public void exportItf() throws Exception {
Connection jdbcConnection = null;
try {
Class driverClass = Class.forName("org.postgresql.Driver");
jdbcConnection = DriverManager.getConnection(dburl, dbuser, dbpwd);
stmt = jdbcConnection.createStatement();
stmt.execute("DROP SCHEMA IF EXISTS " + DBSCHEMA + " CASCADE");
DbUtility.executeSqlScript(jdbcConnection, new java.io.FileReader("test/data/Datatypes10/CreateTable.sql"));
DbUtility.executeSqlScript(jdbcConnection, new java.io.FileReader("test/data/Datatypes10/InsertIntoTable.sql"));
File data = new File("test/data/Datatypes10/Datatypes10a-out.itf");
Config config = initConfig(data.getPath(), DBSCHEMA, data.getPath() + ".log");
config.setModels("Datatypes10");
config.setFunction(Config.FC_EXPORT);
Ili2db.readSettingsFromDb(config);
Ili2db.run(config, null);
// read objects of db and write objectValue to HashMap
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("10");
Assert.assertNotNull(obj0);
Assert.assertEquals("Datatypes10.Topic.OtherTable", obj0.getobjecttag());
}
{
IomObject obj1 = objs.get("11");
Assert.assertNotNull(obj1);
Assert.assertEquals("Datatypes10.Topic.OtherTable", obj1.getobjecttag());
}
} finally {
if (jdbcConnection != null) {
jdbcConnection.close();
}
}
}
use of ch.interlis.iom.IomObject in project ili2db by claeis.
the class Datatypes23Test method exportXtfLine.
@Test
public void exportXtfLine() 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(CREATETABLES_LINES));
DbUtility.executeSqlScript(jdbcConnection, new java.io.FileReader(INSERTINTOTABLES_LINES));
File data = new File(TEST_OUT + "Datatypes23Line-out.xtf");
Config config = initConfig(data.getPath(), DBSCHEMA, data.getPath() + ".log");
config.setFunction(Config.FC_EXPORT);
config.setModels(DBSCHEMA);
config.setBasketHandling(null);
Ili2db.readSettingsFromDb(config);
try {
Ili2db.run(config, null);
} catch (Exception ex) {
EhiLogger.logError(ex);
Assert.fail();
}
// tests
// read objects of db and write objectValue to HashMap
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 obj1 = objs.get("Line3.1");
Assert.assertNotNull(obj1);
Assert.assertEquals("Datatypes23.Topic.Line3", obj1.getobjecttag());
IomObject lineSegment = obj1.getattrobj("straightsarcs3d", 0);
Assert.assertEquals("POLYLINE {sequence SEGMENTS {segment [COORD {C1 2460001.0, C2 1045001.0, C3 300.0}, ARC {A1 2460005.0, A2 1045004.0, C1 2460006.0, C2 1045006.0, C3 300.0}, COORD {C1 2460010.0, C2 1045010.0, C3 300.0}]}}", lineSegment.toString());
}
} catch (SQLException e) {
throw new IoxException(e);
} finally {
if (jdbcConnection != null) {
jdbcConnection.close();
}
}
}
use of ch.interlis.iom.IomObject in project ili2db by claeis.
the class Datatypes23Test method exportXtfAttr.
@Test
public void exportXtfAttr() 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(CREATETABLES_ATTRS));
DbUtility.executeSqlScript(jdbcConnection, new java.io.FileReader(INSERTINTOTABLES_ATTRS));
File data = new File(TEST_OUT + "Datatypes23Attr-out.xtf");
Config config = initConfig(data.getPath(), DBSCHEMA, data.getPath() + ".log");
config.setFunction(Config.FC_EXPORT);
config.setModels(DBSCHEMA);
config.setBasketHandling(null);
Ili2db.readSettingsFromDb(config);
try {
Ili2db.run(config, null);
} catch (Exception ex) {
EhiLogger.logError(ex);
Assert.fail();
}
// tests
// read objects of db and write objectValue to HashMap
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 obj1 = objs.get("ClassAttr.1");
Assert.assertNotNull(obj1);
Assert.assertEquals("Datatypes23.Topic.ClassAttr", obj1.getobjecttag());
// datatypes23
Assert.assertEquals("22", obj1.getattrvalue("aI32id"));
Assert.assertEquals("true", obj1.getattrvalue("aBoolean"));
Assert.assertEquals("15b6bcce-8772-4595-bf82-f727a665fbf3", obj1.getattrvalue("aUuid"));
Assert.assertEquals("abc100", obj1.getattrvalue("textLimited"));
Assert.assertEquals("Left", obj1.getattrvalue("horizAlignment"));
Assert.assertEquals("mailto:ceis@localhost", obj1.getattrvalue("uritext"));
Assert.assertEquals("5", obj1.getattrvalue("numericInt"));
Assert.assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><x>\n" + " <a></a>\n" + " </x>", obj1.getattrvalue("xmlbox"));
Assert.assertEquals("mehr.vier", obj1.getattrvalue("aufzaehlung"));
Assert.assertEquals("09:00:00.000", obj1.getattrvalue("aTime"));
Assert.assertEquals("abc200\n" + "end200", obj1.getattrvalue("mtextLimited"));
Assert.assertEquals("AAAA", obj1.getattrvalue("binbox"));
Assert.assertEquals("chgAAAAAAAAA0azD", obj1.getattrvalue("aStandardid"));
Assert.assertEquals("Grunddatensatz.Fixpunkte.LFP.Nummer", obj1.getattrvalue("aAttribute"));
Assert.assertEquals("2002-09-24", obj1.getattrvalue("aDate"));
Assert.assertEquals("Top", obj1.getattrvalue("vertAlignment"));
Assert.assertEquals("ClassA", obj1.getattrvalue("nametext"));
Assert.assertEquals("abc101", obj1.getattrvalue("textUnlimited"));
Assert.assertEquals("6.0", obj1.getattrvalue("numericDec"));
Assert.assertEquals("abc201\n" + "end201", obj1.getattrvalue("mtextUnlimited"));
Assert.assertEquals("1900-01-01T12:30:05.000", obj1.getattrvalue("aDateTime"));
Assert.assertEquals("DM01AVCH24D.FixpunkteKategorie1.LFP1", obj1.getattrvalue("aClass"));
}
} catch (SQLException e) {
throw new IoxException(e);
} finally {
if (jdbcConnection != null) {
jdbcConnection.close();
}
}
}
Aggregations