Search in sources :

Example 1 with ServiceTask

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;
}
Also used : ServiceTask(org.activiti.bpmn.model.ServiceTask) ScriptServiceTaskBuilder(org.activiti.workflow.simple.alfresco.conversion.script.ScriptServiceTaskBuilder)

Example 2 with 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;
}
Also used : ServiceTask(org.activiti.bpmn.model.ServiceTask)

Example 3 with 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);
    }
}
Also used : ServiceTask(org.activiti.bpmn.model.ServiceTask)

Example 4 with ServiceTask

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());
}
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 5 with ServiceTask

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);
}
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) TimerEventDefinition(org.activiti.bpmn.model.TimerEventDefinition)

Aggregations

ServiceTask (org.activiti.bpmn.model.ServiceTask)21 FlowElement (org.activiti.bpmn.model.FlowElement)9 FieldExtension (org.activiti.bpmn.model.FieldExtension)6 ActivitiListener (org.activiti.bpmn.model.ActivitiListener)4 UserTask (org.activiti.bpmn.model.UserTask)3 ScriptServiceTaskBuilder (org.activiti.workflow.simple.alfresco.conversion.script.ScriptServiceTaskBuilder)3 BoundaryEvent (org.activiti.bpmn.model.BoundaryEvent)2 MultiInstanceLoopCharacteristics (org.activiti.bpmn.model.MultiInstanceLoopCharacteristics)2 Process (org.activiti.bpmn.model.Process)2 SequenceFlow (org.activiti.bpmn.model.SequenceFlow)2 PropertyReference (org.activiti.workflow.simple.alfresco.conversion.script.PropertyReference)2 M2Model (org.activiti.workflow.simple.alfresco.model.M2Model)2 M2Type (org.activiti.workflow.simple.alfresco.model.M2Type)2 Test (org.junit.Test)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 List (java.util.List)1 Activity (org.activiti.bpmn.model.Activity)1 Artifact (org.activiti.bpmn.model.Artifact)1