Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WSPLGENJob.java @ 1091:7230e087ef8b
Prepare directories for WSPLGEN specific data in FloodMap state and remove those directories when State.endOfLife() is called.
flys-artifacts/trunk@2594 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 26 Aug 2011 12:42:12 +0000 |
parents | |
children | e9f66d63bdd0 |
comparison
equal
deleted
inserted
replaced
1090:9324839684a4 | 1091:7230e087ef8b |
---|---|
1 package de.intevation.flys.artifacts.model; | |
2 | |
3 import java.io.IOException; | |
4 import java.io.File; | |
5 import java.io.FileOutputStream; | |
6 import java.io.OutputStreamWriter; | |
7 import java.io.PrintWriter; | |
8 | |
9 | |
10 public class WSPLGENJob { | |
11 | |
12 public static final String GEL_SPERRE = "SPERRE"; | |
13 public static final String GEL_NOSPERRE = "NOSPERRE"; | |
14 | |
15 | |
16 protected String dgm; | |
17 protected String pro; | |
18 protected String wsp; | |
19 protected String wspTag; | |
20 protected String lin; | |
21 protected String axis; | |
22 protected String area; | |
23 protected String gel; | |
24 protected String outFile; | |
25 | |
26 protected int out; | |
27 | |
28 protected double start; | |
29 protected double end; | |
30 protected double from; | |
31 protected double to; | |
32 protected double diff; | |
33 protected double dist; | |
34 | |
35 | |
36 | |
37 public WSPLGENJob() { | |
38 out = -1; | |
39 start = Double.NaN; | |
40 end = Double.NaN; | |
41 from = Double.NaN; | |
42 to = Double.NaN; | |
43 diff = Double.NaN; | |
44 dist = Double.NaN; | |
45 } | |
46 | |
47 | |
48 public void setWsp(String wsp) { | |
49 this.wsp = wsp; | |
50 } | |
51 | |
52 | |
53 public String getWsp() { | |
54 return wsp; | |
55 } | |
56 | |
57 | |
58 public void setWspTag(String wspTag) { | |
59 this.wspTag = wspTag; | |
60 } | |
61 | |
62 | |
63 public String getWspTag() { | |
64 return wspTag; | |
65 } | |
66 | |
67 | |
68 public void setLin(String lin) { | |
69 this.lin = lin; | |
70 } | |
71 | |
72 | |
73 public String getLin() { | |
74 return lin; | |
75 } | |
76 | |
77 | |
78 public void setAxis(String axis) { | |
79 this.axis = axis; | |
80 } | |
81 | |
82 | |
83 public String getAxis() { | |
84 return axis; | |
85 } | |
86 | |
87 | |
88 public void setArea(String area) { | |
89 this.area = area; | |
90 } | |
91 | |
92 | |
93 public String getArea() { | |
94 return area; | |
95 } | |
96 | |
97 | |
98 public void setOut(int out) { | |
99 this.out = out; | |
100 } | |
101 | |
102 | |
103 public int getOut() { | |
104 return out; | |
105 } | |
106 | |
107 | |
108 public void setOutFile(String outFile) { | |
109 this.outFile = outFile; | |
110 } | |
111 | |
112 | |
113 public String getOutFile() { | |
114 return outFile; | |
115 } | |
116 | |
117 | |
118 public void setStart(double start) { | |
119 this.start = start; | |
120 } | |
121 | |
122 | |
123 public double getStart() { | |
124 return start; | |
125 } | |
126 | |
127 | |
128 public void setEnd(double end) { | |
129 this.end = end; | |
130 } | |
131 | |
132 | |
133 public double getEnd() { | |
134 return end; | |
135 } | |
136 | |
137 | |
138 public void setPro(String pro) { | |
139 this.pro = pro; | |
140 } | |
141 | |
142 | |
143 public String getPro() { | |
144 return pro; | |
145 } | |
146 | |
147 | |
148 public void setDgm(String dgm) { | |
149 this.dgm = dgm; | |
150 } | |
151 | |
152 | |
153 public String getDgm() { | |
154 return dgm; | |
155 } | |
156 | |
157 | |
158 public void setFrom(double from) { | |
159 this.from = from; | |
160 } | |
161 | |
162 | |
163 public double getFrom() { | |
164 return from; | |
165 } | |
166 | |
167 | |
168 public void setTo(double to) { | |
169 this.to = to; | |
170 } | |
171 | |
172 | |
173 public double getTo() { | |
174 return to; | |
175 } | |
176 | |
177 | |
178 public void setDiff(double diff) { | |
179 this.diff = diff; | |
180 } | |
181 | |
182 | |
183 public double getDiff() { | |
184 return diff; | |
185 } | |
186 | |
187 | |
188 public void setDist(double dist) { | |
189 this.dist = dist; | |
190 } | |
191 | |
192 | |
193 public double getDist() { | |
194 return dist; | |
195 } | |
196 | |
197 | |
198 public void setGel(String gel) { | |
199 if (gel == null || gel.length() == 0) { | |
200 return; | |
201 } | |
202 | |
203 if (gel.equals(GEL_SPERRE) || gel.equals(GEL_NOSPERRE)) { | |
204 this.gel = gel; | |
205 } | |
206 } | |
207 | |
208 | |
209 public String getGel() { | |
210 return gel; | |
211 } | |
212 | |
213 | |
214 public void toFile(File file) | |
215 throws IOException, IllegalArgumentException | |
216 { | |
217 PrintWriter writer = null; | |
218 | |
219 try { | |
220 writer = | |
221 new PrintWriter( | |
222 new OutputStreamWriter( | |
223 new FileOutputStream(file))); | |
224 | |
225 write(writer); | |
226 } | |
227 finally { | |
228 if (writer != null) { | |
229 writer.flush(); | |
230 writer.close(); | |
231 } | |
232 } | |
233 } | |
234 | |
235 | |
236 protected void write(PrintWriter writer) | |
237 throws IOException, IllegalArgumentException | |
238 { | |
239 writeWsp(writer); | |
240 writeWspTag(writer); | |
241 writeLin(writer); | |
242 writeAxis(writer); | |
243 writeArea(writer); | |
244 writeOut(writer); | |
245 writeOutFile(writer); | |
246 writeRange(writer); | |
247 writeDelta(writer); | |
248 writeGel(writer); | |
249 writeDist(writer); | |
250 writePro(writer); | |
251 writeDgm(writer); | |
252 } | |
253 | |
254 | |
255 protected void writeWsp(PrintWriter writer) | |
256 throws IllegalArgumentException | |
257 { | |
258 String wsp = getWsp(); | |
259 | |
260 if (wsp != null && wsp.length() > 0) { | |
261 writer.println("-WSP=\"" + wsp + "\""); | |
262 return; | |
263 } | |
264 | |
265 throw new IllegalArgumentException("Required WSP missing!"); | |
266 } | |
267 | |
268 protected void writeWspTag(PrintWriter writer) | |
269 throws IllegalArgumentException | |
270 { | |
271 String wspTag = getWspTag(); | |
272 | |
273 if (wspTag != null && wspTag.length() > 0) { | |
274 writer.println("-WSPTAG=\"" + wspTag + "\""); | |
275 return; | |
276 } | |
277 | |
278 throw new IllegalArgumentException("Required WSPTAG missing!"); | |
279 } | |
280 | |
281 protected void writeLin(PrintWriter writer) | |
282 throws IllegalArgumentException | |
283 { | |
284 String lin = getLin(); | |
285 | |
286 if (lin != null && lin.length() > 0) { | |
287 writer.println("-LIN=\"" + lin + "\""); | |
288 } | |
289 } | |
290 | |
291 protected void writeAxis(PrintWriter writer) | |
292 throws IllegalArgumentException | |
293 { | |
294 String axis = getAxis(); | |
295 | |
296 if (axis != null && axis.length() > 0) { | |
297 writer.println("-ACHSE=\"" + axis + "\""); | |
298 } | |
299 } | |
300 | |
301 protected void writeGel(PrintWriter writer) | |
302 throws IllegalArgumentException | |
303 { | |
304 if (area != null && area.length() > 0) { | |
305 writer.println("-GEL=" + getGel()); | |
306 } | |
307 } | |
308 | |
309 protected void writeArea(PrintWriter writer) | |
310 throws IllegalArgumentException | |
311 { | |
312 String area = getArea(); | |
313 | |
314 if (area != null && area.length() > 0) { | |
315 writer.println("-GEBIET=\"" + area + "\""); | |
316 } | |
317 } | |
318 | |
319 | |
320 protected void writeOut(PrintWriter writer) | |
321 throws IllegalArgumentException | |
322 { | |
323 int out = getOut(); | |
324 | |
325 if (out >= 0) { | |
326 writer.println("-OUTPUT=" + String.valueOf(out)); | |
327 } | |
328 } | |
329 | |
330 protected void writeOutFile(PrintWriter writer) | |
331 throws IllegalArgumentException | |
332 { | |
333 String outFile = getOutFile(); | |
334 | |
335 if (outFile != null && outFile.length() > 0) { | |
336 writer.println("-AUSGABE=\""+ outFile + "\""); | |
337 } | |
338 } | |
339 | |
340 protected void writeRange(PrintWriter writer) | |
341 throws IllegalArgumentException | |
342 { | |
343 StringBuilder sb = new StringBuilder("-STRECKE="); | |
344 | |
345 double start = getStart(); | |
346 double end = getEnd(); | |
347 | |
348 if (Double.isNaN(start) && Double.isNaN(end)) { | |
349 return; | |
350 } | |
351 | |
352 if (! Double.isNaN(getStart())) { | |
353 sb.append(getStart()); | |
354 } | |
355 | |
356 sb.append(","); | |
357 | |
358 if (! Double.isNaN(getEnd())) { | |
359 sb.append(getEnd()); | |
360 } | |
361 | |
362 writer.println(sb.toString()); | |
363 } | |
364 | |
365 protected void writeDelta(PrintWriter writer) | |
366 throws IllegalArgumentException | |
367 { | |
368 StringBuilder sb = new StringBuilder("-DELTA="); | |
369 if (! Double.isNaN(from)) { | |
370 sb.append(from); | |
371 } | |
372 | |
373 sb.append(","); | |
374 | |
375 if (! Double.isNaN(to)) { | |
376 sb.append(to); | |
377 } | |
378 | |
379 sb.append(","); | |
380 | |
381 if (! Double.isNaN(diff)) { | |
382 sb.append(diff); | |
383 } | |
384 | |
385 writer.println(sb.toString()); | |
386 } | |
387 | |
388 protected void writeDist(PrintWriter writer) | |
389 throws IllegalArgumentException | |
390 { | |
391 if (! Double.isNaN(getDist())) { | |
392 writer.println("-DIST=" + String.valueOf(getDist())); | |
393 } | |
394 } | |
395 | |
396 protected void writePro(PrintWriter writer) | |
397 throws IllegalArgumentException | |
398 { | |
399 if (pro != null && pro.length() > 0) { | |
400 writer.println("-PRO=\"" + getPro() + "\""); | |
401 } | |
402 } | |
403 | |
404 protected void writeDgm(PrintWriter writer) | |
405 throws IllegalArgumentException | |
406 { | |
407 if (dgm != null && dgm.length() > 0) { | |
408 writer.println("-DGM=\"" + getDgm() + "\""); | |
409 return; | |
410 } | |
411 | |
412 throw new IllegalArgumentException("Required DGM missing!"); | |
413 } | |
414 } | |
415 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |