public static Predicate hasTaxidAndModification(final Integer taxid, final String modId) { BooleanBuilder booleanBuilder = new BooleanBuilder(); booleanBuilder.and(hasTaxid(taxid)); booleanBuilder.and(hasModification(modId)); return booleanBuilder.getValue(); }
/** * Create a {@code left in right or...} expression for each list * * @param <D> * @param left * @param lists * @return a {@code left in right or...} expression */ public static <D> Predicate inAny(Expression<D> left, Iterable<? extends Collection<? extends D>> lists) { BooleanBuilder rv = new BooleanBuilder(); for (Collection<? extends D> list : lists) { rv.or(in(left, list)); } return rv; }
/** * Create a {@code left not in right and...} expression for each list * * @param <D> * @param left * @param lists * @return a {@code left not in right and...} expression */ public static <D> Predicate notInAny(Expression<D> left, Iterable<? extends Collection<? extends D>> lists) { BooleanBuilder rv = new BooleanBuilder(); for (Collection<? extends D> list : lists) { rv.and(notIn(left, list)); } return rv; }
protected void visitOperation(Class<?> type, Operator<?> operator, List<? extends Expression<?>> args) { if (operator == Ops.IN && inToOr) { BooleanBuilder builder = new BooleanBuilder(); for (Object arg : ((Constant<Collection>)args.get(1)).getConstant()) { builder.or(ExpressionUtils.eq(args.get(0), new ConstantImpl(arg))); builder.getValue().accept(this, null); return;
@Test public void BooleanBuilder2() { BooleanBuilder bb1 = new BooleanBuilder(); bb1.and(cat.eq(cat)); BooleanBuilder bb2 = new BooleanBuilder(); bb2.or(cat.eq(cat)); bb2.or(cat.eq(cat)); assertToString("cat = cat and (cat = cat or cat = cat)", bb1.and(bb2.getValue())); }
@Test public void BooleanBuilder1() { BooleanBuilder bb1 = new BooleanBuilder(); bb1.and(cat.eq(cat)); BooleanBuilder bb2 = new BooleanBuilder(); bb2.or(cat.eq(cat)); bb2.or(cat.eq(cat)); assertToString("cat = cat and (cat = cat or cat = cat)", bb1.and(bb2)); }
@Override public void clearWhere() { where = new BooleanBuilder(); }
StoredQueryParam paramFormatCode = getQueryParam(XDSConstants.QRY_DOCUMENT_ENTRY_FORMAT_CODE); if (paramConfidentialityCode != null || paramFormatCode != null) { BooleanBuilder docBuilder = new BooleanBuilder(); docBuilder.and(QXDSDocumentEntry.xDSDocumentEntry.eq(QAssociation.association.targetObject)); addXdsCodeMatch(docBuilder, getQueryParam(XDSConstants.QRY_DOCUMENT_ENTRY_CONFIDENTIALITY_CODE), XDSConstants.UUID_XDSDocumentEntry_confidentialityCode, QXDSDocumentEntry.xDSDocumentEntry.xdsCodes); XDSConstants.UUID_XDSDocumentEntry_formatCode, QXDSDocumentEntry.xDSDocumentEntry.xdsCodes); BooleanBuilder orBuilder = new BooleanBuilder(); orBuilder.orNot(QAssociation.association.targetObject.instanceOf(XDSDocumentEntry.class)) .or(new JPASubQuery().from(QXDSDocumentEntry.xDSDocumentEntry) .where(docBuilder).exists()); query.where(QAssociation.association.sourceObject.eq(ro),
basePredicate.toString()); basePredicate = new BooleanBuilder(); BooleanBuilder filtersByColumnPredicate = new BooleanBuilder(); BooleanBuilder filtersByTablePredicate = new BooleanBuilder(); basePredicate = basePredicate.and(firstRowsInExpression.not()); basePredicate = new BooleanBuilder(); hasBasePredicate = false; query = query.where(basePredicate.and( filtersByColumnPredicate.getValue()).and( filtersByTablePredicate.getValue()));
public static GroupBlock group(Collection<Predicate> predicates) { List<Block> blocks = new ArrayList<Block>(); BooleanBuilder filters = new BooleanBuilder(); handle(predicates, blocks, filters); if (filters.getValue() == null) { return new GroupBlock(blocks); } else { return new GroupBlock(blocks, filters.getValue()); } }
private static void handle(Collection<Predicate> predicates, List<Block> blocks, BooleanBuilder filters) { for (Predicate predicate : predicates) { if (predicate instanceof Block) { blocks.add((Block) predicate); } else { filters.and(predicate); } } }
basePredicate.toString()); basePredicate = new BooleanBuilder();
@Override public boolean equals(Object o) { if (o == this) { return true; } else if (o instanceof BooleanBuilder) { return Objects.equal(((BooleanBuilder)o).getValue(), predicate); } else { return false; } }
/** * Create the union of this and the negation of the given predicate * * @param right * @return */ public BooleanBuilder orNot(Predicate right) { return or(right.not()); }
} else if (uids.size() > 1) { QUID g = new QUID("__g"); // TODO : use constant BooleanBuilder b = new BooleanBuilder(); for (Constant<UID> uid : uids) { b.or(g.eq(uid)); where = Blocks.graphFilter(g, (Block) where, b.getValue());
.and(filterExpression); BooleanBuilder filtersByAssociationPredicate = new BooleanBuilder(); associationFieldName, searchStr); filtersByAssociationPredicate = filtersByAssociationPredicate .or(filterExpression); .and(filtersByAssociationPredicate.getValue()); filtersByAssociationPredicate.getValue());
/** * {@inheritDoc} */ @Override public <T, E> BooleanBuilder createPredicateByIn(PathBuilder<T> entity, String fieldName, Set<E> values) { // Using BooleanBuilder, a cascading builder for // Predicate expressions BooleanBuilder predicate = new BooleanBuilder(); if (StringUtils.isEmpty(fieldName) || values.isEmpty()) { return predicate; } // Build the predicate predicate.and(createCollectionExpression(entity, fieldName, values)); return predicate; }
/** * Add code matches in XDS form using XDSCode entity * * @param builder BooleanBuilder to add matches for given code parameter * @param codeParam Stored Query Parameter with code values * @param codeType The classification of the codes (Classification.classificationScheme) * @param xdsCodes The CollectionPath for XDSCodes of parent select (to bind subselect) * @throws XDSException */ protected void addXdsCodeMatch(BooleanBuilder builder, StoredQueryParam codeParam, String codeClassification, CollectionPath<XDSCode, QXDSCode> xdsCodes) throws XDSException { if (codeParam != null) { List<String> codeValues; String[] codeAndScheme; for (int i = 0, len=codeParam.getNumberOfANDElements() ; i < len ; i++) { codeValues = codeParam.getMultiValues(i); BooleanBuilder codesBuilder = new BooleanBuilder(); for (int j = 0, jLen = codeValues.size() ; j < jLen ; j++) { codeAndScheme = toCodeValueAndScheme(codeValues.get(j)); codesBuilder.or(ExpressionUtils.allOf(QXDSCode.xDSCode.codeClassification.eq(codeClassification), QXDSCode.xDSCode.codeValue.eq(codeAndScheme[0]), QXDSCode.xDSCode.codingSchemeDesignator.eq(codeAndScheme[1]))); } builder.and(new JPASubQuery().from(QXDSCode.xDSCode) .where(QXDSCode.xDSCode.in(xdsCodes), codesBuilder).exists()); } } }
private List<XDSFolder> getFolders() { JPAQuery query = new JPAQuery(getSession().getEntityManager()); BooleanBuilder builder = new BooleanBuilder(); addPatientIdMatch(builder, getQueryParam(XDSConstants.QRY_PATIENT_ID)); addStatusMatch(builder, QXDSFolder.xDSFolder.status, getQueryParam(XDSConstants.QRY_FOLDER_STATUS)); List<XDSFolder> folders = query.from(QXDSFolder.xDSFolder) .innerJoin(QXDSFolder.xDSFolder.patient, QXADPatient.xADPatient) .innerJoin(QXADPatient.xADPatient.issuerOfPatientID, QXADIssuer.xADIssuer) .where(builder) .list(QXDSFolder.xDSFolder); log.info("#### Found Folders:"+folders); return folders; }
protected void aggregateFilters() { if (!blocks.isEmpty()) { if (filters.getValue() == null) { super.where(new GroupBlock(blocks)); } else { super.where(new GroupBlock(blocks, filters.getValue())); } } blocks = new ArrayList<Block>(); filters = new BooleanBuilder(); }