Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function enter(VirtualExecution $execution)
 {
     $model = $execution->getProcessModel();
     $execution->getEngine()->debug('Starting sub process "{process}"', ['process' => $this->getStringValue($this->name, $execution->getExpressionContext())]);
     $startNode = $model->findNode($this->startNodeId);
     if (!$startNode->getBehavior() instanceof NoneStartEventBehavior) {
         throw new \RuntimeException(sprintf('Cannot start sub process %s ("%s") because it is missing start node %s', $execution->getNode()->getId(), $this->getStringValue($this->name, $execution->getExpressionContext()), $this->startNodeId));
     }
     $execution->waitForSignal();
     $sub = $execution->createNestedExecution($model, $startNode, true, false);
     $sub->execute($startNode);
 }
 /**
  * {@inheritdoc}
  */
 public function enter(VirtualExecution $execution)
 {
     $engine = $execution->getEngine();
     $name = $this->getStringValue($this->name, $execution->getExpressionContext());
     $engine->debug('Execute expression in service task "{task}"', ['task' => $name]);
     $result = $this->getValue($this->expression, $execution->getExpressionContext());
     if ($this->resultVariable !== NULL) {
         $execution->setVariable($this->resultVariable, $result);
     }
     $engine->notify(new TaskExecutedEvent($name, new DelegateExecution($execution), $engine));
     $this->leave($execution);
 }
Beispiel #3
0
 /**
  * {@inheritdoc}
  */
 public function enter(VirtualExecution $execution)
 {
     $engine = $execution->getEngine();
     $typeName = $this->getStringValue($this->typeName, $execution->getExpressionContext());
     $name = $this->getStringValue($this->name, $execution->getExpressionContext());
     $task = $engine->createDelegateTask($typeName);
     if (!$task instanceof DelegateTaskInterface) {
         throw new \RuntimeException('Invalid service task implementation: ' . get_class($task));
     }
     $engine->debug('Execute delegate task "{task}" implemented by <{class}>', ['task' => $name, 'class' => get_class($task)]);
     $task->execute(new DelegateExecution($execution));
     $engine->notify(new TaskExecutedEvent($name, new DelegateExecution($execution), $engine));
     $this->leave($execution);
 }
Beispiel #4
0
 /**
  * {@inheritdoc}
  */
 public function enter(VirtualExecution $execution)
 {
     $engine = $execution->getEngine();
     $name = $this->getStringValue($this->name, $execution->getExpressionContext());
     $engine->debug('Evaluate <{language}> script task "{task}"', ['language' => $this->language, 'task' => $name]);
     if ($this->scriptResource !== NULL) {
         $process = $engine->getRepositoryService()->createProcessDefinitionQuery()->processDefinitionId($execution->getProcessModel()->getId())->findOne();
         $deployment = $engine->getRepositoryService()->createDeploymentQuery()->deploymentId($process->getDeploymentId())->findOne();
         $resource = $deployment->findResourceById($process->getResourceId());
         $file = str_replace('./', '', dirname($resource->getName()) . '/' . $this->scriptResource);
         $script = '?>' . $deployment->findResource($file)->getContents();
     } else {
         $script = $this->script;
     }
     // Isolate scope to prevent manipulation of local / instance variables:
     $callback = function (DelegateExecution $execution, $script) {
         return eval($script);
     };
     if (method_exists($callback, 'bindTo')) {
         $callback = $callback->bindTo(NULL, NULL);
     }
     $result = $callback(new DelegateExecution($execution), $script);
     if ($this->resultVariable !== NULL) {
         $execution->setVariable($this->resultVariable, $result);
     }
     $engine->notify(new TaskExecutedEvent($name, new DelegateExecution($execution), $engine));
     $this->leave($execution);
 }
 /**
  * {@inheritdoc}
  */
 public function createEventSubscriptions(VirtualExecution $execution, $activityId, Node $node = NULL)
 {
     $date = $this->getDateValue($this->date, $execution->getExpressionContext());
     if (!$date instanceof \DateTimeInterface) {
         throw new \RuntimeException(sprintf('Expecting DateTimeInterface, given %s', is_object($date) ? get_class($date) : gettype($date)));
     }
     $execution->getEngine()->executeCommand(new CreateTimerSubscriptionCommand($date, $execution, $activityId, $node === NULL ? $execution->getNode() : $node));
 }
 /**
  * {@inheritdoc}
  */
 public function enter(VirtualExecution $execution)
 {
     $engine = $execution->getEngine();
     $name = $this->getStringValue($this->name, $execution->getExpressionContext());
     $engine->debug('{execution} reached checkpoint "{checkpoint}" ({node})', ['execution' => (string) $execution, 'checkpoint' => $this->name, 'node' => $execution->getNode()->getId()]);
     $engine->notify(new CheckpointReachedEvent($name, new DelegateExecution($execution), $engine));
     $this->leave($execution);
 }
