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;
}
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);
}
}
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;
}
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);
}
Aggregations