Search in sources :

Example 6 with OSQLPredicate

use of com.orientechnologies.orient.core.sql.filter.OSQLPredicate in project orientdb by orientechnologies.

the class OConsoleDatabaseApp method move.

@ConsoleCommand(splitInWords = false, description = "Move from current record by evaluating a predicate against current record")
public void move(@ConsoleParameter(name = "text", description = "The sql predicate to evaluate") final String iText) {
    if (iText == null)
        return;
    if (currentRecord == null)
        return;
    final Object result = new OSQLPredicate(iText).evaluate(currentRecord, null, null);
    if (result != null) {
        if (result instanceof OIdentifiable) {
            setResultset(new ArrayList<OIdentifiable>());
            currentRecord = ((OIdentifiable) result).getRecord();
            dumpRecordDetails();
        } else if (result instanceof List<?>) {
            setResultset((List<OIdentifiable>) result);
            dumpResultSet(-1);
        } else if (result instanceof Iterator<?>) {
            final List<OIdentifiable> list = new ArrayList<OIdentifiable>();
            while (((Iterator) result).hasNext()) list.add(((Iterator<OIdentifiable>) result).next());
            setResultset(list);
            dumpResultSet(-1);
        } else
            setResultset(new ArrayList<OIdentifiable>());
    }
}
Also used : OSQLPredicate(com.orientechnologies.orient.core.sql.filter.OSQLPredicate) OIdentifiableIterator(com.orientechnologies.orient.core.iterator.OIdentifiableIterator) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) ConsoleCommand(com.orientechnologies.common.console.annotation.ConsoleCommand)

Aggregations

OSQLPredicate (com.orientechnologies.orient.core.sql.filter.OSQLPredicate)6 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)2 ORecord (com.orientechnologies.orient.core.record.ORecord)2 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)2 ConsoleCommand (com.orientechnologies.common.console.annotation.ConsoleCommand)1 OContextVariableResolver (com.orientechnologies.common.parser.OContextVariableResolver)1 OCommandContext (com.orientechnologies.orient.core.command.OCommandContext)1 OCommandExecutorNotFoundException (com.orientechnologies.orient.core.command.OCommandExecutorNotFoundException)1 OTraverse (com.orientechnologies.orient.core.command.traverse.OTraverse)1 OAutoConvertToRecord (com.orientechnologies.orient.core.db.record.OAutoConvertToRecord)1 OCommandExecutionException (com.orientechnologies.orient.core.exception.OCommandExecutionException)1 ORecordId (com.orientechnologies.orient.core.id.ORecordId)1 OIdentifiableIterator (com.orientechnologies.orient.core.iterator.OIdentifiableIterator)1 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)1 OSQLFilterItemField (com.orientechnologies.orient.core.sql.filter.OSQLFilterItemField)1 OSQLFilterItemVariable (com.orientechnologies.orient.core.sql.filter.OSQLFilterItemVariable)1 OSQLFunctionRuntime (com.orientechnologies.orient.core.sql.functions.OSQLFunctionRuntime)1 OSQLMethod (com.orientechnologies.orient.core.sql.method.OSQLMethod)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1