use of org.jnosql.diana.api.document.DocumentCondition in project jnosql-artemis by eclipse.
the class DocumentQueryDeleteParser method parse.
public DocumentDeleteQuery parse(String methodName, Object[] args, ClassRepresentation representation, Converters converters) {
String[] tokens = methodName.replace(PREFIX, DocumentQueryParserUtil.EMPTY).split(TOKENIZER);
DocumentCondition condition = null;
int index = 0;
for (String token : tokens) {
if (token.startsWith(DocumentQueryParserUtil.AND)) {
ConditionResult result = and(args, index, token, methodName, representation, condition, converters);
condition = result.getCondition();
index = result.getIndex();
} else if (token.startsWith(DocumentQueryParserUtil.OR)) {
ConditionResult result = or(args, index, token, methodName, representation, condition, converters);
condition = result.getCondition();
index = result.getIndex();
} else {
condition = toCondition(token, index, args, methodName, representation, converters);
index++;
}
}
return new ArtemisDocumentDeleteQuery(representation.getName(), condition);
}
use of org.jnosql.diana.api.document.DocumentCondition in project jnosql-artemis by eclipse.
the class DocumentQueryParser method parse.
public DocumentQuery parse(String methodName, Object[] args, ClassRepresentation representation, Converters converters) {
String[] tokens = methodName.replace(PREFIX, EMPTY).split(TOKENIZER);
String className = representation.getClassInstance().getName();
DocumentCondition condition = null;
List<Sort> sorts = new ArrayList<>();
long limit = 0;
long start = 0;
int index = 0;
for (String token : tokens) {
if (token.startsWith(AND)) {
DocumentQueryParserUtil.ConditionResult result = and(args, index, token, methodName, representation, condition, converters);
condition = result.getCondition();
index = result.getIndex();
} else {
if (token.startsWith(ORDER_BY)) {
sort(sorts, token, representation);
} else if (token.startsWith(DocumentQueryParserUtil.OR)) {
DocumentQueryParserUtil.ConditionResult result = or(args, index, token, methodName, representation, condition, converters);
condition = result.getCondition();
index = result.getIndex();
} else {
condition = toCondition(token, index, args, methodName, representation, converters);
index++;
}
}
}
while (index < args.length) {
Object value = args[index];
if (Sort.class.isInstance(value)) {
sorts.add(Sort.class.cast(value));
} else if (Pagination.class.isInstance(value)) {
Pagination pagination = Pagination.class.cast(value);
limit = pagination.getMaxResults();
start = pagination.getFirstResult();
} else {
LOGGER.info(String.format("Ignoring parameter %s on methodName %s class name %s arg-number: %d", String.valueOf(value), methodName, className, index));
}
index++;
}
return new ArtemisDocumentQuery(sorts, limit, start, condition, representation.getName());
}
use of org.jnosql.diana.api.document.DocumentCondition in project jnosql-artemis by eclipse.
the class DocumentQueryParserUtil method and.
static ConditionResult and(Object[] args, int index, String token, String methodName, ClassRepresentation representation, DocumentCondition queryCondition, Converters converters) {
String field = token.replace(DocumentQueryParserUtil.AND, DocumentQueryParserUtil.EMPTY);
DocumentCondition conditionResult = toCondition(field, index, args, methodName, representation, converters);
DocumentCondition condition = null;
if (queryCondition == null) {
condition = conditionResult;
} else {
condition = queryCondition.and(conditionResult);
}
if (Condition.BETWEEN.equals(condition.getCondition())) {
return new ConditionResult(index + 2, condition);
} else {
return new ConditionResult(++index, condition);
}
}
use of org.jnosql.diana.api.document.DocumentCondition in project jnosql-artemis by eclipse.
the class DocumentQueryParserUtil method or.
static ConditionResult or(Object[] args, int index, String token, String methodName, ClassRepresentation representation, DocumentCondition queryCondition, Converters converters) {
String field = token.replace(DocumentQueryParserUtil.OR, DocumentQueryParserUtil.EMPTY);
DocumentCondition conditionResult = toCondition(field, index, args, methodName, representation, converters);
DocumentCondition condition = null;
if (queryCondition == null) {
condition = conditionResult;
} else {
condition = queryCondition.or(conditionResult);
}
if (Condition.BETWEEN.equals(condition.getCondition())) {
return new ConditionResult(index + 2, condition);
} else {
return new ConditionResult(++index, condition);
}
}
use of org.jnosql.diana.api.document.DocumentCondition in project jnosql-artemis by eclipse.
the class AbstractMapperQuery method gtImpl.
protected void gtImpl(Number value) {
requireNonNull(value, "value is required");
DocumentCondition newCondition = DocumentCondition.gt(Document.of(representation.getColumnField(name), getValue(value)));
appendCondition(newCondition);
}
Aggregations