Java Code Examples for org.activiti.engine.delegate.event.ActivitiEvent#getType()

The following examples show how to use org.activiti.engine.delegate.event.ActivitiEvent#getType() . 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: ActivitiEventDispatcherImpl.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Override
public void dispatchEvent(ActivitiEvent event) {
  if (enabled) {
    eventSupport.dispatchEvent(event);
  }

  if (event.getType() == ActivitiEventType.ENTITY_DELETED && event instanceof ActivitiEntityEvent) {
    ActivitiEntityEvent entityEvent = (ActivitiEntityEvent) event;
    if (entityEvent.getEntity() instanceof ProcessDefinition) {
      // process definition deleted event doesn't need to be dispatched to event listeners
      return;
    }
  }
  
  // Try getting hold of the Process definition, based on the process definition key, if a context is active
  CommandContext commandContext = Context.getCommandContext();
  if (commandContext != null) {
    BpmnModel bpmnModel = extractBpmnModelFromEvent(event);
    if (bpmnModel != null) {
      ((ActivitiEventSupport) bpmnModel.getEventSupport()).dispatchEvent(event);
    }
  }
  
}
 
Example 2
Source File: CancelCallActivityByMessageTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Override
public void onEvent(ActivitiEvent event) {
	switch (event.getType()) {
	case ENTITY_CREATED:
		ActivitiEntityEvent entityEvent = (ActivitiEntityEvent) event;
		if (entityEvent.getEntity() instanceof ExecutionEntity) {
			eventsReceived.add(event);
		}
		break;
	case ACTIVITY_STARTED:
	case ACTIVITY_COMPLETED:
	case ACTIVITY_CANCELLED:
	case TASK_CREATED:
	case TASK_COMPLETED:
	case PROCESS_STARTED:
	case PROCESS_COMPLETED:
	case PROCESS_CANCELLED:
		eventsReceived.add(event);
		break;
	default:
		break;
	}
}
 
Example 3
Source File: SkipEventListener.java    From lemon with Apache License 2.0 6 votes vote down vote up
public void onEvent(ActivitiEvent event) {
    if (!(event instanceof ActivitiEntityEventImpl)) {
        return;
    }

    ActivitiEntityEventImpl activitiEntityEventImpl = (ActivitiEntityEventImpl) event;
    Object entity = activitiEntityEventImpl.getEntity();

    if (!(entity instanceof TaskEntity)) {
        return;
    }

    TaskEntity taskEntity = (TaskEntity) entity;

    try {
        switch (event.getType()) {
        case TASK_CREATED:
            logger.debug("create : {}", taskEntity.getId());
            this.onCreate(taskEntity);

            break;
        }
    } catch (Exception ex) {
        logger.error(ex.getMessage(), ex);
    }
}
 
Example 4
Source File: AutoCompleteFirstTaskEventListener.java    From lemon with Apache License 2.0 6 votes vote down vote up
public void onEvent(ActivitiEvent event) {
    if (!(event instanceof ActivitiEntityEventImpl)) {
        return;
    }

    ActivitiEntityEventImpl activitiEntityEventImpl = (ActivitiEntityEventImpl) event;
    Object entity = activitiEntityEventImpl.getEntity();

    if (!(entity instanceof TaskEntity)) {
        return;
    }

    TaskEntity taskEntity = (TaskEntity) entity;

    try {
        switch (event.getType()) {
        case TASK_CREATED:
            logger.debug("create : {}", taskEntity.getId());
            this.onCreate(taskEntity);

            break;
        }
    } catch (Exception ex) {
        logger.error(ex.getMessage(), ex);
    }
}
 
Example 5
Source File: TestActivitiActivityEventListener.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
public void onEvent(ActivitiEvent event) {
  if (event instanceof ActivitiActivityEvent) {
    if (!ignoreRawActivityEvents || (event.getType() != ActivitiEventType.ACTIVITY_STARTED && event.getType() != ActivitiEventType.ACTIVITY_COMPLETED)) {
      eventsReceived.add(event);
    }
  }
}
 
Example 6
Source File: TestActivitiActivityEventListener.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
public void onEvent(ActivitiEvent event) {
	if(event instanceof ActivitiActivityEvent) {
		if(!ignoreRawActivityEvents || (event.getType() != ActivitiEventType.ACTIVITY_STARTED && 
				event.getType() != ActivitiEventType.ACTIVITY_COMPLETED)) {
			eventsReceived.add(event);
		}
	}
}
 
Example 7
Source File: VariableCreateListener.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
public void onEvent(ActivitiEvent event) {
    switch (event.getType()) {

        case VARIABLE_CREATED:
            ActivitiVariableEvent variableEvent = (ActivitiVariableEvent) event;
            System.out.println("创建了变量: " + variableEvent.getVariableName() + ", 值:" + variableEvent.getVariableValue());
            break;

        default:
            System.out.println("Event received: " + event.getType());
    }
}
 
Example 8
Source File: FunctionEventListener.java    From lemon with Apache License 2.0 5 votes vote down vote up
@Override
public void onEvent(ActivitiEvent event) {
    switch (event.getType()) {
    case ACTIVITY_STARTED:
        this.onActivityStart((ActivitiActivityEvent) event);

        break;

    case ACTIVITY_COMPLETED:
        this.onActivityEnd((ActivitiActivityEvent) event);

        break;

    case TASK_COMPLETED:
        this.onTaskCompleted((ActivitiEntityEvent) event);

        break;

    case PROCESS_COMPLETED:
        this.onProcessCompleted((ActivitiEntityEvent) event);

        break;

    case PROCESS_CANCELLED:
        this.onProcessCancelled((ActivitiCancelledEvent) event);

        break;

    default:
        logger.debug("Event received: {}", event.getType());
    }
}
 
Example 9
Source File: HumanTaskEventListener.java    From lemon with Apache License 2.0 4 votes vote down vote up
public void onEvent(ActivitiEvent event) {
    if (!(event instanceof ActivitiEntityEventImpl)) {
        return;
    }

    ActivitiEntityEventImpl activitiEntityEventImpl = (ActivitiEntityEventImpl) event;
    Object entity = activitiEntityEventImpl.getEntity();

    if (!(entity instanceof TaskEntity)) {
        return;
    }

    TaskEntity taskEntity = (TaskEntity) entity;

    try {
        switch (event.getType()) {
        case TASK_CREATED:
            logger.debug("create : {}", taskEntity.getId());
            this.onCreate(taskEntity);

            break;

        case TASK_ASSIGNED:
            logger.debug("assign : {}", taskEntity.getId());
            this.onAssign(taskEntity);

            break;

        case TASK_COMPLETED:
            logger.debug("complete : {}", taskEntity.getId());
            this.onComplete(taskEntity);

            break;

        case ENTITY_DELETED:
            logger.debug("delete : {}", taskEntity.getId());
            this.onDelete(taskEntity);

            break;

        default:
            logger.debug("{} : {}", event.getType(), taskEntity.getId());
        }
    } catch (Exception ex) {
        logger.error(ex.getMessage(), ex);
    }
}