cz.jirutka.rsql.parser.ast.LogicalNode Java Examples

The following examples show how to use cz.jirutka.rsql.parser.ast.LogicalNode. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GenericRsqlSpecBuilder.java    From tutorials with MIT License 6 votes vote down vote up
public Specification<T> createSpecification(final LogicalNode logicalNode) {
    
    List<Specification<T>> specs = logicalNode.getChildren()
            .stream()
            .map(node -> createSpecification(node))
            .filter(Objects::nonNull)
            .collect(Collectors.toList());
    
    Specification<T> result = specs.get(0);
    if (logicalNode.getOperator() == LogicalOperator.AND) {
       for (int i = 1; i < specs.size(); i++) {
           result = Specification.where(result).and(specs.get(i));
       }
    }
    else if (logicalNode.getOperator() == LogicalOperator.OR) {
       for (int i = 1; i < specs.size(); i++) {
           result = Specification.where(result).or(specs.get(i));
       }
    }
    
    return result;
}
 
Example #2
Source File: RSQLUtility.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
private List<Predicate> acceptChilds(final LogicalNode node) {
    final List<Node> children = node.getChildren();
    final List<Predicate> childs = new ArrayList<>();
    for (final Node node2 : children) {
        final List<Predicate> accept = node2.accept(this);
        if (!CollectionUtils.isEmpty(accept)) {
            childs.addAll(accept);
        } else {
            LOGGER.debug("visit logical node children but could not parse it, ignoring {}", node2);
        }
    }
    return childs;
}
 
Example #3
Source File: RSQLNodeTraveller.java    From pnc with Apache License 2.0 5 votes vote down vote up
public T visit(Node node) {
    // remember overloading is chosen based on static type.
    if (node instanceof LogicalNode) {
        return visit((LogicalNode) node);
    } else if (node instanceof ComparisonNode) {
        return visit((ComparisonNode) node);
    } else {
        throw new UnsupportedOperationException("Did you invent 3rd type of the node?");
    }
}
 
Example #4
Source File: RSQLNodeTraveller.java    From pnc with Apache License 2.0 5 votes vote down vote up
public T visit(Node node) {
    // remember overloading is chosen based on static type.
    if (node instanceof LogicalNode) {
        return visit((LogicalNode) node);
    } else if (node instanceof ComparisonNode) {
        return visit((ComparisonNode) node);
    } else {
        throw new UnsupportedOperationException("Did you invent 3rd type of the node?");
    }
}
 
Example #5
Source File: GenericRsqlSpecBuilder.java    From tutorials with MIT License 5 votes vote down vote up
public Specification<T> createSpecification(final Node node) {
    if (node instanceof LogicalNode) {
        return createSpecification((LogicalNode) node);
    }
    if (node instanceof ComparisonNode) {
        return createSpecification((ComparisonNode) node);
    }
    return null;
}
 
Example #6
Source File: RSQLNodeTraveller.java    From pnc with Apache License 2.0 4 votes vote down vote up
@Override
public T visit(AndNode node) {
    return visit((LogicalNode) node);
}
 
Example #7
Source File: RSQLNodeTraveller.java    From pnc with Apache License 2.0 4 votes vote down vote up
@Override
public T visit(OrNode node) {
    return visit((LogicalNode) node);
}
 
Example #8
Source File: SortRSQLNodeTraveller.java    From pnc with Apache License 2.0 4 votes vote down vote up
@Override
public SortInfo visit(LogicalNode logicalNode) {
    return null;
}
 
Example #9
Source File: ComparatorRSQLNodeTraveller.java    From pnc with Apache License 2.0 4 votes vote down vote up
@Override
public Comparator<DTO> visit(LogicalNode logicalNode) {
    return null;
}
 
Example #10
Source File: EntityRSQLNodeTraveller.java    From pnc with Apache License 2.0 4 votes vote down vote up
@Override
public javax.persistence.criteria.Predicate visit(LogicalNode node) {
    logger.trace("Parsing LogicalNode {}", node);
    return proceedEmbeddedNodes(node);
}
 
Example #11
Source File: RSQLNodeTraveller.java    From pnc with Apache License 2.0 4 votes vote down vote up
@Override
public T visit(AndNode node) {
    return visit((LogicalNode) node);
}
 
Example #12
Source File: RSQLNodeTraveller.java    From pnc with Apache License 2.0 4 votes vote down vote up
@Override
public T visit(OrNode node) {
    return visit((LogicalNode) node);
}
 
Example #13
Source File: QueryRsqlVisitor.java    From molgenis with GNU Lesser General Public License v3.0 4 votes vote down vote up
private Query visit(LogicalNode node, Operator operator) {
  List<Query> subQueries =
      node.getChildren().stream().map(childNode -> childNode.accept(this)).collect(toList());
  return Query.builder().setOperator(operator).setValue(subQueries).build();
}
 
Example #14
Source File: RSQLNodeTraveller.java    From pnc with Apache License 2.0 votes vote down vote up
public abstract T visit(LogicalNode logicalNode); 
Example #15
Source File: RSQLNodeTraveller.java    From pnc with Apache License 2.0 votes vote down vote up
public abstract T visit(LogicalNode logicalNode);