Java Code Examples for org.activiti.bpmn.model.ActivitiListener#getImplementation()

The following examples show how to use org.activiti.bpmn.model.ActivitiListener#getImplementation() . 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: ExecutionListenerValidator.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected void validateListeners(Process process, BaseElement baseElement, List<ActivitiListener> listeners, List<ValidationError> errors) {
  if (listeners != null) {
    for (ActivitiListener listener : listeners) {
      if (listener.getImplementation() == null || listener.getImplementationType() == null) {
        addError(errors, Problems.EXECUTION_LISTENER_IMPLEMENTATION_MISSING, process, baseElement, "Element 'class' or 'expression' is mandatory on executionListener");
      }
      if (listener.getOnTransaction() != null && ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION.equals(listener.getImplementationType())) {
        addError(errors, Problems.EXECUTION_LISTENER_INVALID_IMPLEMENTATION_TYPE, process, baseElement, "Expression cannot be used when using 'onTransaction'");
      }
    }
  }
}
 
Example 2
Source File: UserTaskValidator.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
protected void executeValidation(BpmnModel bpmnModel, Process process, List<ValidationError> errors) {
  List<UserTask> userTasks = process.findFlowElementsOfType(UserTask.class);
  for (UserTask userTask : userTasks) {
    if (userTask.getTaskListeners() != null) {
      for (ActivitiListener listener : userTask.getTaskListeners()) {
        if (listener.getImplementation() == null || listener.getImplementationType() == null) {
          addError(errors, Problems.USER_TASK_LISTENER_IMPLEMENTATION_MISSING, process, userTask, "Element 'class' or 'expression' is mandatory on executionListener");
        }
      }
    }
  }
}
 
Example 3
Source File: SyncProcessCmd.java    From lemon with Apache License 2.0 5 votes vote down vote up
/**
 * 配置监听器.
 */
public void processListener(List<ActivitiListener> activitiListeners,
        BpmConfNode bpmConfNode) {
    Map<String, Integer> eventTypeMap = new HashMap<String, Integer>();
    eventTypeMap.put("start", 0);
    eventTypeMap.put("end", 1);
    eventTypeMap.put("take", 2);
    eventTypeMap.put("create", 3);
    eventTypeMap.put("assignment", 4);
    eventTypeMap.put("complete", 5);
    eventTypeMap.put("delete", 6);

    BpmConfListenerManager bpmConfListenerManager = getBpmConfListenerManager();

    for (ActivitiListener activitiListener : activitiListeners) {
        String value = activitiListener.getImplementation();
        int type = eventTypeMap.get(activitiListener.getEvent());
        BpmConfListener bpmConfListener = bpmConfListenerManager
                .findUnique(
                        "from BpmConfListener where value=? and type=? and status=0 and bpmConfNode=?",
                        value, type, bpmConfNode);

        if (bpmConfListener == null) {
            bpmConfListener = new BpmConfListener();
            bpmConfListener.setValue(value);
            bpmConfListener.setType(type);
            bpmConfListener.setBpmConfNode(bpmConfNode);
            bpmConfListenerManager.save(bpmConfListener);
        }
    }
}
 
Example 4
Source File: DefaultListenerFactory.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public TaskListener createClassDelegateTaskListener(ActivitiListener activitiListener) {
  return new ClassDelegate(activitiListener.getImplementation(), createFieldDeclarations(activitiListener.getFieldExtensions()));
}
 
Example 5
Source File: DefaultListenerFactory.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public ExecutionListener createClassDelegateExecutionListener(ActivitiListener activitiListener) {
  return new ClassDelegate(activitiListener.getImplementation(), createFieldDeclarations(activitiListener.getFieldExtensions()));
}