Mercurial > dive4elements > river
diff 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 |
line wrap: on
line diff
--- a/flys-backend/src/main/java/de/intevation/flys/importer/Importer.java Sat Jun 18 20:13:31 2011 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/Importer.java Sun Jun 19 12:26:12 2011 +0000 @@ -1,5 +1,7 @@ package de.intevation.flys.importer; +import de.intevation.artifacts.common.utils.XMLUtils; + import java.io.File; import java.io.IOException; @@ -12,6 +14,8 @@ import org.hibernate.Transaction; import org.hibernate.HibernateException; +import org.w3c.dom.Document; + public class Importer { private static Logger log = Logger.getLogger(Importer.class); @@ -19,6 +23,9 @@ public static final boolean DRY_RUN = Boolean.getBoolean("flys.backend.importer.dry.run"); + public static final String ANNOTATION_TYPES = + "flys.backend.importer.annotation.types"; + protected List<ImportRiver> rivers; public Importer() { @@ -79,9 +86,34 @@ } } + public static AnnotationClassifier getAnnotationClassifier() { + String annotationTypes = System.getProperty(ANNOTATION_TYPES); + + if (annotationTypes == null) { + return null; + } + + File file = new File(annotationTypes); + + if (!(file.isFile() && file.canRead())) { + log.warn("annotation type file '" + file + "' is not readable."); + return null; + } + + Document rules = XMLUtils.parseDocument(file); + + if (rules == null) { + log.warn("cannot parse annotation types file."); + return null; + } + + return new AnnotationClassifier(rules); + } + public static void main(String [] args) { - InfoGewParser infoGewParser = new InfoGewParser(); + InfoGewParser infoGewParser = new InfoGewParser( + getAnnotationClassifier()); for (String gew: args) { log.info("parsing info gew file: " + gew);