Search in sources :

Example 11 with ContextContainer

use of io.automatiko.engine.workflow.base.core.ContextContainer in project automatiko-engine by automatiko-io.

the class VariableHandler method start.

public Object start(final String uri, final String localName, final Attributes attrs, final ExtensibleXmlParser parser) throws SAXException {
    parser.startElementBuilder(localName, attrs);
    ContextContainer contextContainer = (ContextContainer) parser.getParent();
    final String name = attrs.getValue("name");
    emptyAttributeCheck(localName, "name", name, parser);
    VariableScope variableScope = (VariableScope) contextContainer.getDefaultContext(VariableScope.VARIABLE_SCOPE);
    Variable variable = new Variable();
    if (variableScope != null) {
        variable.setName(name);
        List<Variable> variables = variableScope.getVariables();
        if (variables == null) {
            variables = new ArrayList<Variable>();
            variableScope.setVariables(variables);
        }
        variables.add(variable);
    } else {
        throw new SAXParseException("Could not find default variable scope.", parser.getLocator());
    }
    return variable;
}
Also used : ContextContainer(io.automatiko.engine.workflow.base.core.ContextContainer) Variable(io.automatiko.engine.workflow.base.core.context.variable.Variable) SAXParseException(org.xml.sax.SAXParseException) VariableScope(io.automatiko.engine.workflow.base.core.context.variable.VariableScope)

Example 12 with ContextContainer

use of io.automatiko.engine.workflow.base.core.ContextContainer in project automatiko-engine by automatiko-io.

the class WorkflowProcessInstanceImpl method getEventDescriptions.

