Gary Struthers [
http://community.jboss.org/people/GaryS] created the discussion
"Re: Can a POJO be Parameter Mapped?"
To view the discussion, visit:
http://community.jboss.org/message/618900#618900
--------------------------------------------------------------
Thanks Demian,
I'm still doing something wrong but I don't see it.
I followed the example carefully but I am still getting a null ServiceTask parameter.
Before I get to the ServiceTask I have a HumanTask with the same POJO as input and output
in my BPMN file. I'm using the example TestWorkItemHandler and not doing anything with
the POJO. Do I need to?
In the ServiceTask I'm using ServiceTaskHandler.
In jUnit...
@Test
public void evaluateScore() throws Exception {
// given
final StatefulKnowledgeSession kSession = createKnowledgeSession(fr.getKbase());
TestWorkItemHandler testWorkItemHandler = new TestWorkItemHandler();
kSession.getWorkItemManager().registerWorkItemHandler("Human
Task", testWorkItemHandler);
WorkItemManager wim = kSession.getWorkItemManager();
kSession.getWorkItemManager().registerWorkItemHandler("Service
Task", new ServiceTaskHandler());
...
Map<String, Object> params = new HashMap<String,
Object>();
params.put("vars", vars);
...
new Thread(new Runnable() {
public void run() {
kSession.fireUntilHalt(); // fireAllRules hangs
}
}).start();
ProcessInstance pi =
kSession.startProcess("x.x.x.workflow.xxx", params);
Thread.sleep(250);
// then
assertTrue(pi.getState() == ProcessInstance.STATE_ACTIVE);
restoreSession(kSession, true);
WorkItem workItem = testWorkItemHandler.getWorkItem();
assertNotNull(workItem);
assertEquals(workItem.PENDING, workItem.getState());
...
wim.completeWorkItem(workItem.getId(), null);
After completing the HumanTask workItem it executes the ServiceTask
public XX execute(XX vars) {
if(vars == null) { //@FIXME shouldn't be null
vars = new XX();
vars.setValidScore(true);
}
if(vars.isCanScore()) { //@TODO real implementation
vars.setValidScore(true);
}
return vars;
}
In BPMN
...
<itemDefinition id="_varsItem" structureRef="x.x.x.workflow.xxx"
/>
...
<itemDefinition id="_11_InMessageType"
structureRef=""x.x.x.workflow.xxx" />
<message id="_11_InMessage" itemRef="_11_InMessageType" />
<interface id="_11_ServiceInterface"
name=""x.x.x.workflow.xxx.EvaluateScore">
<operation id="_11_ServiceOperation" name="execute">
<inMessageRef>_11_InMessage</inMessageRef>
</operation>
</interface>
...
<!-- process variables -->
<property id="vars" itemSubjectRef="_varsItem"/>
...
<serviceTask id="_11" name="Evaluate Score"
operationRef="_11_ServiceOperation" implementation="Other" >
<ioSpecification>
<dataInput id="_11_varsInput" name="vars" />
<dataOutput id="_11_varsOutput" name="vars" />
<inputSet>
<dataInputRefs>_11_varsInput</dataInputRefs>
</inputSet>
<outputSet>
<dataOutputRefs>_11_varsOutput</dataOutputRefs>
</outputSet>
</ioSpecification>
<dataInputAssociation>
<sourceRef>vars</sourceRef>
<targetRef>_11_varsInput</targetRef>
</dataInputAssociation>
<dataOutputAssociation>
<sourceRef>_11_varsOutput</sourceRef>
<targetRef>vars</targetRef>
</dataOutputAssociation>
</serviceTask>
+
+
--------------------------------------------------------------
Reply to this message by going to Community
[
http://community.jboss.org/message/618900#618900]
Start a new discussion in jBPM at Community
[
http://community.jboss.org/choose-container!input.jspa?contentType=1&...]