use of org.jbpm.process.core.context.variable.VariableScope in project jbpm by kiegroup.
the class ForEachNode method setOutputVariable.
public void setOutputVariable(String variableName, DataType type) {
this.outputVariableName = variableName;
VariableScope variableScope = (VariableScope) getCompositeNode().getDefaultContext(VariableScope.VARIABLE_SCOPE);
List<Variable> variables = variableScope.getVariables();
if (variables == null) {
variables = new ArrayList<Variable>();
variableScope.setVariables(variables);
}
Variable variable = new Variable();
variable.setName(variableName);
variable.setType(type);
variables.add(variable);
Variable tmpvariable = new Variable();
tmpvariable.setName("foreach_output");
tmpvariable.setType(type);
variables.add(tmpvariable);
}
use of org.jbpm.process.core.context.variable.VariableScope in project jbpm by kiegroup.
the class XmlWorkflowProcessDumper method visitHeader.
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);
}
use of org.jbpm.process.core.context.variable.VariableScope in project jbpm by kiegroup.
the class CompositeNodeHandler method writeNode.
public void writeNode(Node node, StringBuilder xmlDump, boolean includeMeta) {
super.writeNode(getNodeName(), node, xmlDump, includeMeta);
CompositeNode compositeNode = (CompositeNode) node;
writeAttributes(compositeNode, xmlDump, includeMeta);
xmlDump.append(">" + EOL);
if (includeMeta) {
writeMetaData(compositeNode, xmlDump);
}
for (String eventType : compositeNode.getActionTypes()) {
writeActions(eventType, compositeNode.getActions(eventType), xmlDump);
}
writeTimers(compositeNode.getTimers(), xmlDump);
if (compositeNode instanceof CompositeContextNode) {
VariableScope variableScope = (VariableScope) ((CompositeContextNode) compositeNode).getDefaultContext(VariableScope.VARIABLE_SCOPE);
if (variableScope != null) {
List<Variable> variables = variableScope.getVariables();
XmlWorkflowProcessDumper.visitVariables(variables, xmlDump);
}
ExceptionScope exceptionScope = (ExceptionScope) ((CompositeContextNode) compositeNode).getDefaultContext(ExceptionScope.EXCEPTION_SCOPE);
if (exceptionScope != null) {
XmlWorkflowProcessDumper.visitExceptionHandlers(exceptionScope.getExceptionHandlers(), xmlDump);
}
}
List<Node> subNodes = getSubNodes(compositeNode);
xmlDump.append(" <nodes>" + EOL);
for (Node subNode : subNodes) {
XmlRuleFlowProcessDumper.INSTANCE.visitNode(subNode, xmlDump, includeMeta);
}
xmlDump.append(" </nodes>" + EOL);
List<Connection> connections = getSubConnections(compositeNode);
xmlDump.append(" <connections>" + EOL);
for (Connection connection : connections) {
XmlRuleFlowProcessDumper.INSTANCE.visitConnection(connection, xmlDump, includeMeta);
}
xmlDump.append(" </connections>" + EOL);
Map<String, CompositeNode.NodeAndType> inPorts = getInPorts(compositeNode);
xmlDump.append(" <in-ports>" + EOL);
for (Map.Entry<String, CompositeNode.NodeAndType> entry : inPorts.entrySet()) {
xmlDump.append(" <in-port type=\"" + entry.getKey() + "\" nodeId=\"" + entry.getValue().getNodeId() + "\" nodeInType=\"" + entry.getValue().getType() + "\" />" + EOL);
}
xmlDump.append(" </in-ports>" + EOL);
Map<String, CompositeNode.NodeAndType> outPorts = getOutPorts(compositeNode);
xmlDump.append(" <out-ports>" + EOL);
for (Map.Entry<String, CompositeNode.NodeAndType> entry : outPorts.entrySet()) {
xmlDump.append(" <out-port type=\"" + entry.getKey() + "\" nodeId=\"" + entry.getValue().getNodeId() + "\" nodeOutType=\"" + entry.getValue().getType() + "\" />" + EOL);
}
xmlDump.append(" </out-ports>" + EOL);
endNode(getNodeName(), xmlDump);
}
use of org.jbpm.process.core.context.variable.VariableScope in project jbpm by kiegroup.
the class CompositeNodeFactory method variable.
public CompositeNodeFactory variable(String name, DataType type, Object value) {
Variable variable = new Variable();
variable.setName(name);
variable.setType(type);
variable.setValue(value);
VariableScope variableScope = (VariableScope) getCompositeNode().getDefaultContext(VariableScope.VARIABLE_SCOPE);
if (variableScope == null) {
variableScope = new VariableScope();
getCompositeNode().addContext(variableScope);
getCompositeNode().setDefaultContext(variableScope);
}
variableScope.getVariables().add(variable);
return this;
}
use of org.jbpm.process.core.context.variable.VariableScope in project jbpm by kiegroup.
the class DynamicNodeFactory method variable.
public DynamicNodeFactory variable(String name, DataType type, Object value) {
Variable variable = new Variable();
variable.setName(name);
variable.setType(type);
variable.setValue(value);
VariableScope variableScope = (VariableScope) getCompositeNode().getDefaultContext(VariableScope.VARIABLE_SCOPE);
if (variableScope == null) {
variableScope = new VariableScope();
getCompositeNode().addContext(variableScope);
getCompositeNode().setDefaultContext(variableScope);
}
variableScope.getVariables().add(variable);
return this;
}
Aggregations