@Override
public Set<EventDescription<?>> getEventDescriptions() {
    if (getState() == ProcessInstance.STATE_COMPLETED || getState() == ProcessInstance.STATE_ABORTED) {
        return Collections.emptySet();
    }
    VariableScope variableScope = (VariableScope) ((ContextContainer) getProcess()).getDefaultContext(VariableScope.VARIABLE_SCOPE);
    Set<EventDescription<?>> eventDesciptions = new LinkedHashSet<>();
    List<EventListener> activeListeners = eventListeners.values().stream().flatMap(List::stream).collect(Collectors.toList());
    activeListeners.addAll(externalEventListeners.values().stream().flatMap(List::stream).collect(Collectors.toList()));
    activeListeners.forEach(el -> eventDesciptions.addAll(el.getEventDescriptions()));
    ((io.automatiko.engine.workflow.process.core.WorkflowProcess) getProcess()).getNodesRecursively().stream().filter(n -> n instanceof EventNodeInterface).forEach(n -> {
        NamedDataType dataType = null;
        if (((EventNodeInterface) n).getVariableName() != null) {
            Map<String, Object> dataOutputs = (Map<String, Object>) n.getMetaData().get("DataOutputs");
            if (dataOutputs != null) {
                for (Entry<String, Object> dOut : dataOutputs.entrySet()) {
                    dataType = new NamedDataType(dOut.getKey(), dOut.getValue());
                }
            } else {
                Variable eventVar = variableScope.findVariable(((EventNodeInterface) n).getVariableName());
                if (eventVar != null) {
                    dataType = new NamedDataType(eventVar.getName(), eventVar.getType());
                }
            }
        }
        if (n instanceof BoundaryEventNode) {
            BoundaryEventNode boundaryEventNode = (BoundaryEventNode) n;
            StateBasedNodeInstance attachedToNodeInstance = (StateBasedNodeInstance) getNodeInstances(true).stream().filter(ni -> ni.getNode().getMetaData().get(UNIQUE_ID).equals(boundaryEventNode.getAttachedToNodeId())).findFirst().orElse(null);
            if (attachedToNodeInstance != null) {
                Map<String, String> properties = new HashMap<>();
                properties.put("AttachedToID", attachedToNodeInstance.getNodeDefinitionId());
                properties.put("AttachedToName", attachedToNodeInstance.getNodeName());
                String eventType = EVENT_TYPE_SIGNAL;
                String eventName = boundaryEventNode.getType();
                Map<String, String> timerProperties = attachedToNodeInstance.extractTimerEventInformation();
                if (timerProperties != null) {
                    properties.putAll(timerProperties);
                    eventType = "timer";
                    eventName = "timerTriggered";
                }
                eventDesciptions.add(new BaseEventDescription(eventName, (String) n.getMetaData().get(UNIQUE_ID), n.getName(), eventType, null, getId(), dataType, properties));
            }
        } else if (n instanceof EventSubProcessNode) {
            EventSubProcessNode eventSubProcessNode = (EventSubProcessNode) n;
            boolean isContainerActive = false;
            if (eventSubProcessNode.getParentContainer() instanceof WorkflowProcess) {
                isContainerActive = true;
            } else if (eventSubProcessNode.getParentContainer() instanceof CompositeNode) {
                isContainerActive = !getNodeInstances(((CompositeNode) eventSubProcessNode.getParentContainer()).getId()).isEmpty();
            }
            if (isContainerActive) {
                Node startNode = eventSubProcessNode.findStartNode();
                Map<Timer, ProcessAction> timers = eventSubProcessNode.getTimers();
                if (timers != null && !timers.isEmpty()) {
                    getNodeInstances(eventSubProcessNode.getId()).forEach(ni -> {
                        Map<String, String> timerProperties = ((StateBasedNodeInstance) ni).extractTimerEventInformation();
                        if (timerProperties != null) {
                            eventDesciptions.add(new BaseEventDescription("timerTriggered", (String) startNode.getMetaData().get("UniqueId"), startNode.getName(), "timer", ni.getId(), getId(), null, timerProperties));
                        }
                    });
                } else {
                    for (String eventName : eventSubProcessNode.getEvents()) {
                        if ("variableChanged".equals(eventName)) {
                            continue;
                        }
                        eventDesciptions.add(new BaseEventDescription(eventName, (String) startNode.getMetaData().get("UniqueId"), startNode.getName(), "signal", null, getId(), dataType));
                    }
                }
            }
        } else if (n instanceof EventNode) {
            NamedDataType finalDataType = dataType;
            getNodeInstances(n.getId()).forEach(ni -> eventDesciptions.add(new BaseEventDescription(((EventNode) n).getType(), (String) n.getMetaData().get(UNIQUE_ID), n.getName(), (String) n.getMetaData().getOrDefault(EVENT_TYPE, EVENT_TYPE_SIGNAL), ni.getId(), getId(), finalDataType)));
        } else if (n instanceof StateNode) {
            getNodeInstances(n.getId()).forEach(ni -> eventDesciptions.add(new BaseEventDescription((String) n.getMetaData().get(CONDITION), (String) n.getMetaData().get(UNIQUE_ID), n.getName(), (String) n.getMetaData().getOrDefault(EVENT_TYPE, EVENT_TYPE_SIGNAL), ni.getId(), getId(), null)));
        }
    });
    return eventDesciptions;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) StateBasedNode(io.automatiko.engine.workflow.process.core.node.StateBasedNode) Metadata(io.automatiko.engine.workflow.process.executable.core.Metadata) COMPLETED(io.automatiko.engine.api.workflow.flexible.ItemDescription.Status.COMPLETED) NodeImpl(io.automatiko.engine.workflow.process.core.impl.NodeImpl) Matcher(java.util.regex.Matcher) ContextContainer(io.automatiko.engine.workflow.base.core.ContextContainer) Map(java.util.Map) IS_FOR_COMPENSATION(io.automatiko.engine.workflow.process.executable.core.Metadata.IS_FOR_COMPENSATION) PrintWriter(java.io.PrintWriter) AdHocFragment(io.automatiko.engine.api.workflow.flexible.AdHocFragment) MilestoneNode(io.automatiko.engine.workflow.process.core.node.MilestoneNode) EventBasedNodeInstanceInterface(io.automatiko.engine.workflow.process.instance.node.EventBasedNodeInstanceInterface) IdentityProvider(io.automatiko.engine.api.auth.IdentityProvider) Set(java.util.Set) VariableScope(io.automatiko.engine.workflow.base.core.context.variable.VariableScope) CORRELATION_KEY(io.automatiko.engine.workflow.process.executable.core.Metadata.CORRELATION_KEY) EventSubProcessNode(io.automatiko.engine.workflow.process.core.node.EventSubProcessNode) StateNode(io.automatiko.engine.workflow.process.core.node.StateNode) Stream(java.util.stream.Stream) CONDITION(io.automatiko.engine.workflow.process.executable.core.Metadata.CONDITION) Variable(io.automatiko.engine.workflow.base.core.context.variable.Variable) ProcessInstanceJobDescription(io.automatiko.engine.api.jobs.ProcessInstanceJobDescription) WorkflowProcessInstance(io.automatiko.engine.workflow.process.instance.WorkflowProcessInstance) EventSubProcessNodeInstance(io.automatiko.engine.workflow.process.instance.node.EventSubProcessNodeInstance) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) Timer(io.automatiko.engine.workflow.base.core.timer.Timer) CorrelationKey(io.automatiko.engine.services.correlation.CorrelationKey) Node(io.automatiko.engine.api.definition.process.Node) ArrayList(java.util.ArrayList) CUSTOM_ASYNC(io.automatiko.engine.workflow.process.executable.core.Metadata.CUSTOM_ASYNC) EventListener(io.automatiko.engine.api.runtime.process.EventListener) LinkedHashSet(java.util.LinkedHashSet) NodeInstance(io.automatiko.engine.workflow.process.instance.NodeInstance) DynamicNode(io.automatiko.engine.workflow.process.core.node.DynamicNode) ExecutionsErrorInfo(io.automatiko.engine.api.workflow.ExecutionsErrorInfo) VariableResolverFactory(org.mvel2.integration.VariableResolverFactory) StringWriter(java.io.StringWriter) TrustedIdentityProvider(io.automatiko.engine.api.auth.TrustedIdentityProvider) DateTimeUtils(io.automatiko.engine.workflow.base.core.timer.DateTimeUtils) CUSTOM_SLA_DUE_DATE(io.automatiko.engine.workflow.process.executable.core.Metadata.CUSTOM_SLA_DUE_DATE) NodeInstanceContainer(io.automatiko.engine.api.runtime.process.NodeInstanceContainer) AVAILABLE(io.automatiko.engine.api.workflow.flexible.ItemDescription.Status.AVAILABLE) EventNodeInstanceInterface(io.automatiko.engine.workflow.process.instance.node.EventNodeInstanceInterface) EMPTY_EVENT_LISTENER(io.automatiko.engine.workflow.process.instance.impl.DummyEventListener.EMPTY_EVENT_LISTENER) ContextInstance(io.automatiko.engine.workflow.base.instance.ContextInstance) StartNode(io.automatiko.engine.workflow.process.core.node.StartNode) EventDescription(io.automatiko.engine.api.workflow.EventDescription) EndNode(io.automatiko.engine.workflow.process.core.node.EndNode) EventNode(io.automatiko.engine.workflow.process.core.node.EventNode) Date(java.util.Date) LoggerFactory(org.slf4j.LoggerFactory) EVENT_TYPE(io.automatiko.engine.workflow.process.executable.core.Metadata.EVENT_TYPE) TagInstance(io.automatiko.engine.workflow.base.instance.TagInstance) NamedDataType(io.automatiko.engine.api.workflow.NamedDataType) FaultNodeInstance(io.automatiko.engine.workflow.process.instance.node.FaultNodeInstance) VariableScopeInstance(io.automatiko.engine.workflow.base.instance.context.variable.VariableScopeInstance) BaseEventDescription(io.automatiko.engine.api.workflow.BaseEventDescription) ProcessInstance(io.automatiko.engine.api.runtime.process.ProcessInstance) EventNodeInterface(io.automatiko.engine.workflow.process.core.node.EventNodeInterface) TagDefinition(io.automatiko.engine.workflow.base.core.TagDefinition) Collection(java.util.Collection) Tag(io.automatiko.engine.api.workflow.Tag) ProcessAction(io.automatiko.engine.workflow.process.core.ProcessAction) ActionNode(io.automatiko.engine.workflow.process.core.node.ActionNode) ExecutableProcessInstance(io.automatiko.engine.workflow.process.executable.instance.ExecutableProcessInstance) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) WorkItemExecutionError(io.automatiko.engine.api.workflow.workitem.WorkItemExecutionError) Objects(java.util.Objects) NodeContainer(io.automatiko.engine.api.definition.process.NodeContainer) List(java.util.List) PatternConstants(io.automatiko.engine.workflow.util.PatternConstants) EVENT_TYPE_SIGNAL(io.automatiko.engine.workflow.process.executable.core.Metadata.EVENT_TYPE_SIGNAL) ItemDescription(io.automatiko.engine.api.workflow.flexible.ItemDescription) Entry(java.util.Map.Entry) Optional(java.util.Optional) Milestone(io.automatiko.engine.api.workflow.flexible.Milestone) CompositeNodeInstance(io.automatiko.engine.workflow.process.instance.node.CompositeNodeInstance) StateBasedNodeInstance(io.automatiko.engine.workflow.process.instance.node.StateBasedNodeInstance) StartNodeInstance(io.automatiko.engine.workflow.process.instance.node.StartNodeInstance) CompositeNode(io.automatiko.engine.workflow.process.core.node.CompositeNode) UNIQUE_ID(io.automatiko.engine.workflow.process.executable.core.Metadata.UNIQUE_ID) HashMap(java.util.HashMap) Function(java.util.function.Function) DurationExpirationTime(io.automatiko.engine.api.jobs.DurationExpirationTime) ProcessInstanceImpl(io.automatiko.engine.workflow.base.instance.impl.ProcessInstanceImpl) ExpressionEvaluator(io.automatiko.engine.api.expression.ExpressionEvaluator) EndNodeInstance(io.automatiko.engine.workflow.process.instance.node.EndNodeInstance) InternalProcessRuntime(io.automatiko.engine.workflow.base.instance.InternalProcessRuntime) BoundaryEventNode(io.automatiko.engine.workflow.process.core.node.BoundaryEventNode) COMPENSATION(io.automatiko.engine.workflow.process.executable.core.Metadata.COMPENSATION) ACTIVE(io.automatiko.engine.api.workflow.flexible.ItemDescription.Status.ACTIVE) Logger(org.slf4j.Logger) WorkflowProcess(io.automatiko.engine.api.definition.process.WorkflowProcess) TimerInstance(io.automatiko.engine.services.time.TimerInstance) EventNodeInstance(io.automatiko.engine.workflow.process.instance.node.EventNodeInstance) Process(io.automatiko.engine.workflow.base.core.Process) EventTrigger(io.automatiko.engine.workflow.process.core.node.EventTrigger) Collections(java.util.Collections) Variable(io.automatiko.engine.workflow.base.core.context.variable.Variable) HashMap(java.util.HashMap) EventSubProcessNode(io.automatiko.engine.workflow.process.core.node.EventSubProcessNode) StateBasedNode(io.automatiko.engine.workflow.process.core.node.StateBasedNode) MilestoneNode(io.automatiko.engine.workflow.process.core.node.MilestoneNode) EventSubProcessNode(io.automatiko.engine.workflow.process.core.node.EventSubProcessNode) StateNode(io.automatiko.engine.workflow.process.core.node.StateNode) Node(io.automatiko.engine.api.definition.process.Node) DynamicNode(io.automatiko.engine.workflow.process.core.node.DynamicNode) StartNode(io.automatiko.engine.workflow.process.core.node.StartNode) EndNode(io.automatiko.engine.workflow.process.core.node.EndNode) EventNode(io.automatiko.engine.workflow.process.core.node.EventNode) ActionNode(io.automatiko.engine.workflow.process.core.node.ActionNode) CompositeNode(io.automatiko.engine.workflow.process.core.node.CompositeNode) BoundaryEventNode(io.automatiko.engine.workflow.process.core.node.BoundaryEventNode) StateNode(io.automatiko.engine.workflow.process.core.node.StateNode) EventNode(io.automatiko.engine.workflow.process.core.node.EventNode) BoundaryEventNode(io.automatiko.engine.workflow.process.core.node.BoundaryEventNode) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) List(java.util.List) EventListener(io.automatiko.engine.api.runtime.process.EventListener) WorkflowProcess(io.automatiko.engine.api.definition.process.WorkflowProcess) StateBasedNodeInstance(io.automatiko.engine.workflow.process.instance.node.StateBasedNodeInstance) EventNodeInterface(io.automatiko.engine.workflow.process.core.node.EventNodeInterface) BaseEventDescription(io.automatiko.engine.api.workflow.BaseEventDescription) BoundaryEventNode(io.automatiko.engine.workflow.process.core.node.BoundaryEventNode) CompositeNode(io.automatiko.engine.workflow.process.core.node.CompositeNode) NamedDataType(io.automatiko.engine.api.workflow.NamedDataType) EventDescription(io.automatiko.engine.api.workflow.EventDescription) BaseEventDescription(io.automatiko.engine.api.workflow.BaseEventDescription) Map(java.util.Map) HashMap(java.util.HashMap) VariableScope(io.automatiko.engine.workflow.base.core.context.variable.VariableScope)

