use of org.z3950.zing.cql.CQLRelation in project okapi by folio-org.
the class CQLUtilTest method reduce.
private String reduce(String input) {
CQLParser parser = new CQLParser(CQLParser.V1POINT2);
try {
CQLRelation rel = new CQLRelation("=");
CQLTermNode source = new CQLTermNode("source", rel, "kb");
CQLNode top = parser.parse(input);
Comparator<CQLTermNode> f = (CQLTermNode n1, CQLTermNode n2) -> n1.getIndex().equals(n2.getIndex()) ? 0 : -1;
CQLNode res = CQLUtil.reducer(top, source, f);
if (res == null) {
return "null";
} else {
return res.toCQL();
}
} catch (Exception ex) {
return "Error: " + ex.getMessage();
}
}
use of org.z3950.zing.cql.CQLRelation in project okapi by folio-org.
the class CQLUtilTest method eval.
private boolean eval(String input) {
CQLParser parser = new CQLParser(CQLParser.V1POINT2);
try {
CQLRelation rel = new CQLRelation("=");
CQLTermNode source = new CQLTermNode("source", rel, "kb");
CQLNode top = parser.parse(input);
Comparator<CQLTermNode> f = (CQLTermNode n1, CQLTermNode n2) -> {
if (n1.getIndex().equals(n2.getIndex()) && !n1.getTerm().equals(n2.getTerm())) {
return -1;
}
return 0;
};
return CQLUtil.eval(top, source, f);
} catch (Exception ex) {
return false;
}
}
Aggregations