Java Code Examples for org.activiti.engine.impl.persistence.entity.ExecutionEntity#getEventSubscriptions()

The following examples show how to use org.activiti.engine.impl.persistence.entity.ExecutionEntity#getEventSubscriptions() . 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: BoundarySignalEventActivityBehavior.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Override
public void trigger(DelegateExecution execution, String triggerName, Object triggerData) {
  ExecutionEntity executionEntity = (ExecutionEntity) execution;
  BoundaryEvent boundaryEvent = (BoundaryEvent) execution.getCurrentFlowElement();

  if (boundaryEvent.isCancelActivity()) {
    String eventName = null;
    if (signal != null) {
      eventName = signal.getName();
    } else {
      eventName = signalEventDefinition.getSignalRef();
    }

    EventSubscriptionEntityManager eventSubscriptionEntityManager = Context.getCommandContext().getEventSubscriptionEntityManager();
    List<EventSubscriptionEntity> eventSubscriptions = executionEntity.getEventSubscriptions();
    for (EventSubscriptionEntity eventSubscription : eventSubscriptions) {
      if (eventSubscription instanceof SignalEventSubscriptionEntity && eventSubscription.getEventName().equals(eventName)) {

        eventSubscriptionEntityManager.delete(eventSubscription);
      }
    }
  }

  super.trigger(executionEntity, triggerName, triggerData);
}
 
Example 2
Source File: BoundaryCompensateEventActivityBehavior.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Override
public void trigger(DelegateExecution execution, String triggerName, Object triggerData) {
  ExecutionEntity executionEntity = (ExecutionEntity) execution;
  BoundaryEvent boundaryEvent = (BoundaryEvent) execution.getCurrentFlowElement();

  if (boundaryEvent.isCancelActivity()) {
    EventSubscriptionEntityManager eventSubscriptionEntityManager = Context.getCommandContext().getEventSubscriptionEntityManager();
    List<EventSubscriptionEntity> eventSubscriptions = executionEntity.getEventSubscriptions();
    for (EventSubscriptionEntity eventSubscription : eventSubscriptions) {
      if (eventSubscription instanceof CompensateEventSubscriptionEntity && eventSubscription.getActivityId().equals(compensateEventDefinition.getActivityRef())) {
        eventSubscriptionEntityManager.delete(eventSubscription);
      }
    }
  }

  super.trigger(executionEntity, triggerName, triggerData);
}
 
Example 3
Source File: BoundaryMessageEventActivityBehavior.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Override
public void trigger(DelegateExecution execution, String triggerName, Object triggerData) {
  ExecutionEntity executionEntity = (ExecutionEntity) execution;
  BoundaryEvent boundaryEvent = (BoundaryEvent) execution.getCurrentFlowElement();

  if (boundaryEvent.isCancelActivity()) {
    EventSubscriptionEntityManager eventSubscriptionEntityManager = Context.getCommandContext().getEventSubscriptionEntityManager();
    List<EventSubscriptionEntity> eventSubscriptions = executionEntity.getEventSubscriptions();
    for (EventSubscriptionEntity eventSubscription : eventSubscriptions) {
      if (eventSubscription instanceof MessageEventSubscriptionEntity && eventSubscription.getEventName().equals(messageEventDefinition.getMessageRef())) {

        eventSubscriptionEntityManager.delete(eventSubscription);
      }
    }
  }

  super.trigger(executionEntity, triggerName, triggerData);
}
 
Example 4
Source File: IntermediateCatchSignalEventActivityBehavior.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
protected ExecutionEntity deleteSignalEventSubscription(DelegateExecution execution) {
  ExecutionEntity executionEntity = (ExecutionEntity) execution;

  String eventName = null;
  if (signal != null) {
    eventName = signal.getName();
  } else {
    eventName = signalEventDefinition.getSignalRef();
  }

  EventSubscriptionEntityManager eventSubscriptionEntityManager = Context.getCommandContext().getEventSubscriptionEntityManager();
  List<EventSubscriptionEntity> eventSubscriptions = executionEntity.getEventSubscriptions();
  for (EventSubscriptionEntity eventSubscription : eventSubscriptions) {
    if (eventSubscription instanceof SignalEventSubscriptionEntity && eventSubscription.getEventName().equals(eventName)) {

      eventSubscriptionEntityManager.delete(eventSubscription);
    }
  }
  return executionEntity;
}
 
Example 5
Source File: IntermediateCatchMessageEventActivityBehavior.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected ExecutionEntity deleteMessageEventSubScription(DelegateExecution execution) {
  ExecutionEntity executionEntity = (ExecutionEntity) execution;
  EventSubscriptionEntityManager eventSubscriptionEntityManager = Context.getCommandContext().getEventSubscriptionEntityManager();
  List<EventSubscriptionEntity> eventSubscriptions = executionEntity.getEventSubscriptions();
  for (EventSubscriptionEntity eventSubscription : eventSubscriptions) {
    if (eventSubscription instanceof MessageEventSubscriptionEntity && eventSubscription.getEventName().equals(messageEventDefinition.getMessageRef())) {

      eventSubscriptionEntityManager.delete(eventSubscription);
    }
  }
  return executionEntity;
}
 
Example 6
Source File: EventSubProcessMessageStartEventActivityBehavior.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
public void trigger(DelegateExecution execution, String triggerName, Object triggerData) {
  CommandContext commandContext = Context.getCommandContext();
  ExecutionEntityManager executionEntityManager = commandContext.getExecutionEntityManager();
  ExecutionEntity executionEntity = (ExecutionEntity) execution;
  
  StartEvent startEvent = (StartEvent) execution.getCurrentFlowElement();
  if (startEvent.isInterrupting()) {  
    List<ExecutionEntity> childExecutions = executionEntityManager.findChildExecutionsByParentExecutionId(executionEntity.getParentId());
    for (ExecutionEntity childExecution : childExecutions) {
      if (childExecution.getId().equals(executionEntity.getId()) == false) {
        executionEntityManager.deleteExecutionAndRelatedData(childExecution, 
            DeleteReason.EVENT_SUBPROCESS_INTERRUPTING + "(" + startEvent.getId() + ")", false);
      }
    }
  }
  
  EventSubscriptionEntityManager eventSubscriptionEntityManager = Context.getCommandContext().getEventSubscriptionEntityManager();
  List<EventSubscriptionEntity> eventSubscriptions = executionEntity.getEventSubscriptions();
  for (EventSubscriptionEntity eventSubscription : eventSubscriptions) {
    if (eventSubscription instanceof MessageEventSubscriptionEntity && eventSubscription.getEventName().equals(messageEventDefinition.getMessageRef())) {

      eventSubscriptionEntityManager.delete(eventSubscription);
    }
  }
  
  executionEntity.setCurrentFlowElement((SubProcess) executionEntity.getCurrentFlowElement().getParentContainer());
  executionEntity.setScope(true);
  
  ExecutionEntity outgoingFlowExecution = executionEntityManager.createChildExecution(executionEntity);
  outgoingFlowExecution.setCurrentFlowElement(startEvent);
  
  leave(outgoingFlowExecution);
}