Search in sources :

Example 61 with Config

use of ch.ehi.ili2db.gui.Config in project ili2db by claeis.

the class MetaInfo23Test method importIli.

@Test
public void importIli() throws Exception {
    // EhiLogger.getInstance().setTraceFilter(false);
    Connection jdbcConnection = null;
    try {
        setup.resetDb();
        {
            File data = new File(TEST_DATA_DIR, "MetaInfo23.ili");
            Config config = setup.initConfig(data.getPath(), data.getPath() + ".log");
            config.setFunction(Config.FC_SCHEMAIMPORT);
            config.setCreateFk(Config.CREATE_FK_YES);
            config.setTidHandling(Config.TID_HANDLING_PROPERTY);
            config.setBasketHandling(Config.BASKET_HANDLING_READWRITE);
            config.setCreateEnumDefs(Config.CREATE_ENUM_DEFS_MULTI);
            config.setCatalogueRefTrafo(null);
            config.setMultiSurfaceTrafo(null);
            config.setMultilingualTrafo(null);
            config.setInheritanceTrafo(Config.INHERITANCE_TRAFO_SMART1);
            config.setCreateMetaInfo(true);
            Ili2db.readSettingsFromDb(config);
            Ili2db.run(config, null);
            {
                jdbcConnection = setup.createConnection();
                String selStmt = "SELECT " + DbNames.META_INFO_COLUMN_TAB_SETTING_COL + ", " + DbNames.META_INFO_COLUMN_TAB_SUBTYPE_COL + " FROM " + setup.prefixName(DbNames.META_INFO_COLUMN_TAB) + " WHERE " + DbNames.META_INFO_COLUMN_TAB_TABLENAME_COL + "=? AND " + DbNames.META_INFO_COLUMN_TAB_COLUMNNAME_COL + "=? AND " + DbNames.META_INFO_COLUMN_TAB_TAG_COL + "=?";
                java.sql.PreparedStatement selPrepStmt = jdbcConnection.prepareStatement(selStmt);
                {
                    selPrepStmt.setString(1, "classa1");
                    selPrepStmt.setString(2, "numx");
                    selPrepStmt.setString(3, DbExtMetaInfo.TAG_COL_UNIT);
                    ResultSet rs = selPrepStmt.executeQuery();
                    Assert.assertTrue(rs.next());
                    Assert.assertEquals("m", rs.getString(1));
                    Assert.assertEquals("classa1b", rs.getString(2));
                    Assert.assertFalse(rs.next());
                }
                {
                    selPrepStmt.setString(1, "classa1");
                    selPrepStmt.setString(2, "numa");
                    selPrepStmt.setString(3, DbExtMetaInfo.TAG_COL_UNIT);
                    ResultSet rs = selPrepStmt.executeQuery();
                    Assert.assertTrue(rs.next());
                    Assert.assertEquals("m", rs.getString(1));
                    Assert.assertEquals(null, rs.getString(2));
                    Assert.assertFalse(rs.next());
                }
                {
                    selPrepStmt.setString(1, "classc");
                    selPrepStmt.setString(2, "geom");
                    selPrepStmt.setString(3, DbExtMetaInfo.TAG_COL_C1_MAX);
                    ResultSet rs = selPrepStmt.executeQuery();
                    Assert.assertTrue(rs.next());
                    Assert.assertEquals("2870000.000", rs.getString(1));
                    Assert.assertEquals(null, rs.getString(2));
                    Assert.assertFalse(rs.next());
                }
                {
                    // t_ili2db_attrname
                    String[][] expectedValues = new String[][] { { "MetaInfo23.TestA.ClassA.num0", "num0", "classa1", null }, { "MetaInfo23.TestA.a2b.a", "a", "a2b", "classa1" }, { "MetaInfo23.TestA.a2b.b", "b", "a2b", "classb1" }, { "MetaInfo23.TestA.ClassA1.enumb", "enumb", "classa1", null }, { "MetaInfo23.TestA.ClassA1.enuma", "enuma", "classa1", null }, { "MetaInfo23.TestA.ClassA1.mtextb", "mtextb", "classa1", null }, { "MetaInfo23.TestA.ClassA1.mtexta", "mtexta", "classa1", null }, { "MetaInfo23.TestA.ClassA1.texta", "texta", "classa1", null }, { "MetaInfo23.TestA.ClassA1b.numx", "numx", "classa1", null }, { "MetaInfo23.TestA.ClassA1.numa", "numa", "classa1", null }, { "MetaInfo23.TestA.ClassA1.textb", "textb", "classa1", null }, { "MetaInfo23.TestA.ClassA1.numb", "numb", "classa1", null }, { "MetaInfo23.TestA.ClassA1.structa", "classa1_structa", "structa1", "classa1" }, { "MetaInfo23.TestA.ClassC.geom", "geom", "classc", null } };
                    Ili2dbAssert.assertAttrNameTable(jdbcConnection, expectedValues, setup.getSchema());
                }
                {
                    // t_ili2db_trafo
                    String[][] expectedValues = new String[][] { { "MetaInfo23.TestA.Codelist", "ch.ehi.ili2db.inheritance", "newClass" }, { "MetaInfo23.TestA.ClassA1b", "ch.ehi.ili2db.inheritance", "superClass" }, { "MetaInfo23.TestA.ClassA", "ch.ehi.ili2db.inheritance", "subClass" }, { "MetaInfo23.TestA.a2b", "ch.ehi.ili2db.inheritance", "newClass" }, { "CatalogueObjects_V1.Catalogues.Item", "ch.ehi.ili2db.inheritance", "subClass" }, { "MetaInfo23.TestA.StructA1", "ch.ehi.ili2db.inheritance", "newClass" }, { "MetaInfo23.TestA.ClassB1", "ch.ehi.ili2db.inheritance", "newClass" }, { "MetaInfo23.TestA.ClassA1", "ch.ehi.ili2db.inheritance", "newClass" }, { "MetaInfo23.TestA.ClassC", "ch.ehi.ili2db.inheritance", "newClass" } };
                    Ili2dbAssert.assertTrafoTable(jdbcConnection, expectedValues, setup.getSchema());
                }
            }
        }
    } finally {
        if (jdbcConnection != null) {
            jdbcConnection.close();
        }
    }
}
Also used : Config(ch.ehi.ili2db.gui.Config) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) File(java.io.File) Test(org.junit.Test)

