use of org.openforis.collect.persistence.jooq.tables.records.LookupRecord in project collect by openforis.
the class DynamicTableDao method addFilterConditions.
protected void addFilterConditions(Lookup lookupTable, SelectJoinStep<? extends Record> select, NameValueEntry[] filters) {
for (NameValueEntry filter : filters) {
String colName = filter.getKey();
@SuppressWarnings("unchecked") TableField<LookupRecord, Object> tableField = (TableField<LookupRecord, Object>) lookupTable.field(colName);
if (tableField != null) {
Object filterValue = filter.getValue();
Condition condition;
if ((tableField.getType().equals(String.class)) && (filterValue == null || filterValue instanceof String && StringUtils.isEmpty((String) filterValue))) {
condition = tableField.isNull().or(tableField.trim().equal(""));
} else if (filterValue == null) {
condition = tableField.isNull();
} else {
condition = tableField.equal(filterValue);
}
select.where(condition);
} else {
log.warn("Filter not applied: " + filter);
}
}
}
Aggregations