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;
}
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());
}
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());
}
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;
}
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;
}
Aggregations