1 package org.jbpm.graph.node; 2 3 import java.util.Map ; 4 5 import org.dom4j.Element; 6 import org.jbpm.graph.def.Event; 7 import org.jbpm.graph.def.Node; 8 import org.jbpm.graph.def.Transition; 9 import org.jbpm.graph.exe.ExecutionContext; 10 import org.jbpm.jpdl.xml.JpdlXmlReader; 11 import org.jbpm.security.Authentication; 12 import org.jbpm.taskmgmt.def.Swimlane; 13 import org.jbpm.taskmgmt.def.TaskMgmtDefinition; 14 import org.jbpm.taskmgmt.exe.SwimlaneInstance; 15 16 public class StartState extends Node { 17 18 private static final long serialVersionUID = 1L; 19 20 public Swimlane initiatorSwimlane = null; 23 24 public StartState() { 25 } 26 27 public StartState(String name) { 28 super(name); 29 } 30 31 33 public static final String [] supportedEventTypes = new String []{ 34 Event.EVENTTYPE_NODE_LEAVE, 35 Event.EVENTTYPE_AFTER_SIGNAL 36 }; 37 public String [] getSupportedEventTypes() { 38 return supportedEventTypes; 39 } 40 41 43 public void read(Element startStateElement, JpdlXmlReader jpdlReader) { 44 String swimlaneName = startStateElement.attributeValue("swimlane"); 45 if (swimlaneName!=null) { 46 TaskMgmtDefinition taskMgmtDefinition = jpdlReader.getProcessDefinition().getTaskMgmtDefinition(); 47 initiatorSwimlane = taskMgmtDefinition.getSwimlane(swimlaneName); 48 } 49 50 Element startTaskElement = startStateElement.element("task"); 52 if (startTaskElement!=null) { 53 jpdlReader.readStartStateTask(startTaskElement, this); 55 } 56 } 57 58 public void write(Element nodeElement) { 59 } 60 61 public void leave(ExecutionContext executionContext, Transition transition) { 62 if (initiatorSwimlane!=null) { 64 SwimlaneInstance initiatorSwimlaneInstance = executionContext.getTaskMgmtInstance().getSwimlaneInstance(initiatorSwimlane.getName()); 66 String initiatorActorId = Authentication.getAuthenticatedActorId(); 68 initiatorSwimlaneInstance.setActorId(initiatorActorId); 70 } 71 72 super.leave(executionContext, transition); 74 } 75 76 public void execute(ExecutionContext executionContext) { 77 throw new UnsupportedOperationException ( "illegal operation : its not possible to arrive in a start-state" ); 78 } 79 80 public Transition addArrivingTransition(Transition t) { 81 throw new UnsupportedOperationException ( "illegal operation : its not possible to add a transition that is arriving in a start state" ); 82 } 83 84 public void setArrivingTransitions(Map arrivingTransitions) { 85 if ( (arrivingTransitions!=null) 86 && (arrivingTransitions.size()>0)) { 87 throw new UnsupportedOperationException ( "illegal operation : its not possible to set a non-empty map in the arriving transitions of a start state" ); 88 } 89 } 90 } 91 | Popular Tags |