Mercurial > dive4elements > river
changeset 766:aa9e3da95c31
Importer: Fix import of annotation type classification.
flys-backend/trunk@2163 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sun, 19 Jun 2011 17:43:38 +0000 |
parents | 763c4137d6e1 |
children | 5572d051347e |
files | flys-backend/ChangeLog flys-backend/doc/annotation-types.xml flys-backend/src/main/java/de/intevation/flys/importer/AnnotationClassifier.java flys-backend/src/main/java/de/intevation/flys/importer/AnnotationsParser.java flys-backend/src/main/java/de/intevation/flys/importer/ImportAnnotationType.java flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java flys-backend/src/main/java/de/intevation/flys/importer/Importer.java flys-backend/src/main/java/de/intevation/flys/importer/InfoGewParser.java |
diffstat | 8 files changed, 59 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-backend/ChangeLog Sun Jun 19 12:26:12 2011 +0000 +++ b/flys-backend/ChangeLog Sun Jun 19 17:43:38 2011 +0000 @@ -1,3 +1,22 @@ +2011-06-19 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * doc/annotation-types.xml: Fixed some rules. + + * src/main/java/de/intevation/flys/importer/Importer.java, + src/main/java/de/intevation/flys/importer/InfoGewParser.java, + src/main/java/de/intevation/flys/importer/ImportRiver.java: + Call the right constructors now. + + * src/main/java/de/intevation/flys/importer/ImportAnnotationType.java: + Added getter/setter for name property. + + * src/main/java/de/intevation/flys/importer/AnnotationsParser.java: + Print duplicated at WARN level not as DEBUG. + + * src/main/java/de/intevation/flys/importer/AnnotationClassifier.java: + Fixed XPath expression to build the internal lookup structures + correctly. + 2011-06-19 Sascha L. Teichmann <sascha.teichmann@intevation.de> Added classification of annotation types. Needs testing!
--- a/flys-backend/doc/annotation-types.xml Sun Jun 19 12:26:12 2011 +0000 +++ b/flys-backend/doc/annotation-types.xml Sun Jun 19 17:43:38 2011 +0000 @@ -38,14 +38,15 @@ <line pattern="^Berechnungsstrecke.*$" type="Berechnungsstrecke"/> <line pattern="^Brücke[:\s].*$" type="Brücke"/> <line pattern="^Bundesland[:\s].*$" type="Bundesland"/> - <line pattern="^Einmündung[:\s].*$" type="Abzweig"/> + <line pattern="^Einmündung[:\s].*$" type="Einmündung"/> <line pattern="^Fähre[:\s].*$" type="Abzweig"/> - <line pattern="^Gemeinde[:\s].*$" type="Abzweig"/> + <line pattern="^Gemeinde[:\s].*$" type="Gemeinde"/> <line pattern="^Grenze[:\s].*$" type="Grenze"/> <line pattern="^Hafen[:\s].*$" type="Hafen"/> <line pattern="^HW-Schutz[:\s].*$" type="HW-Schutz"/> <line pattern="^Landkreis[:\s].*$" type="Landkreis"/> <line pattern="^Meldestelle[:\s].*$" type="Meldestelle"/> + <line pattern="^Messstelle[:\s].*$" type="Messstelle"/> <line pattern="^Pegel[:\s].*$" type="Pegel"/> <line pattern="^Staatsgrenze[:\s].*$" type="Staatsgrenze"/> <line pattern="^Staat[:\s].*$" type="Staat"/>
--- a/flys-backend/src/main/java/de/intevation/flys/importer/AnnotationClassifier.java Sun Jun 19 12:26:12 2011 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/AnnotationClassifier.java Sun Jun 19 17:43:38 2011 +0000 @@ -26,13 +26,13 @@ private static Logger log = Logger.getLogger(Importer.class); public static final String TYPES_XPATH = - "/annotations/types/type"; + "/annotation/types/type"; public static final String FILE_PATTERNS_XPATH = - "/annotations/patterns/file"; + "/annotation/patterns/file"; public static final String DESCRIPTION_PATTERNS_XPATH = - "/annotations/patterns/line"; + "/annotation/patterns/line"; public static class Pair { @@ -70,7 +70,6 @@ } protected void buildRules(Document rules) { - buildTypes(rules); buildFilePatterns(rules); buildDescriptionPatterns(rules);
--- a/flys-backend/src/main/java/de/intevation/flys/importer/AnnotationsParser.java Sun Jun 19 12:26:12 2011 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/AnnotationsParser.java Sun Jun 19 17:43:38 2011 +0000 @@ -147,8 +147,8 @@ attribute, position, range, edge, type); if (!annotations.add(annotation)) { - log.debug("duplicated annotation in line " - + in.getLineNumber()); + log.warn("duplicated annotation '" + parts[0] + + "' in line " + in.getLineNumber()); } } }
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportAnnotationType.java Sun Jun 19 12:26:12 2011 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportAnnotationType.java Sun Jun 19 17:43:38 2011 +0000 @@ -24,6 +24,15 @@ return name.compareTo(other.name); } + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public AnnotationType getPeer() { if (peer == null) { Session session = ImporterSession.getInstance().getDatabaseSession();
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java Sun Jun 19 12:26:12 2011 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java Sun Jun 19 17:43:38 2011 +0000 @@ -65,23 +65,24 @@ protected River peer; public ImportRiver() { - this(null); - } - - public ImportRiver(AnnotationClassifier annotationClassifier) { extraWsts = new ArrayList<ImportWst>(); fixations = new ArrayList<ImportWst>(); officialLines = new ArrayList<ImportWst>(); floodWater = new ArrayList<ImportWst>(); floodProtection = new ArrayList<ImportWst>(); - this.annotationClassifier = annotationClassifier; } - public ImportRiver(String name, File wstFile, File bbInfoFile) { + public ImportRiver( + String name, + File wstFile, + File bbInfoFile, + AnnotationClassifier annotationClassifier + ) { this(); - this.name = name; - this.wstFile = wstFile; - this.bbInfoFile = bbInfoFile; + this.name = name; + this.wstFile = wstFile; + this.bbInfoFile = bbInfoFile; + this.annotationClassifier = annotationClassifier; } public String getName() {
--- a/flys-backend/src/main/java/de/intevation/flys/importer/Importer.java Sun Jun 19 12:26:12 2011 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/Importer.java Sun Jun 19 17:43:38 2011 +0000 @@ -90,11 +90,14 @@ String annotationTypes = System.getProperty(ANNOTATION_TYPES); if (annotationTypes == null) { + log.info("no annotation types file configured."); return null; } File file = new File(annotationTypes); + log.info("use annotation types file '" + file + "'"); + if (!(file.isFile() && file.canRead())) { log.warn("annotation type file '" + file + "' is not readable."); return null;
--- a/flys-backend/src/main/java/de/intevation/flys/importer/InfoGewParser.java Sun Jun 19 12:26:12 2011 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/InfoGewParser.java Sun Jun 19 17:43:38 2011 +0000 @@ -59,7 +59,6 @@ File root = file.getParentFile(); - ImportRiver importRiver = new ImportRiver(annotationClassifier); try { in = new LineNumberReader( @@ -82,7 +81,11 @@ String river = m.group(1); log.info("Found river '" + river + "'"); if (riverName != null) { - rivers.add(new ImportRiver(riverName, wstFile, bbInfoFile)); + rivers.add(new ImportRiver( + riverName, + wstFile, + bbInfoFile, + annotationClassifier)); } riverName = river; wstFile = null; @@ -109,7 +112,11 @@ } } if (riverName != null) { - rivers.add(new ImportRiver(riverName, wstFile, bbInfoFile)); + rivers.add(new ImportRiver( + riverName, + wstFile, + bbInfoFile, + annotationClassifier)); } } finally {