# HG changeset patch # User Sascha L. Teichmann # Date 1308505418 0 # Node ID aa9e3da95c310d2e3f21f399af2b8d8a21a6ef54 # Parent 763c4137d6e1a2a075287b30e1252ae247e4068b Importer: Fix import of annotation type classification. flys-backend/trunk@2163 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 763c4137d6e1 -r aa9e3da95c31 flys-backend/ChangeLog --- 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 + + * 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 Added classification of annotation types. Needs testing! diff -r 763c4137d6e1 -r aa9e3da95c31 flys-backend/doc/annotation-types.xml --- 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 @@ - + - + + diff -r 763c4137d6e1 -r aa9e3da95c31 flys-backend/src/main/java/de/intevation/flys/importer/AnnotationClassifier.java --- 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); diff -r 763c4137d6e1 -r aa9e3da95c31 flys-backend/src/main/java/de/intevation/flys/importer/AnnotationsParser.java --- 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()); } } } diff -r 763c4137d6e1 -r aa9e3da95c31 flys-backend/src/main/java/de/intevation/flys/importer/ImportAnnotationType.java --- 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(); diff -r 763c4137d6e1 -r aa9e3da95c31 flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java --- 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(); fixations = new ArrayList(); officialLines = new ArrayList(); floodWater = new ArrayList(); floodProtection = new ArrayList(); - 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() { diff -r 763c4137d6e1 -r aa9e3da95c31 flys-backend/src/main/java/de/intevation/flys/importer/Importer.java --- 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; diff -r 763c4137d6e1 -r aa9e3da95c31 flys-backend/src/main/java/de/intevation/flys/importer/InfoGewParser.java --- 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 {