Package org.activiti.bpmn.model

Examples of org.activiti.bpmn.model.ActivitiListener


                TaskListener.EVENTNAME_DELETE);
    }

    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));
    }
View Full Code Here


        TaskDefinition taskDefinition = (TaskDefinition) bpmnParse
                .getCurrentActivity().getProperty(
                        UserTaskParseHandler.PROPERTY_TASK_DEFINITION);

        ActivitiListener activitiListener = new ActivitiListener();
        activitiListener.setEvent(TaskListener.EVENTNAME_ASSIGNMENT);
        activitiListener
                .setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION);
        activitiListener.setImplementation("#{delegateTaskListener}");
        taskDefinition
                .addTaskListener(TaskListener.EVENTNAME_ASSIGNMENT, bpmnParse
                        .getListenerFactory()
                        .createDelegateExpressionTaskListener(activitiListener));

        // candidateuser 或者group 包含被代理人, 则添加代理人为candidateuser
        ActivitiListener delegateActivitiCandidateListener = new ActivitiListener();
        delegateActivitiCandidateListener
                .setEvent(TaskListener.EVENTNAME_CREATE);
        delegateActivitiCandidateListener
                .setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION);
        delegateActivitiCandidateListener
                .setImplementation("#{delegateTaskCreateListener}");
        taskDefinition.addTaskListener(
                TaskListener.EVENTNAME_CREATE,
                bpmnParse.getListenerFactory()
                        .createDelegateExpressionTaskListener(
View Full Code Here

    assertTrue(StringUtils.isEmpty(formProperty.getVariable()));
    assertTrue(StringUtils.isEmpty(formProperty.getExpression()));
   
    List<ActivitiListener> listeners = userTask.getTaskListeners();
    assertEquals(3, listeners.size());
    ActivitiListener listener = (ActivitiListener) listeners.get(0);
    assertTrue(ImplementationType.IMPLEMENTATION_TYPE_CLASS.equals(listener.getImplementationType()));
    assertEquals("org.test.TestClass", listener.getImplementation());
    assertEquals("create", listener.getEvent());
    assertEquals(2, listener.getFieldExtensions().size());
    assertEquals("testField", listener.getFieldExtensions().get(0).getFieldName());
    assertEquals("test", listener.getFieldExtensions().get(0).getStringValue());
    listener = (ActivitiListener) listeners.get(1);
    assertTrue(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION.equals(listener.getImplementationType()));
    assertEquals("${someExpression}", listener.getImplementation());
    assertEquals("assignment", listener.getEvent());
    listener = (ActivitiListener) listeners.get(2);
    assertTrue(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.equals(listener.getImplementationType()));
    assertEquals("${someDelegateExpression}", listener.getImplementation());
    assertEquals("complete", listener.getEvent());
   
    flowElement = model.getMainProcess().getFlowElement("start");
    assertTrue(flowElement instanceof StartEvent);
   
    StartEvent startEvent  = (StartEvent) flowElement;
View Full Code Here

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

    assertEquals("10", subProcess.getLoopCharacteristics().getLoopCardinality());
    assertEquals("${assignee == \"\"}", subProcess.getLoopCharacteristics().getCompletionCondition());
    assertTrue(subProcess.getFlowElements().size() == 5);
   
    assertEquals(1, subProcess.getExecutionListeners().size());
    ActivitiListener listenerSubProcess = subProcess.getExecutionListeners().get(0);
    assertEquals("SubProcessTestClass", listenerSubProcess.getImplementation());
    assertEquals(ImplementationType.IMPLEMENTATION_TYPE_CLASS, listenerSubProcess.getImplementationType());
    assertEquals("start", listenerSubProcess.getEvent());   
   
    flowElement = model.getMainProcess().getFlowElement("boundaryEvent1");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof BoundaryEvent);
    assertEquals("boundaryEvent1", flowElement.getId());
    BoundaryEvent boundaryEvent = (BoundaryEvent) flowElement;
    assertNotNull(boundaryEvent.getAttachedToRef());
    assertEquals("subprocess1", boundaryEvent.getAttachedToRef().getId());
    assertEquals(1, boundaryEvent.getEventDefinitions().size());
    assertTrue(boundaryEvent.getEventDefinitions().get(0) instanceof TimerEventDefinition);
   
    assertEquals(1, model.getMainProcess().getExecutionListeners().size());
    ActivitiListener listenerMainProcess = model.getMainProcess().getExecutionListeners().get(0);
    assertEquals("TestClass", listenerMainProcess.getImplementation());
    assertEquals(ImplementationType.IMPLEMENTATION_TYPE_CLASS, listenerMainProcess.getImplementationType());
    assertEquals("start", listenerMainProcess.getEvent());
  }
