use of org.camunda.bpm.engine.impl.task.TaskDefinition in project camunda-bpm-platform by camunda.
the class GetTaskFormVariablesCmd method execute.
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;
}
use of org.camunda.bpm.engine.impl.task.TaskDefinition in project camunda-bpm-platform by camunda.
the class BpmnParse method parseUserTask.
/**
* Parses a userTask declaration.
*/
public ActivityImpl parseUserTask(Element userTaskElement, ScopeImpl scope) {
ActivityImpl activity = createActivityOnScope(userTaskElement, scope);
parseAsynchronousContinuationForActivity(userTaskElement, activity);
TaskDefinition taskDefinition = parseTaskDefinition(userTaskElement, activity.getId(), (ProcessDefinitionEntity) scope.getProcessDefinition());
TaskDecorator taskDecorator = new TaskDecorator(taskDefinition, expressionManager);
UserTaskActivityBehavior userTaskActivity = new UserTaskActivityBehavior(taskDecorator);
activity.setActivityBehavior(userTaskActivity);
parseProperties(userTaskElement, activity);
parseExecutionListenersOnScope(userTaskElement, activity);
for (BpmnParseListener parseListener : parseListeners) {
parseListener.parseUserTask(userTaskElement, scope, activity);
}
return activity;
}
use of org.camunda.bpm.engine.impl.task.TaskDefinition in project camunda-bpm-platform by camunda.
the class SubmitTaskFormCmd method execute.
public Object execute(CommandContext commandContext) {
ensureNotNull("taskId", taskId);
TaskManager taskManager = commandContext.getTaskManager();
TaskEntity task = taskManager.findTaskById(taskId);
ensureNotNull("Cannot find task with id " + taskId, "task", task);
for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
checker.checkTaskWork(task);
}
TaskDefinition taskDefinition = task.getTaskDefinition();
if (taskDefinition != null) {
TaskFormHandler taskFormHandler = taskDefinition.getTaskFormHandler();
taskFormHandler.submitFormVariables(properties, task);
} else {
// set variables on standalone task
task.setVariables(properties);
}
// complete or resolve the task
if (DelegationState.PENDING.equals(task.getDelegationState())) {
task.resolve();
task.createHistoricTaskDetails(UserOperationLogEntry.OPERATION_TYPE_RESOLVE);
} else {
task.complete();
task.createHistoricTaskDetails(UserOperationLogEntry.OPERATION_TYPE_COMPLETE);
}
return null;
}
use of org.camunda.bpm.engine.impl.task.TaskDefinition in project camunda-bpm-platform by camunda.
the class GetFormKeyCmd method execute.
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();
}
// 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;
}
use of org.camunda.bpm.engine.impl.task.TaskDefinition in project camunda-bpm-platform by camunda.
the class HumanTaskItemHandler method createTaskDefinition.
protected TaskDefinition createTaskDefinition(CmmnElement element, CmmnHandlerContext context) {
// at the moment a default task form handler is only supported,
// custom task form handler are not supported.
TaskFormHandler taskFormHandler = new DefaultTaskFormHandler();
// create new taskDefinition
TaskDefinition taskDefinition = new TaskDefinition(taskFormHandler);
// the plan item id will be handled as taskDefinitionKey
String taskDefinitionKey = element.getId();
taskDefinition.setKey(taskDefinitionKey);
// name
initializeTaskDefinitionName(element, taskDefinition, context);
// dueDate
initializeTaskDefinitionDueDate(element, taskDefinition, context);
// followUp
initializeTaskDefinitionFollowUpDate(element, taskDefinition, context);
// priority
initializeTaskDefinitionPriority(element, taskDefinition, context);
// assignee
initializeTaskDefinitionAssignee(element, taskDefinition, context);
// candidateUsers
initializeTaskDefinitionCandidateUsers(element, taskDefinition, context);
// candidateGroups
initializeTaskDefinitionCandidateGroups(element, taskDefinition, context);
// formKey
initializeTaskDefinitionFormKey(element, taskDefinition, context);
// description
initializeTaskDescription(element, taskDefinition, context);
return taskDefinition;
}
Aggregations