Mercurial > dive4elements > river
annotate flys-aft/src/main/java/de/intevation/aft/Sync.java @ 4073:2c70fae83d0c
start syncing at river level.
flys-aft/trunk@3406 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 13 Dec 2011 13:41:43 +0000 |
parents | 88f801888d85 |
children | dbd0b3b1b8b8 |
rev | line source |
---|---|
4067
d5aed044ca0d
Added AFT sync module.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.aft; |
d5aed044ca0d
Added AFT sync module.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
4072
88f801888d85
load configuration an setup db connections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4067
diff
changeset
|
3 import java.io.File; |
88f801888d85
load configuration an setup db connections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4067
diff
changeset
|
4 |
4073
2c70fae83d0c
start syncing at river level.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4072
diff
changeset
|
5 import java.sql.SQLException; |
2c70fae83d0c
start syncing at river level.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4072
diff
changeset
|
6 |
4072
88f801888d85
load configuration an setup db connections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4067
diff
changeset
|
7 import org.w3c.dom.Document; |
88f801888d85
load configuration an setup db connections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4067
diff
changeset
|
8 |
88f801888d85
load configuration an setup db connections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4067
diff
changeset
|
9 import de.intevation.utils.XML; |
88f801888d85
load configuration an setup db connections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4067
diff
changeset
|
10 |
88f801888d85
load configuration an setup db connections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4067
diff
changeset
|
11 import de.intevation.db.ConnectionBuilder; |
88f801888d85
load configuration an setup db connections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4067
diff
changeset
|
12 |
4067
d5aed044ca0d
Added AFT sync module.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 public class Sync |
d5aed044ca0d
Added AFT sync module.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 { |
4072
88f801888d85
load configuration an setup db connections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4067
diff
changeset
|
15 public static final String FLYS = "flys"; |
88f801888d85
load configuration an setup db connections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4067
diff
changeset
|
16 public static final String AFT = "aft"; |
88f801888d85
load configuration an setup db connections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4067
diff
changeset
|
17 |
88f801888d85
load configuration an setup db connections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4067
diff
changeset
|
18 public static final String CONFIG_FILE = |
88f801888d85
load configuration an setup db connections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4067
diff
changeset
|
19 System.getProperty("config.file", "config.xml"); |
88f801888d85
load configuration an setup db connections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4067
diff
changeset
|
20 |
4067
d5aed044ca0d
Added AFT sync module.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 public static void main(String [] args) { |
4072
88f801888d85
load configuration an setup db connections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4067
diff
changeset
|
22 |
88f801888d85
load configuration an setup db connections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4067
diff
changeset
|
23 File configFile = new File(CONFIG_FILE); |
88f801888d85
load configuration an setup db connections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4067
diff
changeset
|
24 |
88f801888d85
load configuration an setup db connections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4067
diff
changeset
|
25 if (!configFile.isFile() || !configFile.canRead()) { |
88f801888d85
load configuration an setup db connections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4067
diff
changeset
|
26 System.err.println("cannot read config file"); |
88f801888d85
load configuration an setup db connections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4067
diff
changeset
|
27 System.exit(1); |
88f801888d85
load configuration an setup db connections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4067
diff
changeset
|
28 } |
88f801888d85
load configuration an setup db connections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4067
diff
changeset
|
29 |
88f801888d85
load configuration an setup db connections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4067
diff
changeset
|
30 Document config = XML.parseDocument(configFile, Boolean.FALSE); |
88f801888d85
load configuration an setup db connections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4067
diff
changeset
|
31 |
88f801888d85
load configuration an setup db connections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4067
diff
changeset
|
32 if (config == null) { |
88f801888d85
load configuration an setup db connections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4067
diff
changeset
|
33 System.err.println("cannot load config"); |
88f801888d85
load configuration an setup db connections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4067
diff
changeset
|
34 System.exit(1); |
88f801888d85
load configuration an setup db connections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4067
diff
changeset
|
35 } |
88f801888d85
load configuration an setup db connections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4067
diff
changeset
|
36 |
4073
2c70fae83d0c
start syncing at river level.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4072
diff
changeset
|
37 ConnectionBuilder aftConnectionBuilder = |
2c70fae83d0c
start syncing at river level.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4072
diff
changeset
|
38 new ConnectionBuilder(AFT, config); |
2c70fae83d0c
start syncing at river level.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4072
diff
changeset
|
39 |
4072
88f801888d85
load configuration an setup db connections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4067
diff
changeset
|
40 ConnectionBuilder flysConnectionBuilder = |
88f801888d85
load configuration an setup db connections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4067
diff
changeset
|
41 new ConnectionBuilder(FLYS, config); |
88f801888d85
load configuration an setup db connections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4067
diff
changeset
|
42 |
4073
2c70fae83d0c
start syncing at river level.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4072
diff
changeset
|
43 Rivers rivers = new Rivers( |
2c70fae83d0c
start syncing at river level.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4072
diff
changeset
|
44 aftConnectionBuilder, |
2c70fae83d0c
start syncing at river level.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4072
diff
changeset
|
45 flysConnectionBuilder); |
4072
88f801888d85
load configuration an setup db connections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4067
diff
changeset
|
46 |
4073
2c70fae83d0c
start syncing at river level.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4072
diff
changeset
|
47 try { |
2c70fae83d0c
start syncing at river level.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4072
diff
changeset
|
48 rivers.sync(); |
2c70fae83d0c
start syncing at river level.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4072
diff
changeset
|
49 } |
2c70fae83d0c
start syncing at river level.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4072
diff
changeset
|
50 catch (SQLException sqle) { |
2c70fae83d0c
start syncing at river level.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4072
diff
changeset
|
51 System.err.println("syncing failed: " + sqle.getMessage()); |
2c70fae83d0c
start syncing at river level.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4072
diff
changeset
|
52 } |
2c70fae83d0c
start syncing at river level.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4072
diff
changeset
|
53 finally { |
2c70fae83d0c
start syncing at river level.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4072
diff
changeset
|
54 rivers.close(); |
2c70fae83d0c
start syncing at river level.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4072
diff
changeset
|
55 } |
4067
d5aed044ca0d
Added AFT sync module.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
56 } |
d5aed044ca0d
Added AFT sync module.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
57 } |
d5aed044ca0d
Added AFT sync module.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
58 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |