Search in sources :

Example 6 with TransitionImpl

use of org.activiti.engine.impl.pvm.process.TransitionImpl in project Activiti by Activiti.

the class AtomicOperationTransitionNotifyListenerStart method eventNotificationsCompleted.

@Override
protected void eventNotificationsCompleted(InterpretableExecution execution) {
    TransitionImpl transition = execution.getTransition();
    ActivityImpl destination = null;
    if (transition == null) {
        // this is null after async cont. -> transition is not stored in execution
        destination = (ActivityImpl) execution.getActivity();
    } else {
        destination = transition.getDestination();
    }
    ActivityImpl activity = (ActivityImpl) execution.getActivity();
    if (activity != destination) {
        ActivityImpl nextScope = AtomicOperationTransitionNotifyListenerTake.findNextScope(activity, destination);
        execution.setActivity(nextScope);
        execution.performOperation(TRANSITION_CREATE_SCOPE);
    } else {
        execution.setTransition(null);
        execution.setActivity(destination);
        execution.performOperation(ACTIVITY_EXECUTE);
    }
}
Also used : TransitionImpl(org.activiti.engine.impl.pvm.process.TransitionImpl) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl)

Example 7 with TransitionImpl

use of org.activiti.engine.impl.pvm.process.TransitionImpl in project Activiti by Activiti.

the class AtomicOperationTransitionNotifyListenerTake method execute.

public void execute(InterpretableExecution execution) {
    TransitionImpl transition = execution.getTransition();
    List<ExecutionListener> executionListeners = transition.getExecutionListeners();
    int executionListenerIndex = execution.getExecutionListenerIndex();
    if (executionListeners.size() > executionListenerIndex) {
        execution.setEventName(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_TAKE);
        execution.setEventSource(transition);
        ExecutionListener listener = executionListeners.get(executionListenerIndex);
        try {
            listener.notify(execution);
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            throw new PvmException("couldn't execute event listener : " + e.getMessage(), e);
        }
        execution.setExecutionListenerIndex(executionListenerIndex + 1);
        execution.performOperation(this);
    } else {
        if (log.isDebugEnabled()) {
            log.debug("{} takes transition {}", execution, transition);
        }
        execution.setExecutionListenerIndex(0);
        execution.setEventName(null);
        execution.setEventSource(null);
        ActivityImpl activity = (ActivityImpl) execution.getActivity();
        ActivityImpl nextScope = findNextScope(activity.getParent(), transition.getDestination());
        execution.setActivity(nextScope);
        // Firing event that transition is being taken     	
        if (Context.getProcessEngineConfiguration() != null && Context.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
            Context.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createSequenceFlowTakenEvent(ActivitiEventType.SEQUENCEFLOW_TAKEN, transition.getId(), activity.getId(), (String) activity.getProperties().get("name"), (String) activity.getProperties().get("type"), activity.getActivityBehavior().getClass().getCanonicalName(), nextScope.getId(), (String) nextScope.getProperties().get("name"), (String) nextScope.getProperties().get("type"), nextScope.getActivityBehavior().getClass().getCanonicalName()));
        }
        execution.performOperation(TRANSITION_CREATE_SCOPE);
    }
}
Also used : TransitionImpl(org.activiti.engine.impl.pvm.process.TransitionImpl) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) PvmException(org.activiti.engine.impl.pvm.PvmException) PvmException(org.activiti.engine.impl.pvm.PvmException) ExecutionListener(org.activiti.engine.delegate.ExecutionListener)

Example 8 with TransitionImpl

use of org.activiti.engine.impl.pvm.process.TransitionImpl in project Activiti by Activiti.

the class BpmnParseTest method testParseDiagramInterchangeElements.

