Search in sources :

Example 6 with ForeignKey

use of org.activityinfo.store.query.shared.columns.ForeignKey in project activityinfo by bedatadriven.

the class FormScan method updateFromCache.

public void updateFromCache(Map<String, Object> cached) {
    // See which columns we could retrieve from cache
    for (FormulaNode fieldId : Lists.newArrayList(columnMap.keySet())) {
        ColumnView view = (ColumnView) cached.get(fieldCacheKey(fieldId));
        if (view != null) {
            // populate the pending result slot with the view from the cache
            columnMap.get(fieldId).set(view);
            // remove this column from the list of columns to fetch
            columnMap.remove(fieldId);
            // resolve the rowCount slot if still needed
            if (rowCount != null) {
                rowCount.set(view.numRows());
                rowCount = null;
            }
        }
    }
    // And which foreign keys...
    for (ForeignKeyId keyId : Lists.newArrayList(foreignKeyMap.keySet())) {
        ForeignKey map = (ForeignKey) cached.get(fkCacheKey(keyId));
        if (map != null) {
            foreignKeyMap.get(keyId).set(map);
            foreignKeyMap.remove(keyId);
        }
    }
    // Do we need a row count?
    if (rowCount != null) {
        Integer count = (Integer) cached.get(rowCountKey());
        if (count != null) {
            rowCount.set(count);
        }
    }
}
Also used : FormulaNode(org.activityinfo.model.formula.FormulaNode) ForeignKeyId(org.activityinfo.store.query.shared.join.ForeignKeyId) ColumnView(org.activityinfo.model.query.ColumnView) ForeignKey(org.activityinfo.store.query.shared.columns.ForeignKey)

Aggregations

ForeignKey (org.activityinfo.store.query.shared.columns.ForeignKey)6 ResourceId (org.activityinfo.model.resource.ResourceId)3 RecordRef (org.activityinfo.model.type.RecordRef)3 ReferenceValue (org.activityinfo.model.type.ReferenceValue)3 ForeignKeyBuilder (org.activityinfo.store.query.server.join.ForeignKeyBuilder)3 Test (org.junit.Test)3 ForeignKeyId (org.activityinfo.store.query.shared.join.ForeignKeyId)2 BitSet (java.util.BitSet)1 FormulaNode (org.activityinfo.model.formula.FormulaNode)1 ColumnView (org.activityinfo.model.query.ColumnView)1 TableFilter (org.activityinfo.store.query.shared.TableFilter)1