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