org.activiti.bpmn.model.ImplementationType Java Examples

The following examples show how to use org.activiti.bpmn.model.ImplementationType. 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: ActivitiDelegateTest.java    From herd with Apache License 2.0 6 votes vote down vote up
/**
 * This method tests the scenario when an workflow related error is throws while workflow is executing an Async type task like Timer. This error is logged
 * as WARN.
 */
@Test(expected = ActivitiException.class)
public void testActivitiUnReportableError() throws Exception
{
    BpmnModel bpmnModel = getBpmnModelForXmlResource(ACTIVITI_XML_HERD_TIMER_WITH_CLASSPATH);

    ServiceTask serviceTask = (ServiceTask) bpmnModel.getProcesses().get(0).getFlowElement("servicetask1");

    serviceTask.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION);
    serviceTask.setImplementation("${BeanNotAvailable}");

    jobDefinitionServiceTestHelper.createJobDefinitionForActivitiXml(getActivitiXmlFromBpmnModel(bpmnModel));
    Job job = jobService.createAndStartJob(jobServiceTestHelper.createJobCreateRequest(TEST_ACTIVITI_NAMESPACE_CD, TEST_ACTIVITI_JOB_NAME, null));
    org.activiti.engine.runtime.Job timer = activitiManagementService.createJobQuery().processInstanceId(job.getId()).timers().singleResult();
    if (timer != null)
    {
        executeWithoutLogging(TimerExecuteNestedActivityJobHandler.class, () -> {
            activitiManagementService.executeJob(timer.getId());
        });
    }
}
 
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: ServiceTaskValidator.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
protected void verifyWebservice(BpmnModel bpmnModel, Process process, ServiceTask serviceTask, List<ValidationError> errors) {
  if (ImplementationType.IMPLEMENTATION_TYPE_WEBSERVICE.equalsIgnoreCase(serviceTask.getImplementationType()) && StringUtils.isNotEmpty(serviceTask.getOperationRef())) {

    boolean operationFound = false;
    if (bpmnModel.getInterfaces() != null && !bpmnModel.getInterfaces().isEmpty()) {
      for (Interface bpmnInterface : bpmnModel.getInterfaces()) {
        if (bpmnInterface.getOperations() != null && !bpmnInterface.getOperations().isEmpty()) {
          for (Operation operation : bpmnInterface.getOperations()) {
            if (operation.getId() != null && operation.getId().equals(serviceTask.getOperationRef())) {
              operationFound = true;
            }
          }
        }
      }
    }

    if (!operationFound) {
      addError(errors, Problems.SERVICE_TASK_WEBSERVICE_INVALID_OPERATION_REF, process, serviceTask, "Invalid operation reference");
    }

  }
}
 
Example #4
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 #5
Source File: SendTaskValidator.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
protected void verifyWebservice(BpmnModel bpmnModel, Process process, SendTask sendTask, List<ValidationError> errors) {
  if (ImplementationType.IMPLEMENTATION_TYPE_WEBSERVICE.equalsIgnoreCase(sendTask.getImplementationType()) && StringUtils.isNotEmpty(sendTask.getOperationRef())) {

    boolean operationFound = false;
    if (bpmnModel.getInterfaces() != null && !bpmnModel.getInterfaces().isEmpty()) {
      for (Interface bpmnInterface : bpmnModel.getInterfaces()) {
        if (bpmnInterface.getOperations() != null && !bpmnInterface.getOperations().isEmpty()) {
          for (Operation operation : bpmnInterface.getOperations()) {
            if (operation.getId() != null && operation.getId().equals(sendTask.getOperationRef())) {
              operationFound = true;
            }
          }
        }
      }
    }

    if (!operationFound) {
      addError(errors, Problems.SEND_TASK_WEBSERVICE_INVALID_OPERATION_REF, process, sendTask, "Invalid operation reference for send task");
    }

  }
}
 
