Mercurial > dive4elements > river
diff flys-backend/src/main/java/de/intevation/flys/importer/AtFileParser.java @ 493:b35c5dc0f8b7
Importer: Make import of historical discharge tables work.
flys-backend/trunk@1842 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 06 May 2011 10:27:32 +0000 |
parents | 14de9246b356 |
children | ee693b8fbb55 |
line wrap: on
line diff
--- a/flys-backend/src/main/java/de/intevation/flys/importer/AtFileParser.java Thu May 05 15:25:16 2011 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/importer/AtFileParser.java Fri May 06 10:27:32 2011 +0000 @@ -40,10 +40,15 @@ public ImportDischargeTable parse(File file) throws IOException { - return parse(file, 0); + return parse(file, "", 0); } - public ImportDischargeTable parse(File file, int kind) throws IOException { + public ImportDischargeTable parse( + File file, + String prefix, + int kind + ) + throws IOException { logger.info("parsing AT file: " + file); @@ -53,7 +58,8 @@ boolean beginning = true; - ImportDischargeTable dischargeTable = new ImportDischargeTable(kind); + ImportDischargeTable dischargeTable = + new ImportDischargeTable(kind, prefix + file.getName()); Date from = null; Date to = null; @@ -73,8 +79,8 @@ Matcher m = DATE_LINE.matcher(tmp); if (m.matches()) { - from = guessDate(m.group(1), m.group(2), m.group(3)); - to = guessDate(m.group(4), m.group(5), m.group(6)); + from = guessDate(m.group(2), m.group(3), m.group(4)); + to = guessDate(m.group(5), m.group(6), m.group(7)); if (from == null) { Date t = from; from = to; to = t; } @@ -137,6 +143,9 @@ } if (from != null) { + if (to != null && from.compareTo(to) > 0) { + Date t = from; from = to; to = t; + } logger.info("from: " + from + " to: " + to); ImportTimeInterval interval = new ImportTimeInterval(from, to); dischargeTable.setTimeInterval(interval); @@ -152,6 +161,8 @@ return null; } + logger.debug("day: " + day + " month: " + month + " year: " + year); + int dayI = 15; if (day != null) { try { @@ -188,7 +199,9 @@ } Calendar cal = Calendar.getInstance(); - cal.set(yearI, monthI-1, dayI); + cal.set(yearI, monthI-1, dayI, 12, 0, 0); + long ms = cal.getTimeInMillis(); + cal.setTimeInMillis(ms - ms%1000); return cal.getTime(); } }