Java Code Examples for org.camunda.bpm.engine.delegate.DelegateExecution#getEventName()

The following examples show how to use org.camunda.bpm.engine.delegate.DelegateExecution#getEventName() . 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: CdiEventListener.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected BusinessProcessEvent createEvent(DelegateExecution execution) {
  ProcessDefinition processDefinition = Context.getExecutionContext().getProcessDefinition();

  // map type
  String eventName = execution.getEventName();
  BusinessProcessEventType type = null;
  if(ExecutionListener.EVENTNAME_START.equals(eventName)) {
    type = BusinessProcessEventType.START_ACTIVITY;
  } else if(ExecutionListener.EVENTNAME_END.equals(eventName)) {
    type = BusinessProcessEventType.END_ACTIVITY;
  } else if(ExecutionListener.EVENTNAME_TAKE.equals(eventName)) {
    type = BusinessProcessEventType.TAKE;
  }

  return new CdiBusinessProcessEvent(execution.getCurrentActivityId(), execution.getCurrentTransitionId(), processDefinition, execution, type, ClockUtil.getCurrentTime());
}
 
Example 2
Source File: DelegateEvent.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public static DelegateEvent fromExecution(DelegateExecution delegateExecution) {
  DelegateEvent event = new DelegateEvent();

  event.activityInstanceId = delegateExecution.getActivityInstanceId();
  event.businessKey = delegateExecution.getBusinessKey();
  event.currentActivityId = delegateExecution.getCurrentActivityId();
  event.currentActivityName = delegateExecution.getCurrentActivityName();
  event.currentTransitionId = delegateExecution.getCurrentTransitionId();
  event.eventName = delegateExecution.getEventName();
  event.id = delegateExecution.getId();
  event.parentActivityInstanceId = delegateExecution.getParentActivityInstanceId();
  event.parentId = delegateExecution.getParentId();
  event.processBusinessKey = delegateExecution.getProcessBusinessKey();
  event.processDefinitionId = delegateExecution.getProcessDefinitionId();
  event.processInstanceId = delegateExecution.getProcessInstanceId();
  event.tenantId = delegateExecution.getTenantId();
  event.variableScopeKey = delegateExecution.getVariableScopeKey();

  return event;
}
 
Example 3
Source File: ReadLocalVariableListener.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Override
public void notify(DelegateExecution execution) throws Exception {
  if (!execution.hasVariableLocal(variableName)) {
    return;
  }

  Object value = execution.getVariableLocal(variableName);

  VariableEvent event = new VariableEvent();
  event.variableName = variableName;
  event.variableValue = value;
  event.eventName = execution.getEventName();
  event.activityInstanceId = execution.getActivityInstanceId();

  variableEvents.add(event);
}
 
Example 4
Source File: ExecutionEvent.java    From camunda-bpm-spring-boot-starter with Apache License 2.0 5 votes vote down vote up
public ExecutionEvent(DelegateExecution delegateExecution) {
  this.activityInstanceId = delegateExecution.getActivityInstanceId();
  this.businessKey = delegateExecution.getBusinessKey();
  this.currentActivityId = delegateExecution.getCurrentActivityId();
  this.currentActivityName = delegateExecution.getCurrentActivityName();
  this.currentTransitionId = delegateExecution.getCurrentTransitionId();
  this.eventName = delegateExecution.getEventName();
  this.id = delegateExecution.getId();
  this.parentActivityInstanceId = delegateExecution.getParentActivityInstanceId();
  this.parentId = delegateExecution.getParentId();
  this.processBusinessKey = delegateExecution.getProcessBusinessKey();
  this.processDefinitionId = delegateExecution.getProcessDefinitionId();
  this.processInstanceId = delegateExecution.getProcessInstanceId();
  this.tenantId = delegateExecution.getTenantId();
}
 
