public function apply(WorkflowHistory $history)
 {
     $item = $this->getHistoryItem($history, $this->getAttribute('scheduledEventId'));
     $item->setTimeStarted($this->timestamp);
     $item->setState(HistoryItemState::RUNNING());
     $history->add($item);
 }
Esempio n. 2
0
 /**
  * Check for incomplete activities
  *
  * @return bool
  */
 public function haveOpenActivities()
 {
     foreach ($this->history as $history_item) {
         /** @var WorkflowHistoryItem $history_item */
         if ($history_item->getState() == HistoryItemState::SCHEDULED() || $history_item->getState() == HistoryItemState::RUNNING()) {
             return true;
         }
     }
     return false;
 }
Esempio n. 3
0
 public function testCounts()
 {
     $history = new WorkflowHistory();
     $history->add($this->createHistoryItem('test-activity', '1', HistoryItemState::COMPLETED(), 'alpha'));
     $history->add($this->createHistoryItem('test-activity', '1', HistoryItemState::COMPLETED(), 'bravo'));
     $history->add($this->createHistoryItem('test-activity', '2', HistoryItemState::COMPLETED(), 'charlie'));
     $history->add($this->createHistoryItem('test-activity', '1', HistoryItemState::SCHEDULED(), 'delta'));
     $history->add($this->createHistoryItem('other-activity', '1', HistoryItemState::COMPLETED(), 'echo'));
     $history->add($this->createHistoryItem('other-activity', '1', HistoryItemState::RUNNING(), 'foxtrot'));
     $inspector = new HistoryInspector($history);
     $schema_test = TaskSchema::fromKey('test-activity/1');
     $schema_other = TaskSchema::fromKey('other-activity/1');
     $this->assertEquals(0, $inspector->countTask($schema_test, HistoryItemState::RUNNING()));
     $this->assertEquals(0, $inspector->countTask($schema_test, HistoryItemState::FAILED()));
     $this->assertEquals(2, $inspector->countTask($schema_test, HistoryItemState::COMPLETED()));
     $this->assertEquals(1, $inspector->countTask($schema_test, HistoryItemState::SCHEDULED()));
     $this->assertEquals(1, $inspector->countTask($schema_other, HistoryItemState::COMPLETED()));
     $this->assertEquals(1, $inspector->countTask($schema_other, HistoryItemState::RUNNING()));
     $this->assertEquals(0, $inspector->countTask($schema_other, HistoryItemState::SCHEDULED()));
     $this->assertEquals(0, $inspector->countTask($schema_other, HistoryItemState::FAILED()));
     $this->assertEquals(1, $inspector->countControl('alpha', HistoryItemState::COMPLETED()));
     $this->assertEquals(1, $inspector->countControl('bravo', HistoryItemState::COMPLETED()));
     $this->assertEquals(1, $inspector->countControl('charlie', HistoryItemState::COMPLETED()));
     $this->assertEquals(0, $inspector->countControl('delta', HistoryItemState::COMPLETED()));
     $this->assertEquals(1, $inspector->countControl('echo', HistoryItemState::COMPLETED()));
     $this->assertEquals(0, $inspector->countControl('foxtrot', HistoryItemState::COMPLETED()));
     $this->assertTrue($inspector->haveOpenActivities());
     $alpha = new TaskSchema();
     $alpha->setActivityName('test-activity')->setActivityVersion('1')->setControl('alpha');
     $this->assertEquals(2, $inspector->countTask($alpha, HistoryItemState::COMPLETED()));
     $this->assertEquals(1, $inspector->countTask($alpha, HistoryItemState::SCHEDULED()));
     $omega = new TaskSchema();
     $omega->setActivityName('test-activity')->setActivityVersion('10');
     $this->assertEquals(0, $inspector->countTask($omega, HistoryItemState::COMPLETED()));
     $this->assertTrue($inspector->hasTaskBeenScheduled($alpha));
     $this->assertFalse($inspector->hasTaskBeenScheduled($omega));
 }
Esempio n. 4
0
 /**
  * Check if this history item is a actively running
  *
  * @return bool
  */
 public function isActive()
 {
     return $this->state == HistoryItemState::RUNNING();
 }