use of com.bluenimble.platform.db.query.Query.Operator in project serverless by bluenimble.
the class OrientDatabase method compile.
private CompiledQuery compile(String entity, Query.Construct construct, final Query query, final boolean returnBefore) throws DatabaseException {
final String fEntity = entity;
QueryCompiler compiler = new SqlQueryCompiler(construct) {
private static final long serialVersionUID = -1248971549807669897L;
@Override
protected void onQuery(Timing timing, Query query) throws DatabaseException {
super.onQuery(timing, query);
if (Timing.start.equals(timing)) {
return;
}
if (query.start() > 0) {
buff.append(Lang.SPACE).append(Sql.Skip).append(Lang.SPACE).append(query.start());
}
if (query.count() > 0) {
buff.append(Lang.SPACE).append(Sql.Limit).append(Lang.SPACE).append(query.count());
}
}
@Override
protected void onSelect(Timing timing, Select select) throws DatabaseException {
super.onSelect(timing, select);
if (Timing.end.equals(timing) && returnBefore) {
buff.append(Lang.SPACE).append(Sql.ReturnBefore);
}
}
@Override
protected String operatorFor(Operator operator) {
if (Operator.ftq.equals(operator)) {
return Lucene;
} else if (Operator.regex.equals(operator)) {
return Maches;
}
return super.operatorFor(operator);
}
@Override
protected void entity() {
buff.append(fEntity);
}
};
return compiler.compile(query);
}
Aggregations