Skip to content

The logic of merging query parameters may not belong to this module #87

Description

@vlad-lubenskyi

In DsFilter::toFilters you can find a general logic of dividing query parameters into conjunctive and disjunctive.

It seems that this logic should be in core-java.

That's the code:

 /**
     * Performs the actual expression conversion.
     *
     * <p>This method divides the given params into conjunctive and disjunctive. The conjunctive
     * parameters are then merged into a single {@link Filter}. After that, the disjunction
     * parentheses are opened and the {@linkplain #multiply logical multiplication} is performed.
     */
    private static Collection<Filter> toFilters(Collection<CompositeQueryParameter> parameters,
                                                ColumnFilterAdapter columnFilterAdapter) {
        Stream<CompositeQueryParameter> parameterStream = parameters.stream();
        List<CompositeQueryParameter> conjunctionParams = parameterStream.filter(isConjunctive)
                                                                         .collect(toList());
        List<CompositeQueryParameter> disjunctionParams = parameterStream.filter(isDisjunctive)
                                                                         .collect(toList());
        Optional<CompositeQueryParameter> mergedConjunctiveParams =
                mergeConjunctiveParameters(conjunctionParams);

        Collection<Filter> filters = newLinkedList();
        TreePathWalker processor = new ColumnFilterReducer(columnFilterAdapter, filters);
        multiply(mergedConjunctiveParams.orElse(null), disjunctionParams, processor);
        return filters;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions