comparison flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java @ 490:13af9318a4a2

Import "Hochwasser-Marken", too. flys-backend/trunk@1838 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Thu, 05 May 2011 14:46:41 +0000
parents a9e9a8a44d19
children 738140fe56fe
comparison
equal deleted inserted replaced
489:e960098b1398 490:13af9318a4a2
31 "Fixierungen" }; 31 "Fixierungen" };
32 32
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";
37
36 protected String name; 38 protected String name;
37 39
38 protected File wstFile; 40 protected File wstFile;
39 41
40 protected File bbInfoFile; 42 protected File bbInfoFile;
46 protected List<ImportWst> extraWsts; 48 protected List<ImportWst> extraWsts;
47 49
48 protected List<ImportWst> fixations; 50 protected List<ImportWst> fixations;
49 51
50 protected List<ImportWst> officialLines; 52 protected List<ImportWst> officialLines;
53
54 protected List<ImportWst> floodWater;
51 55
52 protected ImportWst wst; 56 protected ImportWst wst;
53 57
54 protected River peer; 58 protected River peer;
55 59
56 public ImportRiver() { 60 public ImportRiver() {
57 extraWsts = new ArrayList<ImportWst>(); 61 extraWsts = new ArrayList<ImportWst>();
58 fixations = new ArrayList<ImportWst>(); 62 fixations = new ArrayList<ImportWst>();
59 officialLines = new ArrayList<ImportWst>(); 63 officialLines = new ArrayList<ImportWst>();
64 floodWater = new ArrayList<ImportWst>();
60 } 65 }
61 66
62 public ImportRiver(String name, File wstFile, File bbInfoFile) { 67 public ImportRiver(String name, File wstFile, File bbInfoFile) {
63 this(); 68 this();
64 this.name = name; 69 this.name = name;
103 parseAnnotations(); 108 parseAnnotations();
104 parseWst(); 109 parseWst();
105 parseExtraWsts(); 110 parseExtraWsts();
106 parseFixations(); 111 parseFixations();
107 parseOfficialLines(); 112 parseOfficialLines();
113 parseFloodWater();
114 }
115
116 public void parseFloodWater() throws IOException {
117 log.info("Parse flood water wst file");
118
119 File riverDir = wstFile.getParentFile().getParentFile();
120
121 File dir = FileTools.repair(new File(riverDir, FLOOD_WATER));
122
123 if (!dir.isDirectory() || !dir.canRead()) {
124 log.info("no directory '" + dir + "' found");
125 return;
126 }
127
128 File [] files = dir.listFiles();
129
130 if (files == null) {
131 log.warn("cannot read '" + dir + "'");
132 return;
133 }
134
135 for (File file: files) {
136 if (!file.isFile() || !file.canRead()) {
137 continue;
138 }
139 String name = file.getName().toLowerCase();
140 if (!(name.endsWith(".zus") || name.endsWith(".wst"))) {
141 continue;
142 }
143 log.info("found file '" + file.getName() + "'");
144 WstParser wstParser = new WstParser();
145 wstParser.parse(file);
146 ImportWst iw = wstParser.getWst();
147 iw.setKind(4);
148 iw.setDescription(FLOOD_WATER + "/" + iw.getDescription());
149 floodWater.add(iw);
150 }
108 } 151 }
109 152
110 public void parseOfficialLines() throws IOException { 153 public void parseOfficialLines() throws IOException {
111 log.info("Parse official wst files"); 154 log.info("Parse official wst files");
112 155
169 212
170 WstParser wstParser = new WstParser(); 213 WstParser wstParser = new WstParser();
171 wstParser.parse(file); 214 wstParser.parse(file);
172 ImportWst iw = wstParser.getWst(); 215 ImportWst iw = wstParser.getWst();
173 iw.setKind(2); 216 iw.setKind(2);
174 iw.setDescription("Fix: " + iw.getDescription()); 217 iw.setDescription(FIXATIONS+ "/" + iw.getDescription());
175 fixations.add(iw); 218 fixations.add(iw);
176 } 219 }
177 } 220 }
178 221
179 public void parseExtraWsts() throws IOException { 222 public void parseExtraWsts() throws IOException {
253 storeGauges(); 296 storeGauges();
254 storeWst(); 297 storeWst();
255 storeExtraWsts(); 298 storeExtraWsts();
256 storeFixations(); 299 storeFixations();
257 storeOfficialLines(); 300 storeOfficialLines();
301 storeFloodWater();
258 } 302 }
259 303
260 public void storeWst() { 304 public void storeWst() {
261 River river = getPeer(); 305 River river = getPeer();
262 wst.storeDependencies(river); 306 wst.storeDependencies(river);
282 326
283 public void storeOfficialLines() { 327 public void storeOfficialLines() {
284 log.info("store official lines wsts"); 328 log.info("store official lines wsts");
285 River river = getPeer(); 329 River river = getPeer();
286 for (ImportWst wst: officialLines) { 330 for (ImportWst wst: officialLines) {
331 log.debug("name: " + wst.getDescription());
332 wst.storeDependencies(river);
333 }
334 }
335
336 public void storeFloodWater() {
337 log.info("store flood water wsts");
338 River river = getPeer();
339 for (ImportWst wst: floodWater) {
287 log.debug("name: " + wst.getDescription()); 340 log.debug("name: " + wst.getDescription());
288 wst.storeDependencies(river); 341 wst.storeDependencies(river);
289 } 342 }
290 } 343 }
291 344

http://dive4elements.wald.intevation.org