* @author Tom Baeyens
*/
public class LifeCycleParser extends Parser {
public Object parseDocumentElement(Element element, Parse parse) {
ProcessDefinitionImpl lifeCycleProcess = new LifeCycle();
lifeCycleProcess.setName("TaskLifeCycle");
List<Element> stateElements = XmlUtil.elements(element, "state");
for (Element stateElement: stateElements) {
parseState(stateElement, lifeCycleProcess, parse);
}
for (Element stateElement: stateElements) {
parseTransitions(stateElement, lifeCycleProcess, parse);
}
String initialStateName = null;
if (element.hasAttribute("initial")) {
initialStateName = element.getAttribute("initial");
ActivityImpl initial = (ActivityImpl) lifeCycleProcess.getActivity(initialStateName);
if (initial!=null) {
lifeCycleProcess.setInitial(initial);
} else {
parse.addProblem("initial "+initialStateName+" doesn't exist", element);
}
}