Search in sources :

Example 21 with Query

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

the class RecordLayerTableModel method getFilterQuery.

protected Query getFilterQuery() {
    final Query query = this.layer.getQuery();
    final Condition filter = getFilter();
    query.and(filter);
    query.setOrderBy(this.orderBy);
    if (this.filterByBoundingBox) {
        final Project project = this.layer.getProject();
        final BoundingBox viewBoundingBox = project.getViewBoundingBox();
        final RecordDefinition recordDefinition = this.layer.getRecordDefinition();
        final FieldDefinition geometryField = recordDefinition.getGeometryField();
        if (geometryField != null) {
            query.and(F.envelopeIntersects(geometryField, viewBoundingBox));
        }
    }
    return query;
}
Also used : Condition(com.revolsys.record.query.Condition) Project(com.revolsys.swing.map.layer.Project) Query(com.revolsys.record.query.Query) BoundingBox(com.revolsys.geometry.model.BoundingBox) FieldDefinition(com.revolsys.record.schema.FieldDefinition) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 22 with Query

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

the class LoadingWorker method handleBackground.

@Override
protected List<LayerRecord> handleBackground() {
    try {
        final Query query = this.layer.newBoundingBoxQuery(this.viewportBoundingBox);
        // TODO cancellable
        final List<LayerRecord> records = this.layer.getRecords(query);
        this.layer.setIndexRecords(this.viewportBoundingBox, records);
        return records;
    } catch (final Exception e) {
        if (this.layer.isDeleted()) {
            return null;
        } else {
            throw e;
        }
    }
}
Also used : Query(com.revolsys.record.query.Query)

Example 23 with Query

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

the class RecordStoreQueryReader method open.

@Override
@PostConstruct
public void open() {
    if (this.typePaths != null) {
        for (final String tableName : this.typePaths) {
            final RecordDefinition recordDefinition = this.recordStore.getRecordDefinition(tableName);
            if (recordDefinition != null) {
                Query query;
                if (this.boundingBox == null) {
                    query = new Query(recordDefinition);
                    query.setWhereCondition(new SqlCondition(this.whereClause));
                } else {
                    query = Query.intersects(recordDefinition, this.boundingBox);
                }
                addQuery(query);
            }
        }
    }
    super.open();
}
Also used : Query(com.revolsys.record.query.Query) RecordDefinition(com.revolsys.record.schema.RecordDefinition) SqlCondition(com.revolsys.record.query.SqlCondition) PostConstruct(javax.annotation.PostConstruct)

Example 24 with Query

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

the class RecordStoreQueryReader method newQueryIterator.

protected AbstractIterator<Record> newQueryIterator(final int i) {
    if (i < this.queries.size()) {
        final Query query = this.queries.get(i);
        if (Property.hasValue(this.whereClause)) {
            query.and(new SqlCondition(this.whereClause));
        }
        if (this.boundingBox != null) {
            final FieldDefinition geometryField = query.getRecordDefinition().getGeometryField();
            query.and(F.envelopeIntersects(geometryField, this.boundingBox));
        }
        final AbstractIterator<Record> iterator = this.recordStore.newIterator(query, getProperties());
        return iterator;
    }
    throw new NoSuchElementException();
}
Also used : Query(com.revolsys.record.query.Query) FieldDefinition(com.revolsys.record.schema.FieldDefinition) Record(com.revolsys.record.Record) NoSuchElementException(java.util.NoSuchElementException) SqlCondition(com.revolsys.record.query.SqlCondition)

Example 25 with Query

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

the class AbstractRecordLayer method setSelectedRecordsById.

public void setSelectedRecordsById(final Identifier id) {
    final RecordDefinition recordDefinition = getRecordDefinition();
    if (recordDefinition != null) {
        final FieldDefinition idField = recordDefinition.getIdField();
        if (idField == null) {
            clearSelectedRecords();
        } else {
            final Query query = Query.where(Q::equal, idField, id);
            setSelectedRecords(query);
        }
    }
}
Also used : Q(com.revolsys.record.query.Q) Query(com.revolsys.record.query.Query) FieldDefinition(com.revolsys.record.schema.FieldDefinition) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Aggregations

Query (com.revolsys.record.query.Query)32 RecordDefinition (com.revolsys.record.schema.RecordDefinition)18 Record (com.revolsys.record.Record)10 FieldDefinition (com.revolsys.record.schema.FieldDefinition)8 Condition (com.revolsys.record.query.Condition)6 RecordReader (com.revolsys.record.io.RecordReader)5 Identifier (com.revolsys.identifier.Identifier)4 ArrayList (java.util.ArrayList)4 RecordWriter (com.revolsys.record.io.RecordWriter)3 RecordStore (com.revolsys.record.schema.RecordStore)3 JdbcRecordStore (com.revolsys.jdbc.io.JdbcRecordStore)2 ListRecordReader (com.revolsys.record.io.ListRecordReader)2 BinaryCondition (com.revolsys.record.query.BinaryCondition)2 SqlCondition (com.revolsys.record.query.SqlCondition)2 LayerRecord (com.revolsys.swing.map.layer.record.LayerRecord)2 CategoryLabelCountMap (com.revolsys.util.count.CategoryLabelCountMap)2 List (java.util.List)2 Map (java.util.Map)2 TreeMap (java.util.TreeMap)2 LruMap (com.revolsys.collection.map.LruMap)1