Java Code Examples for org.activiti.engine.form.TaskFormData#getFormKey()

The following examples show how to use org.activiti.engine.form.TaskFormData#getFormKey() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActivitiTypeConverter.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public WorkflowTaskDefinition getTaskDefinition(Task task)
{
	// Get the task-form used (retrieved from cached process-definition)
	TaskFormData taskFormData = formService.getTaskFormData(task.getId());
    String taskDefId = null;
    if(taskFormData != null) 
    {
        taskDefId = taskFormData.getFormKey();
    }
    
    // Fetch node based on cached process-definition
    ReadOnlyProcessDefinition procDef = activitiUtil.getDeployedProcessDefinition(task.getProcessDefinitionId());
    WorkflowNode node = convert(procDef.findActivity(task.getTaskDefinitionKey()), true);
    
    return factory.createTaskDefinition(taskDefId, node, taskDefId, false);
}
 
Example 2
Source File: TaskController.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
/**
 * 读取用户任务的表单字段
 */
@RequestMapping(value = "task/getform/{taskId}")
public ModelAndView readTaskForm(@PathVariable("taskId") String taskId) throws Exception {
    String viewName = "chapter6/task-form";
    ModelAndView mav = new ModelAndView(viewName);
    TaskFormData taskFormData = formService.getTaskFormData(taskId);
    if (taskFormData.getFormKey() != null) {
        Object renderedTaskForm = formService.getRenderedTaskForm(taskId);
        Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
        mav.addObject("task", task);
        mav.addObject("taskFormData", renderedTaskForm);
        mav.addObject("hasFormKey", true);
    } else {
        mav.addObject("taskFormData", taskFormData);
    }
    return mav;
}
 
Example 3
Source File: TaskController.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
/**
 * 读取用户任务的表单字段
 */
@RequestMapping(value = "task/getform/{taskId}")
public ModelAndView readTaskForm(@PathVariable("taskId") String taskId) throws Exception {
    String viewName = "chapter6/task-form";
    ModelAndView mav = new ModelAndView(viewName);
    TaskFormData taskFormData = formService.getTaskFormData(taskId);
    if (taskFormData.getFormKey() != null) {
        Object renderedTaskForm = formService.getRenderedTaskForm(taskId);
        Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
        mav.addObject("task", task);
        mav.addObject("taskFormData", renderedTaskForm);
        mav.addObject("hasFormKey", true);
    } else {
        mav.addObject("taskFormData", taskFormData);
    }
    return mav;
}
 
Example 4
Source File: TaskController.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
/**
 * 读取用户任务的表单字段
 */
@RequestMapping(value = "task/getform/{taskId}")
public ModelAndView readTaskForm(@PathVariable("taskId") String taskId) throws Exception {
    String viewName = "chapter6/task-form";
    ModelAndView mav = new ModelAndView(viewName);
    TaskFormData taskFormData = formService.getTaskFormData(taskId);
    if (taskFormData.getFormKey() != null) {
        Object renderedTaskForm = formService.getRenderedTaskForm(taskId);
        Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
        mav.addObject("task", task);
        mav.addObject("taskFormData", renderedTaskForm);
        mav.addObject("hasFormKey", true);
    } else {
        mav.addObject("taskFormData", taskFormData);
    }
    return mav;
}
 
Example 5
Source File: TaskController.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
/**
 * 读取用户任务的表单字段
 */
@RequestMapping(value = "task/getform/{taskId}")
public ModelAndView readTaskForm(@PathVariable("taskId") String taskId) throws Exception {
    String viewName = "chapter6/task-form";
    ModelAndView mav = new ModelAndView(viewName);
    TaskFormData taskFormData = formService.getTaskFormData(taskId);
    if (taskFormData.getFormKey() != null) {
        Object renderedTaskForm = formService.getRenderedTaskForm(taskId);
        Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
        mav.addObject("task", task);
        mav.addObject("taskFormData", renderedTaskForm);
        mav.addObject("hasFormKey", true);
    } else {
        mav.addObject("taskFormData", taskFormData);
    }
    return mav;
}
 
Example 6
Source File: TaskController.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
/**
 * 读取用户任务的表单字段
 */
@RequestMapping(value = "task/getform/{taskId}")
public ModelAndView readTaskForm(@PathVariable("taskId") String taskId) throws Exception {
    String viewName = "chapter6/task-form";
    ModelAndView mav = new ModelAndView(viewName);
    TaskFormData taskFormData = formService.getTaskFormData(taskId);
    if (taskFormData.getFormKey() != null) {
        Object renderedTaskForm = formService.getRenderedTaskForm(taskId);
        Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
        mav.addObject("task", task);
        mav.addObject("taskFormData", renderedTaskForm);
        mav.addObject("hasFormKey", true);
    } else {
        mav.addObject("taskFormData", taskFormData);
    }
    return mav;
}
 