Example 13 with ContextContainer

use of io.automatiko.engine.workflow.base.core.ContextContainer in project automatiko-engine by automatiko-io.

the class ProcessHandler method linkBoundaryErrorEvent.

protected void linkBoundaryErrorEvent(NodeContainer nodeContainer, Node node, String attachedTo, Node attachedNode) {
    ContextContainer compositeNode = (ContextContainer) attachedNode;
    ExceptionScope exceptionScope = (ExceptionScope) compositeNode.getDefaultContext(ExceptionScope.EXCEPTION_SCOPE);
    if (exceptionScope == null) {
        exceptionScope = new ExceptionScope();
        compositeNode.addContext(exceptionScope);
        compositeNode.setDefaultContext(exceptionScope);
    }
    String errorCode = (String) node.getMetaData().get("ErrorEvent");
    boolean hasErrorCode = (Boolean) node.getMetaData().get("HasErrorEvent");
    String errorStructureRef = (String) node.getMetaData().get("ErrorStructureRef");
    ActionExceptionHandler exceptionHandler = new ActionExceptionHandler();
    String variable = ((EventNode) node).getVariableName();
    ConsequenceAction action = createJavaAction(new SignalProcessInstanceAction("Error-" + attachedTo + "-" + errorCode, variable, SignalProcessInstanceAction.PROCESS_INSTANCE_SCOPE));
    exceptionHandler.setAction(action);
    exceptionHandler.setFaultVariable(variable);
    if (hasErrorCode) {
        for (String error : errorCode.split(",")) {
            exceptionScope.setExceptionHandler(error, exceptionHandler);
        }
    } else {
        exceptionScope.setExceptionHandler(null, exceptionHandler);
    }
    exceptionHandler.setRetryAfter((Integer) node.getMetaData().get("ErrorRetry"));
    exceptionHandler.setRetryLimit((Integer) node.getMetaData().get("ErrorRetryLimit"));
    exceptionHandler.setRetryIncrement((Integer) node.getMetaData().get("ErrorRetryIncrement"));
    if (node.getMetaData().get("ErrorRetryIncrementMultiplier") != null) {
        exceptionHandler.setRetryIncrementMultiplier(((Number) node.getMetaData().get("ErrorRetryIncrementMultiplier")).floatValue());
    }
    if (errorStructureRef != null) {
        exceptionScope.setExceptionHandler(errorStructureRef, exceptionHandler);
    }
    List<ProcessAction> actions = ((EventNode) node).getActions(EndNode.EVENT_NODE_EXIT);
    if (actions == null) {
        actions = new ArrayList<ProcessAction>();
    }
    ConsequenceAction cancelAction = new ConsequenceAction("java", null);
    cancelAction.setMetaData("Action", new CancelNodeInstanceAction(attachedTo));
    actions.add(cancelAction);
    ((EventNode) node).setActions(EndNode.EVENT_NODE_EXIT, actions);
}
Also used : ProcessAction(io.automatiko.engine.workflow.process.core.ProcessAction) SignalProcessInstanceAction(io.automatiko.engine.workflow.base.instance.impl.actions.SignalProcessInstanceAction) CancelNodeInstanceAction(io.automatiko.engine.workflow.base.instance.impl.actions.CancelNodeInstanceAction) ConsequenceAction(io.automatiko.engine.workflow.process.core.impl.ConsequenceAction) ExceptionScope(io.automatiko.engine.workflow.base.core.context.exception.ExceptionScope) ActionExceptionHandler(io.automatiko.engine.workflow.base.core.context.exception.ActionExceptionHandler) ContextContainer(io.automatiko.engine.workflow.base.core.ContextContainer) BoundaryEventNode(io.automatiko.engine.workflow.process.core.node.BoundaryEventNode) EventNode(io.automatiko.engine.workflow.process.core.node.EventNode)

