use of org.activiti.bpmn.model.ServiceTask in project Activiti by Activiti.
the class AlfrescoEmailStepConverter method createProcessArtifact.
@Override
protected ServiceTask createProcessArtifact(AlfrescoEmailStepDefinition stepDefinition, WorkflowDefinitionConversion conversion) {
ScriptServiceTaskBuilder builder = new ScriptServiceTaskBuilder();
builder.addLine("var mail = actions.create('mail');");
addMailActionParameter("to", getSafeJsString(stepDefinition.getTo()), builder);
addMailActionParameter("cc", getSafeJsString(stepDefinition.getCc()), builder);
addMailActionParameter("from", getSafeJsString(stepDefinition.getFrom()), builder);
addMailActionParameter("subject", getSafeJsString(stepDefinition.getSubject()), builder);
addMailActionParameter("text", getSafeJsString(stepDefinition.getBody()), builder);
builder.addLine("mail.execute(bpm_package);");
// Build the actual task and add it to the process
ServiceTask serviceTask = builder.build();
serviceTask.setName(stepDefinition.getName());
serviceTask.setId(conversion.getUniqueNumberedId(ConversionConstants.SERVICE_TASK_ID_PREFIX));
addFlowElement(conversion, serviceTask, true);
return serviceTask;
}
use of org.activiti.bpmn.model.ServiceTask in project Activiti by Activiti.
the class ServiceTaskXMLConverter method convertXMLToElement.
@Override
protected BaseElement convertXMLToElement(XMLStreamReader xtr, BpmnModel model) throws Exception {
ServiceTask serviceTask = new ServiceTask();
BpmnXMLUtil.addXMLLocation(serviceTask, xtr);
if (StringUtils.isNotEmpty(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_SERVICE_CLASS))) {
serviceTask.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_CLASS);
serviceTask.setImplementation(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_SERVICE_CLASS));
} else if (StringUtils.isNotEmpty(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_SERVICE_EXPRESSION))) {
serviceTask.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION);
serviceTask.setImplementation(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_SERVICE_EXPRESSION));
} else if (StringUtils.isNotEmpty(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_SERVICE_DELEGATEEXPRESSION))) {
serviceTask.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION);
serviceTask.setImplementation(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_SERVICE_DELEGATEEXPRESSION));
} else if ("##WebService".equals(xtr.getAttributeValue(null, ATTRIBUTE_TASK_IMPLEMENTATION))) {
serviceTask.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_WEBSERVICE);
serviceTask.setOperationRef(parseOperationRef(xtr.getAttributeValue(null, ATTRIBUTE_TASK_OPERATION_REF), model));
}
serviceTask.setResultVariableName(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_SERVICE_RESULTVARIABLE));
if (StringUtils.isEmpty(serviceTask.getResultVariableName())) {
serviceTask.setResultVariableName(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, "resultVariable"));
}
serviceTask.setType(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TYPE));
serviceTask.setExtensionId(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_SERVICE_EXTENSIONID));
if (StringUtils.isNotEmpty(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_SERVICE_SKIP_EXPRESSION))) {
serviceTask.setSkipExpression(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_SERVICE_SKIP_EXPRESSION));
}
parseChildElements(getXMLElementName(), serviceTask, model, xtr);
return serviceTask;
}
use of org.activiti.bpmn.model.ServiceTask in project Activiti by Activiti.
the class ServiceTaskValidator method executeValidation.
@Override
protected void executeValidation(BpmnModel bpmnModel, Process process, List<ValidationError> errors) {
List<ServiceTask> serviceTasks = process.findFlowElementsOfType(ServiceTask.class);
for (ServiceTask serviceTask : serviceTasks) {
verifyImplementation(process, serviceTask, errors);
verifyType(process, serviceTask, errors);
verifyResultVariableName(process, serviceTask, errors);
verifyWebservice(bpmnModel, process, serviceTask, errors);
}
}
use of org.activiti.bpmn.model.ServiceTask in project Activiti by Activiti.
the class ServiceTaskConverterTest method validateModel.
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());
}
use of org.activiti.bpmn.model.ServiceTask in project Activiti by Activiti.
the class CustomExtensionsConverterTest method validateModel.
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);
}
Aggregations