comparison backend/src/main/java/org/dive4elements/river/importer/sinfo/parsers/InfrastructureParser.java @ 9636:ac41551a8e4d

Bundu/Bzws: Error message for missing channel/year, Nachtrag Pos. 20: import of two levels of infrastructure types
author mschaefer
date Mon, 11 Nov 2019 16:29:36 +0100
parents ddebd4c2fe93
children 75bd347147ad
comparison
equal deleted inserted replaced
9635:a03c54129819 9636:ac41551a8e4d
39 39
40 /***** FIELDS *****/ 40 /***** FIELDS *****/
41 41
42 private static final Logger log = Logger.getLogger(InfrastructureParser.class); 42 private static final Logger log = Logger.getLogger(InfrastructureParser.class);
43 43
44 private static final Pattern META_TYPE = Pattern.compile("^#\\sInfrastruktur:\\s*([^;]*).*", Pattern.CASE_INSENSITIVE); 44 private static final Pattern META_GROUP = Pattern.compile("^#\\sInfrastruktur:\\s*([^;]*).*", Pattern.CASE_INSENSITIVE);
45
46 private static final Pattern META_TYPE = Pattern.compile("^#\\sTyp\\/Bezeichnung:\\s*([^;]*).*", Pattern.CASE_INSENSITIVE);
45 47
46 private static final Pattern META_PROVIDER = Pattern.compile("^#\\sDatenherkunft:\\s*([^;]*).*", Pattern.CASE_INSENSITIVE); 48 private static final Pattern META_PROVIDER = Pattern.compile("^#\\sDatenherkunft:\\s*([^;]*).*", Pattern.CASE_INSENSITIVE);
47 49
48 private static final Pattern META_EVALUATOR = Pattern.compile("^#\\sAuswerter:\\s*([^;]*).*", Pattern.CASE_INSENSITIVE); 50 private static final Pattern META_EVALUATOR = Pattern.compile("^#\\sAuswerter:\\s*([^;]*).*", Pattern.CASE_INSENSITIVE);
49 51
114 return KmMode.DUPLICATES; 116 return KmMode.DUPLICATES;
115 } 117 }
116 118
117 @Override 119 @Override
118 protected boolean handleMetaOther() { 120 protected boolean handleMetaOther() {
119 if (handleMetaType()) 121 if (handleMetaGroup())
122 return true;
123 else if (handleMetaType())
120 return true; 124 return true;
121 else if (handleMetaProvider()) 125 else if (handleMetaProvider())
122 return true; 126 return true;
123 else if (handleMetaEvaluator()) 127 else if (handleMetaEvaluator())
124 return true; 128 return true;
125 else if (handleMetaYear()) 129 else if (handleMetaYear())
126 return true; 130 return true;
127 else 131 else
128 return false; 132 return false;
133 }
134
135 private boolean handleMetaGroup() {
136 final Matcher m = META_GROUP.matcher(this.currentLine);
137 if (m.matches()) {
138 this.metaPatternsMatched.add(META_GROUP);
139 if (this.river.getAnnotationClassifier() != null) {
140 final ImportAnnotationType group = this.river.getAnnotationClassifier().classifyDescription(m.group(1).trim(),
141 this.river.getAnnotationClassifier().getDefaultType());
142 this.seriesHeader.setGroup(group);
143 log.info(String.format("Group name in file: '%s', will be assigned to database name '%s'", m.group(1).trim(), group.getName()));
144 }
145 else {
146 log.error("No annotation types file configured, cannot process group '" + m.group(1).trim() + "'");
147 this.headerParsingState = ParsingState.STOP;
148 }
149 return true;
150 }
151 return false;
129 } 152 }
130 153
131 private boolean handleMetaType() { 154 private boolean handleMetaType() {
132 final Matcher m = META_TYPE.matcher(this.currentLine); 155 final Matcher m = META_TYPE.matcher(this.currentLine);
133 if (m.matches()) { 156 if (m.matches()) {

http://dive4elements.wald.intevation.org