Example 7
Source File: JuelFormEngine.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public Object renderTaskForm(TaskFormData taskForm) {
  if (taskForm.getFormKey() == null) {
    return null;
  }
  String formTemplateString = getFormTemplateString(taskForm, taskForm.getFormKey());
  ScriptingEngines scriptingEngines = Context.getProcessEngineConfiguration().getScriptingEngines();
  TaskEntity task = (TaskEntity) taskForm.getTask();
  return scriptingEngines.evaluate(formTemplateString, ScriptingEngines.DEFAULT_SCRIPTING_LANGUAGE, task.getExecution());
}
 
Example 8
Source File: ActivitiTypeConverter.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Converts the given task into a {@link WorkflowTask}, allows ignoring domain mismatch (ALF-12264)
 * @param task Task
 * @param ignoreDomainMismatch whether or not to ignore domain mismatch exception
 * @return the converter task. Returns null when the domain mismatched and ignoreDomainMismatch was true.
 */
public WorkflowTask convert(Task task, boolean ignoreDomainMismatch)
{
    if(task == null)
        return null;
    String id = task.getId();
    String defaultTitle = task.getName();
    String defaultDescription = task.getDescription();
    
    WorkflowTaskState state = WorkflowTaskState.IN_PROGRESS;
    WorkflowPath path = getWorkflowPath(task.getExecutionId(), ignoreDomainMismatch);
    
    if(path != null) 
    {
    	// Since the task is active, it's safe to use the active node on
        // the execution path
        WorkflowNode node = path.getNode();
        
        TaskFormData taskFormData =formService.getTaskFormData(task.getId());
        String taskDefId = null;
        if(taskFormData != null) 
        {
            taskDefId = taskFormData.getFormKey();
        }
        WorkflowTaskDefinition taskDef = factory.createTaskDefinition(taskDefId, node, taskDefId, false);
        
        // All task-properties should be fetched, not only local
        Map<QName, Serializable> properties = propertyConverter.getTaskProperties(task);
        
        return factory.createTask(id,
                    taskDef, taskDef.getId(), defaultTitle, defaultDescription, state, path, properties);
    }
    else
    {
    	// Ignoring this task, domain mismatched and safely ignoring that
    	return null;
    }
}
 
Example 9
Source File: JuelFormEngine.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public Object renderTaskForm(TaskFormData taskForm) {
    if (taskForm.getFormKey() == null) {
        return null;
    }
    String formTemplateString = getFormTemplateString(taskForm, taskForm.getFormKey());
    ScriptingEngines scriptingEngines = Context.getProcessEngineConfiguration().getScriptingEngines();
    TaskEntity task = (TaskEntity) taskForm.getTask();
    return scriptingEngines.evaluate(formTemplateString, ScriptingEngines.DEFAULT_SCRIPTING_LANGUAGE, task.getExecution());
}
 
Example 10
Source File: TaskController.java    From activiti-in-action-codes with Apache License 2.0 4 votes vote down vote up
/**
 * 读取用户任务的表单字段
 */
@RequestMapping(value = "task/getform/{taskId}")
public ModelAndView readTaskForm(@PathVariable("taskId") String taskId) throws Exception {
    String viewName = "chapter6/task-form";
    ModelAndView mav = new ModelAndView(viewName);
    TaskFormData taskFormData = formService.getTaskFormData(taskId);
    Task task = null;

    // 外置表单
    if (taskFormData != null && taskFormData.getFormKey() != null) {
        Object renderedTaskForm = formService.getRenderedTaskForm(taskId);
        task = taskService.createTaskQuery().taskId(taskId).singleResult();
        mav.addObject("taskFormData", renderedTaskForm);
        mav.addObject("hasFormKey", true);
    } else if (taskFormData != null) { // 动态表单
        mav.addObject("taskFormData", taskFormData);
        task = taskFormData.getTask();
    } else { // 手动创建的任务(包括子任务)
        task = taskService.createTaskQuery().taskId(taskId).singleResult();
        mav.addObject("manualTask", true);
    }
    mav.addObject("task", task);

    // 读取任务参与人列表
    List<IdentityLink> identityLinksForTask = taskService.getIdentityLinksForTask(taskId);
    mav.addObject("identityLinksForTask", identityLinksForTask);

    // 读取所有人员
    List<User> users = identityService.createUserQuery().list();
    mav.addObject("users", users);

    // 读取所有组
    List<Group> groups = identityService.createGroupQuery().list();
    mav.addObject("groups", groups);

    // 读取子任务
    List<HistoricTaskInstance> subTasks = historyService.createHistoricTaskInstanceQuery().taskParentTaskId(taskId).list();
    mav.addObject("subTasks", subTasks);

    // 读取上级任务
    if (task != null && task.getParentTaskId() != null) {
        HistoricTaskInstance parentTask = historyService.createHistoricTaskInstanceQuery().taskId(task.getParentTaskId()).singleResult();
        mav.addObject("parentTask", parentTask);
    }

    // 读取附件
    List<Attachment> attachments = null;
    if (task.getTaskDefinitionKey() != null) {
        attachments = taskService.getTaskAttachments(taskId);
    } else {
        attachments = taskService.getProcessInstanceAttachments(task.getProcessInstanceId());
    }
    mav.addObject("attachments", attachments);

    return mav;
}
 
