org.camunda.bpm.engine.impl.pvm.process.TransitionImpl Java Examples

The following examples show how to use org.camunda.bpm.engine.impl.pvm.process.TransitionImpl. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AsyncAfterMigrationValidator.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Override
public void validate(MigratingTransitionInstance migratingInstance, MigratingProcessInstance migratingProcessInstance,
    MigratingTransitionInstanceValidationReportImpl instanceReport) {
  ActivityImpl targetActivity = (ActivityImpl) migratingInstance.getTargetScope();

  if (targetActivity != null && migratingInstance.isAsyncAfter()) {
    MigratingJobInstance jobInstance = migratingInstance.getJobInstance();
    AsyncContinuationConfiguration config = (AsyncContinuationConfiguration) jobInstance.getJobEntity().getJobHandlerConfiguration();
    String sourceTransitionId = config.getTransitionId();

    if (targetActivity.getOutgoingTransitions().size() > 1) {
      if (sourceTransitionId == null) {
        instanceReport.addFailure("Transition instance is assigned to no sequence flow"
            + " and target activity has more than one outgoing sequence flow");
      }
      else {
        TransitionImpl matchingOutgoingTransition = targetActivity.findOutgoingTransition(sourceTransitionId);
        if (matchingOutgoingTransition == null) {
          instanceReport.addFailure("Transition instance is assigned to a sequence flow"
            + " that cannot be matched in the target activity");
        }
      }
    }
  }

}
 
Example #2
Source File: PvmAtomicOperationTransitionNotifyListenerStart.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void eventNotificationsCompleted(PvmExecutionImpl execution) {

    super.eventNotificationsCompleted(execution);

    TransitionImpl transition = execution.getTransition();
    PvmActivity destination;
    if (transition == null) { // this is null after async cont. -> transition is not stored in execution
      destination = execution.getActivity();
    } else {
      destination = transition.getDestination();
    }
    execution.setTransition(null);
    execution.setActivity(destination);

    ExecutionStartContext executionStartContext = execution.getExecutionStartContext();
    if (executionStartContext != null) {
      executionStartContext.executionStarted(execution);
      execution.disposeExecutionStartContext();
    }

    execution.dispatchDelayedEventsAndPerformOperation(ACTIVITY_EXECUTE);
  }
 
Example #3
Source File: AsyncContinuationJobHandler.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Override
public void execute(AsyncContinuationConfiguration configuration, ExecutionEntity execution, CommandContext commandContext, String tenantId) {

  LegacyBehavior.repairMultiInstanceAsyncJob(execution);

  PvmAtomicOperation atomicOperation = findMatchingAtomicOperation(configuration.getAtomicOperation());
  ensureNotNull("Cannot process job with configuration " + configuration, "atomicOperation", atomicOperation);

  // reset transition id.
  String transitionId = configuration.getTransitionId();
  if (transitionId != null) {
    PvmActivity activity = execution.getActivity();
    TransitionImpl transition = (TransitionImpl) activity.findOutgoingTransition(transitionId);
    execution.setTransition(transition);
  }

  Context.getCommandInvocationContext()
    .performOperation(atomicOperation, execution);
}
 
Example #4
Source File: StartProcessInstanceAtActivitiesCmd.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
/**
 * get the activity that is started by the first instruction, if exists;
 * return null if the first instruction is a start-transition instruction
 */
protected ActivityImpl determineFirstActivity(ProcessDefinitionImpl processDefinition,
    ProcessInstanceModificationBuilderImpl modificationBuilder) {
  AbstractProcessInstanceModificationCommand firstInstruction = modificationBuilder.getModificationOperations().get(0);

  if (firstInstruction instanceof AbstractInstantiationCmd) {
    AbstractInstantiationCmd instantiationInstruction = (AbstractInstantiationCmd) firstInstruction;
    CoreModelElement targetElement = instantiationInstruction.getTargetElement(processDefinition);

    ensureNotNull(NotValidException.class,
        "Element '" + instantiationInstruction.getTargetElementId() + "' does not exist in process " + processDefinition.getId(),
        "targetElement",
        targetElement);

    if (targetElement instanceof ActivityImpl) {
      return (ActivityImpl) targetElement;
    }
    else if (targetElement instanceof TransitionImpl) {
      return (ActivityImpl) ((TransitionImpl) targetElement).getDestination();
    }

  }

  return null;
}
 
