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

The following examples show how to use org.activiti.engine.form.TaskFormData#getTask() . 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: 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 2
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 3
Source File: RestResponseFactory.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public FormDataResponse createFormDataResponse(FormData formData) {
  FormDataResponse result = new FormDataResponse();
  result.setDeploymentId(formData.getDeploymentId());
  result.setFormKey(formData.getFormKey());
  if (formData.getFormProperties() != null) {
    for (FormProperty formProp : formData.getFormProperties()) {
      RestFormProperty restFormProp = new RestFormProperty();
      restFormProp.setId(formProp.getId());
      restFormProp.setName(formProp.getName());
      if (formProp.getType() != null) {
        restFormProp.setType(formProp.getType().getName());
      }
      restFormProp.setValue(formProp.getValue());
      restFormProp.setReadable(formProp.isReadable());
      restFormProp.setRequired(formProp.isRequired());
      restFormProp.setWritable(formProp.isWritable());
      if ("enum".equals(restFormProp.getType())) {
        Object values = formProp.getType().getInformation("values");
        if (values != null) {
          @SuppressWarnings("unchecked")
          Map<String, String> enumValues = (Map<String, String>) values;
          for (String enumId : enumValues.keySet()) {
            RestEnumFormProperty enumProperty = new RestEnumFormProperty();
            enumProperty.setId(enumId);
            enumProperty.setName(enumValues.get(enumId));
            restFormProp.addEnumValue(enumProperty);
          }
        }
      } else if ("date".equals(restFormProp.getType())) {
        restFormProp.setDatePattern((String) formProp.getType().getInformation("datePattern"));
      }
      result.addFormProperty(restFormProp);
    }
  }
  RestUrlBuilder urlBuilder = createUrlBuilder();
  if (formData instanceof StartFormData) {
    StartFormData startFormData = (StartFormData) formData;
    if (startFormData.getProcessDefinition() != null) {
      result.setProcessDefinitionId(startFormData.getProcessDefinition().getId());
      result.setProcessDefinitionUrl(urlBuilder.buildUrl(RestUrls.URL_PROCESS_DEFINITION, startFormData.getProcessDefinition().getId()));
    }
  } else if (formData instanceof TaskFormData) {
    TaskFormData taskFormData = (TaskFormData) formData;
    if (taskFormData.getTask() != null) {
      result.setTaskId(taskFormData.getTask().getId());
      result.setTaskUrl(urlBuilder.buildUrl(RestUrls.URL_TASK, taskFormData.getTask().getId()));
    }
  }
  return result;
}
 
Example 4
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 5
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 6
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 7
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 8
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 9
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;
}