Help getting a condition to work
earniedyke Sep 11, 2006 3:22 PMGreetings all!!!!
I have been trying all day to get, what I think, is a simple process to work. I can never get it to think the account is NOT locked. No matter what value I set the locked variable to it always takes the default transition. I have tried every style of condition I could find referenced in this forum all to no avail.
Any and all help would be appreciated.
Earnie!
processdefinition.xml
<?xml version="1.0" encoding="UTF-8"?> <process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="test2"> <start-state name="BeginLogin"> <transition name="toCheckForLock" to="CheckForLockedAccount"></transition> </start-state> <end-state name="End"></end-state> <decision name="CheckForLockedAccount"> <transition name="Account is locked" to="AccountIsLocked"></transition> <transition name="Account is not locked" to="AccountIsNotLocked"> <condition expression="#{contextInstance.variables['locked'] == 'N'}"/> </transition> </decision> <node name="AccountIsLocked"> <controller> <variable name="message">Is</variable> </controller> <transition name="toEnd" to="End"></transition> </node> <node name="AccountIsNotLocked"> <controller> <variable name="message">Is NOT</variable> </controller> <transition name="toEnd" to="End"></transition> </node> </process-definition>
test case:
package com.sample; import java.io.FileInputStream; import junit.framework.TestCase; import org.jbpm.*; import org.jbpm.graph.def.ProcessDefinition; import org.jbpm.graph.exe.ProcessInstance; public class SimpleProcessTest extends TestCase { public void testSimpleProcess() throws Exception { JbpmConfiguration cfg = JbpmConfiguration.getInstance(); JbpmContext ctx = cfg.createJbpmContext(); try { FileInputStream fis = new FileInputStream("processes/test2/processdefinition.xml"); ProcessDefinition processDefinition = ProcessDefinition.parseXmlInputStream(fis); ctx.deployProcessDefinition(processDefinition); ProcessInstance instance = ctx.getGraphSession().findLatestProcessDefinition("test2").createProcessInstance(); instance.getContextInstance().setVariable("locked","N"); instance.signal(); System.out.println(instance.getContextInstance().getVariable("message") + " Locked? " + instance.getContextInstance().getVariable("locked")); } finally { ctx.close(); cfg.close(); } } }