Example 14 with ContextContainer

use of io.automatiko.engine.workflow.base.core.ContextContainer in project automatiko-engine by automatiko-io.

the class ProcessHandler method addCompensationScope.

protected static void addCompensationScope(final ExecutableProcess process, final Node node, final io.automatiko.engine.api.definition.process.NodeContainer parentContainer, final String compensationHandlerId) {
    process.getMetaData().put("Compensation", true);
    assert parentContainer instanceof ContextContainer : "Expected parent node to be a CompositeContextNode, not a " + parentContainer.getClass().getSimpleName();
    ContextContainer contextContainer = (ContextContainer) parentContainer;
    CompensationScope scope = null;
    boolean addScope = false;
    if (contextContainer.getContexts(CompensationScope.COMPENSATION_SCOPE) == null) {
        addScope = true;
    } else {
        scope = (CompensationScope) contextContainer.getContexts(CompensationScope.COMPENSATION_SCOPE).get(0);
        if (scope == null) {
            addScope = true;
        }
    }
    if (addScope) {
        scope = new CompensationScope();
        contextContainer.addContext(scope);
        contextContainer.setDefaultContext(scope);
        scope.setContextContainer(contextContainer);
    }
    CompensationHandler handler = new CompensationHandler();
    handler.setNode(node);
    if (scope.getExceptionHandler(compensationHandlerId) != null) {
        throw new IllegalArgumentException("More than one compensation handler per node (" + compensationHandlerId + ")" + " is not supported!");
    }
    scope.setExceptionHandler(compensationHandlerId, handler);
}
Also used : ContextContainer(io.automatiko.engine.workflow.base.core.ContextContainer) CompensationHandler(io.automatiko.engine.workflow.base.core.context.exception.CompensationHandler) CompensationScope(io.automatiko.engine.workflow.base.core.context.exception.CompensationScope)

