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 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 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 e) { 31 throw new RuntimeException ("priority '"+priorityText+"' could not be parsed as a priority"); 32 } 33 } 34 35 protected String description = null; 36 protected boolean isBlocking = false; 37 protected String 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 name) { 50 this.name = name; 51 } 52 53 55 private static final String [] supportedEventTypes = new String []{ 56 Event.EVENTTYPE_TASK_CREATE, 57 Event.EVENTTYPE_TASK_ASSIGN, 58 Event.EVENTTYPE_TASK_START, 59 Event.EVENTTYPE_TASK_END 60 }; 61 public String [] getSupportedEventTypes() { 62 return supportedEventTypes; 63 } 64 65 67 72 public void setSwimlane(Swimlane swimlane) { 73 this.swimlane = swimlane; 74 assignmentDelegation = null; 75 } 76 80 public void setTaskNode(TaskNode taskNode) { 81 this.taskNode = taskNode; 82 } 83 84 88 public void setTaskMgmtDefinition(TaskMgmtDefinition taskMgmtDefinition) { 89 this.taskMgmtDefinition = taskMgmtDefinition; 90 } 91 92 96 public void setAssignmentDelegation(Delegation assignmentDelegation) { 97 this.assignmentDelegation = assignmentDelegation; 98 this.swimlane = null; 99 } 100 101 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 115 public TaskMgmtDefinition getTaskMgmtDefinition() { 116 return taskMgmtDefinition; 117 } 118 public String getDescription() { 119 return description; 120 } 121 public void setDescription(String 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 getDueDate() { 140 return dueDate; 141 } 142 public void setDueDate(String 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 |