Search in sources :

Example 6 with HumanTask

use of org.camunda.bpm.model.cmmn.instance.HumanTask in project camunda-bpm-platform by camunda.

the class HumanTaskItemHandler method initializeTaskDefinitionAssignee.

protected void initializeTaskDefinitionAssignee(CmmnElement element, TaskDefinition taskDefinition, CmmnHandlerContext context) {
    HumanTask definition = getDefinition(element);
    Role performer = definition.getPerformer();
    String assignee = null;
    if (performer != null) {
        assignee = performer.getName();
    } else {
        assignee = definition.getCamundaAssignee();
    }
    if (assignee != null) {
        ExpressionManager expressionManager = context.getExpressionManager();
        Expression assigneeExpression = expressionManager.createExpression(assignee);
        taskDefinition.setAssigneeExpression(assigneeExpression);
    }
}
Also used : Role(org.camunda.bpm.model.cmmn.instance.Role) ExpressionManager(org.camunda.bpm.engine.impl.el.ExpressionManager) Expression(org.camunda.bpm.engine.delegate.Expression) HumanTask(org.camunda.bpm.model.cmmn.instance.HumanTask)

Example 7 with HumanTask

use of org.camunda.bpm.model.cmmn.instance.HumanTask in project camunda-bpm-platform by camunda.

the class HumanTaskItemHandler method initializeTaskDefinitionFollowUpDate.

protected void initializeTaskDefinitionFollowUpDate(CmmnElement element, TaskDefinition taskDefinition, CmmnHandlerContext context) {
    HumanTask definition = getDefinition(element);
    String followUpDate = definition.getCamundaFollowUpDate();
    if (followUpDate != null) {
        ExpressionManager expressionManager = context.getExpressionManager();
        Expression followUpDateExpression = expressionManager.createExpression(followUpDate);
        taskDefinition.setFollowUpDateExpression(followUpDateExpression);
    }
}
Also used : ExpressionManager(org.camunda.bpm.engine.impl.el.ExpressionManager) Expression(org.camunda.bpm.engine.delegate.Expression) HumanTask(org.camunda.bpm.model.cmmn.instance.HumanTask)

Example 8 with HumanTask

use of org.camunda.bpm.model.cmmn.instance.HumanTask in project camunda-bpm-platform by camunda.

the class HumanTaskItemHandler method initializeTaskListeners.

protected void initializeTaskListeners(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context, TaskDefinition taskDefinition) {
    HumanTask humanTask = getDefinition(element);
    List<CamundaTaskListener> listeners = queryExtensionElementsByClass(humanTask, CamundaTaskListener.class);
    for (CamundaTaskListener listener : listeners) {
        TaskListener taskListener = initializeTaskListener(element, activity, context, listener);
        String eventName = listener.getCamundaEvent();
        if (eventName != null) {
            taskDefinition.addTaskListener(eventName, taskListener);
        } else {
            taskDefinition.addTaskListener(TaskListener.EVENTNAME_CREATE, taskListener);
            taskDefinition.addTaskListener(TaskListener.EVENTNAME_ASSIGNMENT, taskListener);
            taskDefinition.addTaskListener(TaskListener.EVENTNAME_COMPLETE, taskListener);
            taskDefinition.addTaskListener(TaskListener.EVENTNAME_DELETE, taskListener);
        }
    }
}
Also used : CamundaTaskListener(org.camunda.bpm.model.cmmn.instance.camunda.CamundaTaskListener) CamundaTaskListener(org.camunda.bpm.model.cmmn.instance.camunda.CamundaTaskListener) ExpressionTaskListener(org.camunda.bpm.engine.impl.task.listener.ExpressionTaskListener) ClassDelegateTaskListener(org.camunda.bpm.engine.impl.task.listener.ClassDelegateTaskListener) TaskListener(org.camunda.bpm.engine.delegate.TaskListener) DelegateExpressionTaskListener(org.camunda.bpm.engine.impl.task.listener.DelegateExpressionTaskListener) ScriptTaskListener(org.camunda.bpm.engine.impl.task.listener.ScriptTaskListener) HumanTask(org.camunda.bpm.model.cmmn.instance.HumanTask)

Example 9 with HumanTask

use of org.camunda.bpm.model.cmmn.instance.HumanTask in project camunda-bpm-platform by camunda.

the class CmmnTransformerTest method testActivityTreeWithOneStageAndNestedHumanTasks.

/**
 *   +-----------------+                                       +-----------------+
 *   | Case1            \                                      | aCaseDefinition |
 *   +-------------------+-----------------+                   +-----------------+
 *   |                                     |                            |
 *   |     +------------------------+      |                   +-----------------+
 *   |    / X                        \     |                   |  aCasePlanModel |
 *   |   +    +-------+  +-------+    +    |                   +-----------------+
 *   |   |    |   A   |  |   B   |    |    |  ==>                       |
 *   |   +    +-------+  +-------+    +    |                   +-----------------+
 *   |    \                          /     |                   |        X        |
 *   |     +------------------------+      |                   +-----------------+
 *   |                                     |                           / \
 *   +-------------------------------------+                          /   \
 *                                                 +-----------------+     +-----------------+
 *                                                 |        A        |     |        B        |
 *                                                 +-----------------+     +-----------------+
 */