View Full Code Here

      if (itemsArrayNode != null) {
        for (JsonNode itemNode : itemsArrayNode) {
          JsonNode typeNode = itemNode.get(eventType);
          if (typeNode != null && StringUtils.isNotEmpty(typeNode.asText())) {
           
            ActivitiListener listener = new ActivitiListener();
            listener.setEvent(typeNode.asText());
            if (StringUtils.isNotEmpty(getValueAsString(listenerClass, itemNode))) {
              listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_CLASS);
              listener.setImplementation(getValueAsString(listenerClass, itemNode));
            } else if (StringUtils.isNotEmpty(getValueAsString(listenerExpression, itemNode))) {
              listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION);
              listener.setImplementation(getValueAsString(listenerExpression, itemNode));
            } else if (StringUtils.isNotEmpty(getValueAsString(listenerDelegateExpression, itemNode))) {
              listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION);
              listener.setImplementation(getValueAsString(listenerDelegateExpression, itemNode));
            }
           
            listenerFieldsNode = itemNode.get(listenerFields);
            if (listenerFieldsNode != null && StringUtils.isNotEmpty(listenerFieldsNode.asText()) && !("undefined".equals(listenerFieldsNode.asText()))){
              if(listenerFieldsNode.isValueNode()){
                try{
                  listenerFieldsNode = objectMapper.readTree(listenerFieldsNode.asText());
                } catch(Exception e){
                  LOGGER.info("Listener fields node can not be read", e);
                }
              }
            }
            if (listenerFieldsNode != null) {
              listenerFieldsArrayNode = listenerFieldsNode.get(EDITOR_PROPERTIES_GENERAL_ITEMS);
              List<FieldExtension> fields = new ArrayList<FieldExtension>();
              if (listenerFieldsArrayNode != null) {
                for (JsonNode fieldNode : listenerFieldsArrayNode){
                  JsonNode fieldNameNode = fieldNode.get(listenerFieldName);
                  if (fieldNameNode != null && StringUtils.isNotEmpty(fieldNameNode.asText())){
                    FieldExtension field = new FieldExtension();
                    field.setFieldName(fieldNameNode.asText());
                    field.setStringValue(getValueAsString(listenerFieldValue, fieldNode));
                    field.setExpression(getValueAsString(listenerFieldExpression, fieldNode));
                    fields.add(field);
                  }
                }
              }
              listener.setFieldExtensions(fields);
            }
           
            if (element instanceof Process) {
              ((Process) element).getExecutionListeners().add(listener);
            } else if (element instanceof SequenceFlow) {
View Full Code Here

    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());
  }
View Full Code Here

    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());
  }
View Full Code Here

      if (selectPeopleUserTask.getTaskListeners() == null)
      {
        selectPeopleUserTask.setTaskListeners(new ArrayList<ActivitiListener>());
      }
     
      ActivitiListener taskListener = new ActivitiListener();
      taskListener.setEvent("complete");
      taskListener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_CLASS);
      taskListener.setImplementation("org.activiti.engine.impl.bpmn.listener.ScriptTaskListener");
     
      FieldExtension languageField = new FieldExtension();
      languageField.setFieldName("language");
      languageField.setStringValue("JavaScript");
     
      FieldExtension scriptField = new FieldExtension();
      scriptField.setFieldName("script");
     
      StringBuilder script = new StringBuilder();
      if (JvmUtil.isJDK8()) {
        script.append("load(\"nashorn:mozilla_compat.js\");");
      }
      script.append("importPackage (java.util); var feedbackProviders = new ArrayList();" + System.getProperty("line.separator"));
      for (String feedbackProvider : feedbackStepDefinition.getFeedbackProviders()) {
        script.append("feedbackProviders.add('" + feedbackProvider + "');" + System.getProperty("line.separator"));
      }
      script.append("task.getExecution().setVariable('" + VARIABLE_FEEDBACK_PROVIDERS + "', feedbackProviders);" + System.getProperty("line.separator"));
      scriptField.setStringValue(script.toString());

      taskListener.setFieldExtensions(Arrays.asList(languageField, scriptField));
     
      selectPeopleUserTask.getTaskListeners().add(taskListener);
    }
   
   
View Full Code Here

    assertTrue(StringUtils.isEmpty(formProperty.getExpression()));
    assertEquals(2, formProperty.getFormValues().size());
   
    List<ActivitiListener> listeners = userTask.getTaskListeners();
    assertEquals(3, listeners.size());
    ActivitiListener listener = listeners.get(0);
    assertTrue(ImplementationType.IMPLEMENTATION_TYPE_CLASS.equals(listener.getImplementationType()));
    assertEquals("org.test.TestClass", listener.getImplementation());
    assertEquals("create", listener.getEvent());
    listener = listeners.get(1);
    assertTrue(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION.equals(listener.getImplementationType()));
    assertEquals("${someExpression}", listener.getImplementation());
    assertEquals("assignment", listener.getEvent());
    listener = listeners.get(2);
    assertTrue(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.equals(listener.getImplementationType()));
    assertEquals("${someDelegateExpression}", listener.getImplementation());
    assertEquals("complete", listener.getEvent());
   
    List<ActivitiListener> executionListeners = userTask.getExecutionListeners();
    assertEquals(1, executionListeners.size());
    ActivitiListener executionListener = executionListeners.get(0);
    assertEquals("end", executionListener.getEvent());
   
  }
View Full Code Here

TOP

Related Classes of org.activiti.bpmn.model.ActivitiListener

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.