Search in sources :

Example 21 with PvmTransition

use of org.activiti.engine.impl.pvm.PvmTransition 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 22 with PvmTransition

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

the class WaitState method signal.

public void signal(ActivityExecution execution, String signalName, Object signalData) throws Exception {
    PvmTransition transition = execution.getActivity().getOutgoingTransitions().get(0);
    execution.take(transition);
}
Also used : PvmTransition(org.activiti.engine.impl.pvm.PvmTransition)

Example 23 with PvmTransition

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

the class While method execute.

public void execute(ActivityExecution execution) throws Exception {
    PvmTransition more = execution.getActivity().findOutgoingTransition("more");
    PvmTransition done = execution.getActivity().findOutgoingTransition("done");
    Integer value = (Integer) execution.getVariable(variableName);
    if (value == null) {
        execution.setVariable(variableName, from);
        execution.take(more);
    } else {
        value = value + 1;
        if (value < to) {
            execution.setVariable(variableName, value);
            execution.take(more);
        } else {
            execution.take(done);
        }
    }
}
Also used : PvmTransition(org.activiti.engine.impl.pvm.PvmTransition)

Example 24 with PvmTransition

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

the class EventScopeCreatingSubprocess method lastExecutionEnded.

/*
   * Incoming execution is transformed into an event scope, 
   * new, non-concurrent execution leaves activity 
   */
@SuppressWarnings("unchecked")
public void lastExecutionEnded(ActivityExecution execution) {
    ActivityExecution outgoingExecution = execution.getParent().createExecution();
    outgoingExecution.setConcurrent(false);
    ((InterpretableExecution) outgoingExecution).setActivity((ActivityImpl) execution.getActivity());
    // eventscope execution
    execution.setConcurrent(false);
    execution.setActive(false);
    ((InterpretableExecution) execution).setEventScope(true);
    List<PvmTransition> outgoingTransitions = execution.getActivity().getOutgoingTransitions();
    if (outgoingTransitions.isEmpty()) {
        outgoingExecution.end();
    } else {
        outgoingExecution.takeAll(outgoingTransitions, Collections.EMPTY_LIST);
    }
}
Also used : ActivityExecution(org.activiti.engine.impl.pvm.delegate.ActivityExecution) InterpretableExecution(org.activiti.engine.impl.pvm.runtime.InterpretableExecution) PvmTransition(org.activiti.engine.impl.pvm.PvmTransition)

Example 25 with PvmTransition

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

the class Noop method execute.

public void execute(ActivityExecution execution) throws Exception {
    PvmTransition transition = execution.getActivity().getOutgoingTransitions().get(0);
    execution.take(transition);
}
Also used : PvmTransition(org.activiti.engine.impl.pvm.PvmTransition)

Aggregations

PvmTransition (org.activiti.engine.impl.pvm.PvmTransition)25 ArrayList (java.util.ArrayList)8 ActivityExecution (org.activiti.engine.impl.pvm.delegate.ActivityExecution)7 PvmActivity (org.activiti.engine.impl.pvm.PvmActivity)6 ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)6 ActivitiException (org.activiti.engine.ActivitiException)3 Expression (org.activiti.engine.delegate.Expression)3 HistoricActivityInstance (org.activiti.engine.history.HistoricActivityInstance)3 Condition (org.activiti.engine.impl.Condition)3 ExecutionEntity (org.activiti.engine.impl.persistence.entity.ExecutionEntity)3 List (java.util.List)2 CommandContext (org.activiti.engine.impl.interceptor.CommandContext)2 CommandExecutor (org.activiti.engine.impl.interceptor.CommandExecutor)2 ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)2 PvmException (org.activiti.engine.impl.pvm.PvmException)2 TransitionImpl (org.activiti.engine.impl.pvm.process.TransitionImpl)2 InterpretableExecution (org.activiti.engine.impl.pvm.runtime.InterpretableExecution)2 Deployment (org.activiti.engine.test.Deployment)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1