newNode.setTask(task);
org.jbpm.taskmgmt.def.Swimlane jPDLswimlane = task.getSwimlane();
if (jPDLswimlane != null) {
String swimlaneName = jPDLswimlane.getName();
if (swimlaneContext.getSwimlane(swimlaneName) == null) {
Swimlane swimlane = new Swimlane();
swimlane.setName(swimlaneName);
swimlane.setActorId(jPDLswimlane.getActorIdExpression());
// TODO support other types of actor expressions as well
swimlaneContext.addSwimlane(swimlane);
}
}
}
node = newNode;
} else if (jPDLnode instanceof org.jbpm.graph.node.EndState) {
node = new EndState();
} else if (org.jbpm.graph.def.Node.class.equals(jPDLnode.getClass())) {
JpdlNode newNode = new JpdlNode();
setDefaultNodeProperties(jPDLnode, newNode);
node = newNode;
} else if (jPDLnode instanceof org.jbpm.graph.node.Fork) {
org.jbpm.graph.node.Fork jPDLfork =
(org.jbpm.graph.node.Fork) jPDLnode;
Fork newNode = new Fork();
newNode.setScript(jPDLfork.getScript());
node = newNode;
} else if (jPDLnode instanceof org.jbpm.graph.node.Join) {
org.jbpm.graph.node.Join jPDLjoin =
(org.jbpm.graph.node.Join) jPDLnode;
Join newNode = new Join();
newNode.setDiscriminator(jPDLjoin.isDiscriminator());
newNode.setTokenNames(jPDLjoin.getTokenNames());
newNode.setScript(jPDLjoin.getScript());
newNode.setNOutOfM(jPDLjoin.getNOutOfM());
node = newNode;
} else if (jPDLnode instanceof org.jbpm.graph.node.MailNode) {
String config = jPDLnode.getAction().getActionDelegation().getConfiguration();
MailNode newNode = new MailNode();
Matcher matcher = MAIL_TEMPLATE_PATTERN.matcher(config);
if (matcher.find()) {
newNode.setTemplate(matcher.group(1));
}
matcher = MAIL_ACTORS_PATTERN.matcher(config);
if (matcher.find()) {
newNode.setActors(matcher.group(1));
}
matcher = MAIL_TO_PATTERN.matcher(config);
if (matcher.find()) {
newNode.setToEmail(matcher.group(1));
}
matcher = MAIL_SUBJECT_PATTERN.matcher(config);
if (matcher.find()) {
newNode.setSubject(matcher.group(1));
}
matcher = MAIL_TEXT_PATTERN.matcher(config);
if (matcher.find()) {
newNode.setText(matcher.group(1));
}
node = newNode;
} else if (jPDLnode instanceof org.jbpm.graph.node.Decision) {
org.jbpm.graph.node.Decision jPDLdecision =
(org.jbpm.graph.node.Decision) jPDLnode;
Decision newNode = new Decision();
newNode.setDecisionConditions(jPDLdecision.getDecisionConditions());
// TODO: unable to access decisionDelegation
// TODO: unable to access decisionExpression
node = newNode;
} else if (jPDLnode instanceof org.jbpm.graph.node.ProcessState) {
org.jbpm.graph.node.ProcessState jPDLprocessState =
(org.jbpm.graph.node.ProcessState) jPDLnode;
ProcessState newNode = new ProcessState();
ProcessDefinition subProcessDefinition =
jPDLprocessState.getSubProcessDefinition();
if (subProcessDefinition != null) {
newNode.setSubProcessName(subProcessDefinition.getName());
// TODO: parse sub process definition as well
}
// TODO: unable to access subProcessName
// TODO: unable to access variableAccesses
node = newNode;
} else if (jPDLnode instanceof org.jbpm.graph.def.SuperState) {
org.jbpm.graph.def.SuperState jPDLsuperState =
(org.jbpm.graph.def.SuperState) jPDLnode;
SuperState newNode = new SuperState();
List<org.jbpm.graph.def.Node> nodes = jPDLsuperState.getNodes();
Map<org.jbpm.graph.def.Node, Node> mapping = new HashMap<org.jbpm.graph.def.Node, Node>();
for (org.jbpm.graph.def.Node nodeInsideSuperState : nodes) {
JpdlNode nodeToAdd = classifyNode(processDefinition, nodeInsideSuperState, swimlaneContext);
if (nodeToAdd == null) {
throw new IllegalArgumentException(
"Unknown node type: " + jPDLnode.getClass().getName() + " " + jPDLnode);
}
setDefaultNodeProperties(nodeInsideSuperState, (JpdlNode) nodeToAdd);
nodeToAdd.setId(++nodeId);
mapping.put(nodeInsideSuperState, nodeToAdd);
newNode.addNode(nodeToAdd);
}
generateConnections(mapping);
node = newNode;
} else if (jPDLnode instanceof org.jbpm.graph.node.TaskNode) {
org.jbpm.graph.node.TaskNode jPDLtaskNode =
(org.jbpm.graph.node.TaskNode) jPDLnode;
TaskNode newNode = new TaskNode();
Set<Task> tasks = jPDLtaskNode.getTasks();
newNode.setTasks(tasks);
newNode.setSignal(jPDLtaskNode.getSignal());
newNode.setCreateTasks(jPDLtaskNode.getCreateTasks());
newNode.setEndTasks(jPDLtaskNode.isEndTasks());
for (Task task : tasks) {
org.jbpm.taskmgmt.def.Swimlane jPDLswimlane = task.getSwimlane();
if (jPDLswimlane != null) {
String swimlaneName = jPDLswimlane.getName();
if (swimlaneContext.getSwimlane(swimlaneName) == null) {
Swimlane swimlane = new Swimlane();
swimlane.setName(swimlaneName);
swimlane.setActorId(jPDLswimlane.getActorIdExpression());
// TODO support other types of actor expressions as well
swimlaneContext.addSwimlane(swimlane);
}
}
}