Example #6
Source File: ServiceTaskXMLConverter.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Override
protected void writeAdditionalAttributes(BaseElement element, BpmnModel model, XMLStreamWriter xtw) throws Exception {

  ServiceTask serviceTask = (ServiceTask) element;

  if (ImplementationType.IMPLEMENTATION_TYPE_CLASS.equals(serviceTask.getImplementationType())) {
    writeQualifiedAttribute(ATTRIBUTE_TASK_SERVICE_CLASS, serviceTask.getImplementation(), xtw);
  } else if (ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION.equals(serviceTask.getImplementationType())) {
    writeQualifiedAttribute(ATTRIBUTE_TASK_SERVICE_EXPRESSION, serviceTask.getImplementation(), xtw);
  } else if (ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.equals(serviceTask.getImplementationType())) {
    writeQualifiedAttribute(ATTRIBUTE_TASK_SERVICE_DELEGATEEXPRESSION, serviceTask.getImplementation(), xtw);
  }

  if (StringUtils.isNotEmpty(serviceTask.getResultVariableName())) {
    writeQualifiedAttribute(ATTRIBUTE_TASK_SERVICE_RESULTVARIABLE, serviceTask.getResultVariableName(), xtw);
  }
  if (StringUtils.isNotEmpty(serviceTask.getType())) {
    writeQualifiedAttribute(ATTRIBUTE_TYPE, serviceTask.getType(), xtw);
  }
  if (StringUtils.isNotEmpty(serviceTask.getExtensionId())) {
    writeQualifiedAttribute(ATTRIBUTE_TASK_SERVICE_EXTENSIONID, serviceTask.getExtensionId(), xtw);
  }
  if (StringUtils.isNotEmpty(serviceTask.getSkipExpression())) {
    writeQualifiedAttribute(ATTRIBUTE_TASK_SERVICE_SKIP_EXPRESSION, serviceTask.getSkipExpression(), xtw);
  }
}
 
Example #7
Source File: ServiceTaskInfoMapper.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
protected void mapProperties(Object element) {
	ServiceTask serviceTask = (ServiceTask) element;
	if (ImplementationType.IMPLEMENTATION_TYPE_CLASS.equals(serviceTask.getImplementationType())) {
		createPropertyNode("Class", serviceTask.getImplementation());
	} else if (ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION.equals(serviceTask.getImplementationType())) {
		createPropertyNode("Expression", serviceTask.getImplementation());
	} else if (ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.equals(serviceTask.getImplementationType())) {
		createPropertyNode("Delegate expression", serviceTask.getImplementation());
	}
	if (serviceTask.isAsynchronous()) {
	    createPropertyNode("Asynchronous", true);
	    createPropertyNode("Exclusive", !serviceTask.isNotExclusive());
	}
	if (ServiceTask.MAIL_TASK.equalsIgnoreCase(serviceTask.getType())) {
	    createPropertyNode("Type", "Mail task");
	}
	createPropertyNode("Result variable name", serviceTask.getResultVariableName());
	createFieldPropertyNodes("Field extensions", serviceTask.getFieldExtensions());
	createListenerPropertyNodes("Execution listeners", serviceTask.getExecutionListeners());
}
 
Example #8
Source File: DefaultListenerFactory.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Override
public ActivitiEventListener createEventThrowingEventListener(EventListener eventListener) {
  BaseDelegateEventListener result = null;
  if (ImplementationType.IMPLEMENTATION_TYPE_THROW_SIGNAL_EVENT.equals(eventListener.getImplementationType())) {
    result = new SignalThrowingEventListener();
    ((SignalThrowingEventListener) result).setSignalName(eventListener.getImplementation());
    ((SignalThrowingEventListener) result).setProcessInstanceScope(true);
  } else if (ImplementationType.IMPLEMENTATION_TYPE_THROW_GLOBAL_SIGNAL_EVENT.equals(eventListener.getImplementationType())) {
    result = new SignalThrowingEventListener();
    ((SignalThrowingEventListener) result).setSignalName(eventListener.getImplementation());
    ((SignalThrowingEventListener) result).setProcessInstanceScope(false);
  } else if (ImplementationType.IMPLEMENTATION_TYPE_THROW_MESSAGE_EVENT.equals(eventListener.getImplementationType())) {
    result = new MessageThrowingEventListener();
    ((MessageThrowingEventListener) result).setMessageName(eventListener.getImplementation());
  } else if (ImplementationType.IMPLEMENTATION_TYPE_THROW_ERROR_EVENT.equals(eventListener.getImplementationType())) {
    result = new ErrorThrowingEventListener();
    ((ErrorThrowingEventListener) result).setErrorCode(eventListener.getImplementation());
  }

  if (result == null) {
    throw new ActivitiIllegalArgumentException("Cannot create an event-throwing event-listener, unknown implementation type: " + eventListener.getImplementationType());
  }

  result.setEntityClass(getEntityType(eventListener.getEntityType()));
  return result;
}
 