Example 11
Source File: TaskController.java    From activiti-in-action-codes with Apache License 2.0 4 votes vote down vote up
/**
 * 读取用户任务的表单字段
 */
@RequestMapping(value = "task/getform/{taskId}")
public ModelAndView readTaskForm(@PathVariable("taskId") String taskId) throws Exception {
    String viewName = "chapter6/task-form";
    ModelAndView mav = new ModelAndView(viewName);
    TaskFormData taskFormData = formService.getTaskFormData(taskId);
    Task task = null;

    // 外置表单
    if (taskFormData != null && taskFormData.getFormKey() != null) {
        Object renderedTaskForm = formService.getRenderedTaskForm(taskId);
        task = taskService.createTaskQuery().taskId(taskId).singleResult();
        mav.addObject("taskFormData", renderedTaskForm);
        mav.addObject("hasFormKey", true);
    } else if (taskFormData != null) { // 动态表单
        mav.addObject("taskFormData", taskFormData);
        task = taskFormData.getTask();
    } else { // 手动创建的任务(包括子任务)
        task = taskService.createTaskQuery().taskId(taskId).singleResult();
        mav.addObject("manualTask", true);
    }
    mav.addObject("task", task);

    // 读取任务参与人列表
    List<IdentityLink> identityLinksForTask = taskService.getIdentityLinksForTask(taskId);
    mav.addObject("identityLinksForTask", identityLinksForTask);

    // 读取所有人员
    List<User> users = identityService.createUserQuery().list();
    mav.addObject("users", users);

    // 读取所有组
    List<Group> groups = identityService.createGroupQuery().list();
    mav.addObject("groups", groups);

    // 读取子任务
    List<HistoricTaskInstance> subTasks = historyService.createHistoricTaskInstanceQuery().taskParentTaskId(taskId).list();
    mav.addObject("subTasks", subTasks);

    // 读取上级任务
    if (task != null && task.getParentTaskId() != null) {
        HistoricTaskInstance parentTask = historyService.createHistoricTaskInstanceQuery().taskId(task.getParentTaskId()).singleResult();
        mav.addObject("parentTask", parentTask);
    }

    // 读取附件
    List<Attachment> attachments = null;
    if (task.getTaskDefinitionKey() != null) {
        attachments = taskService.getTaskAttachments(taskId);
    } else {
        attachments = taskService.getProcessInstanceAttachments(task.getProcessInstanceId());
    }
    mav.addObject("attachments", attachments);

    return mav;
}
 
Example 12
Source File: TaskController.java    From activiti-in-action-codes with Apache License 2.0 4 votes vote down vote up
/**
 * 读取用户任务的表单字段
 */
