-
1. Re: Example decision node with bean shell script
ziya Sep 14, 2005 8:16 AM (in response to ziya)Hi there,
This is the example:<decision name="edit"> <transition name="edityes" to="editing"> <condition>[CDATA[ not okay ]]</condition> </transition> <transition name="editno" to="publish"> <condition>[CDATA[ okay ]]</condition> </transition> </decision>
--Ziya -
2. Re: Example decision node with bean shell script
eruiz Sep 16, 2005 2:08 AM (in response to ziya)We are using conditions like this:
<decision name="isNull"> <transition name="tr1" to="tr1"> <condition> executionContext.getVariable("techReserves") != null </condition> </transition> <transition name="tr2" to="tr2"> <condition> executionContext.getVariable("techReserves") == null </condition> </transition> </decision>
-
3. Re: Example decision node with bean shell script
sak Sep 22, 2005 1:00 AM (in response to ziya)hi
im not been abel to implement the decision node as its giving me error my processdefinition.xml file is........ <decision name="Check color"> <transition name="tr1" to="select color again"> <condition>executionContext.getVariable("color")=="red" </condition> </transition> <transition name="tr2" to="Check color slected"> <condition> executionContext.getVariable("color")=="blue" </condition> </transition> </decision> <task-node name="Check color slected"> <task swimlane="Head"> <controller> <variable name="color"/> </controller> </task> <transition name="tr1" to="end1"></transition> </task-node> <task-node name="select color again"> <task swimlane="Employee"> <controller> <variable name="color"/> </controller> </task>
The error i get isrun(Thread.java:534) java.lang.RuntimeException: decision 'Check color' selected non existing transition 'null' at org.jbpm.graph.node.Decision.execute(Decision.java:92) at org.jbpm.graph.def.Node.enter(Node.java:284) at org.jbpm.graph.def.Transition.take(Transition.java:92) at org.jbpm.graph.def.Node.leave(Node.java:349) at org.jbpm.graph.node.TaskNode.leave(TaskNode.java:167) at org.jbpm.graph.exe.Token.signal(Token.java:127) at org.jbpm.graph.exe.Token.signal(Token.java:92) at org.jbpm.taskmgmt.exe.TaskInstance.end(TaskInstance.java:341) at org.jbpm.taskmgmt.exe.TaskInstance.end(TaskInstance.java:272) at org.jbpm.webapp.bean.TaskBean.saveAndClose(TaskBean.java:122) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:138) at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:62) at javax.faces.component.UICommand.broadcast(UICommand.java:106)
do you have different implementation of decision node?
please help i`m stuck
thanks -
4. Re: Example decision node with bean shell script
kukeltje Sep 22, 2005 2:57 AM (in response to ziya)if both conditions resolve to 'false' there is no transition taken and probably you get this error (just a first quick guess)
-
5. Re: Example decision node with bean shell script
sak Sep 22, 2005 3:57 AM (in response to ziya)Hi
Thanks first for prompt reply Ronalds..you are correct to point that the both of the conditions in decision must be evaluating to false but i donno know why its happeniong although im fufilling one of the condition (i:e making it true) here is the stck trace13:15:03,834 DEBUG [TaskBean] Submitted button:Save and Close Task 13:15:03,834 DEBUG [GraphElement] event 'task-end' on 'Task(start)' for 'Token(/)' 13:15:03,834 DEBUG [TaskInstance] completion of task 'start' results in taking the default transition 13:15:03,850 DEBUG [GraphElement] event 'before-signal' on 'StartState(start)' for 'Token(/)' 13:15:03,850 DEBUG [GraphElement] event 'node-leave' on 'StartState(start)' for 'Token(/)' 13:15:03,850 DEBUG [GraphElement] event 'transition' on 'Transition(1fef1a0)' for 'Token(/)' 13:15:03,850 DEBUG [GraphElement] event 'node-enter' on 'Decision(Check color)' for 'Token(/)' 13:15:03,850 DEBUG [Script] script input: {taskInstance=null, color=blue, node=Decision(Check color), my favourite=nothing, token=Token(/), task=null, executionContext=ExecutionContext[Token(/)]} 13:15:04,006 DEBUG [Script] script output: {decision_condition_result=false} 13:15:04,006 DEBUG [Script] script input: {taskInstance=null, color=blue, node=Decision(Check color), my favourite=nothing, token=Token(/), task=null, executionContext=ExecutionContext[Token(/)]} 13:15:04,006 DEBUG [Script] script output: {decision_condition_result=false} 13:15:04,006 ERROR [MethodBindingImpl] Exception while invoking expression #{taskBean.saveAndClose} java.lang.RuntimeException: decision 'Check color' selected non existing transition 'null' at org.jbpm.graph.node.Decision.execute(Decision.java:92) at org.jbpm.graph.def.Node.enter(Node.java:284) at org.jbpm.graph.def.Transition.take(Transition.java:92) at org.jbpm.graph.def.Node.leave(Node.java:349) at org.jbpm.graph.node.StartState.leave(StartState.java:73)
as you see its reading the process variable color as blue and in the decison ode i have specified the transition.
please comment on that
any help will be appreciated.. -
6. Re: Example decision node with bean shell script
kukeltje Sep 22, 2005 4:15 AM (in response to ziya)wrong programming language ;-)
== "blue" must be .equals("blue")
Probaly needs some casting to string as well. -
7. Re: Example decision node with bean shell script
sak Sep 22, 2005 8:06 AM (in response to ziya)Thank you again Ronalds i corrected the error and itsworking fine..!!!!
here is the code for others if needed<decision name="Check color"> <transition name="tr1" to="select color again"> <condition> executionContext.getVariable("color").toString().equals("red") </condition> </transition> <transition name="tr2" to="Check color slected"> <condition> executionContext.getVariable("color").toString().equals("blue") </condition> </transition> </decision>
The values must be casted to String!!!! -
8. Re: Example decision node with bean shell script
sak Sep 22, 2005 9:07 AM (in response to ziya)hi
is it possible to check two conditions inside the decision node ?
likeexecutionContext.getVariable("color").toString().equals("red")||executionContext.getVariable("color")==null
that is if the process variable is null or the process variable equals to red(say)?
when i am doing its throwing up errors18:16:18,846 INFO [STDOUT] Caused by: Sourced file: inline evaluation of: ``decision_condition_result = ( executio xt.getVariable("color").toStr . . . '' : null : at Line: 2 : in file: inline evaluation of: ``decision_condition_result = ( executionContext.getVariable("color").toStr . . . '' : .toString ( ) Target exception: java.lang.NullPointerException: Attempt to invoke method toString on null value 18:16:18,846 INFO [STDOUT] at bsh.UtilTargetError.toEvalError(Unknown Source) 18:16:18,846 INFO [STDOUT] at bsh.UtilEvalError.toEvalError(Unknown Source) 18:16:18,846 INFO [STDOUT] at bsh.Reflect.invokeObjectMethod(Unknown Source) 18:16:18,846 INFO [STDOUT] at bsh.BSHPrimarySuffix.doName(Unknown Source) 18:16:18,846 INFO [STDOUT] at bsh.BSHPrimarySuffix.doSuffix(Unknown Source) 18:16:18,846 INFO [STDOUT] at bsh.BSHPrimaryExpression.eval(Unknown Source) 18:16:18,846 INFO [STDOUT] at bsh.BSHPrimaryExpression.eval(Unknown Source) 18:16:18,846 INFO [STDOUT] at bsh.BSHBinaryExpression.eval(Unknown Source) 18:16:18,846 INFO [STDOUT] at bsh.BSHPrimaryExpression.eval(Unknown Source) 18:16:18,846 INFO [STDOUT] at bsh.BSHPrimaryExpression.eval(Unknown Source) 18:16:18,846 INFO [STDOUT] at bsh.BSHAssignment.eval(Unknown Source) 18:16:18,846 INFO [STDOUT] at bsh.Interpreter.eval(Unknown Source) 18:16:18,846 INFO [STDOUT] at bsh.Interpreter.eval(Unknown Source) 18:16:18,846 INFO [STDOUT] at bsh.Interpreter.eval(Unknown Source) 18:16:18,846 INFO [STDOUT] at org.jbpm.graph.action.Script.eval(Script.java:108) 18:16:18,846 INFO [STDOUT] ... 53 more 18:16:18,846 ERROR [[/jbpm]] Root cause: can't evaluate beanshell script 'decision_condition_result = ( executionContext.getVariable("color").toString().equals("red")||executionContext.getVariable("color")==null );' java.lang.RuntimeException: can't evaluate beanshell script 'decision_condition_result = ( executionContext.getVariable("color").toString().equals("red")||executionContext.getVariable("color")==null );' tion.Script.eval(Script.java:117)
is there examples to implement the decision using scripts or handler class??
any help will be highly appreciated..
thanks -
9. Re: Example decision node with bean shell script
kukeltje Sep 22, 2005 1:24 PM (in response to ziya)like many opensource projects, jBPM contains lots of tests (I'm suspecting Tom to have a test-fetish, he once 'ordered' me to say 10 hail-maries because I only *said* to not like writing tests)
If you read the docs http://docs.jboss.com/jbpm/v3/userguide/processmodelling.html#nodetypedecision you can read that what you ask is possible. If you then search the tests, you will find a case under src\java.jbpm.test\org\jbpm\jpdl\exe
hth -
10. Re: Example decision node with bean shell script
koen.aers Sep 22, 2005 5:52 PM (in response to ziya)I am praying all the time... To be relieved of the sin for not knowing how to write good unit tests to test my gpd code... :-(
Regards,
Koen -
11. Re: Example decision node with bean shell script
kukeltje Sep 22, 2005 6:06 PM (in response to ziya)rotflol
-
12. Re: Example decision node with bean shell script
tom.baeyens Sep 26, 2005 7:27 AM (in response to ziya)what !?
i just ordered a box of rosemaries for you koen. start praying some more... with a lot of effort, you might make it to the purgatory :-)
regards, tom.