/** * @param Import $import * @param array $targets * @param array $configuration * @param ResourceInterface $resource * @param ManagerInterface $manager * @return bool * @throws \HDNET\Importr\Exception\ReinitializeException */ public function process(Import $import, array $targets, array $configuration, ResourceInterface $resource, ManagerInterface $manager) { // Resourcen Object anhand der Datei auswählen if (!preg_match($resource->getFilepathExpression(), $import->getFilepath())) { return false; } $this->configuration->process($configuration, $manager, 'before'); // Resource "benutzen" $resource->parseResource(); // Basis Import Aktualsieren (DB) $import->setAmount($resource->getAmount()); $import->setStarttime(new \DateTime('now')); $this->importService->updateImport($import); // Durchlauf starten for ($pointer = $import->getPointer(); $pointer < $import->getAmount(); $pointer++) { $this->configuration->process($configuration, $manager, 'each'); $this->processOneLine($resource, $pointer, $targets, $import); if (($pointer + 1) % $manager->getUpdateInterval() == 0) { $this->importService->updateImport($import, $pointer + 1); } } $import->setEndtime(new \DateTime('now')); $this->importService->updateImport($import, $pointer); $this->configuration->process($configuration, $manager, 'after'); return true; }
/** * @param TargetInterface $target * @param mixed $entry * @param Import $import * @param int $pointer * * @throws \Exception */ public function process(TargetInterface $target, $entry, Import $import, $pointer) { try { $entry = $this->emitEntrySignal('preProcess', $target->getConfiguration(), $entry); $result = $target->processEntry($entry); $import->increaseCount($result); } catch (\Exception $e) { $import->increaseCount(TargetInterface::RESULT_ERROR); $this->importService->updateImport($import, $pointer + 1); throw $e; } }