Search in sources :

Example 41 with TaskEntity

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

the class ProcessTaskTest method testInputBusinessKey.

@Deployment(resources = { "org/camunda/bpm/engine/test/cmmn/processtask/ProcessTaskTest.testInputBusinessKey.cmmn", "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testInputBusinessKey() {
    // given
    String businessKey = "myBusinessKey";
    String caseInstanceId = createCaseInstanceByKey(ONE_PROCESS_TASK_CASE, businessKey).getId();
    String processTaskId = queryCaseExecutionByActivityId(PROCESS_TASK).getId();
    // then
    // there exists a process instance
    ExecutionEntity processInstance = (ExecutionEntity) queryProcessInstance();
    assertNotNull(processInstance);
    // the case instance id is set on called process instance
    assertEquals(caseInstanceId, processInstance.getCaseInstanceId());
    // the super case execution id is equals the processTaskId
    assertEquals(processTaskId, processInstance.getSuperCaseExecutionId());
    // the business key has been set
    assertEquals(businessKey, processInstance.getBusinessKey());
    TaskEntity task = (TaskEntity) queryTask();
    // the case instance id has been also set on the task
    assertEquals(caseInstanceId, task.getCaseInstanceId());
    // the case execution id should be null
    assertNull(task.getCaseExecutionId());
    // complete ////////////////////////////////////////////////////////
    taskService.complete(task.getId());
    assertProcessEnded(processInstance.getId());
    close(caseInstanceId);
    assertCaseEnded(caseInstanceId);
}
Also used : TaskEntity(org.camunda.bpm.engine.impl.persistence.entity.TaskEntity) ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 42 with TaskEntity

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

the class ProcessTaskTest method testCallProcessByVersionAsExpressionStartsWithHash.

@Deployment(resources = { "org/camunda/bpm/engine/test/cmmn/processtask/ProcessTaskTest.testCallProcessByVersionAsExpressionStartsWithHash.cmmn", "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testCallProcessByVersionAsExpressionStartsWithHash() {
    // given
    String bpmnResourceName = "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml";
    String secondDeploymentId = repositoryService.createDeployment().addClasspathResource(bpmnResourceName).deploy().getId();
    String thirdDeploymentId = repositoryService.createDeployment().addClasspathResource(bpmnResourceName).deploy().getId();
    assertEquals(3, repositoryService.createProcessDefinitionQuery().count());
    String caseInstanceId = createCaseInstanceByKey(ONE_PROCESS_TASK_CASE, Variables.createVariables().putValue("myVersion", 2)).getId();
    String processTaskId = queryCaseExecutionByActivityId(PROCESS_TASK).getId();
    // latest process definition
    String processDefinitionIdInSecondDeployment = repositoryService.createProcessDefinitionQuery().deploymentId(secondDeploymentId).singleResult().getId();
    // then
    // there exists a process instance
    ExecutionEntity processInstance = (ExecutionEntity) queryProcessInstance();
    assertNotNull(processInstance);
    // the case instance id is set on called process instance
    assertEquals(caseInstanceId, processInstance.getCaseInstanceId());
    // the super case execution id is equals the processTaskId
    assertEquals(processTaskId, processInstance.getSuperCaseExecutionId());
    // it is associated with the correct process definition
    assertEquals(processDefinitionIdInSecondDeployment, processInstance.getProcessDefinitionId());
    TaskEntity task = (TaskEntity) queryTask();
    // the case instance id has been also set on the task
    assertEquals(caseInstanceId, task.getCaseInstanceId());
    // the case execution id should be null
    assertNull(task.getCaseExecutionId());
    // complete ////////////////////////////////////////////////////////
    taskService.complete(task.getId());
    assertProcessEnded(processInstance.getId());
    close(caseInstanceId);
    assertCaseEnded(caseInstanceId);
    repositoryService.deleteDeployment(secondDeploymentId, true);
    repositoryService.deleteDeployment(thirdDeploymentId, true);
}
Also used : TaskEntity(org.camunda.bpm.engine.impl.persistence.entity.TaskEntity) ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 43 with TaskEntity

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

the class DeleteAttachmentCmd method execute.

public Object execute(CommandContext commandContext) {
    AttachmentEntity attachment = commandContext.getDbEntityManager().selectById(AttachmentEntity.class, attachmentId);
    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 44 with TaskEntity

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

the class GetIdentityLinksForTaskCmd method execute.

@SuppressWarnings({ "unchecked", "rawtypes" })
public List<IdentityLink> execute(CommandContext commandContext) {
    ensureNotNull("taskId", taskId);
    TaskManager taskManager = commandContext.getTaskManager();
    TaskEntity task = taskManager.findTaskById(taskId);
    ensureNotNull("Cannot find task with id " + taskId, "task", task);
    checkGetIdentityLink(task, commandContext);
    List<IdentityLink> identityLinks = (List) task.getIdentityLinks();
    // and of course this leads to exception while trying to delete a non-existing identityLink
    if (task.getAssignee() != null) {
        IdentityLinkEntity identityLink = new IdentityLinkEntity();
        identityLink.setUserId(task.getAssignee());
        identityLink.setTask(task);
        identityLink.setType(IdentityLinkType.ASSIGNEE);
        identityLinks.add(identityLink);
    }
    if (task.getOwner() != null) {
        IdentityLinkEntity identityLink = new IdentityLinkEntity();
        identityLink.setUserId(task.getOwner());
        identityLink.setTask(task);
        identityLink.setType(IdentityLinkType.OWNER);
        identityLinks.add(identityLink);
    }
    return (List) task.getIdentityLinks();
}
Also used : IdentityLinkEntity(org.camunda.bpm.engine.impl.persistence.entity.IdentityLinkEntity) TaskManager(org.camunda.bpm.engine.impl.persistence.entity.TaskManager) TaskEntity(org.camunda.bpm.engine.impl.persistence.entity.TaskEntity) List(java.util.List) IdentityLink(org.camunda.bpm.engine.task.IdentityLink)

Example 45 with TaskEntity

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

the class GetTaskVariableCmdTyped method execute.

public TypedValue execute(CommandContext commandContext) {
    ensureNotNull("taskId", taskId);
    ensureNotNull("variableName", variableName);
    TaskEntity task = Context.getCommandContext().getTaskManager().findTaskById(taskId);
    ensureNotNull("task " + taskId + " doesn't exist", "task", task);
    checkGetTaskVariableTyped(task, commandContext);
    TypedValue value;
    if (isLocal) {
        value = task.getVariableLocalTyped(variableName, deserializeValue);
    } else {
        value = task.getVariableTyped(variableName, deserializeValue);
    }
    return value;
}
Also used : TaskEntity(org.camunda.bpm.engine.impl.persistence.entity.TaskEntity) TypedValue(org.camunda.bpm.engine.variable.value.TypedValue)

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