Example 15 with ContextContainer

use of io.automatiko.engine.workflow.base.core.ContextContainer in project automatiko-engine by automatiko-io.

the class LightProcessRuntime method createProcessInstance.

private io.automatiko.engine.workflow.base.instance.ProcessInstance createProcessInstance(Process process, CorrelationKey correlationKey, Map<String, Object> parameters) {
    io.automatiko.engine.workflow.base.instance.ProcessInstance pi = runtimeContext.createProcessInstance(process, correlationKey);
    pi.setProcessRuntime(this);
    runtimeContext.setupParameters(pi, parameters, variableInitializer);
    Map<String, Object> temp = new HashMap<>();
    if (parameters != null) {
        temp.putAll(parameters);
    }
    temp.putAll(pi.getVariables());
    String uuid;
    if (correlationKey != null) {
        uuid = UUID.nameUUIDFromBytes(correlationKey.toExternalForm().getBytes(StandardCharsets.UTF_8)).toString();
        ((WorkflowProcessInstanceImpl) pi).setCorrelationKey(correlationKey.toExternalForm());
    } else {
        VariableScope variableScope = (VariableScope) ((ContextContainer) process).getDefaultContext(VariableScope.VARIABLE_SCOPE);
        Optional<Object> businessKeyVar = variableScope.getVariables().stream().filter(var -> var.hasTag(Variable.BUSINESS_KEY_TAG)).map(v -> temp.get(v.getName())).filter(var -> var != null).findAny();
        if (businessKeyVar.isPresent()) {
            Object businessKey = businessKeyVar.get();
            uuid = UUID.nameUUIDFromBytes(businessKey.toString().getBytes(StandardCharsets.UTF_8)).toString();
            ((WorkflowProcessInstanceImpl) pi).setCorrelationKey(businessKey.toString());
        } else {
            uuid = UUID.randomUUID().toString();
        }
    }
    pi.setId(uuid);
    VariableScope variableScope = (VariableScope) ((ContextContainer) process).getDefaultContext(VariableScope.VARIABLE_SCOPE);
    VariableScopeInstance variableScopeInstance = (VariableScopeInstance) pi.getContextInstance(VariableScope.VARIABLE_SCOPE);
    // set input parameters
    if (parameters != null) {
        if (variableScope != null) {
            for (Map.Entry<String, Object> entry : parameters.entrySet()) {
                variableScope.validateVariable(process.getName(), entry.getKey(), entry.getValue());
                variableScopeInstance.setVariable(entry.getKey(), entry.getValue());
            }
        } else {
            throw new IllegalArgumentException("This process does not support parameters!");
        }
    }
    variableScopeInstance.enforceRequiredVariables();
    return pi;
}
Also used : SignalManager(io.automatiko.engine.api.workflow.signal.SignalManager) Trigger(io.automatiko.engine.workflow.process.core.node.Trigger) Timer(io.automatiko.engine.workflow.base.core.timer.Timer) TimeUtils(io.automatiko.engine.workflow.base.core.timer.TimeUtils) ExactExpirationTime(io.automatiko.engine.api.jobs.ExactExpirationTime) WorkflowProcessInstanceImpl(io.automatiko.engine.workflow.process.instance.impl.WorkflowProcessInstanceImpl) ExpirationTime(io.automatiko.engine.api.jobs.ExpirationTime) CorrelationKey(io.automatiko.engine.services.correlation.CorrelationKey) HashMap(java.util.HashMap) DefaultProcessInstanceManager(io.automatiko.engine.workflow.base.instance.impl.DefaultProcessInstanceManager) Node(io.automatiko.engine.api.definition.process.Node) VariableScopeInstance(io.automatiko.engine.workflow.base.instance.context.variable.VariableScopeInstance) DurationExpirationTime(io.automatiko.engine.api.jobs.DurationExpirationTime) ProcessJobDescription(io.automatiko.engine.api.jobs.ProcessJobDescription) JobsService(io.automatiko.engine.api.jobs.JobsService) ContextContainer(io.automatiko.engine.workflow.base.core.ContextContainer) ProcessInstance(io.automatiko.engine.api.runtime.process.ProcessInstance) ProcessEventSupport(io.automatiko.engine.workflow.base.core.event.ProcessEventSupport) Map(java.util.Map) EventListener(io.automatiko.engine.api.runtime.process.EventListener) Process(io.automatiko.engine.api.definition.process.Process) EventFilter(io.automatiko.engine.workflow.base.core.event.EventFilter) ProcessEventListener(io.automatiko.engine.api.event.process.ProcessEventListener) UnitOfWorkManager(io.automatiko.engine.api.uow.UnitOfWorkManager) Collection(java.util.Collection) ExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ExecutableProcess) EventTransformer(io.automatiko.engine.workflow.base.core.event.EventTransformer) DateTimeUtils(io.automatiko.engine.workflow.base.core.timer.DateTimeUtils) UUID(java.util.UUID) InMemoryJobService(io.automatiko.engine.services.jobs.impl.InMemoryJobService) VariableScope(io.automatiko.engine.workflow.base.core.context.variable.VariableScope) StandardCharsets(java.nio.charset.StandardCharsets) WorkItemExecutionError(io.automatiko.engine.api.workflow.workitem.WorkItemExecutionError) VariableInitializer(io.automatiko.engine.api.workflow.VariableInitializer) DateTimeParseException(java.time.format.DateTimeParseException) List(java.util.List) EventTypeFilter(io.automatiko.engine.workflow.base.core.event.EventTypeFilter) CronExpirationTime(io.automatiko.engine.workflow.base.core.timer.CronExpirationTime) Optional(java.util.Optional) StartNode(io.automatiko.engine.workflow.process.core.node.StartNode) WorkItemManager(io.automatiko.engine.api.runtime.process.WorkItemManager) Variable(io.automatiko.engine.workflow.base.core.context.variable.Variable) EventTrigger(io.automatiko.engine.workflow.process.core.node.EventTrigger) Collections(java.util.Collections) HashMap(java.util.HashMap) WorkflowProcessInstanceImpl(io.automatiko.engine.workflow.process.instance.impl.WorkflowProcessInstanceImpl) VariableScopeInstance(io.automatiko.engine.workflow.base.instance.context.variable.VariableScopeInstance) HashMap(java.util.HashMap) Map(java.util.Map) VariableScope(io.automatiko.engine.workflow.base.core.context.variable.VariableScope)

