Search in sources :

Example 46 with TaskEntity

use of org.camunda.bpm.engine.impl.persistence.entity.TaskEntity in project camunda-bpm-platform by camunda.

the class DeleteTaskAttachmentCmd method execute.

public Object execute(CommandContext commandContext) {
    AttachmentEntity attachment = (AttachmentEntity) commandContext.getAttachmentManager().findAttachmentByTaskIdAndAttachmentId(taskId, attachmentId);
    ensureNotNull("No attachment exist for task id '" + taskId + " and attachmentId '" + attachmentId + "'.", "attachment", attachment);
    commandContext.getDbEntityManager().delete(attachment);
    if (attachment.getContentId() != null) {
        commandContext.getByteArrayManager().deleteByteArrayById(attachment.getContentId());
    }
    if (attachment.getTaskId() != null) {
        TaskEntity task = commandContext.getTaskManager().findTaskById(attachment.getTaskId());
        PropertyChange propertyChange = new PropertyChange("name", null, attachment.getName());
        commandContext.getOperationLogManager().logAttachmentOperation(UserOperationLogEntry.OPERATION_TYPE_DELETE_ATTACHMENT, task, propertyChange);
    }
    return null;
}
Also used : TaskEntity(org.camunda.bpm.engine.impl.persistence.entity.TaskEntity) PropertyChange(org.camunda.bpm.engine.impl.persistence.entity.PropertyChange) AttachmentEntity(org.camunda.bpm.engine.impl.persistence.entity.AttachmentEntity)

Example 47 with TaskEntity

use of org.camunda.bpm.engine.impl.persistence.entity.TaskEntity in project camunda-bpm-platform by camunda.

the class UserOperationLogTaskServiceAndBeanTest method testAllTrackedProperties.

public void testAllTrackedProperties() {
    Date yesterday = new Date(new Date().getTime() - 86400000);
    Date tomorrow = new Date(new Date().getTime() + 86400000);
    TaskEntity entity = new TaskEntity();
    // call all tracked setter methods
    entity.setAssignee("er");
    entity.setDelegationState(DelegationState.PENDING);
    entity.setDeleted(true);
    entity.setDescription("a description");
    entity.setDueDate(tomorrow);
    entity.setFollowUpDate(yesterday);
    entity.setName("to do");
    entity.setOwner("icke");
    entity.setParentTaskId("parent");
    entity.setPriority(73);
    // and validate the change list
    Map<String, PropertyChange> changes = entity.getPropertyChanges();
    assertEquals("er", changes.get(ASSIGNEE).getNewValue());
    assertSame(DelegationState.PENDING, changes.get(DELEGATION).getNewValue());
    assertTrue((Boolean) changes.get(DELETE).getNewValue());
    assertEquals("a description", changes.get(DESCRIPTION).getNewValue());
    assertEquals(tomorrow, changes.get(DUE_DATE).getNewValue());
    assertEquals(yesterday, changes.get(FOLLOW_UP_DATE).getNewValue());
    assertEquals("to do", changes.get(NAME).getNewValue());
    assertEquals("icke", changes.get(OWNER).getNewValue());
    assertEquals("parent", changes.get(PARENT_TASK).getNewValue());
    assertEquals(73, changes.get(PRIORITY).getNewValue());
}
Also used : TaskEntity(org.camunda.bpm.engine.impl.persistence.entity.TaskEntity) PropertyChange(org.camunda.bpm.engine.impl.persistence.entity.PropertyChange) Date(java.util.Date)

Example 48 with TaskEntity

use of org.camunda.bpm.engine.impl.persistence.entity.TaskEntity in project camunda-bpm-platform by camunda.

the class UserOperationLogTaskServiceAndBeanTest method testBeanPropertyChanges.

