use of org.camunda.bpm.engine.impl.persistence.entity.TaskEntity in project camunda-bpm-platform by camunda.
the class MigratingInstanceParser method parse.
public MigratingProcessInstance parse(String processInstanceId, MigrationPlan migrationPlan, MigratingProcessInstanceValidationReportImpl processInstanceReport) {
CommandContext commandContext = Context.getCommandContext();
List<EventSubscriptionEntity> eventSubscriptions = fetchEventSubscriptions(commandContext, processInstanceId);
List<ExecutionEntity> executions = fetchExecutions(commandContext, processInstanceId);
List<ExternalTaskEntity> externalTasks = fetchExternalTasks(commandContext, processInstanceId);
List<IncidentEntity> incidents = fetchIncidents(commandContext, processInstanceId);
List<JobEntity> jobs = fetchJobs(commandContext, processInstanceId);
List<TaskEntity> tasks = fetchTasks(commandContext, processInstanceId);
List<VariableInstanceEntity> variables = fetchVariables(commandContext, processInstanceId);
ExecutionEntity processInstance = commandContext.getExecutionManager().findExecutionById(processInstanceId);
processInstance.restoreProcessInstance(executions, eventSubscriptions, variables, tasks, jobs, incidents, externalTasks);
ProcessDefinitionEntity targetProcessDefinition = Context.getProcessEngineConfiguration().getDeploymentCache().findDeployedProcessDefinitionById(migrationPlan.getTargetProcessDefinitionId());
List<JobDefinitionEntity> targetJobDefinitions = fetchJobDefinitions(commandContext, targetProcessDefinition.getId());
final MigratingInstanceParseContext parseContext = new MigratingInstanceParseContext(this, migrationPlan, processInstance, targetProcessDefinition).eventSubscriptions(eventSubscriptions).externalTasks(externalTasks).incidents(incidents).jobs(jobs).tasks(tasks).targetJobDefinitions(targetJobDefinitions).variables(variables);
ActivityInstance activityInstance = engine.getRuntimeService().getActivityInstance(processInstanceId);
ActivityInstanceWalker activityInstanceWalker = new ActivityInstanceWalker(activityInstance);
activityInstanceWalker.addPreVisitor(new TreeVisitor<ActivityInstance>() {
@Override
public void visit(ActivityInstance obj) {
activityInstanceHandler.handle(parseContext, obj);
}
});
activityInstanceWalker.walkWhile();
CompensationEventSubscriptionWalker compensateSubscriptionsWalker = new CompensationEventSubscriptionWalker(parseContext.getMigratingActivityInstances());
compensateSubscriptionsWalker.addPreVisitor(new TreeVisitor<EventSubscriptionEntity>() {
@Override
public void visit(EventSubscriptionEntity obj) {
compensationInstanceHandler.handle(parseContext, obj);
}
});
compensateSubscriptionsWalker.walkWhile();
for (IncidentEntity incidentEntity : incidents) {
incidentHandler.handle(parseContext, incidentEntity);
}
parseContext.validateNoEntitiesLeft(processInstanceReport);
return parseContext.getMigratingProcessInstance();
}
use of org.camunda.bpm.engine.impl.persistence.entity.TaskEntity in project camunda-bpm-platform by camunda.
the class TaskAuthorizationTest method testSaveAndUpdateTaskWithTaskAssignPermission.
public void testSaveAndUpdateTaskWithTaskAssignPermission() {
// given
TaskEntity task = TaskEntity.create();
task.setAssignee("demo");
createGrantAuthorization(TASK, ANY, userId, CREATE, TASK_ASSIGN);
// when
taskService.saveTask(task);
task.delegate("demoNew");
taskService.saveTask(task);
// then
task = (TaskEntity) selectSingleTask();
assertNotNull(task);
assertEquals("demoNew", task.getAssignee());
String taskId = task.getId();
deleteTask(taskId, true);
}
use of org.camunda.bpm.engine.impl.persistence.entity.TaskEntity in project camunda-bpm-platform by camunda.
the class TaskAuthorizationTest method testSaveTaskInsertWithoutAuthorization.
// save task (insert) //////////////////////////////////////////////////////////
public void testSaveTaskInsertWithoutAuthorization() {
// given
TaskEntity task = TaskEntity.create();
try {
// when
taskService.saveTask(task);
fail("Exception expected: It should not be possible to save a task.");
} catch (AuthorizationException e) {
// then
assertTextPresent("The user with id 'test' does not have 'CREATE' permission on resource 'Task'", e.getMessage());
}
}
use of org.camunda.bpm.engine.impl.persistence.entity.TaskEntity in project camunda-bpm-platform by camunda.
the class ProcessTaskTest method testCallProcessAsConstant.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneProcessTaskCase.cmmn", "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testCallProcessAsConstant() {
// given
String caseInstanceId = createCaseInstanceByKey(ONE_PROCESS_TASK_CASE).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());
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);
}
use of org.camunda.bpm.engine.impl.persistence.entity.TaskEntity in project camunda-bpm-platform by camunda.
the class ProcessTaskTest method testCallProcessByVersion.
@Deployment(resources = { "org/camunda/bpm/engine/test/cmmn/processtask/ProcessTaskTest.testCallProcessByVersion.cmmn", "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testCallProcessByVersion() {
// 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).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);
}
Aggregations