Search in sources :

Example 1 with TaskFormHandler

use of org.activiti.engine.impl.form.TaskFormHandler in project Activiti by Activiti.

the class UserTaskParseHandler method parseTaskDefinition.

public TaskDefinition parseTaskDefinition(BpmnParse bpmnParse, UserTask userTask, String taskDefinitionKey, ProcessDefinitionEntity processDefinition) {
    TaskFormHandler taskFormHandler = new DefaultTaskFormHandler();
    taskFormHandler.parseConfiguration(userTask.getFormProperties(), userTask.getFormKey(), bpmnParse.getDeployment(), processDefinition);
    TaskDefinition taskDefinition = new TaskDefinition(taskFormHandler);
    taskDefinition.setKey(taskDefinitionKey);
    processDefinition.getTaskDefinitions().put(taskDefinitionKey, taskDefinition);
    ExpressionManager expressionManager = bpmnParse.getExpressionManager();
    if (StringUtils.isNotEmpty(userTask.getName())) {
        taskDefinition.setNameExpression(expressionManager.createExpression(userTask.getName()));
    }
    if (StringUtils.isNotEmpty(userTask.getDocumentation())) {
        taskDefinition.setDescriptionExpression(expressionManager.createExpression(userTask.getDocumentation()));
    }
    if (StringUtils.isNotEmpty(userTask.getAssignee())) {
        taskDefinition.setAssigneeExpression(expressionManager.createExpression(userTask.getAssignee()));
    }
    if (StringUtils.isNotEmpty(userTask.getOwner())) {
        taskDefinition.setOwnerExpression(expressionManager.createExpression(userTask.getOwner()));
    }
    for (String candidateUser : userTask.getCandidateUsers()) {
        taskDefinition.addCandidateUserIdExpression(expressionManager.createExpression(candidateUser));
    }
    for (String candidateGroup : userTask.getCandidateGroups()) {
        taskDefinition.addCandidateGroupIdExpression(expressionManager.createExpression(candidateGroup));
    }
    // Task listeners
    for (ActivitiListener taskListener : userTask.getTaskListeners()) {
        taskDefinition.addTaskListener(taskListener.getEvent(), createTaskListener(bpmnParse, taskListener, userTask.getId()));
    }
    // Due date
    if (StringUtils.isNotEmpty(userTask.getDueDate())) {
        taskDefinition.setDueDateExpression(expressionManager.createExpression(userTask.getDueDate()));
    }
    // Business calendar name
    if (StringUtils.isNotEmpty(userTask.getBusinessCalendarName())) {
        taskDefinition.setBusinessCalendarNameExpression(expressionManager.createExpression(userTask.getBusinessCalendarName()));
    } else {
        taskDefinition.setBusinessCalendarNameExpression(expressionManager.createExpression(DueDateBusinessCalendar.NAME));
    }
    // Category
    if (StringUtils.isNotEmpty(userTask.getCategory())) {
        taskDefinition.setCategoryExpression(expressionManager.createExpression(userTask.getCategory()));
    }
    // Priority
    if (StringUtils.isNotEmpty(userTask.getPriority())) {
        taskDefinition.setPriorityExpression(expressionManager.createExpression(userTask.getPriority()));
    }
    if (StringUtils.isNotEmpty(userTask.getFormKey())) {
        taskDefinition.setFormKeyExpression(expressionManager.createExpression(userTask.getFormKey()));
    }
    // CustomUserIdentityLinks
    for (String customUserIdentityLinkType : userTask.getCustomUserIdentityLinks().keySet()) {
        Set<Expression> userIdentityLinkExpression = new HashSet<Expression>();
        for (String userIdentityLink : userTask.getCustomUserIdentityLinks().get(customUserIdentityLinkType)) {
            userIdentityLinkExpression.add(expressionManager.createExpression(userIdentityLink));
        }
        taskDefinition.addCustomUserIdentityLinkExpression(customUserIdentityLinkType, userIdentityLinkExpression);
    }
    // CustomGroupIdentityLinks
    for (String customGroupIdentityLinkType : userTask.getCustomGroupIdentityLinks().keySet()) {
        Set<Expression> groupIdentityLinkExpression = new HashSet<Expression>();
        for (String groupIdentityLink : userTask.getCustomGroupIdentityLinks().get(customGroupIdentityLinkType)) {
            groupIdentityLinkExpression.add(expressionManager.createExpression(groupIdentityLink));
        }
        taskDefinition.addCustomGroupIdentityLinkExpression(customGroupIdentityLinkType, groupIdentityLinkExpression);
    }
    if (StringUtils.isNotEmpty(userTask.getSkipExpression())) {
        taskDefinition.setSkipExpression(expressionManager.createExpression(userTask.getSkipExpression()));
    }
    return taskDefinition;
}
Also used : ExpressionManager(org.activiti.engine.impl.el.ExpressionManager) TaskDefinition(org.activiti.engine.impl.task.TaskDefinition) TaskFormHandler(org.activiti.engine.impl.form.TaskFormHandler) DefaultTaskFormHandler(org.activiti.engine.impl.form.DefaultTaskFormHandler) Expression(org.activiti.engine.delegate.Expression) DefaultTaskFormHandler(org.activiti.engine.impl.form.DefaultTaskFormHandler) ActivitiListener(org.activiti.bpmn.model.ActivitiListener) HashSet(java.util.HashSet)

