public String dump(WorkflowProcess process) { return dump(process, true); }
private void visitConnections(Node[] nodes, StringBuilder xmlDump, boolean includeMeta) { List<Connection> connections = new ArrayList<Connection>(); for (Node node: nodes) { for (List<Connection> connectionList: node.getIncomingConnections().values()) { connections.addAll(connectionList); } } xmlDump.append(" <connections>" + EOL); for (Connection connection: connections) { visitConnection(connection, xmlDump, includeMeta); } xmlDump.append(" </connections>" + EOL + EOL); }
visitHeader(process, xmlDump, includeMeta); visitNodes(process, xmlDump, includeMeta); visitConnections(process.getNodes(), xmlDump, includeMeta); xmlDump.append("</process>");
public static void visitVariables(List<Variable> variables, StringBuilder xmlDump) { if (variables != null && variables.size() > 0) { xmlDump.append(" <variables>" + EOL); for (Variable variable: variables) { xmlDump.append(" <variable name=\"" + variable.getName() + "\" >" + EOL); visitDataType(variable.getType(), xmlDump); Object value = variable.getValue(); if (value != null) { visitValue(variable.getValue(), variable.getType(), xmlDump); } xmlDump.append(" </variable>" + EOL); } xmlDump.append(" </variables>" + EOL); } }
protected void visitHeader(WorkflowProcess process, StringBuilder xmlDump, boolean includeMeta) { xmlDump.append(" <header>" + EOL); visitImports(((org.jbpm.process.core.Process) process).getImports(), xmlDump); visitGlobals(((org.jbpm.process.core.Process) process).getGlobals(), xmlDump); visitFunctionImports(((org.jbpm.process.core.Process) process).getFunctionImports(), xmlDump); VariableScope variableScope = (VariableScope) ((org.jbpm.process.core.Process) process).getDefaultContext(VariableScope.VARIABLE_SCOPE); if (variableScope != null) { visitVariables(variableScope.getVariables(), xmlDump); } SwimlaneContext swimlaneContext = (SwimlaneContext) ((org.jbpm.process.core.Process) process).getDefaultContext(SwimlaneContext.SWIMLANE_SCOPE); if (swimlaneContext != null) { visitSwimlanes(swimlaneContext.getSwimlanes(), xmlDump); } ExceptionScope exceptionScope = (ExceptionScope) ((org.jbpm.process.core.Process) process).getDefaultContext(ExceptionScope.EXCEPTION_SCOPE); if (exceptionScope != null) { visitExceptionHandlers(exceptionScope.getExceptionHandlers(), xmlDump); } xmlDump.append(" </header>" + EOL + EOL); }
if (variableScope != null) { List<Variable> variables = variableScope.getVariables(); XmlWorkflowProcessDumper.visitVariables(variables, xmlDump); XmlWorkflowProcessDumper.visitExceptionHandlers( exceptionScope.getExceptionHandlers(), xmlDump);
private void visitNodes(WorkflowProcess process, StringBuilder xmlDump, boolean includeMeta) { xmlDump.append(" <nodes>" + EOL); for (Node node: process.getNodes()) { visitNode(node, xmlDump, includeMeta); } xmlDump.append(" </nodes>" + EOL + EOL); }
protected void visitHeader(WorkflowProcess process, StringBuilder xmlDump, boolean includeMeta) { xmlDump.append(" <header>" + EOL); visitImports(((org.jbpm.process.core.Process) process).getImports(), xmlDump); visitGlobals(((org.jbpm.process.core.Process) process).getGlobals(), xmlDump); visitFunctionImports(((org.jbpm.process.core.Process) process).getFunctionImports(), xmlDump); VariableScope variableScope = (VariableScope) ((org.jbpm.process.core.Process) process).getDefaultContext(VariableScope.VARIABLE_SCOPE); if (variableScope != null) { visitVariables(variableScope.getVariables(), xmlDump); } SwimlaneContext swimlaneContext = (SwimlaneContext) ((org.jbpm.process.core.Process) process).getDefaultContext(SwimlaneContext.SWIMLANE_SCOPE); if (swimlaneContext != null) { visitSwimlanes(swimlaneContext.getSwimlanes(), xmlDump); } ExceptionScope exceptionScope = (ExceptionScope) ((org.jbpm.process.core.Process) process).getDefaultContext(ExceptionScope.EXCEPTION_SCOPE); if (exceptionScope != null) { visitExceptionHandlers(exceptionScope.getExceptionHandlers(), xmlDump); } xmlDump.append(" </header>" + EOL + EOL); }
protected void visitWork(Work work, StringBuilder xmlDump, boolean includeMeta) { if (work != null) { xmlDump.append(" <work name=\"" + work.getName() + "\" >" + EOL); List<ParameterDefinition> parameterDefinitions = new ArrayList<ParameterDefinition>(work.getParameterDefinitions()); Collections.sort(parameterDefinitions, new Comparator<ParameterDefinition>() { public int compare(ParameterDefinition o1, ParameterDefinition o2) { return o1.getName().compareTo(o2.getName()); } }); for (ParameterDefinition paramDefinition: parameterDefinitions) { DataType dataType = paramDefinition.getType(); xmlDump.append(" <parameter name=\"" + paramDefinition.getName() + "\" >" + EOL + " "); XmlWorkflowProcessDumper.visitDataType(dataType, xmlDump); Object value = work.getParameter(paramDefinition.getName()); if (value != null) { xmlDump.append(" "); XmlWorkflowProcessDumper.visitValue(value, dataType, xmlDump); } xmlDump.append(" </parameter>" + EOL); } xmlDump.append(" </work>" + EOL); } } }
if (variableScope != null) { List<Variable> variables = variableScope.getVariables(); XmlWorkflowProcessDumper.visitVariables(variables, xmlDump); XmlWorkflowProcessDumper.visitExceptionHandlers( exceptionScope.getExceptionHandlers(), xmlDump);
private void visitNodes(WorkflowProcess process, StringBuilder xmlDump, boolean includeMeta) { xmlDump.append(" <nodes>" + EOL); for (Node node: process.getNodes()) { visitNode(node, xmlDump, includeMeta); } xmlDump.append(" </nodes>" + EOL + EOL); }
visitHeader(process, xmlDump, includeMeta); visitNodes(process, xmlDump, includeMeta); visitConnections(process.getNodes(), xmlDump, includeMeta); xmlDump.append("</process>");
public static void visitVariables(List<Variable> variables, StringBuilder xmlDump) { if (variables != null && variables.size() > 0) { xmlDump.append(" <variables>" + EOL); for (Variable variable: variables) { xmlDump.append(" <variable name=\"" + variable.getName() + "\" >" + EOL); visitDataType(variable.getType(), xmlDump); Object value = variable.getValue(); if (value != null) { visitValue(variable.getValue(), variable.getType(), xmlDump); } xmlDump.append(" </variable>" + EOL); } xmlDump.append(" </variables>" + EOL); } }
public String dump(WorkflowProcess process) { return dump(process, true); }
private void visitConnections(Node[] nodes, StringBuilder xmlDump, boolean includeMeta) { List<Connection> connections = new ArrayList<Connection>(); for (Node node: nodes) { for (List<Connection> connectionList: node.getIncomingConnections().values()) { connections.addAll(connectionList); } } xmlDump.append(" <connections>" + EOL); for (Connection connection: connections) { visitConnection(connection, xmlDump, includeMeta); } xmlDump.append(" </connections>" + EOL + EOL); }
protected void visitWork(Work work, StringBuilder xmlDump, boolean includeMeta) { if (work != null) { xmlDump.append(" <work name=\"" + work.getName() + "\" >" + EOL); List<ParameterDefinition> parameterDefinitions = new ArrayList<ParameterDefinition>(work.getParameterDefinitions()); Collections.sort(parameterDefinitions, new Comparator<ParameterDefinition>() { public int compare(ParameterDefinition o1, ParameterDefinition o2) { return o1.getName().compareTo(o2.getName()); } }); for (ParameterDefinition paramDefinition: parameterDefinitions) { DataType dataType = paramDefinition.getType(); xmlDump.append(" <parameter name=\"" + paramDefinition.getName() + "\" >" + EOL + " "); XmlWorkflowProcessDumper.visitDataType(dataType, xmlDump); Object value = work.getParameter(paramDefinition.getName()); if (value != null) { xmlDump.append(" "); XmlWorkflowProcessDumper.visitValue(value, dataType, xmlDump); } xmlDump.append(" </parameter>" + EOL); } xmlDump.append(" </work>" + EOL); } } }