@RequestMapping(value = "task/getform/{taskId}")
public ModelAndView readTaskForm(@PathVariable("taskId") String taskId) throws Exception {
    String viewName = "chapter6/task-form";
    ModelAndView mav = new ModelAndView(viewName);
    TaskFormData taskFormData = formService.getTaskFormData(taskId);
    Task task = null;

    // 外置表单
    if (taskFormData != null && taskFormData.getFormKey() != null) {
        Object renderedTaskForm = formService.getRenderedTaskForm(taskId);
        task = taskService.createTaskQuery().taskId(taskId).singleResult();
        mav.addObject("taskFormData", renderedTaskForm);
        mav.addObject("hasFormKey", true);
    } else if (taskFormData != null) { // 动态表单
        mav.addObject("taskFormData", taskFormData);
        task = taskFormData.getTask();
    } else { // 手动创建的任务(包括子任务)
        task = taskService.createTaskQuery().taskId(taskId).singleResult();
        mav.addObject("manualTask", true);
    }
    mav.addObject("task", task);

    // 读取任务参与人列表
    List<IdentityLink> identityLinksForTask = taskService.getIdentityLinksForTask(taskId);
    mav.addObject("identityLinksForTask", identityLinksForTask);

    // 读取所有人员
    List<User> users = identityService.createUserQuery().list();
    mav.addObject("users", users);

    // 读取所有组
    List<Group> groups = identityService.createGroupQuery().list();
    mav.addObject("groups", groups);

    // 读取子任务
    List<HistoricTaskInstance> subTasks = historyService.createHistoricTaskInstanceQuery().taskParentTaskId(taskId).list();
    mav.addObject("subTasks", subTasks);

    // 读取上级任务
    if (task != null && task.getParentTaskId() != null) {
        HistoricTaskInstance parentTask = historyService.createHistoricTaskInstanceQuery().taskId(task.getParentTaskId()).singleResult();
        mav.addObject("parentTask", parentTask);
    }

    // 读取附件
    List<Attachment> attachments = null;
    if (task.getTaskDefinitionKey() != null) {
        attachments = taskService.getTaskAttachments(taskId);
    } else {
        attachments = taskService.getProcessInstanceAttachments(task.getProcessInstanceId());
    }
    mav.addObject("attachments", attachments);

    return mav;
}
 
Example 13
Source File: TaskController.java    From activiti-in-action-codes with Apache License 2.0 4 votes vote down vote up
/**
 * 读取用户任务的表单字段
 */
@RequestMapping(value = "task/getform/{taskId}")
public ModelAndView readTaskForm(@PathVariable("taskId") String taskId) throws Exception {
    String viewName = "chapter6/task-form";
    ModelAndView mav = new ModelAndView(viewName);
    TaskFormData taskFormData = formService.getTaskFormData(taskId);
    Task task = null;

    // 外置表单
    if (taskFormData != null && taskFormData.getFormKey() != null) {
        Object renderedTaskForm = formService.getRenderedTaskForm(taskId);
        task = taskService.createTaskQuery().taskId(taskId).singleResult();
        mav.addObject("taskFormData", renderedTaskForm);
        mav.addObject("hasFormKey", true);
    } else if (taskFormData != null) { // 动态表单
        mav.addObject("taskFormData", taskFormData);
        task = taskFormData.getTask();
    } else { // 手动创建的任务(包括子任务)
        task = taskService.createTaskQuery().taskId(taskId).singleResult();
        mav.addObject("manualTask", true);
    }
    mav.addObject("task", task);

    // 读取任务参与人列表
    List<IdentityLink> identityLinksForTask = taskService.getIdentityLinksForTask(taskId);
    mav.addObject("identityLinksForTask", identityLinksForTask);

    // 读取所有人员
    List<User> users = identityService.createUserQuery().list();
    mav.addObject("users", users);

    // 读取所有组
    List<Group> groups = identityService.createGroupQuery().list();
    mav.addObject("groups", groups);

    // 读取子任务
    List<HistoricTaskInstance> subTasks = historyService.createHistoricTaskInstanceQuery().taskParentTaskId(taskId).list();
    mav.addObject("subTasks", subTasks);

    // 读取上级任务
    if (task != null && task.getParentTaskId() != null) {
        HistoricTaskInstance parentTask = historyService.createHistoricTaskInstanceQuery().taskId(task.getParentTaskId()).singleResult();
        mav.addObject("parentTask", parentTask);
    }

    // 读取附件
    List<Attachment> attachments = null;
    if (task.getTaskDefinitionKey() != null) {
        attachments = taskService.getTaskAttachments(taskId);
    } else {
        attachments = taskService.getProcessInstanceAttachments(task.getProcessInstanceId());
    }
    mav.addObject("attachments", attachments);

    return mav;
}
 
Example 14
Source File: TaskController.java    From activiti-in-action-codes with Apache License 2.0 4 votes vote down vote up
/**
 * 读取用户任务的表单字段
 */
