org.activiti.bpmn.model.ActivitiListener Java Examples

The following examples show how to use org.activiti.bpmn.model.ActivitiListener. 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: ListenerNotificationHelper.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public void executeTaskListeners(UserTask userTask, TaskEntity taskEntity, String eventType) {
  for (ActivitiListener activitiListener : userTask.getTaskListeners()) {
    String event = activitiListener.getEvent();
    if (event.equals(eventType) || event.equals(TaskListener.EVENTNAME_ALL_EVENTS)) {
      BaseTaskListener taskListener = createTaskListener(activitiListener);

      if (activitiListener.getOnTransaction() != null) {
        planTransactionDependentTaskListener(taskEntity.getExecution(), (TransactionDependentTaskListener) taskListener, activitiListener);
      } else {
        taskEntity.setEventName(eventType);
        taskEntity.setCurrentActivitiListener(activitiListener);
        try {
          Context.getProcessEngineConfiguration().getDelegateInterceptor()
            .handleInvocation(new TaskListenerInvocation((TaskListener) taskListener, taskEntity));
        } catch (Exception e) {
          throw new ActivitiException("Exception while invoking TaskListener: " + e.getMessage(), e);
        } finally {
          taskEntity.setEventName(null);
          taskEntity.setCurrentActivitiListener(null);
        }
      }
    }
  }
}
 
Example #2
Source File: AsyncEndEventConverterTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
private void validateModel(BpmnModel model) {
  FlowElement flowElement = model.getMainProcess().getFlowElement("endEvent");
  assertNotNull(flowElement);
  assertTrue(flowElement instanceof EndEvent);
  assertEquals("endEvent", flowElement.getId());
  EndEvent endEvent = (EndEvent) flowElement;
  assertEquals("endEvent", endEvent.getId());
  assertTrue(endEvent.isAsynchronous());
  
  List<ActivitiListener> listeners = endEvent.getExecutionListeners();
  assertEquals(1, listeners.size());
  ActivitiListener listener = listeners.get(0);
  assertTrue(ImplementationType.IMPLEMENTATION_TYPE_CLASS.equals(listener.getImplementationType()));
  assertEquals("org.test.TestClass", listener.getImplementation());
  assertEquals("start", listener.getEvent());
}
 
Example #3
Source File: CustomSequenceFlowBpmnParseHandler.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
protected void executeParse(BpmnParse bpmnParse, SequenceFlow flow) {

    // Do the regular stuff
    super.executeParse(bpmnParse, flow);

    // Add extension element conditions
    Map<String, List<ExtensionElement>> extensionElements = flow.getExtensionElements();
    if (extensionElements.containsKey("activiti_custom_condition")) {
      List<ExtensionElement> conditionsElements = extensionElements.get("activiti_custom_condition");
      
      CustomSetConditionsExecutionListener customFlowListener = new CustomSetConditionsExecutionListener();
      customFlowListener.setFlowId(flow.getId());
      for (ExtensionElement conditionElement : conditionsElements) {
        customFlowListener.addCondition(conditionElement.getElementText());
      }
      
      ActivitiListener activitiListener = new ActivitiListener();
      activitiListener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_INSTANCE);
      activitiListener.setInstance(customFlowListener);
      activitiListener.setEvent("start");
      flow.getSourceFlowElement().getExecutionListeners().add(activitiListener);
      
    }
  }
 
Example #4
Source File: AddListenerUserTaskParseHandler.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected void executeParse(BpmnParse bpmnParse, UserTask userTask) {
  super.executeParse(bpmnParse, userTask);
  
  ActivitiListener listener = new ActivitiListener();
  listener.setEvent(eventName);
  listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_INSTANCE);
  listener.setInstance(taskListener);
  userTask.getTaskListeners().add(listener);
  

}
 
