Search in sources :

Example 16 with WorkItemImpl

use of io.automatiko.engine.workflow.base.instance.impl.workitem.WorkItemImpl 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());
}
Also used : WorkItemImpl(io.automatiko.engine.workflow.base.instance.impl.workitem.WorkItemImpl) ProcessInstance(io.automatiko.engine.api.runtime.process.ProcessInstance)

Example 17 with WorkItemImpl

use of io.automatiko.engine.workflow.base.instance.impl.workitem.WorkItemImpl 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);
}
Also used : DefaultWorkItemManager(io.automatiko.engine.workflow.base.instance.impl.workitem.DefaultWorkItemManager) WorkItemImpl(io.automatiko.engine.workflow.base.instance.impl.workitem.WorkItemImpl) EventTransformerImpl(io.automatiko.engine.workflow.base.core.event.EventTransformerImpl)

Example 18 with WorkItemImpl

use of io.automatiko.engine.workflow.base.instance.impl.workitem.WorkItemImpl 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);
    }
}
Also used : DefaultWorkItemManager(io.automatiko.engine.workflow.base.instance.impl.workitem.DefaultWorkItemManager) WorkItemImpl(io.automatiko.engine.workflow.base.instance.impl.workitem.WorkItemImpl)

Example 19 with WorkItemImpl

use of io.automatiko.engine.workflow.base.instance.impl.workitem.WorkItemImpl in project automatiko-engine by automatiko-io.

the class LightWorkItemManager method failWorkItem.

@Override
public void failWorkItem(String id, Throwable error) {
    WorkItemImpl workItem = (WorkItemImpl) workItems.get(id);
    // work item may have been aborted
    if (workItem != null) {
        ProcessInstance processInstance = workItem.getProcessInstance();
        workItem.setState(FAILED);
        // process instance may have finished already
        if (processInstance != null) {
            workItem.setResult("Error", error);
            processInstance.signalEvent("workItemFailed", workItem);
        }
        workItems.remove(id);
    }
}
Also used : WorkItemImpl(io.automatiko.engine.workflow.base.instance.impl.workitem.WorkItemImpl) ProcessInstance(io.automatiko.engine.api.runtime.process.ProcessInstance)

Example 20 with WorkItemImpl

use of io.automatiko.engine.workflow.base.instance.impl.workitem.WorkItemImpl in project automatiko-engine by automatiko-io.

the class LightWorkItemManager method retryWorkItemWithParams.

public void retryWorkItemWithParams(String workItemId, Map<String, Object> map) {
    WorkItem workItem = workItems.get(workItemId);
    if (workItem != null) {
        ((WorkItemImpl) workItem).setParameters(map);
        retryWorkItem(workItem);
    }
}
Also used : WorkItemImpl(io.automatiko.engine.workflow.base.instance.impl.workitem.WorkItemImpl) WorkItem(io.automatiko.engine.api.runtime.process.WorkItem)

Aggregations

WorkItemImpl (io.automatiko.engine.workflow.base.instance.impl.workitem.WorkItemImpl)21 ProcessInstance (io.automatiko.engine.api.runtime.process.ProcessInstance)6 ExpressionEvaluator (io.automatiko.engine.api.expression.ExpressionEvaluator)4 WorkItemExecutionError (io.automatiko.engine.api.workflow.workitem.WorkItemExecutionError)4 Date (java.util.Date)4 ProcessContext (io.automatiko.engine.workflow.base.core.context.ProcessContext)3 VariableScopeInstance (io.automatiko.engine.workflow.base.instance.context.variable.VariableScopeInstance)3 AssignmentAction (io.automatiko.engine.workflow.base.instance.impl.AssignmentAction)3 DefaultWorkItemManager (io.automatiko.engine.workflow.base.instance.impl.workitem.DefaultWorkItemManager)3 WorkItemHandlerNotFoundException (io.automatiko.engine.workflow.base.instance.impl.workitem.WorkItemHandlerNotFoundException)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 Matcher (java.util.regex.Matcher)3 DataTransformer (io.automatiko.engine.api.runtime.process.DataTransformer)2 WorkItemHandler (io.automatiko.engine.api.runtime.process.WorkItemHandler)2 HumanTaskWorkItemImpl (io.automatiko.engine.workflow.base.instance.impl.humantask.HumanTaskWorkItemImpl)2 WorkflowProcess (io.automatiko.engine.workflow.process.core.WorkflowProcess)2 NodeInstance (io.automatiko.engine.workflow.process.instance.NodeInstance)2 NodeInstanceResolverFactory (io.automatiko.engine.workflow.process.instance.impl.NodeInstanceResolverFactory)2 ExtensionRegistry (com.google.protobuf.ExtensionRegistry)1