Search in sources :

Example 1 with StartEvent

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

the class TimerEventDefinitionParseHandler method executeParse.

protected void executeParse(BpmnParse bpmnParse, TimerEventDefinition timerEventDefinition) {
    ActivityImpl timerActivity = bpmnParse.getCurrentActivity();
    if (bpmnParse.getCurrentFlowElement() instanceof StartEvent) {
        ProcessDefinitionEntity processDefinition = bpmnParse.getCurrentProcessDefinition();
        timerActivity.setProperty("type", "startTimerEvent");
        TimerDeclarationImpl timerDeclaration = createTimer(bpmnParse, timerEventDefinition, timerActivity, TimerStartEventJobHandler.TYPE);
        String jobHandlerConfiguration = timerDeclaration.getJobHandlerConfiguration();
        Map<String, JobHandler> jobHandlers = Context.getProcessEngineConfiguration().getJobHandlers();
        JobHandler jobHandler = jobHandlers.get(TimerStartEventJobHandler.TYPE);
        jobHandlerConfiguration = ((TimerEventHandler) jobHandler).setProcessDefinitionKeyToConfiguration(jobHandlerConfiguration, processDefinition.getKey());
        jobHandlerConfiguration = ((TimerEventHandler) jobHandler).setActivityIdToConfiguration(jobHandlerConfiguration, timerActivity.getId());
        timerDeclaration.setJobHandlerConfiguration(jobHandlerConfiguration);
        List<TimerDeclarationImpl> timerDeclarations = (List<TimerDeclarationImpl>) processDefinition.getProperty(PROPERTYNAME_START_TIMER);
        if (timerDeclarations == null) {
            timerDeclarations = new ArrayList<TimerDeclarationImpl>();
            processDefinition.setProperty(PROPERTYNAME_START_TIMER, timerDeclarations);
        }
        timerDeclarations.add(timerDeclaration);
    } else if (bpmnParse.getCurrentFlowElement() instanceof IntermediateCatchEvent) {
        timerActivity.setProperty("type", "intermediateTimer");
        TimerDeclarationImpl timerDeclaration = createTimer(bpmnParse, timerEventDefinition, timerActivity, TimerCatchIntermediateEventJobHandler.TYPE);
        if (getPrecedingEventBasedGateway(bpmnParse, (IntermediateCatchEvent) bpmnParse.getCurrentFlowElement()) != null) {
            addTimerDeclaration(timerActivity.getParent(), timerDeclaration);
        } else {
            addTimerDeclaration(timerActivity, timerDeclaration);
            timerActivity.setScope(true);
        }
    } else if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent) {
        timerActivity.setProperty("type", "boundaryTimer");
        TimerDeclarationImpl timerDeclaration = createTimer(bpmnParse, timerEventDefinition, timerActivity, TimerExecuteNestedActivityJobHandler.TYPE);
        // ACT-1427
        BoundaryEvent boundaryEvent = (BoundaryEvent) bpmnParse.getCurrentFlowElement();
        boolean interrupting = boundaryEvent.isCancelActivity();
        if (interrupting) {
            timerDeclaration.setInterruptingTimer(true);
        }
        addTimerDeclaration(timerActivity.getParent(), timerDeclaration);
        if (timerActivity.getParent() instanceof ActivityImpl) {
            ((ActivityImpl) timerActivity.getParent()).setScope(true);
        }
        timerActivity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createBoundaryEventActivityBehavior((BoundaryEvent) bpmnParse.getCurrentFlowElement(), interrupting, timerActivity));
    }
}
Also used : TimerDeclarationImpl(org.activiti.engine.impl.jobexecutor.TimerDeclarationImpl) BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent) IntermediateCatchEvent(org.activiti.bpmn.model.IntermediateCatchEvent) TimerStartEventJobHandler(org.activiti.engine.impl.jobexecutor.TimerStartEventJobHandler) TimerCatchIntermediateEventJobHandler(org.activiti.engine.impl.jobexecutor.TimerCatchIntermediateEventJobHandler) TimerExecuteNestedActivityJobHandler(org.activiti.engine.impl.jobexecutor.TimerExecuteNestedActivityJobHandler) JobHandler(org.activiti.engine.impl.jobexecutor.JobHandler) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) StartEvent(org.activiti.bpmn.model.StartEvent) ArrayList(java.util.ArrayList) List(java.util.List) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)

