Search in sources :

Example 11 with Query

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

the class RecordLayerTableModel method exportRecords.

public void exportRecords(final Object target) {
    final TableRecordsMode tableRecordsMode = getTableRecordsMode();
    if (tableRecordsMode != null) {
        final Query query = getFilterQuery();
        tableRecordsMode.exportRecords(query, target);
    }
}
Also used : Query(com.revolsys.record.query.Query)

Example 12 with Query

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

the class RecordStoreLayer method newBoundingBoxQuery.

protected Query newBoundingBoxQuery(BoundingBox boundingBox) {
    final RecordDefinition recordDefinition = getInternalRecordDefinition();
    final FieldDefinition geometryField = recordDefinition.getGeometryField();
    boundingBox = convertBoundingBox(boundingBox);
    if (geometryField == null || Property.isEmpty(boundingBox)) {
        return null;
    } else {
        Query query = getQuery();
        query = query.newQuery(recordDefinition);
        query.and(F.envelopeIntersects(geometryField, boundingBox));
        return query;
    }
}
Also used : Query(com.revolsys.record.query.Query) FieldDefinition(com.revolsys.record.schema.FieldDefinition) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 13 with Query

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

the class RecordStoreLayer method getRecords.

@Override
public <R extends LayerRecord> List<R> getRecords(final Geometry geometry, final double distance) {
    if (Property.isEmpty(geometry) || !hasGeometryField()) {
        return Collections.emptyList();
    } else {
        final RecordDefinition recordDefinition = getRecordDefinition();
        final FieldDefinition geometryField = getGeometryField();
        final WithinDistance where = F.dWithin(geometryField, geometry, distance);
        final Query query = new Query(recordDefinition, where);
        return getRecords(query);
    }
}
Also used : Query(com.revolsys.record.query.Query) FieldDefinition(com.revolsys.record.schema.FieldDefinition) WithinDistance(com.revolsys.record.query.functions.WithinDistance) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 14 with Query

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

the class RecordStoreLayer method refreshDo.

@Override
protected void refreshDo() {
    synchronized (getSync()) {
        if (this.loadingWorker != null) {
            this.loadingWorker.cancel(true);
        }
        this.loadedBoundingBox = BoundingBox.empty();
        this.loadingBoundingBox = this.loadedBoundingBox;
        super.refreshDo();
    }
    final RecordStore recordStore = getRecordStore();
    final PathName pathName = getPathName();
    final CodeTable codeTable = recordStore.getCodeTable(pathName);
    if (codeTable != null) {
        codeTable.refresh();
    }
    if (hasIdField()) {
        final List<Identifier> identifiers = new ArrayList<>();
        synchronized (getSync()) {
            identifiers.addAll(this.recordsByIdentifier.keySet());
        }
        if (!identifiers.isEmpty()) {
            identifiers.sort(Identifier.comparator());
            final RecordDefinition recordDefinition = recordStore.getRecordDefinition(pathName);
            final List<FieldDefinition> idFields = recordDefinition.getIdFields();
            final int idFieldCount = idFields.size();
            if (idFieldCount == 1) {
                final FieldDefinition idField = idFields.get(0);
                final int pageSize = 999;
                final int identifierCount = identifiers.size();
                for (int i = 0; i < identifiers.size(); i += pageSize) {
                    final List<Identifier> queryIdentifiers = identifiers.subList(i, Math.min(identifierCount, i + pageSize));
                    final In in = Q.in(idField, queryIdentifiers);
                    final Query query = new Query(recordDefinition, in);
                    updateCachedRecords(recordStore, query);
                }
            } else if (!idFields.isEmpty()) {
                for (final Identifier identifier : identifiers) {
                    final Query query = new Query(recordDefinition, Q.equalId(idFields, identifier));
                    updateCachedRecords(recordStore, query);
                }
            }
        }
    }
}
Also used : CodeTable(com.revolsys.record.code.CodeTable) Identifier(com.revolsys.identifier.Identifier) Query(com.revolsys.record.query.Query) In(com.revolsys.record.query.In) RecordStore(com.revolsys.record.schema.RecordStore) FieldDefinition(com.revolsys.record.schema.FieldDefinition) ArrayList(java.util.ArrayList) PathName(com.revolsys.io.PathName) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 15 with Query

use of com.revolsys.record.query.Query 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)

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