Search in sources :

Example 1 with SwimlaneContext

use of io.automatiko.engine.workflow.base.core.context.swimlane.SwimlaneContext in project automatiko-engine by automatiko-io.

the class AbstractProtobufProcessInstanceMarshaller method readProcessInstance.

// Input methods
public ProcessInstance readProcessInstance(MarshallerReaderContext context) throws IOException {
    AutomatikoMessages.ProcessInstance _instance = (io.automatiko.engine.workflow.marshalling.impl.AutomatikoMessages.ProcessInstance) context.parameterObject;
    if (_instance == null) {
        // try to parse from the stream
        ExtensionRegistry registry = PersisterHelper.buildRegistry(context, null);
        Header _header;
        try {
            _header = PersisterHelper.readFromStreamWithHeaderPreloaded(context, registry);
        } catch (ClassNotFoundException e) {
            // Java 5 does not accept [new IOException(String, Throwable)]
            IOException ioe = new IOException("Error deserializing process instance.");
            ioe.initCause(e);
            throw ioe;
        }
        _instance = AutomatikoMessages.ProcessInstance.parseFrom(_header.getPayload(), registry);
    }
    WorkflowProcessInstanceImpl processInstance = createProcessInstance();
    processInstance.setId(_instance.getId());
    String processId = _instance.getProcessId();
    processInstance.setProcessId(processId);
    String processXml = _instance.getProcessXml();
    Process process = null;
    if (processXml != null && processXml.trim().length() > 0) {
        processInstance.setProcessXml(processXml);
        process = processInstance.getProcess();
    } else {
        process = context.processes.get(processId);
        if (process == null) {
            throw new RuntimeException("Could not find process " + processId + " when restoring process instance " + processInstance.getId());
        }
        processInstance.setProcess(process);
    }
    processInstance.setDescription(_instance.getDescription());
    processInstance.internalSetState(_instance.getState());
    processInstance.setParentProcessInstanceId(_instance.getParentProcessInstanceId());
    processInstance.setRootProcessInstanceId(_instance.getRootProcessInstanceId());
    processInstance.setRootProcessId(_instance.getRootProcessId());
    processInstance.setSignalCompletion(_instance.getSignalCompletion());
    processInstance.setInitiator(_instance.getInitiator());
    processInstance.setCorrelationKey(_instance.getCorrelationKey());
    processInstance.setStartDate(new Date(_instance.getStartDate()));
    processInstance.internalSetSlaCompliance(_instance.getSlaCompliance());
    if (_instance.getSlaDueDate() > 0) {
        processInstance.internalSetSlaDueDate(new Date(_instance.getSlaDueDate()));
    }
    processInstance.internalSetSlaTimerId(_instance.getSlaTimerId());
    processInstance.setProcessRuntime(context.getProcessRuntime());
    List<ExecutionsErrorInfo> errors = new ArrayList<>();
    for (io.automatiko.engine.workflow.marshalling.impl.AutomatikoMessages.ProcessInstance.Error error : _instance.getErrorsList()) {
        errors.add(new ExecutionsErrorInfo(error.getErrorNodeId(), error.getErrorId(), error.getErrorMessage(), error.getErrorDetails()));
    }
    processInstance.internalSetExecutionErrors(errors);
    processInstance.setReferenceId(_instance.getReferenceId());
    processInstance.internalSetReferenceFromRoot(_instance.getReferenceFromRoot());
    for (String completedNodeId : _instance.getCompletedNodeIdsList()) {
        processInstance.addCompletedNodeId(completedNodeId);
    }
    if (_instance.getChildrenCount() > 0) {
        _instance.getChildrenList().forEach(child -> processInstance.addChildren(child.getProcessId(), child.getIdsList()));
    }
    if (_instance.getTagsCount() > 0) {
        _instance.getTagsList().forEach(tag -> processInstance.internalAddTag(tag.getId(), tag.getValue()));
    }
    if (_instance.getSwimlaneContextCount() > 0) {
        Context swimlaneContext = ((io.automatiko.engine.workflow.base.core.Process) process).getDefaultContext(SwimlaneContext.SWIMLANE_SCOPE);
        SwimlaneContextInstance swimlaneContextInstance = (SwimlaneContextInstance) processInstance.getContextInstance(swimlaneContext);
        for (AutomatikoMessages.ProcessInstance.SwimlaneContextInstance _swimlane : _instance.getSwimlaneContextList()) {
            swimlaneContextInstance.setActorId(_swimlane.getSwimlane(), _swimlane.getActorId());
        }
    }
    for (AutomatikoMessages.ProcessInstance.NodeInstance _node : _instance.getNodeInstanceList()) {
        context.parameterObject = _node;
        readNodeInstance(context, processInstance, processInstance);
    }
    if (processInstance.getState() == ProcessInstance.STATE_ACTIVE || processInstance.getState() == ProcessInstance.STATE_ERROR) {
        for (AutomatikoMessages.ProcessInstance.ExclusiveGroupInstance _excl : _instance.getExclusiveGroupList()) {
            ExclusiveGroupInstance exclusiveGroupInstance = new ExclusiveGroupInstance();
            processInstance.addContextInstance(ExclusiveGroup.EXCLUSIVE_GROUP, exclusiveGroupInstance);
            for (String nodeInstanceId : _excl.getGroupNodeInstanceIdList()) {
                NodeInstance nodeInstance = ((io.automatiko.engine.workflow.process.instance.NodeInstanceContainer) processInstance).getNodeInstance(nodeInstanceId, true);
                if (nodeInstance == null) {
                    throw new IllegalArgumentException("Could not find node instance when deserializing exclusive group instance: " + nodeInstanceId);
                }
                exclusiveGroupInstance.addNodeInstance(nodeInstance);
            }
        }
    }
    readVariableScope(context, process, processInstance, _instance);
    if (_instance.getIterationLevelsCount() > 0) {
        for (AutomatikoMessages.IterationLevel _level : _instance.getIterationLevelsList()) {
            processInstance.getIterationLevels().put(_level.getId(), _level.getLevel());
        }
    }
    return processInstance;
}
Also used : ExecutionsErrorInfo(io.automatiko.engine.api.workflow.ExecutionsErrorInfo) NodeInstanceContainer(io.automatiko.engine.api.runtime.process.NodeInstanceContainer) WorkflowProcessInstanceImpl(io.automatiko.engine.workflow.process.instance.impl.WorkflowProcessInstanceImpl) ArrayList(java.util.ArrayList) Process(io.automatiko.engine.api.definition.process.Process) ExtensionRegistry(com.google.protobuf.ExtensionRegistry) Context(io.automatiko.engine.workflow.base.core.Context) SwimlaneContext(io.automatiko.engine.workflow.base.core.context.swimlane.SwimlaneContext) ExclusiveGroupInstance(io.automatiko.engine.workflow.base.instance.context.exclusive.ExclusiveGroupInstance) SwimlaneContextInstance(io.automatiko.engine.workflow.base.instance.context.swimlane.SwimlaneContextInstance) IOException(java.io.IOException) Date(java.util.Date) Header(io.automatiko.engine.workflow.marshalling.impl.AutomatikoMessages.Header) ProcessInstance(io.automatiko.engine.api.runtime.process.ProcessInstance) WorkflowProcessInstance(io.automatiko.engine.api.runtime.process.WorkflowProcessInstance) CompositeContextNodeInstance(io.automatiko.engine.workflow.process.instance.node.CompositeContextNodeInstance) StateNodeInstance(io.automatiko.engine.workflow.process.instance.node.StateNodeInstance) ForEachNodeInstance(io.automatiko.engine.workflow.process.instance.node.ForEachNodeInstance) EventSubProcessNodeInstance(io.automatiko.engine.workflow.process.instance.node.EventSubProcessNodeInstance) TimerNodeInstance(io.automatiko.engine.workflow.process.instance.node.TimerNodeInstance) MilestoneNodeInstance(io.automatiko.engine.workflow.process.instance.node.MilestoneNodeInstance) HumanTaskNodeInstance(io.automatiko.engine.workflow.process.instance.node.HumanTaskNodeInstance) SubProcessNodeInstance(io.automatiko.engine.workflow.process.instance.node.SubProcessNodeInstance) WorkItemNodeInstance(io.automatiko.engine.workflow.process.instance.node.WorkItemNodeInstance) DynamicNodeInstance(io.automatiko.engine.workflow.process.instance.node.DynamicNodeInstance) LambdaSubProcessNodeInstance(io.automatiko.engine.workflow.process.instance.node.LambdaSubProcessNodeInstance) NodeInstance(io.automatiko.engine.api.runtime.process.NodeInstance) RuleSetNodeInstance(io.automatiko.engine.workflow.process.instance.node.RuleSetNodeInstance) EventNodeInstance(io.automatiko.engine.workflow.process.instance.node.EventNodeInstance)