Example 2 with StartEvent

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

the class SignalEventDefinitionParseHandler method executeParse.

protected void executeParse(BpmnParse bpmnParse, SignalEventDefinition signalDefinition) {
    Signal signal = null;
    if (bpmnParse.getBpmnModel().containsSignalId(signalDefinition.getSignalRef())) {
        signal = bpmnParse.getBpmnModel().getSignal(signalDefinition.getSignalRef());
        String signalName = signal.getName();
        signalDefinition.setSignalRef(signalName);
    }
    if (signal == null) {
        return;
    }
    ActivityImpl activity = bpmnParse.getCurrentActivity();
    if (bpmnParse.getCurrentFlowElement() instanceof StartEvent) {
        activity.setProperty("type", "signalStartEvent");
        EventSubscriptionDeclaration eventSubscriptionDeclaration = new EventSubscriptionDeclaration(signalDefinition.getSignalRef(), "signal");
        eventSubscriptionDeclaration.setActivityId(activity.getId());
        eventSubscriptionDeclaration.setStartEvent(true);
        addEventSubscriptionDeclaration(bpmnParse, eventSubscriptionDeclaration, signalDefinition, bpmnParse.getCurrentScope());
    } else if (bpmnParse.getCurrentFlowElement() instanceof IntermediateCatchEvent) {
        activity.setProperty("type", "intermediateSignalCatch");
        EventSubscriptionDeclaration eventSubscriptionDeclaration = new EventSubscriptionDeclaration(signalDefinition.getSignalRef(), "signal");
        if (signal.getScope() != null) {
            eventSubscriptionDeclaration.setConfiguration(signal.getScope());
        }
        if (getPrecedingEventBasedGateway(bpmnParse, (IntermediateCatchEvent) bpmnParse.getCurrentFlowElement()) != null) {
            eventSubscriptionDeclaration.setActivityId(activity.getId());
            addEventSubscriptionDeclaration(bpmnParse, eventSubscriptionDeclaration, signalDefinition, activity.getParent());
        } else {
            activity.setScope(true);
            addEventSubscriptionDeclaration(bpmnParse, eventSubscriptionDeclaration, signalDefinition, activity);
        }
    } else if (bpmnParse.getCurrentFlowElement() instanceof ThrowEvent) {
        ThrowEvent throwEvent = (ThrowEvent) bpmnParse.getCurrentFlowElement();
        activity.setProperty("type", "intermediateSignalThrow");
        EventSubscriptionDeclaration eventSubscriptionDeclaration = new EventSubscriptionDeclaration(signalDefinition.getSignalRef(), "signal");
        eventSubscriptionDeclaration.setAsync(signalDefinition.isAsync());
        activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createIntermediateThrowSignalEventActivityBehavior(throwEvent, signal, eventSubscriptionDeclaration));
    } else if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent) {
        BoundaryEvent boundaryEvent = (BoundaryEvent) bpmnParse.getCurrentFlowElement();
        boolean interrupting = boundaryEvent.isCancelActivity();
        activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createBoundaryEventActivityBehavior(boundaryEvent, interrupting, activity));
        activity.setProperty("type", "boundarySignal");
        EventSubscriptionDeclaration eventSubscriptionDeclaration = new EventSubscriptionDeclaration(signalDefinition.getSignalRef(), "signal");
        eventSubscriptionDeclaration.setActivityId(activity.getId());
        if (signal.getScope() != null) {
            eventSubscriptionDeclaration.setConfiguration(signal.getScope());
        }
        addEventSubscriptionDeclaration(bpmnParse, eventSubscriptionDeclaration, signalDefinition, activity.getParent());
        if (activity.getParent() instanceof ActivityImpl) {
            ((ActivityImpl) activity.getParent()).setScope(true);
        }
    }
}
Also used : ThrowEvent(org.activiti.bpmn.model.ThrowEvent) Signal(org.activiti.bpmn.model.Signal) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent) IntermediateCatchEvent(org.activiti.bpmn.model.IntermediateCatchEvent) StartEvent(org.activiti.bpmn.model.StartEvent) EventSubscriptionDeclaration(org.activiti.engine.impl.bpmn.parser.EventSubscriptionDeclaration)

