|
42 | 42 | import java.util.ArrayList;
|
43 | 43 | import java.util.List;
|
44 | 44 | import java.util.Optional;
|
45 |
| -import java.util.function.BiFunction; |
46 |
| -import java.util.function.Function; |
47 | 45 | import java.util.function.IntFunction;
|
48 | 46 | import java.util.stream.Stream;
|
49 | 47 |
|
|
55 | 53 | import org.usf.jquery.core.JQueryType;
|
56 | 54 | import org.usf.jquery.core.JavaType;
|
57 | 55 | import org.usf.jquery.core.LogicalOperator;
|
| 56 | +import org.usf.jquery.core.NamedColumn; |
58 | 57 | import org.usf.jquery.core.OperationColumn;
|
59 | 58 | import org.usf.jquery.core.Order;
|
60 | 59 | import org.usf.jquery.core.ParameterSet;
|
61 | 60 | import org.usf.jquery.core.Partition;
|
| 61 | +import org.usf.jquery.core.QueryBuilder; |
62 | 62 | import org.usf.jquery.core.QueryColumn;
|
63 | 63 | import org.usf.jquery.core.QueryContext;
|
64 | 64 | import org.usf.jquery.core.QueryView;
|
65 |
| -import org.usf.jquery.core.QueryBuilder; |
66 |
| -import org.usf.jquery.core.NamedColumn; |
67 |
| -import org.usf.jquery.core.TypedComparator; |
68 | 65 | import org.usf.jquery.core.ViewColumn;
|
69 | 66 | import org.usf.jquery.core.ViewJoin;
|
70 | 67 |
|
@@ -251,15 +248,18 @@ public DBFilter evalFilter(ViewDecorator vd, QueryContext ctx, List<RequestEntry
|
251 | 248 | }
|
252 | 249 | }
|
253 | 250 | else if(nonNull(rc.col)) {
|
254 |
| - if(nonNull(rc.cmp)) { //column comparator |
255 |
| - var cp = new RequestEntryChain(rc.entry.value, false, null, rc.entry.assertOuterParameters(values), null); |
256 |
| - return rc.entry.chainComparator(vd, ctx, rc.cmp.filter(cp.toArgs(vd, ctx, rc.col, rc.cmp.getParameterSet()))); |
257 |
| - } |
258 | 251 | if(rc.entry.isLast()) { // no criteria, no comparator
|
259 | 252 | var fn = requireNonNull(values).size() == 1 ? eq() : in(); //non empty
|
260 | 253 | var e = new RequestEntryChain(null, false, null, values, null);
|
261 | 254 | return fn.filter(e.toArgs(vd, ctx, rc.col, fn.getParameterSet())); //no chain
|
262 | 255 | }
|
| 256 | + var e = rc.entry.next; |
| 257 | + var res = lookupComparator(e.value); |
| 258 | + if(res.isPresent()) { //column comparator |
| 259 | + var cmp = res.get(); |
| 260 | + var cp = new RequestEntryChain(e.value, false, null, e.assertOuterParameters(values), null); |
| 261 | + return e.chainComparator(vd, ctx, cmp.filter(cp.toArgs(vd, ctx, rc.col, cmp.getParameterSet()))); |
| 262 | + } |
263 | 263 | throw noSuchResourceException(isNull(rc.cd) ? "comparator" : "comparator|criteria", rc.entry.next.value);
|
264 | 264 | }
|
265 | 265 | throw new IllegalStateException("illegal ViewResource: " + rc);
|
@@ -292,7 +292,7 @@ DBFilter chainComparator(ViewDecorator td, QueryContext ctx, DBFilter f) {
|
292 | 292 |
|
293 | 293 | private ViewResource chainColumnOperations(ViewDecorator vd, QueryContext ctx, boolean filter) {
|
294 | 294 | var r = lookupResource(vd, ctx, filter);
|
295 |
| - if(!r.isFilter()) { // !criteria & !comparator |
| 295 | + if(!r.isCriteria()) { // !criteria & !comparator |
296 | 296 | var e = r.entry.next;
|
297 | 297 | while(nonNull(e)) { //chain until !operator
|
298 | 298 | var res = lookupOperator(e.value);
|
@@ -374,12 +374,8 @@ private Optional<ViewResource> lookupColumnResource(ViewDecorator td, boolean fi
|
374 | 374 | var cd = res.get();
|
375 | 375 | try {
|
376 | 376 | var col = td.column(cd); //throw exception
|
377 |
| - if(filter && hasNext()) { |
378 |
| - var cmp = lookupComparator(next.value); |
379 |
| - if(cmp.isPresent()) { |
380 |
| - return Optional.of(new ViewResource(requireNoArgs().next, td, cd, col, cmp.get())); |
381 |
| - } |
382 |
| - var crt = cd.criteria(next.value); //TD !operator |
| 377 | + if(filter && hasNext() && lookupComparator(next.value).isEmpty() && lookupOperator(next.value).isEmpty()) { |
| 378 | + var crt = cd.criteria(next.value); //!operator & !comparator |
383 | 379 | if(nonNull(crt)) {
|
384 | 380 | return Optional.of(new ViewResource(requireNoArgs().next, td, cd, col, crt));
|
385 | 381 | }
|
@@ -531,26 +527,17 @@ static final class ViewResource {
|
531 | 527 | private DBColumn col;
|
532 | 528 | private CriteriaBuilder<DBFilter> viewCrt;
|
533 | 529 | private CriteriaBuilder<ComparisonExpression> colCrt;
|
534 |
| - private TypedComparator cmp; |
535 | 530 |
|
536 | 531 | public ViewResource(RequestEntryChain entry, ViewDecorator vd, ColumnDecorator cd, DBColumn col) {
|
537 |
| - this(entry, vd, cd, col, null, null, null); //[view.]column |
| 532 | + this(entry, vd, cd, col, null, null); //[view.]column |
538 | 533 | }
|
539 | 534 |
|
540 | 535 | public ViewResource(RequestEntryChain entry, ViewDecorator vd, ColumnDecorator cd, DBColumn col, CriteriaBuilder<ComparisonExpression> colCrt) {
|
541 |
| - this(entry, vd, cd, col, null, colCrt, null); //[view.]colum.criteria |
542 |
| - } |
543 |
| - |
544 |
| - public ViewResource(RequestEntryChain entry, ViewDecorator vd, ColumnDecorator cd, DBColumn col, TypedComparator cmp) { |
545 |
| - this(entry, vd, cd, col, null, null, cmp); //[view.]colum.comparator |
| 536 | + this(entry, vd, cd, col, null, colCrt); //[view.]colum.criteria |
546 | 537 | }
|
547 | 538 |
|
548 | 539 | public ViewResource(RequestEntryChain entry, ViewDecorator vd, CriteriaBuilder<DBFilter> viewCrt) {
|
549 |
| - this(entry, vd, null, null, viewCrt, null, null); //[view.]criteria |
550 |
| - } |
551 |
| - |
552 |
| - boolean isFilter() { |
553 |
| - return nonNull(cmp) || isCriteria(); |
| 540 | + this(entry, vd, null, null, viewCrt, null); //[view.]criteria |
554 | 541 | }
|
555 | 542 |
|
556 | 543 | boolean isCriteria() {
|
|
0 commit comments