1 package org.jbpm.graph.def; 2 3 import java.io.Serializable ; 4 import java.util.ArrayList ; 5 import java.util.List ; 6 7 public class Event implements Serializable { 8 9 private static final long serialVersionUID = 1L; 10 11 public static final String EVENTTYPE_TRANSITION = "transition"; 12 public static final String EVENTTYPE_BEFORE_SIGNAL = "before-signal"; 13 public static final String EVENTTYPE_AFTER_SIGNAL = "after-signal"; 14 public static final String EVENTTYPE_PROCESS_START = "process-start"; 15 public static final String EVENTTYPE_PROCESS_END = "process-end"; 16 public static final String EVENTTYPE_NODE_ENTER = "node-enter"; 17 public static final String EVENTTYPE_NODE_LEAVE = "node-leave"; 18 public static final String EVENTTYPE_SUPERSTATE_ENTER = "superstate-enter"; 19 public static final String EVENTTYPE_SUPERSTATE_LEAVE = "superstate-leave"; 20 public static final String EVENTTYPE_SUBPROCESS_CREATED = "subprocess-created"; 21 public static final String EVENTTYPE_SUBPROCESS_END = "subprocess-end"; 22 public static final String EVENTTYPE_TASK_CREATE = "task-create"; 23 public static final String EVENTTYPE_TASK_ASSIGN = "task-assign"; 24 public static final String EVENTTYPE_TASK_START = "task-start"; 25 public static final String EVENTTYPE_TASK_END = "task-end"; 26 public static final String EVENTTYPE_TIMER = "timer"; 27 28 long id = 0; 29 protected String eventType = null; 30 protected GraphElement graphElement = null; 31 protected List actions = null; 32 33 35 public Event() { 36 } 37 38 public Event(String eventType) { 39 this.eventType = eventType; 40 } 41 42 public Event(GraphElement graphElement, String eventType) { 43 this.graphElement = graphElement; 44 this.eventType = eventType; 45 } 46 47 49 53 public List getActions() { 54 return actions; 55 } 56 57 public boolean hasActions() { 58 return ( (actions!=null) 59 && (actions.size()>0) ); 60 } 61 62 public Action addAction(Action action) { 63 if (action==null) throw new IllegalArgumentException ("can't add a null action to an event"); 64 if (actions==null) actions = new ArrayList (); 65 actions.add(action); 66 action.event = this; 67 return action; 68 } 69 70 public void removeAction(Action action) { 71 if (action==null) throw new IllegalArgumentException ("can't remove a null action from an event"); 72 if (actions!=null) { 73 if (actions.remove(action)) { 74 action.event=null; 75 } 76 } 77 } 78 79 123 148 149 public String toString() { 150 return eventType; 151 } 152 153 155 public String getEventType() { 156 return eventType; 157 } 158 public GraphElement getGraphElement() { 159 return graphElement; 160 } 161 public long getId() { 162 return id; 163 } 164 165 } 167 | Popular Tags |