Example 2 with TaskFormHandler

use of org.activiti.engine.impl.form.TaskFormHandler in project Activiti by Activiti.

the class SubmitTaskFormCmd method execute.

protected Object execute(CommandContext commandContext, TaskEntity task) {
    commandContext.getHistoryManager().reportFormPropertiesSubmitted(task.getExecution(), properties, taskId);
    TaskFormHandler taskFormHandler = task.getTaskDefinition().getTaskFormHandler();
    taskFormHandler.submitFormProperties(properties, task.getExecution());
    if (completeTask) {
        task.complete(properties, false);
    }
    return null;
}
Also used : TaskFormHandler(org.activiti.engine.impl.form.TaskFormHandler)

Example 3 with TaskFormHandler

use of org.activiti.engine.impl.form.TaskFormHandler in project Activiti by Activiti.

the class GetRenderedTaskFormCmd method execute.

public Object execute(CommandContext commandContext) {
    TaskEntity task = commandContext.getTaskEntityManager().findTaskById(taskId);
    if (task == null) {
        throw new ActivitiObjectNotFoundException("Task '" + taskId + "' not found", Task.class);
    }
    if (task.getTaskDefinition() == null) {
        throw new ActivitiException("Task form definition for '" + taskId + "' not found");
    }
    TaskFormHandler taskFormHandler = task.getTaskDefinition().getTaskFormHandler();
    if (taskFormHandler == null) {
        return null;
    }
    FormEngine formEngine = commandContext.getProcessEngineConfiguration().getFormEngines().get(formEngineName);
    if (formEngine == null) {
        throw new ActivitiException("No formEngine '" + formEngineName + "' defined process engine configuration");
    }
    TaskFormData taskForm = taskFormHandler.createTaskForm(task);
    return formEngine.renderTaskForm(taskForm);
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) TaskEntity(org.activiti.engine.impl.persistence.entity.TaskEntity) TaskFormHandler(org.activiti.engine.impl.form.TaskFormHandler) TaskFormData(org.activiti.engine.form.TaskFormData) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) FormEngine(org.activiti.engine.impl.form.FormEngine)

Aggregations

TaskFormHandler (org.activiti.engine.impl.form.TaskFormHandler)3 HashSet (java.util.HashSet)1 ActivitiListener (org.activiti.bpmn.model.ActivitiListener)1 ActivitiException (org.activiti.engine.ActivitiException)1 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)1 Expression (org.activiti.engine.delegate.Expression)1 TaskFormData (org.activiti.engine.form.TaskFormData)1 ExpressionManager (org.activiti.engine.impl.el.ExpressionManager)1 DefaultTaskFormHandler (org.activiti.engine.impl.form.DefaultTaskFormHandler)1 FormEngine (org.activiti.engine.impl.form.FormEngine)1 TaskEntity (org.activiti.engine.impl.persistence.entity.TaskEntity)1 TaskDefinition (org.activiti.engine.impl.task.TaskDefinition)1