use of org.kie.kogito.internal.process.runtime.KogitoWorkItemHandler in project kogito-runtimes by kiegroup.
the class KogitoDefaultWorkItemManager method internalExecuteWorkItem.
@Override
public void internalExecuteWorkItem(InternalKogitoWorkItem workItem) {
((KogitoWorkItemImpl) workItem).setId(UUID.randomUUID().toString());
internalAddWorkItem(workItem);
KogitoWorkItemHandler handler = this.workItemHandlers.get(workItem.getName());
if (handler != null) {
handler.executeWorkItem(workItem, this);
} else
throw new KogitoWorkItemHandlerNotFoundException(workItem.getName());
}
use of org.kie.kogito.internal.process.runtime.KogitoWorkItemHandler in project kogito-runtimes by kiegroup.
the class DataTest method testDataInputAssociationsWithStringObject.
@Test
public void testDataInputAssociationsWithStringObject() throws Exception {
kruntime = createKogitoProcessRuntime("BPMN2-DataInputAssociations-string-object.bpmn2");
kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", new KogitoWorkItemHandler() {
@Override
public void abortWorkItem(KogitoWorkItem manager, KogitoWorkItemManager mgr) {
}
@Override
public void executeWorkItem(KogitoWorkItem workItem, KogitoWorkItemManager mgr) {
assertEquals("hello", workItem.getParameter("coId"));
}
});
Map<String, Object> params = new HashMap<>();
params.put("instanceMetadata", "hello");
KogitoProcessInstance processInstance = kruntime.startProcess("process", params);
}
use of org.kie.kogito.internal.process.runtime.KogitoWorkItemHandler in project kogito-runtimes by kiegroup.
the class DataTest method testDataInputAssociationsWithStringWithoutQuotes.
@Test
public void testDataInputAssociationsWithStringWithoutQuotes() throws Exception {
kruntime = createKogitoProcessRuntime("BPMN2-DataInputAssociations-string-no-quotes.bpmn2");
kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", new KogitoWorkItemHandler() {
public void abortWorkItem(KogitoWorkItem manager, KogitoWorkItemManager mgr) {
}
public void executeWorkItem(KogitoWorkItem workItem, KogitoWorkItemManager mgr) {
assertEquals("hello", workItem.getParameter("coId"));
}
});
KogitoProcessInstance processInstance = kruntime.startProcess("process");
}
use of org.kie.kogito.internal.process.runtime.KogitoWorkItemHandler in project kogito-runtimes by kiegroup.
the class DataTest method testDataInputAssociationsWithLazyLoading.
/**
* TODO testDataInputAssociationsWithLazyLoading
*/
@Test
@Disabled
public void testDataInputAssociationsWithLazyLoading() throws Exception {
kruntime = createKogitoProcessRuntime("BPMN2-DataInputAssociations-lazy-creating.bpmn2");
kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", new KogitoWorkItemHandler() {
public void abortWorkItem(KogitoWorkItem manager, KogitoWorkItemManager mgr) {
}
public void executeWorkItem(KogitoWorkItem workItem, KogitoWorkItemManager mgr) {
Object coIdParamObj = workItem.getParameter("coId");
assertEquals("mydoc", ((Element) coIdParamObj).getNodeName());
assertEquals("mynode", ((Element) workItem.getParameter("coId")).getFirstChild().getNodeName());
assertEquals("user", ((Element) workItem.getParameter("coId")).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<>();
params.put("instanceMetadata", document.getFirstChild());
KogitoProcessInstance processInstance = kruntime.startProcess("process", params);
}
use of org.kie.kogito.internal.process.runtime.KogitoWorkItemHandler in project kogito-runtimes by kiegroup.
the class DataTest method testDataOutputAssociations.
@Test
public void testDataOutputAssociations() throws Exception {
kruntime = createKogitoProcessRuntime("BPMN2-DataOutputAssociations.bpmn2");
kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", new KogitoWorkItemHandler() {
public void abortWorkItem(KogitoWorkItem manager, KogitoWorkItemManager mgr) {
}
public void executeWorkItem(KogitoWorkItem workItem, KogitoWorkItemManager mgr) {
try {
Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream("<user hello='hello world' />".getBytes()));
Map<String, Object> params = new HashMap<>();
params.put("output", document.getFirstChild());
mgr.completeWorkItem(workItem.getStringId(), params);
} catch (Throwable e) {
throw new RuntimeException(e);
}
}
});
KogitoProcessInstance processInstance = kruntime.startProcess("process");
}
Aggregations