Search in sources :

Example 1 with EndEvent

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

the class AsyncEndEventConverterTest method validateModel.

private void validateModel(BpmnModel model) {
    FlowElement flowElement = model.getMainProcess().getFlowElement("endEvent");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof EndEvent);
    assertEquals("endEvent", flowElement.getId());
    EndEvent endEvent = (EndEvent) flowElement;
    assertEquals("endEvent", endEvent.getId());
    assertTrue(endEvent.isAsynchronous());
    List<ActivitiListener> listeners = endEvent.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 : FlowElement(org.activiti.bpmn.model.FlowElement) EndEvent(org.activiti.bpmn.model.EndEvent) ActivitiListener(org.activiti.bpmn.model.ActivitiListener)

Example 2 with EndEvent

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

the class AlfrescoEndProcessStepConverter method createProcessArtifact.

@Override
protected EndEvent createProcessArtifact(AlfrescoEndProcessStepDefinition stepDefinition, WorkflowDefinitionConversion conversion) {
    EndEvent endEvent = new EndEvent();
    endEvent.setId(conversion.getUniqueNumberedId(ConversionConstants.EVENT_ID_PREFIX));
    addFlowElement(conversion, endEvent, true);
    return endEvent;
}
Also used : EndEvent(org.activiti.bpmn.model.EndEvent)

Example 3 with EndEvent

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

the class DefaultWorkflowDefinitionConversionListener method afterStepsConversion.

public void afterStepsConversion(WorkflowDefinitionConversion conversion) {
    // Add end-event to process
    Process process = conversion.getProcess();
    EndEvent endEvent = new EndEvent();
    endEvent.setId(END_EVENT_ID);
    process.addFlowElement(endEvent);
    // Sequence flow from last created activity to end
    SequenceFlow sequenceFlow = new SequenceFlow();
    sequenceFlow.setId(conversion.getUniqueNumberedId(ConversionConstants.DEFAULT_SEQUENCEFLOW_PREFIX));
    sequenceFlow.setSourceRef(conversion.getLastActivityId());
    sequenceFlow.setTargetRef(END_EVENT_ID);
    process.addFlowElement(sequenceFlow);
    // To make the generated workflow compatible with some tools (eg the
    // Modeler, but also others),
    // We must add the ingoing and outgoing sequence flow to each of the flow
    // nodes
    SequenceFlowMapping sequenceFlowMapping = generateSequenceflowMappings(process);
    for (FlowNode flowNode : process.findFlowElementsOfType(FlowNode.class)) {
        List<SequenceFlow> incomingSequenceFlow = sequenceFlowMapping.getIncomingSequenceFlowMapping().get(flowNode.getId());
        if (incomingSequenceFlow != null) {
            flowNode.setIncomingFlows(incomingSequenceFlow);
        }
        List<SequenceFlow> outgoingSequenceFlow = sequenceFlowMapping.getOutgoingSequenceFlowMapping().get(flowNode.getId());
        if (outgoingSequenceFlow != null) {
            flowNode.setOutgoingFlows(outgoingSequenceFlow);
        }
    }
}
Also used : SequenceFlow(org.activiti.bpmn.model.SequenceFlow) EndEvent(org.activiti.bpmn.model.EndEvent) Process(org.activiti.bpmn.model.Process) FlowNode(org.activiti.bpmn.model.FlowNode)

Example 4 with EndEvent

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

the class ChoiceStepsDefinitionConverter method createProcessArtifact.