Example #5
Source File: ActivityAfterInstantiationCmd.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected TransitionImpl findTransition(ProcessDefinitionImpl processDefinition) {
  PvmActivity activity = processDefinition.findActivity(activityId);

  EnsureUtil.ensureNotNull(NotValidException.class,
      describeFailure("Activity '" + activityId + "' does not exist"),
      "activity",
      activity);

  if (activity.getOutgoingTransitions().isEmpty()) {
    throw new ProcessEngineException("Cannot start after activity " + activityId + "; activity "
        + "has no outgoing sequence flow to take");
  }
  else if (activity.getOutgoingTransitions().size() > 1) {
    throw new ProcessEngineException("Cannot start after activity " + activityId + "; "
        + "activity has more than one outgoing sequence flow");
  }

  return (TransitionImpl) activity.getOutgoingTransitions().get(0);
}
 
Example #6
Source File: ProcessDefinitionBuilder.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
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 RuntimeException("destination '"+destinationActivityName+"' not found.  (referenced from transition in '"+transition.getSource().getId()+"')");
    }
    transition.setDestination(destination);
  }
  return processDefinition;
}
 
Example #7
Source File: MigratingAsyncJobInstance.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void updateAsyncAfterTargetConfiguration(AsyncContinuationConfiguration currentConfiguration) {
  ActivityImpl targetActivity = (ActivityImpl) targetScope;
  List<PvmTransition> outgoingTransitions = targetActivity.getOutgoingTransitions();

  AsyncContinuationConfiguration targetConfiguration = new AsyncContinuationConfiguration();

  if (outgoingTransitions.isEmpty()) {
    targetConfiguration.setAtomicOperation(PvmAtomicOperation.ACTIVITY_END.getCanonicalName());
  }
  else {
    targetConfiguration.setAtomicOperation(PvmAtomicOperation.TRANSITION_NOTIFY_LISTENER_TAKE.getCanonicalName());

    if (outgoingTransitions.size() == 1) {
      targetConfiguration.setTransitionId(outgoingTransitions.get(0).getId());
    }
    else {
      TransitionImpl matchingTargetTransition = null;
      String currentTransitionId = currentConfiguration.getTransitionId();
      if (currentTransitionId != null) {
        matchingTargetTransition = targetActivity.findOutgoingTransition(currentTransitionId);
      }

      if (matchingTargetTransition != null) {
        targetConfiguration.setTransitionId(matchingTargetTransition.getId());
      }
      else {
        // should not happen since it is avoided by validation
        throw new ProcessEngineException("Cannot determine matching outgoing sequence flow");
      }
    }
  }

  jobEntity.setJobHandlerConfiguration(targetConfiguration);
}
 
Example #8
Source File: CustomBpmnParse.java    From wecube-platform with Apache License 2.0 5 votes vote down vote up
public void parseSequenceFlowConditionExpression(Element seqFlowElement, TransitionImpl seqFlow) {
    logger.debug("parse sequence flow condition expression,id={}", seqFlow.getId());

    Element conditionExprElement = seqFlowElement.element(CONDITION_EXPRESSION);
    if (conditionExprElement != null) {
        Condition condition = parseConditionExpression(conditionExprElement);
        seqFlow.setProperty(PROPERTYNAME_CONDITION_TEXT,
                translateConditionExpressionElementText(conditionExprElement));
        seqFlow.setProperty(PROPERTYNAME_CONDITION, condition);
    } else {
        tryDeduceConditionExpression(seqFlowElement, seqFlow);
    }
}
 
Example #9
Source File: ActivityAfterInstantiationCmd.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Override
protected ScopeImpl getTargetFlowScope(ProcessDefinitionImpl processDefinition) {
  TransitionImpl transition = findTransition(processDefinition);

  return transition.getDestination().getFlowScope();
}
 