Example 2 with SwimlaneContext

use of io.automatiko.engine.workflow.base.core.context.swimlane.SwimlaneContext in project automatiko-engine by automatiko-io.

the class XmlBPMNProcessDumper method visitLanes.

private void visitLanes(WorkflowProcess process, StringBuilder xmlDump) {
    // lanes
    Collection<Swimlane> swimlanes = ((SwimlaneContext) ((io.automatiko.engine.workflow.process.core.WorkflowProcess) process).getDefaultContext(SwimlaneContext.SWIMLANE_SCOPE)).getSwimlanes();
    if (!swimlanes.isEmpty()) {
        xmlDump.append("    <laneSet>" + EOL);
        for (Swimlane swimlane : swimlanes) {
            xmlDump.append("      <lane name=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(swimlane.getName()) + "\" >" + EOL);
            visitLane(process, swimlane.getName(), xmlDump);
            xmlDump.append("      </lane>" + EOL);
        }
        xmlDump.append("    </laneSet>" + EOL);
    }
}
Also used : SwimlaneContext(io.automatiko.engine.workflow.base.core.context.swimlane.SwimlaneContext) Swimlane(io.automatiko.engine.workflow.base.core.context.swimlane.Swimlane)

Example 3 with SwimlaneContext

use of io.automatiko.engine.workflow.base.core.context.swimlane.SwimlaneContext in project automatiko-engine by automatiko-io.

