Search in sources :

Example 31 with Query

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

the class CodeTableProperty method loadAll.

public synchronized void loadAll() {
    final long time = System.currentTimeMillis();
    if (this.threadLoading.get() != Boolean.TRUE) {
        if (this.loading) {
            while (this.loading) {
                try {
                    wait(1000);
                } catch (final InterruptedException e) {
                }
            }
            return;
        } else {
            this.threadLoading.set(Boolean.TRUE);
            this.loading = true;
            try {
                final RecordDefinition recordDefinition = this.recordStore.getRecordDefinition(this.typePath);
                final Query query = new Query(recordDefinition);
                query.setFieldNames(recordDefinition.getFieldNames());
                for (final String order : this.orderBy) {
                    query.addOrderBy(order);
                }
                try (Reader<Record> reader = this.recordStore.getRecords(query)) {
                    final List<Record> codes = reader.toList();
                    final CategoryLabelCountMap statistics = this.recordStore.getStatistics();
                    if (statistics != null) {
                        statistics.getLabelCountMap("query").addCount(this.typePath, -codes.size());
                    }
                    Collections.sort(codes, new RecordFieldComparator(this.orderBy));
                    addValues(codes);
                }
                Property.firePropertyChange(this, "valuesChanged", false, true);
            } finally {
                this.loading = false;
                this.loaded = true;
                this.threadLoading.set(null);
                this.notifyAll();
            }
        }
    }
    Dates.debugEllapsedTime(this, "Load All: " + getTypePath(), time);
}
Also used : Query(com.revolsys.record.query.Query) CategoryLabelCountMap(com.revolsys.util.count.CategoryLabelCountMap) Record(com.revolsys.record.Record) RecordFieldComparator(com.revolsys.record.comparator.RecordFieldComparator) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Example 32 with Query

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

the class RecordHtmlUiBuilder method newDataTableMap.

@SuppressWarnings("unchecked")
public Map<String, Object> newDataTableMap(final HttpServletRequest request, final String pageName, final Map<String, Object> parameters) {
    final RecordDefinition recordDefinition = getRecordDefinition();
    Query query = (Query) parameters.get("query");
    if (query == null) {
        final Map<String, Object> filter = (Map<String, Object>) parameters.get("filter");
        query = Query.and(recordDefinition, filter);
    }
    final String fromClause = (String) parameters.get("fromClause");
    if (Property.hasValue(fromClause)) {
        query.setFromClause(fromClause);
    }
    return newDataTableMap(request, pageName, query);
}
Also used : Query(com.revolsys.record.query.Query) Map(java.util.Map) 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