/**
  * @param MessageType $messageType
  * @return bool
  */
 private function canHandleMessageType(MessageType $messageType)
 {
     if ($this->handlerType->isConnector()) {
         if ($messageType->isCollectDataMessage() && $this->dataDirection->isSource()) {
             return true;
         }
         if ($messageType->isProcessDataMessage() && $this->dataDirection->isTarget()) {
             return true;
         }
     } elseif ($this->handlerType->isScript()) {
         if ($messageType->isProcessDataMessage()) {
             return true;
         }
     } else {
         //HandlerType is callback, so handler can handle all message types
         return true;
     }
     //No matching until now, so handler is not able to handle the message type
     return false;
 }
 /**
  * @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);
 }
Exemplo n.º 3
0
 /**
  * @param DataDirection $other
  * @return bool
  */
 public function equals(DataDirection $other)
 {
     return $this->toString() === $other->toString();
 }
Exemplo n.º 4
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');
 }
 /**
  * @return DataDirection
  */
 public function dataDirection()
 {
     return DataDirection::fromString($this->payload['data_direction']);
 }
 /**
  * @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'));
 }
 /**
  * @test
  */
 function it_is_equal_to_another_source()
 {
     $direction1 = DataDirection::source();
     $direction2 = DataDirection::source();
     $this->assertTrue($direction1->equals($direction2));
 }
 /**
  * @return DataDirection
  */
 public function dataDirection()
 {
     if (is_null($this->dataDirection)) {
         $this->dataDirection = DataDirection::fromString($this->payload['data_direction']);
     }
     return $this->dataDirection;
 }