Search in sources :

Example 1 with TaskDefinition

use of org.activiti.engine.impl.task.TaskDefinition in project Activiti by Activiti.

the class ProcessParseHandler method transformProcess.

protected ProcessDefinitionEntity transformProcess(BpmnParse bpmnParse, Process process) {
    ProcessDefinitionEntity currentProcessDefinition = new ProcessDefinitionEntity();
    bpmnParse.setCurrentProcessDefinition(currentProcessDefinition);
    /*
     * Mapping object model - bpmn xml: processDefinition.id -> generated by
     * activiti engine processDefinition.key -> bpmn id (required)
     * processDefinition.name -> bpmn name (optional)
     */
    currentProcessDefinition.setKey(process.getId());
    currentProcessDefinition.setName(process.getName());
    currentProcessDefinition.setCategory(bpmnParse.getBpmnModel().getTargetNamespace());
    currentProcessDefinition.setDescription(process.getDocumentation());
    // Kept for backwards compatibility. See ACT-1020
    currentProcessDefinition.setProperty(PROPERTYNAME_DOCUMENTATION, process.getDocumentation());
    currentProcessDefinition.setTaskDefinitions(new HashMap<String, TaskDefinition>());
    currentProcessDefinition.setDeploymentId(bpmnParse.getDeployment().getId());
    createExecutionListenersOnScope(bpmnParse, process.getExecutionListeners(), currentProcessDefinition);
    createEventListeners(bpmnParse, process.getEventListeners(), currentProcessDefinition);
    ExpressionManager expressionManager = bpmnParse.getExpressionManager();
    for (String candidateUser : process.getCandidateStarterUsers()) {
        currentProcessDefinition.addCandidateStarterUserIdExpression(expressionManager.createExpression(candidateUser));
    }
    for (String candidateGroup : process.getCandidateStarterGroups()) {
        currentProcessDefinition.addCandidateStarterGroupIdExpression(expressionManager.createExpression(candidateGroup));
    }
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Parsing process {}", currentProcessDefinition.getKey());
    }
    bpmnParse.setCurrentScope(currentProcessDefinition);
    bpmnParse.processFlowElements(process.getFlowElements());
    processArtifacts(bpmnParse, process.getArtifacts(), currentProcessDefinition);
    // parse out any data objects from the template in order to set up the necessary process variables
    Map<String, Object> variables = processDataObjects(bpmnParse, process.getDataObjects(), currentProcessDefinition);
    if (null != currentProcessDefinition.getVariables()) {
        currentProcessDefinition.getVariables().putAll(variables);
    } else {
        currentProcessDefinition.setVariables(variables);
    }
    bpmnParse.removeCurrentScope();
    if (process.getIoSpecification() != null) {
        IOSpecification ioSpecification = createIOSpecification(bpmnParse, process.getIoSpecification());
        currentProcessDefinition.setIoSpecification(ioSpecification);
    }
    return currentProcessDefinition;
}
Also used : ExpressionManager(org.activiti.engine.impl.el.ExpressionManager) TaskDefinition(org.activiti.engine.impl.task.TaskDefinition) IOSpecification(org.activiti.engine.impl.bpmn.data.IOSpecification) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)

Example 2 with TaskDefinition

use of org.activiti.engine.impl.task.TaskDefinition in project Activiti by Activiti.

the class UserTaskParseHandler method executeParse.

protected void executeParse(BpmnParse bpmnParse, UserTask userTask) {
    ActivityImpl activity = createActivityOnCurrentScope(bpmnParse, userTask, BpmnXMLConstants.ELEMENT_TASK_USER);
    activity.setAsync(userTask.isAsynchronous());
    activity.setExclusive(!userTask.isNotExclusive());
    TaskDefinition taskDefinition = parseTaskDefinition(bpmnParse, userTask, userTask.getId(), (ProcessDefinitionEntity) bpmnParse.getCurrentScope().getProcessDefinition());
    activity.setProperty(PROPERTY_TASK_DEFINITION, taskDefinition);
    activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createUserTaskActivityBehavior(userTask, taskDefinition));
}
Also used : TaskDefinition(org.activiti.engine.impl.task.TaskDefinition) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl)

Example 3 with TaskDefinition

use of org.activiti.engine.impl.task.TaskDefinition 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 4 with TaskDefinition

use of org.activiti.engine.impl.task.TaskDefinition in project Activiti by Activiti.

the class UserTaskHistoryParseHandler method executeParse.

protected void executeParse(BpmnParse bpmnParse, UserTask element) {
    TaskDefinition taskDefinition = (TaskDefinition) bpmnParse.getCurrentActivity().getProperty(UserTaskParseHandler.PROPERTY_TASK_DEFINITION);
    taskDefinition.addTaskListener(TaskListener.EVENTNAME_ASSIGNMENT, USER_TASK_ASSIGNMENT_HANDLER);
    taskDefinition.addTaskListener(TaskListener.EVENTNAME_CREATE, USER_TASK_ID_HANDLER);
}
Also used : TaskDefinition(org.activiti.engine.impl.task.TaskDefinition)

Example 5 with TaskDefinition

use of org.activiti.engine.impl.task.TaskDefinition in project Activiti by Activiti.

the class GetFormKeyCmd method execute.

public String execute(CommandContext commandContext) {
    ProcessDefinitionEntity processDefinition = commandContext.getProcessEngineConfiguration().getDeploymentManager().findDeployedProcessDefinitionById(processDefinitionId);
    DefaultFormHandler formHandler;
    if (taskDefinitionKey == null) {
        // TODO: Maybe add getFormKey() to FormHandler interface to avoid the following cast
        formHandler = (DefaultFormHandler) processDefinition.getStartFormHandler();
    } else {
        TaskDefinition taskDefinition = processDefinition.getTaskDefinitions().get(taskDefinitionKey);
        // TODO: Maybe add getFormKey() to FormHandler interface to avoid the following cast
        formHandler = (DefaultFormHandler) taskDefinition.getTaskFormHandler();
    }
    String formKey = null;
    if (formHandler.getFormKey() != null) {
        formKey = formHandler.getFormKey().getExpressionText();
    }
    return formKey;
}
Also used : DefaultFormHandler(org.activiti.engine.impl.form.DefaultFormHandler) TaskDefinition(org.activiti.engine.impl.task.TaskDefinition) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)

Aggregations

TaskDefinition (org.activiti.engine.impl.task.TaskDefinition)5 ExpressionManager (org.activiti.engine.impl.el.ExpressionManager)2 ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)2 HashSet (java.util.HashSet)1 ActivitiListener (org.activiti.bpmn.model.ActivitiListener)1 Expression (org.activiti.engine.delegate.Expression)1 IOSpecification (org.activiti.engine.impl.bpmn.data.IOSpecification)1 DefaultFormHandler (org.activiti.engine.impl.form.DefaultFormHandler)1 DefaultTaskFormHandler (org.activiti.engine.impl.form.DefaultTaskFormHandler)1 TaskFormHandler (org.activiti.engine.impl.form.TaskFormHandler)1 ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)1