Search in sources :

Example 11 with TaskEntity

use of org.activiti.engine.impl.persistence.entity.TaskEntity in project Activiti by Activiti.

the class JuelFormEngine method renderTaskForm.

public Object renderTaskForm(TaskFormData taskForm) {
    if (taskForm.getFormKey() == null) {
        return null;
    }
    String formTemplateString = getFormTemplateString(taskForm, taskForm.getFormKey());
    ScriptingEngines scriptingEngines = Context.getProcessEngineConfiguration().getScriptingEngines();
    TaskEntity task = (TaskEntity) taskForm.getTask();
    return scriptingEngines.evaluate(formTemplateString, ScriptingEngines.DEFAULT_SCRIPTING_LANGUAGE, task.getExecution());
}
Also used : TaskEntity(org.activiti.engine.impl.persistence.entity.TaskEntity) ScriptingEngines(org.activiti.engine.impl.scripting.ScriptingEngines)

Example 12 with TaskEntity

use of org.activiti.engine.impl.persistence.entity.TaskEntity in project Activiti by Activiti.

the class GetTaskVariableCmd method execute.

public Object execute(CommandContext commandContext) {
    if (taskId == null) {
        throw new ActivitiIllegalArgumentException("taskId is null");
    }
    if (variableName == null) {
        throw new ActivitiIllegalArgumentException("variableName is null");
    }
    TaskEntity task = commandContext.getTaskEntityManager().findTaskById(taskId);
    if (task == null) {
        throw new ActivitiObjectNotFoundException("task " + taskId + " doesn't exist", Task.class);
    }
    Object value;
    if (isLocal) {
        value = task.getVariableLocal(variableName, false);
    } else {
        value = task.getVariable(variableName, false);
    }
    return value;
}
Also used : TaskEntity(org.activiti.engine.impl.persistence.entity.TaskEntity) ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException)

Example 13 with TaskEntity

use of org.activiti.engine.impl.persistence.entity.TaskEntity in project Activiti by Activiti.

the class HasTaskVariableCmd method execute.

public Boolean execute(CommandContext commandContext) {
    if (taskId == null) {
        throw new ActivitiIllegalArgumentException("taskId is null");
    }
    if (variableName == null) {
        throw new ActivitiIllegalArgumentException("variableName is null");
    }
    TaskEntity task = commandContext.getTaskEntityManager().findTaskById(taskId);
    if (task == null) {
        throw new ActivitiObjectNotFoundException("task " + taskId + " doesn't exist", Task.class);
    }
    boolean hasVariable = false;
    if (isLocal) {
        hasVariable = task.hasVariableLocal(variableName);
    } else {
        hasVariable = task.hasVariable(variableName);
    }
    return hasVariable;
}
Also used : TaskEntity(org.activiti.engine.impl.persistence.entity.TaskEntity) ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException)

Example 14 with TaskEntity

use of org.activiti.engine.impl.persistence.entity.TaskEntity in project Activiti by Activiti.

the class NewTaskCmd method execute.

public Task execute(CommandContext commandContext) {
    Date currentTime = commandContext.getProcessEngineConfiguration().getClock().getCurrentTime();
    TaskEntity task = TaskEntity.create(currentTime);
    task.setId(taskId);
    return task;
}
Also used : TaskEntity(org.activiti.engine.impl.persistence.entity.TaskEntity) Date(java.util.Date)

Example 15 with TaskEntity

use of org.activiti.engine.impl.persistence.entity.TaskEntity in project Activiti by Activiti.

the class SetProcessDefinitionVersionCmd method validateAndSwitchVersionOfExecution.

protected void validateAndSwitchVersionOfExecution(CommandContext commandContext, ExecutionEntity execution, ProcessDefinitionEntity newProcessDefinition) {
    // check that the new process definition version contains the current activity
    if (execution.getActivity() != null && !newProcessDefinition.contains(execution.getActivity())) {
        throw new ActivitiException("The new process definition " + "(key = '" + newProcessDefinition.getKey() + "') " + "does not contain the current activity " + "(id = '" + execution.getActivity().getId() + "') " + "of the process instance " + "(id = '" + processInstanceId + "').");
    }
    // switch the process instance to the new process definition version
    execution.setProcessDefinition(newProcessDefinition);
    // and change possible existing tasks (as the process definition id is stored there too)
    List<TaskEntity> tasks = commandContext.getTaskEntityManager().findTasksByExecutionId(execution.getId());
    for (TaskEntity taskEntity : tasks) {
        taskEntity.setProcessDefinitionId(newProcessDefinition.getId());
        commandContext.getHistoryManager().recordTaskProcessDefinitionChange(taskEntity.getId(), newProcessDefinition.getId());
    }
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) TaskEntity(org.activiti.engine.impl.persistence.entity.TaskEntity)

Aggregations

TaskEntity (org.activiti.engine.impl.persistence.entity.TaskEntity)21 ActivitiException (org.activiti.engine.ActivitiException)5 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)5 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)4 ActivitiEntityEventImpl (org.activiti.engine.delegate.event.impl.ActivitiEntityEventImpl)4 Date (java.util.Date)3 ExecutionEntity (org.activiti.engine.impl.persistence.entity.ExecutionEntity)3 Task (org.activiti.engine.task.Task)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Expression (org.activiti.engine.delegate.Expression)1 ActivitiEntityEvent (org.activiti.engine.delegate.event.ActivitiEntityEvent)1 ActivitiEntityWithVariablesEvent (org.activiti.engine.delegate.event.ActivitiEntityWithVariablesEvent)1 TaskFormData (org.activiti.engine.form.TaskFormData)1 BusinessCalendar (org.activiti.engine.impl.calendar.BusinessCalendar)1 DueDateBusinessCalendar (org.activiti.engine.impl.calendar.DueDateBusinessCalendar)1 FormEngine (org.activiti.engine.impl.form.FormEngine)1 TaskFormHandler (org.activiti.engine.impl.form.TaskFormHandler)1 CommentEntity (org.activiti.engine.impl.persistence.entity.CommentEntity)1