Example 62 with Config

use of ch.ehi.ili2db.gui.Config in project ili2db by claeis.

the class MultiCoord24Test method exportXtf.

@Test
public void exportXtf() throws Exception {
    importXtf();
    // export xtf
    File data = new File(TEST_OUT, "MultiCoord24-out.xtf");
    Config config = setup.initConfig(data.getPath(), data.getPath() + ".log");
    config.setFunction(Config.FC_EXPORT);
    config.setModels("MultiCoord24");
    Ili2db.readSettingsFromDb(config);
    Ili2db.run(config, null);
    // compile model
    Configuration ili2cConfig = new Configuration();
    FileEntry fileEntry = new FileEntry(TEST_OUT + "/MultiCoord24.ili", FileEntryKind.ILIMODELFILE);
    ili2cConfig.addFileEntry(fileEntry);
    TransferDescription td = ch.interlis.ili2c.Ili2c.runCompiler(ili2cConfig);
    assertNotNull(td);
    // assert xtf
    Xtf24Reader reader = new Xtf24Reader(data);
    reader.setModel(td);
    assertTrue(reader.read() instanceof StartTransferEvent);
    assertTrue(reader.read() instanceof StartBasketEvent);
    IoxEvent event = reader.read();
    assertTrue(event instanceof ObjectEvent);
    IomObject iomObj = ((ObjectEvent) event).getIomObject();
    assertEquals(1, iomObj.getattrcount());
    assertEquals("MultiCoord24.TestA.ClassA1", iomObj.getobjecttag());
    assertEquals(1, iomObj.getattrcount());
    assertEquals(1, iomObj.getattrvaluecount("geomAttr1"));
    IomObject multiCoordAttr = iomObj.getattrobj("geomAttr1", 0);
    assertNotNull(multiCoordAttr);
    IomObject coord1 = multiCoordAttr.getattrobj("coord", 0);
    assertNotNull(coord1);
    assertEquals("2530001.0", coord1.getattrvalue("C1"));
    assertEquals("1150002.0", coord1.getattrvalue("C2"));
    assertNull(coord1.getattrvalue("C3"));
    IomObject coord2 = multiCoordAttr.getattrobj("coord", 1);
    assertNotNull(coord2);
    assertEquals("2740003.0", coord2.getattrvalue("C1"));
    assertEquals("1260004.0", coord2.getattrvalue("C2"));
    assertNull(coord2.getattrvalue("C3"));
    assertTrue(reader.read() instanceof EndBasketEvent);
    assertTrue(reader.read() instanceof EndTransferEvent);
}
Also used : Configuration(ch.interlis.ili2c.config.Configuration) Config(ch.ehi.ili2db.gui.Config) IomObject(ch.interlis.iom.IomObject) TransferDescription(ch.interlis.ili2c.metamodel.TransferDescription) FileEntry(ch.interlis.ili2c.config.FileEntry) File(java.io.File) Xtf24Reader(ch.interlis.iom_j.xtf.Xtf24Reader) Test(org.junit.Test)

