Search in sources :

Example 1 with SimpleExpression

use of io.jans.scim.service.antlr.scimFilter.util.SimpleExpression in project jans by JanssenProject.

the class MatchFilterVisitor method visitAttrexp.

@Override
public Boolean visitAttrexp(ScimFilterParser.AttrexpContext ctx) {
    log.trace("visitAttrexp. childs: {}, text: {}", ctx.getChildCount(), ctx.getText());
    String path = ctx.attrpath().getText();
    ScimFilterParser.CompvalueContext compValueCtx = ctx.compvalue();
    boolean isPrRule = compValueCtx == null && ctx.getChild(1).getText().equals("pr");
    ScimOperator operator;
    CompValueType valueType;
    String value;
    if (isPrRule) {
        operator = ScimOperator.NOT_EQUAL;
        valueType = CompValueType.NULL;
        value = null;
    } else {
        operator = ScimOperator.getByValue(ctx.compareop().getText());
        valueType = FilterUtil.getCompValueType(compValueCtx);
        value = compValueCtx.getText();
        if (// drop double quotes
        CompValueType.STRING.equals(valueType))
            value = value.substring(1, value.length() - 1);
    }
    SimpleExpression expr = new SimpleExpression(path, operator, valueType, value);
    expr.setParentAttribute(parentAttribute);
    expr.setResourceClass(resourceClass);
    return expr.evaluate(item);
}
Also used : ScimOperator(io.jans.scim.service.antlr.scimFilter.enums.ScimOperator) ScimFilterParser(io.jans.scim.service.antlr.scimFilter.antlr4.ScimFilterParser) CompValueType(io.jans.scim.service.antlr.scimFilter.enums.CompValueType) SimpleExpression(io.jans.scim.service.antlr.scimFilter.util.SimpleExpression)

Aggregations

ScimFilterParser (io.jans.scim.service.antlr.scimFilter.antlr4.ScimFilterParser)1 CompValueType (io.jans.scim.service.antlr.scimFilter.enums.CompValueType)1 ScimOperator (io.jans.scim.service.antlr.scimFilter.enums.ScimOperator)1 SimpleExpression (io.jans.scim.service.antlr.scimFilter.util.SimpleExpression)1