예제 #1
0
파일: Loader.php 프로젝트: tillk/vufind
 /**
  * Given an ID and record source, load the requested record object.
  *
  * @param string $id              Record ID
  * @param string $source          Record source
  * @param bool   $tolerateMissing Should we load a "Missing" placeholder
  * instead of throwing an exception if the record cannot be found?
  *
  * @throws \Exception
  * @return \VuFind\RecordDriver\AbstractBase
  */
 public function load($id, $source = 'VuFind', $tolerateMissing = false)
 {
     $results = $this->searchService->retrieve($source, $id)->getRecords();
     if (count($results) > 0) {
         return $results[0];
     }
     if ($tolerateMissing) {
         $record = $this->recordFactory->get('Missing');
         $record->setRawData(['id' => $id]);
         $record->setSourceIdentifier($source);
         return $record;
     }
     throw new RecordMissingException('Record ' . $source . ':' . $id . ' does not exist.');
 }
예제 #2
0
 /**
  * Given an ID and record source, load the requested record object.
  *
  * @param string $id              Record ID
  * @param string $source          Record source
  * @param bool   $tolerateMissing Should we load a "Missing" placeholder
  * instead of throwing an exception if the record cannot be found?
  *
  * @throws \Exception
  * @return \VuFind\RecordDriver\AbstractBase
  */
 public function load($id, $source = DEFAULT_SEARCH_BACKEND, $tolerateMissing = false)
 {
     if (null !== $id && '' !== $id) {
         $results = [];
         if (null !== $this->recordCache && $this->recordCache->isPrimary($source)) {
             $results = $this->recordCache->lookup($id, $source);
         }
         if (empty($results)) {
             $results = $this->searchService->retrieve($source, $id)->getRecords();
         }
         if (empty($results) && null !== $this->recordCache && $this->recordCache->isFallback($source)) {
             $results = $this->recordCache->lookup($id, $source);
         }
         if (!empty($results)) {
             return $results[0];
         }
     }
     if ($tolerateMissing) {
         $record = $this->recordFactory->get('Missing');
         $record->setRawData(['id' => $id]);
         $record->setSourceIdentifier($source);
         return $record;
     }
     throw new RecordMissingException('Record ' . $source . ':' . $id . ' does not exist.');
 }
예제 #3
0
파일: Solr.php 프로젝트: CUSAT/vufind
 /**
  * Does this data source support the specified hierarchy ID?
  *
  * @param string $id Hierarchy ID.
  *
  * @return bool
  */
 public function supports($id)
 {
     $settings = $this->hierarchyDriver->getTreeSettings();
     if (!isset($settings['checkAvailability']) || $settings['checkAvailability'] == 1) {
         $results = $this->searchService->retrieve('Solr', $id, new ParamBag(['fq' => $this->filters]));
         if ($results->getTotal() < 1) {
             return false;
         }
     }
     // If we got this far the support-check was positive in any case.
     return true;
 }