Example 3 with StartEvent

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

the class RepositoryServiceTest method testGetBpmnModel.

@Deployment
public void testGetBpmnModel() {
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    // Some basic assertions
    BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinition.getId());
    assertNotNull(bpmnModel);
    assertEquals(1, bpmnModel.getProcesses().size());
    assertTrue(!bpmnModel.getLocationMap().isEmpty());
    assertTrue(!bpmnModel.getFlowLocationMap().isEmpty());
    // Test the flow
    org.activiti.bpmn.model.Process process = bpmnModel.getProcesses().get(0);
    List<StartEvent> startEvents = process.findFlowElementsOfType(StartEvent.class);
    assertEquals(1, startEvents.size());
    StartEvent startEvent = startEvents.get(0);
    assertEquals(1, startEvent.getOutgoingFlows().size());
    assertEquals(0, startEvent.getIncomingFlows().size());
    String nextElementId = startEvent.getOutgoingFlows().get(0).getTargetRef();
    UserTask userTask = (UserTask) process.getFlowElement(nextElementId);
    assertEquals("First Task", userTask.getName());
    assertEquals(1, userTask.getOutgoingFlows().size());
    assertEquals(1, userTask.getIncomingFlows().size());
    nextElementId = userTask.getOutgoingFlows().get(0).getTargetRef();
    ParallelGateway parallelGateway = (ParallelGateway) process.getFlowElement(nextElementId);
    assertEquals(2, parallelGateway.getOutgoingFlows().size());
    nextElementId = parallelGateway.getOutgoingFlows().get(0).getTargetRef();
    assertEquals(1, parallelGateway.getIncomingFlows().size());
    userTask = (UserTask) process.getFlowElement(nextElementId);
    assertEquals(1, userTask.getOutgoingFlows().size());
    nextElementId = userTask.getOutgoingFlows().get(0).getTargetRef();
    parallelGateway = (ParallelGateway) process.getFlowElement(nextElementId);
    assertEquals(1, parallelGateway.getOutgoingFlows().size());
    assertEquals(2, parallelGateway.getIncomingFlows().size());
    nextElementId = parallelGateway.getOutgoingFlows().get(0).getTargetRef();
    EndEvent endEvent = (EndEvent) process.getFlowElement(nextElementId);
    assertEquals(0, endEvent.getOutgoingFlows().size());
    assertEquals(1, endEvent.getIncomingFlows().size());
}
Also used : ParallelGateway(org.activiti.bpmn.model.ParallelGateway) StartEvent(org.activiti.bpmn.model.StartEvent) UserTask(org.activiti.bpmn.model.UserTask) EndEvent(org.activiti.bpmn.model.EndEvent) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) BpmnModel(org.activiti.bpmn.model.BpmnModel) Deployment(org.activiti.engine.test.Deployment)

Example 4 with StartEvent

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

the class TestProcessUtil method createTwoTasksBpmnModel.