Example #10
Source File: AbstractBpmnParseListener.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public void parseSequenceFlow(Element sequenceFlowElement, ScopeImpl scopeElement, TransitionImpl transition) {
}
 
Example #11
Source File: TransitionInstantiationCmd.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Override
protected CoreModelElement getTargetElement(ProcessDefinitionImpl processDefinition) {
  TransitionImpl transition = processDefinition.findTransition(transitionId);
  return transition;
}
 
Example #12
Source File: TransitionInstantiationCmd.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Override
protected ScopeImpl getTargetFlowScope(ProcessDefinitionImpl processDefinition) {
  TransitionImpl transition = processDefinition.findTransition(transitionId);
  return transition.getSource().getFlowScope();
}
 
Example #13
Source File: HistoryParseListener.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public void parseSequenceFlow(Element sequenceFlowElement, ScopeImpl scopeElement, TransitionImpl transition) {
}
 
Example #14
Source File: BpmnParseTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Deployment
@Test
public void testParseDiagramInterchangeElements() {

  // Graphical information is not yet exposed publicly, so we need to do some
  // plumbing
  CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired();
  ProcessDefinitionEntity processDefinitionEntity = commandExecutor.execute(new Command<ProcessDefinitionEntity>() {
    @Override
    public ProcessDefinitionEntity execute(CommandContext commandContext) {
      return Context.getProcessEngineConfiguration().getDeploymentCache().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());
  if (processEngineConfiguration.isCreateDiagramOnDeploy()) {
    assertEquals(2, resourceNames.size());
  } else {
    assertEquals(1, 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);
      }

    }
  }
}
 
Example #15
Source File: PvmAtomicOperationActivityInitStackNotifyListenerStart.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected void eventNotificationsCompleted(PvmExecutionImpl execution) {
  super.eventNotificationsCompleted(execution);

  execution.activityInstanceStarted();

  ExecutionStartContext startContext = execution.getExecutionStartContext();
  InstantiationStack instantiationStack = startContext.getInstantiationStack();

  PvmExecutionImpl propagatingExecution = execution;
  ActivityImpl activity = execution.getActivity();
  if (activity.getActivityBehavior() instanceof ModificationObserverBehavior) {
    ModificationObserverBehavior behavior = (ModificationObserverBehavior) activity.getActivityBehavior();
    List<ActivityExecution> concurrentExecutions = behavior.initializeScope(propagatingExecution, 1);
    propagatingExecution = (PvmExecutionImpl) concurrentExecutions.get(0);
  }

  // if the stack has been instantiated
  if (instantiationStack.getActivities().isEmpty() && instantiationStack.getTargetActivity() != null) {
    // as if we are entering the target activity instance id via a transition
    propagatingExecution.setActivityInstanceId(null);

    // execute the target activity with this execution
    startContext.applyVariables(propagatingExecution);
    propagatingExecution.setActivity(instantiationStack.getTargetActivity());
    propagatingExecution.performOperation(ACTIVITY_START_CREATE_SCOPE);

  }
  else if (instantiationStack.getActivities().isEmpty() && instantiationStack.getTargetTransition() != null) {
    // as if we are entering the target activity instance id via a transition
    propagatingExecution.setActivityInstanceId(null);

    // execute the target transition with this execution
    PvmTransition transition = instantiationStack.getTargetTransition();
    startContext.applyVariables(propagatingExecution);
    propagatingExecution.setActivity(transition.getSource());
    propagatingExecution.setTransition((TransitionImpl) transition);
    propagatingExecution.performOperation(TRANSITION_START_NOTIFY_LISTENER_TAKE);
  }
  else {
    // else instantiate the activity stack further
    propagatingExecution.setActivity(null);
    propagatingExecution.performOperation(ACTIVITY_INIT_STACK);

  }

}
 
Example #16
Source File: BpmnParseTest.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected void assertSequenceFlowWayPoints(TransitionImpl sequenceFlow, Integer... waypoints) {
  assertEquals(waypoints.length, sequenceFlow.getWaypoints().size());
  for (int i = 0; i < waypoints.length; i++) {
    assertEquals(waypoints[i], sequenceFlow.getWaypoints().get(i));
  }
}
 
