JBoss Community

Re: Any help how to play with WorkItemHandler with parameter mapping ?

created by rickylkl in jBPM - View the full discussion

Dear,

 

I try to update the src here.

 

private void testDrlJbpm(Channel channel){

                    Map<String,Object> map = new HashMap<String,Object>();

                    map.put("channel", channel);

                    map.put("x","hello world");

                    ksession.insert(channel);                                                  //          if there is a rule flow in workflow, need to insert obj to run rule

                    ksession.getWorkItemManager().registerWorkItemHandler("ShowRegPage", new RegistrationHandler());

         ProcessInstance processInstance = (ProcessInstance) ksession.startProcess("testflow-web", map);          //          passing map inside the process, and use kcontext.getvariable() to get obj on if else case

                    System.out.println(processInstance.getEventTypes());

                    System.out.println(processInstance.getId());

                    System.out.println(processInstance.getProcessId());

          ksession.fireAllRules();

          }

 

 

bpmn file:

  <itemDefinition id="_xItem" structureRef="String" />

  <itemDefinition id="_35-xItem" structureRef="String" />

  <itemDefinition id="_32-xItem" structureRef="String" />

  <itemDefinition id="_33-xItem" structureRef="String" />

  <process processType="Private" isExecutable="true" id="testflow-web" name="testflow-web" >

 

    <extensionElements>

     <tns:import name="org.drools.runtime.process.WorkflowProcessInstance" />

    </extensionElements>

    <!-- process variables -->

   <property id="x" itemSubjectRef="_xItem"/>

 

    <!-- nodes -->

    <task id="_35" name="ShowRegPage" tns:taskName="ShowRegPage" >

     <ioSpecification>

        <dataInput id="_35_xInput" name="x" />

        <inputSet>

          <dataInputRefs>_35_xInput</dataInputRefs>

        </inputSet>

        <outputSet>

        </outputSet>

      </ioSpecification>

      <dataInputAssociation>

        <sourceRef>x</sourceRef>

        <targetRef>_35_xInput</targetRef>

      </dataInputAssociation>

    </task>

 

 

work item handler:

 

@Override

          public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {

  System.out.println("========= Executing registration =============" + workItem);

          }

 

result: workItem parameter cant not GET 'X' .... pls help :(

 

Best Regards

Reply to this message by going to Community

Start a new discussion in jBPM at Community