Package de.innovationgate.wgpublisher.expressions.tmlscript

Examples of de.innovationgate.wgpublisher.expressions.tmlscript.RhinoExpressionEngineImpl$MasterFunction


        if (action == null) {
            throw new EvaluatorException("Could not retrieve TMLScript module '" + args[0] + "'");
        }

        // Fetch runtime and return function object
        RhinoExpressionEngineImpl runtime = fetchRuntime(cx);
       
        // Use Context Redirector as scope, so the objects implicit context always directs to the current script's context
        ContextRedirector redirector = new ContextRedirector();
       
        // Preserve thread locals
        ThreadLocalPreserver preserver = new ThreadLocalPreserver((RhinoContext) cx);
        preserver.preserve(RhinoExpressionEngine.TL_ACTIONDEFINITION, action);
        preserver.preserve(RhinoExpressionEngine.TL_SCRIPTNAME, "TMLScript-Object " + action.getModuleDatabase() + "/" + action.getModuleName());;
        try {
            Function func = runtime.getCompiledFunction(action.getCode(), (RhinoContext) cx, redirector);
            func.put(RhinoExpressionEngine.PARAM_ACTIONDEFINITION, func, action);
            return func;
        }
        finally {
            preserver.restore();
View Full Code Here


        Arguments parsedArgs = _buildOptionsVarargs.parse(args);
       
        Iterable<WGContent> contents = (Iterable<WGContent>) parsedArgs.get("contents");
        String titleExpr = (String) parsedArgs.get("title");
        TMLContext context = fetchInitialContext(cx);
        RhinoExpressionEngineImpl runtime = fetchRuntime(cx);
       
        List<String> options = new ArrayList<String>();
        if (parsedArgs.has("emptyTitle")) {
            options.add(String.valueOf(parsedArgs.get("emptyTitle")) + "|" + TMLForm.RELATION_NULLPLACE_HOLDER);
        }
       
        for (WGContent content : contents) {
            String title = content.getTitle();
            if (titleExpr != null) {
                TMLContext conContext = context.context(content);
                ExpressionResult result = runtime.evaluateExpression(titleExpr, conContext, ExpressionEngine.TYPE_EXPRESSION, null);
                if (!result.isError()) {
                    title = String.valueOf(result.getResult());
                }
            }
            options.add(title + "|" + content.getStructKey());
View Full Code Here

       
    }
   
    public static Object runFunction(Context cx, Scriptable thisObj, java.lang.Object[] args, Function funObj) {
        try {
            RhinoExpressionEngineImpl runtime = WGAGlobal.fetchRuntime(cx);
            VarArgParser.Arguments parsedArgs = _runMasterFunctionVarargs.parse(args);
           
            Function function = (Function) parsedArgs.get("function");
            TMLContext context = (TMLContext) parsedArgs.get("context");
            if (context == null) {
                context = WGAGlobal.fetchInitialContext(Context.getCurrentContext());
            }
           
            Object returnValue = runtime.runAsMaster(function, context, parsedArgs.getOverflowArgs().toArray());
            if (returnValue != null) {
                return Context.javaToJS(returnValue, thisObj);
            }
            else {
                return null;
View Full Code Here

        }
    }
   
    public static Object runMethod(Context cx, Scriptable thisObj, java.lang.Object[] args, Function funObj) {
        try {
            RhinoExpressionEngineImpl runtime = WGAGlobal.fetchRuntime(cx);
            VarArgParser.Arguments parsedArgs = _runMasterMethodVarargs.parse(args);
           
            Function function = (Function) parsedArgs.get("function");
            Object returnValue = runtime.runAsMaster(function, null, parsedArgs.getOverflowArgs().toArray());
            if (returnValue != null) {
                return Context.javaToJS(returnValue, thisObj);
            }
            else {
                return null;
View Full Code Here

        Design design = unwrapThisObj(thisObj);
       
        // For the current design redirect to WGAGlobal.callAction() which uses all location info from the current design
        if (design._isCurrentScriptDesign) {
            RhinoExpressionEngineImpl runtime = WGAGlobal.fetchRuntime(cx);
            return WGAGlobal.callAction(cx, runtime.getSharedScope().getWgaGlobal(), args, funObj);
        }
       
        VarArgParser.Arguments parsedArgs = WGAGlobal._callActionVarargs.parse(args);

        // Determine action id and action context
View Full Code Here

       
        Design design = unwrapThisObj(thisObj);
       
        // For the current design redirect to WGAGlobal.createObject() which uses all location info from the current design
        if (design._isCurrentScriptDesign) {
            RhinoExpressionEngineImpl runtime = WGAGlobal.fetchRuntime(cx);
            return WGAGlobal.createObject(cx, runtime.getSharedScope().getWgaGlobal(), args, funObj);
        }

        VarArgParser.Arguments parsedArgs = WGAGlobal._createObjectVarargs.parse(args);

        // Retrieve object definition, either as script or as Function object
View Full Code Here

       
        Design design = unwrapThisObj(thisObj);
       
        // For the current design redirect to WGAGlobal.loadObjectDefinition() which uses all location info from the current design
        if (design._isCurrentScriptDesign) {
            RhinoExpressionEngineImpl runtime = WGAGlobal.fetchRuntime(cx);
            return WGAGlobal.loadObjectDefinition(cx, runtime.getSharedScope().getWgaGlobal(), args, funObj);
        }

        VarArgParser.Arguments parsedArgs = WGAGlobal._loadObjectDefVarags.parse(args);

        TMLContext context = WGAGlobal.fetchInitialContext(cx);
        String actionID = (String) parsedArgs.get("id");
        NativeObject currentObject = (NativeObject) parsedArgs.get("currentObject");

        // Get the function def (might need to expand local name by the name of
        // the current action)
        // Locate object definition
        TMLAction action = null;
        try {
            if (design._currentObject != null) {
                TMLAction.Locator locator = WGAGlobal.determineActionLocator(cx, design._currentObject, context, actionID);
                action = context.getModuleActionByID(locator.getId(), locator.getDbkey());
            }
            else {
                action = context.getModuleActionByID(actionID, design._designContext.getDesignDB().getDbReference());
            }
        }
        catch (TMLActionException e) {
            throw new EvaluatorException("Could not retrieve TMLScript module '" + args[0] + "': " + e.getMessage());
        }
       
        if (action == null) {
            throw new EvaluatorException("Could not retrieve TMLScript module '" + args[0] + "'");
        }
       
        // Fetch runtime and return function object
        RhinoExpressionEngineImpl runtime = WGAGlobal.fetchRuntime(cx);
       
        // Use Context Redirector as scope, so the objects implicit context always directs to the current script's context
        ContextRedirector redirector = new ContextRedirector();
       
        // Preserve thread locals
        ThreadLocalPreserver preserver = new ThreadLocalPreserver((RhinoContext) cx);
        preserver.preserve(RhinoExpressionEngine.TL_ACTIONDEFINITION, action);
        preserver.preserve(RhinoExpressionEngine.TL_SCRIPTNAME, "TMLScript-Object " + action.getModuleDatabase() + "/" + action.getModuleName());;
        try {
            Function func = runtime.getCompiledFunction(action.getCode(), (RhinoContext) cx, redirector);
            func.put(RhinoExpressionEngine.PARAM_ACTIONDEFINITION, func, action);
            return func;
        }
        finally {
            preserver.restore();
View Full Code Here

TOP

Related Classes of de.innovationgate.wgpublisher.expressions.tmlscript.RhinoExpressionEngineImpl$MasterFunction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.