Example 63 with Config

use of ch.ehi.ili2db.gui.Config in project ili2db by claeis.

the class MultiCoord24Test method importXtf.

@Test
public void importXtf() throws Exception {
    setup.resetDb();
    File data = new File(TEST_OUT, "MultiCoord24.xtf");
    Config config = setup.initConfig(data.getPath(), data.getPath() + ".log");
    config.setFunction(Config.FC_IMPORT);
    config.setDoImplicitSchemaImport(true);
    config.setCreateFk(Config.CREATE_FK_YES);
    config.setCreateNumChecks(true);
    config.setTidHandling(Config.TID_HANDLING_PROPERTY);
    config.setImportTid(true);
    config.setBasketHandling(Config.BASKET_HANDLING_READWRITE);
    config.setCatalogueRefTrafo(null);
    config.setMultiSurfaceTrafo(null);
    config.setMultilingualTrafo(null);
    config.setInheritanceTrafo(null);
    config.setDefaultSrsCode("2056");
    setup.setXYParams(config);
    Ili2db.run(config, null);
    Connection jdbcConnection = null;
    Statement stmt = null;
    try {
        jdbcConnection = setup.createConnection();
        stmt = jdbcConnection.createStatement();
        assertMultiChoord24_classa1_geomattr1(stmt);
    } finally {
        if (stmt != null) {
            stmt.close();
        }
        if (jdbcConnection != null) {
            jdbcConnection.close();
        }
    }
}
Also used : Config(ch.ehi.ili2db.gui.Config) Statement(java.sql.Statement) Connection(java.sql.Connection) File(java.io.File) Test(org.junit.Test)

Example 64 with Config

use of ch.ehi.ili2db.gui.Config in project ili2db by claeis.

the class MultiCoord24Test method importIli.

