本文整理汇总了Java中org.camunda.bpm.engine.task.Task.getProcessInstanceId方法的典型用法代码示例。如果您正苦于以下问题:Java Task.getProcessInstanceId方法的具体用法?Java Task.getProcessInstanceId怎么用?Java Task.getProcessInstanceId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.camunda.bpm.engine.task.Task
的用法示例。
在下文中一共展示了Task.getProcessInstanceId方法的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: doExecute
import org.camunda.bpm.engine.task.Task; //导入方法依赖的package包/类
@Override
protected Object doExecute() throws Exception {
TaskQuery taskQuery = engine.getTaskService().createTaskQuery();
if (processId != null) {
taskQuery.processDefinitionId(processId);
}
List<Task> tasks = taskQuery.orderByTaskCreateTime().asc().list();
int i = 0;
String[][] data = new String[tasks.size()][HEADER.length];
for (Task task : tasks) {
data[i++] = new String[]{
task.getId(),
task.getProcessInstanceId(),
task.getProcessDefinitionId(),
task.getAssignee(),
task.getName()};
}
return null;
}
示例3: tearDown
import org.camunda.bpm.engine.task.Task; //导入方法依赖的package包/类
@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();
}
示例4: tearDown
import org.camunda.bpm.engine.task.Task; //导入方法依赖的package包/类
@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);
}
}
}
示例5: testScriptTaskExecutesQueryAfterUserCompletesTask
import org.camunda.bpm.engine.task.Task; //导入方法依赖的package包/类
@Deployment
public void testScriptTaskExecutesQueryAfterUserCompletesTask() {
// given
startProcessInstancesByKey(DEFAULT_PROCESS_KEY, 5);
Task task = selectAnyTask();
String taskId = task.getId();
String processInstanceId = task.getProcessInstanceId();
createGrantAuthorization(TASK, taskId, userId, UPDATE);
// when
taskService.complete(taskId);
// then
disableAuthorization();
VariableInstanceQuery query = runtimeService
.createVariableInstanceQuery()
.processInstanceIdIn(processInstanceId);
VariableInstance variableUser = query
.variableName("userId")
.singleResult();
assertNotNull(variableUser);
assertEquals(userId, variableUser.getValue());
VariableInstance variableCount = query
.variableName("count")
.singleResult();
assertNotNull(variableCount);
assertEquals(5l, variableCount.getValue());
enableAuthorization();
}
示例6: testScriptExecutionListenerExecutesQueryAfterUserCompletesTask
import org.camunda.bpm.engine.task.Task; //导入方法依赖的package包/类
@Deployment
public void testScriptExecutionListenerExecutesQueryAfterUserCompletesTask() {
// given
startProcessInstancesByKey(DEFAULT_PROCESS_KEY, 5);
Task task = selectAnyTask();
String taskId = task.getId();
String processInstanceId = task.getProcessInstanceId();
createGrantAuthorization(TASK, taskId, userId, UPDATE);
// when
taskService.complete(taskId);
// then
disableAuthorization();
VariableInstanceQuery query = runtimeService
.createVariableInstanceQuery()
.processInstanceIdIn(processInstanceId);
VariableInstance variableUser = query
.variableName("userId")
.singleResult();
assertNotNull(variableUser);
assertEquals(userId, variableUser.getValue());
VariableInstance variableCount = query
.variableName("count")
.singleResult();
assertNotNull(variableCount);
assertEquals(5l, variableCount.getValue());
enableAuthorization();
}
示例7: testScriptTaskListenerExecutesQueryAfterUserCompletesTask
import org.camunda.bpm.engine.task.Task; //导入方法依赖的package包/类
@Deployment
public void testScriptTaskListenerExecutesQueryAfterUserCompletesTask() {
// given
startProcessInstancesByKey(DEFAULT_PROCESS_KEY, 5);
Task task = selectAnyTask();
String taskId = task.getId();
String processInstanceId = task.getProcessInstanceId();
createGrantAuthorization(TASK, taskId, userId, UPDATE);
// when
taskService.complete(taskId);
// then
disableAuthorization();
VariableInstanceQuery query = runtimeService
.createVariableInstanceQuery()
.processInstanceIdIn(processInstanceId);
VariableInstance variableUser = query
.variableName("userId")
.singleResult();
assertNotNull(variableUser);
assertEquals(userId, variableUser.getValue());
VariableInstance variableCount = query
.variableName("count")
.singleResult();
assertNotNull(variableCount);
assertEquals(5l, variableCount.getValue());
enableAuthorization();
}
示例8: testScriptConditionExecutesQueryAfterUserCompletesTask
import org.camunda.bpm.engine.task.Task; //导入方法依赖的package包/类
@Deployment
public void testScriptConditionExecutesQueryAfterUserCompletesTask() {
// given
startProcessInstancesByKey(DEFAULT_PROCESS_KEY, 5);
Task task = selectAnyTask();
String taskId = task.getId();
String processInstanceId = task.getProcessInstanceId();
createGrantAuthorization(TASK, taskId, userId, UPDATE);
// when
taskService.complete(taskId);
// then
disableAuthorization();
VariableInstanceQuery query = runtimeService
.createVariableInstanceQuery()
.processInstanceIdIn(processInstanceId);
VariableInstance variableUser = query
.variableName("userId")
.singleResult();
assertNotNull(variableUser);
assertEquals(userId, variableUser.getValue());
VariableInstance variableCount = query
.variableName("count")
.singleResult();
assertNotNull(variableCount);
assertEquals(5l, variableCount.getValue());
enableAuthorization();
}
示例9: testScriptIoMappingExecutesQueryAfterUserCompletesTask
import org.camunda.bpm.engine.task.Task; //导入方法依赖的package包/类
@Deployment
public void testScriptIoMappingExecutesQueryAfterUserCompletesTask() {
// given
startProcessInstancesByKey(DEFAULT_PROCESS_KEY, 5);
Task task = selectAnyTask();
String taskId = task.getId();
String processInstanceId = task.getProcessInstanceId();
createGrantAuthorization(TASK, taskId, userId, UPDATE);
// when
taskService.complete(taskId);
// then
disableAuthorization();
VariableInstanceQuery query = runtimeService
.createVariableInstanceQuery()
.processInstanceIdIn(processInstanceId);
VariableInstance variableUser = query
.variableName("userId")
.singleResult();
assertNotNull(variableUser);
assertEquals(userId, variableUser.getValue());
VariableInstance variableCount = query
.variableName("count")
.singleResult();
assertNotNull(variableCount);
assertEquals(5l, variableCount.getValue());
enableAuthorization();
}
示例10: testInterruptingMessageEventSubProcessEventSubscriptionsInsideCallActivity
import org.camunda.bpm.engine.task.Task; //导入方法依赖的package包/类
@Deployment(resources = {"org/camunda/bpm/engine/test/bpmn/callactivity/CallActivity.testInterruptingEventSubProcessEventSubscriptions.bpmn20.xml",
"org/camunda/bpm/engine/test/bpmn/callactivity/interruptingEventSubProcessEventSubscriptions.bpmn20.xml"})
public void testInterruptingMessageEventSubProcessEventSubscriptionsInsideCallActivity() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("callInterruptingEventSubProcess");
// one task in the call activity subprocess should be active after starting the process instance
TaskQuery taskQuery = taskService.createTaskQuery();
Task taskInsideCallActivity = taskQuery.singleResult();
assertEquals("taskBeforeInterruptingEventSubprocess", taskInsideCallActivity.getTaskDefinitionKey());
// we should have no event subscriptions for the parent process
assertEquals(0, runtimeService.createEventSubscriptionQuery().processInstanceId(processInstance.getId()).count());
// we should have two event subscriptions for the called process instance, one for message and one for signal
String calledProcessInstanceId = taskInsideCallActivity.getProcessInstanceId();
EventSubscriptionQuery eventSubscriptionQuery = runtimeService.createEventSubscriptionQuery().processInstanceId(calledProcessInstanceId);
List<EventSubscription> subscriptions = eventSubscriptionQuery.list();
assertEquals(2, subscriptions.size());
// start the message interrupting event sub process
runtimeService.correlateMessage("newMessage");
Task taskAfterMessageStartEvent = taskQuery.processInstanceId(calledProcessInstanceId).singleResult();
assertEquals("taskAfterMessageStartEvent", taskAfterMessageStartEvent.getTaskDefinitionKey());
// no subscriptions left
assertEquals(0, eventSubscriptionQuery.count());
// Complete the task inside the called process instance
taskService.complete(taskAfterMessageStartEvent.getId());
assertProcessEnded(calledProcessInstanceId);
assertProcessEnded(processInstance.getId());
}
示例11: testInterruptingSignalEventSubProcessEventSubscriptionsInsideCallActivity
import org.camunda.bpm.engine.task.Task; //导入方法依赖的package包/类
@Deployment(resources = {"org/camunda/bpm/engine/test/bpmn/callactivity/CallActivity.testInterruptingEventSubProcessEventSubscriptions.bpmn20.xml",
"org/camunda/bpm/engine/test/bpmn/callactivity/interruptingEventSubProcessEventSubscriptions.bpmn20.xml"})
public void testInterruptingSignalEventSubProcessEventSubscriptionsInsideCallActivity() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("callInterruptingEventSubProcess");
// one task in the call activity subprocess should be active after starting the process instance
TaskQuery taskQuery = taskService.createTaskQuery();
Task taskInsideCallActivity = taskQuery.singleResult();
assertEquals("taskBeforeInterruptingEventSubprocess", taskInsideCallActivity.getTaskDefinitionKey());
// we should have no event subscriptions for the parent process
assertEquals(0, runtimeService.createEventSubscriptionQuery().processInstanceId(processInstance.getId()).count());
// we should have two event subscriptions for the called process instance, one for message and one for signal
String calledProcessInstanceId = taskInsideCallActivity.getProcessInstanceId();
EventSubscriptionQuery eventSubscriptionQuery = runtimeService.createEventSubscriptionQuery().processInstanceId(calledProcessInstanceId);
List<EventSubscription> subscriptions = eventSubscriptionQuery.list();
assertEquals(2, subscriptions.size());
// start the signal interrupting event sub process
runtimeService.signalEventReceived("newSignal");
Task taskAfterSignalStartEvent = taskQuery.processInstanceId(calledProcessInstanceId).singleResult();
assertEquals("taskAfterSignalStartEvent", taskAfterSignalStartEvent.getTaskDefinitionKey());
// no subscriptions left
assertEquals(0, eventSubscriptionQuery.count());
// Complete the task inside the called process instance
taskService.complete(taskAfterSignalStartEvent.getId());
assertProcessEnded(calledProcessInstanceId);
assertProcessEnded(processInstance.getId());
}
示例12: fromEntity
import org.camunda.bpm.engine.task.Task; //导入方法依赖的package包/类
public static TaskDto fromEntity(Task task) {
TaskDto dto = new TaskDto();
dto.id = task.getId();
dto.name = task.getName();
dto.assignee = task.getAssignee();
dto.created = task.getCreateTime();
dto.due = task.getDueDate();
dto.followUp = task.getFollowUpDate();
if (task.getDelegationState() != null) {
dto.delegationState = task.getDelegationState().toString();
}
dto.description = task.getDescription();
dto.executionId = task.getExecutionId();
dto.owner = task.getOwner();
dto.parentTaskId = task.getParentTaskId();
dto.priority = task.getPriority();
dto.processDefinitionId = task.getProcessDefinitionId();
dto.processInstanceId = task.getProcessInstanceId();
dto.taskDefinitionKey = task.getTaskDefinitionKey();
dto.caseDefinitionId = task.getCaseDefinitionId();
dto.caseExecutionId = task.getCaseExecutionId();
dto.caseInstanceId = task.getCaseInstanceId();
dto.suspended = task.isSuspended();
dto.tenantId = task.getTenantId();
try {
dto.formKey = task.getFormKey();
}
catch (BadUserRequestException e) {
// ignore (initializeFormKeys was not called)
}
return dto;
}
示例13: testSubProcessWithNullDataInput
import org.camunda.bpm.engine.task.Task; //导入方法依赖的package包/类
/**
* Test case for handing over a null process variables to a sub process
*/
@Deployment(resources = {
"org/camunda/bpm/engine/test/bpmn/callactivity/CallActivity.testSubProcessDataInputOutput.bpmn20.xml",
"org/camunda/bpm/engine/test/bpmn/callactivity/dataSubProcess.bpmn20.xml"})
public void testSubProcessWithNullDataInput() {
String processInstanceId = runtimeService.startProcessInstanceByKey("subProcessDataInputOutput").getId();
// the variable named "subVariable" is not set on process instance
VariableInstance variable = runtimeService
.createVariableInstanceQuery()
.processInstanceIdIn(processInstanceId)
.variableName("subVariable")
.singleResult();
assertNull(variable);
variable = runtimeService
.createVariableInstanceQuery()
.processInstanceIdIn(processInstanceId)
.variableName("superVariable")
.singleResult();
assertNull(variable);
// the sub process instance is in the task
Task task = taskService.createTaskQuery().singleResult();
assertNotNull(task);
assertEquals("Task in subprocess", task.getName());
// the value of "subVariable" is null
assertNull(taskService.getVariable(task.getId(), "subVariable"));
String subProcessInstanceId = task.getProcessInstanceId();
assertFalse(processInstanceId.equals(subProcessInstanceId));
// the variable "subVariable" is set on the sub process instance
variable = runtimeService
.createVariableInstanceQuery()
.processInstanceIdIn(subProcessInstanceId)
.variableName("subVariable")
.singleResult();
assertNotNull(variable);
assertNull(variable.getValue());
assertEquals("subVariable", variable.getName());
}
示例14: testSubProcessWithNullDataInputAsExpression
import org.camunda.bpm.engine.task.Task; //导入方法依赖的package包/类
/**
* Test case for handing over a null process variables to a sub process
*/
@Deployment(resources = {
"org/camunda/bpm/engine/test/bpmn/callactivity/CallActivity.testSubProcessDataInputOutputAsExpression.bpmn20.xml",
"org/camunda/bpm/engine/test/bpmn/callactivity/dataSubProcess.bpmn20.xml"})
public void testSubProcessWithNullDataInputAsExpression() {
Map<String, Object> params = new HashMap<String, Object>();
params.put("superVariable", null);
String processInstanceId = runtimeService.startProcessInstanceByKey("subProcessDataInputOutput", params).getId();
// the variable named "subVariable" is not set on process instance
VariableInstance variable = runtimeService
.createVariableInstanceQuery()
.processInstanceIdIn(processInstanceId)
.variableName("subVariable")
.singleResult();
assertNull(variable);
variable = runtimeService
.createVariableInstanceQuery()
.processInstanceIdIn(processInstanceId)
.variableName("superVariable")
.singleResult();
assertNotNull(variable);
assertNull(variable.getValue());
// the sub process instance is in the task
Task task = taskService.createTaskQuery().singleResult();
assertNotNull(task);
assertEquals("Task in subprocess", task.getName());
// the value of "subVariable" is null
assertNull(taskService.getVariable(task.getId(), "subVariable"));
String subProcessInstanceId = task.getProcessInstanceId();
assertFalse(processInstanceId.equals(subProcessInstanceId));
// the variable "subVariable" is set on the sub process instance
variable = runtimeService
.createVariableInstanceQuery()
.processInstanceIdIn(subProcessInstanceId)
.variableName("subVariable")
.singleResult();
assertNotNull(variable);
assertNull(variable.getValue());
assertEquals("subVariable", variable.getName());
}
示例15: fromTask
import org.camunda.bpm.engine.task.Task; //导入方法依赖的package包/类
public static HalTask fromTask(Task task) {
HalTask dto = new HalTask();
// task state
dto.id = task.getId();
dto.name = task.getName();
dto.assignee = task.getAssignee();
dto.created = task.getCreateTime();
dto.due = task.getDueDate();
dto.followUp = task.getFollowUpDate();
dto.delegationState = task.getDelegationState();
dto.description = task.getDescription();
dto.executionId = task.getExecutionId();
dto.owner = task.getOwner();
dto.parentTaskId = task.getParentTaskId();
dto.priority = task.getPriority();
dto.processDefinitionId = task.getProcessDefinitionId();
dto.processInstanceId = task.getProcessInstanceId();
dto.taskDefinitionKey = task.getTaskDefinitionKey();
dto.caseDefinitionId = task.getCaseDefinitionId();
dto.caseExecutionId = task.getCaseExecutionId();
dto.caseInstanceId = task.getCaseInstanceId();
dto.suspended = task.isSuspended();
dto.tenantId = task.getTenantId();
try {
dto.formKey = task.getFormKey();
}
catch (BadUserRequestException e) {
// ignore (initializeFormKeys was not called)
}
// links
dto.linker.createLink(REL_SELF, task.getId());
dto.linker.createLink(REL_ASSIGNEE, task.getAssignee());
dto.linker.createLink(REL_OWNER, task.getOwner());
dto.linker.createLink(REL_EXECUTION,task.getExecutionId());
dto.linker.createLink(REL_PARENT_TASK, task.getParentTaskId());
dto.linker.createLink(REL_PROCESS_DEFINITION, task.getProcessDefinitionId());
dto.linker.createLink(REL_PROCESS_INSTANCE, task.getProcessInstanceId());
dto.linker.createLink(REL_CASE_INSTANCE, task.getCaseInstanceId());
dto.linker.createLink(REL_CASE_EXECUTION, task.getCaseExecutionId());
dto.linker.createLink(REL_CASE_DEFINITION, task.getCaseDefinitionId());
dto.linker.createLink(REL_IDENTITY_LINKS, task.getId());
return dto;
}