use of org.activityinfo.store.query.shared.TableFilter in project activityinfo by bedatadriven.
the class ForeignKeyTest method filtering.
@Test
public void filtering() {
// Build the unfiltered foreign key map
// That maps row indexes to foreign keys
ResourceId formId = ResourceId.valueOf("a00001");
ForeignKeyBuilder builder = new ForeignKeyBuilder(formId, new PendingSlot<ForeignKey>());
builder.onNext(new ReferenceValue(new RecordRef(formId, ResourceId.valueOf("s0272548382"))));
builder.onNext(new ReferenceValue(new RecordRef(formId, ResourceId.valueOf("s0272548382"))));
builder.onNext(new ReferenceValue(new RecordRef(formId, ResourceId.valueOf("s0362622291"))));
builder.onNext(new ReferenceValue(new RecordRef(formId, ResourceId.valueOf("s0362622291"))));
builder.onNext(new ReferenceValue(new RecordRef(formId, ResourceId.valueOf("s0890848243"))));
builder.onNext(new ReferenceValue(new RecordRef(formId, ResourceId.valueOf("s0890848243"))));
ForeignKey fkMap = builder.build();
// Now define a filter that includes only the 4th and 5th rows
BitSet bitSet = new BitSet();
bitSet.set(4);
bitSet.set(5);
TableFilter filter = new TableFilter(bitSet);
// Apply the filter to the ForeignKey map and verify the results
ForeignKey filteredKey = filter.apply(fkMap);
assertThat(filteredKey.getKey(0), equalTo("s0890848243"));
assertThat(filteredKey.getKey(1), equalTo("s0890848243"));
}
use of org.activityinfo.store.query.shared.TableFilter in project activityinfo by bedatadriven.
the class ParentMask method get.
@Override
public TableFilter get() {
if (result == null) {
BitSet bitSet = new BitSet();
PrimaryKeyMap parentKeyMap = parentKeySlot.get();
ColumnView parentView = parentIdSlot.get();
for (int i = 0; i < parentView.numRows(); i++) {
String parentId = parentView.getString(i);
bitSet.set(i, parentKeyMap.contains(parentId));
}
result = new TableFilter(bitSet);
}
return result;
}
Aggregations