@Test
public void importIli() throws SQLException, Ili2dbException {
    setup.resetDb();
    File data = new File(TEST_OUT, "MultiCoord24.ili");
    Config config = setup.initConfig(data.getPath(), data.getPath() + ".log");
    config.setFunction(Config.FC_SCHEMAIMPORT);
    config.setCreateFk(Config.CREATE_FK_YES);
    config.setCreateTextChecks(true);
    config.setCreateNumChecks(true);
    config.setCreateDateTimeChecks(true);
    config.setTidHandling(Config.TID_HANDLING_PROPERTY);
    config.setBasketHandling(Config.BASKET_HANDLING_READWRITE);
    config.setCatalogueRefTrafo(null);
    config.setMultiSurfaceTrafo(null);
    config.setMultilingualTrafo(null);
    config.setInheritanceTrafo(null);
    Ili2db.run(config, null);
    Connection jdbcConnection = null;
    Statement stmt = null;
    try {
        jdbcConnection = setup.createConnection();
        stmt = jdbcConnection.createStatement();
        {
            // t_ili2db_attrname
            String[][] expectedValues = new String[][] { { "MultiCoord24.TestA.ClassA1.geomAttr1", "geomattr1", "classa1", null } };
            Ili2dbAssert.assertAttrNameTable(jdbcConnection, expectedValues, setup.getSchema());
        }
        {
            // t_ili2db_trafo
            String[][] expectedValues = new String[][] { { "MultiCoord24.TestA.ClassA1", "ch.ehi.ili2db.inheritance", "newClass" } };
            Ili2dbAssert.assertTrafoTable(jdbcConnection, expectedValues, setup.getSchema());
        }
    } finally {
        if (stmt != null) {
            stmt.close();
        }
        if (jdbcConnection != null) {
            jdbcConnection.close();
        }
    }
}
Also used : Config(ch.ehi.ili2db.gui.Config) Statement(java.sql.Statement) Connection(java.sql.Connection) File(java.io.File) Test(org.junit.Test)

Example 65 with Config

use of ch.ehi.ili2db.gui.Config in project ili2db by claeis.

the class MultiPolyline24Test method importXtf.

@Test
public void importXtf() throws Exception {
    setup.resetDb();
    File data = new File(TEST_OUT, "MultiPolyline24.xtf");
    Config config = setup.initConfig(data.getPath(), data.getPath() + ".log");
    config.setFunction(Config.FC_IMPORT);
    config.setDoImplicitSchemaImport(true);
    config.setCreateFk(Config.CREATE_FK_YES);
    config.setCreateNumChecks(true);
    config.setTidHandling(Config.TID_HANDLING_PROPERTY);
    config.setImportTid(true);
    config.setBasketHandling(Config.BASKET_HANDLING_READWRITE);
    config.setCatalogueRefTrafo(null);
    config.setMultiSurfaceTrafo(null);
    config.setMultilingualTrafo(null);
    config.setInheritanceTrafo(null);
    config.setDefaultSrsCode("2056");
    setup.setXYParams(config);
    Ili2db.run(config, null);
    Connection jdbcConnection = null;
    Statement stmt = null;
    try {
        jdbcConnection = setup.createConnection();
        stmt = jdbcConnection.createStatement();
        assertMultiPolyline24_classa1_geomattr1(stmt);
    } finally {
        if (stmt != null) {
            stmt.close();
        }
        if (jdbcConnection != null) {
            jdbcConnection.close();
        }
    }
}
Also used : Config(ch.ehi.ili2db.gui.Config) Statement(java.sql.Statement) Connection(java.sql.Connection) File(java.io.File) Test(org.junit.Test)

Aggregations

Config (ch.ehi.ili2db.gui.Config)555 File (java.io.File)475 Test (org.junit.Test)469 Connection (java.sql.Connection)364 ResultSet (java.sql.ResultSet)173 Statement (java.sql.Statement)171 HashMap (java.util.HashMap)134 IomObject (ch.interlis.iom.IomObject)133 IoxEvent (ch.interlis.iox.IoxEvent)131 StartBasketEvent (ch.interlis.iox.StartBasketEvent)131 StartTransferEvent (ch.interlis.iox.StartTransferEvent)130 EndTransferEvent (ch.interlis.iox.EndTransferEvent)129 ObjectEvent (ch.interlis.iox.ObjectEvent)129 EndBasketEvent (ch.interlis.iox.EndBasketEvent)128 XtfReader (ch.interlis.iom_j.xtf.XtfReader)118 Ili2dbException (ch.ehi.ili2db.base.Ili2dbException)54 IoxException (ch.interlis.iox.IoxException)44 FgdbDriver (ch.ehi.ili2fgdb.jdbc.FgdbDriver)35 SQLException (java.sql.SQLException)29 ResultSetMetaData (java.sql.ResultSetMetaData)23