Search in sources :

Example 26 with Condition

use of com.revolsys.record.query.Condition in project com.revolsys.open by revolsys.

the class ModeAbstractCached method exportRecords.

@Override
public void exportRecords(final Query query, final Object target) {
    final Condition filter = query.getWhereCondition();
    final Map<? extends CharSequence, Boolean> orderBy = query.getOrderBy();
    final AbstractRecordLayer layer = getLayer();
    final Iterable<LayerRecord> records = new ListByIndexIterator<>(this.records);
    layer.exportRecords(records, filter, orderBy, target);
}
Also used : Condition(com.revolsys.record.query.Condition) ListByIndexIterator(com.revolsys.collection.list.ListByIndexIterator) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord)

Example 27 with Condition

use of com.revolsys.record.query.Condition in project com.revolsys.open by revolsys.

the class ModeAllPaged method isRecordPageQueryChanged.

/**
 * Has the record been changed such that
 * @param record
 * @return
 */
protected boolean isRecordPageQueryChanged(final LayerRecord record) {
    final AbstractRecordLayer layer = getLayer();
    if (layer.isModified(record)) {
        final Condition filter = getFilter();
        final RecordLayerTableModel model = getTableModel();
        final Comparator<Record> comparator = model.getOrderByComparatorIdentifier();
        if (comparator != null) {
            final Record orginialRecord = record.getOriginalRecord();
            final int compare = comparator.compare(record, orginialRecord);
            if (compare != 0) {
                return true;
            }
        }
        if (!filter.isEmpty()) {
            if (filter.test(record)) {
                final Record orginialRecord = record.getOriginalRecord();
                if (!filter.test(orginialRecord)) {
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : Condition(com.revolsys.record.query.Condition) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) Record(com.revolsys.record.Record) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord)

Example 28 with Condition

use of com.revolsys.record.query.Condition in project com.revolsys.open by revolsys.

the class ModeAllPaged method getRecordsForCache.

@Override
protected List<LayerRecord> getRecordsForCache() {
    final AbstractRecordLayer layer = getLayer();
    final List<LayerRecord> records = layer.getRecordsNew();
    final Condition filter = getFilter();
    if (!filter.isEmpty()) {
        Predicates.retain(records, filter);
        for (final LayerRecord modifiedRecord : layer.getRecordsModified()) {
            if (filterTestModified(filter, modifiedRecord)) {
                records.add(modifiedRecord);
            }
        }
    }
    final RecordLayerTableModel model = getTableModel();
    final Comparator<Record> comparator = model.getOrderByComparatorIdentifier();
    if (comparator != null) {
        records.sort(comparator);
    }
    return records;
}
Also used : Condition(com.revolsys.record.query.Condition) AbstractRecordLayer(com.revolsys.swing.map.layer.record.AbstractRecordLayer) Record(com.revolsys.record.Record) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord)

Example 29 with Condition

use of com.revolsys.record.query.Condition in project com.revolsys.open by revolsys.

the class QueryValueTest method testIsNotNull.

private void testIsNotNull() {
    final Condition trueCondition1 = Q.isNotNull(this.idField);
    assertConditionTrue(trueCondition1, this.record);
    final Condition falseCondition1 = Q.isNotNull(this.descriptionAttribute);
    assertConditionFalse(falseCondition1, this.record);
}
Also used : Condition(com.revolsys.record.query.Condition)

Example 30 with Condition

use of com.revolsys.record.query.Condition in project com.revolsys.open by revolsys.

the class QueryValueTest method testIsNull.

private void testIsNull() {
    final Condition trueCondition1 = Q.isNull(this.descriptionAttribute);
    assertConditionTrue(trueCondition1, this.record);
    final Condition falseCondition1 = Q.isNull(this.idField);
    assertConditionFalse(falseCondition1, this.record);
}
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