Search in sources :

Example 1 with OSQLFunction

use of com.orientechnologies.orient.core.sql.functions.OSQLFunction in project orientdb by orientechnologies.

the class OFunctionCall method execute.

private Object execute(Object targetObjects, OCommandContext ctx, String name) {
    List<Object> paramValues = new ArrayList<Object>();
    OIdentifiable record = ctx == null ? null : (OIdentifiable) ctx.getVariable("$current");
    if (record == null && targetObjects instanceof OIdentifiable) {
        record = (OIdentifiable) targetObjects;
    }
    for (OExpression expr : this.params) {
        paramValues.add(expr.execute(record, ctx));
    }
    OSQLFunction function = OSQLEngine.getInstance().getFunction(name);
    if (function != null) {
        return function.execute(targetObjects, record, null, paramValues.toArray(), ctx);
    }
    throw new UnsupportedOperationException("This expression is not currently supported: " + toString());
}
Also used : ArrayList(java.util.ArrayList) OSQLFunction(com.orientechnologies.orient.core.sql.functions.OSQLFunction) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable)

Example 2 with OSQLFunction

use of com.orientechnologies.orient.core.sql.functions.OSQLFunction in project orientdb by orientechnologies.

the class OMethodCall method execute.

private Object execute(Object targetObjects, OCommandContext ctx, String name, List<OExpression> iParams, Iterable<OIdentifiable> iPossibleResults) {
    List<Object> paramValues = new ArrayList<Object>();
    for (OExpression expr : iParams) {
        paramValues.add(expr.execute((OIdentifiable) ctx.getVariable("$current"), ctx));
    }
    if (graphMethods.contains(name)) {
        OSQLFunction function = OSQLEngine.getInstance().getFunction(name);
        if (function instanceof OSQLFunctionFiltered) {
            return ((OSQLFunctionFiltered) function).execute(targetObjects, (OIdentifiable) ctx.getVariable("$current"), null, paramValues.toArray(), iPossibleResults, ctx);
        } else {
            return function.execute(targetObjects, (OIdentifiable) ctx.getVariable("$current"), null, paramValues.toArray(), ctx);
        }
    }
    OSQLMethod method = OSQLEngine.getMethod(name);
    if (method != null) {
        return method.execute(targetObjects, (OIdentifiable) ctx.getVariable("$current"), ctx, targetObjects, paramValues.toArray());
    }
    throw new UnsupportedOperationException("OMethod call, something missing in the implementation...?");
}
Also used : OSQLFunction(com.orientechnologies.orient.core.sql.functions.OSQLFunction) OIdentifiable(com.orientechnologies.orient.core.db.record.OIdentifiable) OSQLMethod(com.orientechnologies.orient.core.sql.method.OSQLMethod) OSQLFunctionFiltered(com.orientechnologies.orient.core.sql.functions.OSQLFunctionFiltered)

Aggregations

OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)2 OSQLFunction (com.orientechnologies.orient.core.sql.functions.OSQLFunction)2 OSQLFunctionFiltered (com.orientechnologies.orient.core.sql.functions.OSQLFunctionFiltered)1 OSQLMethod (com.orientechnologies.orient.core.sql.method.OSQLMethod)1 ArrayList (java.util.ArrayList)1