Java Code Examples for org.activiti.bpmn.model.BoundaryEvent#isCancelActivity()

The following examples show how to use org.activiti.bpmn.model.BoundaryEvent#isCancelActivity() . 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: CompensateEventDefinitionParseHandler.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected void executeParse(BpmnParse bpmnParse, CompensateEventDefinition eventDefinition) {
  
  ScopeImpl scope = bpmnParse.getCurrentScope();
  if(StringUtils.isNotEmpty(eventDefinition.getActivityRef())) {
    if(scope.findActivity(eventDefinition.getActivityRef()) == null) {
      logger.warn("Invalid attribute value for 'activityRef': no activity with id '" + eventDefinition.getActivityRef() +
          "' in current scope " + scope.getId());
    }
  }
  
  org.activiti5.engine.impl.bpmn.parser.CompensateEventDefinition compensateEventDefinition = 
          new org.activiti5.engine.impl.bpmn.parser.CompensateEventDefinition();
  compensateEventDefinition.setActivityRef(eventDefinition.getActivityRef());
  compensateEventDefinition.setWaitForCompletion(eventDefinition.isWaitForCompletion());
  
  ActivityImpl activity = bpmnParse.getCurrentActivity();
  if (bpmnParse.getCurrentFlowElement() instanceof ThrowEvent) {
    
    activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createIntermediateThrowCompensationEventActivityBehavior((ThrowEvent) bpmnParse.getCurrentFlowElement(), compensateEventDefinition));
    
  } else if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent) {
   
    BoundaryEvent boundaryEvent = (BoundaryEvent) bpmnParse.getCurrentFlowElement();
    boolean interrupting = boundaryEvent.isCancelActivity();
    
    activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createBoundaryEventActivityBehavior(boundaryEvent, interrupting, activity));
    activity.setProperty("type", "compensationBoundaryCatch");
    
  } else {
    
    // What to do?
    
  }
  
}