public void testBeanPropertyChanges() {
    TaskEntity entity = new TaskEntity();
    // assign and validate changes
    entity.setAssignee("icke");
    Map<String, PropertyChange> changes = entity.getPropertyChanges();
    assertEquals(1, changes.size());
    assertNull(changes.get(ASSIGNEE).getOrgValue());
    assertEquals("icke", changes.get(ASSIGNEE).getNewValue());
    // assign it again
    entity.setAssignee("er");
    changes = entity.getPropertyChanges();
    assertEquals(1, changes.size());
    // original value is still null because the task was not saved
    assertNull(changes.get(ASSIGNEE).getOrgValue());
    assertEquals("er", changes.get(ASSIGNEE).getNewValue());
    // set a due date
    entity.setDueDate(new Date());
    changes = entity.getPropertyChanges();
    assertEquals(2, changes.size());
}
Also used : TaskEntity(org.camunda.bpm.engine.impl.persistence.entity.TaskEntity) PropertyChange(org.camunda.bpm.engine.impl.persistence.entity.PropertyChange) Date(java.util.Date)

Example 49 with TaskEntity

use of org.camunda.bpm.engine.impl.persistence.entity.TaskEntity in project camunda-bpm-platform by camunda.

the class ClaimTaskCmd method execute.

public Void execute(CommandContext commandContext) {
    ensureNotNull("taskId", taskId);
    TaskManager taskManager = commandContext.getTaskManager();
    TaskEntity task = taskManager.findTaskById(taskId);
    ensureNotNull("Cannot find task with id " + taskId, "task", task);
    checkClaimTask(task, commandContext);
    if (userId != null) {
        if (task.getAssignee() != null) {
            if (!task.getAssignee().equals(userId)) {
                // this, post-conditions of method already met.
                throw new TaskAlreadyClaimedException(task.getId(), task.getAssignee());
            }
        } else {
            task.setAssignee(userId);
        }
    } else {
        // Task should be assigned to no one
        task.setAssignee(null);
    }
    task.createHistoricTaskDetails(UserOperationLogEntry.OPERATION_TYPE_CLAIM);
    return null;
}
Also used : TaskManager(org.camunda.bpm.engine.impl.persistence.entity.TaskManager) TaskEntity(org.camunda.bpm.engine.impl.persistence.entity.TaskEntity) TaskAlreadyClaimedException(org.camunda.bpm.engine.TaskAlreadyClaimedException)

Example 50 with TaskEntity

use of org.camunda.bpm.engine.impl.persistence.entity.TaskEntity in project camunda-bpm-platform by camunda.

the class DelegateTaskCmd 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);
    checkDelegateTask(task, commandContext);
    task.delegate(userId);
    task.createHistoricTaskDetails(UserOperationLogEntry.OPERATION_TYPE_DELEGATE);
    return null;
}
Also used : TaskManager(org.camunda.bpm.engine.impl.persistence.entity.TaskManager) TaskEntity(org.camunda.bpm.engine.impl.persistence.entity.TaskEntity)

Aggregations

TaskEntity (org.camunda.bpm.engine.impl.persistence.entity.TaskEntity)53 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)17 Deployment (org.camunda.bpm.engine.test.Deployment)11 TaskManager (org.camunda.bpm.engine.impl.persistence.entity.TaskManager)10 Date (java.util.Date)4 PropertyChange (org.camunda.bpm.engine.impl.persistence.entity.PropertyChange)4 CommandChecker (org.camunda.bpm.engine.impl.cfg.CommandChecker)3 TaskFormHandler (org.camunda.bpm.engine.impl.form.handler.TaskFormHandler)3 ExternalTaskEntity (org.camunda.bpm.engine.impl.persistence.entity.ExternalTaskEntity)3 VariableInstanceEntity (org.camunda.bpm.engine.impl.persistence.entity.VariableInstanceEntity)3 TaskDefinition (org.camunda.bpm.engine.impl.task.TaskDefinition)3 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)2 TaskFormData (org.camunda.bpm.engine.form.TaskFormData)2 HistoryEvent (org.camunda.bpm.engine.impl.history.event.HistoryEvent)2 AttachmentEntity (org.camunda.bpm.engine.impl.persistence.entity.AttachmentEntity)2 ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)2 Task (org.camunda.bpm.engine.task.Task)2 VariableMapImpl (org.camunda.bpm.engine.variable.impl.VariableMapImpl)2 TypedValue (org.camunda.bpm.engine.variable.value.TypedValue)2 Before (org.junit.Before)2