/**
  * @param OutputInterface $output
  * @param ImportPart      $part
  */
 protected function runImportPart(OutputInterface $output, ImportPart $part)
 {
     $output->writeln(sprintf('Importing part <comment>%d</comment> of import <comment>%d</comment>', $part->getPosition(), $part->getImport()->getId()));
     $job = $this->importFactory->createImportJob($part);
     $job->setLogger($this->logger);
     $job->run();
 }
 /**
  * @inheritdoc
  */
 public function markProcessing(ImportPart $part)
 {
     $part->setProcess(posix_getpid());
 }
 /**
  * @param ImportPart               $importPart
  * @param EventDispatcherInterface $dispatcher
  * @param array                    $options
  *
  * @return ReaderInterface
  */
 protected function createImportPartReader(ImportPart $importPart, EventDispatcherInterface $dispatcher, array $options = [])
 {
     $import = $importPart->getImport();
     $transport = $importPart->getTransportConfig();
     $resourceType = ReaderBuilderInterface::RESOURCE_TYPE_PART;
     return $this->createReader($import, $transport, $resourceType, $dispatcher, $options);
 }
 /**
  * @param ImportPart $part
  */
 public function schedulePart(ImportPart $part)
 {
     $part->setDatetimeScheduled(new \DateTime());
     $this->getImportRepository()->savePart($part);
     $this->eventDispatcher->dispatch(ImportEvents::PART_SCHEDULED, new PartEvent($part));
 }
Example #5
0
 /**
  * @param string $message
  */
 protected function fail($message)
 {
     // log the error
     $this->part->setError($message);
     $this->logger->error(sprintf('Importing part %d of import %d failed with message: %s', $this->part->getPosition(), $this->part->getImport()->getId(), $message));
 }
 /**
  * @param ImportPart $part
  *
  * @return bool
  */
 protected function validate(ImportPart $part)
 {
     // validate that we have a valid transport config
     try {
         TransportFactory::createTransportFromConfig($part->getTransportConfig());
     } catch (\RuntimeException $e) {
         $part->setError($e->getMessage());
         return false;
     }
     return true;
 }
 /**
  * @param ImportPart $part
  */
 public function finishImportPart(ImportPart $part)
 {
     if (!$part->isStarted()) {
         throw new \RuntimeException('Import part has not yet started');
     }
     $part->setDatetimeEnded(new \DateTime());
     $this->savePart($part);
 }