@Deployment
public void testParseDiagramInterchangeElements() {
    // Graphical information is not yet exposed publicly, so we need to do some plumbing
    CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutor();
    ProcessDefinitionEntity processDefinitionEntity = commandExecutor.execute(new Command<ProcessDefinitionEntity>() {

        public ProcessDefinitionEntity execute(CommandContext commandContext) {
            return Context.getProcessEngineConfiguration().getDeploymentManager().findDeployedLatestProcessDefinitionByKey("myProcess");
        }
    });
    assertNotNull(processDefinitionEntity);
    assertEquals(7, processDefinitionEntity.getActivities().size());
    // Check if diagram has been created based on Diagram Interchange when it's not a headless instance
    List<String> resourceNames = repositoryService.getDeploymentResourceNames(processDefinitionEntity.getDeploymentId());
    assertEquals(2, resourceNames.size());
    for (ActivityImpl activity : processDefinitionEntity.getActivities()) {
        if (activity.getId().equals("theStart")) {
            assertActivityBounds(activity, 70, 255, 30, 30);
        } else if (activity.getId().equals("task1")) {
            assertActivityBounds(activity, 176, 230, 100, 80);
        } else if (activity.getId().equals("gateway1")) {
            assertActivityBounds(activity, 340, 250, 40, 40);
        } else if (activity.getId().equals("task2")) {
            assertActivityBounds(activity, 445, 138, 100, 80);
        } else if (activity.getId().equals("gateway2")) {
            assertActivityBounds(activity, 620, 250, 40, 40);
        } else if (activity.getId().equals("task3")) {
            assertActivityBounds(activity, 453, 304, 100, 80);
        } else if (activity.getId().equals("theEnd")) {
            assertActivityBounds(activity, 713, 256, 28, 28);
        }
        for (PvmTransition sequenceFlow : activity.getOutgoingTransitions()) {
            assertTrue(((TransitionImpl) sequenceFlow).getWaypoints().size() >= 4);
            TransitionImpl transitionImpl = (TransitionImpl) sequenceFlow;
            if (transitionImpl.getId().equals("flowStartToTask1")) {
                assertSequenceFlowWayPoints(transitionImpl, 100, 270, 176, 270);
            } else if (transitionImpl.getId().equals("flowTask1ToGateway1")) {
                assertSequenceFlowWayPoints(transitionImpl, 276, 270, 340, 270);
            } else if (transitionImpl.getId().equals("flowGateway1ToTask2")) {
                assertSequenceFlowWayPoints(transitionImpl, 360, 250, 360, 178, 445, 178);
            } else if (transitionImpl.getId().equals("flowGateway1ToTask3")) {
                assertSequenceFlowWayPoints(transitionImpl, 360, 290, 360, 344, 453, 344);
            } else if (transitionImpl.getId().equals("flowTask2ToGateway2")) {
                assertSequenceFlowWayPoints(transitionImpl, 545, 178, 640, 178, 640, 250);
            } else if (transitionImpl.getId().equals("flowTask3ToGateway2")) {
                assertSequenceFlowWayPoints(transitionImpl, 553, 344, 640, 344, 640, 290);
            } else if (transitionImpl.getId().equals("flowGateway2ToEnd")) {
                assertSequenceFlowWayPoints(transitionImpl, 660, 270, 713, 270);
            }
        }
    }
}
Also used : TransitionImpl(org.activiti.engine.impl.pvm.process.TransitionImpl) CommandContext(org.activiti.engine.impl.interceptor.CommandContext) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) CommandExecutor(org.activiti.engine.impl.interceptor.CommandExecutor) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity) PvmTransition(org.activiti.engine.impl.pvm.PvmTransition) Deployment(org.activiti.engine.test.Deployment)

Example 9 with TransitionImpl

use of org.activiti.engine.impl.pvm.process.TransitionImpl in project Activiti by Activiti.

the class ProcessDefinitionBuilder method buildProcessDefinition.

public PvmProcessDefinition buildProcessDefinition() {
    for (Object[] unresolvedTransition : unresolvedTransitions) {
        TransitionImpl transition = (TransitionImpl) unresolvedTransition[0];
        String destinationActivityName = (String) unresolvedTransition[1];
        ActivityImpl destination = processDefinition.findActivity(destinationActivityName);
        if (destination == null) {
            throw new ActivitiException("destination '" + destinationActivityName + "' not found.  (referenced from transition in '" + transition.getSource().getId() + "')");
        }
        transition.setDestination(destination);
    }
    return processDefinition;
}
Also used : TransitionImpl(org.activiti.engine.impl.pvm.process.TransitionImpl) ActivitiException(org.activiti.engine.ActivitiException) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl)

Aggregations

TransitionImpl (org.activiti.engine.impl.pvm.process.TransitionImpl)9 ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)8 ArrayList (java.util.ArrayList)2 PvmTransition (org.activiti.engine.impl.pvm.PvmTransition)2 ScopeImpl (org.activiti.engine.impl.pvm.process.ScopeImpl)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 List (java.util.List)1 FlowElement (org.activiti.bpmn.model.FlowElement)1 GraphicInfo (org.activiti.bpmn.model.GraphicInfo)1 SequenceFlow (org.activiti.bpmn.model.SequenceFlow)1 UserTask (org.activiti.bpmn.model.UserTask)1 ActivitiException (org.activiti.engine.ActivitiException)1 ExecutionListener (org.activiti.engine.delegate.ExecutionListener)1 Expression (org.activiti.engine.delegate.Expression)1 Condition (org.activiti.engine.impl.Condition)1 BoundaryEventActivityBehavior (org.activiti.engine.impl.bpmn.behavior.BoundaryEventActivityBehavior)1 CallActivityBehavior (org.activiti.engine.impl.bpmn.behavior.CallActivityBehavior)1 ErrorEventDefinition (org.activiti.engine.impl.bpmn.parser.ErrorEventDefinition)1