@RequestMapping(value = "task/getform/{taskId}")
public ModelAndView readTaskForm(@PathVariable("taskId") String taskId) throws Exception {
    String viewName = "chapter6/task-form";
    ModelAndView mav = new ModelAndView(viewName);
    TaskFormData taskFormData = formService.getTaskFormData(taskId);
    Task task = null;

    // 外置表单
    if (taskFormData != null && taskFormData.getFormKey() != null) {
        Object renderedTaskForm = formService.getRenderedTaskForm(taskId);
        task = taskService.createTaskQuery().taskId(taskId).singleResult();
        mav.addObject("taskFormData", renderedTaskForm);
        mav.addObject("hasFormKey", true);
    } else if (taskFormData != null) { // 动态表单
        mav.addObject("taskFormData", taskFormData);
        task = taskFormData.getTask();
    } else { // 手动创建的任务(包括子任务)
        task = taskService.createTaskQuery().taskId(taskId).singleResult();
        mav.addObject("manualTask", true);
    }
    mav.addObject("task", task);

    // 读取任务参与人列表
    List<IdentityLink> identityLinksForTask = taskService.getIdentityLinksForTask(taskId);
    mav.addObject("identityLinksForTask", identityLinksForTask);

    // 读取所有人员
    List<User> users = identityService.createUserQuery().list();
    mav.addObject("users", users);

    // 读取所有组
    List<Group> groups = identityService.createGroupQuery().list();
    mav.addObject("groups", groups);

    // 读取子任务
    List<HistoricTaskInstance> subTasks = historyService.createHistoricTaskInstanceQuery().taskParentTaskId(taskId).list();
    mav.addObject("subTasks", subTasks);

    // 读取上级任务
    if (task != null && task.getParentTaskId() != null) {
        HistoricTaskInstance parentTask = historyService.createHistoricTaskInstanceQuery().taskId(task.getParentTaskId()).singleResult();
        mav.addObject("parentTask", parentTask);
    }

    // 读取附件
    List<Attachment> attachments = null;
    if (task.getTaskDefinitionKey() != null) {
        attachments = taskService.getTaskAttachments(taskId);
    } else {
        attachments = taskService.getProcessInstanceAttachments(task.getProcessInstanceId());
    }
    mav.addObject("attachments", attachments);

    return mav;
}
 
Example 15
Source File: TaskController.java    From activiti-in-action-codes with Apache License 2.0 4 votes vote down vote up
/**
 * 读取用户任务的表单字段
 */
@RequestMapping(value = "task/getform/{taskId}")
public ModelAndView readTaskForm(@PathVariable("taskId") String taskId) throws Exception {
    String viewName = "chapter6/task-form";
    ModelAndView mav = new ModelAndView(viewName);
    TaskFormData taskFormData = formService.getTaskFormData(taskId);
    Task task = null;

    // 外置表单
    if (taskFormData != null && taskFormData.getFormKey() != null) {
        Object renderedTaskForm = formService.getRenderedTaskForm(taskId);
        task = taskService.createTaskQuery().taskId(taskId).singleResult();
        mav.addObject("taskFormData", renderedTaskForm);
        mav.addObject("hasFormKey", true);
    } else if (taskFormData != null) { // 动态表单
        mav.addObject("taskFormData", taskFormData);
        task = taskFormData.getTask();
    } else { // 手动创建的任务(包括子任务)
        task = taskService.createTaskQuery().taskId(taskId).singleResult();
        mav.addObject("manualTask", true);
    }
    mav.addObject("task", task);

    // 读取任务参与人列表
    List<IdentityLink> identityLinksForTask = taskService.getIdentityLinksForTask(taskId);
    mav.addObject("identityLinksForTask", identityLinksForTask);

    // 读取所有人员
    List<User> users = identityService.createUserQuery().list();
    mav.addObject("users", users);

    // 读取所有组
    List<Group> groups = identityService.createGroupQuery().list();
    mav.addObject("groups", groups);

    // 读取子任务
    List<HistoricTaskInstance> subTasks = historyService.createHistoricTaskInstanceQuery().taskParentTaskId(taskId).list();
    mav.addObject("subTasks", subTasks);

    // 读取上级任务
    if (task != null && task.getParentTaskId() != null) {
        HistoricTaskInstance parentTask = historyService.createHistoricTaskInstanceQuery().taskId(task.getParentTaskId()).singleResult();
        mav.addObject("parentTask", parentTask);
    }

    // 读取附件
    List<Attachment> attachments = null;
    if (task.getTaskDefinitionKey() != null) {
        attachments = taskService.getTaskAttachments(taskId);
    } else {
        attachments = taskService.getProcessInstanceAttachments(task.getProcessInstanceId());
    }
    mav.addObject("attachments", attachments);

    return mav;
}