Example #9
Source File: SendTaskParseHandler.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
protected void executeParse(BpmnParse bpmnParse, SendTask sendTask) {

    if (StringUtils.isNotEmpty(sendTask.getType())) {
      
      if (sendTask.getType().equalsIgnoreCase("mail")) {
        sendTask.setBehavior(bpmnParse.getActivityBehaviorFactory().createMailActivityBehavior(sendTask));
      } else if (sendTask.getType().equalsIgnoreCase("mule")) {
        sendTask.setBehavior(bpmnParse.getActivityBehaviorFactory().createMuleActivityBehavior(sendTask));
      } else if (sendTask.getType().equalsIgnoreCase("camel")) {
        sendTask.setBehavior(bpmnParse.getActivityBehaviorFactory().createCamelActivityBehavior(sendTask));
      } else if (sendTask.getType().equalsIgnoreCase("dmn")) {
        sendTask.setBehavior(bpmnParse.getActivityBehaviorFactory().createDmnActivityBehavior(sendTask));
      }

    } else if (ImplementationType.IMPLEMENTATION_TYPE_WEBSERVICE.equalsIgnoreCase(sendTask.getImplementationType()) && StringUtils.isNotEmpty(sendTask.getOperationRef())) {

      WebServiceActivityBehavior webServiceActivityBehavior = bpmnParse.getActivityBehaviorFactory().createWebServiceActivityBehavior(sendTask);
      sendTask.setBehavior(webServiceActivityBehavior);
       
    } else {
      logger.warn("One of the attributes 'type' or 'operation' is mandatory on sendTask " + sendTask.getId());
    }
  }
 
Example #10
Source File: DefaultListenerFactory.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
public ActivitiEventListener createEventThrowingEventListener(EventListener eventListener) {
	BaseDelegateEventListener result = null;
	if (ImplementationType.IMPLEMENTATION_TYPE_THROW_SIGNAL_EVENT.equals(eventListener.getImplementationType())) {
		result = new SignalThrowingEventListener();
		((SignalThrowingEventListener) result).setSignalName(eventListener.getImplementation());
		((SignalThrowingEventListener) result).setProcessInstanceScope(true);
	} else if (ImplementationType.IMPLEMENTATION_TYPE_THROW_GLOBAL_SIGNAL_EVENT.equals(eventListener.getImplementationType())) {
		result = new SignalThrowingEventListener();
		((SignalThrowingEventListener) result).setSignalName(eventListener.getImplementation());
		((SignalThrowingEventListener) result).setProcessInstanceScope(false);
	} else if (ImplementationType.IMPLEMENTATION_TYPE_THROW_MESSAGE_EVENT.equals(eventListener.getImplementationType())) {
		result = new MessageThrowingEventListener();
		((MessageThrowingEventListener) result).setMessageName(eventListener.getImplementation());
	} else if (ImplementationType.IMPLEMENTATION_TYPE_THROW_ERROR_EVENT.equals(eventListener.getImplementationType())) {
		result = new ErrorThrowingEventListener();
		((ErrorThrowingEventListener) result).setErrorCode(eventListener.getImplementation());
	}

	if (result == null) {
		throw new ActivitiIllegalArgumentException("Cannot create an event-throwing event-listener, unknown implementation type: "
		        + eventListener.getImplementationType());
	}

	result.setEntityClass(getEntityType(eventListener.getEntityType()));
	return result;
}
 
