Mercurial > dive4elements > river
view flys-aft/src/main/java/de/intevation/aft/Sync.java @ 4077:97de7a552b79
Load DIPS XML
flys-aft/trunk@3452 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 16 Dec 2011 16:21:59 +0000 |
parents | dbd0b3b1b8b8 |
children | 44dc38ca8492 |
line wrap: on
line source
package de.intevation.aft; import java.io.File; import java.sql.SQLException; import org.w3c.dom.Document; import javax.xml.xpath.XPathConstants; import de.intevation.utils.XML; import de.intevation.db.ConnectionBuilder; public class Sync { public static final String FLYS = "flys"; public static final String AFT = "aft"; public static final String XPATH_DIPS = "/sync/dips/@file"; 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); } String dipsF = (String)XML.xpath( config, XPATH_DIPS, XPathConstants.STRING, null, null); if (dipsF == null || dipsF.length() == 0) { System.err.println("Cannot find path to DiPS xml in config."); System.exit(1); } File dipsFile = new File(dipsF); if (!dipsFile.isFile() || !dipsFile.canRead()) { System.err.println("Cannot find '" + dipsF + "'"); System.exit(1); } Document dips = XML.parseDocument(dipsFile, Boolean.FALSE); if (dips == null) { System.err.println("Cannot load DiPs document."); System.exit(1); } ConnectionBuilder aftConnectionBuilder = new ConnectionBuilder(AFT, config); ConnectionBuilder flysConnectionBuilder = new ConnectionBuilder(FLYS, config); SyncContext syncContext = null; try { syncContext = new SyncContext( aftConnectionBuilder.getConnectedStatements(), flysConnectionBuilder.getConnectedStatements(), dips); Rivers rivers = new Rivers(); rivers.sync(syncContext); } catch (SQLException sqle) { sqle.printStackTrace(); System.err.println("syncing failed: " + sqle.getMessage()); } finally { if (syncContext != null) { syncContext.close(); } } } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :