Search in sources :

Example 1 with IntermediateCatchEvent

use of org.activiti.bpmn.model.IntermediateCatchEvent 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 IntermediateCatchEvent

use of org.activiti.bpmn.model.IntermediateCatchEvent 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 IntermediateCatchEvent

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

the class CatchEventXMLConverter method writeAdditionalChildElements.

@Override
protected void writeAdditionalChildElements(BaseElement element, BpmnModel model, XMLStreamWriter xtw) throws Exception {
    IntermediateCatchEvent catchEvent = (IntermediateCatchEvent) element;
    writeEventDefinitions(catchEvent, catchEvent.getEventDefinitions(), model, xtw);
}
Also used : IntermediateCatchEvent(org.activiti.bpmn.model.IntermediateCatchEvent)

Example 4 with IntermediateCatchEvent

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

the class SimpleConverterTest method validateModel.

private void validateModel(BpmnModel model) {
    assertEquals(2, model.getDefinitionsAttributes().size());
    assertEquals("2.2A", model.getDefinitionsAttributeValue("http://activiti.com/modeler", "version"));
    assertEquals("20140312T10:45:23", model.getDefinitionsAttributeValue("http://activiti.com/modeler", "exportDate"));
    assertEquals("simpleProcess", model.getMainProcess().getId());
    assertEquals("Simple process", model.getMainProcess().getName());
    assertEquals("simple doc", model.getMainProcess().getDocumentation());
    assertEquals(true, model.getMainProcess().isExecutable());
    FlowElement flowElement = model.getMainProcess().getFlowElement("flow1");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof SequenceFlow);
    assertEquals("flow1", flowElement.getId());
    flowElement = model.getMainProcess().getFlowElement("catchEvent");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof IntermediateCatchEvent);
    assertEquals("catchEvent", flowElement.getId());
    IntermediateCatchEvent catchEvent = (IntermediateCatchEvent) flowElement;
    assertTrue(catchEvent.getEventDefinitions().size() == 1);
    EventDefinition eventDefinition = catchEvent.getEventDefinitions().get(0);
    assertTrue(eventDefinition instanceof TimerEventDefinition);
    TimerEventDefinition timerDefinition = (TimerEventDefinition) eventDefinition;
    assertEquals("PT5M", timerDefinition.getTimeDuration());
    flowElement = model.getMainProcess().getFlowElement("userTask1");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof UserTask);
    UserTask task = (UserTask) flowElement;
    assertEquals("task doc", task.getDocumentation());
    flowElement = model.getMainProcess().getFlowElement("flow1Condition");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof SequenceFlow);
    assertEquals("flow1Condition", flowElement.getId());
    SequenceFlow flow = (SequenceFlow) flowElement;
    assertEquals("${number <= 1}", flow.getConditionExpression());
    flowElement = model.getMainProcess().getFlowElement("gateway1");
    assertNotNull(flowElement);
    assertTrue(flowElement instanceof ExclusiveGateway);
}
Also used : ExclusiveGateway(org.activiti.bpmn.model.ExclusiveGateway) FlowElement(org.activiti.bpmn.model.FlowElement) SequenceFlow(org.activiti.bpmn.model.SequenceFlow) IntermediateCatchEvent(org.activiti.bpmn.model.IntermediateCatchEvent) UserTask(org.activiti.bpmn.model.UserTask) EventDefinition(org.activiti.bpmn.model.EventDefinition) TimerEventDefinition(org.activiti.bpmn.model.TimerEventDefinition) TimerEventDefinition(org.activiti.bpmn.model.TimerEventDefinition)

Example 5 with IntermediateCatchEvent

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

the class CatchEventJsonConverter method convertElementToJson.

protected void convertElementToJson(ObjectNode propertiesNode, BaseElement baseElement) {
    IntermediateCatchEvent catchEvent = (IntermediateCatchEvent) baseElement;
    addEventProperties(catchEvent, propertiesNode);
}
Also used : IntermediateCatchEvent(org.activiti.bpmn.model.IntermediateCatchEvent)

Aggregations

IntermediateCatchEvent (org.activiti.bpmn.model.IntermediateCatchEvent)15 FlowElement (org.activiti.bpmn.model.FlowElement)5 StartEvent (org.activiti.bpmn.model.StartEvent)5 BoundaryEvent (org.activiti.bpmn.model.BoundaryEvent)4 TimerEventDefinition (org.activiti.bpmn.model.TimerEventDefinition)4 UserTask (org.activiti.bpmn.model.UserTask)4 EventDefinition (org.activiti.bpmn.model.EventDefinition)3 SequenceFlow (org.activiti.bpmn.model.SequenceFlow)3 SignalEventDefinition (org.activiti.bpmn.model.SignalEventDefinition)3 ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)3 ReceiveTask (org.activiti.bpmn.model.ReceiveTask)2 SubProcess (org.activiti.bpmn.model.SubProcess)2 EventSubscriptionDeclaration (org.activiti.engine.impl.bpmn.parser.EventSubscriptionDeclaration)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 BpmnModel (org.activiti.bpmn.model.BpmnModel)1 ExclusiveGateway (org.activiti.bpmn.model.ExclusiveGateway)1 Message (org.activiti.bpmn.model.Message)1 MessageEventDefinition (org.activiti.bpmn.model.MessageEventDefinition)1 ServiceTask (org.activiti.bpmn.model.ServiceTask)1