the class SwimlaneHandler method start.

public Object start(final String uri, final String localName, final Attributes attrs, final ExtensibleXmlParser parser) throws SAXException {
    parser.startElementBuilder(localName, attrs);
    WorkflowProcessImpl process = (WorkflowProcessImpl) parser.getParent();
    final String name = attrs.getValue("name");
    emptyAttributeCheck(localName, "name", name, parser);
    SwimlaneContext swimlaneContext = (SwimlaneContext) process.getDefaultContext(SwimlaneContext.SWIMLANE_SCOPE);
    if (swimlaneContext != null) {
        Swimlane swimlane = new Swimlane();
        swimlane.setName(name);
        swimlaneContext.addSwimlane(swimlane);
    } else {
        throw new SAXParseException("Could not find default swimlane context.", parser.getLocator());
    }
    return null;
}
Also used : SwimlaneContext(io.automatiko.engine.workflow.base.core.context.swimlane.SwimlaneContext) Swimlane(io.automatiko.engine.workflow.base.core.context.swimlane.Swimlane) SAXParseException(org.xml.sax.SAXParseException) WorkflowProcessImpl(io.automatiko.engine.workflow.process.core.impl.WorkflowProcessImpl)

Example 4 with SwimlaneContext

use of io.automatiko.engine.workflow.base.core.context.swimlane.SwimlaneContext in project automatiko-engine by automatiko-io.

the class XmlWorkflowProcessDumper method visitHeader.