Example #11
Source File: ServiceTaskValidator.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected void verifyImplementation(Process process, ServiceTask serviceTask, List<ValidationError> errors) {
  if (!ImplementationType.IMPLEMENTATION_TYPE_CLASS.equalsIgnoreCase(serviceTask.getImplementationType())
      && !ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.equalsIgnoreCase(serviceTask.getImplementationType())
      && !ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION.equalsIgnoreCase(serviceTask.getImplementationType())
      && !ImplementationType.IMPLEMENTATION_TYPE_WEBSERVICE.equalsIgnoreCase(serviceTask.getImplementationType()) && StringUtils.isEmpty(serviceTask.getType())) {
    addError(errors, Problems.SERVICE_TASK_MISSING_IMPLEMENTATION, process, serviceTask,
        "One of the attributes 'class', 'delegateExpression', 'type', 'operation', or 'expression' is mandatory on serviceTask.");
  }
}
 
Example #12
Source File: ServiceTaskValidator.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected void verifyResultVariableName(Process process, ServiceTask serviceTask, List<ValidationError> errors) {
  if (StringUtils.isNotEmpty(serviceTask.getResultVariableName())
      && (ImplementationType.IMPLEMENTATION_TYPE_CLASS.equals(serviceTask.getImplementationType()) || ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.equals(serviceTask
          .getImplementationType()))) {
    addError(errors, Problems.SERVICE_TASK_RESULT_VAR_NAME_WITH_DELEGATE, process, serviceTask, "'resultVariableName' not supported for service tasks using 'class' or 'delegateExpression");
  }
}
 
Example #13
Source File: SendTaskValidator.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<SendTask> sendTasks = process.findFlowElementsOfType(SendTask.class);
  for (SendTask sendTask : sendTasks) {

    // Verify implementation
    if (StringUtils.isEmpty(sendTask.getType()) && !ImplementationType.IMPLEMENTATION_TYPE_WEBSERVICE.equalsIgnoreCase(sendTask.getImplementationType())) {
      addError(errors, Problems.SEND_TASK_INVALID_IMPLEMENTATION, process, sendTask, "One of the attributes 'type' or 'operation' is mandatory on sendTask");
    }

    // Verify type
    if (StringUtils.isNotEmpty(sendTask.getType())) {

      if (!sendTask.getType().equalsIgnoreCase("mail") && !sendTask.getType().equalsIgnoreCase("mule") && !sendTask.getType().equalsIgnoreCase("camel")) {
        addError(errors, Problems.SEND_TASK_INVALID_TYPE, process, sendTask, "Invalid or unsupported type for send task");
      }

      if (sendTask.getType().equalsIgnoreCase("mail")) {
        validateFieldDeclarationsForEmail(process, sendTask, sendTask.getFieldExtensions(), errors);
      }

    }

    // Web service
    verifyWebservice(bpmnModel, process, sendTask, errors);
  }
}
 
Example #14
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 #15
Source File: ActivitiEventListenerValidator.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<EventListener> eventListeners = process.getEventListeners();
  if (eventListeners != null) {
    for (EventListener eventListener : eventListeners) {

      if (eventListener.getImplementationType() != null && eventListener.getImplementationType().equals(ImplementationType.IMPLEMENTATION_TYPE_INVALID_THROW_EVENT)) {

        addError(errors, Problems.EVENT_LISTENER_INVALID_THROW_EVENT_TYPE, process, eventListener, "Invalid or unsupported throw event type on event listener");

      } else if (eventListener.getImplementationType() == null || eventListener.getImplementationType().length() == 0) {

        addError(errors, Problems.EVENT_LISTENER_IMPLEMENTATION_MISSING, process, eventListener, "Element 'class', 'delegateExpression' or 'throwEvent' is mandatory on eventListener");

      } else if (eventListener.getImplementationType() != null) {

        if (!ImplementationType.IMPLEMENTATION_TYPE_CLASS.equals(eventListener.getImplementationType())
            && !ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.equals(eventListener.getImplementationType())
            && !ImplementationType.IMPLEMENTATION_TYPE_THROW_SIGNAL_EVENT.equals(eventListener.getImplementationType())
            && !ImplementationType.IMPLEMENTATION_TYPE_THROW_GLOBAL_SIGNAL_EVENT.equals(eventListener.getImplementationType())
            && !ImplementationType.IMPLEMENTATION_TYPE_THROW_MESSAGE_EVENT.equals(eventListener.getImplementationType())
            && !ImplementationType.IMPLEMENTATION_TYPE_THROW_ERROR_EVENT.equals(eventListener.getImplementationType())) {
          addError(errors, Problems.EVENT_LISTENER_INVALID_IMPLEMENTATION, process, eventListener, "Unsupported implementation type for event listener");
        }

      }

    }

  }
}
 
