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());
}
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());
}
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);
}
}
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;
}
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;
}
Aggregations