use of io.automatiko.engine.api.runtime.process.ProcessInstance in project automatiko-engine by automatiko-io.
the class DmnDecisionInProcessTest method testDmn.
@Test
public void testDmn() {
String namespace = "https://kiegroup.org/dmn/_52CEF9FD-9943-4A89-96D5-6F66810CA4C1";
String modelName = "PersonDecisions";
String decisionName = "isAdult";
ExecutableProcess process = createProcess(namespace, modelName, decisionName);
Map<String, Object> parameters = new HashMap<>();
Person person = new Person("John", 25);
parameters.put("person", person);
parameters.put("isAdult", false);
ProcessRuntime runtime = createProcessRuntime(process);
ProcessInstance pi = runtime.startProcess("process", parameters);
assertEquals(ProcessInstance.STATE_COMPLETED, pi.getState());
boolean result = (boolean) pi.getVariables().get("isAdult");
assertEquals(true, result);
}
use of io.automatiko.engine.api.runtime.process.ProcessInstance in project automatiko-engine by automatiko-io.
the class LightProcessRuntime method abortProcessInstance.
public void abortProcessInstance(String processInstanceId) {
ProcessInstance processInstance = getProcessInstance(processInstanceId);
if (processInstance == null) {
throw new IllegalArgumentException("Could not find process instance for id " + processInstanceId);
}
((io.automatiko.engine.workflow.base.instance.ProcessInstance) processInstance).setState(ProcessInstance.STATE_ABORTED);
}
use of io.automatiko.engine.api.runtime.process.ProcessInstance in project automatiko-engine by automatiko-io.
the class LightWorkItemManager method internalAbortWorkItem.
public void internalAbortWorkItem(String id) {
WorkItemImpl workItem = (WorkItemImpl) workItems.get(id);
// work item may have been aborted
if (workItem != null) {
workItem.setCompleteDate(new Date());
WorkItemHandler handler = this.workItemHandlers.get(workItem.getName());
if (handler != null) {
ProcessInstance processInstance = workItem.getProcessInstance();
Transition<?> transition = new TransitionToAbort(Collections.emptyList());
eventSupport.fireBeforeWorkItemTransition(processInstance, workItem, transition, null);
handler.abortWorkItem(workItem, this);
workItem.setPhaseId(ID);
workItem.setPhaseStatus(STATUS);
eventSupport.fireAfterWorkItemTransition(processInstance, workItem, transition, null);
} else {
workItems.remove(workItem.getId());
throw new WorkItemHandlerNotFoundException(workItem.getName());
}
workItems.remove(workItem.getId());
}
}
use of io.automatiko.engine.api.runtime.process.ProcessInstance in project automatiko-engine by automatiko-io.
the class LightWorkItemManager method transitionWorkItem.
@SuppressWarnings("unchecked")
@Override
public void transitionWorkItem(String id, Transition<?> transition) {
WorkItem workItem = workItems.get(id);
// work item may have been aborted
if (workItem != null) {
WorkItemHandler handler = this.workItemHandlers.get(workItem.getName());
if (handler != null) {
ProcessInstance processInstance = workItem.getProcessInstance();
eventSupport.fireBeforeWorkItemTransition(processInstance, workItem, transition, null);
try {
handler.transitionToPhase(workItem, this, transition);
} catch (UnsupportedOperationException e) {
((WorkItemImpl) workItem).setResults((Map<String, Object>) transition.data());
workItem.setPhaseId(Complete.ID);
workItem.setPhaseStatus(Complete.STATUS);
completePhase.apply(workItem, transition);
internalCompleteWorkItem(workItem);
}
eventSupport.fireAfterWorkItemTransition(processInstance, workItem, transition, null);
} else {
throw new WorkItemHandlerNotFoundException(workItem.getName());
}
} else {
throw new WorkItemNotFoundException("Work Item (" + id + ") does not exist", id);
}
}
use of io.automatiko.engine.api.runtime.process.ProcessInstance in project automatiko-engine by automatiko-io.
the class LightWorkItemManager method internalAbortWorkItem.
public void internalAbortWorkItem(WorkItem workItem) {
ProcessInstance processInstance = workItem.getProcessInstance();
((WorkItemImpl) workItem).setState(ABORTED);
// process instance may have finished already
if (processInstance != null) {
processInstance.signalEvent("workItemAborted", workItem);
}
workItems.remove(workItem.getId());
}
Aggregations