protected ExclusiveGateway createProcessArtifact(ChoiceStepsDefinition choiceStepsDefinition, WorkflowDefinitionConversion conversion) {
    // First choice gateway
    ExclusiveGateway forkGateway = createExclusiveGateway(conversion);
    // Sequence flow from last activity to first gateway
    addSequenceFlow(conversion, conversion.getLastActivityId(), forkGateway.getId());
    conversion.setLastActivityId(forkGateway.getId());
    // Convert all other steps, disabling activity id updates which makes all 
    // generated steps have a sequence flow to the first gateway
    WorkflowDefinitionConversionFactory conversionFactory = conversion.getConversionFactory();
    List<FlowElement> endElements = new ArrayList<FlowElement>();
    List<SequenceFlow> bypassingFlows = new ArrayList<SequenceFlow>();
    for (ListConditionStepDefinition<ChoiceStepsDefinition> stepListDefinition : choiceStepsDefinition.getStepList()) {
        StringBuilder conditionBuilder = new StringBuilder();
        for (ConditionDefinition conditionDefintion : stepListDefinition.getConditions()) {
            if (conditionBuilder.length() > 0) {
                conditionBuilder.append(" && ");
            } else {
                conditionBuilder.append("${");
            }
            conditionBuilder.append(conditionDefintion.getLeftOperand());
            conditionBuilder.append(" ");
            conditionBuilder.append(conditionDefintion.getOperator());
            conditionBuilder.append(" ");
            conditionBuilder.append(conditionDefintion.getRightOperand());
        }
        for (int i = 0; i < stepListDefinition.getSteps().size(); i++) {
            if (i == 0) {
                conversion.setSequenceflowGenerationEnabled(false);
            } else {
                conversion.setSequenceflowGenerationEnabled(true);
            }
            StepDefinition step = stepListDefinition.getSteps().get(i);
            FlowElement flowElement = (FlowElement) conversionFactory.getStepConverterFor(step).convertStepDefinition(step, conversion);
            if (i == 0) {
                if (conditionBuilder.length() > 0) {
                    conditionBuilder.append("}");
                    SequenceFlow mainFlow = addSequenceFlow(conversion, forkGateway.getId(), flowElement.getId(), conditionBuilder.toString());
                    if (stepListDefinition.getName() != null) {
                        mainFlow.setName(stepListDefinition.getName());
                    }
                } else {
                    addSequenceFlow(conversion, forkGateway.getId(), flowElement.getId());
                }
            }
            if ((i + 1) == stepListDefinition.getSteps().size()) {
                endElements.add(flowElement);
            }
        }
        if (stepListDefinition.getSteps().isEmpty()) {
            // Special case for a "stepless" stepListDefinition, which should just create a sequence-flow from the fork to the join
            SequenceFlow created = null;
            if (conditionBuilder.length() > 0) {
                conditionBuilder.append("}");
                created = addSequenceFlow(conversion, forkGateway.getId(), null, conditionBuilder.toString());
            } else {
                created = addSequenceFlow(conversion, forkGateway.getId(), null);
            }
            if (stepListDefinition.getName() != null) {
                created.setName(stepListDefinition.getName());
            }
            bypassingFlows.add(created);
        }
    }
    conversion.setSequenceflowGenerationEnabled(false);
    // Second choice gateway
    ExclusiveGateway joinGateway = createExclusiveGateway(conversion);
    conversion.setLastActivityId(joinGateway.getId());
    conversion.setSequenceflowGenerationEnabled(true);
    // Create sequenceflow from all generated steps to the second gateway
    for (FlowElement endElement : endElements) {
        if (!(endElement instanceof EndEvent)) {
            addSequenceFlow(conversion, endElement.getId(), joinGateway.getId());
        }
    }
    for (SequenceFlow bypassingFlow : bypassingFlows) {
        bypassingFlow.setTargetRef(joinGateway.getId());
    }
    return forkGateway;
}
Also used : SequenceFlow(org.activiti.bpmn.model.SequenceFlow) ChoiceStepsDefinition(org.activiti.workflow.simple.definition.ChoiceStepsDefinition) ArrayList(java.util.ArrayList) ExclusiveGateway(org.activiti.bpmn.model.ExclusiveGateway) WorkflowDefinitionConversionFactory(org.activiti.workflow.simple.converter.WorkflowDefinitionConversionFactory) FlowElement(org.activiti.bpmn.model.FlowElement) StepDefinition(org.activiti.workflow.simple.definition.StepDefinition) ListConditionStepDefinition(org.activiti.workflow.simple.definition.ListConditionStepDefinition) EndEvent(org.activiti.bpmn.model.EndEvent) ConditionDefinition(org.activiti.workflow.simple.definition.ConditionDefinition)

