use of org.camunda.bpm.engine.impl.task.TaskDefinition in project camunda-bpm-platform by camunda.
the class CaseHandler method initializeActivity.
protected void initializeActivity(Case element, CmmnActivity activity, CmmnHandlerContext context) {
CaseDefinitionEntity definition = (CaseDefinitionEntity) activity;
Deployment deployment = context.getDeployment();
definition.setKey(element.getId());
definition.setName(element.getName());
definition.setDeploymentId(deployment.getId());
definition.setTaskDefinitions(new HashMap<String, TaskDefinition>());
definition.setHistoryTimeToLive(ParseUtil.parseHistoryTimeToLive(element.getCamundaHistoryTimeToLiveString()));
CmmnModelInstance model = context.getModel();
Definitions definitions = model.getDefinitions();
String category = definitions.getTargetNamespace();
definition.setCategory(category);
}
use of org.camunda.bpm.engine.impl.task.TaskDefinition in project camunda-bpm-platform by camunda.
the class TaskEntity method getTaskDefinition.
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;
}
use of org.camunda.bpm.engine.impl.task.TaskDefinition in project camunda-bpm-platform by camunda.
the class HumanTaskPlanItemHandlerTest method testDeleteTaskListenerByExpression.
@Test
public void testDeleteTaskListenerByExpression() {
// given:
ExtensionElements extensionElements = addExtensionElements(humanTask);
CamundaTaskListener taskListener = createElement(extensionElements, null, CamundaTaskListener.class);
String expression = "${myExpression}";
String event = TaskListener.EVENTNAME_DELETE;
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());
}
use of org.camunda.bpm.engine.impl.task.TaskDefinition in project camunda-bpm-platform by camunda.
the class HumanTaskPlanItemHandlerTest method testHumanTaskDescription.
@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());
}
use of org.camunda.bpm.engine.impl.task.TaskDefinition in project camunda-bpm-platform by camunda.
the class HumanTaskPlanItemHandlerTest method testAssignmentTaskListenerByClass.
@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());
}
Aggregations