/**
  * Calls the function specified in the constructor with any additional arguments
  * passed to the constructor.
  */
 public function doUpdate()
 {
     try {
         call_user_func_array($this->doUpdateFunction, $this->arguments);
     } catch (Exception $ex) {
         $this->exceptionHandler->handleException($ex, 'data-update-failed', 'A data update callback triggered an exception');
     }
 }
 /**
  * @param string $line
  * @return EntityId|null
  */
 protected function lineToId($line)
 {
     $line = trim($line);
     try {
         $id = $this->parser->parse($line);
     } catch (EntityIdParsingException $ex) {
         $this->exceptionHandler->handleException($ex, 'bad-entity-id', "Failed to parse Entity ID {$line}");
         $id = null;
     }
     return $id;
 }
Ejemplo n.º 3
0
 /**
  * Dump list of entities
  *
  * @param EntityId[] $entityIds
  * @param int &$dumpCount The number of entities already dumped (will be updated).
  */
 private function dumpEntities(array $entityIds, &$dumpCount)
 {
     $toLoad = array();
     foreach ($entityIds as $entityId) {
         if ($this->idMatchesFilters($entityId)) {
             $toLoad[] = $entityId;
         }
     }
     $this->entityPrefetcher->prefetch($toLoad);
     foreach ($toLoad as $entityId) {
         try {
             $data = $this->generateDumpForEntityId($entityId);
             if (!$data) {
                 continue;
             }
             $this->preEntityDump($dumpCount);
             $this->writeToDump($data);
             $this->postEntityDump($dumpCount);
             $dumpCount++;
             if ($this->limit && $dumpCount >= $this->limit) {
                 break;
             }
         } catch (EntityLookupException $ex) {
             $this->exceptionHandler->handleException($ex, 'failed-to-dump', 'Failed to dump ' . $entityId);
         } catch (StorageException $ex) {
             $this->exceptionHandler->handleException($ex, 'failed-to-dump', 'Failed to dump ' . $entityId);
         }
     }
 }
 /**
  * @param ResultWrapper $res
  *
  * @return EntityId[] An associative array mapping page IDs to Entity IDs.
  */
 private function slurpEntityIds(ResultWrapper $res)
 {
     $entityPerPage = array();
     foreach ($res as $row) {
         try {
             $entityId = $this->idParser->parse($row->pp_value);
             $entityPerPage[$row->pp_page] = $entityId;
         } catch (Exception $ex) {
             $this->exceptionHandler->handleException($ex, 'badEntityId', __METHOD__ . ': ' . 'Failed to parse entity ID: ' . $row->pp_value . ' at page ' . $row->pp_page);
         }
     }
     return $entityPerPage;
 }