Aggregations

ContextContainer (io.automatiko.engine.workflow.base.core.ContextContainer)19 Variable (io.automatiko.engine.workflow.base.core.context.variable.Variable)9 VariableScope (io.automatiko.engine.workflow.base.core.context.variable.VariableScope)9 List (java.util.List)8 ProcessAction (io.automatiko.engine.workflow.process.core.ProcessAction)7 Map (java.util.Map)7 ConsequenceAction (io.automatiko.engine.workflow.process.core.impl.ConsequenceAction)6 EventNode (io.automatiko.engine.workflow.process.core.node.EventNode)6 ActionExceptionHandler (io.automatiko.engine.workflow.base.core.context.exception.ActionExceptionHandler)5 CompensationScope (io.automatiko.engine.workflow.base.core.context.exception.CompensationScope)5 ExceptionScope (io.automatiko.engine.workflow.base.core.context.exception.ExceptionScope)5 ArrayList (java.util.ArrayList)5 Logger (org.slf4j.Logger)5 LoggerFactory (org.slf4j.LoggerFactory)5 Node (io.automatiko.engine.api.definition.process.Node)4 CompensationHandler (io.automatiko.engine.workflow.base.core.context.exception.CompensationHandler)4 SignalProcessInstanceAction (io.automatiko.engine.workflow.base.instance.impl.actions.SignalProcessInstanceAction)4 BoundaryEventNode (io.automatiko.engine.workflow.process.core.node.BoundaryEventNode)4 EventTrigger (io.automatiko.engine.workflow.process.core.node.EventTrigger)4 IdentityProvider (io.automatiko.engine.api.auth.IdentityProvider)3