Search in sources :

Example 11 with ActivitiListener

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

the class EventBasedGatewayConverterTest method validateModel.

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());
}
Also used : EventGateway(org.activiti.bpmn.model.EventGateway) FlowElement(org.activiti.bpmn.model.FlowElement) ActivitiListener(org.activiti.bpmn.model.ActivitiListener)

Example 12 with ActivitiListener

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

the class ActivitiListenerParser method parseChildElement.

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));
    addListenerToParent(listener, parentElement);
    parseChildElements(xtr, listener, model, new FieldExtensionParser());
}
Also used : ActivitiListener(org.activiti.bpmn.model.ActivitiListener)

Example 13 with ActivitiListener

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

the class FieldExtensionParser method parseChildElement.

public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception {
    if (!accepts(parentElement))
        return;
    FieldExtension extension = new FieldExtension();
    BpmnXMLUtil.addXMLLocation(extension, xtr);
    extension.setFieldName(xtr.getAttributeValue(null, ATTRIBUTE_FIELD_NAME));
    if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_FIELD_STRING))) {
        extension.setStringValue(xtr.getAttributeValue(null, ATTRIBUTE_FIELD_STRING));
    } else if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_FIELD_EXPRESSION))) {
        extension.setExpression(xtr.getAttributeValue(null, ATTRIBUTE_FIELD_EXPRESSION));
    } else {
        boolean readyWithFieldExtension = false;
        try {
            while (readyWithFieldExtension == false && xtr.hasNext()) {
                xtr.next();
                if (xtr.isStartElement() && ELEMENT_FIELD_STRING.equalsIgnoreCase(xtr.getLocalName())) {
                    extension.setStringValue(xtr.getElementText().trim());
                } else if (xtr.isStartElement() && ATTRIBUTE_FIELD_EXPRESSION.equalsIgnoreCase(xtr.getLocalName())) {
                    extension.setExpression(xtr.getElementText().trim());
                } else if (xtr.isEndElement() && getElementName().equalsIgnoreCase(xtr.getLocalName())) {
                    readyWithFieldExtension = true;
                }
            }
        } catch (Exception e) {
            LOGGER.warn("Error parsing field extension child elements", e);
        }
    }
    if (parentElement instanceof ActivitiListener) {
        ((ActivitiListener) parentElement).getFieldExtensions().add(extension);
    } else if (parentElement instanceof ServiceTask) {
        ((ServiceTask) parentElement).getFieldExtensions().add(extension);
    } else {
        ((SendTask) parentElement).getFieldExtensions().add(extension);
    }
}
Also used : ServiceTask(org.activiti.bpmn.model.ServiceTask) FieldExtension(org.activiti.bpmn.model.FieldExtension) SendTask(org.activiti.bpmn.model.SendTask) ActivitiListener(org.activiti.bpmn.model.ActivitiListener)

Example 14 with ActivitiListener

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

the class BpmnModelUtil method createSequenceFlow.

public static SequenceFlow createSequenceFlow(WorkflowDefinitionConversion conversion, FlowNode source, FlowNode target, ActivitiListener... executionListeners) {
    SequenceFlow sequenceFlow = new SequenceFlow();
    sequenceFlow.setId(conversion.getUniqueNumberedId(ConversionConstants.DEFAULT_SEQUENCEFLOW_PREFIX));
    sequenceFlow.setSourceRef(source.getId());
    sequenceFlow.setTargetRef(target.getId());
    if (executionListeners != null && executionListeners.length > 0) {
        List<ActivitiListener> listeners = new ArrayList<ActivitiListener>();
        for (ActivitiListener listener : executionListeners) {
            listeners.add(listener);
        }
        sequenceFlow.setExecutionListeners(listeners);
    }
    return sequenceFlow;
}
Also used : SequenceFlow(org.activiti.bpmn.model.SequenceFlow) ArrayList(java.util.ArrayList) ActivitiListener(org.activiti.bpmn.model.ActivitiListener)

Example 15 with ActivitiListener

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

the class ScriptTaskListenerBuilder method build.

public ActivitiListener build() {
    if (listener == null) {
        listener = new ActivitiListener();
        listener.setEvent(event);
        listener.setImplementationType(BpmnXMLConstants.ATTRIBUTE_LISTENER_CLASS);
        listener.setImplementation(AlfrescoConversionConstants.CLASSNAME_SCRIPT_TASK_LISTENER);
        FieldExtension scriptFieldElement = new FieldExtension();
        scriptFieldElement.setFieldName(AlfrescoConversionConstants.SCRIPT_TASK_LISTENER_SCRIPT_FIELD_NAME);
        scriptFieldElement.setStringValue(finalScript.toString());
        listener.getFieldExtensions().add(scriptFieldElement);
    }
    return listener;
}
Also used : FieldExtension(org.activiti.bpmn.model.FieldExtension) ActivitiListener(org.activiti.bpmn.model.ActivitiListener)

Aggregations

ActivitiListener (org.activiti.bpmn.model.ActivitiListener)19 FlowElement (org.activiti.bpmn.model.FlowElement)9 FieldExtension (org.activiti.bpmn.model.FieldExtension)8 UserTask (org.activiti.bpmn.model.UserTask)6 SequenceFlow (org.activiti.bpmn.model.SequenceFlow)4 ServiceTask (org.activiti.bpmn.model.ServiceTask)4 FormProperty (org.activiti.bpmn.model.FormProperty)3 Process (org.activiti.bpmn.model.Process)3 StartEvent (org.activiti.bpmn.model.StartEvent)3 TimerEventDefinition (org.activiti.bpmn.model.TimerEventDefinition)3 BoundaryEvent (org.activiti.bpmn.model.BoundaryEvent)2 EndEvent (org.activiti.bpmn.model.EndEvent)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 BpmnXMLConverter (org.activiti.bpmn.converter.BpmnXMLConverter)1