Example #16
Source File: ServiceTaskXMLConverter.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
protected BaseElement convertXMLToElement(XMLStreamReader xtr, BpmnModel model) throws Exception {
  ServiceTask serviceTask = new ServiceTask();
  BpmnXMLUtil.addXMLLocation(serviceTask, xtr);
  if (StringUtils.isNotEmpty(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_SERVICE_CLASS))) {
    serviceTask.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_CLASS);
    serviceTask.setImplementation(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_SERVICE_CLASS));

  } else if (StringUtils.isNotEmpty(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_SERVICE_EXPRESSION))) {
    serviceTask.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION);
    serviceTask.setImplementation(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_SERVICE_EXPRESSION));

  } else if (StringUtils.isNotEmpty(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_SERVICE_DELEGATEEXPRESSION))) {
    serviceTask.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION);
    serviceTask.setImplementation(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_SERVICE_DELEGATEEXPRESSION));

  } else if ("##WebService".equals(xtr.getAttributeValue(null, ATTRIBUTE_TASK_IMPLEMENTATION))) {
    serviceTask.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_WEBSERVICE);
    serviceTask.setOperationRef(parseOperationRef(xtr.getAttributeValue(null, ATTRIBUTE_TASK_OPERATION_REF), model));
  }

  serviceTask.setResultVariableName(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_SERVICE_RESULTVARIABLE));
  if (StringUtils.isEmpty(serviceTask.getResultVariableName())) {
    serviceTask.setResultVariableName(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "resultVariable"));
  }

  serviceTask.setType(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TYPE));
  serviceTask.setExtensionId(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_SERVICE_EXTENSIONID));

  if (StringUtils.isNotEmpty(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_SERVICE_SKIP_EXPRESSION))) {
    serviceTask.setSkipExpression(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_SERVICE_SKIP_EXPRESSION));
  }
  parseChildElements(getXMLElementName(), serviceTask, model, xtr);

  return serviceTask;
}
 
Example #17
Source File: SendTaskXMLConverter.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
protected BaseElement convertXMLToElement(XMLStreamReader xtr, BpmnModel model) throws Exception {
  SendTask sendTask = new SendTask();
  BpmnXMLUtil.addXMLLocation(sendTask, xtr);
  sendTask.setType(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TYPE));

  if ("##WebService".equals(xtr.getAttributeValue(null, ATTRIBUTE_TASK_IMPLEMENTATION))) {
    sendTask.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_WEBSERVICE);
    sendTask.setOperationRef(parseOperationRef(xtr.getAttributeValue(null, ATTRIBUTE_TASK_OPERATION_REF), model));
  }

  parseChildElements(getXMLElementName(), sendTask, model, xtr);

  return sendTask;
}
 
Example #18
Source File: ActivitiEventListenerParser.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 {
  EventListener listener = new EventListener();
  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_DELEGATEEXPRESSION))) {
    listener.setImplementation(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_DELEGATEEXPRESSION));
    listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION);
  } else if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_THROW_EVENT_TYPE))) {
    String eventType = xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_THROW_EVENT_TYPE);
    if (ATTRIBUTE_LISTENER_THROW_EVENT_TYPE_SIGNAL.equals(eventType)) {
      listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_THROW_SIGNAL_EVENT);
      listener.setImplementation(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_THROW_SIGNAL_EVENT_NAME));
    } else if (ATTRIBUTE_LISTENER_THROW_EVENT_TYPE_GLOBAL_SIGNAL.equals(eventType)) {
      listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_THROW_GLOBAL_SIGNAL_EVENT);
      listener.setImplementation(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_THROW_SIGNAL_EVENT_NAME));
    } else if (ATTRIBUTE_LISTENER_THROW_EVENT_TYPE_MESSAGE.equals(eventType)) {
      listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_THROW_MESSAGE_EVENT);
      listener.setImplementation(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_THROW_MESSAGE_EVENT_NAME));
    } else if (ATTRIBUTE_LISTENER_THROW_EVENT_TYPE_ERROR.equals(eventType)) {
      listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_THROW_ERROR_EVENT);
      listener.setImplementation(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_THROW_ERROR_EVENT_CODE));
    } else {
      listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_INVALID_THROW_EVENT);
    }
  }
  listener.setEvents(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_EVENTS));
  listener.setEntityType(xtr.getAttributeValue(null, ATTRIBUTE_LISTENER_ENTITY_TYPE));

  Process parentProcess = (Process) parentElement;
  parentProcess.getEventListeners().add(listener);
}
 