Example #5
Source File: AbstractInfoMapper.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected void createListenerPropertyNodes(String name, List<ActivitiListener> listeners) {
    if (CollectionUtils.isNotEmpty(listeners)) {
           List<String> listenerValues = new ArrayList<String>();
           for (ActivitiListener listener : listeners) {
               StringBuilder listenerBuilder = new StringBuilder();
               listenerBuilder.append(listener.getEvent());
               if (StringUtils.isNotEmpty(listener.getImplementation())) {
                   listenerBuilder.append(" - ");
                   listenerBuilder.append(listener.getImplementation());
                   listenerBuilder.append(" (");
                   listenerBuilder.append(listener.getImplementationType());
                   listenerBuilder.append(")");
               }
               if (CollectionUtils.isNotEmpty(listener.getFieldExtensions())) {
                   listenerBuilder.append(", field extensions: ");
                   for (int i = 0; i < listener.getFieldExtensions().size(); i++) {
                       if (i > 0) {
                           listenerBuilder.append(",  ");
                       }
                       FieldExtension field = listener.getFieldExtensions().get(i);
                       listenerBuilder.append(field.getFieldName());
                       if (StringUtils.isNotEmpty(field.getStringValue())) {
                           listenerBuilder.append(" - ");
                           listenerBuilder.append(field.getStringValue());
                       } else if (StringUtils.isNotEmpty(field.getExpression())) {
                           listenerBuilder.append(" - ");
                           listenerBuilder.append(field.getExpression());
                       }
                   }
               }
               listenerValues.add(listenerBuilder.toString());
           }
           createPropertyNode(name, listenerValues);
       }
}
 
Example #6
Source File: StartEventConverterTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
private void validateModel(BpmnModel model) {

    FlowElement flowElement = model.getMainProcess().getFlowElement("start", true);
    assertTrue(flowElement instanceof StartEvent);

    StartEvent startEvent = (StartEvent) flowElement;
    assertEquals("start", startEvent.getId());
    assertEquals("startName", startEvent.getName());
    assertEquals("startFormKey", startEvent.getFormKey());
    assertEquals("startInitiator", startEvent.getInitiator());
    assertEquals("startDoc", startEvent.getDocumentation());
 
    assertEquals(2, startEvent.getExecutionListeners().size());
    ActivitiListener executionListener = startEvent.getExecutionListeners().get(0);
    assertEquals("start", executionListener.getEvent());
    assertEquals("org.test.TestClass", executionListener.getImplementation());
    assertEquals(ImplementationType.IMPLEMENTATION_TYPE_CLASS, executionListener.getImplementationType());
    
    executionListener = startEvent.getExecutionListeners().get(1);
    assertEquals("end", executionListener.getEvent());
    assertEquals("${someExpression}", executionListener.getImplementation());
    assertEquals(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION, executionListener.getImplementationType());
    
    List<FormProperty> formProperties = startEvent.getFormProperties();
    assertEquals(2, formProperties.size());

    FormProperty formProperty = formProperties.get(0);
    assertEquals("startFormProp1", formProperty.getId());
    assertEquals("startFormProp1", formProperty.getName());
    assertEquals("string", formProperty.getType());

    formProperty = formProperties.get(1);
    assertEquals("startFormProp2", formProperty.getId());
    assertEquals("startFormProp2", formProperty.getName());
    assertEquals("boolean", formProperty.getType());

  }
 
Example #7
Source File: ListenerNotificationHelper.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected void planTransactionDependentTaskListener(DelegateExecution execution, TransactionDependentTaskListener taskListener, ActivitiListener activitiListener) {
  Map<String, Object> executionVariablesToUse = execution.getVariables();
  CustomPropertiesResolver customPropertiesResolver = createCustomPropertiesResolver(activitiListener);
  Map<String, Object> customPropertiesMapToUse = invokeCustomPropertiesResolver(execution, customPropertiesResolver);
  
  TransactionDependentTaskListenerExecutionScope scope = new TransactionDependentTaskListenerExecutionScope(
      execution.getProcessInstanceId(), execution.getId(), (Task) execution.getCurrentFlowElement(), executionVariablesToUse, customPropertiesMapToUse);
  addTransactionListener(activitiListener, new ExecuteTaskListenerTransactionListener(taskListener, scope));
}
 
