9417
|
1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde |
|
2 * Software engineering by |
|
3 * Björnsen Beratende Ingenieure GmbH |
|
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt |
|
5 * |
|
6 * This file is Free Software under the GNU AGPL (>=v3) |
|
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
|
8 * documentation coming with Dive4Elements River for details. |
|
9 */ |
|
10 package test; |
|
11 |
|
12 import java.io.IOException; |
|
13 |
|
14 import org.dive4elements.artifacts.httpclient.exceptions.ConnectionException; |
|
15 import org.dive4elements.river.client.shared.exceptions.ServerException; |
|
16 import org.dive4elements.river.client.shared.model.Data; |
|
17 import org.dive4elements.river.client.shared.model.DataItem; |
|
18 import org.dive4elements.river.client.shared.model.DefaultDataItem; |
|
19 import org.dive4elements.river.client.shared.model.StringOptionsData; |
|
20 |
|
21 import test.BerechnungsartenTester.CalcMode; |
|
22 import test.BerechnungsartenTester.FilenameMapper; |
|
23 import test.BerechnungsartenTester.River; |
|
24 |
|
25 /** |
|
26 * @author Domenico Nardi Tironi |
|
27 * |
|
28 */ |
|
29 public class SinfoCollisionRunner extends AbstractModuleRunner { |
|
30 |
|
31 private final int[] years; |
|
32 private final String epochs; |
|
33 private boolean isYears; // cannot be final because of the ternary expression |
|
34 |
|
35 public SinfoCollisionRunner(final String username, final String password, final FilenameMapper file, final double from, final double to, final River river, |
|
36 final int[] years, final String epochs) throws ConnectionException, ServerException { |
|
37 super(username, password, AbstractModuleRunner.Infotype.sinfo, CalcMode.sinfo_calc_collision, file, from, to, river); |
|
38 this.years = years; |
|
39 this.epochs = epochs; |
|
40 this.isYears = (years != null) ? (this.isYears = true) : (this.isYears = false); |
|
41 } |
|
42 |
|
43 @Override |
|
44 public void runTest(final boolean exportToFile) throws ServerException, IOException { |
|
45 /* Select River */ |
|
46 super.selectRiver(); |
|
47 |
|
48 /* Select CalcMode */ |
|
49 super.selectCalcMode(); |
|
50 |
|
51 super.feed(new Data[] { |
|
52 new StringOptionsData("ld_mode", "ld_mode", new DataItem[] { new DefaultDataItem("distance_only", "distance_only", "distance_only") }) }); // ggf |
|
53 |
|
54 /* Select Range */ |
|
55 super.selectRange(); |
|
56 |
|
57 /* Year or Epoch? eigentlich vermutlich überflüssig */ |
|
58 final String yeSelectStr = this.isYears ? "state.sinfo.year" : "state.sinfo.epoch"; |
|
59 final Data yearEpochSelect = new StringOptionsData("ye_select", "ye_select", |
|
60 new DataItem[] { new DefaultDataItem(yeSelectStr, yeSelectStr, yeSelectStr) }); |
|
61 feedAndGo(new Data[] { yearEpochSelect }, 0); |
|
62 |
|
63 if (this.years != null) { |
|
64 final StringBuilder sb = new StringBuilder(); |
|
65 for (final int value : this.years) { |
|
66 sb.append(String.valueOf(value)); |
|
67 sb.append(" "); |
|
68 } |
|
69 final Data yearsData = new StringOptionsData("years", "years", new DataItem[] { new DefaultDataItem("years", "years", sb.toString()) }); |
|
70 feedAndGo(new Data[] { yearsData }, 0); |
|
71 } else if (this.epochs != null) { |
|
72 final Data data = new StringOptionsData("epochs", "epochs", new DataItem[] { new DefaultDataItem("epochs", "epochs", this.epochs) }); |
|
73 feedAndGo(new Data[] { data }, 0); |
|
74 } |
|
75 describeCollection(); |
|
76 |
|
77 super.export(exportToFile); |
|
78 } |
|
79 } |