Search in sources :

Example 1 with ItfWriter2

use of ch.interlis.iom_j.itf.ItfWriter2 in project ili2db by claeis.

the class Ili2db method transferToXtf.

/**
 * transfer data from database to xml file
 */
private static void transferToXtf(Connection conn, String xtffile, NameMapping ili2sqlName, TransferDescription td, SqlColumnConverter geomConv, String sender, Config config, String[] exportParamModelnames, long[] basketSqlIds, Map<Long, BasketStat> stat, TrafoConfig trafoConfig, Viewable2TableMapping class2wrapper) {
    java.io.File outfile = new java.io.File(xtffile);
    IoxWriter ioxWriter = null;
    try {
        if (Config.ILIGML20.equals(config.getTransferFileFormat())) {
            ioxWriter = new Iligml20Writer(outfile, td);
        } else {
            String ext = ch.ehi.basics.view.GenericFileFilter.getFileExtension(xtffile).toLowerCase();
            if (config.isItfTransferfile()) {
                if (!config.getDoItfLineTables()) {
                    ioxWriter = new ItfWriter2(outfile, td);
                } else {
                    ioxWriter = new ItfWriter(outfile, td);
                }
                config.setValue(ch.interlis.iox_j.validator.Validator.CONFIG_DO_ITF_OIDPERTABLE, ch.interlis.iox_j.validator.Validator.CONFIG_DO_ITF_OIDPERTABLE_DO);
            } else if (ext != null && ext.equals("gml")) {
                ioxWriter = new Iligml10Writer(outfile, td);
            } else {
                ioxWriter = new XtfWriter(outfile, td);
            }
        }
        TransferToXtf trsfr = new TransferToXtf(ili2sqlName, td, conn, geomConv, config, trafoConfig, class2wrapper);
        trsfr.doit(outfile.getName(), ioxWriter, sender, exportParamModelnames, basketSqlIds, stat);
        // trsfr.doitJava();
        ioxWriter.flush();
    } catch (ch.interlis.iox.IoxException ex) {
        EhiLogger.logError("failed to write xml output", ex);
    } finally {
        if (ioxWriter != null) {
            try {
                ioxWriter.close();
            } catch (ch.interlis.iox.IoxException ex) {
                EhiLogger.logError("failed to close xml output", ex);
            }
        }
        ioxWriter = null;
    }
}
Also used : XtfWriter(ch.interlis.iom_j.xtf.XtfWriter) ItfWriter2(ch.interlis.iom_j.itf.ItfWriter2) Iligml20Writer(ch.interlis.iom_j.iligml.Iligml20Writer) Iligml10Writer(ch.interlis.iom_j.iligml.Iligml10Writer) IoxException(ch.interlis.iox.IoxException) TransferToXtf(ch.ehi.ili2db.toxtf.TransferToXtf) IoxWriter(ch.interlis.iox.IoxWriter) ItfWriter(ch.interlis.iom_j.itf.ItfWriter)

Aggregations

TransferToXtf (ch.ehi.ili2db.toxtf.TransferToXtf)1 Iligml10Writer (ch.interlis.iom_j.iligml.Iligml10Writer)1 Iligml20Writer (ch.interlis.iom_j.iligml.Iligml20Writer)1 ItfWriter (ch.interlis.iom_j.itf.ItfWriter)1 ItfWriter2 (ch.interlis.iom_j.itf.ItfWriter2)1 XtfWriter (ch.interlis.iom_j.xtf.XtfWriter)1 IoxException (ch.interlis.iox.IoxException)1 IoxWriter (ch.interlis.iox.IoxWriter)1