public static BpmnModel createTwoTasksBpmnModel() {
    BpmnModel model = new BpmnModel();
    org.activiti.bpmn.model.Process process = new org.activiti.bpmn.model.Process();
    model.addProcess(process);
    process.setId("twoTasksProcess");
    process.setName("The two tasks process");
    StartEvent startEvent = new StartEvent();
    startEvent.setId("start");
    process.addFlowElement(startEvent);
    UserTask userTask = new UserTask();
    userTask.setName("The First Task");
    userTask.setId("task1");
    userTask.setAssignee("kermit");
    process.addFlowElement(userTask);
    UserTask userTask2 = new UserTask();
    userTask2.setName("The Second Task");
    userTask2.setId("task2");
    userTask2.setAssignee("kermit");
    process.addFlowElement(userTask2);
    EndEvent endEvent = new EndEvent();
    endEvent.setId("theEnd");
    process.addFlowElement(endEvent);
    process.addFlowElement(new SequenceFlow("start", "task1"));
    process.addFlowElement(new SequenceFlow("start", "task2"));
    process.addFlowElement(new SequenceFlow("task1", "theEnd"));
    process.addFlowElement(new SequenceFlow("task2", "theEnd"));
    return model;
}
Also used : SequenceFlow(org.activiti.bpmn.model.SequenceFlow) StartEvent(org.activiti.bpmn.model.StartEvent) UserTask(org.activiti.bpmn.model.UserTask) EndEvent(org.activiti.bpmn.model.EndEvent) BpmnModel(org.activiti.bpmn.model.BpmnModel)

Example 5 with StartEvent

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

the class DefaultWorkflowDefinitionConversionListener method initializeProcess.

protected void initializeProcess(WorkflowDefinitionConversion conversion) {
    WorkflowDefinition workflowDefinition = conversion.getWorkflowDefinition();
    // Create new process
    Process process = conversion.getProcess();
    process.setId(generateProcessId(workflowDefinition));
    process.setName(workflowDefinition.getName());
    process.setDocumentation(workflowDefinition.getDescription());
    if (workflowDefinition.getCategory() != null) {
        conversion.getBpmnModel().setTargetNamespace(workflowDefinition.getCategory());
    }
    conversion.setProcess(process);
    // Add start-event
    StartEvent startEvent = new StartEvent();
    startEvent.setId(START_EVENT_ID);
    if (workflowDefinition.getStartFormDefinition() != null && workflowDefinition.getStartFormDefinition().getFormKey() != null) {
        startEvent.setFormKey(workflowDefinition.getStartFormDefinition().getFormKey());
    }
    process.addFlowElement(startEvent);
    conversion.setLastActivityId(startEvent.getId());
}
Also used : StartEvent(org.activiti.bpmn.model.StartEvent) WorkflowDefinition(org.activiti.workflow.simple.definition.WorkflowDefinition) Process(org.activiti.bpmn.model.Process)

Aggregations

StartEvent (org.activiti.bpmn.model.StartEvent)35 UserTask (org.activiti.bpmn.model.UserTask)18 FlowElement (org.activiti.bpmn.model.FlowElement)14 SubProcess (org.activiti.bpmn.model.SubProcess)8 BoundaryEvent (org.activiti.bpmn.model.BoundaryEvent)7 BpmnModel (org.activiti.bpmn.model.BpmnModel)7 SequenceFlow (org.activiti.bpmn.model.SequenceFlow)7 EndEvent (org.activiti.bpmn.model.EndEvent)6 FormProperty (org.activiti.bpmn.model.FormProperty)6 HashMap (java.util.HashMap)5 IntermediateCatchEvent (org.activiti.bpmn.model.IntermediateCatchEvent)5 ValuedDataObject (org.activiti.bpmn.model.ValuedDataObject)5 ArrayList (java.util.ArrayList)4 FormValue (org.activiti.bpmn.model.FormValue)4 TimerEventDefinition (org.activiti.bpmn.model.TimerEventDefinition)4 AlfrescoStartEvent (org.activiti.bpmn.model.alfresco.AlfrescoStartEvent)4 ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)4 ActivitiListener (org.activiti.bpmn.model.ActivitiListener)3 Process (org.activiti.bpmn.model.Process)3 Date (java.util.Date)2