Search in sources :

Example 31 with FieldExtension

use of org.activiti.bpmn.model.FieldExtension in project Activiti by Activiti.

the class CustomExtensionsConverterTest method validateModel.

private void validateModel(BpmnModel model) {
    Process process = model.getMainProcess();
    assertThat(process.getAttributes()).isNotNull();
    assertThat(process.getAttributes()).hasSize(1);
    List<ExtensionAttribute> attributes = process.getAttributes().get("version");
    assertThat(attributes).isNotNull();
    assertThat(attributes).hasSize(1);
    ExtensionAttribute attribute = attributes.get(0);
    // custom:version = "9"
    assertThat(attribute).isNotNull();
    assertThat(attribute.getNamespace()).isEqualTo("http://custom.org/bpmn");
    assertThat(attribute.getNamespacePrefix()).isEqualTo("custom");
    assertThat(attribute.getName()).isEqualTo("version");
    assertThat(attribute.getValue()).isEqualTo("9");
    List<ActivitiListener> listeners = model.getMainProcess().getExecutionListeners();
    validateExecutionListeners(listeners);
    Map<String, List<ExtensionElement>> extensionElementMap = model.getMainProcess().getExtensionElements();
    validateExtensionElements(extensionElementMap);
    FlowElement flowElement = model.getMainProcess().getFlowElement("servicetask");
    assertThat(flowElement).isNotNull();
    assertThat(flowElement).isInstanceOf(ServiceTask.class);
    assertThat(flowElement.getId()).isEqualTo("servicetask");
    ServiceTask serviceTask = (ServiceTask) flowElement;
    assertThat(serviceTask.getId()).isEqualTo("servicetask");
    assertThat(serviceTask.getName()).isEqualTo("Service task");
    List<FieldExtension> fields = serviceTask.getFieldExtensions();
    assertThat(fields).hasSize(2);
    FieldExtension field = (FieldExtension) fields.get(0);
    assertThat(field.getFieldName()).isEqualTo("testField");
    assertThat(field.getStringValue()).isEqualTo("test");
    field = (FieldExtension) fields.get(1);
    assertThat(field.getFieldName()).isEqualTo("testField2");
    assertThat(field.getExpression()).isEqualTo("${test}");
    listeners = serviceTask.getExecutionListeners();
    validateExecutionListeners(listeners);
    extensionElementMap = serviceTask.getExtensionElements();
    validateExtensionElements(extensionElementMap);
    assertThat(serviceTask.getBoundaryEvents()).hasSize(1);
    BoundaryEvent boundaryEvent = serviceTask.getBoundaryEvents().get(0);
    assertThat(boundaryEvent.getId()).isEqualTo("timerEvent");
    assertThat(boundaryEvent.getEventDefinitions()).hasSize(1);
    assertThat(boundaryEvent.getEventDefinitions().get(0)).isInstanceOf(TimerEventDefinition.class);
    extensionElementMap = boundaryEvent.getEventDefinitions().get(0).getExtensionElements();
    validateExtensionElements(extensionElementMap);
}
Also used : ServiceTask(org.activiti.bpmn.model.ServiceTask) BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent) Process(org.activiti.bpmn.model.Process) ActivitiListener(org.activiti.bpmn.model.ActivitiListener) ExtensionAttribute(org.activiti.bpmn.model.ExtensionAttribute) FlowElement(org.activiti.bpmn.model.FlowElement) FieldExtension(org.activiti.bpmn.model.FieldExtension) List(java.util.List)

Example 32 with FieldExtension

use of org.activiti.bpmn.model.FieldExtension in project Activiti by Activiti.

the class ServiceTaskConverterTest method validateModel.

