org.camunda.bpm.engine.impl.task.TaskDefinition Java Examples

The following examples show how to use org.camunda.bpm.engine.impl.task.TaskDefinition. 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: EntitySerializationTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void testTaskEntitySerialization() throws Exception {
  TaskEntity task = new TaskEntity();
  task.setDelegationState(DelegationState.RESOLVED);
  task.setExecution(new ExecutionEntity());
  task.setProcessInstance(new ExecutionEntity());
  task.setTaskDefinition(new TaskDefinition(null));

  task.setAssignee("kermit");
  task.setCreateTime(new Date());
  task.setDescription("Test description");
  task.setDueDate(new Date());
  task.setName("myTask");
  task.setEventName("end");
  task.setDeleted(false);
  task.setDelegationStateString(DelegationState.RESOLVED.name());

  byte[] data = writeObject(task);
  task = (TaskEntity) readObject(data);

  assertEquals("kermit", task.getAssignee());
  assertEquals("myTask", task.getName());
  assertEquals("end", task.getEventName());
}
 
Example #2
Source File: HumanTaskPlanItemHandlerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testTaskDefinitionPeformerExpression() {
  // given
  CaseRole role = createElement(caseDefinition, "aRole", CaseRole.class);
  role.setName("aPerformerRole");

  humanTask.setPerformer(role);

  // when
  CmmnActivity activity = handler.handleElement(planItem, context);

  // then
  HumanTaskActivityBehavior behavior = (HumanTaskActivityBehavior) activity.getActivityBehavior();
  TaskDefinition taskDefinition = behavior.getTaskDefinition();

  Expression assigneeExpression = taskDefinition.getAssigneeExpression();
  assertNotNull(assigneeExpression);
  assertEquals("aPerformerRole", assigneeExpression.getExpressionText());
}
 
Example #3
Source File: HumanTaskPlanItemHandlerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testTaskDefinitionAssigneeExpression() {
  // given
  String aPriority = "aPriority";
  humanTask.setCamundaPriority(aPriority);

  // when
  CmmnActivity activity = handler.handleElement(planItem, context);

  // then
  HumanTaskActivityBehavior behavior = (HumanTaskActivityBehavior) activity.getActivityBehavior();
  TaskDefinition taskDefinition = behavior.getTaskDefinition();

  Expression priorityExpression = taskDefinition.getPriorityExpression();
  assertNotNull(priorityExpression);
  assertEquals(aPriority, priorityExpression.getExpressionText());
}
 
Example #4
Source File: HumanTaskPlanItemHandlerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testTaskDefinitionPriorityExpression() {
  // given
  String aPriority = "aPriority";
  humanTask.setCamundaPriority(aPriority);

  // when
  CmmnActivity activity = handler.handleElement(planItem, context);

  // then
  HumanTaskActivityBehavior behavior = (HumanTaskActivityBehavior) activity.getActivityBehavior();
  TaskDefinition taskDefinition = behavior.getTaskDefinition();

  Expression priorityExpression = taskDefinition.getPriorityExpression();
  assertNotNull(priorityExpression);
  assertEquals(aPriority, priorityExpression.getExpressionText());
}
 
Example #5
Source File: GetTaskFormVariablesCmd.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public VariableMap execute(CommandContext commandContext) {
  final TaskManager taskManager = commandContext.getTaskManager();
  TaskEntity task = taskManager.findTaskById(resourceId);

  ensureNotNull(BadUserRequestException.class, "Cannot find task with id '" + resourceId + "'.", "task", task);

  checkGetTaskFormVariables(task, commandContext);

  VariableMapImpl result = new VariableMapImpl();

  // first, evaluate form fields
  TaskDefinition taskDefinition = task.getTaskDefinition();
  if (taskDefinition != null) {
    TaskFormData taskFormData = taskDefinition.getTaskFormHandler().createTaskForm(task);
    for (FormField formField : taskFormData.getFormFields()) {
      if(formVariableNames == null || formVariableNames.contains(formField.getId())) {
        result.put(formField.getId(), createVariable(formField, task));
      }
    }
  }

  // collect remaining variables from task scope and parent scopes
  task.collectVariables(result, formVariableNames, false, deserializeObjectValues);

  return result;
}
 
