Search in sources :

Example 1 with AssociationNotNullSpecification

use of org.qi4j.api.query.grammar.AssociationNotNullSpecification in project qi4j-sdk by Qi4j.

the class RdfQueryParserImpl method processFilter.

private void processFilter(final Specification<Composite> expression, boolean allowInline, StringBuilder builder) {
    if (expression == null) {
        return;
    }
    if (expression instanceof AndSpecification) {
        final AndSpecification conjunction = (AndSpecification) expression;
        int start = builder.length();
        boolean first = true;
        for (Specification<Composite> operand : conjunction.operands()) {
            int size = builder.length();
            processFilter(operand, allowInline, builder);
            if (builder.length() > size) {
                if (first) {
                    first = false;
                } else {
                    builder.insert(size, " && ");
                }
            }
        }
        if (builder.length() > start) {
            builder.insert(start, '(');
            builder.append(')');
        }
    } else if (expression instanceof OrSpecification) {
        final OrSpecification disjunction = (OrSpecification) expression;
        int start = builder.length();
        boolean first = true;
        for (Specification<Composite> operand : disjunction.operands()) {
            int size = builder.length();
            processFilter(operand, false, builder);
            if (builder.length() > size) {
                if (first) {
                    first = false;
                } else {
                    builder.insert(size, "||");
                }
            }
        }
        if (builder.length() > start) {
            builder.insert(start, '(');
            builder.append(')');
        }
    } else if (expression instanceof NotSpecification) {
        builder.insert(0, "(!");
        processFilter(((NotSpecification) expression).operand(), false, builder);
        builder.append(")");
    } else if (expression instanceof ComparisonSpecification) {
        processComparisonPredicate(expression, allowInline, builder);
    } else if (expression instanceof ContainsAllSpecification) {
        processContainsAllPredicate((ContainsAllSpecification) expression, builder);
    } else if (expression instanceof ContainsSpecification<?>) {
        processContainsPredicate((ContainsSpecification<?>) expression, builder);
    } else if (expression instanceof MatchesSpecification) {
        processMatchesPredicate((MatchesSpecification) expression, builder);
    } else if (expression instanceof PropertyNotNullSpecification<?>) {
        processNotNullPredicate((PropertyNotNullSpecification) expression, builder);
    } else if (expression instanceof PropertyNullSpecification<?>) {
        processNullPredicate((PropertyNullSpecification) expression, builder);
    } else if (expression instanceof AssociationNotNullSpecification<?>) {
        processNotNullPredicate((AssociationNotNullSpecification) expression, builder);
    } else if (expression instanceof AssociationNullSpecification<?>) {
        processNullPredicate((AssociationNullSpecification) expression, builder);
    } else if (expression instanceof ManyAssociationContainsSpecification<?>) {
        processManyAssociationContainsPredicate((ManyAssociationContainsSpecification) expression, allowInline, builder);
    } else {
        throw new UnsupportedOperationException("Expression " + expression + " is not supported");
    }
}
Also used : OrSpecification(org.qi4j.api.query.grammar.OrSpecification) Composite(org.qi4j.api.composite.Composite) EntityComposite(org.qi4j.api.entity.EntityComposite) MatchesSpecification(org.qi4j.api.query.grammar.MatchesSpecification) ContainsSpecification(org.qi4j.api.query.grammar.ContainsSpecification) ContainsAllSpecification(org.qi4j.api.query.grammar.ContainsAllSpecification) ManyAssociationContainsSpecification(org.qi4j.api.query.grammar.ManyAssociationContainsSpecification) LeSpecification(org.qi4j.api.query.grammar.LeSpecification) PropertyNullSpecification(org.qi4j.api.query.grammar.PropertyNullSpecification) NotSpecification(org.qi4j.api.query.grammar.NotSpecification) PropertyNotNullSpecification(org.qi4j.api.query.grammar.PropertyNotNullSpecification) Specification(org.qi4j.functional.Specification) LtSpecification(org.qi4j.api.query.grammar.LtSpecification) GtSpecification(org.qi4j.api.query.grammar.GtSpecification) NeSpecification(org.qi4j.api.query.grammar.NeSpecification) EqSpecification(org.qi4j.api.query.grammar.EqSpecification) AssociationNotNullSpecification(org.qi4j.api.query.grammar.AssociationNotNullSpecification) ComparisonSpecification(org.qi4j.api.query.grammar.ComparisonSpecification) QuerySpecification(org.qi4j.api.query.grammar.QuerySpecification) OrSpecification(org.qi4j.api.query.grammar.OrSpecification) GeSpecification(org.qi4j.api.query.grammar.GeSpecification) AndSpecification(org.qi4j.api.query.grammar.AndSpecification) AssociationNullSpecification(org.qi4j.api.query.grammar.AssociationNullSpecification) ComparisonSpecification(org.qi4j.api.query.grammar.ComparisonSpecification) ContainsSpecification(org.qi4j.api.query.grammar.ContainsSpecification) ManyAssociationContainsSpecification(org.qi4j.api.query.grammar.ManyAssociationContainsSpecification) NotSpecification(org.qi4j.api.query.grammar.NotSpecification) AndSpecification(org.qi4j.api.query.grammar.AndSpecification) PropertyNullSpecification(org.qi4j.api.query.grammar.PropertyNullSpecification) MatchesSpecification(org.qi4j.api.query.grammar.MatchesSpecification) AssociationNotNullSpecification(org.qi4j.api.query.grammar.AssociationNotNullSpecification) ContainsAllSpecification(org.qi4j.api.query.grammar.ContainsAllSpecification) PropertyNotNullSpecification(org.qi4j.api.query.grammar.PropertyNotNullSpecification) ManyAssociationContainsSpecification(org.qi4j.api.query.grammar.ManyAssociationContainsSpecification) AssociationNullSpecification(org.qi4j.api.query.grammar.AssociationNullSpecification)

Aggregations

Composite (org.qi4j.api.composite.Composite)1 EntityComposite (org.qi4j.api.entity.EntityComposite)1 AndSpecification (org.qi4j.api.query.grammar.AndSpecification)1 AssociationNotNullSpecification (org.qi4j.api.query.grammar.AssociationNotNullSpecification)1 AssociationNullSpecification (org.qi4j.api.query.grammar.AssociationNullSpecification)1 ComparisonSpecification (org.qi4j.api.query.grammar.ComparisonSpecification)1 ContainsAllSpecification (org.qi4j.api.query.grammar.ContainsAllSpecification)1 ContainsSpecification (org.qi4j.api.query.grammar.ContainsSpecification)1 EqSpecification (org.qi4j.api.query.grammar.EqSpecification)1 GeSpecification (org.qi4j.api.query.grammar.GeSpecification)1 GtSpecification (org.qi4j.api.query.grammar.GtSpecification)1 LeSpecification (org.qi4j.api.query.grammar.LeSpecification)1 LtSpecification (org.qi4j.api.query.grammar.LtSpecification)1 ManyAssociationContainsSpecification (org.qi4j.api.query.grammar.ManyAssociationContainsSpecification)1 MatchesSpecification (org.qi4j.api.query.grammar.MatchesSpecification)1 NeSpecification (org.qi4j.api.query.grammar.NeSpecification)1 NotSpecification (org.qi4j.api.query.grammar.NotSpecification)1 OrSpecification (org.qi4j.api.query.grammar.OrSpecification)1 PropertyNotNullSpecification (org.qi4j.api.query.grammar.PropertyNotNullSpecification)1 PropertyNullSpecification (org.qi4j.api.query.grammar.PropertyNullSpecification)1