KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > taskmgmt > def > Task


1 package org.jbpm.taskmgmt.def;
2
3 import org.jbpm.graph.def.Event;
4 import org.jbpm.graph.def.GraphElement;
5 import org.jbpm.graph.node.StartState;
6 import org.jbpm.graph.node.TaskNode;
7 import org.jbpm.instantiation.Delegation;
8
9 /**
10  * defines a task and how the actor must be calculated at runtime.
11  */

12 public class Task extends GraphElement {
13   
14   private static final long serialVersionUID = 1L;
15   
16   public static final int PRIORITY_HIGHEST = 1;
17   public static final int PRIORITY_HIGH = 2;
18   public static final int PRIORITY_NORMAL = 3;
19   public static final int PRIORITY_LOW = 4;
20   public static final int PRIORITY_LOWEST = 5;
21   
22   public static int parsePriority(String JavaDoc priorityText) {
23     if ("highest".equalsIgnoreCase(priorityText)) return PRIORITY_HIGHEST;
24     else if ("high".equalsIgnoreCase(priorityText)) return PRIORITY_HIGH;
25     else if ("normal".equalsIgnoreCase(priorityText)) return PRIORITY_NORMAL;
26     else if ("low".equalsIgnoreCase(priorityText)) return PRIORITY_LOW;
27     else if ("lowest".equalsIgnoreCase(priorityText)) return PRIORITY_LOWEST;
28     try {
29       return Integer.parseInt(priorityText);
30     } catch (NumberFormatException JavaDoc e) {
31       throw new RuntimeException JavaDoc("priority '"+priorityText+"' could not be parsed as a priority");
32     }
33   }
34
35   protected String JavaDoc description = null;
36   protected boolean isBlocking = false;
37   protected String JavaDoc dueDate = null;
38   protected int priority = PRIORITY_NORMAL;
39   protected TaskNode taskNode = null;
40   protected StartState startState = null;
41   protected TaskMgmtDefinition taskMgmtDefinition = null;
42   protected Swimlane swimlane = null;
43   protected Delegation assignmentDelegation = null;
44   protected TaskController taskController = null;
45   
46   public Task() {
47   }
48
49   public Task(String JavaDoc name) {
50     this.name = name;
51   }
52
53   // event types //////////////////////////////////////////////////////////////
54

55   private static final String JavaDoc[] supportedEventTypes = new String JavaDoc[]{
56     Event.EVENTTYPE_TASK_CREATE,
57     Event.EVENTTYPE_TASK_ASSIGN,
58     Event.EVENTTYPE_TASK_START,
59     Event.EVENTTYPE_TASK_END
60   };
61   public String JavaDoc[] getSupportedEventTypes() {
62     return supportedEventTypes;
63   }
64
65   // task instance factory methods ////////////////////////////////////////////
66

67   /**
68    * sets the swimlane unidirectionally. Since a task can have max one of swimlane or assignmentHandler,
69    * this method removes the assignmentHandler if it is set. To create a bidirectional relation, use
70    * {@link Swimlane#addTask(Task)}.
71    */

72   public void setSwimlane(Swimlane swimlane) {
73     this.swimlane = swimlane;
74     assignmentDelegation = null;
75   }
76   /**
77    * sets the taskNode unidirectionally. use {@link TaskNode#addTask(Task)} to create
78    * a bidirectional relation.
79    */

80   public void setTaskNode(TaskNode taskNode) {
81     this.taskNode = taskNode;
82   }
83   
84   /**
85    * sets the taskMgmtDefinition unidirectionally. use TaskMgmtDefinition.addTask to create
86    * a bidirectional relation.
87    */

88   public void setTaskMgmtDefinition(TaskMgmtDefinition taskMgmtDefinition) {
89     this.taskMgmtDefinition = taskMgmtDefinition;
90   }
91
92   /**
93    * sets the swimlane. Since a task can have max one of swimlane or assignmentHandler,
94    * this method removes the swimlane if it is set.
95    */

96   public void setAssignmentDelegation(Delegation assignmentDelegation) {
97     this.assignmentDelegation = assignmentDelegation;
98     this.swimlane = null;
99   }
100
101   // parent ///////////////////////////////////////////////////////////////////
102

103   public GraphElement getParent() {
104     if (taskNode!=null) {
105       return taskNode;
106     }
107     if (startState!=null) {
108       return startState;
109     }
110     return processDefinition;
111   }
112   
113   // getters and setters //////////////////////////////////////////////////////
114

115   public TaskMgmtDefinition getTaskMgmtDefinition() {
116     return taskMgmtDefinition;
117   }
118   public String JavaDoc getDescription() {
119     return description;
120   }
121   public void setDescription(String JavaDoc description) {
122     this.description = description;
123   }
124   public Swimlane getSwimlane() {
125     return swimlane;
126   }
127   public boolean isBlocking() {
128     return isBlocking;
129   }
130   public void setBlocking(boolean isBlocking) {
131     this.isBlocking = isBlocking;
132   }
133   public TaskNode getTaskNode() {
134     return taskNode;
135   }
136   public Delegation getAssignmentDelegation() {
137     return assignmentDelegation;
138   }
139   public String JavaDoc getDueDate() {
140     return dueDate;
141   }
142   public void setDueDate(String JavaDoc duedate) {
143     this.dueDate = duedate;
144   }
145   public TaskController getTaskController() {
146     return taskController;
147   }
148   public void setTaskController(TaskController taskController) {
149     this.taskController = taskController;
150   }
151   public int getPriority() {
152     return priority;
153   }
154   public void setPriority(int priority) {
155     this.priority = priority;
156   }
157   public StartState getStartState() {
158     return startState;
159   }
160   public void setStartState(StartState startState) {
161     this.startState = startState;
162   }
163 }
164
Popular Tags