Search in sources :

Example 26 with Config

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

the class SimpleFgdbTest method importXtfStruct.

@Test
public void importXtfStruct() throws Exception {
    EhiLogger.getInstance().setTraceFilter(false);
    File fgdbFile = new File(fgdbFileName);
    Fgdb4j.deleteFileGdb(fgdbFile);
    Class driverClass = Class.forName(FgdbDriver.class.getName());
    File data = new File("test/data/Simple/SimpleStruct23a.xtf");
    Config config = initConfig(data.getPath(), data.getPath() + ".log");
    config.setFunction(Config.FC_IMPORT);
    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);
    try {
        Ili2db.run(config, null);
    } catch (Exception ex) {
        EhiLogger.logError(ex);
        Assert.fail();
    }
}
Also used : FgdbDriver(ch.ehi.ili2fgdb.jdbc.FgdbDriver) Config(ch.ehi.ili2db.gui.Config) File(java.io.File) Ili2dbException(ch.ehi.ili2db.base.Ili2dbException) Test(org.junit.Test)

Example 27 with Config

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

the class GeodbDbPanel 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)

Example 28 with Config

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

the class Dataset23Smart1Test method initConfig.

public Config initConfig(String xtfFilename, String dbschema, 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 29 with Config

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

the class Dataset23Smart1Test method importNoDatasetName.

@Test
public void importNoDatasetName() throws Exception {
    EhiLogger.getInstance().setTraceFilter(false);
    Connection jdbcConnection = null;
    try {
        File fgdbFile = new File(fgdbFileName);
        Fgdb4j.deleteFileGdb(fgdbFile);
        Class driverClass = Class.forName(FgdbDriver.class.getName());
        jdbcConnection = DriverManager.getConnection(FgdbDriver.BASE_URL + fgdbFileName, null, null);
        Statement stmt = jdbcConnection.createStatement();
        {
            {
                File data = new File("test/data/Dataset23Smart1/Dataset1a1.xtf");
                Config config = initConfig(data.getPath(), null, data.getPath() + ".log");
                config.setDatasetName(null);
                config.setFunction(Config.FC_IMPORT);
                config.setCreateFk(config.CREATE_FK_YES);
                config.setBasketHandling(config.BASKET_HANDLING_READWRITE);
                config.setBasketHandling(null);
                config.setCatalogueRefTrafo(null);
                config.setMultiSurfaceTrafo(null);
                config.setMultilingualTrafo(null);
                config.setInheritanceTrafo(config.INHERITANCE_TRAFO_SMART1);
                Ili2db.readSettingsFromDb(config);
                Ili2db.run(config, null);
            }
            {
                File data = new File("test/data/Dataset23Smart1/Dataset1a1.xtf");
                Config config = initConfig(data.getPath(), null, data.getPath() + ".log");
                config.setDatasetName(null);
                config.setFunction(Config.FC_IMPORT);
                Ili2db.readSettingsFromDb(config);
                Ili2db.run(config, null);
            }
        }
    } finally {
        if (jdbcConnection != null) {
            jdbcConnection.close();
        }
    }
}
Also used : FgdbDriver(ch.ehi.ili2fgdb.jdbc.FgdbDriver) Statement(java.sql.Statement) Config(ch.ehi.ili2db.gui.Config) Connection(java.sql.Connection) File(java.io.File) Test(org.junit.Test)

Example 30 with Config

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

the class Datatypes23Test 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)

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