Java Code Examples for cz.jirutka.rsql.parser.ast.AndNode

The following examples show how to use cz.jirutka.rsql.parser.ast.AndNode. These examples are extracted from open source projects. 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
@Test
void testVisitAndNode() {
  String argument0 = "piet";
  ComparisonOperator operator0 = new ComparisonOperator("=q=");
  ComparisonNode node0 = new ComparisonNode(operator0, "*", singletonList(argument0));

  String argument1 = "jan";
  ComparisonOperator operator1 = new ComparisonOperator("=q=");
  ComparisonNode node1 = new ComparisonNode(operator1, "*", singletonList(argument1));

  AndNode andNode = new AndNode(asList(node0, node1));
  Query query =
      Query.builder()
          .setOperator(AND)
          .setValue(
              asList(
                  Query.builder().setOperator(MATCHES).setValue(argument0).build(),
                  Query.builder().setOperator(MATCHES).setValue(argument1).build()))
          .build();
  assertEquals(query, queryRsqlVisitor.visit(andNode));
}
 
Example 2
@Override
public Query<Entity> visit(AndNode node) {
  initQuery();
  boolean nested = node.getChildren().size() > 1;
  if (nested) {
    q.nest();
  }
  for (Iterator<Node> it = node.iterator(); it.hasNext(); ) {
    Node child = it.next();
    child.accept(this);

    if (it.hasNext()) {
      q.and();
    }
  }
  if (nested) {
    q.unnest();
  }
  return q;
}
 
Example 3
Source Project: dremio-oss   Source File: SearchFilterToQueryConverter.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public SearchQuery visit(final AndNode node) {
  final List<SearchQuery> queries = new ArrayList<>();
  for (final Node child: node.getChildren()) {
    queries.add(child.accept(this));
  }
  return SearchQueryUtils.and(queries);
}
 
Example 4
Source Project: hawkbit   Source File: RSQLUtility.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Override
public List<Predicate> visit(final AndNode node, final String param) {
    beginLevel(false);
    final List<Predicate> childs = acceptChilds(node);
    endLevel();
    if (!childs.isEmpty()) {
        return toSingleList(cb.and(childs.toArray(new Predicate[childs.size()])));
    }
    return toSingleList(cb.conjunction());
}
 
Example 5
@Override
public AggregateQuery visit(AndNode node) {
  for (Node child : node) {
    child.accept(this);
  }

  return aggsQ;
}
 
Example 6
Source Project: rsql-jpa-specification   Source File: RSQLSimpleConverter.java    License: MIT License 4 votes vote down vote up
@Override
public Void visit(AndNode node, MultiValueMap<String, String> map) {
	log.debug("visit(node:{},map:{})", node, map);
	node.getChildren().forEach(n -> n.accept(this, map));
	return null;
}
 
Example 7
Source Project: rsql-jpa-specification   Source File: RSQLComplexConverter.java    License: MIT License 4 votes vote down vote up
@Override
public Void visit(AndNode node, Map<String, MultiValueMap<String, String>> map) {
	log.debug("visit(node:{},map:{})", node, map);
	node.getChildren().forEach(n -> n.accept(this, map));
	return null;
}
 
Example 8
@Override
public BooleanExpression visit(AndNode node, Path entityClass) {
	log.debug("visit(node:{},param:{})", node, entityClass);

	return node.getChildren().stream().map(n -> n.accept(this, entityClass)).collect(Collectors.reducing(BooleanExpression::and)).get();
}
 
Example 9
Source Project: rsql-jpa-specification   Source File: RSQLJPAPredicateConverter.java    License: MIT License 4 votes vote down vote up
@Override
public Predicate visit(AndNode node, Root root) {
	log.debug("visit(node:{},root:{})", node, root);

	return node.getChildren().stream().map(n -> n.accept(this, root)).collect(Collectors.reducing(builder::and)).get();
}
 
Example 10
Source Project: pnc   Source File: RSQLNodeTraveller.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public T visit(AndNode node) {
    return visit((LogicalNode) node);
}
 
Example 11
Source Project: pnc   Source File: RSQLNodeTraveller.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public T visit(AndNode node) {
    return visit((LogicalNode) node);
}
 
Example 12
@Override
public Query visit(AndNode node) {
  return visit(node, AND);
}
 
Example 13
@Override
public PermissionsQuery visit(AndNode andNode) {
  throw new UnsupportedPermissionQueryOperatorException();
}
 
Example 14
@Test
void testVisitAnd() {
  Node node = mock(Node.class);
  AndNode andNode = new AndNode(Arrays.asList(node, node));
  assertThrows(UnsupportedPermissionQueryOperatorException.class, () -> visitor.visit(andNode));
}
 
Example 15
Source Project: tutorials   Source File: CustomRsqlVisitor.java    License: MIT License 4 votes vote down vote up
@Override
public Specification<T> visit(final AndNode node, final Void param) {
    return builder.createSpecification(node);
}