org.camunda.bpm.engine.delegate.DelegateTask Java Examples
The following examples show how to use
org.camunda.bpm.engine.delegate.DelegateTask.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultHistoryEventProducer.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Override public HistoryEvent createActivityInstanceUpdateEvt(DelegateExecution execution, DelegateTask task) { final ExecutionEntity executionEntity = (ExecutionEntity) execution; // create event instance HistoricActivityInstanceEventEntity evt = loadActivityInstanceEventEntity(executionEntity); // initialize event initActivityInstanceEvent(evt, executionEntity, HistoryEventTypes.ACTIVITY_INSTANCE_UPDATE); // update task assignment if(task != null) { evt.setTaskId(task.getId()); evt.setTaskAssignee(task.getAssignee()); } return evt; }
Example #2
Source File: DelegateExpressionTaskListener.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void notify(DelegateTask delegateTask) { // Note: we can't cache the result of the expression, because the // execution can change: eg. delegateExpression='${mySpringBeanFactory.randomSpringBean()}' VariableScope variableScope = delegateTask.getExecution(); if (variableScope == null) { variableScope = delegateTask.getCaseExecution(); } Object delegate = expression.getValue(variableScope); applyFieldDeclaration(fieldDeclarations, delegate); if (delegate instanceof TaskListener) { try { Context.getProcessEngineConfiguration() .getDelegateInterceptor() .handleInvocation(new TaskListenerInvocation((TaskListener)delegate, delegateTask)); }catch (Exception e) { throw new ProcessEngineException("Exception while invoking TaskListener: "+e.getMessage(), e); } } else { throw new ProcessEngineException("Delegate expression " + expression + " did not resolve to an implementation of " + TaskListener.class ); } }
Example #3
Source File: TaskEvent.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public TaskEvent(DelegateTask delegateTask) { this.assignee = delegateTask.getAssignee(); this.caseDefinitionId = delegateTask.getCaseDefinitionId(); this.caseExecutionId = delegateTask.getCaseExecutionId(); this.caseInstanceId = delegateTask.getCaseInstanceId(); this.createTime = delegateTask.getCreateTime(); this.deleteReason = delegateTask.getDeleteReason(); this.description = delegateTask.getDescription(); this.dueDate = delegateTask.getDueDate(); this.eventName = delegateTask.getEventName(); this.executionId = delegateTask.getExecutionId(); this.followUpDate = delegateTask.getFollowUpDate(); this.id = delegateTask.getId(); this.name = delegateTask.getName(); this.owner = delegateTask.getOwner(); this.priority = delegateTask.getPriority(); this.processDefinitionId = delegateTask.getProcessDefinitionId(); this.processInstanceId = delegateTask.getProcessInstanceId(); this.taskDefinitionKey = delegateTask.getTaskDefinitionKey(); this.tenantId = delegateTask.getTenantId(); }
Example #4
Source File: SelectorBuilderTest.java From camunda-bpm-reactor with Apache License 2.0 | 6 votes |
@Test public void creates_key_for_task() { ProcessDefinition processDefinition = CamundaReactorTestHelper.processDefinition(); final DelegateTask task = mock(DelegateTask.class, RETURNS_DEEP_STUBS); RepositoryService repositoryService = mock(RepositoryService.class); when(repositoryService.getProcessDefinition(processDefinition.getId())).thenReturn(processDefinition); when(task.getProcessEngineServices().getRepositoryService()).thenReturn(repositoryService); when(task.getBpmnModelElementInstance().getElementType().getTypeName()).thenReturn("userTask"); when(task.getProcessDefinitionId()).thenReturn("process:1:1"); when(task.getEventName()).thenReturn("create"); when(task.getTaskDefinitionKey()).thenReturn("task1"); assertThat(SelectorBuilder.selector(task).key()).isEqualTo("/camunda/task/{type}/process/task1/create"); }
Example #5
Source File: TaskEvent.java From camunda-bpm-spring-boot-starter with Apache License 2.0 | 6 votes |
public TaskEvent(DelegateTask delegateTask) { this.assignee = delegateTask.getAssignee(); this.caseDefinitionId = delegateTask.getCaseDefinitionId(); this.caseExecutionId = delegateTask.getCaseExecutionId(); this.caseInstanceId = delegateTask.getCaseInstanceId(); this.createTime = delegateTask.getCreateTime(); this.deleteReason = delegateTask.getDeleteReason(); this.description = delegateTask.getDescription(); this.dueDate = delegateTask.getDueDate(); this.eventName = delegateTask.getEventName(); this.executionId = delegateTask.getExecutionId(); this.followUpDate = delegateTask.getFollowUpDate(); this.id = delegateTask.getId(); this.name = delegateTask.getName(); this.owner = delegateTask.getOwner(); this.priority = delegateTask.getPriority(); this.processDefinitionId = delegateTask.getProcessDefinitionId(); this.processInstanceId = delegateTask.getProcessInstanceId(); this.taskDefinitionKey = delegateTask.getTaskDefinitionKey(); this.tenantId = delegateTask.getTenantId(); }
Example #6
Source File: OSGiEventDistributorTest.java From camunda-bpm-platform-osgi with Apache License 2.0 | 5 votes |
@Test public void notifyTask() { String processDefinitionId = "123"; String currActivityId = "Act1234"; String processInstanceId = "Inst1234"; String executionId = "Exe4711"; String taskId = "Task42"; String taskDefinitionKey = "TaskDef"; String transitionId = "Trans1"; DelegateTask task = mock(DelegateTask.class); when(task.getProcessDefinitionId()).thenReturn(processDefinitionId); when(task.getProcessInstanceId()).thenReturn(processInstanceId); when(task.getExecutionId()).thenReturn(executionId); when(task.getId()).thenReturn(taskId); when(task.getTaskDefinitionKey()).thenReturn(taskDefinitionKey); when(task.getEventName()).thenReturn(TaskListener.EVENTNAME_CREATE); DelegateExecution execution = mock(DelegateExecution.class); when(execution.getCurrentActivityId()).thenReturn(currActivityId); when(execution.getCurrentTransitionId()).thenReturn(transitionId); when(task.getExecution()).thenReturn(execution); EventAdmin eventAdminMock = mock(EventAdmin.class); ArgumentCaptor<Event> eventCaptor = ArgumentCaptor.forClass(Event.class); OSGiEventDistributor distributor = new OSGiEventDistributor(eventAdminMock); distributor.notify(task); verify(eventAdminMock).postEvent(eventCaptor.capture()); Event event = eventCaptor.getValue(); assertThat(event.getTopic(), is(Topics.TASK_EVENT_TOPIC)); assertThat((String) event.getProperty(BusinessProcessEventProperties.ACTIVITY_ID), is(currActivityId)); assertThat((String) event.getProperty(BusinessProcessEventProperties.EXECUTION_ID), is(executionId)); assertThat((String) event.getProperty(BusinessProcessEventProperties.PROCESS_DEFINITION), is(processDefinitionId)); assertThat((String) event.getProperty(BusinessProcessEventProperties.PROCESS_INSTANCE_ID), is(processInstanceId)); assertThat((String) event.getProperty(BusinessProcessEventProperties.TASK_DEFINITION_KEY), is(taskDefinitionKey)); assertThat((String) event.getProperty(BusinessProcessEventProperties.TASK_ID), is(taskId)); String timestamp = (String) event.getProperty(BusinessProcessEventProperties.TIMESTAMP); assertThat(new Date(Long.parseLong(timestamp)), is(beforeOrEqual(new Date()))); assertThat((String) event.getProperty(BusinessProcessEventProperties.TRANSITION_ID), is(transitionId)); assertThat((String) event.getProperty(BusinessProcessEventProperties.TYPE), is(TaskListener.EVENTNAME_CREATE)); }
Example #7
Source File: ClassDelegateTaskListener.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public void notify(DelegateTask delegateTask) { TaskListener taskListenerInstance = getTaskListenerInstance(); try { Context.getProcessEngineConfiguration() .getDelegateInterceptor() .handleInvocation(new TaskListenerInvocation(taskListenerInstance, delegateTask)); }catch (Exception e) { throw new ProcessEngineException("Exception while invoking TaskListener: "+e.getMessage(), e); } }
Example #8
Source File: TestTaskCreateListener.java From camunda-bpm-reactor with Apache License 2.0 | 5 votes |
@Override public void notify(final DelegateTask delegateTask) { calledTime = new Date(); log.info("TestTaskCreateListener does something"); try { Thread.sleep(1); } catch (final InterruptedException e) { } }
Example #9
Source File: MultiTenancyDelegateTaskTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
protected static DelegateTaskAsserter hasTenantId(final String expectedTenantId) { return new DelegateTaskAsserter() { @Override public void doAssert(DelegateTask task) { assertThat(task.getTenantId(), is(expectedTenantId)); } }; }
Example #10
Source File: TaskCompletionListener.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public void notify(DelegateTask delegateTask) { Integer counter = (Integer) delegateTask.getVariable("taskListenerCounter"); if (counter == null) { counter = 0; } delegateTask.setVariable("taskListenerCounter", ++counter); }
Example #11
Source File: FluentTaskListenerMock.java From camunda-bpm-mockito with Apache License 2.0 | 5 votes |
@Override public void onExecutionThrowBpmnError(final BpmnError bpmnError) { doAnswer(new TaskListener() { @Override public void notify(final DelegateTask delegateTask) { throw bpmnError; } }); }
Example #12
Source File: DelegateTaskTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Override public void notify(DelegateTask delegateTask) { Date followUpDate = delegateTask.getFollowUpDate(); assertThat(followUpDate, notNullValue()); delegateTask.setVariable("followUp", followUpDate); }
Example #13
Source File: DelegateTaskFake.java From camunda-bpm-mockito with Apache License 2.0 | 5 votes |
private static Set<String> linkIds(DelegateTask task, Function<IdentityLink, String> extract, String type) { return Optional.ofNullable(task.getCandidates()).orElseGet(HashSet::new) .stream() .filter(link -> type == null || type.equals(link.getType())) .map(extract) .filter(Objects::nonNull) .collect(Collectors.toSet()); }
Example #14
Source File: __class-name-prefix__TaskListener.java From camunda-archetypes with Apache License 2.0 | 5 votes |
@Override public void notify(DelegateTask task) { LOGGER.info("Event '" + task.getEventName() + "' received by Task Listener for Task:" + " activityId=" + task.getTaskDefinitionKey() + ", name='" + task.getName() + "'" + ", taskId=" + task.getId() + ", assignee='" + task.getAssignee() + "'" + ", candidateGroups='" + task.getCandidates() + "'"); }
Example #15
Source File: CdiEventListener.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public void notify(DelegateTask task) { // test whether cdi is setup correctly. (if not, just do not deliver the event) if (!testCdiSetup()) { return; } BusinessProcessEvent event = createEvent(task); Annotation[] qualifiers = getQualifiers(event); getBeanManager().fireEvent(event, qualifiers); }
Example #16
Source File: CdiEventListener.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
protected BusinessProcessEvent createEvent(DelegateTask task) { ExecutionContext executionContext = Context.getExecutionContext(); ProcessDefinitionEntity processDefinition = null; if (executionContext != null) { processDefinition = executionContext.getProcessDefinition(); } // map type String eventName = task.getEventName(); BusinessProcessEventType type = null; if (TaskListener.EVENTNAME_CREATE.equals(eventName)) { type = BusinessProcessEventType.CREATE_TASK; } else if (TaskListener.EVENTNAME_ASSIGNMENT.equals(eventName)) { type = BusinessProcessEventType.ASSIGN_TASK; } else if (TaskListener.EVENTNAME_COMPLETE.equals(eventName)) { type = BusinessProcessEventType.COMPLETE_TASK; } else if (TaskListener.EVENTNAME_UPDATE.equals(eventName)) { type = BusinessProcessEventType.UPDATE_TASK; } else if (TaskListener.EVENTNAME_DELETE.equals(eventName)) { type = BusinessProcessEventType.DELETE_TASK; } return new CdiBusinessProcessEvent(task, processDefinition, type, ClockUtil.getCurrentTime()); }
Example #17
Source File: CdiBusinessProcessEvent.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public CdiBusinessProcessEvent(DelegateTask task, ProcessDefinitionEntity processDefinition, BusinessProcessEventType type, Date timeStamp) { this.activityId = null; this.transitionName = null; this.processInstanceId = task.getProcessInstanceId(); this.executionId = task.getExecutionId(); this.type = type; this.timeStamp = timeStamp; this.processDefinition = processDefinition; this.delegateTask = task; }
Example #18
Source File: ActivityInstanceUpdateListener.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
protected HistoryEvent createHistoryEvent(DelegateTask task, ExecutionEntity execution) { ensureHistoryLevelInitialized(); if(historyLevel.isHistoryEventProduced(HistoryEventTypes.ACTIVITY_INSTANCE_UPDATE, execution)) { return eventProducer.createActivityInstanceUpdateEvt(execution, task); } else { return null; } }
Example #19
Source File: MyDelegationService.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
public void logInstancesCount(DelegateTask task) { logInstancesCount(task.getProcessEngineServices()); }
Example #20
Source File: AbstractListenerTestHelper.java From camunda-bpm-reactor with Apache License 2.0 | 4 votes |
public static DelegateTask delegateTask() { return delegateTask("task1", "process:1:1", "create"); }
Example #21
Source File: TaskListenerProcessEngineServicesAccessTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
public void notify(DelegateTask execution) { assertCanPerformQuery(execution.getProcessEngineServices()); }
Example #22
Source File: OSGiEventDistributor.java From camunda-bpm-platform-osgi with Apache License 2.0 | 4 votes |
private Event createEvent(DelegateTask delegateTask) { Dictionary<String, String> properties = new Hashtable<String, String>(); BusinessProcessEventPropertiesFiller.fillDictionary(properties, delegateTask); return new Event(Topics.TASK_EVENT_TOPIC, properties); }
Example #23
Source File: MyTaskListener.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
public void calledInExpression(DelegateTask task, String eventName) { task.setVariable("calledInExpression", task.getName() + "-" + eventName); }
Example #24
Source File: BlueprintELResolverTest.java From camunda-bpm-platform-osgi with Apache License 2.0 | 4 votes |
@Override public void notify(DelegateTask delegateTask) { }
Example #25
Source File: DefaultHistoryEventProducer.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
protected HistoricTaskInstanceEventEntity newTaskInstanceEventEntity(DelegateTask task) { return new HistoricTaskInstanceEventEntity(); }
Example #26
Source File: SetBusinessKeyListener.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Override public void notify(DelegateTask delegateTask) { DelegateExecution execution = delegateTask.getExecution(); String newKeyValue = (String) execution.getVariable(BUSINESS_KEY_VARIABLE); execution.setProcessBusinessKey(newKeyValue); }
Example #27
Source File: MyTaskListenerBean.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
public void notify(DelegateTask delegateTask) { delegateTask.getExecution().setVariable("taskListenerVar", "working"); if (someField!=null) { delegateTask.getExecution().setVariable("taskListenerField", someField.getValue(delegateTask)); } }
Example #28
Source File: ProcessDataLoggingContextTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Override public void notify(DelegateTask delegateTask) { throw new IllegalArgumentException("I am failing!"); }
Example #29
Source File: TestEventCaptor.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT, fallbackExecution = true) public void onTransactionalEvent(DelegateTask event) { transactionTaskEvents.push(new TaskEvent(event)); }
Example #30
Source File: ExpressionTaskListener.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
public void notify(DelegateTask delegateTask) { expression.getValue(delegateTask); }