Example 5
Source File: ExecutionEvent.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public ExecutionEvent(DelegateExecution delegateExecution) {
  this.activityInstanceId = delegateExecution.getActivityInstanceId();
  this.businessKey = delegateExecution.getBusinessKey();
  this.currentActivityId = delegateExecution.getCurrentActivityId();
  this.currentActivityName = delegateExecution.getCurrentActivityName();
  this.currentTransitionId = delegateExecution.getCurrentTransitionId();
  this.eventName = delegateExecution.getEventName();
  this.id = delegateExecution.getId();
  this.parentActivityInstanceId = delegateExecution.getParentActivityInstanceId();
  this.parentId = delegateExecution.getParentId();
  this.processBusinessKey = delegateExecution.getProcessBusinessKey();
  this.processDefinitionId = delegateExecution.getProcessDefinitionId();
  this.processInstanceId = delegateExecution.getProcessInstanceId();
  this.tenantId = delegateExecution.getTenantId();
}
 
Example 6
Source File: ProcessApplicationEventListenerTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Deployment
public void testIntermediateTimerEvent() {

  // given
  final List<String> timerEvents = new ArrayList<String>();

  EmbeddedProcessApplication processApplication = new EmbeddedProcessApplication() {
    public ExecutionListener getExecutionListener() {
      return new ExecutionListener() {
        public void notify(DelegateExecution delegateExecution) {
          String currentActivityId = delegateExecution.getCurrentActivityId();
          String eventName = delegateExecution.getEventName();
          if ("timer".equals(currentActivityId) &&
              (ExecutionListener.EVENTNAME_START.equals(eventName) || ExecutionListener.EVENTNAME_END.equals(eventName))) {
            timerEvents.add(delegateExecution.getEventName());
          }
        }
      };
    }
  };

  // register app so that it is notified about events
  managementService.registerProcessApplication(deploymentId, processApplication.getReference());

  // when
  runtimeService.startProcessInstanceByKey("process");
  String jobId = managementService.createJobQuery().singleResult().getId();
  managementService.executeJob(jobId);

  // then
  assertEquals(2, timerEvents.size());

  // "start" event listener
  assertEquals(ExecutionListener.EVENTNAME_START, timerEvents.get(0));

  // "end" event listener
  assertEquals(ExecutionListener.EVENTNAME_END, timerEvents.get(1));
}
 
Example 7
Source File: ProcessApplicationEventListenerTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Deployment
public void testIntermediateSignalEvent() {

  // given
  final List<String> timerEvents = new ArrayList<String>();

  EmbeddedProcessApplication processApplication = new EmbeddedProcessApplication() {
    public ExecutionListener getExecutionListener() {
      return new ExecutionListener() {
        public void notify(DelegateExecution delegateExecution) {
          String currentActivityId = delegateExecution.getCurrentActivityId();
          String eventName = delegateExecution.getEventName();
          if ("signal".equals(currentActivityId) &&
              (ExecutionListener.EVENTNAME_START.equals(eventName) || ExecutionListener.EVENTNAME_END.equals(eventName))) {
            timerEvents.add(delegateExecution.getEventName());
          }
        }
      };
    }
  };

  // register app so that it is notified about events
  managementService.registerProcessApplication(deploymentId, processApplication.getReference());

  // when
  runtimeService.startProcessInstanceByKey("process");
  runtimeService.signalEventReceived("abort");

  // then
  assertEquals(2, timerEvents.size());

  // "start" event listener
  assertEquals(ExecutionListener.EVENTNAME_START, timerEvents.get(0));

  // "end" event listener
  assertEquals(ExecutionListener.EVENTNAME_END, timerEvents.get(1));
}
 
Example 8
Source File: IntermediateEventExecutionListener.java    From camunda-bpm-process-test-coverage with Apache License 2.0 4 votes vote down vote up
@Override
public void notify(DelegateExecution execution) throws Exception {

    final CoveredFlowNode coveredFlowNode = createCoveredFlowNode(execution);

    final String eventName = execution.getEventName();
    if (eventName.equals(ExecutionListener.EVENTNAME_START)) {

        coverageTestRunState.addCoveredElement(coveredFlowNode);

    } else if (eventName.equals(ExecutionListener.EVENTNAME_END)) {

        coverageTestRunState.endCoveredElement(coveredFlowNode);
    }

}
 
Example 9
Source File: TestExecutionListener.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public void notify(DelegateExecution execution) throws Exception {
  String counterKey = execution.getCurrentActivityId() + "-" +execution.getEventName();
  collectedEvents.add(counterKey);
}