TaskDefinition.java 6.7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/* Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.activiti5.engine.impl.task;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

23 24
import org.activiti.engine.delegate.Expression;
import org.activiti.engine.delegate.TaskListener;
25 26 27 28 29 30 31 32 33
import org.activiti5.engine.impl.form.TaskFormHandler;

/**
 * Container for task definition information gathered at parsing time.
 * 
 * @author Joram Barrez
 */
public class TaskDefinition implements Serializable {

34 35 36
  private static final long serialVersionUID = 1L;

  protected String key;
37
  
38 39 40 41 42 43 44 45 46 47
  // assignment fields
  protected Expression nameExpression;
  protected Expression ownerExpression;
  protected Expression descriptionExpression;
  protected Expression assigneeExpression;
  protected Set<Expression> candidateUserIdExpressions = new HashSet<Expression>();
  protected Set<Expression> candidateGroupIdExpressions = new HashSet<Expression>();
  protected Expression dueDateExpression;
  protected Expression priorityExpression;
  protected Expression categoryExpression;
48
  protected Map<String, Set<Expression>> customUserIdentityLinkExpressions = new HashMap<String, Set<Expression>>(); 
49 50
  protected Map<String, Set<Expression>> customGroupIdentityLinkExpressions = new HashMap<String, Set<Expression>>();
  protected Expression skipExpression;
51
  
52 53 54
  // form fields
  protected TaskFormHandler taskFormHandler;
  protected Expression formKeyExpression;
55
  
56 57
  // task listeners
  protected Map<String, List<TaskListener>> taskListeners = new HashMap<String, List<TaskListener>>();
58
  
59 60 61 62
  public TaskDefinition(TaskFormHandler taskFormHandler) {
    this.taskFormHandler = taskFormHandler;
  }

63
  // getters and setters //////////////////////////////////////////////////////
64 65 66 67 68 69 70 71

  public Expression getNameExpression() {
    return nameExpression;
  }

  public void setNameExpression(Expression nameExpression) {
    this.nameExpression = nameExpression;
  }
72
  
73 74 75
  public Expression getOwnerExpression() {
    return ownerExpression;
  }
76
  
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
  public void setOwnerExpression(Expression ownerExpression) {
    this.ownerExpression = ownerExpression;
  }

  public Expression getDescriptionExpression() {
    return descriptionExpression;
  }

  public void setDescriptionExpression(Expression descriptionExpression) {
    this.descriptionExpression = descriptionExpression;
  }

  public Expression getAssigneeExpression() {
    return assigneeExpression;
  }

  public void setAssigneeExpression(Expression assigneeExpression) {
    this.assigneeExpression = assigneeExpression;
  }

  public Set<Expression> getCandidateUserIdExpressions() {
    return candidateUserIdExpressions;
  }

  public void addCandidateUserIdExpression(Expression userId) {
    candidateUserIdExpressions.add(userId);
  }

  public Set<Expression> getCandidateGroupIdExpressions() {
    return candidateGroupIdExpressions;
  }

  public void addCandidateGroupIdExpression(Expression groupId) {
    candidateGroupIdExpressions.add(groupId);
  }

  public Map<String, Set<Expression>> getCustomUserIdentityLinkExpressions() {
    return customUserIdentityLinkExpressions;
  }

  public void addCustomUserIdentityLinkExpression(String identityLinkType, Set<Expression> idList) {
118
  	customUserIdentityLinkExpressions.put(identityLinkType, idList);
119 120 121 122 123 124 125
  }

  public Map<String, Set<Expression>> getCustomGroupIdentityLinkExpressions() {
    return customGroupIdentityLinkExpressions;
  }

  public void addCustomGroupIdentityLinkExpression(String identityLinkType, Set<Expression> idList) {
126
  	customGroupIdentityLinkExpressions.put(identityLinkType, idList);
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
  }

  public Expression getPriorityExpression() {
    return priorityExpression;
  }

  public void setPriorityExpression(Expression priorityExpression) {
    this.priorityExpression = priorityExpression;
  }

  public TaskFormHandler getTaskFormHandler() {
    return taskFormHandler;
  }

  public void setTaskFormHandler(TaskFormHandler taskFormHandler) {
    this.taskFormHandler = taskFormHandler;
  }
144
  
145
  public Expression getFormKeyExpression() {
146 147
		return formKeyExpression;
	}
148

149 150 151
	public void setFormKeyExpression(Expression formKeyExpression) {
		this.formKeyExpression = formKeyExpression;
	}
152

153
	public String getKey() {
154 155 156 157 158 159
    return key;
  }

  public void setKey(String key) {
    this.key = key;
  }
160
  
161 162 163
  public Expression getDueDateExpression() {
    return dueDateExpression;
  }
164
  
165 166 167
  public void setDueDateExpression(Expression dueDateExpression) {
    this.dueDateExpression = dueDateExpression;
  }
168
  
169
  public Expression getCategoryExpression() {
170 171
		return categoryExpression;
	}
172

173 174 175
	public void setCategoryExpression(Expression categoryExpression) {
		this.categoryExpression = categoryExpression;
	}
176

177
	public Map<String, List<TaskListener>> getTaskListeners() {
178 179 180 181 182 183
    return taskListeners;
  }

  public void setTaskListeners(Map<String, List<TaskListener>> taskListeners) {
    this.taskListeners = taskListeners;
  }
184
  
185 186 187
  public List<TaskListener> getTaskListener(String eventName) {
    return taskListeners.get(eventName);
  }
188
  
189
  public void addTaskListener(String eventName, TaskListener taskListener) {
190 191 192
    if(TaskListener.EVENTNAME_ALL_EVENTS.equals(eventName)) {
      // In order to prevent having to merge the "all" tasklisteners with the ones for a specific eventName,
      // every time "getTaskListener()" is called, we add the listener explicitally to the individual lists
193 194 195 196
      this.addTaskListener(TaskListener.EVENTNAME_CREATE, taskListener);
      this.addTaskListener(TaskListener.EVENTNAME_ASSIGNMENT, taskListener);
      this.addTaskListener(TaskListener.EVENTNAME_COMPLETE, taskListener);
      this.addTaskListener(TaskListener.EVENTNAME_DELETE, taskListener);
197
      
198 199 200 201 202 203 204 205 206
    } else {
      List<TaskListener> taskEventListeners = taskListeners.get(eventName);
      if (taskEventListeners == null) {
        taskEventListeners = new ArrayList<TaskListener>();
        taskListeners.put(eventName, taskEventListeners);
      }
      taskEventListeners.add(taskListener);
    }
  }
207
  
208 209 210 211
  public Expression getSkipExpression() {
    return skipExpression;
  }

212
  
213 214 215
  public void setSkipExpression(Expression skipExpression) {
    this.skipExpression = skipExpression;
  }
216
}