public void visit(SearchCondition<T> sc) { if (builder == null) { builder = em.getCriteriaBuilder(); cq = builder.createQuery(queryClass); root = cq.from(tClass); predStack.push(new ArrayList<>()); } if (sc.getStatement() != null) { predStack.peek().add(buildPredicate(sc.getStatement())); } else { predStack.push(new ArrayList<>()); for (SearchCondition<T> condition : sc.getSearchConditions()) { condition.accept(this); } List<Predicate> predsList = predStack.pop(); Predicate[] preds = predsList.toArray(new Predicate[0]); Predicate newPred; if (sc instanceof OrSearchCondition) { newPred = builder.or(preds); } else { newPred = builder.and(preds); } predStack.peek().add(newPred); } }
public void visit(SearchCondition<T> sc) { if (builder == null) { builder = em.getCriteriaBuilder(); cq = builder.createQuery(queryClass); root = cq.from(tClass); predStack.push(new ArrayList<>()); } if (sc.getStatement() != null) { predStack.peek().add(buildPredicate(sc.getStatement())); } else { predStack.push(new ArrayList<>()); for (SearchCondition<T> condition : sc.getSearchConditions()) { condition.accept(this); } List<Predicate> predsList = predStack.pop(); Predicate[] preds = predsList.toArray(new Predicate[0]); Predicate newPred; if (sc instanceof OrSearchCondition) { newPred = builder.or(preds); } else { newPred = builder.and(preds); } predStack.peek().add(newPred); } }
public void visit(SearchCondition<T> sc) { if (builder == null) { builder = em.getCriteriaBuilder(); cq = builder.createQuery(queryClass); root = cq.from(tClass); predStack.push(new ArrayList<Predicate>()); } if (sc.getStatement() != null) { predStack.peek().add(buildPredicate(sc.getStatement())); } else { predStack.push(new ArrayList<Predicate>()); for (SearchCondition<T> condition : sc.getSearchConditions()) { condition.accept(this); } List<Predicate> predsList = predStack.pop(); Predicate[] preds = predsList.toArray(new Predicate[predsList.size()]); Predicate newPred; if (sc instanceof OrSearchCondition) { newPred = builder.or(preds); } else { newPred = builder.and(preds); } predStack.peek().add(newPred); } }
public void visit(SearchCondition<T> sc) { PrimitiveStatement statement = sc.getStatement(); if (statement != null) { if (statement.getProperty() != null) { queryStack.peek().add(buildSimpleQuery(sc.getConditionType(), statement.getProperty(), statement.getValue())); } } else { queryStack.push(new ArrayList<>()); for (SearchCondition<T> condition : sc.getSearchConditions()) { condition.accept(this); } boolean orCondition = sc.getConditionType() == ConditionType.OR; List<Filter> queries = queryStack.pop(); queryStack.peek().add(createCompositeQuery(queries, orCondition)); } }
public void visit(SearchCondition<T> sc) { PrimitiveStatement statement = sc.getStatement(); if (statement != null) { if (statement.getProperty() != null) { queryStack.peek().add(buildSimpleQuery(sc.getConditionType(), statement.getProperty(), statement.getValue())); } } else { queryStack.push(new ArrayList<>()); for (SearchCondition<T> condition : sc.getSearchConditions()) { condition.accept(this); } boolean orCondition = sc.getConditionType() == ConditionType.OR; List<Filter> queries = queryStack.pop(); queryStack.peek().add(createCompositeQuery(queries, orCondition)); } }
public void visit(SearchCondition<T> sc) { PrimitiveStatement statement = sc.getStatement(); if (statement != null) { if (statement.getProperty() != null) { queryStack.peek().add(buildSimpleQuery(sc.getConditionType(), statement.getProperty(), statement.getValue())); } } else { queryStack.push(new ArrayList<Query>()); for (SearchCondition<T> condition : sc.getSearchConditions()) { condition.accept(this); } boolean orCondition = sc.getConditionType() == ConditionType.OR; List<Query> queries = queryStack.pop(); queryStack.peek().add(createCompositeQuery(queries, orCondition)); } }
private SearchCond visitCompount(final SearchCondition<SearchBean> sc) { List<SearchCond> searchConds = new ArrayList<>(); sc.getSearchConditions().forEach(searchCondition -> { searchConds.add(searchCondition.getStatement() == null ? visitCompount(searchCondition) : visitPrimitive(searchCondition)); }); SearchCond compound; switch (sc.getConditionType()) { case AND: compound = SearchCond.getAndCond(searchConds); break; case OR: compound = SearchCond.getOrCond(searchConds); break; default: throw new IllegalArgumentException( String.format("Condition type %s is not supported", sc.getConditionType().name())); } return compound; }
private static List<SearchClause> getCompoundSearchClauses(final SearchCondition<SearchBean> sc) { List<SearchClause> clauses = new ArrayList<>(); for (SearchCondition<SearchBean> searchCondition : sc.getSearchConditions()) { if (searchCondition.getStatement() == null) { clauses.addAll(getCompoundSearchClauses(searchCondition)); } else { SearchClause clause = getPrimitiveSearchClause(searchCondition); if (sc.getConditionType() == ConditionType.AND) { clause.setOperator(SearchClause.Operator.AND); } if (sc.getConditionType() == ConditionType.OR) { clause.setOperator(SearchClause.Operator.OR); } clauses.add(clause); } } return clauses; }
for (SearchCondition<T> condition : sc.getSearchConditions()) { if (!first) { sb.append(" ").append(sc.getConditionType().toString()).append(" ");
public void visit(SearchCondition<T> sc) { if (state.get() == null) { reset(); } PrimitiveStatement statement = sc.getStatement(); if (statement != null) { if (statement.getProperty() != null) { state.get().peek().add(buildSimpleQuery(sc.getConditionType(), statement.getProperty(), statement.getValue())); } } else { state.get().push(new ArrayList<>()); for (SearchCondition<T> condition : sc.getSearchConditions()) { condition.accept(this); } boolean orCondition = sc.getConditionType() == ConditionType.OR; List<Query> queries = state.get().pop(); state.get().peek().add(createCompositeQuery(queries, orCondition)); } }
public void visit(SearchCondition<T> sc) { if (state.get() == null) { reset(); } PrimitiveStatement statement = sc.getStatement(); if (statement != null) { if (statement.getProperty() != null) { state.get().peek().add(buildSimpleQuery(sc.getConditionType(), statement.getProperty(), statement.getValue())); } } else { state.get().push(new ArrayList<>()); for (SearchCondition<T> condition : sc.getSearchConditions()) { condition.accept(this); } boolean orCondition = sc.getConditionType() == ConditionType.OR; List<Query> queries = state.get().pop(); state.get().peek().add(createCompositeQuery(queries, orCondition)); } }
for (SearchCondition<T> condition : sc.getSearchConditions()) { saveStringBuilder(sb); condition.accept(this);
for (SearchCondition<T> condition : sc.getSearchConditions()) { saveStringBuilder(sb); condition.accept(this);
for (SearchCondition<T> condition : sc.getSearchConditions()) { if (!first) { sb.append(" ").append(sc.getConditionType().toString()).append(" ");
for (SearchCondition<T> condition : sc.getSearchConditions()) { saveStringBuilder(sb); condition.accept(this);
for (SearchCondition<T> condition : sc.getSearchConditions()) { if (!first) { sb.append(" ").append(sc.getConditionType().toString()).append(" ");