SubmitTaskFormCmd.java 2.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/* 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.activiti.engine.impl.cmd;

T
tombaeyens 已提交
16 17
import java.util.Map;

18
import org.activiti.engine.compatibility.Activiti5CompatibilityHandler;
19 20
import org.activiti.engine.impl.form.TaskFormHandler;
import org.activiti.engine.impl.interceptor.CommandContext;
T
tombaeyens 已提交
21
import org.activiti.engine.impl.persistence.entity.TaskEntity;
22
import org.activiti.engine.impl.util.Activiti5Util;
23 24 25

/**
 * @author Tom Baeyens
J
jbarrez 已提交
26
 * @author Joram Barrez
27
 */
J
Joram Barrez 已提交
28
public class SubmitTaskFormCmd extends AbstractCompleteTaskCmd {
29

30
  private static final long serialVersionUID = 1L;
T
Tijs Rademakers 已提交
31

32 33 34
  protected String taskId;
  protected Map<String, String> properties;
  protected boolean completeTask;
T
Tijs Rademakers 已提交
35

36 37 38 39 40 41
  public SubmitTaskFormCmd(String taskId, Map<String, String> properties, boolean completeTask) {
    super(taskId);
    this.taskId = taskId;
    this.properties = properties;
    this.completeTask = completeTask;
  }
T
Tijs Rademakers 已提交
42

43
  protected Void execute(CommandContext commandContext, TaskEntity task) {
44 45 46 47
    
    // Backwards compatibility
    if (task.getProcessDefinitionId() != null) {
      if (Activiti5Util.isActiviti5ProcessDefinitionId(commandContext, task.getProcessDefinitionId())) {
48
        Activiti5CompatibilityHandler activiti5CompatibilityHandler = Activiti5Util.getActiviti5CompatibilityHandler(); 
49
        activiti5CompatibilityHandler.submitTaskFormData(taskId, properties, completeTask);
50 51 52 53
        return null;
      }
    }
    
54
    commandContext.getHistoryManager().recordFormPropertiesSubmitted(task.getExecution(), properties, taskId);
T
Tijs Rademakers 已提交
55

56 57
    TaskFormHandler taskFormHandler = task.getTaskDefinition().getTaskFormHandler();
    taskFormHandler.submitFormProperties(properties, task.getExecution());
T
Tijs Rademakers 已提交
58

59
    if (completeTask) {
J
Joram Barrez 已提交
60
      executeTaskComplete(commandContext, task, null, false);
T
Tijs Rademakers 已提交
61 62
    }

63 64 65 66 67 68 69
    return null;
  }

  @Override
  protected String getSuspendedTaskException() {
    return "Cannot submit a form to a suspended task";
  }
70 71

}