Example #8
Source File: ListenerNotificationHelper.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected CustomPropertiesResolver createCustomPropertiesResolver(ActivitiListener activitiListener) {
  CustomPropertiesResolver customPropertiesResolver = null;
  ListenerFactory listenerFactory = Context.getProcessEngineConfiguration().getListenerFactory();
  if (ImplementationType.IMPLEMENTATION_TYPE_CLASS.equalsIgnoreCase(activitiListener.getCustomPropertiesResolverImplementationType())) {
    customPropertiesResolver = listenerFactory.createClassDelegateCustomPropertiesResolver(activitiListener);
  } else if (ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION.equalsIgnoreCase(activitiListener.getCustomPropertiesResolverImplementationType())) {
    customPropertiesResolver = listenerFactory.createExpressionCustomPropertiesResolver(activitiListener);
  } else if (ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.equalsIgnoreCase(activitiListener.getCustomPropertiesResolverImplementationType())) {
    customPropertiesResolver = listenerFactory.createDelegateExpressionCustomPropertiesResolver(activitiListener);
  }
  return customPropertiesResolver;
}
 
Example #9
Source File: UserTaskParseHandler.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected TaskListener createTaskListener(BpmnParse bpmnParse, ActivitiListener activitiListener, String taskId) {
  TaskListener taskListener = null;

  if (ImplementationType.IMPLEMENTATION_TYPE_CLASS.equalsIgnoreCase(activitiListener.getImplementationType())) {
    taskListener = bpmnParse.getListenerFactory().createClassDelegateTaskListener(activitiListener); 
  } else if (ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION.equalsIgnoreCase(activitiListener.getImplementationType())) {
    taskListener = bpmnParse.getListenerFactory().createExpressionTaskListener(activitiListener);
  } else if (ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.equalsIgnoreCase(activitiListener.getImplementationType())) {
    taskListener = bpmnParse.getListenerFactory().createDelegateExpressionTaskListener(activitiListener);
  }
  return taskListener;
}
 
Example #10
Source File: ListenerNotificationHelper.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected void addTransactionListener(ActivitiListener activitiListener, TransactionListener transactionListener) {
  TransactionContext transactionContext = Context.getTransactionContext();
  if (TransactionDependentExecutionListener.ON_TRANSACTION_BEFORE_COMMIT.equals(activitiListener.getOnTransaction())) {
    transactionContext.addTransactionListener(TransactionState.COMMITTING, transactionListener);
    
  } else if (TransactionDependentExecutionListener.ON_TRANSACTION_COMMITTED.equals(activitiListener.getOnTransaction())) {
    transactionContext.addTransactionListener(TransactionState.COMMITTED, transactionListener);
    
  } else if (TransactionDependentExecutionListener.ON_TRANSACTION_ROLLED_BACK.equals(activitiListener.getOnTransaction())) {
    transactionContext.addTransactionListener(TransactionState.ROLLED_BACK, transactionListener);
    
  }
}
 
Example #11
Source File: AbstractBpmnParseHandler.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected ExecutionListener createExecutionListener(BpmnParse bpmnParse, ActivitiListener activitiListener) {
  ExecutionListener executionListener = null;

  if (ImplementationType.IMPLEMENTATION_TYPE_CLASS.equalsIgnoreCase(activitiListener.getImplementationType())) {
    executionListener = bpmnParse.getListenerFactory().createClassDelegateExecutionListener(activitiListener);  
  } else if (ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION.equalsIgnoreCase(activitiListener.getImplementationType())) {
    executionListener = bpmnParse.getListenerFactory().createExpressionExecutionListener(activitiListener);
  } else if (ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.equalsIgnoreCase(activitiListener.getImplementationType())) {
    executionListener = bpmnParse.getListenerFactory().createDelegateExpressionExecutionListener(activitiListener);
  }
  return executionListener;
}
 
