-
1. Re: Any help how to play with WorkItemHandler with parameter mapping ?
rickylkl Oct 26, 2012 3:31 AM (in response to rickylkl)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
-
2. Re: Any help how to play with WorkItemHandler with parameter mapping ?
joe.chuah Oct 28, 2012 10:16 PM (in response to rickylkl)AFAIK, the map you inserted belongs to the ProcessInstance "testflow-web". Hence to get the data from the map, you have to obtain the ProcessInstance inside your work item handler then use the getVariable() method to obtain the parameter you passed in when you started the process.
The parameter mapping used in the nodes in the diagram is for mapping variables which are present in the diagram itself (Open the bpmn diagram's properties and there is a row for variables where you can add/remove variables used in the Parameter Mapping
-
3. Re: Any help how to play with WorkItemHandler with parameter mapping ?
rickylkl Oct 28, 2012 10:40 PM (in response to joe.chuah)Dear,
Thanks & Regards