Example #6
Source File: HumanTaskPlanItemHandlerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testTaskDefinitionFormKey() {
  // given
  String aFormKey = "aFormKey";
  humanTask.setCamundaFormKey(aFormKey);

  // when
  CmmnActivity activity = handler.handleElement(planItem, context);

  // then
  HumanTaskActivityBehavior behavior = (HumanTaskActivityBehavior) activity.getActivityBehavior();
  TaskDefinition taskDefinition = behavior.getTaskDefinition();

  Expression formKeyExpression = taskDefinition.getFormKey();
  assertNotNull(formKeyExpression);
  assertEquals(aFormKey, formKeyExpression.getExpressionText());
}
 
Example #7
Source File: HumanTaskPlanItemHandlerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testHumanTaskDescription() {
  // given
  String description = "A description";
  humanTask.setDescription(description);

  // when
  CmmnActivity activity = handler.handleElement(planItem, context);

  // then
  HumanTaskActivityBehavior behavior = (HumanTaskActivityBehavior) activity.getActivityBehavior();
  TaskDefinition taskDefinition = behavior.getTaskDefinition();

  Expression descriptionExpression = taskDefinition.getDescriptionExpression();
  assertNotNull(descriptionExpression);
  assertEquals(description, descriptionExpression.getExpressionText());
}
 
Example #8
Source File: HumanTaskPlanItemHandlerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testPlanItemDescription() {
  // given
  String description = "A description";
  humanTask.setDescription(description);

  // the planItem has an own description
  String localDescription = "My Local Description";
  planItem.setDescription(localDescription);

  // when
  CmmnActivity activity = handler.handleElement(planItem, context);

  // then
  HumanTaskActivityBehavior behavior = (HumanTaskActivityBehavior) activity.getActivityBehavior();
  TaskDefinition taskDefinition = behavior.getTaskDefinition();

  Expression descriptionExpression = taskDefinition.getDescriptionExpression();
  assertNotNull(descriptionExpression);
  assertEquals(localDescription, descriptionExpression.getExpressionText());
}
 
Example #9
Source File: HumanTaskPlanItemHandlerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testTaskDefinitionFollowUpDateExpression() {
  // given
  String aFollowUpDate = "aFollowDate";
  humanTask.setCamundaFollowUpDate(aFollowUpDate);

  // when
  CmmnActivity activity = handler.handleElement(planItem, context);

  // then
  HumanTaskActivityBehavior behavior = (HumanTaskActivityBehavior) activity.getActivityBehavior();
  TaskDefinition taskDefinition = behavior.getTaskDefinition();

  Expression followUpDateExpression = taskDefinition.getFollowUpDateExpression();
  assertNotNull(followUpDateExpression);
  assertEquals(aFollowUpDate, followUpDateExpression.getExpressionText());
}
 
Example #10
Source File: HumanTaskPlanItemHandlerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testTaskDefinitionDueDateExpression() {
  // given
  String aDueDate = "aDueDate";
  humanTask.setCamundaDueDate(aDueDate);

  // when
  CmmnActivity activity = handler.handleElement(planItem, context);

  // then
  HumanTaskActivityBehavior behavior = (HumanTaskActivityBehavior) activity.getActivityBehavior();
  TaskDefinition taskDefinition = behavior.getTaskDefinition();

  Expression dueDateExpression = taskDefinition.getDueDateExpression();
  assertNotNull(dueDateExpression);
  assertEquals(aDueDate, dueDateExpression.getExpressionText());
}
 
Example #11
Source File: TaskEntity.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public TaskDefinition getTaskDefinition() {
  if (taskDefinition==null && taskDefinitionKey!=null) {

    Map<String, TaskDefinition> taskDefinitions = null;
    if (processDefinitionId != null) {
      ProcessDefinitionEntity processDefinition = Context
          .getProcessEngineConfiguration()
          .getDeploymentCache()
          .findDeployedProcessDefinitionById(processDefinitionId);

      taskDefinitions = processDefinition.getTaskDefinitions();

    } else {
      CaseDefinitionEntity caseDefinition = Context
          .getProcessEngineConfiguration()
          .getDeploymentCache()
          .findDeployedCaseDefinitionById(caseDefinitionId);

      taskDefinitions = caseDefinition.getTaskDefinitions();
    }

    taskDefinition = taskDefinitions.get(taskDefinitionKey);
  }
  return taskDefinition;
}
 
