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