Пример #1
0
 /**
  * @param WorkflowEngine $workflowEngine
  */
 protected function startWithoutMessage(WorkflowEngine $workflowEngine)
 {
     $taskListEntry = $this->taskList->getNextNotStartedTaskListEntry();
     if ($taskListEntry) {
         $this->recordThat(TaskEntryMarkedAsRunning::at($taskListEntry->taskListPosition()));
         $task = $taskListEntry->task();
         if (!$task instanceof CollectData && !$task instanceof RunSubProcess) {
             $this->receiveMessage(LogMessage::logNoMessageReceivedFor($task, $taskListEntry->taskListPosition()), $workflowEngine);
             return;
         }
         $this->performTask($task, $taskListEntry->taskListPosition(), $workflowEngine);
     }
 }
Пример #2
0
 /**
  * @param CollectionType $collection
  * @param WorkflowEngine $workflowEngine
  */
 private function startSubProcessForEachItem(CollectionType $collection, WorkflowEngine $workflowEngine)
 {
     $taskListEntry = $this->taskList->getNextNotStartedTaskListEntry();
     $this->recordThat(TaskEntryMarkedAsRunning::at($taskListEntry->taskListPosition()));
     $this->processingCollection = true;
     /** @var $task RunSubProcess */
     $task = $taskListEntry->task();
     foreach ($collection as $item) {
         $message = WorkflowMessage::newDataCollected($item, $this->taskList->taskListId()->nodeName(), $task->targetNodeName());
         $message->connectToProcessTask($taskListEntry->taskListPosition());
         $this->recordThat(MultiPerformTaskWasStarted::at($taskListEntry->taskListPosition()));
         $this->performRunSubProcess($task, $taskListEntry->taskListPosition(), $workflowEngine, $message);
     }
     $this->processingCollection = false;
 }
Пример #3
0
 /**
  * @param WorkflowMessage $workflowMessage
  * @param WorkflowEngine $workflowEngine
  */
 private function startSubProcessForEachChunk(WorkflowMessage $workflowMessage, WorkflowEngine $workflowEngine)
 {
     $taskListEntry = $this->taskList->getNextNotStartedTaskListEntry();
     $this->recordThat(TaskEntryMarkedAsRunning::at($taskListEntry->taskListPosition()));
     $this->processingCollection = true;
     /** @var $task RunSubProcess */
     $task = $taskListEntry->task();
     $metadata = $workflowMessage->metadata();
     $currentOffset = 0;
     $currentLimit = (int) $metadata[self::META_LIMIT];
     $totalItems = (int) $metadata[self::META_TOTAL_ITEMS];
     //May start message was performed as a count only message so we unset this instruction to tell
     //the workflow message handler that it should collect the data now.
     unset($metadata[self::META_COUNT_ONLY]);
     do {
         $typeClass = $workflowMessage->payload()->getTypeClass();
         $metadata[self::META_OFFSET] = $currentOffset;
         $metadata[self::META_LIMIT] = $currentLimit;
         $collectChunk = WorkflowMessage::collectDataOf($typeClass::prototype(), $this->taskList->taskListId()->nodeName(), $task->targetNodeName(), $metadata);
         $collectChunk->connectToProcessTask($taskListEntry->taskListPosition());
         $this->recordThat(MultiPerformTaskWasStarted::at($taskListEntry->taskListPosition()));
         $this->performRunSubProcess($task, $taskListEntry->taskListPosition(), $workflowEngine, $collectChunk);
         $currentOffset = $currentOffset + $currentLimit;
     } while ($currentOffset + $currentLimit <= $totalItems);
     $this->processingCollection = false;
 }