use of org.kie.api.runtime.process.WorkItem in project jbpm by kiegroup.
the class DataTest method testDataInputAssociationsWithStringObject.
@Test
public void testDataInputAssociationsWithStringObject() throws Exception {
KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-DataInputAssociations-string-object.bpmn2");
ksession = createKnowledgeSession(kbase);
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new WorkItemHandler() {
public void abortWorkItem(WorkItem manager, WorkItemManager mgr) {
}
public void executeWorkItem(WorkItem workItem, WorkItemManager mgr) {
assertEquals("hello", workItem.getParameter("coId"));
}
});
Map<String, Object> params = new HashMap<String, Object>();
params.put("instanceMetadata", "hello");
ProcessInstance processInstance = ksession.startProcess("process", params);
}
use of org.kie.api.runtime.process.WorkItem in project jbpm by kiegroup.
the class DataTest method testDataInputAssociationsWithString.
@Test
public void testDataInputAssociationsWithString() throws Exception {
KieBase kbase = createKnowledgeBase("BPMN2-DataInputAssociations-string.bpmn2");
ksession = createKnowledgeSession(kbase);
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new WorkItemHandler() {
public void abortWorkItem(WorkItem manager, WorkItemManager mgr) {
}
public void executeWorkItem(WorkItem workItem, WorkItemManager mgr) {
assertEquals("hello", workItem.getParameter("coId"));
}
});
ProcessInstance processInstance = ksession.startProcess("process", null);
}
use of org.kie.api.runtime.process.WorkItem in project jbpm by kiegroup.
the class DataTest method testDataOutputAssociationsforHumanTask.
@Test
public void testDataOutputAssociationsforHumanTask() throws Exception {
KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-DataOutputAssociations-HumanTask.bpmn2");
ksession = createKnowledgeSession(kbase);
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new WorkItemHandler() {
public void abortWorkItem(WorkItem manager, WorkItemManager mgr) {
}
public void executeWorkItem(WorkItem workItem, WorkItemManager mgr) {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder;
try {
builder = factory.newDocumentBuilder();
} catch (ParserConfigurationException e) {
throw new RuntimeException(e);
}
final Map<String, Object> results = new HashMap<String, Object>();
// process metadata
org.w3c.dom.Document processMetadaDoc = builder.newDocument();
org.w3c.dom.Element processMetadata = processMetadaDoc.createElement("previoustasksowner");
processMetadaDoc.appendChild(processMetadata);
// org.w3c.dom.Element procElement =
// processMetadaDoc.createElement("previoustasksowner");
processMetadata.setAttribute("primaryname", "my_result");
// processMetadata.appendChild(procElement);
results.put("output", processMetadata);
mgr.completeWorkItem(workItem.getId(), results);
}
});
Map<String, Object> params = new HashMap<String, Object>();
ProcessInstance processInstance = ksession.startProcess("process", params);
}
use of org.kie.api.runtime.process.WorkItem in project jbpm by kiegroup.
the class DataTest method testDataOutputAssociations.
@Test
public void testDataOutputAssociations() throws Exception {
KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-DataOutputAssociations.bpmn2");
ksession = createKnowledgeSession(kbase);
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new WorkItemHandler() {
public void abortWorkItem(WorkItem manager, WorkItemManager mgr) {
}
public void executeWorkItem(WorkItem workItem, WorkItemManager mgr) {
try {
Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream("<user hello='hello world' />".getBytes()));
Map<String, Object> params = new HashMap<String, Object>();
params.put("output", document.getFirstChild());
mgr.completeWorkItem(workItem.getId(), params);
} catch (Throwable e) {
throw new RuntimeException(e);
}
}
});
ProcessInstance processInstance = ksession.startProcess("process", null);
}
use of org.kie.api.runtime.process.WorkItem in project jbpm by kiegroup.
the class DataTest method testDataInputAssociationsWithTwoAssigns.
/**
* TODO testDataInputAssociationsWithTwoAssigns
*/
@Test
@Ignore
public void testDataInputAssociationsWithTwoAssigns() throws Exception {
KieBase kbase = createKnowledgeBase("BPMN2-DataInputAssociations-two-assigns.bpmn2");
ksession = createKnowledgeSession(kbase);
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new WorkItemHandler() {
public void abortWorkItem(WorkItem manager, WorkItemManager mgr) {
}
public void executeWorkItem(WorkItem workItem, WorkItemManager mgr) {
assertEquals("foo", ((Element) workItem.getParameter("Comment")).getNodeName());
// assertEquals("mynode", ((Element)
// workItem.getParameter("Comment")).getFirstChild().getNodeName());
// assertEquals("user", ((Element)
// workItem.getParameter("Comment")).getFirstChild().getFirstChild().getNodeName());
// assertEquals("hello world", ((Element)
// workItem.getParameter("coId")).getFirstChild().getFirstChild().getAttributes().getNamedItem("hello").getNodeValue());
}
});
Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream("<user hello='hello world' />".getBytes()));
Map<String, Object> params = new HashMap<String, Object>();
params.put("instanceMetadata", document.getFirstChild());
ProcessInstance processInstance = ksession.startProcess("process", params);
}
Aggregations