Mercurial > dive4elements > river
comparison flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java @ 494:88d5b02ff0c1
Importer: Import the "HW-Schutzanlagen", too.
flys-backend/trunk@1845 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 06 May 2011 15:15:04 +0000 |
parents | 738140fe56fe |
children | 67fd63e4ef66 |
comparison
equal
deleted
inserted
replaced
493:b35c5dc0f8b7 | 494:88d5b02ff0c1 |
---|---|
33 public static final String OFFICIAL_LINES = | 33 public static final String OFFICIAL_LINES = |
34 "Amtl_Linien.wst"; | 34 "Amtl_Linien.wst"; |
35 | 35 |
36 public static final String FLOOD_WATER = "HW-Marken"; | 36 public static final String FLOOD_WATER = "HW-Marken"; |
37 | 37 |
38 public static final String FLOOD_PROTECTION = | |
39 "HW-Schutzanlagen"; | |
40 | |
38 protected String name; | 41 protected String name; |
39 | 42 |
40 protected File wstFile; | 43 protected File wstFile; |
41 | 44 |
42 protected File bbInfoFile; | 45 protected File bbInfoFile; |
51 | 54 |
52 protected List<ImportWst> officialLines; | 55 protected List<ImportWst> officialLines; |
53 | 56 |
54 protected List<ImportWst> floodWater; | 57 protected List<ImportWst> floodWater; |
55 | 58 |
59 protected List<ImportWst> floodProtection; | |
60 | |
56 protected ImportWst wst; | 61 protected ImportWst wst; |
57 | 62 |
58 protected River peer; | 63 protected River peer; |
59 | 64 |
60 public ImportRiver() { | 65 public ImportRiver() { |
61 extraWsts = new ArrayList<ImportWst>(); | 66 extraWsts = new ArrayList<ImportWst>(); |
62 fixations = new ArrayList<ImportWst>(); | 67 fixations = new ArrayList<ImportWst>(); |
63 officialLines = new ArrayList<ImportWst>(); | 68 officialLines = new ArrayList<ImportWst>(); |
64 floodWater = new ArrayList<ImportWst>(); | 69 floodWater = new ArrayList<ImportWst>(); |
70 floodProtection = new ArrayList<ImportWst>(); | |
65 } | 71 } |
66 | 72 |
67 public ImportRiver(String name, File wstFile, File bbInfoFile) { | 73 public ImportRiver(String name, File wstFile, File bbInfoFile) { |
68 this(); | 74 this(); |
69 this.name = name; | 75 this.name = name; |
109 parseWst(); | 115 parseWst(); |
110 parseExtraWsts(); | 116 parseExtraWsts(); |
111 parseFixations(); | 117 parseFixations(); |
112 parseOfficialLines(); | 118 parseOfficialLines(); |
113 parseFloodWater(); | 119 parseFloodWater(); |
120 parseFloodProtection(); | |
121 } | |
122 | |
123 public void parseFloodProtection() throws IOException { | |
124 log.info("Parse flood protection wst file"); | |
125 | |
126 File riverDir = wstFile.getParentFile().getParentFile(); | |
127 | |
128 File dir = FileTools.repair(new File(riverDir, FLOOD_PROTECTION)); | |
129 | |
130 if (!dir.isDirectory() || !dir.canRead()) { | |
131 log.info("no directory '" + dir + "' found"); | |
132 return; | |
133 } | |
134 | |
135 File [] files = dir.listFiles(); | |
136 | |
137 if (files == null) { | |
138 log.warn("cannot read '" + dir + "'"); | |
139 return; | |
140 } | |
141 | |
142 for (File file: files) { | |
143 if (!file.isFile() || !file.canRead()) { | |
144 continue; | |
145 } | |
146 String name = file.getName().toLowerCase(); | |
147 if (!(name.endsWith(".zus") || name.endsWith(".wst"))) { | |
148 continue; | |
149 } | |
150 log.info("found file '" + file.getName() + "'"); | |
151 WstParser wstParser = new WstParser(); | |
152 wstParser.parse(file); | |
153 ImportWst iw = wstParser.getWst(); | |
154 iw.setKind(5); | |
155 iw.setDescription(FLOOD_PROTECTION + "/" + iw.getDescription()); | |
156 floodProtection.add(iw); | |
157 } | |
114 } | 158 } |
115 | 159 |
116 public void parseFloodWater() throws IOException { | 160 public void parseFloodWater() throws IOException { |
117 log.info("Parse flood water wst file"); | 161 log.info("Parse flood water wst file"); |
118 | 162 |
298 storeWst(); | 342 storeWst(); |
299 storeExtraWsts(); | 343 storeExtraWsts(); |
300 storeFixations(); | 344 storeFixations(); |
301 storeOfficialLines(); | 345 storeOfficialLines(); |
302 storeFloodWater(); | 346 storeFloodWater(); |
347 storeFloodProtection(); | |
303 } | 348 } |
304 | 349 |
305 public void storeWst() { | 350 public void storeWst() { |
306 River river = getPeer(); | 351 River river = getPeer(); |
307 wst.storeDependencies(river); | 352 wst.storeDependencies(river); |
336 | 381 |
337 public void storeFloodWater() { | 382 public void storeFloodWater() { |
338 log.info("store flood water wsts"); | 383 log.info("store flood water wsts"); |
339 River river = getPeer(); | 384 River river = getPeer(); |
340 for (ImportWst wst: floodWater) { | 385 for (ImportWst wst: floodWater) { |
386 log.debug("name: " + wst.getDescription()); | |
387 wst.storeDependencies(river); | |
388 } | |
389 } | |
390 | |
391 public void storeFloodProtection() { | |
392 log.info("store flood protection wsts"); | |
393 River river = getPeer(); | |
394 for (ImportWst wst: floodProtection) { | |
341 log.debug("name: " + wst.getDescription()); | 395 log.debug("name: " + wst.getDescription()); |
342 wst.storeDependencies(river); | 396 wst.storeDependencies(river); |
343 } | 397 } |
344 } | 398 } |
345 | 399 |