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>());
}
}
Aggregations