Search in sources :

Example 11 with Config

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

the class CreateFK23GpkgTest method initConfig.

public Config initConfig(String xtfFilename, String logfile) {
    Config config = new Config();
    new ch.ehi.ili2gpkg.GpkgMain().initConfig(config);
    config.setDbfile(gpkgFileName);
    config.setDburl("jdbc:sqlite:" + gpkgFileName);
    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 12 with Config

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

the class Datatypes10GpkgTest method importIli.

@Test
public void importIli() throws Exception {
    File gpkgFile = new File(gpkgFileName);
    if (gpkgFile.exists()) {
        gpkgFile.delete();
    }
    File data = new File("test/data/Datatypes10/Datatypes10.ili");
    Config config = 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);
    Ili2db.readSettingsFromDb(config);
    Ili2db.run(config, null);
}
Also used : Config(ch.ehi.ili2db.gui.Config) File(java.io.File) Test(org.junit.Test)

Example 13 with Config

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

the class Datatypes10GpkgTest method exportItfWithSkipPolygonBuilding.

// @Test
public void exportItfWithSkipPolygonBuilding() throws Ili2dbException {
    File data = new File("test/data/Datatypes10/Datatypes10a-ltout.itf");
    Config config = initConfig(data.getPath(), data.getPath() + ".log");
    config.setModels("Datatypes10");
    config.setFunction(Config.FC_EXPORT);
    Ili2db.readSettingsFromDb(config);
    Ili2db.run(config, null);
}
Also used : Config(ch.ehi.ili2db.gui.Config) File(java.io.File)

Example 14 with Config

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

the class Datatypes10GpkgTest method importItfWithSkipPolygonBuilding.

@Test
public void importItfWithSkipPolygonBuilding() throws Exception {
    File gpkgFile = new File(gpkgFileName);
    if (gpkgFile.exists()) {
        gpkgFile.delete();
    }
    File data = new File("test/data/Datatypes10/Datatypes10a.itf");
    Config config = initConfig(data.getPath(), 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.setDoItfLineTables(true);
    config.setCatalogueRefTrafo(null);
    config.setMultiSurfaceTrafo(null);
    config.setMultilingualTrafo(null);
    config.setInheritanceTrafo(null);
    Ili2db.readSettingsFromDb(config);
    Ili2db.run(config, null);
    initDb();
    String stmtTxt = "SELECT atext FROM tablea AS a INNER JOIN subtable AS b ON (a.t_id=b.main)  WHERE b.t_ili_tid='30'";
    Assert.assertTrue(stmt.execute(stmtTxt));
    {
        ResultSet rs = stmt.getResultSet();
        Assert.assertTrue(rs.next());
        Assert.assertEquals("obj11", rs.getObject(1));
    }
    exportItfWithSkipPolygonBuilding();
}
Also used : Config(ch.ehi.ili2db.gui.Config) ResultSet(java.sql.ResultSet) File(java.io.File) Test(org.junit.Test)

Example 15 with Config

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

the class MdbDbPanel method getTestConnectionButton.

/**
 * This method initializes testConnectionButton
 *
 * @return javax.swing.JButton
 */
private JButton getTestConnectionButton() {
    if (testConnectionButton == null) {
        testConnectionButton = new JButton();
        testConnectionButton.setText("test connection");
        testConnectionButton.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent e) {
                getLogUi().setText("");
                ch.ehi.ili2db.gui.Config config = new ch.ehi.ili2db.gui.Config();
                config.setDbfile(getDbfile());
                String dbusr = getDbusr();
                String dbpwd = getDbpwd();
                String dburl = dbUrlConverter.makeUrl(config);
                try {
                    Class.forName(jdbcDriver);
                } catch (Exception ex) {
                    EhiLogger.logError("failed to load JDBC driver", ex);
                    return;
                }
                Connection conn = null;
                try {
                    conn = DriverManager.getConnection(dburl, dbusr, dbpwd);
                } catch (Exception ex) {
                    EhiLogger.logError(ex);
                    return;
                } finally {
                    if (conn != null) {
                        try {
                            conn.close();
                        } catch (SQLException ex) {
                            EhiLogger.logError(ex);
                        }
                    }
                }
                JOptionPane.showMessageDialog(null, "Successfully connected", "test connection", JOptionPane.INFORMATION_MESSAGE);
            }
        });
    }
    return testConnectionButton;
}
Also used : SQLException(java.sql.SQLException) Config(ch.ehi.ili2db.gui.Config) JButton(javax.swing.JButton) Connection(java.sql.Connection) SQLException(java.sql.SQLException) Config(ch.ehi.ili2db.gui.Config)

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