Example #12
Source File: EventJavaTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void testStartEventWithExecutionListener() throws Exception {
  BpmnModel bpmnModel = new BpmnModel();
  Process process = new Process();
  process.setId("simpleProcess");
  process.setName("Very simple process");
  bpmnModel.getProcesses().add(process);
  StartEvent startEvent = new StartEvent();
  startEvent.setId("startEvent1");
  TimerEventDefinition timerDef = new TimerEventDefinition();
  timerDef.setTimeDuration("PT5M");
  startEvent.getEventDefinitions().add(timerDef);
  ActivitiListener listener = new ActivitiListener();
  listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION);
  listener.setImplementation("${test}");
  listener.setEvent("end");
  startEvent.getExecutionListeners().add(listener);
  process.addFlowElement(startEvent);
  UserTask task = new UserTask();
  task.setId("reviewTask");
  task.setAssignee("kermit");
  process.addFlowElement(task);
  SequenceFlow flow1 = new SequenceFlow();
  flow1.setId("flow1");
  flow1.setSourceRef("startEvent1");
  flow1.setTargetRef("reviewTask");
  process.addFlowElement(flow1);
  EndEvent endEvent = new EndEvent();
  endEvent.setId("endEvent1");
  process.addFlowElement(endEvent);

  byte[] xml = new BpmnXMLConverter().convertToXML(bpmnModel);

  new BpmnXMLConverter().validateModel(new InputStreamSource(new ByteArrayInputStream(xml)));

  Deployment deployment = repositoryService.createDeployment().name("test").addString("test.bpmn20.xml", new String(xml)).deploy();
  repositoryService.deleteDeployment(deployment.getId());
}
 
Example #13
Source File: CustomListenerFactory.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
public TaskListener createExpressionTaskListener(ActivitiListener activitiListener) {
  return new TaskListener() {
    public void notify(DelegateTask delegateTask) {
      CustomListenerFactoryTest.COUNTER.addAndGet(100);
    }
  };
}
 
Example #14
Source File: CdiEventSupportBpmnParseHandler.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected void addActivitiListenerToElement(FlowElement flowElement, String event, Object instance) {
  ActivitiListener listener = new ActivitiListener();
  listener.setEvent(event);
  listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_INSTANCE);
  listener.setInstance(instance);
  flowElement.getExecutionListeners().add(listener);
}
 
Example #15
Source File: TaskAutoRedirectParseHandler.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
protected void executeParse(BpmnParse bpmnParse, UserTask userTask) {
    super.executeParse(bpmnParse, userTask);

    // 实验后不能添加
    ActivitiListener listener = new ActivitiListener();
    listener.setEvent("create");
    listener.setImplementationType("class");
    listener.setImplementation("me.kafeitu.activiti.chapter21.listeners.TaskAutoRedirectListener");
    userTask.getTaskListeners().add(listener);
}
 
Example #16
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 #17
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 #18
Source File: ListenerNotificationHelper.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected void planTransactionDependentExecutionListener(ListenerFactory listenerFactory, DelegateExecution execution, TransactionDependentExecutionListener executionListener, ActivitiListener activitiListener) {
  Map<String, Object> executionVariablesToUse = execution.getVariables();
  CustomPropertiesResolver customPropertiesResolver = createCustomPropertiesResolver(activitiListener);
  Map<String, Object> customPropertiesMapToUse = invokeCustomPropertiesResolver(execution, customPropertiesResolver);

  TransactionDependentExecutionListenerExecutionScope scope = new TransactionDependentExecutionListenerExecutionScope(
      execution.getProcessInstanceId(), execution.getId(), execution.getCurrentFlowElement(), executionVariablesToUse, customPropertiesMapToUse);
  
  addTransactionListener(activitiListener, new ExecuteExecutionListenerTransactionListener(executionListener, scope));
}
 
