Revize b07f6ea7
Přidáno uživatelem Michal Linha před více než 4 roky(ů)
src/main/java/vldc/aswi/model/table/BooleanWrapper.java | ||
---|---|---|
1 | 1 |
package vldc.aswi.model.table; |
2 | 2 |
|
3 |
/** |
|
4 |
* Class used to wrap a boolean value |
|
5 |
*/ |
|
3 | 6 |
public class BooleanWrapper { |
4 | 7 |
|
8 |
/** |
|
9 |
* Boolean value that is wrapped in this class |
|
10 |
*/ |
|
5 | 11 |
private boolean value; |
6 | 12 |
|
13 |
/** |
|
14 |
* Constructor of the boolean wrapper |
|
15 |
* @param value boolean value to be saved |
|
16 |
*/ |
|
7 | 17 |
public BooleanWrapper(boolean value) { |
8 | 18 |
this.value = value; |
9 | 19 |
} |
10 | 20 |
|
21 |
/** |
|
22 |
* Returns the wrapped value |
|
23 |
* @return wrapped value |
|
24 |
*/ |
|
11 | 25 |
public boolean isValue() { |
12 | 26 |
return value; |
13 | 27 |
} |
14 | 28 |
|
29 |
/** |
|
30 |
* Sets the wrapped value |
|
31 |
* @param value value to be wrapped |
|
32 |
*/ |
|
15 | 33 |
public void setValue(boolean value) { |
16 | 34 |
this.value = value; |
17 | 35 |
} |
src/main/java/vldc/aswi/model/table/DoubleWrapper.java | ||
---|---|---|
1 | 1 |
package vldc.aswi.model.table; |
2 | 2 |
|
3 |
/** |
|
4 |
* Class used to wrap a double value |
|
5 |
*/ |
|
3 | 6 |
public class DoubleWrapper { |
4 | 7 |
|
8 |
/** |
|
9 |
* Value that is wrapped in this class |
|
10 |
*/ |
|
5 | 11 |
private double value; |
6 | 12 |
|
13 |
/** |
|
14 |
* Constructor of the double wrapper |
|
15 |
* @param value double value to be saved |
|
16 |
*/ |
|
7 | 17 |
public DoubleWrapper(double value) { |
8 | 18 |
this.value = value; |
9 | 19 |
} |
10 | 20 |
|
21 |
/** |
|
22 |
* Returns the wrapped value |
|
23 |
* @return wrapped value |
|
24 |
*/ |
|
11 | 25 |
public double getValue() { |
12 | 26 |
return value; |
13 | 27 |
} |
14 | 28 |
|
29 |
/** |
|
30 |
* Sets the wrapped value |
|
31 |
* @param value value to be wrapped |
|
32 |
*/ |
|
15 | 33 |
public void setValue(double value) { |
16 | 34 |
this.value = value; |
17 | 35 |
} |
src/main/java/vldc/aswi/model/table/Node.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
public class Node { |
10 | 10 |
|
11 |
/** |
|
12 |
* Result of COUNT function. |
|
13 |
*/ |
|
11 | 14 |
private double totalResult; |
12 | 15 |
|
16 |
/** |
|
17 |
* Result of count of AVG function. |
|
18 |
*/ |
|
13 | 19 |
private double totalResultAvg; |
14 | 20 |
|
21 |
/** |
|
22 |
* Result of sum of AVG function. |
|
23 |
*/ |
|
15 | 24 |
private double totalResultAvgSum; |
16 | 25 |
|
26 |
/** |
|
27 |
* Result of SUM function. |
|
28 |
*/ |
|
17 | 29 |
private double totalResultSum; |
18 | 30 |
|
31 |
/** |
|
32 |
* Result of MIN function. |
|
33 |
*/ |
|
19 | 34 |
private double totalMin; |
20 | 35 |
|
36 |
/** |
|
37 |
* Result of MAX function. |
|
38 |
*/ |
|
21 | 39 |
private double totalMax; |
22 | 40 |
|
41 |
/** |
|
42 |
* Tells if the counted value is the first value of the MIN function. |
|
43 |
*/ |
|
23 | 44 |
private boolean isFirstMin; |
24 | 45 |
|
46 |
/** |
|
47 |
* Tells if the counted value is the first value of the MAX function. |
|
48 |
*/ |
|
25 | 49 |
private boolean isFirstMax; |
26 | 50 |
|
51 |
/** |
|
52 |
* Tells if the node is usable if it represents a column. |
|
53 |
*/ |
|
27 | 54 |
private boolean isUsable; |
28 | 55 |
|
56 |
/** |
|
57 |
* Tells if total value of a column is filled. |
|
58 |
*/ |
|
29 | 59 |
private boolean isFilledTotalValue = false; |
30 | 60 |
|
31 | 61 |
/** |
... | ... | |
70 | 100 |
this.values = values; |
71 | 101 |
} |
72 | 102 |
|
103 |
/** |
|
104 |
* Gets the total result of COUNT function if this node represents a column. |
|
105 |
* @return Total result of COUNT function if this node represents a column. |
|
106 |
*/ |
|
73 | 107 |
public double getTotalResult() { |
74 | 108 |
return totalResult; |
75 | 109 |
} |
76 | 110 |
|
111 |
/** |
|
112 |
* Sets the total result of COUNT function if this node represents a column. |
|
113 |
* @param totalResult Total result to be set if this node represents a column. |
|
114 |
*/ |
|
77 | 115 |
public void setTotalResult(double totalResult) { |
78 | 116 |
this.totalResult = totalResult; |
79 | 117 |
} |
80 | 118 |
|
119 |
/** |
|
120 |
* Gets the total result of count of AVG function if this node represents a column. |
|
121 |
* @return Total result of count of AVG function if this node represents a column. |
|
122 |
*/ |
|
81 | 123 |
public double getTotalResultAvg() { |
82 | 124 |
return totalResultAvg; |
83 | 125 |
} |
84 | 126 |
|
127 |
/** |
|
128 |
* Sets the total result of of count of AVG function if this node represents a column. |
|
129 |
* @param totalResultAvg Total result to be set if this node represents a column. |
|
130 |
*/ |
|
85 | 131 |
public void setTotalResultAvg(double totalResultAvg) { |
86 | 132 |
this.totalResultAvg = totalResultAvg; |
87 | 133 |
} |
88 | 134 |
|
135 |
/** |
|
136 |
* Gets the total result of sum of AVG function if this node represents a column. |
|
137 |
* @return Total result of of sum of AVG function if this node represents a column. |
|
138 |
*/ |
|
89 | 139 |
public double getTotalResultAvgSum() { |
90 | 140 |
return totalResultAvgSum; |
91 | 141 |
} |
92 | 142 |
|
143 |
/** |
|
144 |
* Sets the total result of of sum of AVG function if this node represents a column. |
|
145 |
* @param totalResultAvgSum Total result to be set if this node represents a column. |
|
146 |
*/ |
|
93 | 147 |
public void setTotalResultAvgSum(double totalResultAvgSum) { |
94 | 148 |
this.totalResultAvgSum = totalResultAvgSum; |
95 | 149 |
} |
96 | 150 |
|
151 |
/** |
|
152 |
* Gets the total result of SUM function if this node represents a column. |
|
153 |
* @return Total result of SUM function if this node represents a column. |
|
154 |
*/ |
|
97 | 155 |
public double getTotalResultSum() { |
98 | 156 |
return totalResultSum; |
99 | 157 |
} |
100 | 158 |
|
159 |
/** |
|
160 |
* Sets the total result of SUM function if this node represents a column. |
|
161 |
* @param totalResultSum Total result to be set if this node represents a column. |
|
162 |
*/ |
|
101 | 163 |
public void setTotalResultSum(double totalResultSum) { |
102 | 164 |
this.totalResultSum = totalResultSum; |
103 | 165 |
} |
104 | 166 |
|
167 |
/** |
|
168 |
* Gets the total result of MIN function if this node represents a column. |
|
169 |
* @return Total result of MIN function if this node represents a column. |
|
170 |
*/ |
|
105 | 171 |
public double getTotalMin() { |
106 | 172 |
return totalMin; |
107 | 173 |
} |
108 | 174 |
|
175 |
/** |
|
176 |
* Sets the total result of MIN function if this node represents a column. |
|
177 |
* @param totalMin Total result to be set if this node represents a column. |
|
178 |
*/ |
|
109 | 179 |
public void setTotalMin(double totalMin) { |
110 | 180 |
this.totalMin = totalMin; |
111 | 181 |
} |
112 | 182 |
|
183 |
/** |
|
184 |
* Gets the total result of MAX function if this node represents a column. |
|
185 |
* @return Total result of MAX function if this node represents a column. |
|
186 |
*/ |
|
113 | 187 |
public double getTotalMax() { |
114 | 188 |
return totalMax; |
115 | 189 |
} |
116 | 190 |
|
191 |
/** |
|
192 |
* Sets the total result of MAX function if this node represents a column. |
|
193 |
* @param totalMax Total result to be set if this node represents a column. |
|
194 |
*/ |
|
117 | 195 |
public void setTotalMax(double totalMax) { |
118 | 196 |
this.totalMax = totalMax; |
119 | 197 |
} |
120 | 198 |
|
199 |
/** |
|
200 |
* Checks if the value if MIN function has been set if this node represents a column. |
|
201 |
* @return True of the value of MIN function has been set. |
|
202 |
*/ |
|
121 | 203 |
public boolean isFirstMin() { |
122 | 204 |
return isFirstMin; |
123 | 205 |
} |
124 | 206 |
|
207 |
/** |
|
208 |
* Set information that first MIN total value jas been set if this node represents a column. |
|
209 |
* @param firstMin Value whether total MIN value is set if this node represents a column. |
|
210 |
*/ |
|
125 | 211 |
public void setFirstMin(boolean firstMin) { |
126 | 212 |
isFirstMin = firstMin; |
127 | 213 |
} |
128 | 214 |
|
215 |
/** |
|
216 |
* Checks if the value if MAX function has been set if this node represents a column. |
|
217 |
* @return True of the value of MAX function has been set. |
|
218 |
*/ |
|
129 | 219 |
public boolean isFirstMax() { |
130 | 220 |
return isFirstMax; |
131 | 221 |
} |
132 | 222 |
|
223 |
/** |
|
224 |
* Set information that first MAX total value jas been set if this node represents a column. |
|
225 |
* @param firstMax Value whether total MAX value is set if this node represents a column. |
|
226 |
*/ |
|
133 | 227 |
public void setFirstMax(boolean firstMax) { |
134 | 228 |
isFirstMax = firstMax; |
135 | 229 |
} |
136 | 230 |
|
231 |
/** |
|
232 |
* Checks if a column this node represents is usable (has some values). |
|
233 |
* @return True if a column has some values. |
|
234 |
*/ |
|
137 | 235 |
public boolean isUsable() { |
138 | 236 |
return isUsable; |
139 | 237 |
} |
140 | 238 |
|
239 |
/** |
|
240 |
* Sets if a column this node represents is usable (has some values). |
|
241 |
* @param usable Value whether a column this node represents is usable (has some values). |
|
242 |
*/ |
|
141 | 243 |
public void setUsable(boolean usable) { |
142 | 244 |
isUsable = usable; |
143 | 245 |
} |
144 | 246 |
|
247 |
/** |
|
248 |
* Checks if a total value of a column this node represents is set. |
|
249 |
* @return True if one of the total values is set. |
|
250 |
*/ |
|
145 | 251 |
public boolean isFilledTotalValue() { |
146 | 252 |
return isFilledTotalValue; |
147 | 253 |
} |
148 | 254 |
|
255 |
/** |
|
256 |
* Sets if a total value of a column this node represents is set. |
|
257 |
* @param filledTotalValue Value whether a total value of a column this node represents is set. |
|
258 |
*/ |
|
149 | 259 |
public void setFilledTotalValue(boolean filledTotalValue) { |
150 | 260 |
isFilledTotalValue = filledTotalValue; |
151 | 261 |
} |
src/main/java/vldc/aswi/model/table/ValueFunction.java | ||
---|---|---|
6 | 6 |
*/ |
7 | 7 |
public class ValueFunction { |
8 | 8 |
|
9 |
/** |
|
10 |
* Result of COUNT function. |
|
11 |
*/ |
|
9 | 12 |
private double totalResult = 0.0; |
10 | 13 |
|
14 |
/** |
|
15 |
* Result of count of AVG function. |
|
16 |
*/ |
|
11 | 17 |
private double totalResultAvg; |
12 | 18 |
|
19 |
/** |
|
20 |
* Result of sum of AVG function. |
|
21 |
*/ |
|
13 | 22 |
private double totalResultAvgSum; |
14 | 23 |
|
24 |
/** |
|
25 |
* Result of SUM function. |
|
26 |
*/ |
|
15 | 27 |
private double totalResultSum; |
16 | 28 |
|
29 |
/** |
|
30 |
* Result of MIN function. |
|
31 |
*/ |
|
17 | 32 |
private double totalMin; |
18 | 33 |
|
34 |
/** |
|
35 |
* Result of MAX function. |
|
36 |
*/ |
|
19 | 37 |
private double totalMax; |
20 | 38 |
|
39 |
/** |
|
40 |
* Tells if the counted value is the first value of the MIN function. |
|
41 |
*/ |
|
21 | 42 |
private boolean isFirstMin = true; |
22 | 43 |
|
44 |
/** |
|
45 |
* Tells if the counted value is the first value of the MAX function. |
|
46 |
*/ |
|
23 | 47 |
private boolean isFirstMax = true; |
24 | 48 |
|
49 |
/** |
|
50 |
* Tells if total value of a column is filled. |
|
51 |
*/ |
|
25 | 52 |
private boolean isFilledTotalValue = false; |
26 | 53 |
|
27 | 54 |
/** |
28 |
* Value
|
|
55 |
* Name of chosen value row in the original table.
|
|
29 | 56 |
*/ |
30 | 57 |
private String nameOfSelect; |
31 | 58 |
|
32 |
private String name; |
|
59 |
/** |
|
60 |
* Name of the value's parameter.. |
|
61 |
*/ |
|
62 |
private String parameterName; |
|
33 | 63 |
|
34 | 64 |
/** |
35 |
* Function
|
|
65 |
* Name of function this class represents.
|
|
36 | 66 |
*/ |
37 | 67 |
private String function; |
38 | 68 |
|
69 |
/** |
|
70 |
* Type of the value (number, date, etc.). |
|
71 |
*/ |
|
39 | 72 |
private String type; |
40 | 73 |
|
41 | 74 |
/** |
... | ... | |
43 | 76 |
* @param nameOfSelect value |
44 | 77 |
* @param function function |
45 | 78 |
*/ |
46 |
public ValueFunction(String nameOfSelect, String name, String function, String type) {
|
|
79 |
public ValueFunction(String nameOfSelect, String parameterName, String function, String type) {
|
|
47 | 80 |
this.nameOfSelect = nameOfSelect; |
48 |
this.name = name;
|
|
81 |
this.parameterName = parameterName;
|
|
49 | 82 |
this.function = function; |
50 | 83 |
this.type = type; |
51 | 84 |
} |
52 | 85 |
|
53 | 86 |
/** |
54 |
* Gets value.
|
|
55 |
* @return value
|
|
87 |
* Gets name of chosen value row in the original table.
|
|
88 |
* @return Name of chosen value row in the original table.
|
|
56 | 89 |
*/ |
57 | 90 |
public String getNameOfSelect() { |
58 | 91 |
return nameOfSelect; |
59 | 92 |
} |
60 | 93 |
|
61 | 94 |
/** |
62 |
* Sets value.
|
|
63 |
* @param nameOfSelect value
|
|
95 |
* Sets name of chosen value row in the original table.
|
|
96 |
* @param nameOfSelect Name of chosen value row in the original table.
|
|
64 | 97 |
*/ |
65 | 98 |
public void setNameOfSelect(String nameOfSelect) { |
66 | 99 |
this.nameOfSelect = nameOfSelect; |
67 | 100 |
} |
68 | 101 |
|
69 |
public String getName() { |
|
70 |
return name; |
|
102 |
/** |
|
103 |
* Gets the name of the value's parameter. |
|
104 |
* @return Name of the value's parameter. |
|
105 |
*/ |
|
106 |
public String getParameterName() { |
|
107 |
return parameterName; |
|
71 | 108 |
} |
72 | 109 |
|
73 |
public void setName(String name) {
|
|
74 |
this.name = name;
|
|
110 |
public void setParameterName(String parameterName) {
|
|
111 |
this.parameterName = parameterName;
|
|
75 | 112 |
} |
76 | 113 |
|
77 | 114 |
/** |
78 |
* Gets function.
|
|
79 |
* @return function
|
|
115 |
* Gets name of function this class represents.
|
|
116 |
* @return Name of function this class represents.
|
|
80 | 117 |
*/ |
81 | 118 |
public String getFunction() { |
82 | 119 |
return function; |
83 | 120 |
} |
84 | 121 |
|
85 | 122 |
/** |
86 |
* Sets function.
|
|
87 |
* @param function function.
|
|
123 |
* Sets name of function this class represents.
|
|
124 |
* @param function Name of function this class represents.
|
|
88 | 125 |
*/ |
89 | 126 |
public void setFunction(String function) { |
90 | 127 |
this.function = function; |
91 | 128 |
} |
92 | 129 |
|
130 |
/** |
|
131 |
* Gets the type of the value (number, date, etc.). |
|
132 |
* @return Type of the value. |
|
133 |
*/ |
|
93 | 134 |
public String getType() { |
94 | 135 |
return type; |
95 | 136 |
} |
96 | 137 |
|
138 |
/** |
|
139 |
* Sets the type of the value (number, date, etc.). |
|
140 |
* @param type Type of the value. |
|
141 |
*/ |
|
97 | 142 |
public void setType(String type) { |
98 | 143 |
this.type = type; |
99 | 144 |
} |
100 | 145 |
|
146 |
/** |
|
147 |
* Gets the total result of COUNT function if this node represents a column. |
|
148 |
* @return Total result of COUNT function if this node represents a column. |
|
149 |
*/ |
|
101 | 150 |
public double getTotalResult() { |
102 | 151 |
return totalResult; |
103 | 152 |
} |
104 | 153 |
|
154 |
/** |
|
155 |
* Sets the total result of COUNT function if this node represents a column. |
|
156 |
* @param totalResult Total result to be set if this node represents a column. |
|
157 |
*/ |
|
105 | 158 |
public void setTotalResult(double totalResult) { |
106 | 159 |
this.totalResult = totalResult; |
107 | 160 |
} |
108 | 161 |
|
162 |
/** |
|
163 |
* Gets the total result of count of AVG function if this node represents a column. |
|
164 |
* @return Total result of count of AVG function if this node represents a column. |
|
165 |
*/ |
|
109 | 166 |
public double getTotalResultAvg() { |
110 | 167 |
return totalResultAvg; |
111 | 168 |
} |
112 | 169 |
|
170 |
/** |
|
171 |
* Sets the total result of of count of AVG function if this node represents a column. |
|
172 |
* @param totalResultAvg Total result to be set if this node represents a column. |
|
173 |
*/ |
|
113 | 174 |
public void setTotalResultAvg(double totalResultAvg) { |
114 | 175 |
this.totalResultAvg = totalResultAvg; |
115 | 176 |
} |
116 | 177 |
|
178 |
/** |
|
179 |
* Gets the total result of sum of AVG function if this node represents a column. |
|
180 |
* @return Total result of of sum of AVG function if this node represents a column. |
|
181 |
*/ |
|
117 | 182 |
public double getTotalResultAvgSum() { |
118 | 183 |
return totalResultAvgSum; |
119 | 184 |
} |
120 | 185 |
|
186 |
/** |
|
187 |
* Sets the total result of of sum of AVG function if this node represents a column. |
|
188 |
* @param totalResultAvgSum Total result to be set if this node represents a column. |
|
189 |
*/ |
|
121 | 190 |
public void setTotalResultAvgSum(double totalResultAvgSum) { |
122 | 191 |
this.totalResultAvgSum = totalResultAvgSum; |
123 | 192 |
} |
124 | 193 |
|
194 |
/** |
|
195 |
* Gets the total result of SUM function if this node represents a column. |
|
196 |
* @return Total result of SUM function if this node represents a column. |
|
197 |
*/ |
|
125 | 198 |
public double getTotalResultSum() { |
126 | 199 |
return totalResultSum; |
127 | 200 |
} |
128 | 201 |
|
202 |
/** |
|
203 |
* Sets the total result of SUM function if this node represents a column. |
|
204 |
* @param totalResultSum Total result to be set if this node represents a column. |
|
205 |
*/ |
|
129 | 206 |
public void setTotalResultSum(double totalResultSum) { |
130 | 207 |
this.totalResultSum = totalResultSum; |
131 | 208 |
} |
132 | 209 |
|
210 |
/** |
|
211 |
* Gets the total result of MIN function if this node represents a column. |
|
212 |
* @return Total result of MIN function if this node represents a column. |
|
213 |
*/ |
|
133 | 214 |
public double getTotalMin() { |
134 | 215 |
return totalMin; |
135 | 216 |
} |
136 | 217 |
|
218 |
/** |
|
219 |
* Sets the total result of MIN function if this node represents a column. |
|
220 |
* @param totalMin Total result to be set if this node represents a column. |
|
221 |
*/ |
|
137 | 222 |
public void setTotalMin(double totalMin) { |
138 | 223 |
this.totalMin = totalMin; |
139 | 224 |
} |
140 | 225 |
|
226 |
/** |
|
227 |
* Gets the total result of MAX function if this node represents a column. |
|
228 |
* @return Total result of MAX function if this node represents a column. |
|
229 |
*/ |
|
141 | 230 |
public double getTotalMax() { |
142 | 231 |
return totalMax; |
143 | 232 |
} |
144 | 233 |
|
234 |
/** |
|
235 |
* Sets the total result of MAX function if this node represents a column. |
|
236 |
* @param totalMax Total result to be set if this node represents a column. |
|
237 |
*/ |
|
145 | 238 |
public void setTotalMax(double totalMax) { |
146 | 239 |
this.totalMax = totalMax; |
147 | 240 |
} |
148 | 241 |
|
242 |
/** |
|
243 |
* Checks if the value if MIN function has been set if this node represents a column. |
|
244 |
* @return True of the value of MIN function has been set. |
|
245 |
*/ |
|
149 | 246 |
public boolean isFirstMin() { |
150 | 247 |
return isFirstMin; |
151 | 248 |
} |
152 | 249 |
|
250 |
/** |
|
251 |
* Set information that first MIN total value jas been set if this node represents a column. |
|
252 |
* @param firstMin Value whether total MIN value is set if this node represents a column. |
|
253 |
*/ |
|
153 | 254 |
public void setFirstMin(boolean firstMin) { |
154 | 255 |
isFirstMin = firstMin; |
155 | 256 |
} |
156 | 257 |
|
258 |
/** |
|
259 |
* Checks if the value if MAX function has been set if this node represents a column. |
|
260 |
* @return True of the value of MAX function has been set. |
|
261 |
*/ |
|
157 | 262 |
public boolean isFirstMax() { |
158 | 263 |
return isFirstMax; |
159 | 264 |
} |
160 | 265 |
|
266 |
/** |
|
267 |
* Set information that first MAX total value jas been set if this node represents a column. |
|
268 |
* @param firstMax Value whether total MAX value is set if this node represents a column. |
|
269 |
*/ |
|
161 | 270 |
public void setFirstMax(boolean firstMax) { |
162 | 271 |
isFirstMax = firstMax; |
163 | 272 |
} |
164 | 273 |
|
274 |
/** |
|
275 |
* Checks if a total value of a column this node represents is set. |
|
276 |
* @return True if one of the total values is set. |
|
277 |
*/ |
|
165 | 278 |
public boolean isFilledTotalValue() { |
166 | 279 |
return isFilledTotalValue; |
167 | 280 |
} |
168 | 281 |
|
282 |
/** |
|
283 |
* Sets if a total value of a column this node represents is set. |
|
284 |
* @param filledTotalValue Value whether a total value of a column this node represents is set. |
|
285 |
*/ |
|
169 | 286 |
public void setFilledTotalValue(boolean filledTotalValue) { |
170 | 287 |
isFilledTotalValue = filledTotalValue; |
171 | 288 |
} |
src/main/java/vldc/aswi/model/table/contingencyTable/ContingencyTableRowCell.java | ||
---|---|---|
46 | 46 |
return "(" + value + ", " + colSpan + ")"; |
47 | 47 |
} |
48 | 48 |
|
49 |
/** |
|
50 |
* Sets the colspan of a cell. |
|
51 |
* @param colSpan Colspan of a cell. |
|
52 |
*/ |
|
49 | 53 |
public void setColSpan(int colSpan) { |
50 | 54 |
this.colSpan = colSpan; |
51 | 55 |
} |
src/main/java/vldc/aswi/service/SqlQueryManager.java | ||
---|---|---|
1 | 1 |
package vldc.aswi.service; |
2 | 2 |
|
3 |
import vldc.aswi.domain.Assembly; |
|
3 | 4 |
import vldc.aswi.domain.Configuration; |
4 | 5 |
import vldc.aswi.domain.parameter.ParameterInConfiguration; |
5 | 6 |
import vldc.aswi.model.table.contingencyTable.ContingencyTableRow; |
... | ... | |
13 | 14 |
|
14 | 15 |
/** |
15 | 16 |
* Get list of contingencyTableRow. |
17 |
* @param assembly Assembly from which configuration was created. |
|
18 |
* @param parametersInConfiguration Parameters in configuration with their locations and operators. |
|
19 |
* @param isNotRemoveEmpty Sets if empty rows and columns should not be removed. |
|
16 | 20 |
* @return List of contingencyTableRow. |
17 | 21 |
*/ |
18 |
List<ContingencyTableRow> getContingencyTableRow(Configuration configuration); |
|
22 |
List<ContingencyTableRow> getContingencyTableRow(Assembly assembly, |
|
23 |
List<ParameterInConfiguration> parametersInConfiguration, |
|
24 |
boolean isNotRemoveEmpty); |
|
19 | 25 |
|
20 | 26 |
/** |
21 | 27 |
* Validate given SQL query. |
src/main/java/vldc/aswi/service/SqlQueryManagerImpl.java | ||
---|---|---|
4 | 4 |
import org.springframework.beans.factory.annotation.Autowired; |
5 | 5 |
import org.springframework.stereotype.Service; |
6 | 6 |
import vldc.aswi.database.DatabaseInterface; |
7 |
import vldc.aswi.domain.Assembly; |
|
7 | 8 |
import vldc.aswi.domain.Configuration; |
8 | 9 |
import vldc.aswi.domain.Function; |
9 | 10 |
import vldc.aswi.domain.parameter.ParameterInConfiguration; |
... | ... | |
31 | 32 |
|
32 | 33 |
/** |
33 | 34 |
* Get list of contingencyTableRow. |
34 |
* |
|
35 |
* @param configuration - configuration from which table will be created. |
|
35 |
* @param assembly Assembly from which configuration was created. |
|
36 |
* @param parametersInConfiguration Parameters in configuration with their locations and operators. |
|
37 |
* @param isNotRemoveEmpty Sets if empty rows and columns should not be removed. |
|
36 | 38 |
* @return List of contingencyTableRow. |
37 | 39 |
*/ |
38 | 40 |
@Override |
39 |
public List<ContingencyTableRow> getContingencyTableRow(Configuration configuration) { |
|
41 |
public List<ContingencyTableRow> getContingencyTableRow(Assembly assembly, |
|
42 |
List<ParameterInConfiguration> parametersInConfiguration, |
|
43 |
boolean isNotRemoveEmpty) { |
|
40 | 44 |
long startTime = System.nanoTime(); |
41 | 45 |
|
42 | 46 |
Map<String, TableColumn> tableColumns = this.databaseInterface.executeQueryAndReturnTableColumns( |
43 |
generateFullSQLQuery(configuration.getAssembly().getSQLQuery(), configuration.getParametersInConfiguration())
|
|
47 |
generateFullSQLQuery(assembly.getSQLQuery(), parametersInConfiguration)
|
|
44 | 48 |
); |
45 | 49 |
|
46 | 50 |
long stopTime = System.nanoTime(); |
... | ... | |
50 | 54 |
List<ValueFunction> valueFunctions = new ArrayList<>(); |
51 | 55 |
|
52 | 56 |
// Create a copy of list. |
53 |
List<ParameterInConfiguration> copiedParametersInConfiguration = new ArrayList<>(configuration.getParametersInConfiguration());
|
|
57 |
List<ParameterInConfiguration> copiedParametersInConfiguration = new ArrayList<>(parametersInConfiguration);
|
|
54 | 58 |
|
55 | 59 |
// sort parameters in configuration to have them in order set by user |
56 | 60 |
Collections.sort(copiedParametersInConfiguration); |
57 | 61 |
|
58 | 62 |
initializeContingencyTableDataLists(rowNames, columnNames, valueFunctions, copiedParametersInConfiguration); |
59 | 63 |
|
60 |
Converter converter = new Converter(tableColumns, rowNames, columnNames, valueFunctions, true);
|
|
64 |
Converter converter = new Converter(tableColumns, rowNames, columnNames, valueFunctions, isNotRemoveEmpty);
|
|
61 | 65 |
return converter.convertTableColumnsToContingencyTableRows(); |
62 | 66 |
} |
63 | 67 |
|
... | ... | |
83 | 87 |
private void initializeContingencyTableDataLists(List<NameUserName> rowNames, List<NameUserName> columnNames, |
84 | 88 |
List<ValueFunction> valueFunctions, List<ParameterInConfiguration> parametersInConfiguration) { |
85 | 89 |
for (ParameterInConfiguration parameterInConfiguration : parametersInConfiguration) { |
86 |
if (parameterInConfiguration.getLocation() != null && parameterInConfiguration.getLocation().getName().equals("Řádek")) { |
|
87 |
rowNames.add(new NameUserName(parameterInConfiguration.getParameter().getNameOfSelect().toUpperCase(), |
|
88 |
parameterInConfiguration.getColumnName())); |
|
89 |
} else if (parameterInConfiguration.getLocation() != null && parameterInConfiguration.getLocation().getName().equals("Sloupec")) { |
|
90 |
columnNames.add(new NameUserName(parameterInConfiguration.getParameter().getNameOfSelect().toUpperCase(), |
|
91 |
parameterInConfiguration.getColumnName())); |
|
92 |
} else if (parameterInConfiguration.getLocation() != null && parameterInConfiguration.getLocation().getName().equals("Hodnota")) { |
|
90 |
if (parameterInConfiguration.getLocation().getName() != null && parameterInConfiguration.getLocation().getName().equals("Řádek")) { |
|
91 |
if (parameterInConfiguration.getColumnName() != null && !parameterInConfiguration.getColumnName().equals("")) { |
|
92 |
rowNames.add(new NameUserName(parameterInConfiguration.getParameter().getNameOfSelect().toUpperCase(), |
|
93 |
parameterInConfiguration.getColumnName())); |
|
94 |
} |
|
95 |
else { |
|
96 |
rowNames.add(new NameUserName(parameterInConfiguration.getParameter().getNameOfSelect().toUpperCase(), |
|
97 |
parameterInConfiguration.getParameter().getName())); |
|
98 |
} |
|
99 |
} else if (parameterInConfiguration.getLocation().getName() != null && parameterInConfiguration.getLocation().getName().equals("Sloupec")) { |
|
100 |
if (parameterInConfiguration.getColumnName() != null && !parameterInConfiguration.getColumnName().equals("")) { |
|
101 |
columnNames.add(new NameUserName(parameterInConfiguration.getParameter().getNameOfSelect().toUpperCase(), |
|
102 |
parameterInConfiguration.getColumnName())); |
|
103 |
} |
|
104 |
else { |
|
105 |
columnNames.add(new NameUserName(parameterInConfiguration.getParameter().getNameOfSelect().toUpperCase(), |
|
106 |
parameterInConfiguration.getParameter().getName())); |
|
107 |
} |
|
108 |
} else if (parameterInConfiguration.getLocation().getName() != null && parameterInConfiguration.getLocation().getName().equals("Hodnota")) { |
|
93 | 109 |
for (Function function : parameterInConfiguration.getFunctions()) { |
94 | 110 |
valueFunctions.add(new ValueFunction(parameterInConfiguration.getParameter().getNameOfSelect().toUpperCase(), |
95 | 111 |
parameterInConfiguration.getParameter().getName(), function.getName().toUpperCase(), |
... | ... | |
108 | 124 |
} |
109 | 125 |
} |
110 | 126 |
|
127 |
/** |
|
128 |
* Generates full SQL query with all the filters |
|
129 |
* @param basicSQLQuery SQL query saved in assembly |
|
130 |
* @param parametersInConfiguration Parameters in configuration. |
|
131 |
* @return SQL query with filters. |
|
132 |
*/ |
|
111 | 133 |
private String generateFullSQLQuery(String basicSQLQuery, List<ParameterInConfiguration> parametersInConfiguration) { |
112 | 134 |
StringBuilder finalSQLQuery = new StringBuilder("SELECT * FROM ("); |
113 | 135 |
finalSQLQuery.append(basicSQLQuery); |
... | ... | |
128 | 150 |
return finalSQLQuery.toString(); |
129 | 151 |
} |
130 | 152 |
|
153 |
/** |
|
154 |
* Precesses listing (enum) type. |
|
155 |
* @param parameterInConfiguration Listing type parameter iin configuration. |
|
156 |
* @param finalSQLQuery Resulting SQL query. |
|
157 |
* @param isWhereDefined Variable storing information if WHERE clause was defined in the resulting SQL query. |
|
158 |
* @return Information that WHERE clause was defined. |
|
159 |
*/ |
|
131 | 160 |
private boolean processListing(ParameterInConfiguration parameterInConfiguration, StringBuilder finalSQLQuery, boolean isWhereDefined) { |
132 | 161 |
if (!isWhereDefined) { |
133 | 162 |
finalSQLQuery.append(" WHERE "); |
... | ... | |
142 | 171 |
return true; |
143 | 172 |
} |
144 | 173 |
|
174 |
/** |
|
175 |
* Process filter of parameter in configuration. |
|
176 |
* @param parameterInConfiguration Parameter in configuration. |
|
177 |
* @param finalSQLQuery Resulting SQL query. |
|
178 |
* @param isWhereDefined Variable storing information if WHERE clause was defined in the resulting SQL query. |
|
179 |
* @return Information that WHERE clause was defined |
|
180 |
*/ |
|
145 | 181 |
private boolean processFilter(ParameterInConfiguration parameterInConfiguration, StringBuilder finalSQLQuery, boolean isWhereDefined) { |
146 | 182 |
String[] values = parameterInConfiguration.getOperatorValue().split(";"); |
147 | 183 |
if (!isWhereDefined) { |
... | ... | |
179 | 215 |
return true; |
180 | 216 |
} |
181 | 217 |
|
218 |
/** |
|
219 |
* Validate LIKE and NOT LIKE operator. |
|
220 |
* @param values Values set by user. |
|
221 |
* @param type Type of the parameter. |
|
222 |
* @return String to be added to SQL query. |
|
223 |
*/ |
|
182 | 224 |
private String likeNotLike(String[] values, String type) { |
183 | 225 |
StringBuilder SQLQueryPart = new StringBuilder(); |
184 | 226 |
addQuotes(type, SQLQueryPart); |
... | ... | |
188 | 230 |
return SQLQueryPart.toString(); |
189 | 231 |
} |
190 | 232 |
|
233 |
/** |
|
234 |
* Validate IN and NOT IN operator. |
|
235 |
* @param values Values set by user. |
|
236 |
* @param type Type of the parameter. |
|
237 |
* @return String to be added to SQL query. |
|
238 |
*/ |
|
191 | 239 |
private String inNotIn(String[] values, String type) { |
192 | 240 |
StringBuilder SQLQueryPart = new StringBuilder(); |
193 | 241 |
SQLQueryPart.append("("); |
... | ... | |
204 | 252 |
return SQLQueryPart.toString(); |
205 | 253 |
} |
206 | 254 |
|
255 |
/** |
|
256 |
* Validate BETWEEN and NOT BETWEEN operator. |
|
257 |
* @param values Values set by user. |
|
258 |
* @param type Type of the parameter. |
|
259 |
* @return String to be added to SQL query. |
|
260 |
*/ |
|
207 | 261 |
private String betweenNotBetween(String[] values, String type) { |
208 | 262 |
StringBuilder SQLQueryPart = new StringBuilder(); |
209 | 263 |
|
... | ... | |
220 | 274 |
return SQLQueryPart.toString(); |
221 | 275 |
} |
222 | 276 |
|
277 |
/** |
|
278 |
* Validate other operators. |
|
279 |
* @param values Values set by user. |
|
280 |
* @param type Type of the parameter. |
|
281 |
* @return String to be added to SQL query. |
|
282 |
*/ |
|
223 | 283 |
private String otherOperators(String[] values, String type) { |
224 | 284 |
StringBuilder SQLQueryPart = new StringBuilder(); |
225 | 285 |
|
... | ... | |
230 | 290 |
return SQLQueryPart.toString(); |
231 | 291 |
} |
232 | 292 |
|
293 |
/** |
|
294 |
* Adds quote to the value. |
|
295 |
* @param type Type Type of the parameter. |
|
296 |
* @param SQLQueryPart Appends quote to the final SQL query. |
|
297 |
*/ |
|
233 | 298 |
private void addQuotes(String type, StringBuilder SQLQueryPart) { |
234 | 299 |
if (type.equals("Text") || type.equals("Datum")) { |
235 | 300 |
SQLQueryPart.append("'"); |
src/main/java/vldc/aswi/service/parameter/ParameterManager.java | ||
---|---|---|
36 | 36 |
* @return true if all parameters was successfully deleted, false if not. |
37 | 37 |
*/ |
38 | 38 |
boolean deleteParameters(Long assemblyId); |
39 |
|
|
40 |
/** |
|
41 |
* Gets a parameter by its ID |
|
42 |
* @param id ID of the parameter |
|
43 |
* @return parameter with selected ID |
|
44 |
*/ |
|
45 |
Parameter getParameterById(Long id); |
|
39 | 46 |
} |
src/main/java/vldc/aswi/service/parameter/ParameterManagerImpl.java | ||
---|---|---|
494 | 494 |
return false; |
495 | 495 |
} |
496 | 496 |
} |
497 |
|
|
498 |
/** |
|
499 |
* Gets a parameter by its ID |
|
500 |
* @param id ID of the parameter |
|
501 |
* @return parameter with selected ID |
|
502 |
*/ |
|
503 |
public Parameter getParameterById(Long id) { |
|
504 |
return parameterRepository.getById(id); |
|
505 |
} |
|
497 | 506 |
} |
src/main/java/vldc/aswi/utils/Converter.java | ||
---|---|---|
11 | 11 |
import java.util.concurrent.TimeUnit; |
12 | 12 |
|
13 | 13 |
/** |
14 |
* Class for converting classes.
|
|
14 |
* Class used to convert original table to contingency table.
|
|
15 | 15 |
*/ |
16 | 16 |
public class Converter { |
17 | 17 |
|
18 |
/** |
|
19 |
* Stores information about whether user set switch to show empty rows and columns to ON. |
|
20 |
*/ |
|
18 | 21 |
private final boolean isNotRemoveEmpty; |
19 | 22 |
|
23 |
/** |
|
24 |
* Map of original table. |
|
25 |
*/ |
|
20 | 26 |
private final Map<String, TableColumn> tableColumns; |
27 |
|
|
28 |
/** |
|
29 |
* List of names and user names of selected rows. |
|
30 |
*/ |
|
21 | 31 |
private final List<NameUserName> rowNames; |
32 |
|
|
33 |
/** |
|
34 |
* List of names and user names of selected columns. |
|
35 |
*/ |
|
22 | 36 |
private final List<NameUserName> columnNames; |
37 |
|
|
38 |
/** |
|
39 |
* List of information about selected value and functions. |
|
40 |
*/ |
|
23 | 41 |
private final List<ValueFunction> valueFunctions; |
24 | 42 |
|
43 |
/** |
|
44 |
* List of columns node of contingency table going from left to right. |
|
45 |
*/ |
|
25 | 46 |
private List<Node> columnNodes; |
47 |
|
|
48 |
/** |
|
49 |
* Formatter of the cell content. |
|
50 |
*/ |
|
26 | 51 |
private final DecimalFormat decimalFormat = new DecimalFormat("0.###"); |
27 | 52 |
|
53 |
/** |
|
54 |
* Creates and initializes converter. |
|
55 |
* @param tableColumns Map of original table. |
|
56 |
* @param rowNames List of names and user names of selected rows. |
|
57 |
* @param columnNames List of names and user names of selected columns. |
|
58 |
* @param valueFunctions List of information about selected value and functions. |
|
59 |
* @param isNotRemoveEmpty Stores information about whether user set switch to show empty rows and columns to ON. |
|
60 |
*/ |
|
28 | 61 |
public Converter(Map<String, TableColumn> tableColumns, List<NameUserName> rowNames, List<NameUserName> columnNames, |
29 | 62 |
List<ValueFunction> valueFunctions, boolean isNotRemoveEmpty) { |
30 | 63 |
this.tableColumns = tableColumns; |
... | ... | |
126 | 159 |
List<String> prevValues = new ArrayList<>(); |
127 | 160 |
int prevSize = 0; |
128 | 161 |
for (ValueFunction valueFunction : valueFunctions) { |
129 |
headerRows.get(0).addTableRowCell(new ContingencyTableRowCell(valueFunction.getFunction() + " z " + valueFunction.getName(), 0)); |
|
162 |
headerRows.get(0).addTableRowCell(new ContingencyTableRowCell(valueFunction.getFunction() + " z " + valueFunction.getParameterName(), 0));
|
|
130 | 163 |
for (Node columnNode : columnNodes) { |
131 | 164 |
for (int i = 0; i < columnNode.getValues().size(); i++) { |
132 | 165 |
String value = columnNode.getValues().get(i); |
... | ... | |
162 | 195 |
headerRows.get(i).addTableRowCell(new ContingencyTableRowCell("", 1)); |
163 | 196 |
} |
164 | 197 |
headerRows.get(0).addTableRowCell(new ContingencyTableRowCell("Celkový " + valueFunction.getFunction() + |
165 |
" z " + valueFunction.getName(), 1)); |
|
198 |
" z " + valueFunction.getParameterName(), 1));
|
|
166 | 199 |
} |
167 | 200 |
|
168 | 201 |
return headerRows; |
... | ... | |
315 | 348 |
} |
316 | 349 |
|
317 | 350 |
DoubleWrapper[] totals = new DoubleWrapper[valueFunctions.size()]; |
318 |
initializeWrapperField(totals); |
|
351 |
initializeDoubleWrapperField(totals);
|
|
319 | 352 |
|
320 | 353 |
DoubleWrapper[] totalsAvgSum = new DoubleWrapper[valueFunctions.size()]; |
321 |
initializeWrapperField(totalsAvgSum); |
|
354 |
initializeDoubleWrapperField(totalsAvgSum);
|
|
322 | 355 |
|
323 | 356 |
boolean[] isFilledValueCells = new boolean[valueFunctions.size()]; |
324 | 357 |
//hodnota |
... | ... | |
419 | 452 |
return ids; |
420 | 453 |
} |
421 | 454 |
|
455 |
/** |
|
456 |
* Checks if column is usable by going through all values of columns of a node in the original table. |
|
457 |
* @param columnNodeValues Values of a column node. |
|
458 |
* @return True if all values of a node are present in the original table columns. |
|
459 |
*/ |
|
422 | 460 |
private boolean checkIfColumnIsUsable(List<String> columnNodeValues) { |
423 | 461 |
for (int i = 0; i < tableColumns.get(columnNames.get(0).getName()).getValues().size(); i++) { |
424 | 462 |
boolean isUsable = true; |
... | ... | |
437 | 475 |
return false; |
438 | 476 |
} |
439 | 477 |
|
478 |
/** |
|
479 |
* Computes value of the cell in regards to function. |
|
480 |
* @param valueFunction Function that should be computed for a cell. |
|
481 |
* @param result Variable to which result is saved. |
|
482 |
* @param resultAvgSum Variable to which sum is saved of a function is AVG. |
|
483 |
* @param columnNode Column node of a cell. |
|
484 |
* @param isFirstMinMax Tells if the counted value is the first value of the MIN or MAX function. |
|
485 |
* @param usableID ID of the row in the original table. |
|
486 |
* @param isValueTotal Tells if a value is total value for the given function. |
|
487 |
* @param isSingleValueRow Tells whether a row only has single value (only represents one column of the original table). |
|
488 |
*/ |
|
440 | 489 |
private void computeValues(ValueFunction valueFunction, DoubleWrapper result, DoubleWrapper resultAvgSum, Node columnNode, |
441 | 490 |
BooleanWrapper isFirstMinMax, int usableID, boolean isValueTotal, boolean isSingleValueRow) { |
442 | 491 |
switch (valueFunction.getFunction()) { |
... | ... | |
458 | 507 |
} |
459 | 508 |
} |
460 | 509 |
|
510 |
/** |
|
511 |
* Generates a cell with filled data. |
|
512 |
* @param function Name of the function. |
|
513 |
* @param totalResult Result of COUNT function to be saved. |
|
514 |
* @param totalResultSum Result of SUM function to be saved. |
|
515 |
* @param totalMin Result of MIN function to be saved. |
|
516 |
* @param totalMax Result of MAX function to be saved. |
|
517 |
* @param totalResultAvgSum Result of sum of AVG function to be saved. |
|
518 |
* @param totalResultAvg Result of count of AVG function to be saved. |
|
519 |
* @return Generated and filled cell. |
|
520 |
*/ |
|
461 | 521 |
private ContingencyTableRowCell generateFilledCell(String function, double totalResult, double totalResultSum, |
462 | 522 |
double totalMin, double totalMax, double totalResultAvgSum, |
463 | 523 |
double totalResultAvg) { |
... | ... | |
487 | 547 |
return cell; |
488 | 548 |
} |
489 | 549 |
|
490 |
private void initializeWrapperField(DoubleWrapper[] field) { |
|
550 |
/** |
|
551 |
* Initializes a filled of the values of a DoubleWrapper type. |
|
552 |
* @param field Field to be initialized. |
|
553 |
*/ |
|
554 |
private void initializeDoubleWrapperField(DoubleWrapper[] field) { |
|
491 | 555 |
for (int i = 0; i < field.length; i++) { |
492 | 556 |
field[i] = new DoubleWrapper(0); |
493 | 557 |
} |
494 | 558 |
} |
495 | 559 |
|
560 |
/** |
|
561 |
* Calculates COUNT function. |
|
562 |
* @param valueFunction Function that should be computed for a cell. |
|
563 |
* @param result Variable to which result is saved. |
|
564 |
* @param columnNode Column node of a cell. |
|
565 |
* @param isValueTotal Tells if a value is total value for the given function. |
|
566 |
* @param isSingleValueRow Tells whether a row only has single value (only represents one column of the original table). |
|
567 |
*/ |
|
496 | 568 |
private void count(ValueFunction valueFunction, DoubleWrapper result, Node columnNode, boolean isValueTotal, |
497 | 569 |
boolean isSingleValueRow) { |
498 | 570 |
result.setValue(result.getValue() + 1); |
... | ... | |
504 | 576 |
} |
505 | 577 |
} |
506 | 578 |
|
579 |
/** |
|
580 |
* Calculates SUM function. |
|
581 |
* @param valueFunction Function that should be computed for a cell. |
|
582 |
* @param result Variable to which result is saved. |
|
583 |
* @param columnNode Column node of a cell. |
|
584 |
* @param usableID ID of the row in the original table. |
|
585 |
* @param isValueTotal Tells if a value is total value for the given function. |
|
586 |
* @param isSingleValueRow Tells whether a row only has single value (only represents one column of the original table). |
|
587 |
*/ |
|
507 | 588 |
private void sum(ValueFunction valueFunction, DoubleWrapper result, Node columnNode, int usableID, boolean isValueTotal, |
508 | 589 |
boolean isSingleValueRow) { |
509 | 590 |
if (valueFunction.getType().equals("Číslo")) { |
... | ... | |
517 | 598 |
} |
518 | 599 |
} |
519 | 600 |
|
601 |
/** |
|
602 |
* Calculates MIN function. |
|
603 |
* @param valueFunction Function that should be computed for a cell. |
|
604 |
* @param result Variable to which result is saved. |
|
605 |
* @param columnNode Column node of a cell. |
|
606 |
* @param isFirstMinMax Tells if the counted value is the first value of the MIN or MAX function. |
|
607 |
* @param usableID ID of the row in the original table. |
|
608 |
* @param isValueTotal Tells if a value is total value for the given function. |
|
609 |
* @param isSingleValueRow Tells whether a row only has single value (only represents one column of the original table). |
|
610 |
*/ |
|
520 | 611 |
private void min(ValueFunction valueFunction, DoubleWrapper result, Node columnNode, BooleanWrapper isFirstMinMax, |
521 | 612 |
int usableID, boolean isValueTotal, boolean isSingleValueRow) { |
522 | 613 |
if (valueFunction.getType().equals("Číslo")) { |
... | ... | |
546 | 637 |
} |
547 | 638 |
} |
548 | 639 |
|
640 |
/** |
|
641 |
* Calculates MAX function. |
|
642 |
* @param valueFunction Function that should be computed for a cell. |
|
643 |
* @param result Variable to which result is saved. |
|
644 |
* @param columnNode Column node of a cell. |
|
645 |
* @param isFirstMinMax Tells if the counted value is the first value of the MIN or MAX function. |
|
646 |
* @param usableID ID of the row in the original table. |
|
647 |
* @param isValueTotal Tells if a value is total value for the given function. |
|
648 |
* @param isSingleValueRow Tells whether a row only has single value (only represents one column of the original table). |
|
649 |
*/ |
|
549 | 650 |
private void max(ValueFunction valueFunction, DoubleWrapper result, Node columnNode, BooleanWrapper isFirstMinMax, |
550 | 651 |
int usableID, boolean isValueTotal, boolean isSingleValueRow) { |
551 | 652 |
if (valueFunction.getType().equals("Číslo")) { |
... | ... | |
575 | 676 |
} |
576 | 677 |
} |
577 | 678 |
|
679 |
/** |
|
680 |
* Calculates AVG function. |
|
681 |
* @param valueFunction Function that should be computed for a cell. |
|
682 |
* @param result Variable to which count result is saved. |
|
683 |
* @param resultAvgSum Variable to which sum result is saved. |
|
684 |
* @param columnNode Column node of a cell. |
|
685 |
* @param usableID ID of the row in the original table. |
|
686 |
* @param isValueTotal Tells if a value is total value for the given function. |
|
687 |
* @param isSingleValueRow Tells whether a row only has single value (only represents one column of the original table). |
|
688 |
*/ |
|
578 | 689 |
private void average(ValueFunction valueFunction, DoubleWrapper result, DoubleWrapper resultAvgSum, Node columnNode, |
579 | 690 |
int usableID, boolean isValueTotal, boolean isSingleValueRow) { |
580 | 691 |
if (valueFunction.getType().equals("Číslo")) { |
... | ... | |
591 | 702 |
} |
592 | 703 |
} |
593 | 704 |
|
705 |
/** |
|
706 |
* Generates a final row, with total values of columns. |
|
707 |
* @return Final row filled with data. |
|
708 |
*/ |
|
594 | 709 |
private ContingencyTableRow createFinalRow() { |
595 | 710 |
ContingencyTableRow finalRow = new ContingencyTableRow(false, 0); |
596 | 711 |
finalRow.addTableRowCell(new ContingencyTableRowCell("Celkem", 1)); |
src/main/java/vldc/aswi/validators/ConfigurationValidator.java | ||
---|---|---|
29 | 29 |
return Configuration.class.isAssignableFrom(aClass); |
30 | 30 |
} |
31 | 31 |
|
32 |
/** |
|
33 |
* Validates the given configuration object. |
|
34 |
* @param obj Configuration object to be validated. |
|
35 |
* @param errors Errors variable where errors are stored. |
|
36 |
*/ |
|
32 | 37 |
@Override |
33 | 38 |
public void validate(Object obj, Errors errors) { |
34 | 39 |
Configuration configuration = (Configuration) obj; |
... | ... | |
56 | 61 |
|
57 | 62 |
} |
58 | 63 |
|
64 |
/** |
|
65 |
* Validates BETWEEN and NOT BETWEEN operator. |
|
66 |
* @param parameterInConfiguration Parameter in configuration to be validated. |
|
67 |
* @param errors Errors variable where errors are stored. |
|
68 |
* @param i Index of the parameter. |
|
69 |
* @param operator Operator of the parameter in configuration. |
|
70 |
*/ |
|
59 | 71 |
private void validateBETWEEN(ParameterInConfiguration parameterInConfiguration, Errors errors, int i, String operator) { |
60 | 72 |
if (!parameterInConfiguration.getOperatorValue().matches("\\w+;\\w+")) { |
61 | 73 |
errors.rejectValue("parametersInConfiguration[" + i + "].operatorValue", "Nesprávně oddělené hodnoty" + |
... | ... | |
66 | 78 |
} |
67 | 79 |
} |
68 | 80 |
|
81 |
/** |
|
82 |
* Validates values in list. |
|
83 |
* @param parameterInConfiguration Parameter in configuration to be validated. |
|
84 |
* @param errors Errors variable where errors are stored. |
|
85 |
* @param i Index of the parameter. |
|
86 |
* @param operator Operator of the parameter in configuration. |
|
87 |
*/ |
|
69 | 88 |
private void validateValuesInList(ParameterInConfiguration parameterInConfiguration, Errors errors, int i, String operator) { |
70 | 89 |
String[] values = parameterInConfiguration.getOperatorValue().split(";"); |
71 | 90 |
for (String value : values) { |
... | ... | |
78 | 97 |
} |
79 | 98 |
} |
80 | 99 |
|
100 |
/** |
|
101 |
* Validates IN and NOT IN operator. |
|
102 |
* @param parameterInConfiguration Parameter in configuration to be validated. |
|
103 |
* @param errors Errors variable where errors are stored. |
|
104 |
* @param i Index of the parameter. |
|
105 |
* @param operator Operator of the parameter in configuration. |
|
106 |
*/ |
|
81 | 107 |
private void validateIN(ParameterInConfiguration parameterInConfiguration, Errors errors, int i, String operator) { |
82 | 108 |
if (!parameterInConfiguration.getOperatorValue().matches("\\w+(;\\w+)*$")) { |
83 | 109 |
errors.rejectValue("parametersInConfiguration[" + i + "].operatorValue", "Špatně zadaná hodnota" + |
... | ... | |
88 | 114 |
} |
89 | 115 |
} |
90 | 116 |
|
117 |
/** |
|
118 |
* Validates other operators. |
|
119 |
* @param parameterInConfiguration Parameter in configuration to be validated. |
|
120 |
* @param errors Errors variable where errors are stored. |
|
121 |
* @param i Index of the parameter. |
|
122 |
* @param operator Operator of the parameter in configuration. |
|
123 |
*/ |
|
91 | 124 |
private void validateOthersExceptLIKE(ParameterInConfiguration parameterInConfiguration, Errors errors, int i, String operator) { |
92 | 125 |
if (parameterInConfiguration.getParameter().getParameterType().getName().equals("Datum")) { |
93 | 126 |
validateDate(parameterInConfiguration.getOperatorValue(), errors, i, operator); |
... | ... | |
97 | 130 |
} |
98 | 131 |
} |
99 | 132 |
|
133 |
/** |
|
134 |
* Validates numeric value. |
|
135 |
* @param value Value to be validated. |
|
136 |
* @param errors Errors variable where errors are stored. |
|
137 |
* @param i Index of hte parameter. |
|
138 |
* @param operator operator Operator of the parameter in configuration. |
|
139 |
*/ |
|
100 | 140 |
private void validateNumber(String value, Errors errors, int i, String operator) { |
101 | 141 |
if (!value.matches("-?\\d+(\\.\\d+)?")) { |
102 | 142 |
errors.rejectValue("parametersInConfiguration[" + i + "].operatorValue", "Špatně zadaná hodnota" + |
... | ... | |
104 | 144 |
} |
105 | 145 |
} |
106 | 146 |
|
147 |
/** |
|
148 |
* Validates date value. |
|
149 |
* @param value Value to be validated. |
|
150 |
* @param errors Errors variable where errors are stored. |
|
151 |
* @param i Index of hte parameter. |
|
152 |
* @param operator operator Operator of the parameter in configuration. |
|
153 |
*/ |
|
107 | 154 |
private void validateDate(String value, Errors errors, int i, String operator) { |
108 | 155 |
try { |
109 | 156 |
new SimpleDateFormat("yyyy-MM-dd").parse(value); |
src/main/java/vldc/aswi/web/controller/AssemblyController.java | ||
---|---|---|
6 | 6 |
import org.springframework.validation.BeanPropertyBindingResult; |
7 | 7 |
import org.springframework.validation.BindingResult; |
8 | 8 |
import org.springframework.web.bind.WebDataBinder; |
9 |
import org.springframework.web.bind.annotation.GetMapping; |
|
10 |
import org.springframework.web.bind.annotation.InitBinder; |
|
11 |
import org.springframework.web.bind.annotation.ModelAttribute; |
|
12 |
import org.springframework.web.bind.annotation.PostMapping; |
|
13 |
import org.springframework.web.bind.annotation.RequestParam; |
|
9 |
import org.springframework.web.bind.annotation.*; |
|
14 | 10 |
import org.springframework.web.servlet.ModelAndView; |
15 | 11 |
import org.springframework.web.servlet.mvc.support.RedirectAttributes; |
16 | 12 |
import vldc.aswi.domain.*; |
17 | 13 |
import vldc.aswi.domain.parameter.Parameter; |
18 | 14 |
import vldc.aswi.domain.parameter.ParameterInConfiguration; |
15 |
import vldc.aswi.model.table.BooleanWrapper; |
|
19 | 16 |
import vldc.aswi.model.table.contingencyTable.ContingencyTableRow; |
20 | 17 |
import vldc.aswi.service.*; |
21 | 18 |
import vldc.aswi.service.parameter.ParameterManager; |
... | ... | |
26 | 23 |
import vldc.aswi.validators.ConfigurationValidator; |
27 | 24 |
|
28 | 25 |
import javax.validation.Valid; |
29 |
import java.util.ArrayList; |
|
30 |
import java.util.Comparator; |
|
31 |
import java.util.List; |
|
32 |
import java.util.Set; |
|
26 |
import java.util.*; |
|
33 | 27 |
import java.util.stream.Collectors; |
34 | 28 |
|
35 | 29 |
/** |
... | ... | |
46 | 40 |
@Autowired |
47 | 41 |
private AssemblyManager assemblyManager; |
48 | 42 |
|
43 |
/** Autowired parameter manager. */ |
|
44 |
@Autowired |
|
45 |
private ParameterManager parameterManager; |
|
46 |
|
|
49 | 47 |
/** Autowired configuration manager */ |
50 | 48 |
@Autowired |
51 | 49 |
private ConfigurationManager configurationManager; |
... | ... | |
70 | 68 |
@Autowired |
71 | 69 |
private LocationManager locationManager; |
72 | 70 |
|
73 |
/** Autowired parameter manager. */ |
|
74 |
@Autowired |
|
75 |
private ParameterManager parameterManager; |
|
76 |
|
|
77 | 71 |
/** Autowired assembly validator */ |
78 | 72 |
@Autowired |
79 | 73 |
private AssemblyValidator assemblyValidator; |
... | ... | |
148 | 142 |
|
149 | 143 |
Comparator<ParameterInConfiguration> comparator = Comparator.comparingInt(o -> o.getParameter().getParameterOrder()); |
150 | 144 |
|
145 |
boolean isNotRemoveEmpty = false; |
|
146 |
modelMap.addAttribute("isNotRemoveEmpty", isNotRemoveEmpty); |
|
151 | 147 |
modelMap.addAttribute("configuration", configuration); |
152 | 148 |
modelMap.addAttribute("comparator", comparator); |
153 | 149 |
modelMap.addAttribute("formAction", "/assembly?assemblyID=" + assembly.getId()); |
... | ... | |
167 | 163 |
public ModelAndView assemblyPost(Configuration newConfiguration, |
168 | 164 |
BindingResult bindingResult, |
169 | 165 |
RedirectAttributes atts, |
166 |
@RequestParam("isNotRemoveEmpty") String isNotRemoveEmptyString, |
|
170 | 167 |
@RequestParam("assemblyID") String id, |
171 | 168 |
@RequestParam(required=false, value="generateTable") String generateTable, |
172 | 169 |
@RequestParam(required=false, value="exportXls") String exportXls, |
... | ... | |
207 | 204 |
modelMap.addAttribute(assemblyTitleName, generateTableTitleText + " " + newConfiguration.getName()); |
208 | 205 |
} |
209 | 206 |
else { |
210 |
List<ContingencyTableRow> rows = this.sqlQueryManager.getContingencyTableRow(newConfiguration); |
|
207 |
boolean isNotRemoveEmpty = isNotRemoveEmptyString == null || !isNotRemoveEmptyString.equals(""); |
|
208 |
List<ContingencyTableRow> rows = this.sqlQueryManager.getContingencyTableRow(newConfiguration.getAssembly(), |
|
209 |
newConfiguration.getParametersInConfiguration(), isNotRemoveEmpty); |
|
211 | 210 |
|
212 | 211 |
System.out.println("Generuj tabulku"); |
213 | 212 |
modelMap.addAttribute("configurationID", id); |
214 | 213 |
modelMap.addAttribute("contingencyTableRows", rows); |
214 |
modelMap.addAttribute("isNotRemoveEmpty", isNotRemoveEmpty); |
|
215 | 215 |
addConfigurationDataIntoModelAndView(newConfiguration, modelAndView, modelMap); |
216 | 216 |
} |
217 | 217 |
} |
... | ... | |
254 | 254 |
*/ |
255 | 255 |
} |
256 | 256 |
|
257 |
/** |
|
258 |
* Adds configuration and other data to modelAndView. |
|
259 |
* @param newConfiguration Configuration to be added to the modelAndView. |
|
260 |
* @param modelAndView ModelAndView to which to which modelMap belongs. |
|
261 |
* @param modelMap ModelMap to which data is added. |
|
262 |
*/ |
|
257 | 263 |
private void addConfigurationDataIntoModelAndView(Configuration newConfiguration, ModelAndView modelAndView, ModelMap modelMap) { |
258 | 264 |
Comparator<ParameterInConfiguration> comparator = Comparator.comparingInt(o -> o.getParameter().getParameterOrder()); |
259 | 265 |
initializeFields(newConfiguration); |
... | ... | |
454 | 460 |
|
455 | 461 |
for(int i = 0; i < configuration.getParametersInConfiguration().size(); i++) { |
456 | 462 |
ParameterInConfiguration parameterInConfiguration = configuration.getParametersInConfiguration().get(i); |
457 |
parameterInConfiguration.setParameter(assembly.getParameters().get(i));
|
|
463 |
parameterInConfiguration.setParameter(parameterManager.getParameterById(parameterInConfiguration.getParameter().getId()));
|
|
458 | 464 |
if (parameterInConfiguration.getLocation() != null) { |
459 | 465 |
parameterInConfiguration.setLocation(locationManager.getLocationById(parameterInConfiguration.getLocation().getId())); |
466 |
} else { |
|
467 |
parameterInConfiguration.setLocation(new Location()); |
|
460 | 468 |
} |
469 |
parameterInConfiguration.setConfiguration(configuration); |
|
461 | 470 |
} |
471 |
|
|
472 |
Comparator<ParameterInConfiguration> comparator = Comparator.comparingInt(o -> o.getParameter().getParameterOrder()); |
|
473 |
configuration.getParametersInConfiguration().sort(comparator); |
|
462 | 474 |
} |
463 | 475 |
} |
src/main/java/vldc/aswi/web/controller/ConfigurationController.java | ||
---|---|---|
19 | 19 |
import vldc.aswi.service.ConfigurationManager; |
20 | 20 |
import vldc.aswi.service.LocationManager; |
21 | 21 |
import vldc.aswi.service.SqlQueryManager; |
22 |
import vldc.aswi.service.parameter.ParameterManager; |
|
22 | 23 |
import vldc.aswi.utils.AuthControl; |
23 | 24 |
import vldc.aswi.utils.Utils; |
24 | 25 |
import vldc.aswi.validators.AssemblyValidator; |
... | ... | |
47 | 48 |
@Autowired |
48 | 49 |
private SqlQueryManager sqlQueryManager; |
49 | 50 |
|
51 |
/** Autowired parameter manager. */ |
|
52 |
@Autowired |
|
53 |
private ParameterManager parameterManager; |
|
54 |
|
|
50 | 55 |
/** Autowired configuration manager */ |
51 | 56 |
@Autowired |
52 | 57 |
private ConfigurationManager configurationManager; |
... | ... | |
114 | 119 |
@PostMapping("/configuration") |
115 | 120 |
public ModelAndView configurationPost(@Valid Configuration newConfiguration, |
116 | 121 |
BindingResult bindingResult, |
122 |
@RequestParam("isNotRemoveEmpty") String isNotRemoveEmptyString, |
|
117 | 123 |
@RequestParam("configurationID") String id, |
118 | 124 |
@RequestParam(required=false, value="generateTable") String generateTable, |
119 | 125 |
@RequestParam(required=false, value="exportXls") String exportXls, |
... | ... | |
144 | 150 |
modelMap.addAttribute(assemblyTitleName, generateTableTitleText + " " + newConfiguration.getName()); |
145 | 151 |
} |
146 | 152 |
else { |
147 |
List<ContingencyTableRow> rows = this.sqlQueryManager.getContingencyTableRow(newConfiguration); |
|
153 |
boolean isNotRemoveEmpty = isNotRemoveEmptyString == null || !isNotRemoveEmptyString.equals(""); |
|
154 |
List<ContingencyTableRow> rows = this.sqlQueryManager.getContingencyTableRow(newConfiguration.getAssembly(), |
|
155 |
newConfiguration.getParametersInConfiguration(), isNotRemoveEmpty); |
|
148 | 156 |
System.out.println("Generuj tabulku"); |
149 | 157 |
modelMap.addAttribute("configurationID", id); |
150 | 158 |
modelMap.addAttribute("contingencyTableRows", rows); |
... | ... | |
232 | 240 |
|
233 | 241 |
for(int i = 0; i < configuration.getParametersInConfiguration().size(); i++) { |
234 | 242 |
ParameterInConfiguration parameterInConfiguration = configuration.getParametersInConfiguration().get(i); |
243 |
parameterInConfiguration.setParameter(parameterManager.getParameterById(parameterInConfiguration.getParameter().getId())); |
|
235 | 244 |
parameterInConfiguration.setParameter(assembly.getParameters().get(i)); |
236 | 245 |
if (parameterInConfiguration.getLocation() != null) { |
237 | 246 |
parameterInConfiguration.setLocation(locationManager.getLocationById(parameterInConfiguration.getLocation().getId())); |
247 |
} else { |
|
248 |
parameterInConfiguration.setLocation(new Location()); |
|
238 | 249 |
} |
250 |
parameterInConfiguration.setConfiguration(configuration); |
|
239 | 251 |
} |
252 |
|
|
253 |
Comparator<ParameterInConfiguration> comparator = Comparator.comparingInt(o -> o.getParameter().getParameterOrder()); |
|
254 |
configuration.getParametersInConfiguration().sort(comparator); |
|
240 | 255 |
} |
241 | 256 |
|
257 |
/** |
|
258 |
* Adds configuration and other data to modelAndView. |
|
259 |
* @param newConfiguration Configuration to be added to the modelAndView. |
|
260 |
* @param modelAndView ModelAndView to which to which modelMap belongs. |
|
261 |
* @param modelMap ModelMap to which data is added. |
|
262 |
*/ |
|
242 | 263 |
private void addConfigurationDataIntoModelAndView(Configuration newConfiguration, ModelAndView modelAndView, ModelMap modelMap) { |
243 | 264 |
Comparator<ParameterInConfiguration> comparator = Comparator.comparingInt(o -> o.getParameter().getParameterOrder()); |
244 | 265 |
initializeFields(newConfiguration); |
src/main/webapp/WEB-INF/templates/assembly.html | ||
---|---|---|
19 | 19 |
|
20 | 20 |
<form th:object="${configuration}" method="post" th:action="@{${formAction}}"> |
21 | 21 |
<input type="hidden" th:field="*{assembly.id}" th:value="${configuration.assembly?.getId()}"/> |
22 |
<input type="hidden" name="isNotRemoveEmpty"/> |
|
22 | 23 |
<div class="container box"> |
23 | 24 |
<div class="col-md-12"> |
24 | 25 |
<div class="col-md-12 form-group row"> |
... | ... | |
37 | 38 |
</tr> |
38 | 39 |
</thead> |
39 | 40 |
<tbody> |
40 |
<tr th:each="parameterInConfiguration, itemStat : ${#lists.sort(configuration.parametersInConfiguration, comparator)}" class="parameter-row"> |
|
41 |
<input type="hidden" class="parameterIndex" th:value="${itemStat.index}"> |
|
41 |
<tr th:each="parameterInConfiguration, itemStat : ${configuration.parametersInConfiguration}" class="parameter-row"> |
|
42 |
<input type="hidden" class="parameterIndex" th:value="${itemStat.index}"> |
|
43 |
<input type="hidden" th:field="${configuration.parametersInConfiguration[__${itemStat.index}__].parameter.id}"/> |
|
42 | 44 |
<td> |
43 | 45 |
<span class="select-text-padding parameter-name" |
44 | 46 |
th:text="${parameterInConfiguration.parameter.name}"></span> |
... | ... | |
200 | 202 |
</div> |
201 | 203 |
|
202 | 204 |
<div class="custom-control custom-switch form-group"> |
203 |
<input type="checkbox" class="custom-control-input" id="customSwitch1" checked>
|
|
205 |
<input type="checkbox" class="custom-control-input" id="customSwitch1" th:checked="${isNotRemoveEmpty}" name="isNotRemoveEmpty">
|
|
204 | 206 |
<label class="custom-control-label" for="customSwitch1">Zobrazovat prázdné řádky</label> |
205 | 207 |
</div> |
206 | 208 |
|
Také k dispozici: Unified diff
re #7885 #8134re #8154 re #8136 added comments and connected switch to allow user to set if he wants to see empty rows or columns in the final table