use of org.folio.cql2pgjson.exception.QueryValidationException in project raml-module-builder by folio-org.
the class ValidationHelperTest method cql1Test.
@Test
public void cql1Test(TestContext context) {
Async async = context.async();
Exception e = new Exception();
e.initCause(new QueryValidationException(QueryValidationException1));
ValidationHelper.handleError(e, r -> {
context.assertEquals(422, r.result().getStatus());
async.complete();
});
}
use of org.folio.cql2pgjson.exception.QueryValidationException in project raml-module-builder by folio-org.
the class ValidationHelperTest method cql2Test.
@Test
public void cql2Test(TestContext context) {
Async async = context.async();
Exception e = new Exception();
e.initCause(new QueryValidationException(QueryValidationException2));
ValidationHelper.handleError(e, r -> {
context.assertEquals(422, r.result().getStatus());
async.complete();
});
}
use of org.folio.cql2pgjson.exception.QueryValidationException in project raml-module-builder by folio-org.
the class ValidationHelperTest method cql3Test.
@Test
public void cql3Test(TestContext context) {
Async async = context.async();
Exception e = new Exception();
e.initCause(new QueryValidationException(QueryValidationException3));
ValidationHelper.handleError(e, r -> {
context.assertEquals(422, r.result().getStatus());
async.complete();
});
}
use of org.folio.cql2pgjson.exception.QueryValidationException in project raml-module-builder by folio-org.
the class CQL2PgJSON method indexNode.
private String indexNode(String index, Table targetTable, CQLTermNode node, IndexTextAndJsonValues vals, CqlModifiers modifiers) throws QueryValidationException {
// primary key
if ("id".equals(index)) {
return pgId(node, index);
}
DbIndex dbIndex;
if (targetTable == null || dbTable.equals(targetTable)) {
dbIndex = dbIndexMap.computeIfAbsent(index, i -> DbSchemaUtils.getDbIndex(dbTable, index));
} else {
// foreign table
dbIndex = dbIndexMap.computeIfAbsent(vals.getIndexJson(), i -> DbSchemaUtils.getDbIndex(targetTable, index));
}
if (dbIndex.isForeignKey()) {
return pgId(node, index);
}
String comparator = node.getRelation().getBase().toLowerCase();
switch(comparator) {
case "=":
if (CqlTermFormat.NUMBER == modifiers.getCqlTermFormat()) {
return queryBySql(dbIndex, vals, node, comparator, modifiers);
} else {
return queryByFt(index, dbIndex, vals, node, comparator, modifiers, targetTable);
}
case "adj":
case "all":
case "any":
return queryByFt(index, dbIndex, vals, node, comparator, modifiers, targetTable);
case "==":
case "<>":
if (CqlTermFormat.STRING == modifiers.getCqlTermFormat()) {
return queryByLike(index, dbIndex, vals, node, comparator, modifiers, targetTable);
} else {
return queryBySql(dbIndex, vals, node, comparator, modifiers);
}
case "<":
case ">":
case "<=":
case ">=":
return queryBySql(dbIndex, vals, node, comparator, modifiers);
default:
throw new CQLFeatureUnsupportedException("Relation " + comparator + " not implemented yet: " + node.toString());
}
}
Aggregations