Example #12
Source File: HumanTaskPlanItemHandlerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testTaskDefinitionPlanItemNameExpression() {
  // given
  String name = "A HumanTask";
  humanTask.setName(name);

  String planItemName = "My LocalName";
  planItem.setName(planItemName);

  // when
  CmmnActivity activity = handler.handleElement(planItem, context);

  // then
  HumanTaskActivityBehavior behavior = (HumanTaskActivityBehavior) activity.getActivityBehavior();
  TaskDefinition taskDefinition = behavior.getTaskDefinition();

  Expression nameExpression = taskDefinition.getNameExpression();
  assertNotNull(nameExpression);
  assertEquals("My LocalName", nameExpression.getExpressionText());
}
 
Example #13
Source File: HumanTaskItemHandler.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Override
protected void initializeActivity(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context) {
  // execute standard initialization
  super.initializeActivity(element, activity, context);

  // create a taskDefinition
  TaskDefinition taskDefinition = createTaskDefinition(element, context);

  // get the caseDefinition...
  CaseDefinitionEntity caseDefinition = (CaseDefinitionEntity) context.getCaseDefinition();
  // ... and taskDefinition to caseDefinition
  caseDefinition.getTaskDefinitions().put(taskDefinition.getKey(), taskDefinition);

  ExpressionManager expressionManager = context.getExpressionManager();
  // create decorator
  TaskDecorator taskDecorator = new TaskDecorator(taskDefinition, expressionManager);

  // set taskDecorator on behavior
  HumanTaskActivityBehavior behavior = (HumanTaskActivityBehavior) activity.getActivityBehavior();
  behavior.setTaskDecorator(taskDecorator);

  // task listeners
  initializeTaskListeners(element, activity, context, taskDefinition);

}
 
Example #14
Source File: HumanTaskItemHandler.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
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_UPDATE, taskListener);
      taskDefinition.addTaskListener(TaskListener.EVENTNAME_DELETE, taskListener);
    }
  }
}
 
Example #15
Source File: RegisterAllBpmnParseListenerTest.java    From camunda-bpm-reactor with Apache License 2.0 6 votes vote down vote up
@Test
public void add_taskListeners_to_already_existin_listeners_with_reactor_listener_first() {
  final TaskDefinition taskDefinition = new TaskDefinition(mock(TaskFormHandler.class));
  final TaskListener taskListenerFromBpmn = mock(TaskListener.class);
  taskDefinition.addTaskListener(EVENTNAME_ASSIGNMENT, taskListenerFromBpmn);
  taskDefinition.addTaskListener(EVENTNAME_COMPLETE, taskListenerFromBpmn);
  taskDefinition.addTaskListener(EVENTNAME_CREATE, taskListenerFromBpmn);
  taskDefinition.addTaskListener(EVENTNAME_DELETE, taskListenerFromBpmn);

  final RegisterAllBpmnParseListener parseListener = new RegisterAllBpmnParseListener(taskListener, executionListener, true);
  parseListener.addTaskListener(taskDefinition);

  assertThat(taskDefinition.getTaskListeners()).hasSize(4);

  assertThat(taskDefinition.getTaskListeners(EVENTNAME_ASSIGNMENT)).containsExactly(taskListener, taskListenerFromBpmn);
  assertThat(taskDefinition.getTaskListeners(EVENTNAME_COMPLETE)).containsExactly(taskListener, taskListenerFromBpmn);
  assertThat(taskDefinition.getTaskListeners(EVENTNAME_CREATE)).containsExactly(taskListener, taskListenerFromBpmn);
  assertThat(taskDefinition.getTaskListeners(EVENTNAME_DELETE)).containsExactly(taskListener, taskListenerFromBpmn);
}
 
