コード例 #1
0
 /**
  * {@inheritdoc}
  */
 protected function getConnectors(array $entities)
 {
     $dictionaryConnectors = $this->typeRegistry->getRegisteredConnectorsTypes(ChannelType::TYPE, function (ConnectorInterface $connector) {
         return $connector instanceof DictionaryConnectorInterface;
     })->toArray();
     $connectors = [];
     $initialConnectors = [];
     $isSupportedExtensionVersion = $this->transportEntity->isSupportedExtensionVersion();
     $isExtensionInstalled = $this->transportEntity->getIsExtensionInstalled();
     foreach ($entities as $entity) {
         $connectorName = $this->settingsProvider->getIntegrationConnectorName($entity);
         if ($connectorName) {
             $connector = $this->typeRegistry->getConnectorType(ChannelType::TYPE, $connectorName);
             if (!$connector) {
                 continue;
             }
             $isExtensionApplicable = $connector instanceof ExtensionVersionAwareInterface ? $isSupportedExtensionVersion : $isExtensionInstalled;
             if ($isExtensionApplicable || !$isExtensionApplicable && !$connector instanceof ExtensionAwareInterface) {
                 array_push($initialConnectors, $connectorName . InitialSyncProcessor::INITIAL_CONNECTOR_SUFFIX);
                 array_push($connectors, $connectorName);
             }
         }
     }
     return array_merge(array_keys($dictionaryConnectors), $initialConnectors, $connectors);
 }
コード例 #2
0
ファイル: SyncScheduler.php プロジェクト: xamin123/platform
 /**
  * Schedules backward sync job
  *
  * @param Integration $integration
  * @param string      $connectorType
  * @param array       $params
  * @param bool        $useFlush
  *
  * @throws LogicException
  */
 public function schedule(Integration $integration, $connectorType, $params = [], $useFlush = true)
 {
     if (!$integration->getEnabled()) {
         return;
     }
     $connector = $this->typesRegistry->getConnectorType($integration->getType(), $connectorType);
     if (!$connector instanceof TwoWaySyncConnectorInterface) {
         throw new LogicException(sprintf('Unable to schedule job for "%s" connector type', $connectorType));
     }
     $args = ['--integration=' . $integration->getId(), '--connector=' . $connectorType, '--params=' . serialize($params)];
     $job = new Job(self::JOB_NAME, $args);
     if ($useFlush) {
         $this->em->persist($job);
         $this->em->flush();
     } else {
         $uow = $this->em->getUnitOfWork();
         $uow->persist($job);
         $jobMeta = $this->em->getMetadataFactory()->getMetadataFor('JMS\\JobQueueBundle\\Entity\\Job');
         $uow->computeChangeSet($jobMeta, $job);
     }
 }
コード例 #3
0
ファイル: SyncScheduler.php プロジェクト: nmallare/platform
 /**
  * Schedules backward sync job
  *
  * @param Integration $integration
  * @param string      $connectorType
  * @param array       $params
  * @param bool        $useFlush
  *
  * @throws LogicException
  */
 public function schedule(Integration $integration, $connectorType, $params = [], $useFlush = true)
 {
     if (!$integration->isEnabled()) {
         return;
     }
     $connector = $this->typesRegistry->getConnectorType($integration->getType(), $connectorType);
     if (!$connector instanceof TwoWaySyncConnectorInterface) {
         throw new LogicException(sprintf('Unable to schedule job for "%s" connector type', $connectorType));
     }
     $args = ['--integration=' . $integration->getId(), '--connector=' . $connectorType, '--params=' . serialize($params)];
     if (!$this->isScheduled($args)) {
         $job = new Job(self::JOB_NAME, $args);
         /** @var EntityManager $em */
         $em = $this->registry->getManagerForClass('JMSJobQueueBundle:Job');
         $em->persist($job);
         if (true === $useFlush) {
             $em->flush();
         } else {
             $jobMeta = $em->getClassMetadata('JMSJobQueueBundle:Job');
             $em->getUnitOfWork()->computeChangeSet($jobMeta, $job);
         }
     }
 }
コード例 #4
0
ファイル: SyncProcessor.php プロジェクト: xamin123/platform
 /**
  * Process integration connector
  *
  * @param Integration $integration Integration object
  * @param string      $connector   Connector name
  * @param array       $parameters  Connector additional parameters
  * @param boolean     $saveStatus  Do we need to save new status to bd
  *
  * @return boolean
  */
 protected function processIntegrationConnector(Integration $integration, $connector, array $parameters = [], $saveStatus = true)
 {
     if (!$integration->getEnabled()) {
         return false;
     }
     try {
         $this->logger->info(sprintf('Start processing "%s" connector', $connector));
         // Clone object here because it will be modified and changes should not be shared between
         $realConnector = clone $this->registry->getConnectorType($integration->getType(), $connector);
         $jobName = $realConnector->getImportJobName();
         $processorAliases = $this->processorRegistry->getProcessorAliasesByEntity(ProcessorRegistry::TYPE_IMPORT, $realConnector->getImportEntityFQCN());
     } catch (\Exception $e) {
         // log and continue
         $this->logger->error($e->getMessage());
         $status = new Status();
         $status->setCode(Status::STATUS_FAILED)->setMessage($e->getMessage())->setConnector($connector);
         $this->doctrineRegistry->getRepository('OroIntegrationBundle:Channel')->addStatus($integration, $status);
         return false;
     }
     $configuration = [ProcessorRegistry::TYPE_IMPORT => array_merge(['processorAlias' => reset($processorAliases), 'entityName' => $realConnector->getImportEntityFQCN(), 'channel' => $integration->getId(), 'channelType' => $integration->getType()], $parameters)];
     return $this->processImport($connector, $jobName, $configuration, $integration, $saveStatus);
 }
コード例 #5
0
 /**
  * Clone object here because it will be modified and changes should not be shared between
  *
  * @param Integration $integration
  * @param string      $connector
  *
  * @return TwoWaySyncConnectorInterface
  */
 protected function getRealConnector(Integration $integration, $connector)
 {
     return clone $this->registry->getConnectorType($integration->getType(), $connector);
 }