Mercurial > dive4elements > river
comparison flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java @ 484:a9e9a8a44d19
Parse and store "amtliche Linien" wst files.
flys-backend/trunk@1807 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 03 May 2011 14:18:43 +0000 |
parents | f1fd9cab6a07 |
children | 13af9318a4a2 |
comparison
equal
deleted
inserted
replaced
483:f1fd9cab6a07 | 484:a9e9a8a44d19 |
---|---|
24 public static final String FIXATIONS = "Fixierungen"; | 24 public static final String FIXATIONS = "Fixierungen"; |
25 | 25 |
26 public static final String EXTRA_LONGITUDINALS = | 26 public static final String EXTRA_LONGITUDINALS = |
27 "Zus.L\u00e4ngsschnitte"; | 27 "Zus.L\u00e4ngsschnitte"; |
28 | 28 |
29 public static final String [] OFFICIAL_LINES_FOLDERS = { | |
30 "Basisdaten", | |
31 "Fixierungen" }; | |
32 | |
33 public static final String OFFICIAL_LINES = | |
34 "Amtl_Linien.wst"; | |
35 | |
29 protected String name; | 36 protected String name; |
30 | 37 |
31 protected File wstFile; | 38 protected File wstFile; |
32 | 39 |
33 protected File bbInfoFile; | 40 protected File bbInfoFile; |
38 | 45 |
39 protected List<ImportWst> extraWsts; | 46 protected List<ImportWst> extraWsts; |
40 | 47 |
41 protected List<ImportWst> fixations; | 48 protected List<ImportWst> fixations; |
42 | 49 |
50 protected List<ImportWst> officialLines; | |
51 | |
43 protected ImportWst wst; | 52 protected ImportWst wst; |
44 | 53 |
45 protected River peer; | 54 protected River peer; |
46 | 55 |
47 public ImportRiver() { | 56 public ImportRiver() { |
48 extraWsts = new ArrayList<ImportWst>(); | 57 extraWsts = new ArrayList<ImportWst>(); |
49 fixations = new ArrayList<ImportWst>(); | 58 fixations = new ArrayList<ImportWst>(); |
59 officialLines = new ArrayList<ImportWst>(); | |
50 } | 60 } |
51 | 61 |
52 public ImportRiver(String name, File wstFile, File bbInfoFile) { | 62 public ImportRiver(String name, File wstFile, File bbInfoFile) { |
53 this(); | 63 this(); |
54 this.name = name; | 64 this.name = name; |
92 parseGauges(); | 102 parseGauges(); |
93 parseAnnotations(); | 103 parseAnnotations(); |
94 parseWst(); | 104 parseWst(); |
95 parseExtraWsts(); | 105 parseExtraWsts(); |
96 parseFixations(); | 106 parseFixations(); |
107 parseOfficialLines(); | |
108 } | |
109 | |
110 public void parseOfficialLines() throws IOException { | |
111 log.info("Parse official wst files"); | |
112 | |
113 File riverDir = wstFile.getParentFile().getParentFile(); | |
114 | |
115 for (String folder: OFFICIAL_LINES_FOLDERS) { | |
116 File dir = FileTools.repair(new File(riverDir, folder)); | |
117 | |
118 if (!dir.isDirectory() || !dir.canRead()) { | |
119 log.info("no directory '" + folder + "' found"); | |
120 continue; | |
121 } | |
122 | |
123 File file = FileTools.repair(new File(dir, OFFICIAL_LINES)); | |
124 if (!file.isFile() || !file.canRead()) { | |
125 log.warn("no official lines wst file found"); | |
126 continue; | |
127 } | |
128 log.debug("Found WST file: " + file); | |
129 | |
130 WstParser wstParser = new WstParser(); | |
131 wstParser.parse(file); | |
132 ImportWst iw = wstParser.getWst(); | |
133 iw.setKind(3); | |
134 iw.setDescription(folder + "/" + iw.getDescription()); | |
135 officialLines.add(iw); | |
136 } // for all folders | |
137 | |
97 } | 138 } |
98 | 139 |
99 public void parseFixations() throws IOException { | 140 public void parseFixations() throws IOException { |
100 log.info("Parse fixation wst files"); | 141 log.info("Parse fixation wst files"); |
101 | 142 |
211 storeAnnotations(); | 252 storeAnnotations(); |
212 storeGauges(); | 253 storeGauges(); |
213 storeWst(); | 254 storeWst(); |
214 storeExtraWsts(); | 255 storeExtraWsts(); |
215 storeFixations(); | 256 storeFixations(); |
257 storeOfficialLines(); | |
216 } | 258 } |
217 | 259 |
218 public void storeWst() { | 260 public void storeWst() { |
219 River river = getPeer(); | 261 River river = getPeer(); |
220 wst.storeDependencies(river); | 262 wst.storeDependencies(river); |
231 | 273 |
232 public void storeExtraWsts() { | 274 public void storeExtraWsts() { |
233 log.info("store extra wsts"); | 275 log.info("store extra wsts"); |
234 River river = getPeer(); | 276 River river = getPeer(); |
235 for (ImportWst wst: extraWsts) { | 277 for (ImportWst wst: extraWsts) { |
278 log.debug("name: " + wst.getDescription()); | |
279 wst.storeDependencies(river); | |
280 } | |
281 } | |
282 | |
283 public void storeOfficialLines() { | |
284 log.info("store official lines wsts"); | |
285 River river = getPeer(); | |
286 for (ImportWst wst: officialLines) { | |
236 log.debug("name: " + wst.getDescription()); | 287 log.debug("name: " + wst.getDescription()); |
237 wst.storeDependencies(river); | 288 wst.storeDependencies(river); |
238 } | 289 } |
239 } | 290 } |
240 | 291 |