@Test
public void testActivityTreeWithOneStageAndNestedHumanTasks() {
    // given
    Stage stage = createElement(casePlanModel, "X", Stage.class);
    HumanTask humanTaskA = createElement(casePlanModel, "A", HumanTask.class);
    HumanTask humanTaskB = createElement(casePlanModel, "B", HumanTask.class);
    PlanItem planItemX = createElement(casePlanModel, "PI_X", PlanItem.class);
    PlanItem planItemA = createElement(stage, "PI_A", PlanItem.class);
    PlanItem planItemB = createElement(stage, "PI_B", PlanItem.class);
    planItemX.setDefinition(stage);
    planItemA.setDefinition(humanTaskA);
    planItemB.setDefinition(humanTaskB);
    // when
    List<CaseDefinitionEntity> caseDefinitions = transform();
    // then
    assertEquals(1, caseDefinitions.size());
    CaseDefinitionEntity caseDefinition = caseDefinitions.get(0);
    List<CmmnActivity> activities = caseDefinition.getActivities();
    CmmnActivity casePlanModelActivity = activities.get(0);
    List<CmmnActivity> children = casePlanModelActivity.getActivities();
    assertEquals(1, children.size());
    CmmnActivity planItemStage = children.get(0);
    assertEquals(planItemX.getId(), planItemStage.getId());
    children = planItemStage.getActivities();
    assertEquals(2, children.size());
    CmmnActivity childPlanItem = children.get(0);
    assertEquals(planItemA.getId(), childPlanItem.getId());
    assertTrue(childPlanItem.getActivities().isEmpty());
    childPlanItem = children.get(1);
    assertEquals(planItemB.getId(), childPlanItem.getId());
    assertTrue(childPlanItem.getActivities().isEmpty());
}
Also used : CaseDefinitionEntity(org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity) Stage(org.camunda.bpm.model.cmmn.instance.Stage) HumanTask(org.camunda.bpm.model.cmmn.instance.HumanTask) PlanItem(org.camunda.bpm.model.cmmn.instance.PlanItem) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) Test(org.junit.Test)

Example 10 with HumanTask

use of org.camunda.bpm.model.cmmn.instance.HumanTask in project camunda-bpm-platform by camunda.

the class CmmnTransformerTest method testActivityTreeWithOneHumanTask.

/**
 *   +-----------------+                    +-----------------+
 *   | Case1            \                   | aCaseDefinition |
 *   +-------------------+---+              +-----------------+
 *   |                       |                      |
 *   |     +-------+         |   ==>        +-----------------+
 *   |     |   A   |         |              |  aCasePlanModel |
 *   |     +-------+         |              +-----------------+
 *   |                       |                      |
 *   +-----------------------+              +-----------------+
 *                                          |       A         |
 *                                          +-----------------+
 */
@Test
public void testActivityTreeWithOneHumanTask() {
    // given
    HumanTask humanTask = createElement(casePlanModel, "A", HumanTask.class);
    PlanItem planItem = createElement(casePlanModel, "PI_A", PlanItem.class);
    planItem.setDefinition(humanTask);
    // when
    List<CaseDefinitionEntity> caseDefinitions = transform();
    // then
    assertEquals(1, caseDefinitions.size());
    CaseDefinitionEntity caseDefinition = caseDefinitions.get(0);
    List<CmmnActivity> activities = caseDefinition.getActivities();
    CmmnActivity casePlanModelActivity = activities.get(0);
    List<CmmnActivity> planItemActivities = casePlanModelActivity.getActivities();
    assertEquals(1, planItemActivities.size());
    CmmnActivity child = planItemActivities.get(0);
    assertEquals(planItem.getId(), child.getId());
    assertTrue(child.getActivities().isEmpty());
}
Also used : CaseDefinitionEntity(org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity) HumanTask(org.camunda.bpm.model.cmmn.instance.HumanTask) PlanItem(org.camunda.bpm.model.cmmn.instance.PlanItem) CmmnActivity(org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity) Test(org.junit.Test)

Aggregations

HumanTask (org.camunda.bpm.model.cmmn.instance.HumanTask)20 Test (org.junit.Test)9 Expression (org.camunda.bpm.engine.delegate.Expression)8 ExpressionManager (org.camunda.bpm.engine.impl.el.ExpressionManager)8 CasePlanModel (org.camunda.bpm.model.cmmn.instance.CasePlanModel)5 PlanItem (org.camunda.bpm.model.cmmn.instance.PlanItem)5 CmmnActivity (org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity)4 Case (org.camunda.bpm.model.cmmn.instance.Case)4 Stage (org.camunda.bpm.model.cmmn.instance.Stage)4 CaseDefinitionEntity (org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity)3 CmmnModelInstance (org.camunda.bpm.model.cmmn.CmmnModelInstance)2 Definitions (org.camunda.bpm.model.cmmn.instance.Definitions)2 Task (org.camunda.bpm.model.cmmn.instance.Task)2 Collection (java.util.Collection)1 TaskListener (org.camunda.bpm.engine.delegate.TaskListener)1 ItemHandler (org.camunda.bpm.engine.impl.cmmn.handler.ItemHandler)1 ClassDelegateTaskListener (org.camunda.bpm.engine.impl.task.listener.ClassDelegateTaskListener)1 DelegateExpressionTaskListener (org.camunda.bpm.engine.impl.task.listener.DelegateExpressionTaskListener)1 ExpressionTaskListener (org.camunda.bpm.engine.impl.task.listener.ExpressionTaskListener)1 ScriptTaskListener (org.camunda.bpm.engine.impl.task.listener.ScriptTaskListener)1