本文整理了Java中org.camunda.bpm.engine.task.Task.getProcessInstanceId()
方法的一些代码示例,展示了Task.getProcessInstanceId()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Task.getProcessInstanceId()
方法的具体详情如下:
包路径:org.camunda.bpm.engine.task.Task
类名称:Task
方法名:getProcessInstanceId
[英]Reference to the process instance or null if it is not related to a process instance.
[中]对流程实例的引用,如果与流程实例无关,则为null。
代码示例来源:origin: camunda/camunda-bpm-platform
@Override
public String getProperty(Task obj) {
return obj.getProcessInstanceId();
}
});
代码示例来源:origin: camunda/camunda-bpm-platform
protected void verifyTasksSortedByProcessInstanceId(List<ProcessInstance> expectedProcessInstances,
List<Task> actualTasks) {
assertEquals(expectedProcessInstances.size(), actualTasks.size());
List<ProcessInstance> instances = new ArrayList<ProcessInstance>(expectedProcessInstances);
Collections.sort(instances, new Comparator<ProcessInstance>() {
public int compare(ProcessInstance p1, ProcessInstance p2) {
return p1.getId().compareTo(p2.getId());
}
});
for (int i = 0; i < instances.size(); i++) {
assertEquals(instances.get(i).getId(), actualTasks.get(i).getProcessInstanceId());
}
}
代码示例来源:origin: camunda/camunda-bpm-platform
/**
* verify that either the first or the last task of the list belong to the given process instance
*/
protected void verifyFirstOrLastTask(List<Task> tasks, ProcessInstance belongingProcessInstance) {
if (tasks.size() == 0) {
fail("no tasks given");
}
int numTasks = tasks.size();
boolean matches = tasks.get(0).getProcessInstanceId().equals(belongingProcessInstance.getId());
matches = matches || tasks.get(numTasks - 1).getProcessInstanceId()
.equals(belongingProcessInstance.getId());
assertTrue("neither first nor last task belong to process instance " + belongingProcessInstance.getId(),
matches);
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Deployment(resources = {"org/camunda/bpm/engine/test/cmmn/processtask/ProcessTaskTest.testOutputAll.cmmn",
"org/camunda/bpm/engine/test/cmmn/processtask/subProcessWithError.bpmn"})
public void testOutputWhenErrorOccurs() {
String caseInstanceId = createCaseInstanceByKey(ONE_PROCESS_TASK_CASE).getId();
Task task = queryTask();
assertThat(task.getName(), is("SubTask"));
String variableName = "foo";
Object variableValue = "bar";
runtimeService.setVariable(task.getProcessInstanceId(), variableName, variableValue);
taskService.complete(task.getId());
Object variable = caseService.getVariable(caseInstanceId, variableName);
assertThat(variable, is(notNullValue()));
assertThat(variable, is(variableValue));
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Deployment(resources = {"org/camunda/bpm/engine/test/cmmn/processtask/ProcessTaskTest.testOutputAll.cmmn",
"org/camunda/bpm/engine/test/cmmn/processtask/subProcessWithThrownError.bpmn"})
public void testOutputWhenThrownBpmnErrorOccurs() {
String caseInstanceId = createCaseInstanceByKey(ONE_PROCESS_TASK_CASE).getId();
Task task = queryTask();
assertThat(task.getName(), is("SubTask"));
String variableName = "foo";
Object variableValue = "bar";
runtimeService.setVariable(task.getProcessInstanceId(), variableName, variableValue);
taskService.complete(task.getId());
Object variable = caseService.getVariable(caseInstanceId, variableName);
assertThat(variable, is(notNullValue()));
assertThat(variable, is(variableValue));
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Deployment(resources = {
"org/camunda/bpm/engine/test/bpmn/callactivity/CallActivity.testSubProcessDataOutputOnError.bpmn",
"org/camunda/bpm/engine/test/bpmn/callactivity/subProcessWithError.bpmn"
})
public void testSubProcessDataOutputOnError() {
String variableName = "subVariable";
Object variableValue = "Hello from Subprocess";
runtimeService.startProcessInstanceByKey("Process_1");
//first task is the one in the subprocess
Task task = taskService.createTaskQuery().singleResult();
assertThat(task.getName(), is("SubTask"));
runtimeService.setVariable(task.getProcessInstanceId(), variableName, variableValue);
taskService.complete(task.getId());
task = taskService.createTaskQuery().singleResult();
assertThat(task.getName(), is("Task after error"));
Object variable = runtimeService.getVariable(task.getProcessInstanceId(), variableName);
assertThat(variable, is(notNullValue()));
assertThat(variable, is(variableValue));
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Deployment(resources = {
"org/camunda/bpm/engine/test/bpmn/callactivity/CallActivity.testSubProcessDataOutputOnThrownError.bpmn",
"org/camunda/bpm/engine/test/bpmn/callactivity/subProcessWithThrownError.bpmn"
})
public void testSubProcessDataOutputOnThrownError() {
String variableName = "subVariable";
Object variableValue = "Hello from Subprocess";
runtimeService.startProcessInstanceByKey("Process_1");
//first task is the one in the subprocess
Task task = taskService.createTaskQuery().singleResult();
assertThat(task.getName(), is("SubTask"));
runtimeService.setVariable(task.getProcessInstanceId(), variableName, variableValue);
taskService.complete(task.getId());
task = taskService.createTaskQuery().singleResult();
assertThat(task.getName(), is("Task after error"));
Object variable = runtimeService.getVariable(task.getProcessInstanceId(), variableName);
assertThat(variable, is(notNullValue()));
assertThat(variable, is(variableValue));
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Deployment(resources = {
"org/camunda/bpm/engine/test/bpmn/callactivity/CallActivity.testTwoSubProcessesDataOutputOnError.bpmn",
"org/camunda/bpm/engine/test/bpmn/callactivity/subProcessCallErrorSubProcess.bpmn",
"org/camunda/bpm/engine/test/bpmn/callactivity/subProcessWithError.bpmn"
})
public void testTwoSubProcessesDataOutputOnError() {
String variableName = "subVariable";
Object variableValue = "Hello from Subprocess";
runtimeService.startProcessInstanceByKey("Process_1");
//first task is the one in the subprocess
Task task = taskService.createTaskQuery().singleResult();
assertThat(task.getName(), is("SubTask"));
runtimeService.setVariable(task.getProcessInstanceId(), variableName, variableValue);
taskService.complete(task.getId());
task = taskService.createTaskQuery().singleResult();
assertThat(task.getName(), is("Task after error"));
Object variable = runtimeService.getVariable(task.getProcessInstanceId(), variableName);
//both processes have and out mapping for all, so we want the variable to be propagated to the process with the event handler
assertThat(variable, is(notNullValue()));
assertThat(variable, is(variableValue));
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Deployment(resources={"org/camunda/bpm/engine/test/api/task/TaskQueryTest.testProcessDefinition.bpmn20.xml"})
public void testProcessDefinitionName() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
List<Task> tasks = taskService.createTaskQuery().processDefinitionName("The%One%Task%Process").list();
assertEquals(1, tasks.size());
assertEquals(processInstance.getId(), tasks.get(0).getProcessInstanceId());
assertEquals(0, taskService.createTaskQuery().processDefinitionName("unexisting").count());
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Deployment(resources={"org/camunda/bpm/engine/test/api/task/TaskQueryTest.testProcessDefinition.bpmn20.xml"})
public void testProcessDefinitionKey() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
List<Task> tasks = taskService.createTaskQuery().processDefinitionKey("oneTaskProcess").list();
assertEquals(1, tasks.size());
assertEquals(processInstance.getId(), tasks.get(0).getProcessInstanceId());
assertEquals(0, taskService.createTaskQuery().processDefinitionKey("unexisting").count());
}
代码示例来源:origin: camunda/camunda-bpm-platform
protected void testDelegation() {
TaskQuery taskQuery = taskService.createTaskQuery();
//when
Task taskInSubProcess = taskQuery.singleResult();
assertEquals("Task in subprocess", taskInSubProcess.getName());
//then check value from input variable
Object inputVar = runtimeService.getVariable(taskInSubProcess.getProcessInstanceId(), "TestInputVar");
assertEquals("inValue", inputVar);
//when completing the task in the subprocess, finishes the subprocess
taskService.complete(taskInSubProcess.getId());
Task taskAfterSubProcess = taskQuery.singleResult();
assertEquals("Task after subprocess", taskAfterSubProcess.getName());
//then check value from output variable
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().singleResult();
Object outputVar = runtimeService.getVariable(processInstance.getId(), "TestOutputVar");
assertEquals("outValue", outputVar);
//complete task after sub process
taskService.complete(taskAfterSubProcess.getId());
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Deployment(resources={"org/camunda/bpm/engine/test/api/task/TaskQueryTest.testProcessDefinition.bpmn20.xml"})
public void testProcessDefinitionId() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
List<Task> tasks = taskService.createTaskQuery().processDefinitionId(processInstance.getProcessDefinitionId()).list();
assertEquals(1, tasks.size());
assertEquals(processInstance.getId(), tasks.get(0).getProcessInstanceId());
assertEquals(0, taskService.createTaskQuery().processDefinitionId("unexisting").count());
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Deployment(resources={"org/camunda/bpm/engine/test/api/task/TaskQueryTest.testProcessDefinition.bpmn20.xml"})
public void testQueryByMultipleActivityInstanceIds() throws Exception {
ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("oneTaskProcess");
String activityInstanceId1 = runtimeService.getActivityInstance(processInstance1.getId())
.getChildActivityInstances()[0].getId();
ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("oneTaskProcess");
String activityInstanceId2 = runtimeService.getActivityInstance(processInstance2.getId())
.getChildActivityInstances()[0].getId();
List<Task> result1 = taskService.createTaskQuery().activityInstanceIdIn(activityInstanceId1).list();
assertEquals(1, result1.size());
assertEquals(processInstance1.getId(), result1.get(0).getProcessInstanceId());
List<Task> result2 = taskService.createTaskQuery().activityInstanceIdIn(activityInstanceId2).list();
assertEquals(1, result2.size());
assertEquals(processInstance2.getId(), result2.get(0).getProcessInstanceId());
assertEquals(2, taskService.createTaskQuery().activityInstanceIdIn(activityInstanceId1, activityInstanceId2).list().size());
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Deployment(resources={"org/camunda/bpm/engine/test/api/task/TaskQueryTest.testProcessDefinition.bpmn20.xml"})
public void testProcessDefinitionNameLike() throws Exception {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
List<Task> tasks = taskService.createTaskQuery().processDefinitionNameLike("The\\%One\\%Task%").list();
assertEquals(1, tasks.size());
assertEquals(processInstance.getId(), tasks.get(0).getProcessInstanceId());
assertEquals(0, taskService.createTaskQuery().processDefinitionNameLike("The One Task").count());
assertEquals(0, taskService.createTaskQuery().processDefinitionNameLike("The Other Task%").count());
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Deployment(resources = {
"org/camunda/bpm/engine/test/bpmn/callactivity/CaseCallActivityTest.testOutputAll.bpmn20.xml",
"org/camunda/bpm/engine/test/api/cmmn/oneTaskCaseWithManualActivation.cmmn"
})
public void testCallCaseOutputAllVariablesTypedToProcess(){
startProcessInstanceByKey("process");
CaseInstance caseInstance = queryOneTaskCaseInstance();
String variableName = "foo";
String variableName2 = "null";
TypedValue variableValue = Variables.stringValue("bar");
TypedValue variableValue2 = Variables.integerValue(null);
caseService.withCaseExecution(caseInstance.getId())
.setVariable(variableName, variableValue)
.setVariable(variableName2, variableValue2)
.execute();
complete(caseInstance.getId());
Task task = taskService.createTaskQuery().singleResult();
TypedValue value = runtimeService.getVariableTyped(task.getProcessInstanceId(), variableName);
assertThat(value, is(variableValue));
value = runtimeService.getVariableTyped(task.getProcessInstanceId(), variableName2);
assertThat(value, is(variableValue2));
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Deployment(resources = {"org/camunda/bpm/engine/test/bpmn/event/escalation/EscalationEventTest.throwEscalationEvent.bpmn20.xml",
"org/camunda/bpm/engine/test/bpmn/event/escalation/EscalationEventTest.testPropagateOutputVariablesWhileCatchEscalationOnCallActivity.bpmn20.xml"})
public void testPropagateOutputVariablesTwoTimes() {
Map<String,Object> variables = new HashMap<String, Object>();
variables.put("input", 42);
String processInstanceId = runtimeService.startProcessInstanceByKey("catchEscalationProcess", variables).getId();
// when throw an escalation event on called process
Task taskInSuperProcess = taskService.createTaskQuery().taskDefinitionKey("taskAfterCatchedEscalation").singleResult();
assertNotNull(taskInSuperProcess);
// (1) the variables has been passed for the first time (from sub process to super process)
assertEquals(42, runtimeService.getVariable(processInstanceId, "output"));
// change variable "input" in sub process
Task taskInSubProcess = taskService.createTaskQuery().taskDefinitionKey("task").singleResult();
runtimeService.setVariable(taskInSubProcess.getProcessInstanceId(), "input", 999);
taskService.complete(taskInSubProcess.getId());
// (2) the variables has been passed for the second time (from sub process to super process)
assertEquals(999, runtimeService.getVariable(processInstanceId, "output"));
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Deployment(resources = {"org/camunda/bpm/engine/test/bpmn/event/escalation/EscalationEventTest.throwEscalationEvent.bpmn20.xml",
"org/camunda/bpm/engine/test/bpmn/event/escalation/EscalationEventSubprocessTest.testPropagateOutputVariablesWhileCatchEscalationOnCallActivity.bpmn20.xml"})
public void testPropagateOutputVariablesTwoTimes() {
Map<String,Object> variables = new HashMap<String, Object>();
variables.put("input", 42);
String processInstanceId = runtimeService.startProcessInstanceByKey("catchEscalationProcess", variables).getId();
// when throw an escalation event on called process
// (1) the variables has been passed for the first time (from sub process to super process)
Task taskInSuperProcess = taskService.createTaskQuery().taskDefinitionKey("taskAfterCatchedEscalation").singleResult();
assertNotNull(taskInSuperProcess);
assertEquals(42, runtimeService.getVariable(processInstanceId, "output"));
// change variable "input" in sub process
Task taskInSubProcess = taskService.createTaskQuery().taskDefinitionKey("task").singleResult();
runtimeService.setVariable(taskInSubProcess.getProcessInstanceId(), "input", 999);
taskService.complete(taskInSubProcess.getId());
// (2) the variables has been passed for the second time (from sub process to super process)
assertEquals(999, runtimeService.getVariable(processInstanceId, "output"));
}
代码示例来源:origin: camunda/camunda-bpm-platform
@After
public void tearDown() {
Mocks.reset();
for (Group group : identityService.createGroupQuery().list()) {
identityService.deleteGroup(group.getId());
}
for (User user : identityService.createUserQuery().list()) {
identityService.deleteUser(user.getId());
}
for (Task task : taskService.createTaskQuery().list()) {
if (task.getProcessInstanceId() == null) {
taskService.deleteTask(task.getId(), true);
}
}
identityService.clearAuthentication();
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Override
public void tearDown() {
processEngineConfiguration.setEnableExpressionsInAdhocQueries(false);
Mocks.reset();
for (Filter filter : filterService.createTaskFilterQuery().list()) {
filterService.deleteFilter(filter.getId());
}
for (Group group : identityService.createGroupQuery().list()) {
identityService.deleteGroup(group.getId());
}
for (User user : identityService.createUserQuery().list()) {
identityService.deleteUser(user.getId());
}
for (Task task : taskService.createTaskQuery().list()) {
if (task.getProcessInstanceId() == null) {
taskService.deleteTask(task.getId(), true);
}
}
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Deployment
public void testTaskPropertiesNotNull() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
List<String> activeActivityIds = runtimeService.getActiveActivityIds(processInstance.getId());
Task task = taskService.createTaskQuery().singleResult();
assertNotNull(task.getId());
assertEquals("my task", task.getName());
assertEquals("Very important", task.getDescription());
assertTrue(task.getPriority() > 0);
assertEquals("kermit", task.getAssignee());
assertEquals(processInstance.getId(), task.getProcessInstanceId());
assertEquals(processInstance.getId(), task.getExecutionId());
assertNotNull(task.getProcessDefinitionId());
assertNotNull(task.getTaskDefinitionKey());
assertNotNull(task.getCreateTime());
// the next test verifies that if an execution creates a task, that no events are created during creation of the task.
if (processEngineConfiguration.getHistoryLevel().getId() >= ProcessEngineConfigurationImpl.HISTORYLEVEL_ACTIVITY) {
assertEquals(0, taskService.getTaskEvents(task.getId()).size());
}
}
内容来源于网络,如有侵权,请联系作者删除!