Search in sources :

Example 21 with Condition

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);
}
Also used : Condition(com.revolsys.record.query.Condition) BinaryCondition(com.revolsys.record.query.BinaryCondition) RightUnaryCondition(com.revolsys.record.query.RightUnaryCondition) QueryWhereConditionField(com.revolsys.swing.field.QueryWhereConditionField)

Example 22 with Condition

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);
    }
}
Also used : Condition(com.revolsys.record.query.Condition) BinaryCondition(com.revolsys.record.query.BinaryCondition) RightUnaryCondition(com.revolsys.record.query.RightUnaryCondition) JXSearchField(org.jdesktop.swingx.JXSearchField) DateField(com.revolsys.swing.field.DateField) AbstractRecordQueryField(com.revolsys.swing.field.AbstractRecordQueryField) Field(com.revolsys.swing.field.Field) TextField(com.revolsys.swing.field.TextField) QueryWhereConditionField(com.revolsys.swing.field.QueryWhereConditionField)

Example 23 with 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);
        }
    });
}
Also used : Condition(com.revolsys.record.query.Condition) RecordRowPredicateRowFilter(com.revolsys.swing.table.record.filter.RecordRowPredicateRowFilter) RecordLayerTable(com.revolsys.swing.map.layer.record.table.RecordLayerTable)

Example 24 with Condition

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);
}
Also used : Condition(com.revolsys.record.query.Condition) Query(com.revolsys.record.query.Query) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 25 with Condition

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;
}
Also used : Condition(com.revolsys.record.query.Condition)

Aggregations

Condition (com.revolsys.record.query.Condition)40 BinaryCondition (com.revolsys.record.query.BinaryCondition)7 AbstractRecordLayer (com.revolsys.swing.map.layer.record.AbstractRecordLayer)6 Record (com.revolsys.record.Record)5 Query (com.revolsys.record.query.Query)5 RightUnaryCondition (com.revolsys.record.query.RightUnaryCondition)5 RecordDefinition (com.revolsys.record.schema.RecordDefinition)5 LayerRecord (com.revolsys.swing.map.layer.record.LayerRecord)5 ValueNode (com.akiban.sql.parser.ValueNode)2 ListByIndexIterator (com.revolsys.collection.list.ListByIndexIterator)2 AbstractMultiCondition (com.revolsys.record.query.AbstractMultiCondition)2 QueryWhereConditionField (com.revolsys.swing.field.QueryWhereConditionField)2 ArrayList (java.util.ArrayList)2 TreeMap (java.util.TreeMap)2 StandardException (com.akiban.sql.StandardException)1 BetweenOperatorNode (com.akiban.sql.parser.BetweenOperatorNode)1 BinaryArithmeticOperatorNode (com.akiban.sql.parser.BinaryArithmeticOperatorNode)1 BinaryLogicalOperatorNode (com.akiban.sql.parser.BinaryLogicalOperatorNode)1 BinaryOperatorNode (com.akiban.sql.parser.BinaryOperatorNode)1 CastNode (com.akiban.sql.parser.CastNode)1