private void validateModel(BpmnModel model) {
    FlowElement flowElement = model.getMainProcess().getFlowElement("servicetask");
    assertThat(flowElement).isNotNull();
    assertThat(flowElement).isInstanceOf(ServiceTask.class);
    assertThat(flowElement.getId()).isEqualTo("servicetask");
    ServiceTask serviceTask = (ServiceTask) flowElement;
    assertThat(serviceTask.getId()).isEqualTo("servicetask");
    assertThat(serviceTask.getName()).isEqualTo("Service task");
    List<FieldExtension> fields = serviceTask.getFieldExtensions();
    assertThat(fields).hasSize(2);
    FieldExtension field = fields.get(0);
    assertThat(field.getFieldName()).isEqualTo("testField");
    assertThat(field.getStringValue()).isEqualTo("test");
    field = fields.get(1);
    assertThat(field.getFieldName()).isEqualTo("testField2");
    assertThat(field.getExpression()).isEqualTo("${test}");
    List<ActivitiListener> listeners = serviceTask.getExecutionListeners();
    assertThat(listeners).hasSize(3);
    ActivitiListener listener = listeners.get(0);
    assertThat(ImplementationType.IMPLEMENTATION_TYPE_CLASS.equals(listener.getImplementationType())).isTrue();
    assertThat(listener.getImplementation()).isEqualTo("org.test.TestClass");
    assertThat(listener.getEvent()).isEqualTo("start");
    listener = listeners.get(1);
    assertThat(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION.equals(listener.getImplementationType())).isTrue();
    assertThat(listener.getImplementation()).isEqualTo("${testExpression}");
    assertThat(listener.getEvent()).isEqualTo("end");
    listener = listeners.get(2);
    assertThat(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.equals(listener.getImplementationType())).isTrue();
    assertThat(listener.getImplementation()).isEqualTo("${delegateExpression}");
    assertThat(listener.getEvent()).isEqualTo("start");
    assertThat(serviceTask.getFailedJobRetryTimeCycleValue()).isEqualTo("R5/PT5M");
}
Also used : ServiceTask(org.activiti.bpmn.model.ServiceTask) FlowElement(org.activiti.bpmn.model.FlowElement) FieldExtension(org.activiti.bpmn.model.FieldExtension) ActivitiListener(org.activiti.bpmn.model.ActivitiListener)

Example 33 with FieldExtension

use of org.activiti.bpmn.model.FieldExtension in project Activiti by Activiti.

the class AbstractBehaviorFactory method createFieldDeclarations.

public List<FieldDeclaration> createFieldDeclarations(List<FieldExtension> fieldList) {
    List<FieldDeclaration> fieldDeclarations = new ArrayList<FieldDeclaration>();
    for (FieldExtension fieldExtension : fieldList) {
        FieldDeclaration fieldDeclaration = null;
        if (StringUtils.isNotEmpty(fieldExtension.getExpression())) {
            fieldDeclaration = new FieldDeclaration(fieldExtension.getFieldName(), Expression.class.getName(), expressionManager.createExpression(fieldExtension.getExpression()));
        } else {
            fieldDeclaration = new FieldDeclaration(fieldExtension.getFieldName(), Expression.class.getName(), new FixedValue(fieldExtension.getStringValue()));
        }
        fieldDeclarations.add(fieldDeclaration);
    }
    return fieldDeclarations;
}
Also used : FieldExtension(org.activiti.bpmn.model.FieldExtension) ArrayList(java.util.ArrayList) FixedValue(org.activiti.engine.impl.el.FixedValue) FieldDeclaration(org.activiti.engine.impl.bpmn.parser.FieldDeclaration)

Example 34 with FieldExtension

use of org.activiti.bpmn.model.FieldExtension in project Activiti by Activiti.

the class BpmnJsonConverterUtil method parseListeners.

protected static void parseListeners(JsonNode listenersNode, BaseElement element, boolean isTaskListener) {
    if (listenersNode == null)
        return;
    listenersNode = validateIfNodeIsTextual(listenersNode);
    for (JsonNode listenerNode : listenersNode) {
        listenerNode = validateIfNodeIsTextual(listenerNode);
        JsonNode eventNode = listenerNode.get(PROPERTY_LISTENER_EVENT);
        if (eventNode != null && !eventNode.isNull() && StringUtils.isNotEmpty(eventNode.asText())) {
            ActivitiListener listener = new ActivitiListener();
            listener.setEvent(eventNode.asText());
            if (StringUtils.isNotEmpty(getValueAsString(PROPERTY_LISTENER_CLASS_NAME, listenerNode))) {
                listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_CLASS);
                listener.setImplementation(getValueAsString(PROPERTY_LISTENER_CLASS_NAME, listenerNode));
            } else if (StringUtils.isNotEmpty(getValueAsString(PROPERTY_LISTENER_EXPRESSION, listenerNode))) {
                listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION);
                listener.setImplementation(getValueAsString(PROPERTY_LISTENER_EXPRESSION, listenerNode));
            } else if (StringUtils.isNotEmpty(getValueAsString(PROPERTY_LISTENER_DELEGATE_EXPRESSION, listenerNode))) {
                listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION);
                listener.setImplementation(getValueAsString(PROPERTY_LISTENER_DELEGATE_EXPRESSION, listenerNode));
            }
            JsonNode fieldsNode = listenerNode.get(PROPERTY_LISTENER_FIELDS);
            if (fieldsNode != null) {
                for (JsonNode fieldNode : fieldsNode) {
                    JsonNode nameNode = fieldNode.get(PROPERTY_FIELD_NAME);
                    if (nameNode != null && !nameNode.isNull() && StringUtils.isNotEmpty(nameNode.asText())) {
                        FieldExtension fieldExtension = new FieldExtension();
                        fieldExtension.setFieldName(nameNode.asText());
                        fieldExtension.setStringValue(getValueAsString(PROPERTY_FIELD_STRING_VALUE, fieldNode));
                        if (StringUtils.isEmpty(fieldExtension.getStringValue())) {
                            fieldExtension.setStringValue(getValueAsString(PROPERTY_FIELD_STRING, fieldNode));
                        }
                        if (StringUtils.isEmpty(fieldExtension.getStringValue())) {
                            fieldExtension.setExpression(getValueAsString(PROPERTY_FIELD_EXPRESSION, fieldNode));
                        }
                        listener.getFieldExtensions().add(fieldExtension);
                    }
                }
            }
            if (element instanceof Process) {
                ((Process) element).getExecutionListeners().add(listener);
            } else if (element instanceof SequenceFlow) {
                ((SequenceFlow) element).getExecutionListeners().add(listener);
            } else if (element instanceof UserTask) {
                if (isTaskListener) {
                    ((UserTask) element).getTaskListeners().add(listener);
                } else {
                    ((UserTask) element).getExecutionListeners().add(listener);
                }
            } else if (element instanceof FlowElement) {
                ((FlowElement) element).getExecutionListeners().add(listener);
            }
        }
    }
}
Also used : FieldExtension(org.activiti.bpmn.model.FieldExtension) SequenceFlow(org.activiti.bpmn.model.SequenceFlow) FlowElement(org.activiti.bpmn.model.FlowElement) UserTask(org.activiti.bpmn.model.UserTask) JsonNode(com.fasterxml.jackson.databind.JsonNode) Process(org.activiti.bpmn.model.Process) ActivitiListener(org.activiti.bpmn.model.ActivitiListener)