Example #17
Source File: CustomBpmnParse.java    From wecube-platform with Apache License 2.0 4 votes vote down vote up
protected void tryDeduceConditionExpression(Element seqFlowElement, TransitionImpl seqFlow) {
    logger.debug("try deduce condition expression,id={}", seqFlow.getId());
}
 
Example #18
Source File: ProcessApplicationEventParseListener.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Override
public void parseSequenceFlow(Element sequenceFlowElement, ScopeImpl scopeElement, TransitionImpl transition) {
  addTakeEventListener(transition);
}
 
Example #19
Source File: ProcessApplicationEventParseListener.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected void addTakeEventListener(TransitionImpl transition) {
  transition.addExecutionListener(EXECUTION_LISTENER);
}
 
Example #20
Source File: CdiEventSupportBpmnParseListener.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Override
public void parseSequenceFlow(Element sequenceFlowElement, ScopeImpl scopeElement, TransitionImpl transition) {
  transition.addExecutionListener(new CdiEventListener());
}
 
Example #21
Source File: PublishDelegateParseListener.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
private void addExecutionListener(final TransitionImpl transition) {
  if (executionListener != null) {
    transition.addListener(EVENTNAME_TAKE, executionListener);
  }
}
 
Example #22
Source File: PublishDelegateParseListener.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Override
public void parseSequenceFlow(Element sequenceFlowElement, ScopeImpl scopeElement, TransitionImpl transition) {
  addExecutionListener(transition);
}
 
Example #23
Source File: GlobalOSGiEventBridgeActivator.java    From camunda-bpm-platform-osgi with Apache License 2.0 4 votes vote down vote up
@Override
public void parseSequenceFlow(Element sequenceFlowElement, ScopeImpl scopeElement, TransitionImpl transition) {
  addTakeEventListener(transition);
}
 
Example #24
Source File: GlobalOSGiEventBridgeActivator.java    From camunda-bpm-platform-osgi with Apache License 2.0 4 votes vote down vote up
protected void addTakeEventListener(TransitionImpl transition) {
  transition.addExecutionListener(createExecutionListener(transition));
}
 
Example #25
Source File: PublishDelegateParseListener.java    From camunda-bpm-spring-boot-starter with Apache License 2.0 4 votes vote down vote up
private void addExecutionListener(final TransitionImpl transition) {
  if (executionListener != null) {
    transition.addListener(EVENTNAME_TAKE, executionListener);
  }
}
 
Example #26
Source File: PublishDelegateParseListener.java    From camunda-bpm-spring-boot-starter with Apache License 2.0 4 votes vote down vote up
@Override
public void parseSequenceFlow(Element sequenceFlowElement, ScopeImpl scopeElement, TransitionImpl transition) {
  addExecutionListener(transition);
}
 
Example #27
Source File: RegisterAllBpmnParseListener.java    From camunda-bpm-reactor with Apache License 2.0 4 votes vote down vote up
void addExecutionListener(final TransitionImpl transition) {
  transition.addListener(EVENTNAME_TAKE, executionListener);
}
 
Example #28
Source File: RegisterAllBpmnParseListener.java    From camunda-bpm-reactor with Apache License 2.0 4 votes vote down vote up
@Override
public void parseSequenceFlow(final Element sequenceFlowElement, final ScopeImpl scopeElement, final TransitionImpl transition) {
  addExecutionListener(transition);
}
 
Example #29
Source File: AddSendEventListenerToBpmnParseListener.java    From camunda-spring-boot-amqp-microservice-cloud-example with Apache License 2.0 4 votes vote down vote up
@Override
public void parseSequenceFlow(Element sequenceFlowElement, ScopeImpl scopeElement, TransitionImpl transition) {
}
 
Example #30
Source File: PvmScope.java    From camunda-bpm-platform with Apache License 2.0 2 votes vote down vote up
/**
 * Recursively finds a transition.
 * @param transitionId the transiton to find
 * @return the transition or null
 */
TransitionImpl findTransition(String transitionId);