Beispiel #7
0
 /**
  * {@inheritdoc}
  */
 public function enter(VirtualExecution $execution)
 {
     $engine = $execution->getEngine();
     $name = $this->getStringValue($this->name, $execution->getExpressionContext());
     $execution->getEngine()->debug('Executing manual task "{task}"', ['task' => $name]);
     $engine->notify(new TaskExecutedEvent($name, new DelegateExecution($execution), $engine));
     $this->leave($execution);
 }
 /**
  * {@inheritdoc}
  */
 public function enter(VirtualExecution $execution)
 {
     $execution->getEngine()->debug('Reached terminate end event "{name}"', ['name' => $this->getStringValue($this->name, $execution->getExpressionContext())]);
     $engine = $execution->getEngine();
     $engine->notify(new ActivityCompletedEvent($execution->getNode()->getId(), $execution, $engine));
     $root = $execution->getScopeRoot();
     $root->setNode($execution->getNode());
     $root->setTransition($execution->getTransition());
     $root->terminate(false);
 }
Beispiel #9
0
 /**
  * {@inheritdoc}
  */
 public function enter(VirtualExecution $execution)
 {
     $context = $execution->getExpressionContext();
     $command = new CreateUserTaskCommand($this->getStringValue($this->name, $context), (int) $this->getIntegerValue($this->priority, $context), $execution, $this->getStringValue($this->documentation, $context));
     if (NULL !== ($due = $this->getDateValue($this->dueDate, $context))) {
         $command->setDueDate($due);
     }
     $task = $execution->getEngine()->executeCommand($command);
     if ($this->assignee !== NULL) {
         $execution->getEngine()->pushCommand(new ClaimUserTaskCommand($task->getId(), $this->getStringValue($this->assignee, $context)));
     }
     $execution->waitForSignal();
 }
Beispiel #10
0
 /**
  * {@inheritdoc}
  */
 public function enter(VirtualExecution $execution)
 {
     $context = $execution->getExpressionContext();
     $definition = $execution->getEngine()->getRepositoryService()->createProcessDefinitionQuery()->processDefinitionKey($this->processDefinitionKey)->findOne();
     $execution->getEngine()->debug('Starting process {process} from call activity "{task}"', ['process' => $this->processDefinitionKey, 'task' => $this->getStringValue($this->name, $context)]);
     $start = $definition->getModel()->findInitialNodes();
     if (count($start) !== 1) {
         throw new \RuntimeException(sprintf('Missing single non start event in process %s', $definition->getKey()));
     }
     $startNode = array_shift($start);
     $sub = $execution->createNestedExecution($definition->getModel(), $startNode, true, true);
     foreach ($this->inputs as $target => $source) {
         if ($source instanceof ExpressionInterface) {
             $sub->setVariable($target, $source($context));
         } elseif ($execution->hasVariable($source)) {
             $sub->setVariable($target, $execution->getVariable($source));
         }
     }
     $execution->waitForSignal();
     $sub->execute($startNode);
 }