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

The following examples show how to use cz.jirutka.rsql.parser.ast.OrNode. 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 testVisitOrNode() {
  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));

  OrNode orNode = new OrNode(asList(node0, node1));
  Query query =
      Query.builder()
          .setOperator(OR)
          .setValue(
              asList(
                  Query.builder().setOperator(MATCHES).setValue(argument0).build(),
                  Query.builder().setOperator(MATCHES).setValue(argument1).build()))
          .build();
  assertEquals(query, queryRsqlVisitor.visit(orNode));
}
 
Example 2
@Override
public Query<Entity> visit(OrNode 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.or();
    }
  }
  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 OrNode node) {
  final List<SearchQuery> queries = new ArrayList<>();
  for (final Node child: node.getChildren()) {
    queries.add(child.accept(this));
  }
  return SearchQueryUtils.or(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 OrNode node, final String param) {
    beginLevel(true);
    final List<Predicate> childs = acceptChilds(node);
    endLevel();
    if (!childs.isEmpty()) {
        return toSingleList(cb.or(childs.toArray(new Predicate[childs.size()])));
    }
    return toSingleList(cb.conjunction());
}
 
Example 5
@Override
public PermissionsQuery visit(OrNode orNode) {
  List<Node> nodes = orNode.getChildren();
  PermissionsQuery permissionsQuery = new PermissionsQuery();
  if (nodes.size() == 2) {
    for (Node node : nodes) {
      if (node instanceof ComparisonNode) {
        setQuery((ComparisonNode) node, permissionsQuery);
      } else {
        throw new UnsupportedOperationException("invalide node");
      }
    }
  }
  return permissionsQuery;
}
 
Example 6
@Test
void testVisitOr() {
  ComparisonNode comparisonNodeUser =
      new ComparisonNode(
          new ComparisonOperator("=="), "user", Collections.singletonList("user1"));
  ComparisonNode comparisonNodeRole =
      new ComparisonNode(
          new ComparisonOperator("=in=", true), "role", Arrays.asList("role1", "role2"));
  OrNode orNode = new OrNode(Arrays.asList(comparisonNodeUser, comparisonNodeRole));
  assertEquals(
      new PermissionsQuery(asList("user1"), asList("role1", "role2")), visitor.visit(orNode));
}
 
Example 7
Source Project: rsql-jpa-specification   Source File: RSQLSimpleConverter.java    License: MIT License 4 votes vote down vote up
@Override
public Void visit(OrNode node, MultiValueMap<String, String> map) {
	log.debug("visit(node:{},map:{})", node, map);
	node.getChildren().forEach(n -> n.accept(this, map));
	return null;
}
 
Example 8
Source Project: rsql-jpa-specification   Source File: RSQLComplexConverter.java    License: MIT License 4 votes vote down vote up
@Override
public Void visit(OrNode 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 9
@Override
public BooleanExpression visit(OrNode node, Path entityClass) {
	log.debug("visit(node:{},param:{})", node, entityClass);

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

	return node.getChildren().stream().map(n -> n.accept(this, root)).collect(Collectors.reducing(builder::or)).get();
}
 
Example 11
Source Project: pnc   Source File: RSQLNodeTraveller.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public T visit(OrNode node) {
    return visit((LogicalNode) node);
}
 
Example 12
Source Project: pnc   Source File: RSQLNodeTraveller.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public T visit(OrNode node) {
    return visit((LogicalNode) node);
}
 
Example 13
@Override
public Query visit(OrNode node) {
  return visit(node, OR);
}
 
Example 14
@Override
public AggregateQuery visit(OrNode node) {
  throw new MolgenisQueryException(
      "RSQL query operator OR (';' or 'or') not allowed in aggregates query");
}
 
Example 15
Source Project: tutorials   Source File: CustomRsqlVisitor.java    License: MIT License 4 votes vote down vote up
@Override
public Specification<T> visit(final OrNode node, final Void param) {
    return builder.createSpecification(node);
}