[jBPM] - Best practices for building custom tasklist queries
by Olly Edgell
Olly Edgell [https://community.jboss.org/people/nofranksuk] created the discussion
"Best practices for building custom tasklist queries"
To view the discussion, visit: https://community.jboss.org/message/811202#811202
--------------------------------------------------------------
Hi All,
I'm currently evaluating Jbpm 5.4 for my company and am creating a non-trivial prototype. I have the task service started in a servlet to which the task client connects over hornetq.
I need to be able to display a list of "current" group tasks to a user per process type, so filtered on process id. I can see how the built-in task list queries are executed via the Command object in the TaskClient and how these relate to the queries specified in the Taskorm-JPA2.xml packaged with the TaskService. What I'm unclear on is the best way to go about including my own queries to construct task lists.
I note the query method on the task client has been deprecated though this seems like the best option I have. Ideally I would extend the TaskClient class and provide my own methods working in the same way as the existing ones. Has this functionality been replaced by something else? Another way I can think of implementing it is via remote calls to the task server via ejb3 or web services that utilise the task persistence context but this doesn't seem like a good solution. Any advice would be greatly appreciated.
Olly Edgell
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/811202#811202]
Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
10 years, 12 months
[jBPM] - Pass the result of a workitem to the next workitem with a workitemhandler
by hansi007
hansi007 [https://community.jboss.org/people/hansi007] created the discussion
"Pass the result of a workitem to the next workitem with a workitemhandler"
To view the discussion, visit: https://community.jboss.org/message/738803#738803
--------------------------------------------------------------
Is it possible to pass the results of a workitem to the next workitem with a workitemhandler:
public class MyHandlerWorkItemTypeA implements WorkItemHandler{
@Override
public final void executeWorkItem(WorkItem wItem, WorkItemManager wItemManager) {
Map<String,Object> objectToPassToTheNextWorkItem = ...
wItemManager.completeWorkItem(wItem.getId(), objectToPassToTheNextWorkItem ); //That doesnt work
}
@Override
public final void abortWorkItem(WorkItem wItem, WorkItemManager wItemManager) {
}
}
public class MyHandlerWorkItemTypeB implements WorkItemHandler{
@Override
public final void executeWorkItem(WorkItem wItem, WorkItemManager wItemManager) {
Map<String,Object> objectToGetFromThePreviousWorkItem = wItem.getResults(); //That doesnt work
}
@Override
public final void abortWorkItem(WorkItem wItem, WorkItemManager wItemManager) {
}
}
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/738803#738803]
Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
10 years, 12 months
[jBPM] - Duplicate entries in bpmn2 file
by David Harris
David Harris [https://community.jboss.org/people/dmwpepper] created the discussion
"Duplicate entries in bpmn2 file"
To view the discussion, visit: https://community.jboss.org/message/811311#811311
--------------------------------------------------------------
I'm getting the following error when executing a process that references a work item definition file:
0 02/05 15:15:16,856[main] ERROR drools.xml.ExtensibleXmlParser.error - (null: 40, 62): cvc-id.2: There are multiple occurrences of ID value '_4_Source_IPInput'.
16 02/05 15:15:16,872[main] ERROR drools.xml.ExtensibleXmlParser.error - (null: 40, 62): cvc-attribute.3: The value '_4_Source_IPInput' of attribute 'id' on element 'dataInput' is not valid with respect to its type, 'ID'.
16 02/05 15:15:16,872[main] ERROR drools.xml.ExtensibleXmlParser.error - (null: 41, 64): cvc-id.2: There are multiple occurrences of ID value '_4_Start_DateInput'.
16 02/05 15:15:16,872[main] ERROR drools.xml.ExtensibleXmlParser.error - (null: 41, 64): cvc-attribute.3: The value '_4_Start_DateInput' of attribute 'id' on element 'dataInput' is not valid with respect to its type, 'ID'.
16 02/05 15:15:16,872[main] ERROR drools.xml.ExtensibleXmlParser.error - (null: 42, 60): cvc-id.2: There are multiple occurrences of ID value '_4_End_DateInput'.
16 02/05 15:15:16,872[main] ERROR drools.xml.ExtensibleXmlParser.error - (null: 42, 60): cvc-attribute.3: The value '_4_End_DateInput' of attribute 'id' on element 'dataInput' is not valid with respect to its type, 'ID'.
parameters passed into work item: 111.111.111.111,2013 05 02 09:00:00,2013 04 02 09:00:00####
The last line above, in green, was the output I expected. Looking at the bpmn2 file below shows the duplicate xml occurences, though I'm not sure why the duplication is occuring.
<?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:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"
xmlns:g="http://www.jboss.org/drools/flow/gpd"
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="_processIPItem" structureRef="String" />
<itemDefinition id="_processStartDateItem" structureRef="String" />
<itemDefinition id="_processEndDateItem" structureRef="String" />
<itemDefinition id="_4-processIPItem" structureRef="String" />
<itemDefinition id="_4-processStartDateItem" structureRef="String" />
<itemDefinition id="_4-processEndDateItem" structureRef="String" />
<process processType="Private" isExecutable="true" id="com.sample.bpmn.hello" name="Hello World" >
<!-- process variables -->
<property id="processIP" itemSubjectRef="_processIPItem"/>
<property id="processStartDate" itemSubjectRef="_processStartDateItem"/>
<property id="processEndDate" itemSubjectRef="_processEndDateItem"/>
<!-- nodes -->
<startEvent id="_1" name="StartProcess" />
<endEvent id="_3" name="EndProcess" >
<terminateEventDefinition />
</endEvent>
<task id="_4" name="IP Conversations" tns:taskName="IP Conversations" >
<ioSpecification>
<dataInput id="_4_Source_IPInput" name="Source_IP" />
<dataInput id="_4_Start_DateInput" name="Start_Date" />
<dataInput id="_4_End_DateInput" name="End_Date" />
<dataInput id="_4_Source_IPInput" name="Source_IP" />
<dataInput id="_4_Start_DateInput" name="Start_Date" />
<dataInput id="_4_End_DateInput" name="End_Date" />
<inputSet>
<dataInputRefs>_4_Source_IPInput</dataInputRefs>
<dataInputRefs>_4_Start_DateInput</dataInputRefs>
<dataInputRefs>_4_End_DateInput</dataInputRefs>
<dataInputRefs>_4_Source_IPInput</dataInputRefs>
<dataInputRefs>_4_Start_DateInput</dataInputRefs>
<dataInputRefs>_4_End_DateInput</dataInputRefs>
</inputSet>
<outputSet>
</outputSet>
</ioSpecification>
<dataInputAssociation>
<sourceRef>processIP</sourceRef>
<targetRef>_4_Source_IPInput</targetRef>
</dataInputAssociation>
<dataInputAssociation>
<sourceRef>processStartDate</sourceRef>
<targetRef>_4_Start_DateInput</targetRef>
</dataInputAssociation>
<dataInputAssociation>
<sourceRef>processEndDate</sourceRef>
<targetRef>_4_End_DateInput</targetRef>
</dataInputAssociation>
<dataInputAssociation>
<targetRef>_4_Source_IPInput</targetRef>
<assignment>
<from xsi:type="tFormalExpression"></from>
<to xsi:type="tFormalExpression">_4_Source_IPInput</to>
</assignment>
</dataInputAssociation>
<dataInputAssociation>
<targetRef>_4_Start_DateInput</targetRef>
<assignment>
<from xsi:type="tFormalExpression"></from>
<to xsi:type="tFormalExpression">_4_Start_DateInput</to>
</assignment>
</dataInputAssociation>
<dataInputAssociation>
<targetRef>_4_End_DateInput</targetRef>
<assignment>
<from xsi:type="tFormalExpression"></from>
<to xsi:type="tFormalExpression">_4_End_DateInput</to>
</assignment>
</dataInputAssociation>
</task>
<!-- connections -->
<sequenceFlow id="_4-_3" sourceRef="_4" targetRef="_3" />
<sequenceFlow id="_1-_4" sourceRef="_1" targetRef="_4" />
</process>
<bpmndi:BPMNDiagram>
<bpmndi:BPMNPlane bpmnElement="com.sample.bpmn.hello" >
<bpmndi:BPMNShape bpmnElement="_1" >
<dc:Bounds x="148" y="103" width="48" height="48" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_3" >
<dc:Bounds x="482" y="101" width="48" height="48" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_4" >
<dc:Bounds x="249" y="101" width="178" height="48" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="_4-_3" >
<di:waypoint x="338" y="125" />
<di:waypoint x="506" y="125" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_1-_4" >
<di:waypoint x="172" y="127" />
<di:waypoint x="338" y="125" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
The .wid file contains
[
"name" : "IP Conversations",
"parameters" : [
"Source_IP" : new StringDataType(),
"Start_Date" : new StringDataType(),
"End_Date" : new StringDataType()
],
"results" : [
"Source_IPs" : new StringDataType(),
"Source_Ports" : new StringDataType(),
"Dest_IPs" : new StringDataType(),
"Dest_Ports" : new StringDataType(),
"Recv_Time" : new StringDataType()
],
"displayName" : "IP Conversations"
],
Anyone have any ideas? Thanks!
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/811311#811311]
Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
10 years, 12 months
[jBPM] - Drools XML error when passing process variables to work item
by David Harris
David Harris [https://community.jboss.org/people/dmwpepper] created the discussion
"Drools XML error when passing process variables to work item"
To view the discussion, visit: https://community.jboss.org/message/811284#811284
--------------------------------------------------------------
I've been reading through "Section 7.2.3, Using your new work item in your processes" to see how to pass process variables to a work item. Even though the values of each process variable are getting passed each work item, I'm getting the following XML error in the Eclipse console:
| 1 | 02/05 11:43:16,406[main] ERROR drools.xml.ExtensibleXmlParser.error - (null: 40, 62): cvc-id.2: There are multiple occurrences of ID value '_4_Source_IPInput'. |
| 4 | 02/05 11:43:16,409[main] ERROR drools.xml.ExtensibleXmlParser.error - (null: 40, 62): cvc-attribute.3: The value '_4_Source_IPInput' of attribute 'id' on element 'dataInput' is not valid with respect to its type, 'ID'. |
| 5 | 02/05 11:43:16,410[main] ERROR drools.xml.ExtensibleXmlParser.error - (null: 41, 64): cvc-id.2: There are multiple occurrences of ID value '_4_Start_DateInput'. |
| 5 | 02/05 11:43:16,410[main] ERROR drools.xml.ExtensibleXmlParser.error - (null: 41, 64): cvc-attribute.3: The value '_4_Start_DateInput' of attribute 'id' on element 'dataInput' is not valid with respect to its type, 'ID'. |
| 6 | 02/05 11:43:16,411[main] ERROR drools.xml.ExtensibleXmlParser.error - (null: 42, 60): cvc-id.2: There are multiple occurrences of ID value '_4_End_DateInput'. |
| 6 | 02/05 11:43:16,411[main] ERROR drools.xml.ExtensibleXmlParser.error - (null: 42, 60): cvc-attribute.3: The value '_4_End_DateInput' of attribute 'id' on element 'dataInput' is not valid with respect to its type, 'ID'. |
*parameters passed into work item: 111.111.111.111, 2013 05 02 09:00:00, 2013 04 02 09:00:00*
Note the last line in red shows the values are being passed. Does anyone see anything in the folllowing that would cause the Drools XML error?
**********
public class ProcessMain {
public static final void main(String[] args) throws Exception {
// load up the knowledge base
KnowledgeBase kbase = readKnowledgeBase();
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
// start a new process instance
Map<String,Object> params = new HashMap<String,Object>();
params.put("processIP", "111.111.111.111");
params.put("processStartDate", "2013 05 02 09:00:00");
params.put("processEndDate", "2013 04 02 09:00:00");
ksession.getWorkItemManager().registerWorkItemHandler("IP Conversations", new IPConversationsWorkItemHandler());
ksession.startProcess("com.sample.bpmn.hello",params);
}
private static KnowledgeBase readKnowledgeBase() throws Exception {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("sample.bpmn"), ResourceType.BPMN2);
return kbuilder.newKnowledgeBase();
}
}
***********
The Work Item Handler is:
**********
package com.sample;
import org.drools.runtime.process.WorkItem;
import org.drools.runtime.process.WorkItemHandler;
import org.drools.runtime.process.WorkItemManager;
import java.sql.*;
import java.util.*;
public class IPConversationsWorkItemHandler implements WorkItemHandler {
public void executeWorkItem (WorkItem workItem, WorkItemManager manager) {
// extract parameters
String sourceIP = (String) workItem.getParameter("Source_IP");
String startDate = (String) workItem.getParameter("Start_Date");
String endDate = (String) workItem.getParameter("End_Date");
System.out.println("parameters passed into work item: " + sourceIP + "," + startDate + "," + endDate);
// notify manager that work item has been completed
manager.completeWorkItem(workItem.getId(),null);
}
public void abortWorkItem (WorkItem workItem, WorkItemManager manager) {
// do nothing, not planning to abort operation at this time
}
}
*********
*********
The work item definition file has the following entry:
import org.drools.process.core.datatype.impl.type.StringDataType;
[
[
"name" : "IP Conversations",
"parameters" : [
"Source_IP" : new StringDataType(),
"Start_Date" : new StringDataType(),
"End_Date" : new StringDataType()
],
"results" : [
"Source_IPs" : new StringDataType(),
"Source_Ports" : new StringDataType(),
"Dest_IPs" : new StringDataType(),
"Dest_Ports" : new StringDataType(),
"Recv_Time" : new StringDataType()
],
"displayName" : "IP Conversations"
],
]
********
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/811284#811284]
Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
10 years, 12 months