9439
|
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.bundu; |
|
11 |
9570
|
12 import java.io.File; |
9439
|
13 import java.io.IOException; |
9567
|
14 import java.util.Calendar; |
9439
|
15 import java.util.List; |
9567
|
16 import java.util.TimeZone; |
9439
|
17 |
|
18 import org.dive4elements.artifacts.httpclient.exceptions.ConnectionException; |
|
19 import org.dive4elements.river.client.shared.exceptions.ServerException; |
|
20 import org.dive4elements.river.client.shared.model.Data; |
|
21 import org.dive4elements.river.client.shared.model.DataItem; |
|
22 import org.dive4elements.river.client.shared.model.DefaultDataItem; |
|
23 import org.dive4elements.river.client.shared.model.IntDataItem; |
|
24 import org.dive4elements.river.client.shared.model.IntegerArrayData; |
|
25 import org.dive4elements.river.client.shared.model.StringOptionsData; |
|
26 |
|
27 import test.AbstractBerechnungsartenTester.River; |
|
28 import test.AbstractModuleRunner; |
|
29 |
|
30 /** |
|
31 * @author Domenico Nardi Tironi |
|
32 * |
|
33 */ |
|
34 class BunduBezugswstRunner extends AbstractModuleRunner { |
|
35 |
|
36 private final String fixationChoice; |
|
37 private final int bezugsjahr; |
|
38 private final int years_length; |
|
39 |
|
40 private final boolean fehlvolumina; |
|
41 private final String sounding; |
|
42 |
|
43 private final String calcChoice; |
|
44 private final double step; |
|
45 private final List<Segment> segments; |
9442
|
46 private final String qSectorStart; |
|
47 private final String qSectorEnd; |
9439
|
48 private final int[] events; |
9442
|
49 private final String function; |
9567
|
50 private final Double fehlVolFrom; |
|
51 private final Double fehlVolTo; |
|
52 private final boolean preprocessing; |
9439
|
53 |
9570
|
54 public BunduBezugswstRunner(final File testFolder, final double from, final double to, final double step, final River river, final int bezugsjahr, |
|
55 final String fixationChoice, final String function, final String abflussklasseFrom, final String abflussklasseTo, final int[] events, |
|
56 final int years_length, final List<Segment> segments, final String calcChoice, final boolean preprocessing, final boolean fehlvolumina, |
|
57 final Double fehlVolFrom, final Double fehlVolTo, final String sounding) throws ConnectionException, ServerException { |
|
58 super(testFolder, AbstractModuleRunner.Infotype.bundu, test.bundu.BunduBerechnungsartenTester.CalcMode.bundu_bezugswst, from, to, river); |
9439
|
59 this.fixationChoice = fixationChoice; |
9442
|
60 this.qSectorStart = abflussklasseFrom; |
|
61 this.qSectorEnd = abflussklasseTo; |
9439
|
62 this.bezugsjahr = bezugsjahr; |
|
63 this.years_length = years_length; |
|
64 this.fehlvolumina = fehlvolumina; |
9567
|
65 this.fehlVolFrom = fehlVolFrom; |
|
66 this.fehlVolTo = fehlVolTo; |
9439
|
67 this.sounding = sounding; |
|
68 this.calcChoice = calcChoice; |
9567
|
69 this.preprocessing = preprocessing; |
9439
|
70 this.step = step; |
|
71 this.segments = segments; |
|
72 this.events = events; |
9442
|
73 this.function = function; |
9567
|
74 |
9439
|
75 } |
|
76 |
|
77 @Override |
9567
|
78 public void runTest() throws ServerException, IOException { |
9439
|
79 /* Select River */ |
|
80 super.selectRiver(); |
|
81 |
|
82 /* Select ICalcMode */ |
|
83 super.selectCalcMode(); |
|
84 |
|
85 /* Select Range with step */ |
9567
|
86 final Data[] temp = super.makeFromToData("ld_from", "ld_to", this.getFrom(), this.getTo()); |
9439
|
87 final String stepStr = String.valueOf(this.step); |
|
88 final Data[] data = super.addItemToExistingData(temp, |
|
89 new StringOptionsData("ld_step", "ld_step", new DataItem[] { new DefaultDataItem(stepStr, stepStr, stepStr) })); |
|
90 |
|
91 super.feedAndGo(data, 0); |
|
92 |
|
93 /* bezugsjahr */ |
|
94 final String bezugsjahr = String.valueOf(this.bezugsjahr); |
9567
|
95 |
|
96 final IntDataItem[] eventArray = new IntDataItem[this.events.length]; |
|
97 for (int i = 0; i < this.events.length; i++) { |
|
98 eventArray[i] = new IntDataItem("id", "id", this.events[i]); |
|
99 } |
|
100 |
|
101 final IntegerArrayData iadTemp = new IntegerArrayData("events_temp", "events_temp", eventArray); |
|
102 |
|
103 super.feedAndGo(new Data[] { super.getSimpleTextInput("singleyear", bezugsjahr), iadTemp }, 0); |
9439
|
104 |
|
105 /* fixierungsauswahl - auto oder manuell */ |
|
106 // AUTO: 0, 3 |
9442
|
107 final Data q1 = super.getSimpleTextInput("q1", this.qSectorStart); |
|
108 final Data q2 = super.getSimpleTextInput("q2", this.qSectorEnd); |
9439
|
109 final Data fixChoice = super.getSimpleTextInput("fix_choice", this.fixationChoice); |
9567
|
110 // start, end (missing) |
|
111 // final DateTimeFormat df = DateTimeFormat.getFormat("dd.MM.yyyy"); |
|
112 final Calendar cal = Calendar.getInstance(); |
|
113 cal.setTimeZone(TimeZone.getDefault());// TODO: TimeZoneHandling |
|
114 cal.set(Calendar.YEAR, (this.bezugsjahr - 5)); |
|
115 cal.set(Calendar.DAY_OF_YEAR, 1); |
9439
|
116 |
9567
|
117 final Data startData = super.getSimpleTextInput("start", String.valueOf(cal.getTime().getTime())); |
|
118 cal.set(Calendar.YEAR, (this.bezugsjahr - 5)); |
|
119 cal.set(Calendar.DAY_OF_YEAR, 365); |
|
120 final Data endData = super.getSimpleTextInput("end", String.valueOf(cal.getTime().getTime())); |
|
121 final IntegerArrayData iad = new IntegerArrayData("events", "events", eventArray); |
|
122 |
|
123 super.feedAndGo(new Data[] { q1, q2, iad, fixChoice, startData, endData }, 0); |
|
124 |
|
125 if (this.fixationChoice.equals("state.bundu.wst.fix.manual")) { |
|
126 super.feedAndGo(new Data[] { q1, q2 }, 0); // ein State extra im workflow |
9439
|
127 } |
|
128 |
|
129 /* Länge der Abflusszeitreihe */ |
|
130 super.feedAndGoSimpleTextInput("year_input_q_series", String.valueOf(this.years_length)); |
|
131 |
|
132 /* (W)Q-Input / UD Input */ |
|
133 |
|
134 final Data[] wqData = Segment.getDataforFeed("wq_values", this.segments); |
|
135 final Data[] wqAndMode = super.addItemToExistingData(wqData, |
|
136 new StringOptionsData("bundu.wst.mode", "bundu.wst.mode", new DataItem[] { new DefaultDataItem("Q", "Q", "Q") })); |
|
137 |
|
138 super.feedAndGo(wqAndMode, // |
|
139 0);// reachable state index |
|
140 |
|
141 /* calc_choice */ |
9567
|
142 final Data preprocessingData = super.getSimpleTextInput("preprocessing", String.valueOf(this.preprocessing)); |
9442
|
143 final Data functionData = super.getSimpleTextInput("function", this.function); |
9439
|
144 final Data calcChoice = super.getSimpleTextInput("calc_choice", this.calcChoice); |
9567
|
145 super.feedAndGo(new Data[] { calcChoice, preprocessingData, functionData }, 0); |
9439
|
146 |
9567
|
147 if (this.calcChoice.equals("state.bundu.wst.calc.manual")) { |
|
148 super.feedAndGo(new Data[] { functionData }, 0); // extra states im workflow |
|
149 super.feedAndGo(new Data[] { preprocessingData }, 0); |
|
150 } |
9439
|
151 |
|
152 /* missing_volume */ |
9567
|
153 final Data missingVolume = super.getSimpleTextInput("missing_volume", String.valueOf(this.fehlvolumina)); |
|
154 super.feedAndGo(new Data[] { missingVolume }, 0); |
9439
|
155 |
9567
|
156 if (this.fehlvolumina) { |
|
157 super.makeKmRange(this.fehlVolFrom, this.fehlVolTo, "ld_from_part", "ld_to_part"); |
|
158 super.feedAndGoSimpleTextInput("soundings", this.sounding); |
|
159 } |
9439
|
160 describeCollection(); |
9567
|
161 super.runTests(); |
9439
|
162 } |
|
163 |
|
164 } |