/// <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()); } }
/// <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)); }
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)); }
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)); }
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); }
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); }
public ScriptTaskListener(ExecutableScript script) { this.script = script; }
public CommandAnonymousInnerClass(ScriptCompilationTest outerInstance, ExecutableScript script, ScriptingEnvironment scriptingEnvironment) { this.outerInstance = outerInstance; this.script = script; this.scriptingEnvironment = scriptingEnvironment; }
protected internal virtual object ExecuteScript(ExecutableScript script) { ScriptingEnvironment scriptingEnvironment = processEngineConfiguration.ScriptingEnvironment; return(processEngineConfiguration.CommandExecutorTxRequired.Execute(new CommandAnonymousInnerClass(this, script, scriptingEnvironment))); }
public ScriptTaskActivityBehavior(ExecutableScript script, string resultVariable) { this.script = script; this.resultVariable = resultVariable; }
public ScriptCaseVariableListener(ExecutableScript script) { this.script = script; }
public ScriptInvocation(ExecutableScript script, IVariableScope scope, IBaseDelegateExecution contextExecution) : base(contextExecution, null) { this._script = script; this._scope = scope; }
public ScriptInvocation(ExecutableScript script, IVariableScope scope) : this(script, scope, null) { }
public ScriptExecutionListener(ExecutableScript script) { this.script = script; }