Example 5 with EndEvent

use of org.activiti.bpmn.model.EndEvent in project herd by FINRAOS.

the class JobDefinitionServiceTest method testUpdateJobDefinitionAssertSuccessWhenFirstTaskAsync.

/**
 * Asserts that update job definition proceeds without exceptions when first task is set to async
 *
 * @throws Exception
 */
@Test
public void testUpdateJobDefinitionAssertSuccessWhenFirstTaskAsync() throws Exception {
    String namespace = NAMESPACE;
    String jobName = JOB_NAME;
    BpmnModel bpmnModel = new BpmnModel();
    Process process = new Process();
    process.setId(namespace + '.' + jobName);
    {
        StartEvent element = new StartEvent();
        element.setId("start");
        process.addFlowElement(element);
    }
    {
        ScriptTask element = new ScriptTask();
        element.setId("script");
        element.setScriptFormat("js");
        element.setScript("// do nothing");
        element.setAsynchronous(true);
        process.addFlowElement(element);
    }
    {
        EndEvent element = new EndEvent();
        element.setId("end");
        process.addFlowElement(element);
    }
    process.addFlowElement(new SequenceFlow("start", "script"));
    process.addFlowElement(new SequenceFlow("script", "end"));
    bpmnModel.addProcess(process);
    String activitiJobXml = getActivitiXmlFromBpmnModel(bpmnModel);
    namespaceDaoTestHelper.createNamespaceEntity(namespace);
    jobDefinitionService.createJobDefinition(new JobDefinitionCreateRequest(namespace, jobName, null, activitiJobXml, null, null), true);
    jobDefinitionService.updateJobDefinition(namespace, jobName, new JobDefinitionUpdateRequest(null, activitiJobXml, null, null), true);
// Assert no exceptions
}
Also used : ScriptTask(org.activiti.bpmn.model.ScriptTask) SequenceFlow(org.activiti.bpmn.model.SequenceFlow) StartEvent(org.activiti.bpmn.model.StartEvent) JobDefinitionCreateRequest(org.finra.herd.model.api.xml.JobDefinitionCreateRequest) EndEvent(org.activiti.bpmn.model.EndEvent) Process(org.activiti.bpmn.model.Process) BpmnModel(org.activiti.bpmn.model.BpmnModel) JobDefinitionUpdateRequest(org.finra.herd.model.api.xml.JobDefinitionUpdateRequest) Test(org.junit.Test)

Aggregations

EndEvent (org.activiti.bpmn.model.EndEvent)24 SequenceFlow (org.activiti.bpmn.model.SequenceFlow)14 StartEvent (org.activiti.bpmn.model.StartEvent)13 BpmnModel (org.activiti.bpmn.model.BpmnModel)11 Process (org.activiti.bpmn.model.Process)9 UserTask (org.activiti.bpmn.model.UserTask)6 Test (org.junit.Test)5 ScriptTask (org.activiti.bpmn.model.ScriptTask)4 JobDefinitionCreateRequest (org.finra.herd.model.api.xml.JobDefinitionCreateRequest)4 FlowElement (org.activiti.bpmn.model.FlowElement)3 TerminateEventDefinition (org.activiti.bpmn.model.TerminateEventDefinition)3 ActivitiListener (org.activiti.bpmn.model.ActivitiListener)2 CancelEventDefinition (org.activiti.bpmn.model.CancelEventDefinition)2 ErrorEventDefinition (org.activiti.bpmn.model.ErrorEventDefinition)2 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ArrayList (java.util.ArrayList)1 BpmnXMLConverter (org.activiti.bpmn.converter.BpmnXMLConverter)1 EventDefinition (org.activiti.bpmn.model.EventDefinition)1 ExclusiveGateway (org.activiti.bpmn.model.ExclusiveGateway)1