comparison backend/src/main/java/org/dive4elements/river/importer/parsers/StaFileParser.java @ 6004:ec54bb4fe407

Importer: use gauge official number as identifier, not name
author Tom Gottfried <tom.gottfried@intevation.de>
date Mon, 13 May 2013 11:14:38 +0200
parents 4c3ccf2b0304
children 53d08f33d094
comparison
equal deleted inserted replaced
5999:492a17232154 6004:ec54bb4fe407
40 public static final String ENCODING = "ISO-8859-1"; 40 public static final String ENCODING = "ISO-8859-1";
41 41
42 public static final String TYPES = 42 public static final String TYPES =
43 System.getProperty("flys.backend.main.value.types", "QWTD"); 43 System.getProperty("flys.backend.main.value.types", "QWTD");
44 44
45 public static final boolean NOT_PARSE_GAUGE_NUMBERS =
46 Boolean.getBoolean("flys.backend.sta.not.parse.gauge.numbers");
47
48 public static final Pattern QWTD_ = 45 public static final Pattern QWTD_ =
49 Pattern.compile("\\s*([^\\s]+)\\s+([^\\s]+)\\s+([" + 46 Pattern.compile("\\s*([^\\s]+)\\s+([^\\s]+)\\s+([" +
50 Pattern.quote(TYPES) + "]).*"); 47 Pattern.quote(TYPES) + "]).*");
51 48
52 // TODO: To be extented. 49 // TODO: To be extented.
115 112
116 String gaugeName = line.substring(16, 35).trim(); 113 String gaugeName = line.substring(16, 35).trim();
117 114
118 Long gaugeNumber = null; 115 Long gaugeNumber = null;
119 116
120 if (!NOT_PARSE_GAUGE_NUMBERS) { 117 String gaugeNumberString = line.substring(8, 16).trim();
121 String gaugeNumberString = line.substring(8, 16).trim(); 118
122 119 try {
123 try { 120 gaugeNumber = Long.parseLong(gaugeNumberString);
124 gaugeNumber = Long.parseLong(gaugeNumberString); 121 }
125 } 122 catch (NumberFormatException nfe) {
126 catch (NumberFormatException nfe) { 123 log.warn("STA: gauge number '" + gaugeNumberString +
127 log.warn("STA: gauge number '" + gaugeNumberString + 124 "' is not a valid long number.");
128 "' is not a valid long number.");
129 }
130 } 125 }
131 126
132 gauge.setName(gaugeName); 127 gauge.setName(gaugeName);
133 gauge.setOfficialNumber(gaugeNumber); 128 gauge.setOfficialNumber(gaugeNumber);
134 129

http://dive4elements.wald.intevation.org