comparison flys-backend/src/main/java/de/intevation/flys/importer/Importer.java @ 765:763c4137d6e1

Added classification of annotation types. Needs testing! flys-backend/trunk@2162 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Sun, 19 Jun 2011 12:26:12 +0000
parents 67fd63e4ef66
children aa9e3da95c31
comparison
equal deleted inserted replaced
764:e09f00ecb915 765:763c4137d6e1
1 package de.intevation.flys.importer; 1 package de.intevation.flys.importer;
2
3 import de.intevation.artifacts.common.utils.XMLUtils;
2 4
3 import java.io.File; 5 import java.io.File;
4 import java.io.IOException; 6 import java.io.IOException;
5 7
6 import java.util.List; 8 import java.util.List;
10 import org.apache.log4j.Logger; 12 import org.apache.log4j.Logger;
11 13
12 import org.hibernate.Transaction; 14 import org.hibernate.Transaction;
13 import org.hibernate.HibernateException; 15 import org.hibernate.HibernateException;
14 16
17 import org.w3c.dom.Document;
18
15 public class Importer 19 public class Importer
16 { 20 {
17 private static Logger log = Logger.getLogger(Importer.class); 21 private static Logger log = Logger.getLogger(Importer.class);
18 22
19 public static final boolean DRY_RUN = 23 public static final boolean DRY_RUN =
20 Boolean.getBoolean("flys.backend.importer.dry.run"); 24 Boolean.getBoolean("flys.backend.importer.dry.run");
25
26 public static final String ANNOTATION_TYPES =
27 "flys.backend.importer.annotation.types";
21 28
22 protected List<ImportRiver> rivers; 29 protected List<ImportRiver> rivers;
23 30
24 public Importer() { 31 public Importer() {
25 } 32 }
77 } 84 }
78 throw re; 85 throw re;
79 } 86 }
80 } 87 }
81 88
89 public static AnnotationClassifier getAnnotationClassifier() {
90 String annotationTypes = System.getProperty(ANNOTATION_TYPES);
91
92 if (annotationTypes == null) {
93 return null;
94 }
95
96 File file = new File(annotationTypes);
97
98 if (!(file.isFile() && file.canRead())) {
99 log.warn("annotation type file '" + file + "' is not readable.");
100 return null;
101 }
102
103 Document rules = XMLUtils.parseDocument(file);
104
105 if (rules == null) {
106 log.warn("cannot parse annotation types file.");
107 return null;
108 }
109
110 return new AnnotationClassifier(rules);
111 }
112
82 public static void main(String [] args) { 113 public static void main(String [] args) {
83 114
84 InfoGewParser infoGewParser = new InfoGewParser(); 115 InfoGewParser infoGewParser = new InfoGewParser(
116 getAnnotationClassifier());
85 117
86 for (String gew: args) { 118 for (String gew: args) {
87 log.info("parsing info gew file: " + gew); 119 log.info("parsing info gew file: " + gew);
88 try { 120 try {
89 infoGewParser.parse(new File(gew)); 121 infoGewParser.parse(new File(gew));

http://dive4elements.wald.intevation.org