Search in sources :

Example 46 with Config

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

the class Assoc23Test method importXtfExtRefBackward.

@Test
public void importXtfExtRefBackward() throws Exception {
    // EhiLogger.getInstance().setTraceFilter(false);
    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");
        {
            {
                File data = new File("test/data/Assoc23/Assoc2a.xtf");
                Config config = initConfig(data.getPath(), DBSCHEMA, data.getPath() + ".log");
                config.setFunction(Config.FC_IMPORT);
                config.setCreateFk(config.CREATE_FK_YES);
                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.readSettingsFromDb(config);
                Ili2db.run(config, null);
            }
        }
    } finally {
        if (jdbcConnection != null) {
            jdbcConnection.close();
        }
    }
}
Also used : Config(ch.ehi.ili2db.gui.Config) Connection(java.sql.Connection) File(java.io.File) Test(org.junit.Test)

Example 47 with Config

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

the class Assoc23Test method importXtfExtFileRefBackward.

@Test
public void importXtfExtFileRefBackward() throws Exception {
    // EhiLogger.getInstance().setTraceFilter(false);
    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");
        {
            {
                File data = new File("test/data/Assoc23/Assoc2b1.xtf");
                Config config = initConfig(data.getPath(), DBSCHEMA, data.getPath() + ".log");
                config.setFunction(Config.FC_IMPORT);
                config.setCreateFk(config.CREATE_FK_YES);
                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.readSettingsFromDb(config);
                Ili2db.run(config, null);
            }
            {
                File data = new File("test/data/Assoc23/Assoc2b2.xtf");
                Config config = initConfig(data.getPath(), DBSCHEMA, data.getPath() + ".log");
                config.setFunction(Config.FC_IMPORT);
                config.setCreateFk(config.CREATE_FK_YES);
                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.readSettingsFromDb(config);
                Ili2db.run(config, null);
            }
        }
    } finally {
        if (jdbcConnection != null) {
            jdbcConnection.close();
        }
    }
}
Also used : Config(ch.ehi.ili2db.gui.Config) Connection(java.sql.Connection) File(java.io.File) Test(org.junit.Test)

Example 48 with Config

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

the class GenericDbPanelDescriptor method aboutToDisplayPanel.

public void aboutToDisplayPanel() {
    super.aboutToDisplayPanel();
    Config config = ((Ili2dbWizard) getWizard()).getIli2dbConfig();
    GenericDbPanel panel = (GenericDbPanel) getPanelComponent();
    panel.setDburl(config.getDburl());
    panel.setDbusr(config.getDbusr());
    panel.setDbpwd(config.getDbpwd());
}
Also used : Config(ch.ehi.ili2db.gui.Config) Ili2dbWizard(ch.ehi.ili2db.gui.Ili2dbWizard)

Example 49 with Config

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

the class Json23Test method importIli.

@Test
public void importIli() throws Exception {
    Class driverClass = Class.forName("org.postgresql.Driver");
    Connection jdbcConnection = null;
    try {
        setup.resetDb();
        jdbcConnection = setup.createConnection();
        File data = new File(TEST_OUT, "Json23.ili");
        Config config = setup.initConfig(data.getPath(), data.getPath() + ".log");
        config.setFunction(Config.FC_SCHEMAIMPORT);
        config.setCreateFk(Config.CREATE_FK_YES);
        config.setCreateNumChecks(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);
        config.setJsonTrafo(Config.JSON_TRAFO_COALESCE);
        Ili2db.run(config, null);
        // asserts
        {
            {
                // t_ili2db_attrname
                String[][] expectedValues = new String[][] { { "Json23.TestA.Farbe.r", "r", "farbe", null }, { "Json23.TestA.Auto.Farben", "farben", "auto", null }, { "Json23.TestA.Farbe.active", "aactive", "farbe", null }, { "Json23.TestA.Farbe.g", "g", "farbe", null }, { "Json23.TestA.Farbe.name", "aname", "farbe", null }, { "Json23.TestA.Farbe.b", "b", "farbe", null } };
                Ili2dbAssert.assertAttrNameTable(jdbcConnection, expectedValues, setup.getSchema());
            }
            {
                // t_ili2db_trafo
                String[][] expectedValues = new String[][] { { "Json23.TestA.Farbe", "ch.ehi.ili2db.inheritance", "newClass" }, { "Json23.TestA.Auto.Farben", "ch.ehi.ili2db.jsonTrafo", "coalesce" }, { "Json23.TestA.Auto", "ch.ehi.ili2db.inheritance", "newClass" } };
                Ili2dbAssert.assertTrafoTable(jdbcConnection, expectedValues, setup.getSchema());
            }
        }
    } finally {
        if (jdbcConnection != null) {
            jdbcConnection.close();
            jdbcConnection = null;
        }
    }
}
Also used : Config(ch.ehi.ili2db.gui.Config) Connection(java.sql.Connection) File(java.io.File) Test(org.junit.Test)

Example 50 with Config

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

the class Json23Test method importXtf.

@Test
public void importXtf() throws Exception {
    // EhiLogger.getInstance().setTraceFilter(false);
    Class driverClass = Class.forName("org.postgresql.Driver");
    setup.resetDb();
    File data = new File(TEST_OUT, "Json23a.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.setImportBid(true);
    config.setBasketHandling(Config.BASKET_HANDLING_READWRITE);
    config.setCatalogueRefTrafo(null);
    config.setMultiSurfaceTrafo(null);
    config.setMultilingualTrafo(null);
    config.setInheritanceTrafo(null);
    config.setJsonTrafo(Config.JSON_TRAFO_COALESCE);
    try {
        Ili2db.run(config, null);
    } catch (Exception ex) {
        EhiLogger.logError(ex);
        Assert.fail();
    }
    {
        Connection jdbcConnection = null;
        try {
            jdbcConnection = setup.createConnection();
            java.sql.Statement stmt = jdbcConnection.createStatement();
            importXtf_doAsserts(stmt);
        } finally {
            if (jdbcConnection != null) {
                jdbcConnection.close();
                jdbcConnection = null;
            }
        }
    }
}
Also used : Config(ch.ehi.ili2db.gui.Config) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) Connection(java.sql.Connection) File(java.io.File) SQLException(java.sql.SQLException) IoxException(ch.interlis.iox.IoxException) Ili2dbException(ch.ehi.ili2db.base.Ili2dbException) 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