Example #19
Source File: AbstractBpmnParseHandler.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected ExecutionListener createExecutionListener(BpmnParse bpmnParse, ActivitiListener activitiListener) {
  ExecutionListener executionListener = null;

  if (ImplementationType.IMPLEMENTATION_TYPE_CLASS.equalsIgnoreCase(activitiListener.getImplementationType())) {
    executionListener = bpmnParse.getListenerFactory().createClassDelegateExecutionListener(activitiListener);
  } else if (ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION.equalsIgnoreCase(activitiListener.getImplementationType())) {
    executionListener = bpmnParse.getListenerFactory().createExpressionExecutionListener(activitiListener);
  } else if (ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.equalsIgnoreCase(activitiListener.getImplementationType())) {
    executionListener = bpmnParse.getListenerFactory().createDelegateExpressionExecutionListener(activitiListener);
  }
  return executionListener;
}
 
Example #20
Source File: ActivitiListenerParser.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception {

    ActivitiListener listener = new ActivitiListener();
    BpmnXMLUtil.addXMLLocation(listener, xtr);
    if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_CLASS))) {
      listener.setImplementation(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_CLASS));
      listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_CLASS);
    } else if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_EXPRESSION))) {
      listener.setImplementation(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_EXPRESSION));
      listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION);
    } else if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_DELEGATEEXPRESSION))) {
      listener.setImplementation(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_DELEGATEEXPRESSION));
      listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION);
    }
    listener.setEvent(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_EVENT));
    listener.setOnTransaction(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_ON_TRANSACTION));

    if (StringUtils.isNotEmpty((xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_CUSTOM_PROPERTIES_RESOLVER_CLASS)))) {
      listener.setCustomPropertiesResolverImplementation(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_CUSTOM_PROPERTIES_RESOLVER_CLASS));
      listener.setCustomPropertiesResolverImplementationType(ImplementationType.IMPLEMENTATION_TYPE_CLASS);
    } else if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_CUSTOM_PROPERTIES_RESOLVER_EXPRESSION))) {
      listener.setCustomPropertiesResolverImplementation(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_CUSTOM_PROPERTIES_RESOLVER_EXPRESSION));
      listener.setCustomPropertiesResolverImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION);
    } else if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_CUSTOM_PROPERTIES_RESOLVER_DELEGATEEXPRESSION))) {
      listener.setCustomPropertiesResolverImplementation(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_CUSTOM_PROPERTIES_RESOLVER_DELEGATEEXPRESSION));
      listener.setCustomPropertiesResolverImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION);
    }
    addListenerToParent(listener, parentElement);
    parseChildElements(xtr, listener, model, new FieldExtensionParser());
  }
 
Example #21
Source File: ExecutionListenerParser.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void addListenerToParent(ActivitiListener listener, BaseElement parentElement) {
  if (parentElement instanceof HasExecutionListeners) {
    if (StringUtils.isEmpty(listener.getEvent()) && parentElement instanceof SequenceFlow) {
      // No event type on a sequenceflow = 'take' implied
      listener.setEvent("take");
    }
    ((HasExecutionListeners) parentElement).getExecutionListeners().add(listener);
  }
}
 
Example #22
Source File: EventBasedGatewayConverterTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
private void validateModel(BpmnModel model) {
  FlowElement flowElement = model.getMainProcess().getFlowElement("eventBasedGateway");
  assertNotNull(flowElement);
  assertTrue(flowElement instanceof EventGateway);

  EventGateway gateway = (EventGateway) flowElement;
  List<ActivitiListener> listeners = gateway.getExecutionListeners();
  assertEquals(1, listeners.size());
  ActivitiListener listener = listeners.get(0);
  assertTrue(ImplementationType.IMPLEMENTATION_TYPE_CLASS.equals(listener.getImplementationType()));
  assertEquals("org.test.TestClass", listener.getImplementation());
  assertEquals("start", listener.getEvent());
}
 
