Search in sources :

Example 1 with Operator

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);
}
Also used : Operator(com.bluenimble.platform.db.query.Query.Operator) Query(com.bluenimble.platform.db.query.Query) OSQLSynchQuery(com.orientechnologies.orient.core.sql.query.OSQLSynchQuery) CompiledQuery(com.bluenimble.platform.db.query.CompiledQuery) SqlQueryCompiler(com.bluenimble.platform.db.query.impls.SqlQueryCompiler) Select(com.bluenimble.platform.db.query.Select) SqlQueryCompiler(com.bluenimble.platform.db.query.impls.SqlQueryCompiler) QueryCompiler(com.bluenimble.platform.db.query.QueryCompiler)

Aggregations

CompiledQuery (com.bluenimble.platform.db.query.CompiledQuery)1 Query (com.bluenimble.platform.db.query.Query)1 Operator (com.bluenimble.platform.db.query.Query.Operator)1 QueryCompiler (com.bluenimble.platform.db.query.QueryCompiler)1 Select (com.bluenimble.platform.db.query.Select)1 SqlQueryCompiler (com.bluenimble.platform.db.query.impls.SqlQueryCompiler)1 OSQLSynchQuery (com.orientechnologies.orient.core.sql.query.OSQLSynchQuery)1