Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/importer/sinfo/parsers/TkhParser.java @ 9032:1f63e9d3b0ec
New columns for bed_height, tkh and depth_evolution, a few syntactic corrections for Oracle
author | mschaefer |
---|---|
date | Fri, 27 Apr 2018 17:35:12 +0200 |
parents | dcbdff96d1a8 |
children | 4c5eeaff554c |
comparison
equal
deleted
inserted
replaced
9031:efd2de78d158 | 9032:1f63e9d3b0ec |
---|---|
29 import org.dive4elements.river.importer.common.AbstractParser; | 29 import org.dive4elements.river.importer.common.AbstractParser; |
30 import org.dive4elements.river.importer.common.ParsingState; | 30 import org.dive4elements.river.importer.common.ParsingState; |
31 import org.dive4elements.river.importer.sinfo.importitem.TkhColumnSeriesImport; | 31 import org.dive4elements.river.importer.sinfo.importitem.TkhColumnSeriesImport; |
32 import org.dive4elements.river.importer.sinfo.importitem.TkhKmLineImport; | 32 import org.dive4elements.river.importer.sinfo.importitem.TkhKmLineImport; |
33 import org.dive4elements.river.importer.sinfo.importitem.TkhSeriesImport; | 33 import org.dive4elements.river.importer.sinfo.importitem.TkhSeriesImport; |
34 import org.dive4elements.river.model.sinfo.Tkh; | |
34 import org.dive4elements.river.model.sinfo.TkhColumn; | 35 import org.dive4elements.river.model.sinfo.TkhColumn; |
35 import org.dive4elements.river.model.sinfo.TkhValue; | 36 import org.dive4elements.river.model.sinfo.TkhValue; |
36 | 37 |
37 /** | 38 /** |
38 * Reads and parses the header of a TKH file and handles the parse and store of the columns | 39 * Reads and parses the header of a TKH file and handles the parse and store of the columns |
54 | 55 |
55 private static final Pattern META_TYPE = Pattern.compile("^#\\sTyp:\\s*([^;]*).*", Pattern.CASE_INSENSITIVE); | 56 private static final Pattern META_TYPE = Pattern.compile("^#\\sTyp:\\s*([^;]*).*", Pattern.CASE_INSENSITIVE); |
56 | 57 |
57 private static final Pattern COLUMN_TITLE = Pattern.compile("Transportk((.)|(oe))rperh((.)|(oe))he\\s*\\((.+?)\\)\\s*\\[cm\\].*", Pattern.CASE_INSENSITIVE); | 58 private static final Pattern COLUMN_TITLE = Pattern.compile("Transportk((.)|(oe))rperh((.)|(oe))he\\s*\\((.+?)\\)\\s*\\[cm\\].*", Pattern.CASE_INSENSITIVE); |
58 | 59 |
60 private enum GroupDirectory { | |
61 NONE(Tkh.Group.NONE, ""), // | |
62 CALCULATION(Tkh.Group.CALCULATION, "Berechnungsergebnisse"), // | |
63 MEASUREMENT(Tkh.Group.MEASUREMENT, "Naturmessungen"); | |
64 | |
65 private final Tkh.Group group; | |
66 private final String dirname; | |
67 | |
68 GroupDirectory(final Tkh.Group group, final String dirname) { | |
69 this.group = group; | |
70 this.dirname = dirname; | |
71 } | |
72 | |
73 public Tkh.Group getGroup() { | |
74 return this.group; | |
75 } | |
76 | |
77 public String getDirName() { | |
78 return this.dirname; | |
79 } | |
80 | |
81 public static GroupDirectory forDirName(final String dirname) { | |
82 for (final GroupDirectory gd : GroupDirectory.values()) { | |
83 if (dirname.equalsIgnoreCase(gd.getDirName())) | |
84 return gd; | |
85 } | |
86 return NONE; | |
87 } | |
88 } | |
89 | |
59 private static final DateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy"); | 90 private static final DateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy"); |
60 | 91 |
61 private final TkhSeriesImport tkhGroup; | 92 private final TkhSeriesImport tkhGroup; |
62 | 93 |
63 private final List<TkhColumnParser> colParsers; | 94 private final List<TkhColumnParser> colParsers; |
66 /***** CONSTRUCTORS *****/ | 97 /***** CONSTRUCTORS *****/ |
67 | 98 |
68 public TkhParser(final File importPath, final File rootRelativePath, final ImportRiver river) { | 99 public TkhParser(final File importPath, final File rootRelativePath, final ImportRiver river) { |
69 super(importPath, rootRelativePath, river); | 100 super(importPath, rootRelativePath, river); |
70 this.tkhGroup = new TkhSeriesImport(importPath.getName().replaceAll("\\.csv", "")); | 101 this.tkhGroup = new TkhSeriesImport(importPath.getName().replaceAll("\\.csv", "")); |
102 this.tkhGroup.setGroup(GroupDirectory.forDirName(this.importPath.getParentFile().getName()).getGroup()); | |
71 this.seriesHeader = new TkhColumnSeriesImport(this.tkhGroup.getFilename(), this.tkhGroup, null, null); | 103 this.seriesHeader = new TkhColumnSeriesImport(this.tkhGroup.getFilename(), this.tkhGroup, null, null); |
72 this.colParsers = new ArrayList<>(); | 104 this.colParsers = new ArrayList<>(); |
73 } | 105 } |
74 | 106 |
75 | 107 |