Exemplo n.º 1
0
 /**
  * @return MessageHandler\MessageHandlerId
  */
 public function messageHandlerId()
 {
     if (is_null($this->messageHandlerId)) {
         $this->messageHandlerId = MessageHandler\MessageHandlerId::fromString($this->payload['message_handler_id']);
     }
     return $this->messageHandlerId;
 }
 /**
  * @return MessageHandlerId
  */
 public function messageHandlerId()
 {
     if (is_null($this->messageHandlerId)) {
         $this->messageHandlerId = MessageHandlerId::fromString($this->aggregateId());
     }
     return $this->messageHandlerId;
 }
 public function create($data)
 {
     if (!array_key_exists('name', $data)) {
         return $this->apiProblem(422, "No name given for the message handler");
     }
     if (!array_key_exists('node_name', $data)) {
         return $this->apiProblem(422, "No node_name given for the message handler");
     }
     if (!array_key_exists('type', $data)) {
         return $this->apiProblem(422, "No type given for the message handler");
     }
     if (!array_key_exists('data_direction', $data)) {
         return $this->apiProblem(422, "No data_direction given for the message handler");
     }
     if (!array_key_exists('metadata_riot_tag', $data)) {
         return $this->apiProblem(422, "No metadata_riot_tag given for the message handler");
     }
     if (!array_key_exists('icon', $data)) {
         return $this->apiProblem(422, "No icon given for the message handler");
     }
     if (!array_key_exists('icon_type', $data)) {
         return $this->apiProblem(422, "No icon_type given for the message handler");
     }
     if (!isset($data['processing_types'])) {
         $data['processing_types'] = ProcessingTypes::SUPPORT_ALL;
     }
     if (!isset($data['processing_metadata'])) {
         $data['processing_metadata'] = ProcessingMetadata::noData()->toArray();
     }
     if (!isset($data['preferred_type'])) {
         $data['preferred_type'] = null;
     }
     if (!isset($data['processing_id'])) {
         $data['processing_id'] = null;
     }
     if (!isset($data['additional_data'])) {
         $data['additional_data'] = [];
     }
     $messageHandlerId = MessageHandlerId::generate();
     $this->commandBus->dispatch(InstallMessageHandler::withData($messageHandlerId, $data['name'], $data['node_name'], $data['type'], $data['data_direction'], $data['processing_types'], $data['processing_metadata'], $data['metadata_riot_tag'], $data['icon'], $data['icon_type'], $data['preferred_type'], $data['processing_id'], $data['additional_data']));
     return $this->location($this->url()->fromRoute('prooph.link/process_config/api/message_handler', ['id' => $messageHandlerId->toString()]));
 }
 /**
  * @return MessageHandlerId
  */
 public function nextMessageHandlerId()
 {
     return MessageHandlerId::fromString($this->payload['next_message_handler_id']);
 }
 /**
  * @test
  */
 function it_installs_a_message_handler()
 {
     $messageHandler = ProcessingNode::initializeAs(NodeName::defaultName())->installMessageHandler(MessageHandlerId::generate(), 'Article Exporter', HandlerType::connector(), DataDirection::source(), ProcessingTypes::support([ArticleCollection::prototype()]), ProcessingMetadata::noData(), 'sqlconnector-pm-metadata', 'glyphicon-hdd', 'glyphicon', ArticleCollection::prototype(), ProcessingId::fromString('sqlconnector:::example'));
     $this->assertInstanceOf(MessageHandler::class, $messageHandler);
 }
 /**
  * @param MessageHandlerId $handlerId
  * @return MessageHandler
  */
 public function get(MessageHandlerId $handlerId)
 {
     return $this->getAggregateRoot($handlerId->toString());
 }
 /**
  * @return MessageHandlerId
  */
 public function firstMessageHandlerId()
 {
     return MessageHandlerId::fromString($this->payload['first_message_handler']);
 }
 /**
  * @param MessageHandlerId $other
  * @return bool
  */
 public function equals(MessageHandlerId $other)
 {
     return $this->toString() === $other->toString();
 }
Exemplo n.º 9
0
 /**
  * @param bool $singleItemMode
  * @return MessageHandler
  */
 protected function getArticleImporterMessageHandler($singleItemMode = false)
 {
     $supportedProcessingType = $singleItemMode ? Article::prototype() : ArticleCollection::prototype();
     return MessageHandler::fromDefinition(MessageHandlerId::generate(), 'Article Importer', NodeName::defaultName(), MessageHandler\HandlerType::connector(), MessageHandler\DataDirection::target(), MessageHandler\ProcessingTypes::support([$supportedProcessingType]), ProcessingMetadata::fromArray(['chunk_support' => true]), 'sqlconnector-pm-metadata', 'glyphicon-hdd', 'glyphicon');
 }
Exemplo n.º 10
0
 /**
  * @return string representation of the unique identifier of the aggregate root
  */
 protected function aggregateId()
 {
     return $this->messageHandlerId->toString();
 }
 /**
  * @param $dataDirection
  * @param null|string $handlerType
  * @param null|array $metadata
  * @return MessageHandler
  */
 private function getMessageHandler($dataDirection, $handlerType = null, array $metadata = null)
 {
     if (!is_null($handlerType)) {
         $handlerType = MessageHandler\HandlerType::fromString($handlerType);
     } else {
         $handlerType = MessageHandler\HandlerType::connector();
     }
     if (!is_null($metadata)) {
         $metadata = ProcessingMetadata::fromArray($metadata);
     } else {
         $metadata = ProcessingMetadata::noData();
     }
     return MessageHandler::fromDefinition(MessageHandlerId::generate(), 'Article Export', NodeName::defaultName(), $handlerType, MessageHandler\DataDirection::fromString($dataDirection), MessageHandler\ProcessingTypes::support([ArticleCollection::prototype(), Article::prototype()]), $metadata, 'sqlconnector-pm-metadata', 'glyphicon-hdd', 'glyphicon', Article::prototype(), MessageHandler\ProcessingId::fromString('sqlconnector:::example'));
 }