Example #19
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 #20
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 #21
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 #22
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))
      .deploymentProperty(DeploymentProperties.DEPLOY_AS_ACTIVITI5_PROCESS_DEFINITION, Boolean.TRUE)
      .deploy();
  repositoryService.deleteDeployment(deployment.getId());
}
 
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: CdiEventSupportBpmnParseHandler.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected void addActivitiListenerToUserTask(UserTask userTask, String event, Object instance) {
  ActivitiListener listener = new ActivitiListener();
  listener.setEvent(event);
  listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_INSTANCE);
  listener.setInstance(instance);
  userTask.getTaskListeners().add(listener);
}
 
Example #25
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 #26
Source File: ProcessParseHandler.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected void createEventListeners(BpmnParse bpmnParse, List<EventListener> eventListeners) {

    if (eventListeners != null && !eventListeners.isEmpty()) {
      for (EventListener eventListener : eventListeners) {
        // Extract specific event-types (if any)
        ActivitiEventType[] types = ActivitiEventType.getTypesFromString(eventListener.getEvents());

        if (ImplementationType.IMPLEMENTATION_TYPE_CLASS.equals(eventListener.getImplementationType())) {
          getEventSupport(bpmnParse.getBpmnModel()).addEventListener(bpmnParse.getListenerFactory().createClassDelegateEventListener(eventListener), types);
        
        } else if (ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.equals(eventListener.getImplementationType())) {
          getEventSupport(bpmnParse.getBpmnModel()).addEventListener(bpmnParse.getListenerFactory().createDelegateExpressionEventListener(eventListener), types);
        
        } else if (ImplementationType.IMPLEMENTATION_TYPE_THROW_SIGNAL_EVENT.equals(eventListener.getImplementationType())
            || ImplementationType.IMPLEMENTATION_TYPE_THROW_GLOBAL_SIGNAL_EVENT.equals(eventListener.getImplementationType())
            || ImplementationType.IMPLEMENTATION_TYPE_THROW_MESSAGE_EVENT.equals(eventListener.getImplementationType())
            || ImplementationType.IMPLEMENTATION_TYPE_THROW_ERROR_EVENT.equals(eventListener.getImplementationType())) {
        
          getEventSupport(bpmnParse.getBpmnModel()).addEventListener(bpmnParse.getListenerFactory().createEventThrowingEventListener(eventListener), types);
        
        } else {
          LOGGER.warn("Unsupported implementation type for EventListener: " + eventListener.getImplementationType() + " for element " + bpmnParse.getCurrentFlowElement().getId());
        }
      }
    }

  }
 
Example #27
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 #28
Source File: ServiceTaskInfoMapper.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected void mapProperties(Object element) {
	ServiceTask serviceTask = (ServiceTask) element;
	if (ImplementationType.IMPLEMENTATION_TYPE_CLASS.equals(serviceTask.getImplementationType())) {
		createPropertyNode("Class", serviceTask.getImplementation());
	} else if (ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION.equals(serviceTask.getImplementationType())) {
		createPropertyNode("Expression", serviceTask.getImplementation());
	} else if (ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.equals(serviceTask.getImplementationType())) {
		createPropertyNode("Delegate expression", serviceTask.getImplementation());
	}
	createPropertyNode("Result variable name", serviceTask.getResultVariableName());
}
 
Example #29
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 #30
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;
}