Example #16
Source File: RegisterAllBpmnParseListenerTest.java    From camunda-bpm-reactor with Apache License 2.0 6 votes vote down vote up
@Test
public void add_taskListeners_to_already_existin_listeners() {
  final TaskDefinition taskDefinition = new TaskDefinition(mock(TaskFormHandler.class));
  final TaskListener taskListenerFromBpmn = mock(TaskListener.class);
  taskDefinition.addTaskListener(EVENTNAME_ASSIGNMENT, taskListenerFromBpmn);
  taskDefinition.addTaskListener(EVENTNAME_COMPLETE, taskListenerFromBpmn);
  taskDefinition.addTaskListener(EVENTNAME_CREATE, taskListenerFromBpmn);
  taskDefinition.addTaskListener(EVENTNAME_DELETE, taskListenerFromBpmn);

  parseListener.addTaskListener(taskDefinition);

  assertThat(taskDefinition.getTaskListeners()).hasSize(4);

  assertThat(taskDefinition.getTaskListeners(EVENTNAME_ASSIGNMENT)).containsExactly(taskListenerFromBpmn, taskListener);
  assertThat(taskDefinition.getTaskListeners(EVENTNAME_COMPLETE)).containsExactly(taskListenerFromBpmn, taskListener);
  assertThat(taskDefinition.getTaskListeners(EVENTNAME_CREATE)).containsExactly(taskListenerFromBpmn, taskListener);
  assertThat(taskDefinition.getTaskListeners(EVENTNAME_DELETE)).containsExactly(taskListenerFromBpmn, taskListener);
}
 
Example #17
Source File: HumanTaskItemHandler.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
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);
  }
}
 
Example #18
Source File: HumanTaskPlanItemHandlerTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testAssignmentTaskListenerByClass() {
  // given:
  ExtensionElements extensionElements = addExtensionElements(humanTask);
  CamundaTaskListener taskListener = createElement(extensionElements, null, CamundaTaskListener.class);

  String className = "org.camunda.bpm.test.tasklistener.ABC";
  String event = TaskListener.EVENTNAME_ASSIGNMENT;
  taskListener.setCamundaEvent(event);
  taskListener.setCamundaClass(className);

  // when
  CmmnActivity activity = handler.handleElement(planItem, context);

  // then
  assertEquals(0, activity.getListeners().size());

  HumanTaskActivityBehavior behavior = (HumanTaskActivityBehavior) activity.getActivityBehavior();
  TaskDefinition taskDefinition = behavior.getTaskDefinition();

  assertNotNull(taskDefinition);

  assertEquals(1, taskDefinition.getTaskListeners().size());

  List<TaskListener> createListeners = taskDefinition.getTaskListeners(event);
  assertEquals(1, createListeners.size());
  TaskListener listener = createListeners.get(0);

  assertTrue(listener instanceof ClassDelegateTaskListener);

  ClassDelegateTaskListener classDelegateListener = (ClassDelegateTaskListener) listener;
  assertEquals(className, classDelegateListener.getClassName());
  assertTrue(classDelegateListener.getFieldDeclarations().isEmpty());

}
 
Example #19
Source File: HumanTaskPlanItemHandlerTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testAssignmentTaskListenerByDelegateExpression() {
  // given:
  ExtensionElements extensionElements = addExtensionElements(humanTask);
  CamundaTaskListener taskListener = createElement(extensionElements, null, CamundaTaskListener.class);

  String delegateExpression = "${myDelegateExpression}";
  String event = TaskListener.EVENTNAME_ASSIGNMENT;
  taskListener.setCamundaEvent(event);
  taskListener.setCamundaDelegateExpression(delegateExpression);

  // when
  CmmnActivity activity = handler.handleElement(planItem, context);

  // then
  assertEquals(0, activity.getListeners().size());

  HumanTaskActivityBehavior behavior = (HumanTaskActivityBehavior) activity.getActivityBehavior();
  TaskDefinition taskDefinition = behavior.getTaskDefinition();

  assertNotNull(taskDefinition);

  assertEquals(1, taskDefinition.getTaskListeners().size());

  List<TaskListener> createListeners = taskDefinition.getTaskListeners(event);
  assertEquals(1, createListeners.size());
  TaskListener listener = createListeners.get(0);

  assertTrue(listener instanceof DelegateExpressionTaskListener);

  DelegateExpressionTaskListener delegateExpressionListener = (DelegateExpressionTaskListener) listener;
  assertEquals(delegateExpression, delegateExpressionListener.getExpressionText());
  assertTrue(delegateExpressionListener.getFieldDeclarations().isEmpty());

}
 
