use of com.revolsys.record.query.Condition in project com.revolsys.open by revolsys.
the class FieldFilterPanel method showAdvancedFilter.
public void showAdvancedFilter() {
final Condition filter = getFilter();
final QueryWhereConditionField advancedFilter = new QueryWhereConditionField(this.layer, this, filter);
advancedFilter.showDialog(this);
}
use of com.revolsys.record.query.Condition in project com.revolsys.open by revolsys.
the class FieldFilterPanel method updateCondition.
public void updateCondition() {
if (!(this.searchField instanceof Field) || ((Field) this.searchField).isFieldValid()) {
final Object searchValue = getSearchValue();
this.lastValue = searchValue;
Condition condition = null;
final String searchOperator = getSearchOperator();
if ("IS NULL".equalsIgnoreCase(searchOperator)) {
condition = Q.isNull(this.field);
} else if ("IS NOT NULL".equalsIgnoreCase(searchOperator)) {
condition = Q.isNotNull(this.field);
} else if (this.field != null) {
if (Property.hasValue(DataTypes.toString(searchValue))) {
if ("Like".equalsIgnoreCase(searchOperator)) {
final String searchText = DataTypes.toString(searchValue);
if (Property.hasValue(searchText)) {
condition = Q.iLike(this.field, "%" + searchText + "%");
}
} else {
Object value = null;
if (this.codeTable == null) {
value = this.layer.getValidSearchValue(this.field, searchValue);
} else {
value = this.codeTable.getIdentifier(searchValue);
}
if (value != null) {
condition = Q.binary(this.field, searchOperator, value);
}
}
}
}
setSearchFilter(condition);
}
}
use of com.revolsys.record.query.Condition in project com.revolsys.open by revolsys.
the class RecordLayerTableModel method setFilter.
public void setFilter(final Condition filter) {
Invoke.later(() -> {
final Condition filter2;
if (filter == null) {
filter2 = Condition.ALL;
} else {
filter2 = filter;
}
if (!DataType.equal(filter2, this.filter)) {
final Object oldValue = this.filter;
this.filter = filter2;
if (Property.isEmpty(filter2)) {
this.rowFilterCondition = null;
} else {
this.rowFilterCondition = new RecordRowPredicateRowFilter(filter2);
if (!DataType.equal(oldValue, filter2)) {
this.filterHistory.remove(filter2);
this.filterHistory.addFirst(filter2);
while (this.filterHistory.size() > 20) {
this.filterHistory.removeLast();
}
firePropertyChange("hasFilterHistory", false, true);
}
}
if (isSortable()) {
final RecordLayerTable table = getTable();
table.setRowFilter(this.rowFilterCondition);
} else {
refresh();
}
firePropertyChange("filter", oldValue, this.filter);
final boolean hasFilter = isHasFilter();
firePropertyChange("hasFilter", !hasFilter, hasFilter);
}
});
}
use of com.revolsys.record.query.Condition in project com.revolsys.open by revolsys.
the class AbstractRecordLayer method getQuery.
public final Query getQuery() {
final RecordDefinition recordDefinition = getRecordDefinition();
final Condition whereCondition = getFilter();
return new Query(recordDefinition, whereCondition);
}
use of com.revolsys.record.query.Condition in project com.revolsys.open by revolsys.
the class ListRecordLayer method getRecordsPersisted.
@Override
public List<LayerRecord> getRecordsPersisted(final Query query) {
final List<LayerRecord> records = getRecords();
final Condition filter = query.getWhereCondition();
final Map<? extends CharSequence, Boolean> orderBy = query.getOrderBy();
Records.filterAndSort(records, filter, orderBy);
return records;
}
Aggregations