Example #23
Source File: ProxyUserTaskBpmnParseHandler.java    From lemon with Apache License 2.0 5 votes vote down vote up
public void configEvent(TaskDefinition taskDefinition, BpmnParse bpmnParse,
        String eventName) {
    ActivitiListener activitiListener = new ActivitiListener();
    activitiListener.setEvent(eventName);
    activitiListener
            .setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION);
    activitiListener.setImplementation("#{" + taskListenerId + "}");
    taskDefinition
            .addTaskListener(eventName, bpmnParse.getListenerFactory()
                    .createDelegateExpressionTaskListener(activitiListener));
}
 
Example #24
Source File: ServiceTaskConverterTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
private void validateModel(BpmnModel model) {
  FlowElement flowElement = model.getMainProcess().getFlowElement("servicetask");
  assertNotNull(flowElement);
  assertTrue(flowElement instanceof ServiceTask);
  assertEquals("servicetask", flowElement.getId());
  ServiceTask serviceTask = (ServiceTask) flowElement;
  assertEquals("servicetask", serviceTask.getId());
  assertEquals("Service task", serviceTask.getName());

  List<FieldExtension> fields = serviceTask.getFieldExtensions();
  assertEquals(2, fields.size());
  FieldExtension field = fields.get(0);
  assertEquals("testField", field.getFieldName());
  assertEquals("test", field.getStringValue());
  field = fields.get(1);
  assertEquals("testField2", field.getFieldName());
  assertEquals("${test}", field.getExpression());

  List<ActivitiListener> listeners = serviceTask.getExecutionListeners();
  assertEquals(3, listeners.size());
  ActivitiListener listener = listeners.get(0);
  assertTrue(ImplementationType.IMPLEMENTATION_TYPE_CLASS.equals(listener.getImplementationType()));
  assertEquals("org.test.TestClass", listener.getImplementation());
  assertEquals("start", listener.getEvent());
  listener = listeners.get(1);
  assertTrue(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION.equals(listener.getImplementationType()));
  assertEquals("${testExpression}", listener.getImplementation());
  assertEquals("end", listener.getEvent());
  listener = listeners.get(2);
  assertTrue(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.equals(listener.getImplementationType()));
  assertEquals("${delegateExpression}", listener.getImplementation());
  assertEquals("start", listener.getEvent());

  assertEquals("R5/PT5M", serviceTask.getFailedJobRetryTimeCycleValue());
}
 
Example #25
Source File: ExecutionImpl.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
@Override
public ActivitiListener getCurrentActivitiListener() {
  throw new UnsupportedOperationException();
}
 
Example #26
Source File: DefaultListenerFactory.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
@Override
public ExecutionListener createDelegateExpressionExecutionListener(ActivitiListener activitiListener) {
  return new DelegateExpressionExecutionListener(expressionManager.createExpression(activitiListener.getImplementation()), createFieldDeclarations(activitiListener.getFieldExtensions()));
}
 
Example #27
Source File: DefaultListenerFactory.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
@Override
public CustomPropertiesResolver createClassDelegateCustomPropertiesResolver(ActivitiListener activitiListener) {
  return classDelegateFactory.create(activitiListener.getCustomPropertiesResolverImplementation(), null);
}
 
Example #28
Source File: DefaultListenerFactory.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
@Override
public ExecutionListener createClassDelegateExecutionListener(ActivitiListener activitiListener) {
  return classDelegateFactory.create(activitiListener.getImplementation(), createFieldDeclarations(activitiListener.getFieldExtensions()));
}
 
Example #29
Source File: DefaultListenerFactory.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
@Override
public DelegateExpressionTransactionDependentExecutionListener createTransactionDependentDelegateExpressionExecutionListener(ActivitiListener activitiListener) {
  return new DelegateExpressionTransactionDependentExecutionListener(expressionManager.createExpression(activitiListener.getImplementation()));
}
 
Example #30
Source File: DefaultListenerFactory.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
@Override
public TransactionDependentTaskListener createTransactionDependentDelegateExpressionTaskListener(ActivitiListener activitiListener) {
  return new DelegateExpressionTransactionDependentTaskListener(expressionManager.createExpression(activitiListener.getImplementation()));
}