Ejemplo n.º 1
0
 /**
  * @param mixed $id
  * @param array $data
  * @return array|mixed|null|ApiProblemResponse
  */
 public function update($id, array $data)
 {
     if (!$this->existsConnector($id)) {
         return new ApiProblemResponse(new ApiProblem(404, 'Connector can not be found'));
     }
     $data['ui_metadata_riot_tag'] = self::UI_METADATA_RIOT_TAG;
     $data['icon'] = self::ICON;
     $result = $this->validateConnectorData($data);
     if ($result instanceof ApiProblemResponse) {
         return $result;
     }
     $data = FileGatewayTranslator::translateFromClient($data);
     $this->commandBus->dispatch(ChangeConnectorConfig::ofConnector($id, $data, $this->systemConfig->getConfigLocation()));
     $data = FileGatewayTranslator::translateToClient($data);
     $data['id'] = $id;
     return $data;
 }
 public function updateConnector($id, array $connector, $regenerateType = false)
 {
     $this->assertConnector($connector);
     if (!$this->dbalConnections->containsKey($connector['dbal_connection'])) {
         throw new \InvalidArgumentException(sprintf("Dbal connection %s for connector %s does not exists", $connector['dbal_connection'], $connector['name']));
     }
     $connection = $this->dbalConnections->get($connector['dbal_connection']);
     if ($regenerateType) {
         $generatedTypes = $this->replaceProcessingTypes($connection->config()['dbname'], $connector['table'], $connection->connection());
     } else {
         $generatedTypes = $this->generateTypeClassFQCNs($connection->config()['dbname'], $connector['table']);
     }
     $connector['icon'] = self::ICON;
     $connector['ui_metadata_riot_tag'] = self::METADATA_UI_KEY;
     $connector['allowed_types'] = $generatedTypes;
     $connector['allowed_messages'] = [MessageNameUtils::COLLECT_DATA, MessageNameUtils::PROCESS_DATA];
     $command = ChangeConnectorConfig::ofConnector($id, $connector, $this->configLocation);
     $this->commandBus->dispatch($command);
 }
 /**
  * @param MessageHandler $messageHandler
  */
 private function syncMessageHandler(MessageHandler $messageHandler)
 {
     $additionalData = $messageHandler->additionalData();
     if ($messageHandler->preferredProcessingType()) {
         $additionalData['preferred_type'] = $messageHandler->preferredProcessingType()->of();
     }
     $additionalData['node_name'] = $messageHandler->processingNodeName()->toString();
     $additionalData['icon'] = $messageHandler->icon();
     $additionalData['icon_type'] = $messageHandler->iconType();
     $additionalData['metadata'] = $messageHandler->processingMetadata()->toArray();
     $additionalData['ui_metadata_riot_tag'] = $messageHandler->metadataRiotTag();
     $allowedTypes = $messageHandler->supportedProcessingTypes()->areAllTypesSupported() ? MessageHandler\ProcessingTypes::SUPPORT_ALL : $messageHandler->supportedProcessingTypes()->typeList();
     if ($messageHandler->isKnownInProcessingSystem()) {
         $this->commandBus->dispatch(ChangeConnectorConfig::ofConnector($messageHandler->processingId()->toString(), array_merge(['name' => $messageHandler->name(), 'allowed_messages' => $this->determineAllowedMessages($messageHandler), 'allowed_types' => $allowedTypes], $additionalData), $this->processingConfigLocation));
     } else {
         $this->commandBus->dispatch(AddConnectorToConfig::fromDefinition($messageHandler->processingId()->toString(), $messageHandler->name(), $this->determineAllowedMessages($messageHandler), $allowedTypes, $this->processingConfigLocation, $additionalData));
     }
 }