Beispiel #1
0
        /// <exception cref="BpmnParseException"> if the parameter is invalid </exception>
        protected internal static ParameterValueProvider parseParamValueProvider(Element parameterElement)
        {
            // LIST
            if ("list".Equals(parameterElement.TagName))
            {
                IList <ParameterValueProvider> providerList = new List <ParameterValueProvider>();
                foreach (Element element in parameterElement.elements())
                {
                    // parse nested provider
                    providerList.Add(parseParamValueProvider(element));
                }
                return(new ListValueProvider(providerList));
            }

            // MAP
            if ("map".Equals(parameterElement.TagName))
            {
                SortedDictionary <ParameterValueProvider, ParameterValueProvider> providerMap = new SortedDictionary <ParameterValueProvider, ParameterValueProvider>();
                foreach (Element entryElement in parameterElement.elements("entry"))
                {
                    // entry must provide key
                    string keyAttribute = entryElement.attribute("key");
                    if (string.ReferenceEquals(keyAttribute, null) || keyAttribute.Length == 0)
                    {
                        throw new BpmnParseException("Missing attribute 'key' for 'entry' element", entryElement);
                    }
                    // parse nested provider
                    providerMap[new ElValueProvider(ExpressionManager.createExpression(keyAttribute))] = parseNestedParamValueProvider(entryElement);
                }
                return(new MapValueProvider(providerMap));
            }

            // SCRIPT
            if ("script".Equals(parameterElement.TagName))
            {
                ExecutableScript executableScript = parseCamundaScript(parameterElement);
                if (executableScript != null)
                {
                    return(new ScriptValueProvider(executableScript));
                }
                else
                {
                    return(new NullValueProvider());
                }
            }

            string textContent = parameterElement.Text.Trim();

            if (textContent.Length > 0)
            {
                // EL
                return(new ElValueProvider(ExpressionManager.createExpression(textContent)));
            }
            else
            {
                // NULL value
                return(new NullValueProvider());
            }
        }
Beispiel #2
0
        /// <summary>
        /// execute a given script in the environment
        /// </summary>
        /// <param name="script"> the <seealso cref="ExecutableScript"/> to execute </param>
        /// <param name="scope"> the scope in which to execute the script </param>
        /// <returns> the result of the script evaluation </returns>
        public virtual object Execute(ExecutableScript script, IVariableScope scope)
        {
            // get script engine
            IScriptEngine scriptEngine = scriptingEngines.GetScriptEngineForLanguage(script.Language);

            // create bindings
            IBindings bindings = scriptingEngines.CreateBindings(scriptEngine, scope);

            return(Execute(script, scope, bindings, scriptEngine));
        }
Beispiel #3
0
        public virtual object Execute(ExecutableScript script, IVariableScope scope, IBindings bindings, IScriptEngine scriptEngine)
        {
            string scriptLanguage = script.Language;
            // first, evaluate the env scripts (if any)
            IList <ExecutableScript> envScripts = getEnvScripts(scriptLanguage);

            foreach (ExecutableScript envScript in envScripts)
            {
                envScript.Execute(scriptEngine, scope, bindings);
            }

            // next evaluate the actual script
            return(script.Execute(scriptEngine, scope, bindings));
        }
Beispiel #4
0
        public virtual object execute(ExecutableScript script, VariableScope scope, Bindings bindings, ScriptEngine scriptEngine)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final String scriptLanguage = script.getLanguage();
            string scriptLanguage = script.Language;

            // first, evaluate the env scripts (if any)
            IList <ExecutableScript> envScripts = getEnvScripts(scriptLanguage);

            foreach (ExecutableScript envScript in envScripts)
            {
                envScript.execute(scriptEngine, scope, bindings);
            }

            // next evaluate the actual script
            return(script.execute(scriptEngine, scope, bindings));
        }
Beispiel #5
0
        protected internal virtual TaskListener initializeTaskListener(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context, CamundaTaskListener listener)
        {
            ICollection <CamundaField> fields            = listener.CamundaFields;
            IList <FieldDeclaration>   fieldDeclarations = initializeFieldDeclarations(element, activity, context, fields);

            ExpressionManager expressionManager = context.ExpressionManager;

            TaskListener taskListener = null;

            string        className          = listener.CamundaClass;
            string        expression         = listener.CamundaExpression;
            string        delegateExpression = listener.CamundaDelegateExpression;
            CamundaScript scriptElement      = listener.CamundaScript;

            if (!string.ReferenceEquals(className, null))
            {
                taskListener = new ClassDelegateTaskListener(className, fieldDeclarations);
            }
            else if (!string.ReferenceEquals(expression, null))
            {
                Expression expressionExp = expressionManager.createExpression(expression);
                taskListener = new ExpressionTaskListener(expressionExp);
            }
            else if (!string.ReferenceEquals(delegateExpression, null))
            {
                Expression delegateExp = expressionManager.createExpression(delegateExpression);
                taskListener = new DelegateExpressionTaskListener(delegateExp, fieldDeclarations);
            }
            else if (scriptElement != null)
            {
                ExecutableScript executableScript = initializeScript(element, activity, context, scriptElement);
                if (executableScript != null)
                {
                    taskListener = new ScriptTaskListener(executableScript);
                }
            }

            return(taskListener);
        }
Beispiel #6
0
        protected internal virtual object executeScript(string scriptSrc, VariableScope scope)
        {
            ProcessEngineConfigurationImpl processEngineConfiguration = Context.ProcessEngineConfiguration;
            ScriptFactory    scriptFactory = processEngineConfiguration.ScriptFactory;
            ExecutableScript script        = scriptFactory.createScriptFromSource(ScriptingEngines.DEFAULT_SCRIPTING_LANGUAGE, scriptSrc);

            ScriptInvocation invocation = new ScriptInvocation(script, scope);

            try
            {
                processEngineConfiguration.DelegateInterceptor.handleInvocation(invocation);
            }
            catch (Exception e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw new ProcessEngineException(e);
            }

            return(invocation.InvocationResult);
        }
Beispiel #7
0
 public ScriptTaskListener(ExecutableScript script)
 {
     this.script = script;
 }
Beispiel #8
0
 public CommandAnonymousInnerClass(ScriptCompilationTest outerInstance, ExecutableScript script, ScriptingEnvironment scriptingEnvironment)
 {
     this.outerInstance        = outerInstance;
     this.script               = script;
     this.scriptingEnvironment = scriptingEnvironment;
 }
Beispiel #9
0
        protected internal virtual object ExecuteScript(ExecutableScript script)
        {
            ScriptingEnvironment scriptingEnvironment = processEngineConfiguration.ScriptingEnvironment;

            return(processEngineConfiguration.CommandExecutorTxRequired.Execute(new CommandAnonymousInnerClass(this, script, scriptingEnvironment)));
        }
Beispiel #10
0
 public ScriptTaskActivityBehavior(ExecutableScript script, string resultVariable)
 {
     this.script         = script;
     this.resultVariable = resultVariable;
 }
Beispiel #11
0
 public ScriptCaseVariableListener(ExecutableScript script)
 {
     this.script = script;
 }
Beispiel #12
0
 public ScriptInvocation(ExecutableScript script, IVariableScope scope, IBaseDelegateExecution contextExecution)
     : base(contextExecution, null)
 {
     this._script = script;
     this._scope  = scope;
 }
Beispiel #13
0
 public ScriptInvocation(ExecutableScript script, IVariableScope scope) : this(script, scope, null)
 {
 }
Beispiel #14
0
 public ScriptExecutionListener(ExecutableScript script)
 {
     this.script = script;
 }