Java Code Examples for org.activiti.bpmn.model.ServiceTask#getFieldExtensions()

The following examples show how to use org.activiti.bpmn.model.ServiceTask#getFieldExtensions() . 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: ServiceTaskJsonConverter.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected void setPropertyFieldValue(String name, ServiceTask task, ObjectNode propertiesNode) {
  for (FieldExtension extension : task.getFieldExtensions()) {
    if (name.substring(8).equalsIgnoreCase(extension.getFieldName())) {
      if (StringUtils.isNotEmpty(extension.getStringValue())) {
        setPropertyValue(name, extension.getStringValue(), propertiesNode);
      } else if (StringUtils.isNotEmpty(extension.getExpression())) {
        setPropertyValue(name, extension.getExpression(), propertiesNode);
      }
    }
  }
}
 
Example 2
Source File: ServiceTaskJsonConverter.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected void setPropertyFieldValue(String propertyName, String fieldName, ServiceTask task, ObjectNode propertiesNode) {
  for (FieldExtension extension : task.getFieldExtensions()) {
    if (fieldName.equalsIgnoreCase(extension.getFieldName())) {
      if (StringUtils.isNotEmpty(extension.getStringValue())) {
        setPropertyValue(propertyName, extension.getStringValue(), propertiesNode);
      } else if (StringUtils.isNotEmpty(extension.getExpression())) {
        setPropertyValue(propertyName, extension.getExpression(), propertiesNode);
      }
    }
  }
}
 
Example 3
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 4
Source File: ServiceTaskJsonConverter.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
protected void convertElementToJson(ObjectNode propertiesNode, BaseElement baseElement) {
  ServiceTask serviceTask = (ServiceTask) baseElement;

  if ("mail".equalsIgnoreCase(serviceTask.getType())) {
    setPropertyFieldValue(PROPERTY_MAILTASK_TO, serviceTask, propertiesNode);
    setPropertyFieldValue(PROPERTY_MAILTASK_FROM, serviceTask, propertiesNode);
    setPropertyFieldValue(PROPERTY_MAILTASK_SUBJECT, serviceTask, propertiesNode);
    setPropertyFieldValue(PROPERTY_MAILTASK_CC, serviceTask, propertiesNode);
    setPropertyFieldValue(PROPERTY_MAILTASK_BCC, serviceTask, propertiesNode);
    setPropertyFieldValue(PROPERTY_MAILTASK_TEXT, serviceTask, propertiesNode);
    setPropertyFieldValue(PROPERTY_MAILTASK_HTML, serviceTask, propertiesNode);
    setPropertyFieldValue(PROPERTY_MAILTASK_CHARSET, serviceTask, propertiesNode);

  } else if ("camel".equalsIgnoreCase(serviceTask.getType())) {
    setPropertyFieldValue(PROPERTY_CAMELTASK_CAMELCONTEXT, "camelContext", serviceTask, propertiesNode);

  } else if ("mule".equalsIgnoreCase(serviceTask.getType())) {
    setPropertyFieldValue(PROPERTY_MULETASK_ENDPOINT_URL, "endpointUrl", serviceTask, propertiesNode);
    setPropertyFieldValue(PROPERTY_MULETASK_LANGUAGE, "language", serviceTask, propertiesNode);
    setPropertyFieldValue(PROPERTY_MULETASK_PAYLOAD_EXPRESSION, "payloadExpression", serviceTask, propertiesNode);
    setPropertyFieldValue(PROPERTY_MULETASK_RESULT_VARIABLE, "resultVariable", serviceTask, propertiesNode);
    
  } else if ("dmn".equalsIgnoreCase(serviceTask.getType())) {
    for (FieldExtension fieldExtension : serviceTask.getFieldExtensions()) {
      if (PROPERTY_DECISIONTABLE_REFERENCE_KEY.equals(fieldExtension.getFieldName()) &&
          decisionTableKeyMap != null && decisionTableKeyMap.containsKey(fieldExtension.getStringValue())) {
        
        ObjectNode decisionReferenceNode = objectMapper.createObjectNode();
        propertiesNode.set(PROPERTY_DECISIONTABLE_REFERENCE, decisionReferenceNode);
        
        ModelInfo modelInfo = decisionTableKeyMap.get(fieldExtension.getStringValue());
        decisionReferenceNode.put("id", modelInfo.getId());
        decisionReferenceNode.put("name", modelInfo.getName());
        decisionReferenceNode.put("key", modelInfo.getKey());
      }
    }

  } else {

    if (ImplementationType.IMPLEMENTATION_TYPE_CLASS.equals(serviceTask.getImplementationType())) {
      propertiesNode.put(PROPERTY_SERVICETASK_CLASS, serviceTask.getImplementation());
    } else if (ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION.equals(serviceTask.getImplementationType())) {
      propertiesNode.put(PROPERTY_SERVICETASK_EXPRESSION, serviceTask.getImplementation());
    } else if (ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.equals(serviceTask.getImplementationType())) {
      propertiesNode.put(PROPERTY_SERVICETASK_DELEGATE_EXPRESSION, serviceTask.getImplementation());
    }

    if (StringUtils.isNotEmpty(serviceTask.getResultVariableName())) {
      propertiesNode.put(PROPERTY_SERVICETASK_RESULT_VARIABLE, serviceTask.getResultVariableName());
    }

    addFieldExtensions(serviceTask.getFieldExtensions(), propertiesNode);
  }
}
 
Example 5
Source File: CustomExtensionsConverterTest.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
private void validateModel(BpmnModel model) {
  Process process = model.getMainProcess();
  assertNotNull(process.getAttributes());
  assertEquals(1, process.getAttributes().size());
  List<ExtensionAttribute> attributes = process.getAttributes().get("version");
  assertNotNull(attributes);
  assertEquals(1, attributes.size());
  ExtensionAttribute attribute = attributes.get(0);
  // custom:version = "9"
  assertNotNull(attribute);
  assertEquals("http://custom.org/bpmn", attribute.getNamespace());
  assertEquals("custom", attribute.getNamespacePrefix());
  assertEquals("version", attribute.getName());
  assertEquals("9", attribute.getValue());

  List<ActivitiListener> listeners = model.getMainProcess().getExecutionListeners();
  validateExecutionListeners(listeners);
  Map<String, List<ExtensionElement>> extensionElementMap = model.getMainProcess().getExtensionElements();
  validateExtensionElements(extensionElementMap);

  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 = (FieldExtension) fields.get(0);
  assertEquals("testField", field.getFieldName());
  assertEquals("test", field.getStringValue());
  field = (FieldExtension) fields.get(1);
  assertEquals("testField2", field.getFieldName());
  assertEquals("${test}", field.getExpression());

  listeners = serviceTask.getExecutionListeners();
  validateExecutionListeners(listeners);

  extensionElementMap = serviceTask.getExtensionElements();
  validateExtensionElements(extensionElementMap);

  assertEquals(1, serviceTask.getBoundaryEvents().size());
  BoundaryEvent boundaryEvent = serviceTask.getBoundaryEvents().get(0);
  assertEquals("timerEvent", boundaryEvent.getId());
  assertEquals(1, boundaryEvent.getEventDefinitions().size());
  assertTrue(boundaryEvent.getEventDefinitions().get(0) instanceof TimerEventDefinition);
  extensionElementMap = boundaryEvent.getEventDefinitions().get(0).getExtensionElements();
  validateExtensionElements(extensionElementMap);
}