[rules-users] [flow][bpmn2] Variable not available in workitem?

David Wynter david_wynter at yahoo.com
Wed Nov 10 10:03:54 EST 2010


Hi,

My first bpmn2 workflow. With this the important part of the bpmn2 xml 
definition, transformationTest.bpmn2.

<?xml version="1.0" encoding="UTF-8"?> 
<definitions id="Definition"
             targetNamespace="http://www.jboss.org/drools"
             typeLanguage="http://www.java.com/javaTypes"
             expressionLanguage="http://www.mvel.org/2.0"
             xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
             xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
             xs:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL 
BPMN20.xsd"
             xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
             xmlns:dc="http://www.omg.org/spec/DD/20100524/DC"
             xmlns:di="http://www.omg.org/spec/DD/20100524/DI"
             xmlns:tns="http://www.jboss.org/drools">
             
  <itemDefinition id="_ETLGroupItem" 
structureRef="com.example.model.impl.ETLGroupImpl" />

  <process processType="Private" isExecutable="true" id="Test" name="Test 
Process" >

    <!-- process variables -->
    <property id="ETLGroup" itemSubjectRef="_ETLGroupItem"/>

    <!-- nodes -->
    <startEvent id="_1" name="StartProcess" />
    <task id="_2" name="ETLGroup" tns:taskName="ETLGroup" >
      <ioSpecification>
        <inputSet>
        </inputSet>
        <outputSet>
        </outputSet>
      </ioSpecification>
    </task>
    <endEvent id="_3" name="End" >
        <terminateEventDefinition/>
    </endEvent>

    <!-- connections -->
    <sequenceFlow id="_1-_2" sourceRef="_1" targetRef="_2" />
    <sequenceFlow id="_2-_3" sourceRef="_2" targetRef="_3" />

  </process>


I have this test case

@Before
public void setUp() throws Exception {
KnowledgeBuilder kb = KnowledgeBuilderFactory.newKnowledgeBuilder();
kb.add(ResourceFactory.newClassPathResource("transformationTest.bpmn2"), 
ResourceType.BPMN2);
if (kb.hasErrors()) {
throw new RuntimeException(kb.getErrors().toString());
}
 
KnowledgeBaseConfiguration configuration = 
KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
configuration.setProperty("drools.workDefinitions", "WorkDefinitions.conf 
etlgroup.conf");
KnowledgeBase knowledgeBase = 
KnowledgeBaseFactory.newKnowledgeBase(configuration);
knowledgeBase.addKnowledgePackages(kb.getKnowledgePackages());
session  = knowledgeBase.newStatefulKnowledgeSession();
TrackingProcessEventListener trackingprocel = new 
TrackingProcessEventListener();
session.addEventListener(trackingprocel);
session.getWorkItemManager().registerWorkItemHandler("ETLGroup", new 
ETLGroupWorkItemHandler());
WorkflowLoader wrkflwLdr = new WorkflowLoader();
etlGroup = wrkflwLdr.loadETLGroup("etlGroup", 
"/home/david/workspace/EDMEngine/META-INF/content.xml");
}
@Test
public void testSessionRun() {
   Map<String, Object> parameterMap = new HashMap<String, Object>();
   parameterMap.put("ETLGroup", etlGroup);
session.insert(etlGroup);
   ProcessInstance processInstance = session.startProcess("Test", parameterMap);
   session.insert(processInstance);
   session.fireAllRules();

}


I have this work item handler

public class ETLGroupWorkItemHandler implements WorkItemHandler {
private ETLGroupService service = null;

@Override
public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
ETLGroup etlGrp = (ETLGroup) workItem.getParameter("ETLGroup");
                ...

etlGroup in the @Before section is not null but etlGrp is always null? I must 
have missed something, but cannot see what it is. Can someone point it out to 
me?

Thx.

David


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20101110/b558cd60/attachment.html 


More information about the rules-users mailing list