Example #20
Source File: HumanTaskPlanItemHandlerTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testAssignmentTaskListenerByExpression() {
  // given:
  ExtensionElements extensionElements = addExtensionElements(humanTask);
  CamundaTaskListener taskListener = createElement(extensionElements, null, CamundaTaskListener.class);

  String expression = "${myExpression}";
  String event = TaskListener.EVENTNAME_ASSIGNMENT;
  taskListener.setCamundaEvent(event);
  taskListener.setCamundaExpression(expression);

  // when
  CmmnActivity activity = handler.handleElement(planItem, context);

  // then
  assertEquals(0, activity.getListeners().size());

  HumanTaskActivityBehavior behavior = (HumanTaskActivityBehavior) activity.getActivityBehavior();
  TaskDefinition taskDefinition = behavior.getTaskDefinition();

  assertNotNull(taskDefinition);

  assertEquals(1, taskDefinition.getTaskListeners().size());

  List<TaskListener> createListeners = taskDefinition.getTaskListeners(event);
  assertEquals(1, createListeners.size());
  TaskListener listener = createListeners.get(0);

  assertTrue(listener instanceof ExpressionTaskListener);

  ExpressionTaskListener expressionListener = (ExpressionTaskListener) listener;
  assertEquals(expression, expressionListener.getExpressionText());

}
 
Example #21
Source File: HumanTaskPlanItemHandlerTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testUpdateTaskListenerByClass() {
  // given:
  ExtensionElements extensionElements = addExtensionElements(humanTask);
  CamundaTaskListener taskListener = createElement(extensionElements, null, CamundaTaskListener.class);

  String className = "org.camunda.bpm.test.tasklistener.ABC";
  String event = TaskListener.EVENTNAME_UPDATE;
  taskListener.setCamundaEvent(event);
  taskListener.setCamundaClass(className);

  // when
  CmmnActivity activity = handler.handleElement(planItem, context);

  // then
  assertEquals(0, activity.getListeners().size());

  HumanTaskActivityBehavior behavior = (HumanTaskActivityBehavior) activity.getActivityBehavior();
  TaskDefinition taskDefinition = behavior.getTaskDefinition();

  assertNotNull(taskDefinition);

  assertEquals(1, taskDefinition.getTaskListeners().size());

  List<TaskListener> createListeners = taskDefinition.getTaskListeners(event);
  assertEquals(1, createListeners.size());
  TaskListener listener = createListeners.get(0);

  assertTrue(listener instanceof ClassDelegateTaskListener);

  ClassDelegateTaskListener classDelegateListener = (ClassDelegateTaskListener) listener;
  assertEquals(className, classDelegateListener.getClassName());
  assertTrue(classDelegateListener.getFieldDeclarations().isEmpty());

}
 
Example #22
Source File: HumanTaskPlanItemHandlerTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testTaskDefinitionCandidateUsers() {
  // given
  String aCandidateUsers = "mary,john,peter";
  humanTask.setCamundaCandidateUsers(aCandidateUsers);

  // when
  CmmnActivity activity = handler.handleElement(planItem, context);

  // then
  HumanTaskActivityBehavior behavior = (HumanTaskActivityBehavior) activity.getActivityBehavior();
  TaskDefinition taskDefinition = behavior.getTaskDefinition();

  Set<Expression> candidateUserExpressions = taskDefinition.getCandidateUserIdExpressions();
  assertEquals(3, candidateUserExpressions.size());

  for (Expression candidateUserExpression : candidateUserExpressions) {
    String candidateUser = candidateUserExpression.getExpressionText();
    if ("mary".equals(candidateUser)) {
      assertEquals("mary", candidateUser);
    } else if ("john".equals(candidateUser)) {
      assertEquals("john", candidateUser);
    } else if ("peter".equals(candidateUser)) {
      assertEquals("peter", candidateUser);
    } else {
      fail("Unexpected candidate user: " + candidateUser);
    }
  }
}
 
Example #23
Source File: HistoryParseListener.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void parseUserTask(Element userTaskElement, ScopeImpl scope, ActivityImpl activity) {
  ensureHistoryLevelInitialized();
  addActivityHandlers(activity);

  if (historyLevel.isHistoryEventProduced(HistoryEventTypes.TASK_INSTANCE_CREATE, null)) {
    TaskDefinition taskDefinition = ((UserTaskActivityBehavior) activity.getActivityBehavior()).getTaskDefinition();
    taskDefinition.addBuiltInTaskListener(TaskListener.EVENTNAME_ASSIGNMENT, USER_TASK_ASSIGNMENT_HANDLER);
    taskDefinition.addBuiltInTaskListener(TaskListener.EVENTNAME_CREATE, USER_TASK_ID_HANDLER);
  }
}
 
