1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.extension.repository.search; |
21 |
|
|
22 |
|
import java.util.ArrayList; |
23 |
|
import java.util.Collection; |
24 |
|
import java.util.List; |
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
@version |
30 |
|
@since |
31 |
|
|
|
|
| 92.5% |
Uncovered Elements: 3 (40) |
Complexity: 15 |
Complexity Density: 0.6 |
|
32 |
|
public class ExtensionQuery |
33 |
|
{ |
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
@version |
38 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 0 |
Complexity Density: - |
|
39 |
|
public enum ORDER |
40 |
|
{ |
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
DESC, |
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
ASC; |
50 |
|
} |
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
@version |
56 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 0 |
Complexity Density: - |
|
57 |
|
public enum COMPARISON |
58 |
|
{ |
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
EQUAL, |
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
MATCH; |
68 |
|
} |
69 |
|
|
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
@version |
74 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 3 |
Complexity Density: 0.75 |
|
75 |
|
public static class SortClause |
76 |
|
{ |
77 |
|
private final String field; |
78 |
|
|
79 |
|
private final ORDER order; |
80 |
|
|
81 |
|
|
82 |
|
@param |
83 |
|
@param |
84 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
85 |
0 |
public SortClause(String field, ORDER order)... |
86 |
|
{ |
87 |
0 |
this.field = field; |
88 |
0 |
this.order = order; |
89 |
|
} |
90 |
|
|
91 |
|
|
92 |
|
@return |
93 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
94 |
0 |
public String getField()... |
95 |
|
{ |
96 |
0 |
return this.field; |
97 |
|
} |
98 |
|
|
99 |
|
|
100 |
|
@return |
101 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
102 |
0 |
public ORDER getOrder()... |
103 |
|
{ |
104 |
0 |
return this.order; |
105 |
|
} |
106 |
|
} |
107 |
|
|
108 |
|
|
109 |
|
|
110 |
|
|
111 |
|
@version |
112 |
|
|
|
|
| 55.6% |
Uncovered Elements: 8 (18) |
Complexity: 5 |
Complexity Density: 0.38 |
|
113 |
|
public static class Filter |
114 |
|
{ |
115 |
|
private final String field; |
116 |
|
|
117 |
|
private final Object value; |
118 |
|
|
119 |
|
private final COMPARISON comparison; |
120 |
|
|
121 |
|
|
122 |
|
@param |
123 |
|
@param |
124 |
|
@param |
125 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
126 |
6 |
public Filter(String field, Object value, COMPARISON comparison)... |
127 |
|
{ |
128 |
6 |
this.field = field; |
129 |
6 |
this.value = value; |
130 |
6 |
this.comparison = comparison; |
131 |
|
} |
132 |
|
|
133 |
|
|
134 |
|
@return |
135 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
136 |
85 |
public String getField()... |
137 |
|
{ |
138 |
85 |
return this.field; |
139 |
|
} |
140 |
|
|
141 |
|
|
142 |
|
@return |
143 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
144 |
142 |
public Object getValue()... |
145 |
|
{ |
146 |
142 |
return this.value; |
147 |
|
} |
148 |
|
|
149 |
|
|
150 |
|
@return |
151 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
152 |
112 |
public COMPARISON getComparison()... |
153 |
|
{ |
154 |
112 |
return this.comparison; |
155 |
|
} |
156 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
157 |
0 |
@Override... |
158 |
|
public String toString() |
159 |
|
{ |
160 |
0 |
StringBuilder builder = new StringBuilder(); |
161 |
|
|
162 |
0 |
builder.append(getField()); |
163 |
0 |
builder.append(' '); |
164 |
0 |
builder.append(getComparison()); |
165 |
0 |
builder.append(' '); |
166 |
0 |
builder.append(getValue()); |
167 |
|
|
168 |
0 |
return builder.toString(); |
169 |
|
} |
170 |
|
} |
171 |
|
|
172 |
|
private String query; |
173 |
|
|
174 |
|
private int limit = -1; |
175 |
|
|
176 |
|
private int offset; |
177 |
|
|
178 |
|
private List<SortClause> sortClauses = new ArrayList<>(); |
179 |
|
|
180 |
|
private List<Filter> filters = new ArrayList<>(); |
181 |
|
|
182 |
|
|
183 |
|
|
184 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
185 |
5 |
public ExtensionQuery()... |
186 |
|
{ |
187 |
|
} |
188 |
|
|
189 |
|
|
190 |
|
@param |
191 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
192 |
109 |
public ExtensionQuery(String query)... |
193 |
|
{ |
194 |
109 |
this.query = query; |
195 |
|
} |
196 |
|
|
197 |
|
|
198 |
|
@param |
199 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
200 |
13 |
public ExtensionQuery(ExtensionQuery query)... |
201 |
|
{ |
202 |
13 |
this.query = query.getQuery(); |
203 |
|
|
204 |
13 |
setOffset(query.getOffset()); |
205 |
13 |
setLimit(query.getLimit()); |
206 |
|
|
207 |
13 |
setSortClauses(query.getSortClauses()); |
208 |
13 |
setFilters(query.getFilters()); |
209 |
|
} |
210 |
|
|
211 |
|
|
212 |
|
@return |
213 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
214 |
117 |
public String getQuery()... |
215 |
|
{ |
216 |
117 |
return this.query; |
217 |
|
} |
218 |
|
|
219 |
|
|
220 |
|
@param |
221 |
|
@return |
222 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
223 |
122 |
public ExtensionQuery setLimit(int limit)... |
224 |
|
{ |
225 |
122 |
this.limit = limit; |
226 |
|
|
227 |
122 |
return this; |
228 |
|
} |
229 |
|
|
230 |
|
|
231 |
|
@param |
232 |
|
@return |
233 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
234 |
122 |
public ExtensionQuery setOffset(int offset)... |
235 |
|
{ |
236 |
122 |
this.offset = offset; |
237 |
|
|
238 |
122 |
return this; |
239 |
|
} |
240 |
|
|
241 |
|
|
242 |
|
@return |
243 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
244 |
545 |
public List<Filter> getFilters()... |
245 |
|
{ |
246 |
545 |
return this.filters; |
247 |
|
} |
248 |
|
|
249 |
|
|
250 |
|
@param |
251 |
|
@return |
252 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
253 |
13 |
public ExtensionQuery setFilters(Collection<Filter> filters)... |
254 |
|
{ |
255 |
13 |
this.filters = new ArrayList<>(filters); |
256 |
|
|
257 |
13 |
return this; |
258 |
|
} |
259 |
|
|
260 |
|
|
261 |
|
@param |
262 |
|
@param |
263 |
|
@param |
264 |
|
@return |
265 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
266 |
5 |
public ExtensionQuery addFilter(String field, Object value, COMPARISON comparison)... |
267 |
|
{ |
268 |
5 |
this.filters.add(new Filter(field, value, comparison)); |
269 |
|
|
270 |
5 |
return this; |
271 |
|
} |
272 |
|
|
273 |
|
|
274 |
|
@param |
275 |
|
@return |
276 |
|
@since |
277 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
278 |
13 |
public ExtensionQuery addFilters(List<Filter> newFilters)... |
279 |
|
{ |
280 |
13 |
this.filters.addAll(newFilters); |
281 |
|
|
282 |
13 |
return this; |
283 |
|
} |
284 |
|
|
285 |
|
|
286 |
|
@return |
287 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
288 |
93 |
public List<SortClause> getSortClauses()... |
289 |
|
{ |
290 |
93 |
return this.sortClauses; |
291 |
|
} |
292 |
|
|
293 |
|
|
294 |
|
@param |
295 |
|
@return |
296 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
297 |
13 |
public ExtensionQuery setSortClauses(Collection<SortClause> sortClauses)... |
298 |
|
{ |
299 |
13 |
this.sortClauses = new ArrayList<>(sortClauses); |
300 |
|
|
301 |
13 |
return this; |
302 |
|
} |
303 |
|
|
304 |
|
|
305 |
|
@param |
306 |
|
@param |
307 |
|
@return |
308 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
309 |
0 |
public ExtensionQuery addSort(String field, ORDER order)... |
310 |
|
{ |
311 |
0 |
this.sortClauses.add(new SortClause(field, order)); |
312 |
|
|
313 |
0 |
return this; |
314 |
|
} |
315 |
|
|
316 |
|
|
317 |
|
@return |
318 |
|
@see |
319 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
320 |
204 |
public int getLimit()... |
321 |
|
{ |
322 |
204 |
return this.limit; |
323 |
|
} |
324 |
|
|
325 |
|
|
326 |
|
@return |
327 |
|
@see |
328 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
329 |
234 |
public int getOffset()... |
330 |
|
{ |
331 |
234 |
return this.offset; |
332 |
|
} |
333 |
|
} |