for (ActionNode actionNode : actionNodeNodes) {
Element actionNodeElement = writeNode(document, root, actionNode, null);
for (Action action : actionNode.getActions()) {
ActionImpl actionImpl = (ActionImpl) action;
if (!Event.NODE_ACTION.equals(actionImpl.getEventType())) {
writeEvent(document, actionNodeElement, new Event(actionImpl.getEventType()), actionImpl);
}
}
}
List<Decision> decisions = definition.getChildren(Decision.class);
for (Decision decision : decisions) {
writeNode(document, root, decision, HANDLER_NODE);
}
List<TaskState> states = definition.getChildren(TaskState.class);
for (TaskState state : states) {
Element stateElement = writeTaskState(document, root, state);
if (state.timerExist()) {
Element timerElement = document.createElement(TIMER_NODE);
setAttribute(timerElement, DUEDATE_ATTR, state.getDuration().getDuration());
if (!state.hasTimeoutTransition() && state.getTimerAction() != null) {
if (state.getTimerAction().getRepeat().hasDuration()) {
setAttribute(timerElement, REPEAT_ATTR, state.getTimerAction().getRepeat().getDuration());
}
writeDelegation(document, timerElement, ACTION_NODE, state.getTimerAction());
} else {
setAttribute(timerElement, TRANSITION_NODE, PluginConstants.TIMER_TRANSITION_NAME);
}
stateElement.appendChild(timerElement);
}
writeTransitions(document, stateElement, state);
}
List<WaitState> waitStates = definition.getChildren(WaitState.class);
for (WaitState waitState : waitStates) {
Element stateElement = writeWaitState(document, root, waitState);
writeTransitions(document, stateElement, waitState);
}
List<MailNode> mailNodes = definition.getChildren(MailNode.class);
for (MailNode mailNode : mailNodes) {
Element nodeElement = writeNode(document, root, mailNode, null);
setAttribute(nodeElement, "to", mailNode.getRecipient());
writeTransitions(document, nodeElement, mailNode);
Element subject = document.createElement("subject");
setNodeValue(subject, mailNode.getSubject());
nodeElement.appendChild(subject);
Element body = document.createElement("body");
setNodeValue(body, mailNode.getMailBody());
nodeElement.appendChild(body);
}
List<Fork> forks = definition.getChildren(Fork.class);
for (org.jbpm.ui.common.model.Node node : forks) {
writeNode(document, root, node, null);
}
List<Join> joins = definition.getChildren(Join.class);
for (org.jbpm.ui.common.model.Node node : joins) {
writeNode(document, root, node, null);
}
List<Subprocess> subprocesses = definition.getChildren(Subprocess.class);
boolean addSubprocessPermissionHandler = false;
for (Subprocess subprocess : subprocesses) {
addSubprocessPermissionHandler = true;
Element processStateElement = writeNode(document, root, subprocess, null);
Element subProcessElement = document.createElement(SUB_PROCESS_NODE);
setAttribute(subProcessElement, NAME_ATTR, subprocess.getSubProcessName());
setAttribute(subProcessElement, "binding", "late");
processStateElement.appendChild(subProcessElement);
for (VariableMapping variable : subprocess.getVariablesList()) {
Element variableElement = document.createElement(VARIABLE_NODE);
setAttribute(variableElement, NAME_ATTR, variable.getProcessVariable());
setAttribute(variableElement, MAPPED_NAME_ATTR, variable.getSubprocessVariable());
setAttribute(variableElement, ACCESS_ATTR, variable.getUsage());
processStateElement.appendChild(variableElement);
}
}
/*
List<MultiInstance> multiInstances = definition.getChildren(MultiInstance.class);
for (MultiInstance multiInstance : multiInstances) {
addSubprocessPermissionHandler = true;
Element processStateElement = writeNode(document, root, multiInstance, null);
Element subProcessElement = document.createElement(SUB_PROCESS_NODE);
setAttribute(subProcessElement, NAME_ATTR, multiInstance.getSubProcessName());
setAttribute(subProcessElement, "binding", "late");
processStateElement.appendChild(subProcessElement);
for (VariableMapping variable : multiInstance.getVariablesList()) {
Element variableElement = document.createElement(VARIABLE_NODE);
setAttribute(variableElement, NAME_ATTR, variable.getProcessVariable());
setAttribute(variableElement, MAPPED_NAME_ATTR, variable.getSubprocessVariable());
setAttribute(variableElement, ACCESS_ATTR, variable.getAccess());
processStateElement.appendChild(variableElement);
}
}
*/
if (addSubprocessPermissionHandler) {
// TODO add XML comment and move to own method (after event support will be added)
ActionImpl action = new ActionImpl();
action.setDelegationClassName("ru.runa.wf.jbpm.delegation.action.SetSubProcessPermissionsActionHandler");
writeEvent(document, root, new Event(Event.SUBPROCESS_CREATED), action);
}
EndState endState = definition.getFirstChild(EndState.class);
if (endState != null) {
writeElement(document, root, endState);