use of org.jooq.Condition in project waltz by khartec.
the class SqlServerOrganisationalUnitSearch method search.
@Override
public List<OrganisationalUnit> search(DSLContext dsl, String query, EntitySearchOptions options) {
List<String> terms = mkTerms(query);
if (terms.isEmpty()) {
return Collections.emptyList();
}
Condition nameCondition = terms.stream().map(term -> ORGANISATIONAL_UNIT.NAME.like("%" + term + "%")).collect(Collectors.reducing(DSL.trueCondition(), (acc, frag) -> acc.and(frag)));
List<OrganisationalUnit> orgUnitsViaName = dsl.selectDistinct(ORGANISATIONAL_UNIT.fields()).from(ORGANISATIONAL_UNIT).where(nameCondition).orderBy(ORGANISATIONAL_UNIT.NAME).limit(options.limit()).fetch(OrganisationalUnitDao.TO_DOMAIN_MAPPER);
List<OrganisationalUnit> orgUnitsViaFullText = dsl.select(ORGANISATIONAL_UNIT.fields()).from(ORGANISATIONAL_UNIT).where(JooqUtilities.MSSQL.mkContainsPrefix(terms)).limit(options.limit()).fetch(OrganisationalUnitDao.TO_DOMAIN_MAPPER);
return new ArrayList<>(orderedUnion(orgUnitsViaName, orgUnitsViaFullText));
}
use of org.jooq.Condition in project apex-malhar by apache.
the class AbstractJdbcPollInputOperator method getRecordsCount.
/**
* Finds the total number of rows in the table
*
* @return number of records in table
*/
private int getRecordsCount(Object lowerBoundKey) throws SQLException {
Condition condition = DSL.trueCondition();
if (getWhereCondition() != null) {
condition = condition.and(getWhereCondition());
}
if (isPollerPartition && lowerBoundKey != null) {
condition = andLowerBoundKeyCondition(condition, lowerBoundKey);
}
int recordsCount = dslContext.select(DSL.count()).from(getTableName()).where(condition).fetchOne(0, int.class);
return recordsCount;
}
Aggregations