use of org.folio.cql2pgjson.model.IndexTextAndJsonValues 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());
}
}
use of org.folio.cql2pgjson.model.IndexTextAndJsonValues in project raml-module-builder by folio-org.
the class CQL2PgJSON method getIndexTextAndJsonValues.
private IndexTextAndJsonValues getIndexTextAndJsonValues(String index) {
if (jsonFields != null && jsonFields.size() > 1) {
return multiFieldProcessing(index);
}
IndexTextAndJsonValues vals = new IndexTextAndJsonValues();
vals.setIndexJson(SqlUtil.Cql2PgUtil.cqlNameAsSqlJson(this.jsonField, index));
vals.setIndexText(SqlUtil.Cql2PgUtil.cqlNameAsSqlText(this.jsonField, index));
return vals;
}
Aggregations