use of jakarta.nosql.query.Operator in project jnosql-diana by eclipse.
the class AbstractMethodQueryProvider method exitLte.
@Override
public void exitLte(MethodParser.LteContext ctx) {
boolean hasNot = Objects.nonNull(ctx.not());
String variable = getVariable(ctx.variable());
Operator operator = LESSER_EQUALS_THAN;
appendCondition(hasNot, variable, operator);
}
use of jakarta.nosql.query.Operator in project jnosql-diana by eclipse.
the class AbstractMethodQueryProvider method exitLt.
@Override
public void exitLt(MethodParser.LtContext ctx) {
boolean hasNot = Objects.nonNull(ctx.not());
String variable = getVariable(ctx.variable());
Operator operator = LESSER_THAN;
appendCondition(hasNot, variable, operator);
}
use of jakarta.nosql.query.Operator in project jnosql-diana by eclipse.
the class AbstractMethodQueryProvider method exitEq.
@Override
public void exitEq(MethodParser.EqContext ctx) {
Operator operator = EQUALS;
boolean hasNot = Objects.nonNull(ctx.not());
String variable = getVariable(ctx.variable());
appendCondition(hasNot, variable, operator);
}
use of jakarta.nosql.query.Operator in project jnosql-diana by eclipse.
the class AbstractQueryConvert method getPredicate.
protected GraphTraversal<Vertex, Vertex> getPredicate(GraphQueryMethod graphQuery, Condition condition, ClassMapping mapping) {
Operator operator = condition.getOperator();
String name = condition.getName();
String nativeName = mapping.getColumnField(name);
switch(operator) {
case EQUALS:
return __.has(nativeName, P.eq(graphQuery.getValue(name)));
case GREATER_THAN:
return __.has(nativeName, P.gt(graphQuery.getValue(name)));
case GREATER_EQUALS_THAN:
return __.has(nativeName, P.gte(graphQuery.getValue(name)));
case LESSER_THAN:
return __.has(nativeName, P.lt(graphQuery.getValue(name)));
case LESSER_EQUALS_THAN:
return __.has(nativeName, P.lte(graphQuery.getValue(name)));
case BETWEEN:
return __.has(nativeName, P.between(graphQuery.getValue(name), graphQuery.getValue(name)));
case IN:
return __.has(nativeName, P.within(graphQuery.getInValue(name)));
case NOT:
Condition notCondition = ((ConditionQueryValue) condition.getValue()).get().get(0);
return __.not(getPredicate(graphQuery, notCondition, mapping));
case AND:
return ((ConditionQueryValue) condition.getValue()).get().stream().map(c -> getPredicate(graphQuery, c, mapping)).reduce(GraphTraversal::and).orElseThrow(() -> new UnsupportedOperationException("There is an inconsistency at the AND operator"));
case OR:
return ((ConditionQueryValue) condition.getValue()).get().stream().map(c -> getPredicate(graphQuery, c, mapping)).reduce(GraphTraversal::or).orElseThrow(() -> new UnsupportedOperationException("There is an inconsistency at the OR operator"));
default:
throw new UnsupportedOperationException("There is not support to the type " + operator + " in graph");
}
}
use of jakarta.nosql.query.Operator in project jnosql-diana by eclipse.
the class DeleteByMethodQueryProviderTest method shouldReturnParserQuery6.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "deleteByAgeGreaterThanEqual" })
public void shouldReturnParserQuery6(String query) {
Operator operator = Operator.GREATER_EQUALS_THAN;
String variable = "age";
checkCondition(query, operator, variable);
}
Aggregations