Search in sources :

Example 36 with Config

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

the class MultilineTest method initConfig.

public Config initConfig(String xtfFilename, String logfile) {
    Config config = new Config();
    new ch.ehi.ili2fgdb.FgdbMain().initConfig(config);
    config.setDbfile(fgdbFileName);
    config.setDburl(FgdbDriver.BASE_URL + fgdbFileName);
    if (logfile != null) {
        config.setLogfile(logfile);
    }
    config.setXtffile(xtfFilename);
    if (xtfFilename != null && Ili2db.isItfFilename(xtfFilename)) {
        config.setItfTransferfile(true);
    }
    return config;
}
Also used : Config(ch.ehi.ili2db.gui.Config)

Example 37 with Config

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

the class FilterImportTest method initConfig.

public Config initConfig(String xtfFilename, String dbschema, String logfile) {
    Config config = new Config();
    new ch.ehi.ili2pg.PgMain().initConfig(config);
    config.setDburl(dburl);
    config.setDbusr(dbuser);
    config.setDbpwd(dbpwd);
    if (dbschema != null) {
        config.setDbschema(dbschema);
    }
    if (logfile != null) {
        config.setLogfile(logfile);
    }
    config.setXtffile(xtfFilename);
    if (xtfFilename != null && Ili2db.isItfFilename(xtfFilename)) {
        config.setItfTransferfile(true);
    }
    return config;
}
Also used : Config(ch.ehi.ili2db.gui.Config)

Example 38 with Config

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

the class FilterImportTest method importByTopic.

@Test
public void importByTopic() 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");
        {
            File data = new File("test/data/FilterImport/FilterImport1a.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);
            config.setTopics("FilterImport.TestA");
            Ili2db.readSettingsFromDb(config);
            Ili2db.run(config, null);
            // check that the classa1 objects from both baskets were imported
            {
                String stmtTxt = "SELECT count(*) FROM " + DBSCHEMA + ".classa1";
                Assert.assertTrue(stmt.execute(stmtTxt));
                ResultSet rs = stmt.getResultSet();
                Assert.assertTrue(rs.next());
                Assert.assertEquals(2, rs.getInt(1));
            }
            // check that no classb1 object was imported
            {
                String stmtTxt = "SELECT count(*) FROM " + DBSCHEMA + ".classb1";
                Assert.assertTrue(stmt.execute(stmtTxt));
                ResultSet rs = stmt.getResultSet();
                Assert.assertTrue(rs.next());
                Assert.assertEquals(0, rs.getInt(1));
            }
        }
    } 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 39 with Config

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

the class GeomIndex10Test method initConfig.

public Config initConfig(String xtfFilename, String dbschema, String logfile) {
    Config config = new Config();
    new ch.ehi.ili2pg.PgMain().initConfig(config);
    config.setDburl(dburl);
    config.setDbusr(dbuser);
    config.setDbpwd(dbpwd);
    if (dbschema != null) {
        config.setDbschema(dbschema);
    }
    if (logfile != null) {
        config.setLogfile(logfile);
    }
    config.setXtffile(xtfFilename);
    if (xtfFilename != null && Ili2db.isItfFilename(xtfFilename)) {
        config.setItfTransferfile(true);
    }
    return config;
}
Also used : Config(ch.ehi.ili2db.gui.Config)

Example 40 with Config

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

the class InheritanceNoSmartTest method importNoSmart.

@Test
public void importNoSmart() throws Exception {
    Connection jdbcConnection = null;
    try {
        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");
        {
            File data = new File("test/data/InheritanceNoSmart/Inheritance1a.xtf");
            Config config = initConfig(data.getPath(), DBSCHEMA, data.getPath() + ".log");
            config.setFunction(Config.FC_IMPORT);
            config.setCreateFk(Config.CREATE_FK_YES);
            config.setInheritanceTrafo(null);
            config.setDatasetName(DATASETNAME);
            config.setTidHandling(Config.TID_HANDLING_PROPERTY);
            config.setBasketHandling(Config.BASKET_HANDLING_READWRITE);
            Ili2db.readSettingsFromDb(config);
            Ili2db.run(config, null);
            Assert.assertTrue(stmt.execute("SELECT classa3.attra3,a3b.attra3b FROM " + DBSCHEMA + ".classa3," + DBSCHEMA + ".classa3b a3b WHERE classa3.t_ili_tid='7'"));
            {
                ResultSet rs = stmt.getResultSet();
                Assert.assertTrue(rs.next());
                Assert.assertEquals("a3", rs.getString(1));
                Assert.assertEquals("a3b", rs.getString(2));
            }
        }
    } finally {
        if (jdbcConnection != null) {
            jdbcConnection.close();
        }
    }
}
Also used : Statement(java.sql.Statement) Config(ch.ehi.ili2db.gui.Config) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) File(java.io.File) Test(org.junit.Test)

Aggregations

Config (ch.ehi.ili2db.gui.Config)207 File (java.io.File)162 Test (org.junit.Test)154 Connection (java.sql.Connection)118 ResultSet (java.sql.ResultSet)72 Statement (java.sql.Statement)44 HashMap (java.util.HashMap)40 IomObject (ch.interlis.iom.IomObject)34 EndBasketEvent (ch.interlis.iox.EndBasketEvent)34 EndTransferEvent (ch.interlis.iox.EndTransferEvent)34 IoxEvent (ch.interlis.iox.IoxEvent)34 ObjectEvent (ch.interlis.iox.ObjectEvent)34 StartBasketEvent (ch.interlis.iox.StartBasketEvent)34 StartTransferEvent (ch.interlis.iox.StartTransferEvent)34 FgdbDriver (ch.ehi.ili2fgdb.jdbc.FgdbDriver)33 Ili2dbException (ch.ehi.ili2db.base.Ili2dbException)32 XtfReader (ch.interlis.iom_j.xtf.XtfReader)30 IoxException (ch.interlis.iox.IoxException)15 SQLException (java.sql.SQLException)12 ResultSetMetaData (java.sql.ResultSetMetaData)10