use of jakarta.nosql.column.ColumnCondition in project jnosql-diana by eclipse.
the class BaseQueryBuilder method inImpl.
protected <T> void inImpl(Iterable<T> values) {
requireNonNull(values, "values is required");
ColumnCondition newCondition = ColumnCondition.in(Column.of(name, values));
appendCondition(newCondition);
}
use of jakarta.nosql.column.ColumnCondition in project jnosql-diana by eclipse.
the class BaseQueryBuilder method betweenImpl.
protected <T> void betweenImpl(T valueA, T valueB) {
requireNonNull(valueA, "valueA is required");
requireNonNull(valueB, "valueB is required");
ColumnCondition newCondition = ColumnCondition.between(Column.of(name, asList(valueA, valueB)));
appendCondition(newCondition);
}
use of jakarta.nosql.column.ColumnCondition in project jnosql-diana-driver by eclipse.
the class Relations method load.
private static void load(ColumnCondition columnCondition, List<Relation> relations) {
Column column = columnCondition.getColumn();
Condition condition = columnCondition.getCondition();
switch(condition) {
case EQUALS:
relations.add(Relation.column(QueryUtils.getName(column)).isEqualTo(getTerm(column)));
return;
case GREATER_THAN:
relations.add(Relation.column(QueryUtils.getName(column)).isGreaterThan(getTerm(column)));
return;
case GREATER_EQUALS_THAN:
relations.add(Relation.column(QueryUtils.getName(column)).isGreaterThanOrEqualTo(getTerm(column)));
return;
case LESSER_THAN:
relations.add(Relation.column(QueryUtils.getName(column)).isLessThan(getTerm(column)));
return;
case LESSER_EQUALS_THAN:
relations.add(Relation.column(QueryUtils.getName(column)).isLessThanOrEqualTo(getTerm(column)));
return;
case IN:
relations.add(Relation.column(QueryUtils.getName(column)).in(getIinValue(column.getValue())));
return;
case LIKE:
relations.add(Relation.column(QueryUtils.getName(column)).like(getTerm(column)));
return;
case AND:
column.get(new TypeReference<List<ColumnCondition>>() {
}).forEach(cc -> load(cc, relations));
return;
case OR:
default:
throw new UnsupportedOperationException("The columnCondition " + condition + " is not supported in cassandra column driver");
}
}
use of jakarta.nosql.column.ColumnCondition in project jnosql-diana-driver by eclipse.
the class HBaseColumnFamilyManager method delete.
@Override
public void delete(ColumnDeleteQuery query) {
Objects.requireNonNull(query, "query is required");
ColumnCondition condition = query.getCondition().orElseThrow(() -> new IllegalArgumentException("Condition is required"));
checkedCondition(condition);
List<String> values = new ArrayList<>();
convert(condition, values);
List<Delete> deletes = values.stream().map(String::getBytes).map(Delete::new).collect(toList());
try {
table.delete(deletes);
} catch (IOException e) {
throw new HBaseException("An error when try to delete columns", e);
}
}
use of jakarta.nosql.column.ColumnCondition in project jnosql-diana by eclipse.
the class ColumnRepositoryProxyPaginationTest method shouldFindByAgeLessThanEqual.
@Test
public void shouldFindByAgeLessThanEqual() {
Person ada = Person.builder().withAge(20).withName("Ada").build();
when(template.select(any(ColumnQuery.class))).thenReturn(Stream.of(ada));
Pagination pagination = getPagination();
personRepository.findByAgeLessThanEqual(33, pagination);
ArgumentCaptor<ColumnQuery> captor = ArgumentCaptor.forClass(ColumnQuery.class);
verify(template).select(captor.capture());
ColumnQuery query = captor.getValue();
ColumnCondition condition = query.getCondition().get();
assertEquals("Person", query.getColumnFamily());
assertEquals(LESSER_EQUALS_THAN, condition.getCondition());
assertEquals(Column.of("age", 33), condition.getColumn());
assertEquals(pagination.getSkip(), query.getSkip());
assertEquals(pagination.getLimit(), query.getLimit());
}
Aggregations