use of io.automatiko.engine.workflow.base.instance.impl.workitem.DefaultWorkItemManager in project automatiko-engine by automatiko-io.
the class DynamicUtils method executeWorkItem.
private static void executeWorkItem(InternalProcessRuntime runtime, WorkItemImpl workItem, WorkItemNodeInstance workItemNodeInstance) {
ProcessEventSupport eventSupport = runtime.getProcessEventSupport();
eventSupport.fireBeforeNodeTriggered(workItemNodeInstance, runtime);
((DefaultWorkItemManager) runtime.getWorkItemManager()).internalExecuteWorkItem(workItem);
workItemNodeInstance.internalSetWorkItemId(workItem.getId());
eventSupport.fireAfterNodeTriggered(workItemNodeInstance, runtime);
}
use of io.automatiko.engine.workflow.base.instance.impl.workitem.DefaultWorkItemManager in project automatiko-engine by automatiko-io.
the class HandleMessageAction method execute.
public void execute(ProcessContext context) throws Exception {
Object variable = VariableUtil.resolveVariable(variableName, context.getNodeInstance());
if (transformation != null) {
variable = new EventTransformerImpl(transformation).transformEvent(variable);
}
WorkItemImpl workItem = new WorkItemImpl();
workItem.setName("Send Task");
workItem.setNodeInstanceId(context.getNodeInstance().getId());
workItem.setProcessInstanceId(context.getProcessInstance().getId());
workItem.setProcessInstanceId(context.getProcessInstance().getParentProcessInstanceId());
workItem.setNodeId(context.getNodeInstance().getNodeId());
workItem.setParameter("MessageType", messageType);
if (variable != null) {
workItem.setParameter("Message", variable);
}
((DefaultWorkItemManager) context.getProcessRuntime().getWorkItemManager()).internalExecuteWorkItem(workItem);
}
use of io.automatiko.engine.workflow.base.instance.impl.workitem.DefaultWorkItemManager in project automatiko-engine by automatiko-io.
the class SignalProcessInstanceAction method execute.
public void execute(ProcessContext context) throws Exception {
String variableName = VariableUtil.resolveVariable(this.variableName, context.getNodeInstance());
Object variable = variableName == null ? eventDataSupplier.apply(context) : context.getVariable(variableName);
if (transformation != null) {
variable = new io.automatiko.engine.workflow.base.core.event.EventTransformerImpl(transformation).transformEvent(context.getProcessInstance().getVariables());
}
if (DEFAULT_SCOPE.equals(scope)) {
context.getProcessRuntime().signalEvent(VariableUtil.resolveVariable(signalName, context.getNodeInstance()), variable);
} else if (PROCESS_INSTANCE_SCOPE.equals(scope)) {
context.getProcessInstance().signalEvent(VariableUtil.resolveVariable(signalName, context.getNodeInstance()), variable);
} else if (EXTERNAL_SCOPE.equals(scope)) {
WorkItemImpl workItem = new WorkItemImpl();
workItem.setName("External Send Task");
workItem.setNodeInstanceId(context.getNodeInstance().getId());
workItem.setProcessInstanceId(context.getProcessInstance().getId());
workItem.setProcessInstanceId(context.getProcessInstance().getParentProcessInstanceId());
workItem.setNodeId(context.getNodeInstance().getNodeId());
workItem.setParameter("Signal", VariableUtil.resolveVariable(signalName, context.getNodeInstance()));
workItem.setParameter("SignalProcessInstanceId", context.getVariable("SignalProcessInstanceId"));
workItem.setParameter("SignalWorkItemId", context.getVariable("SignalWorkItemId"));
workItem.setParameter("SignalDeploymentId", context.getVariable("SignalDeploymentId"));
if (variable == null) {
workItem.setParameter("Data", variable);
}
((DefaultWorkItemManager) context.getProcessRuntime().getWorkItemManager()).internalExecuteWorkItem(workItem);
}
}
use of io.automatiko.engine.workflow.base.instance.impl.workitem.DefaultWorkItemManager in project automatiko-engine by automatiko-io.
the class PredictionAwareHumanTaskLifeCycle method transitionTo.
@Override
public Map<String, Object> transitionTo(WorkItem workItem, WorkItemManager manager, Transition<Map<String, Object>> transition) {
LifeCyclePhase targetPhase = phaseById(transition.phase());
if (targetPhase == null) {
logger.debug("Target life cycle phase '{}' does not exist in {}", transition.phase(), this.getClass().getSimpleName());
throw new InvalidLifeCyclePhaseException(transition.phase());
}
HumanTaskWorkItemImpl humanTaskWorkItem = (HumanTaskWorkItemImpl) workItem;
if (targetPhase.id().equals(Active.ID)) {
PredictionOutcome outcome = predictionService.predict(workItem, workItem.getParameters());
logger.debug("Prediction service returned confidence level {} for work item {}", outcome.getConfidenceLevel(), humanTaskWorkItem.getId());
if (outcome.isCertain()) {
humanTaskWorkItem.getResults().putAll(outcome.getData());
logger.debug("Prediction service is certain (confidence level {}) on the outputs, completing work item {}", outcome.getConfidenceLevel(), humanTaskWorkItem.getId());
((DefaultWorkItemManager) manager).internalCompleteWorkItem(humanTaskWorkItem);
return outcome.getData();
} else if (outcome.isPresent()) {
logger.debug("Prediction service is NOT certain (confidence level {}) on the outputs, setting recommended outputs on work item {}", outcome.getConfidenceLevel(), humanTaskWorkItem.getId());
humanTaskWorkItem.getResults().putAll(outcome.getData());
}
}
// prediction service does work only on activating tasks
Map<String, Object> data = super.transitionTo(workItem, manager, transition);
if (targetPhase.id().equals(Complete.ID)) {
// upon actual transition train the data if it's completion phase
predictionService.train(humanTaskWorkItem, workItem.getParameters(), data);
}
return data;
}
Aggregations