Example 35 with FieldExtension

use of org.activiti.bpmn.model.FieldExtension in project Activiti by Activiti.

the class ExternalInvocationTaskValidator method validateFieldDeclarationsForEmail.

protected void validateFieldDeclarationsForEmail(org.activiti.bpmn.model.Process process, TaskWithFieldExtensions task, List<FieldExtension> fieldExtensions, List<ValidationError> errors) {
    boolean toDefined = false;
    boolean textOrHtmlDefined = false;
    for (FieldExtension fieldExtension : fieldExtensions) {
        if (fieldExtension.getFieldName().equals("to")) {
            toDefined = true;
        }
        if (fieldExtension.getFieldName().equals("html")) {
            textOrHtmlDefined = true;
        }
        if (fieldExtension.getFieldName().equals("htmlVar")) {
            textOrHtmlDefined = true;
        }
        if (fieldExtension.getFieldName().equals("text")) {
            textOrHtmlDefined = true;
        }
        if (fieldExtension.getFieldName().equals("textVar")) {
            textOrHtmlDefined = true;
        }
    }
    if (!toDefined) {
        addError(errors, Problems.MAIL_TASK_NO_RECIPIENT, process, task, "No recipient is defined on the mail activity");
    }
    if (!textOrHtmlDefined) {
        addError(errors, Problems.MAIL_TASK_NO_CONTENT, process, task, "Text, html, textVar or htmlVar field should be provided");
    }
}
Also used : FieldExtension(org.activiti.bpmn.model.FieldExtension)

Aggregations

FieldExtension (org.activiti.bpmn.model.FieldExtension)94 ArrayList (java.util.ArrayList)68 Test (org.junit.Test)67 Parameter (org.finra.herd.model.api.xml.Parameter)64 HashMap (java.util.HashMap)55 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)24 BusinessObjectDataAttribute (org.finra.herd.model.api.xml.BusinessObjectDataAttribute)12 Job (org.finra.herd.model.api.xml.Job)11 ServiceTask (org.activiti.bpmn.model.ServiceTask)10 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)10 BusinessObjectDataAttributeEntity (org.finra.herd.model.jpa.BusinessObjectDataAttributeEntity)9 AbstractServiceTest (org.finra.herd.service.AbstractServiceTest)9 ActivitiListener (org.activiti.bpmn.model.ActivitiListener)8 FieldDeclaration (org.activiti.engine.impl.bpmn.parser.FieldDeclaration)4 BusinessObjectDataStorageUnitKey (org.finra.herd.model.api.xml.BusinessObjectDataStorageUnitKey)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3 FlowElement (org.activiti.bpmn.model.FlowElement)3 Attribute (org.finra.herd.model.api.xml.Attribute)3 BusinessObjectDataAttributeKeys (org.finra.herd.model.api.xml.BusinessObjectDataAttributeKeys)3