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

The following examples show how to use cz.jirutka.rsql.parser.ast.AndNode. 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: QueryRsqlVisitorTest.java    From molgenis with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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
Source File: MolgenisRSQLVisitor.java    From molgenis with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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 File: SearchFilterToQueryConverter.java    From dremio-oss with 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 File: RSQLUtility.java    From hawkbit with 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
Source File: AggregateQueryRsqlVisitor.java    From molgenis with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public AggregateQuery visit(AndNode node) {
  for (Node child : node) {
    child.accept(this);
  }

  return aggsQ;
}
 
Example #6
Source File: RSQLSimpleConverter.java    From rsql-jpa-specification with 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 File: RSQLComplexConverter.java    From rsql-jpa-specification with 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
Source File: RSQLQueryDslPredicateConverter.java    From rsql-jpa-specification with MIT License 4 votes vote down vote up
@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 File: RSQLJPAPredicateConverter.java    From rsql-jpa-specification with 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 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 #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: QueryRsqlVisitor.java    From molgenis with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public Query visit(AndNode node) {
  return visit(node, AND);
}
 
Example #13
Source File: PermissionRsqlVisitor.java    From molgenis with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public PermissionsQuery visit(AndNode andNode) {
  throw new UnsupportedPermissionQueryOperatorException();
}
 
Example #14
Source File: PermissionRsqlVisitorTest.java    From molgenis with GNU Lesser General Public License v3.0 4 votes vote down vote up
@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 File: CustomRsqlVisitor.java    From tutorials with MIT License 4 votes vote down vote up
@Override
public Specification<T> visit(final AndNode node, final Void param) {
    return builder.createSpecification(node);
}