Exemplo n.º 1
0
 /**
  * @return TaskListPosition|null
  */
 public function parentTaskListPosition()
 {
     if (is_null($this->parentTaskListPosition) && !is_null($this->payload['parent_task_list_Position'])) {
         $this->parentTaskListPosition = TaskListPosition::fromString($this->payload['parent_task_list_Position']);
     }
     return $this->parentTaskListPosition;
 }
Exemplo n.º 2
0
 /**
  * @param array $taskListEntryData
  * @return TaskListEntry
  */
 public static function fromArray(array $taskListEntryData)
 {
     Assertion::keyExists($taskListEntryData, 'taskListPosition');
     Assertion::keyExists($taskListEntryData, 'taskData');
     Assertion::keyExists($taskListEntryData, 'taskClass');
     Assertion::keyExists($taskListEntryData, 'status');
     Assertion::keyExists($taskListEntryData, 'startedOn');
     Assertion::keyExists($taskListEntryData, 'finishedOn');
     Assertion::keyExists($taskListEntryData, 'log');
     Assertion::inArray($taskListEntryData['status'], [self::STATUS_NOT_STARTED, self::STATUS_IN_PROGRESS, self::STATUS_DONE, self::STATUS_FAILED]);
     $taskListPosition = TaskListPosition::fromString($taskListEntryData['taskListPosition']);
     $taskClass = $taskListEntryData['taskClass'];
     $task = $taskClass::reconstituteFromArray($taskListEntryData['taskData']);
     $startedOn = is_null($taskListEntryData['startedOn']) ? null : new \DateTime($taskListEntryData['startedOn']);
     $finishedOn = is_null($taskListEntryData['finishedOn']) ? null : new \DateTime($taskListEntryData['finishedOn']);
     $instance = new self($taskListPosition, $task);
     $instance->status = $taskListEntryData['status'];
     $instance->startedOn = $startedOn;
     $instance->finishedOn = $finishedOn;
     $instance->setLogFromArray($taskListEntryData['log']);
     return $instance;
 }
Exemplo n.º 3
0
 /**
  * @param RemoteMessage $aMessage
  * @return WorkflowMessage
  * @throws \RuntimeException
  */
 public static function fromServiceBusMessage(RemoteMessage $aMessage)
 {
     $payload = $aMessage->payload();
     Assertion::keyExists($payload, 'json');
     Assertion::keyExists($payload, 'origin');
     Assertion::keyExists($payload, 'target');
     $origin = $payload['origin'];
     $target = $payload['target'];
     $taskListPosition = isset($payload['processTaskListPosition']) ? TaskListPosition::fromString($payload['processTaskListPosition']) : null;
     $messagePayload = Payload::fromJsonDecodedData(json_decode($payload['json'], true));
     $metadata = isset($payload['metadata']) ? $payload['metadata'] : [];
     return new static($messagePayload, $aMessage->name(), $origin, $target, $metadata, $taskListPosition, $aMessage->header()->version(), $aMessage->header()->createdAt(), $aMessage->header()->uuid());
 }
 /**
  * @param array $messageLogEntryArr
  * @return MessageLogEntry
  * @throws \InvalidArgumentException
  */
 public static function fromArray(array $messageLogEntryArr)
 {
     if (!array_key_exists("message_id", $messageLogEntryArr)) {
         throw new \InvalidArgumentException('Message id missing in status array');
     }
     if (!array_key_exists("message_name", $messageLogEntryArr)) {
         throw new \InvalidArgumentException('Message name missing in status array');
     }
     if (!array_key_exists("version", $messageLogEntryArr)) {
         throw new \InvalidArgumentException('Message version missing in status array');
     }
     if (!array_key_exists("logged_at", $messageLogEntryArr)) {
         throw new \InvalidArgumentException('Message logged at missing in status array');
     }
     if (!array_key_exists("task_list_position", $messageLogEntryArr)) {
         throw new \InvalidArgumentException('Message task list position missing in status array');
     }
     if (!array_key_exists("process_id", $messageLogEntryArr)) {
         throw new \InvalidArgumentException('Message process id missing in status array');
     }
     if (!array_key_exists("status", $messageLogEntryArr)) {
         throw new \InvalidArgumentException('Message status missing in status array');
     }
     if (!array_key_exists("failure_msg", $messageLogEntryArr)) {
         throw new \InvalidArgumentException('Status failure msg position on missing in status array');
     }
     $status = MessageStatus::fromArray($messageLogEntryArr);
     $taskListPosition = is_null($messageLogEntryArr["task_list_position"]) ? null : TaskListPosition::fromString($messageLogEntryArr["task_list_position"]);
     $processId = is_null($messageLogEntryArr["process_id"]) ? null : ProcessId::fromString($messageLogEntryArr["process_id"]);
     return new self(Uuid::fromString($messageLogEntryArr["message_id"]), $messageLogEntryArr["message_name"], (int) $messageLogEntryArr["version"], \DateTime::createFromFormat('Y-m-d\\TH:i:s.uO', $messageLogEntryArr["logged_at"]), $status, $taskListPosition, $processId);
 }
Exemplo n.º 5
0
 /**
  * @return TaskListPosition
  */
 public function parentTaskListPosition()
 {
     return TaskListPosition::fromString($this->payload['parent_task_list_position']);
 }
Exemplo n.º 6
0
 /**
  * @param DomainEvent[] $streamEvents
  * @return array
  */
 private function convertToClientProcessEvents(array $streamEvents)
 {
     $clientEvents = [];
     foreach ($streamEvents as $streamEvent) {
         $clientEvent = ['name' => ClassFunctions::short($streamEvent->messageName()), 'process_id' => $streamEvent->metadata()['aggregate_id'], 'payload' => $streamEvent->payload(), 'occurred_on' => $streamEvent->createdAt()->format(\DateTime::ISO8601)];
         $taskListPosition = null;
         if (isset($clientEvent['payload']['taskListPosition'])) {
             $taskListPosition = TaskListPosition::fromString($clientEvent['payload']['taskListPosition']);
         }
         $clientEvent['task_list_id'] = $taskListPosition ? $taskListPosition->taskListId()->toString() : null;
         $clientEvent['task_id'] = $taskListPosition ? $taskListPosition->position() - 1 : null;
         $clientEvents[] = $clientEvent;
     }
     return $clientEvents;
 }
Exemplo n.º 7
0
 /**
  * @param RemoteMessage $aMessage
  * @return LogMessage
  * @throws \RuntimeException
  */
 public static function fromServiceBusMessage(RemoteMessage $aMessage)
 {
     $payload = $aMessage->payload();
     Assertion::keyExists($payload, 'processTaskListPosition');
     Assertion::keyExists($payload, 'origin');
     Assertion::keyExists($payload, 'technicalMsg');
     Assertion::keyExists($payload, 'msgParams');
     Assertion::keyExists($payload, 'msgCode');
     $taskListPosition = TaskListPosition::fromString($payload['processTaskListPosition']);
     return new self($payload['origin'], $taskListPosition, $payload['technicalMsg'], $payload['msgCode'], $payload['msgParams'], $aMessage->header()->uuid(), $aMessage->header()->createdAt());
 }
Exemplo n.º 8
0
 /**
  * @return TaskListPosition
  */
 public function taskListPosition()
 {
     return TaskListPosition::fromString($this->payload['taskListPosition']);
 }