view flys-aft/src/main/java/de/intevation/aft/Sync.java @ 4075:dbd0b3b1b8b8

Sync each river. flys-aft/trunk@3419 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 14 Dec 2011 17:53:15 +0000
parents 2c70fae83d0c
children 97de7a552b79
line wrap: on
line source
package de.intevation.aft;

import java.io.File;

import java.sql.SQLException;

import org.w3c.dom.Document;

import de.intevation.utils.XML;

import de.intevation.db.ConnectionBuilder;
import de.intevation.db.ConnectedStatements;

public class Sync
{
    public static final String FLYS = "flys";
    public static final String AFT  = "aft";

    public static final String CONFIG_FILE =
        System.getProperty("config.file", "config.xml");

    public static void main(String [] args) {

        File configFile = new File(CONFIG_FILE);

        if (!configFile.isFile() || !configFile.canRead()) {
            System.err.println("cannot read config file");
            System.exit(1);
        }

        Document config = XML.parseDocument(configFile, Boolean.FALSE);

        if (config == null) {
            System.err.println("cannot load config");
            System.exit(1);
        }

        ConnectionBuilder aftConnectionBuilder =
            new ConnectionBuilder(AFT, config);

        ConnectionBuilder flysConnectionBuilder =
            new ConnectionBuilder(FLYS, config);

        ConnectedStatements aftStatements  = null;
        ConnectedStatements flysStatements = null;
        try {
            aftStatements  = aftConnectionBuilder.getConnectedStatements();
            flysStatements = flysConnectionBuilder.getConnectedStatements();
            Rivers rivers = new Rivers();
            rivers.sync(aftStatements, flysStatements);
        }
        catch (SQLException sqle) {
            sqle.printStackTrace();
            System.err.println("syncing failed: " + sqle.getMessage());
        }
        finally {
            if (aftStatements != null) {
                aftStatements.close();
            }
            if (flysStatements != null) {
                flysStatements.close();
            }
        }
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org