use of io.spine.client.ColumnFilter in project core-java by SpineEventEngine.
the class EntityQueries method splitFilters.
private static Multimap<EntityColumn, ColumnFilter> splitFilters(CompositeColumnFilter filter, Collection<EntityColumn> entityColumns) {
final Multimap<EntityColumn, ColumnFilter> columnFilters = create(filter.getFilterCount(), 1);
for (ColumnFilter columnFilter : filter.getFilterList()) {
final EntityColumn column = findMatchingColumn(columnFilter, entityColumns);
checkFilterType(column, columnFilter);
columnFilters.put(column, columnFilter);
}
return columnFilters;
}
use of io.spine.client.ColumnFilter in project core-java by SpineEventEngine.
the class EntityQueries method toQueryParams.
private static QueryParameters toQueryParams(EntityFilters entityFilters, Collection<EntityColumn> entityColumns) {
final QueryParameters.Builder builder = QueryParameters.newBuilder();
for (CompositeColumnFilter filter : entityFilters.getFilterList()) {
final Multimap<EntityColumn, ColumnFilter> columnFilters = splitFilters(filter, entityColumns);
final CompositeOperator operator = filter.getOperator();
final CompositeQueryParameter parameter = CompositeQueryParameter.from(columnFilters, operator);
builder.add(parameter);
}
return builder.build();
}
use of io.spine.client.ColumnFilter in project core-java by SpineEventEngine.
the class ERepository method timeFilter.
private static Optional<CompositeColumnFilter> timeFilter(EventStreamQuery query) {
final CompositeColumnFilter.Builder timeFilter = CompositeColumnFilter.newBuilder().setOperator(ALL);
if (query.hasAfter()) {
final Timestamp timestamp = query.getAfter();
final ColumnFilter filter = gt(CREATED_TIME_COLUMN, timestamp);
timeFilter.addFilter(filter);
}
if (query.hasBefore()) {
final Timestamp timestamp = query.getBefore();
final ColumnFilter filter = lt(CREATED_TIME_COLUMN, timestamp);
timeFilter.addFilter(filter);
}
return buildFilter(timeFilter);
}
use of io.spine.client.ColumnFilter in project core-java by SpineEventEngine.
the class EntityQueryShould method paramsFromValues.
private static QueryParameters paramsFromValues(Map<EntityColumn, Object> values) {
final QueryParameters.Builder builder = QueryParameters.newBuilder();
final Multimap<EntityColumn, ColumnFilter> filters = HashMultimap.create(values.size(), 1);
for (Map.Entry<EntityColumn, Object> param : values.entrySet()) {
final EntityColumn column = param.getKey();
final ColumnFilter filter = ColumnFilter.newBuilder().setOperator(EQUAL).setValue(toAny(param.getValue())).setColumnName(column.getName()).build();
filters.put(column, filter);
}
return builder.add(CompositeQueryParameter.from(filters, ALL)).build();
}
use of io.spine.client.ColumnFilter in project core-java by SpineEventEngine.
the class EntityQueryShould method be_serializable.
@Test
public void be_serializable() {
final String columnName = deleted.name();
final EntityColumn column = findColumn(EntityWithLifecycle.class, columnName);
final ColumnFilter filter = ColumnFilters.eq(columnName, false);
final Multimap<EntityColumn, ColumnFilter> filters = of(column, filter);
final CompositeQueryParameter parameter = CompositeQueryParameter.from(filters, ALL);
final QueryParameters parameters = QueryParameters.newBuilder().add(parameter).build();
final Set<String> ids = singleton("my-awesome-id");
final EntityQuery<String> query = EntityQuery.of(ids, parameters);
reserializeAndAssert(query);
}
Aggregations