本文整理汇总了Java中org.camunda.bpm.engine.task.Task类的典型用法代码示例。如果您正苦于以下问题:Java Task类的具体用法?Java Task怎么用?Java Task使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Task类属于org.camunda.bpm.engine.task包,在下文中一共展示了Task类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: get
import org.camunda.bpm.engine.task.Task; //导入依赖的package包/类
/**
* Gets one task for specified id.
*
* <p>
* Task must be assigned or assignable to calling user (directly or via candidate group).
* </p>
* <p>
* This method will fail if no user is logged in.
* </p>
*
* @param id Id of the task
* @return A task
*/
public TaskDto get(String id) {
Task task = getOwnTask(id);
if (task == null) {
task = getUnassignedTask(id);
}
if (task == null) {
task = getUnassignedGroupTask(id);
}
if (task != null) {
Map<String, String> businessKeys = getProcessBusinessKeys(asSet(task.getProcessInstanceId()));
return new TaskDto(task.getId(), task.getTaskDefinitionKey(), task.getName(),
task.getDescription(), task.getProcessInstanceId(),
toInstant(task.getDueDate()), toInstant(task.getCreateTime()), null,
businessKeys.get(task.getProcessInstanceId()),
task.getAssignee(), null);
} else {
throw new MissingObject(TaskDto.class, id);
}
}
示例2: testCompensateParallelSubprocessCompHandlerWaitstate
import org.camunda.bpm.engine.task.Task; //导入依赖的package包/类
@Deployment
public void testCompensateParallelSubprocessCompHandlerWaitstate() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("compensateProcess");
List<Task> compensationHandlerTasks = taskService.createTaskQuery().taskDefinitionKey("undoBookHotel").list();
assertEquals(5, compensationHandlerTasks.size());
ActivityInstance rootActivityInstance = runtimeService.getActivityInstance(processInstance.getId());
List<ActivityInstance> compensationHandlerInstances = getInstancesForActivityId(rootActivityInstance, "undoBookHotel");
assertEquals(5, compensationHandlerInstances.size());
for (Task task : compensationHandlerTasks) {
taskService.complete(task.getId());
}
Task singleResult = taskService.createTaskQuery().singleResult();
taskService.complete(singleResult.getId());
runtimeService.signal(processInstance.getId());
assertProcessEnded(processInstance.getId());
}
示例3: finishTask
import org.camunda.bpm.engine.task.Task; //导入依赖的package包/类
/**
* Marks the task as complete, submits the form attributes and let the process instance continue.
*
* @param id Id of the task
* @param params Form attributes in the form of a {@link Map}
* @param checkOwnership Should application check if this is task owned by signed in user
* @throws BadArgument If no id specified or no user logged in
* @throws MissingObject If task does not exist
*/
public void finishTask(String id, Map<String, Object> params, boolean checkOwnership) {
notNull(id, () -> new BadArgument(Task.class, id));
eq(taskExists(id), true, () -> new MissingObject(Task.class, id));
notNull(user, () -> new BadArgument("user"));
if (checkOwnership) {
ownTask(id);
}
TaskFormData formData = formService.getTaskFormData(id);
try {
formService.submitTaskForm(id, filterDefinedFields(formData, params));
} catch (FormFieldValidatorException ex) {
throw new BadArgument("validation");
}
}
示例4: notify
import org.camunda.bpm.engine.task.Task; //导入依赖的package包/类
@Override
public void notify(DelegateExecution execution) throws Exception {
LOGGER.info("Timer fired at " + new Date() + " in Scope " + execution.getId());
// fetch the BPMN model ID of the timer event
String timerEventId = execution.getCurrentActivityId();
// get the task this timer event is attached to
Job timerJob = execution.getProcessEngineServices().getManagementService().createJobQuery()
.activityId(timerEventId).singleResult();
Task task = execution.getProcessEngineServices().getTaskService().createTaskQuery()
.executionId(timerJob.getExecutionId()).singleResult();
if (task.getFollowUpDate() != null && task.getFollowUpDate().before(new Date())) {
LOGGER.info("the follow up date (" + task.getFollowUpDate()
+ ") of the User Task was reached");
execution.getProcessEngineServices().getRuntimeService().setVariableLocal(
task.getExecutionId(), "demoTaskBoundaryEvent.followUpDateReached", true);
}
// set a trigger marker variable on the local task scope
execution.getProcessEngineServices().getRuntimeService()
.setVariableLocal(task.getExecutionId(), "demoTaskBoundaryEvent.fired", true);
}
示例5: processPrintMail
import org.camunda.bpm.engine.task.Task; //导入依赖的package包/类
@Deployment(resources = "processes/printProcess.bpmn")
@Test
public void processPrintMail() throws Exception {
processApplication.startService(engineRule.getProcessEngine());
TaskQuery taskQuery = taskService.createTaskQuery().taskName("print it");
// wait for first mail
while(taskQuery.count() == 0) {
Thread.sleep(500);
}
List<Task> tasks = taskQuery.list();
assertThat(tasks).isNotEmpty();
for (Task task : tasks) {
taskService.complete(task.getId());
}
waitForAsyncJobs();
assertThat(runtimeService.createProcessInstanceQuery().list()).isEmpty();
}
示例6: testCompleteTask1First_Conventional
import org.camunda.bpm.engine.task.Task; //导入依赖的package包/类
@Test @Ignore // In my mind should work, but does not work due to a Camunda NullpointerExecption
@Deployment(resources = {"org/camunda/bpm/scenario/test/escalations/EscalationEventSubProcessTriggeredTwiceIntermediateTest.bpmn"})
public void testCompleteTask1First_Conventional() {
ProcessInstance pi = rule.getRuntimeService()
.startProcessInstanceByKey("EscalationEventSubProcessTriggeredTwiceIntermediateTest");
complete(task("UserTask1", pi)); // --> Test Case fails here with a NullPointerException
List<Task> tasks = taskQuery().processInstanceId(pi.getId()).taskDefinitionKey("UserTask2").list();
complete(tasks.get(0)); // necessary as query returns two tasks at this point
complete(task("UserTask2", pi));
complete(task("UserTask3", pi));
assertThat(pi)
.hasPassed("EndEvent")
.hasPassedInOrder("EndEventEscalated", "EndEventEscalated");
}
开发者ID:camunda,项目名称:camunda-bpm-assert-scenario,代码行数:21,代码来源:EscalationEventSubProcessTriggeredTwiceIntermediateConventionalTest.java
示例7: complete
import org.camunda.bpm.engine.task.Task; //导入依赖的package包/类
public void complete(String trackingId) {
CaseExecution completeShipmentOrderCaseExecution = processEngine.getCaseService().createCaseExecutionQuery()
.activityId(ShipmentCaseConstants.PLAN_ITEM_HUMAN_TASK_COMPLETE_SHIPMENT_ORDER)
.caseInstanceBusinessKey(trackingId)
.active()
.singleResult();
Assert.notNull(completeShipmentOrderCaseExecution);
Task task = processEngine.getTaskService().createTaskQuery()
.caseExecutionId(completeShipmentOrderCaseExecution.getId())
.singleResult();
Assert.notNull(task);
processEngine.getTaskService().complete(task.getId());
}
示例8: leistungenErfassen
import org.camunda.bpm.engine.task.Task; //导入依赖的package包/类
private void leistungenErfassen(ProcessInstance processInstance, String user, String produkt, String status, Set<String> leistungsNamen) {
Task task = claimTask(processInstance, user);
List<Leistung> leistungen = Lists.newArrayList();
for (String leistungsName : leistungsNamen) {
Leistung leistung = new Leistung();
leistung.setBezeichnung(leistungsName);
leistungen.add(leistung);
}
taskService.complete(task.getId(), Variables
.putValue(VARIABLES.KUNDENSTATUS, status)
.putValue(VARIABLES.PRODUKT, produkt)
.putValueTyped(VARIABLES.LEISTUNGEN, Variables.objectValue(leistungen).create())
);
}
示例9: shouldCoverManualTaskAsStillRunning
import org.camunda.bpm.engine.task.Task; //导入依赖的package包/类
@Test
@Deployment(resources = { RunningFlowNodeCoverageTest.BPMN_PATH })
public void shouldCoverManualTaskAsStillRunning() {
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("path", "B");
final ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceByKey(
CoverageTestProcessConstants.PROCESS_DEFINITION_KEY, variables);
assertFalse("The process instance should still be running!", processInstance.isEnded());
final Task runningTask = rule.getTaskService().createTaskQuery().active().taskDefinitionKey(
"UserTask_B").singleResult();
assertNotNull("One task instance should still be running!", runningTask);
}
示例10: testCompensateTransactionWithEventSubprocess
import org.camunda.bpm.engine.task.Task; //导入依赖的package包/类
@Deployment
public void testCompensateTransactionWithEventSubprocess() {
// given
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("txProcess");
Task beforeCancelTask = taskService.createTaskQuery().singleResult();
// when the transaction is cancelled and handled by an event subprocess
taskService.complete(beforeCancelTask.getId());
// then completing compensation works
Task compensationHandler = taskService.createTaskQuery().singleResult();
assertNotNull(compensationHandler);
assertEquals("blackBoxCompensationHandler", compensationHandler.getTaskDefinitionKey());
taskService.complete(compensationHandler.getId());
assertProcessEnded(processInstance.getId());
}
示例11: testCaseTaskGetSubTasksWithReadPermissionOnSub1
import org.camunda.bpm.engine.task.Task; //导入依赖的package包/类
public void testCaseTaskGetSubTasksWithReadPermissionOnSub1() {
// given
createCaseInstanceByKey(CASE_KEY);
String parentTaskId = selectSingleTask().getId();
disableAuthorization();
Task sub1 = taskService.newTask("sub1");
sub1.setParentTaskId(parentTaskId);
taskService.saveTask(sub1);
Task sub2 = taskService.newTask("sub2");
sub2.setParentTaskId(parentTaskId);
taskService.saveTask(sub2);
enableAuthorization();
createGrantAuthorization(TASK, "sub1", userId, READ);
// when
List<Task> subTasks = taskService.getSubTasks(parentTaskId);
// then
assertFalse(subTasks.isEmpty());
assertEquals(1, subTasks.size());
assertEquals("sub1", subTasks.get(0).getId());
}
示例12: testCompensationRemovalOnCancellation
import org.camunda.bpm.engine.task.Task; //导入依赖的package包/类
@Deployment
public void testCompensationRemovalOnCancellation() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("compensationProcess");
Execution taskExecution = runtimeService.createExecutionQuery().activityId("innerTask").singleResult();
Task task = taskService.createTaskQuery().executionId(taskExecution.getId()).singleResult();
assertNotNull(task);
taskService.complete(task.getId());
// there should be a compensation event subscription for innerTask now
assertEquals(1, runtimeService.createEventSubscriptionQuery().count());
// when innerTask2 is cancelled
ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
runtimeService.createProcessInstanceModification(processInstance.getId()).cancelActivityInstance(getInstanceIdForActivity(tree, "innerTask2")).execute();
// then the innerTask compensation should be removed
assertEquals(0, runtimeService.createEventSubscriptionQuery().count());
}
示例13: testInitConcurrentTriggerCompensationCompletion
import org.camunda.bpm.engine.task.Task; //导入依赖的package包/类
@Test
@ScenarioUnderTest("init.concurrent.triggerCompensation.1")
public void testInitConcurrentTriggerCompensationCompletion() {
// given active compensation
Task undoTask1 = rule.taskQuery().taskDefinitionKey("undoTask1").singleResult();
Task undoTask2 = rule.taskQuery().taskDefinitionKey("undoTask2").singleResult();
// then it is possible to complete compensation and the follow-up task
rule.getTaskService().complete(undoTask1.getId());
rule.getTaskService().complete(undoTask2.getId());
Task afterCompensateTask = rule.taskQuery().singleResult();
Assert.assertNotNull(afterCompensateTask);
Assert.assertEquals("afterCompensate", afterCompensateTask.getTaskDefinitionKey());
rule.getTaskService().complete(afterCompensateTask.getId());
rule.assertScenarioEnded();
}
示例14: testStandaloneTaskCannotChangeTenantId
import org.camunda.bpm.engine.task.Task; //导入依赖的package包/类
public void testStandaloneTaskCannotChangeTenantId() {
// given a persistent task with tenant id
Task task = taskService.newTask();
task.setTenantId(tenant1);
taskService.saveTask(task);
task = taskService.createTaskQuery().singleResult();
// if
// change the tenant id
task.setTenantId(tenant2);
// then
// an exception is thrown on 'save'
try {
taskService.saveTask(task);
fail("Expected an exception");
}
catch(ProcessEngineException e) {
assertTextPresent("ENGINE-03072 Cannot change tenantId of Task", e.getMessage());
}
// Finally, delete task
deleteTasks(task);
}
示例15: testInterruptingBoundaryTimerEvent
import org.camunda.bpm.engine.task.Task; //导入依赖的package包/类
@Deployment
public void testInterruptingBoundaryTimerEvent() {
ProcessInstance pi = runtimeService.startProcessInstanceByKey("process");
Job job = managementService.createJobQuery().singleResult();
assertNotNull(job);
managementService.executeJob(job.getId());
HistoricActivityInstanceQuery query = historyService.createHistoricActivityInstanceQuery();
query.activityId("timer");
assertEquals(1, query.count());
assertNotNull(query.singleResult().getEndTime());
assertEquals("boundaryTimer", query.singleResult().getActivityType());
Task task = taskService.createTaskQuery().singleResult();
taskService.complete(task.getId());
assertProcessEnded(pi.getId());
}