Example #24
Source File: GetFormKeyCmd.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public String execute(CommandContext commandContext) {
  ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
  DeploymentCache deploymentCache = processEngineConfiguration.getDeploymentCache();
  ProcessDefinitionEntity processDefinition = deploymentCache.findDeployedProcessDefinitionById(processDefinitionId);

  for(CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
    checker.checkReadProcessDefinition(processDefinition);
  }

  Expression formKeyExpression = null;

  if (taskDefinitionKey == null) {

    // TODO: Maybe add getFormKey() to FormHandler interface to avoid the following cast
    FormHandler formHandler = processDefinition.getStartFormHandler();

    if (formHandler instanceof DelegateStartFormHandler) {
      DelegateStartFormHandler delegateFormHandler = (DelegateStartFormHandler) formHandler;
      formHandler = delegateFormHandler.getFormHandler();
    }

    // Sorry!!! In case of a custom start form handler (which does not extend
    // the DefaultFormHandler) a formKey would never be returned. So a custom
    // form handler (for a startForm) has always to extend the DefaultStartFormHandler!
    if (formHandler instanceof DefaultStartFormHandler) {
      DefaultStartFormHandler startFormHandler = (DefaultStartFormHandler) formHandler;
      formKeyExpression = startFormHandler.getFormKey();
    }

  } else {
    TaskDefinition taskDefinition = processDefinition.getTaskDefinitions().get(taskDefinitionKey);
    formKeyExpression = taskDefinition.getFormKey();
  }

  String formKey = null;
  if (formKeyExpression != null) {
    formKey = formKeyExpression.getExpressionText();
  }
  return formKey;
}
 
Example #25
Source File: TaskEntity.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void initializeFormKey() {
  isFormKeyInitialized = true;
  if(taskDefinitionKey != null) {
    TaskDefinition taskDefinition = getTaskDefinition();
    if(taskDefinition != null) {
      Expression formKey = taskDefinition.getFormKey();
      if(formKey != null) {
        this.formKey = (String) formKey.getValue(this);
      }
    }
  }
}
 
Example #26
Source File: TaskEntity.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected TaskListener getTimeoutListener(String timeoutId) {
  TaskDefinition resolvedTaskDefinition = getTaskDefinition();
  if (resolvedTaskDefinition == null) {
    return null;
  } else {
    return resolvedTaskDefinition.getTimeoutTaskListener(timeoutId);
  }
}
 
Example #27
Source File: TaskEntity.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected List<TaskListener> getListenersForEvent(String event) {
  TaskDefinition resolvedTaskDefinition = getTaskDefinition();
  if (resolvedTaskDefinition != null) {
    if (skipCustomListeners) {
      return resolvedTaskDefinition.getBuiltinTaskListeners(event);
    }
    else {
      return resolvedTaskDefinition.getTaskListeners(event);
    }

  }
  else {
    return null;
  }
}
 
Example #28
Source File: HumanTaskItemHandler.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void initializeTaskDefinitionPriority(CmmnElement element, TaskDefinition taskDefinition, CmmnHandlerContext context) {
  HumanTask definition = getDefinition(element);

  String priority = definition.getCamundaPriority();
  if (priority != null) {
    ExpressionManager expressionManager = context.getExpressionManager();
    Expression priorityExpression = expressionManager.createExpression(priority);
    taskDefinition.setPriorityExpression(priorityExpression);
  }
}
 
Example #29
Source File: HumanTaskItemHandler.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
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);
  }
}
 
Example #30
Source File: RegisterAllBpmnParseListener.java    From camunda-bpm-reactor with Apache License 2.0 5 votes vote down vote up
void addTaskListener(final TaskDefinition taskDefinition) {
  if(reactorListenerFirstOnUserTask) {
    taskDefinition.setTaskListeners(reactorListenerFirstMap(taskDefinition.getTaskListeners(), TASK_EVENTS, taskListener));
  } else {
    for (final String event : TASK_EVENTS) {
      taskDefinition.addTaskListener(event, taskListener);
    }
  }
}