protected void visitHeader(WorkflowProcess process, StringBuilder xmlDump, boolean includeMeta) {
    xmlDump.append("  <header>" + EOL);
    visitImports(((io.automatiko.engine.workflow.base.core.Process) process).getImports(), xmlDump);
    visitGlobals(((io.automatiko.engine.workflow.base.core.Process) process).getGlobals(), xmlDump);
    visitFunctionImports(((io.automatiko.engine.workflow.base.core.Process) process).getFunctionImports(), xmlDump);
    VariableScope variableScope = (VariableScope) ((io.automatiko.engine.workflow.base.core.Process) process).getDefaultContext(VariableScope.VARIABLE_SCOPE);
    if (variableScope != null) {
        visitVariables(variableScope.getVariables(), xmlDump);
    }
    SwimlaneContext swimlaneContext = (SwimlaneContext) ((io.automatiko.engine.workflow.base.core.Process) process).getDefaultContext(SwimlaneContext.SWIMLANE_SCOPE);
    if (swimlaneContext != null) {
        visitSwimlanes(swimlaneContext.getSwimlanes(), xmlDump);
    }
    ExceptionScope exceptionScope = (ExceptionScope) ((io.automatiko.engine.workflow.base.core.Process) process).getDefaultContext(ExceptionScope.EXCEPTION_SCOPE);
    if (exceptionScope != null) {
        visitExceptionHandlers(exceptionScope.getExceptionHandlers(), xmlDump);
    }
    xmlDump.append("  </header>" + EOL + EOL);
}
Also used : SwimlaneContext(io.automatiko.engine.workflow.base.core.context.swimlane.SwimlaneContext) ExceptionScope(io.automatiko.engine.workflow.base.core.context.exception.ExceptionScope) VariableScope(io.automatiko.engine.workflow.base.core.context.variable.VariableScope)

Aggregations

SwimlaneContext (io.automatiko.engine.workflow.base.core.context.swimlane.SwimlaneContext)4 Swimlane (io.automatiko.engine.workflow.base.core.context.swimlane.Swimlane)2 ExtensionRegistry (com.google.protobuf.ExtensionRegistry)1 Process (io.automatiko.engine.api.definition.process.Process)1 NodeInstance (io.automatiko.engine.api.runtime.process.NodeInstance)1 NodeInstanceContainer (io.automatiko.engine.api.runtime.process.NodeInstanceContainer)1 ProcessInstance (io.automatiko.engine.api.runtime.process.ProcessInstance)1 WorkflowProcessInstance (io.automatiko.engine.api.runtime.process.WorkflowProcessInstance)1 ExecutionsErrorInfo (io.automatiko.engine.api.workflow.ExecutionsErrorInfo)1 Context (io.automatiko.engine.workflow.base.core.Context)1 ExceptionScope (io.automatiko.engine.workflow.base.core.context.exception.ExceptionScope)1 VariableScope (io.automatiko.engine.workflow.base.core.context.variable.VariableScope)1 ExclusiveGroupInstance (io.automatiko.engine.workflow.base.instance.context.exclusive.ExclusiveGroupInstance)1 SwimlaneContextInstance (io.automatiko.engine.workflow.base.instance.context.swimlane.SwimlaneContextInstance)1 Header (io.automatiko.engine.workflow.marshalling.impl.AutomatikoMessages.Header)1 WorkflowProcessImpl (io.automatiko.engine.workflow.process.core.impl.WorkflowProcessImpl)1 WorkflowProcessInstanceImpl (io.automatiko.engine.workflow.process.instance.impl.WorkflowProcessInstanceImpl)1 CompositeContextNodeInstance (io.automatiko.engine.workflow.process.instance.node.CompositeContextNodeInstance)1 DynamicNodeInstance (io.automatiko.engine.workflow.process.instance.node.DynamicNodeInstance)1 EventNodeInstance (io.automatiko.engine.workflow.process.instance.node.EventNodeInstance)1