/** * Return an individual record * * @param string record identifier * @return ResultSet */ protected function doGetRecord($id) { $results = new Search\ResultSet($this->config); // get the record from the database $record = $this->datamap->getRecordByID($id); // no record found? if ($record == null) { $results->total = 0; return $results; } // got one $results->total = 1; $result = $this->createSearchResult($record); // corrupted record, look out if ($result->corrupted == true) { $fixed = false; $data = $record->marc; // go back to the original search engine and fetch it again $class_name = 'Application\\Model\\' . ucfirst($result->source) . '\\Engine'; if (class_exists($class_name)) { try { $engine = new $class_name(); $new_results = $engine->getRecord($result->original_id); if ($new_results->total > 0) { $result = $new_results->getRecord(0); $fixed = true; } } catch (NotFoundException $e) { if (strstr($data, 'Xerxes_TransRecord')) { $data = '<?xml version="1.0"?>' . Parser::removeLeft($data, '<?xml version="1.0"?>'); $data = Parser::removeRight($data, '</xerxes_record>') . '</xerxes_record>'; $xerxes_record = new Xerxes\Record(); $xerxes_record->loadXML($data); $record->xerxes_record = $xerxes_record; // recreate the result, since we need the openurl and such $result = $this->createSearchResult($record); $fixed = true; } } } elseif (strstr($data, 'Xerxes_MetalibRecord')) { $data = '<?xml' . Parser::removeLeft($data, '<?xml'); $data = Parser::removeRight($data, '</x_server_response>') . '</x_server_response>'; $xerxes_record = new \Xerxes_MetalibRecord(); $xerxes_record->loadXML($data); $record->xerxes_record = $xerxes_record; // recreate the result, since we need the openurl and such $result = $this->createSearchResult($record); $fixed = true; } if ($fixed == false) { throw new \Exception('Sorry, this record has been corrupted'); } } // if a catalog record, fetch holdings if ($record->xerxes_record instanceof Solr\Record) { try { $engine = new Solr\Engine(); $solr_results = $engine->getRecord($result->original_id); $holdings = $solr_results->getRecord(0)->getHoldings(); $result->setHoldings($holdings); } catch (\Exception $e) { trigger_error('saved records holdings lookup: ' . $e->getMessage(), E_USER_WARNING); } } $results->addResult($result); return $results; }
public function loadXML($xml) { parent::loadXML($xml); }
/** * Load data from MARC-XML */ public function loadXML($xml) { $this->marc = new MarcRecord(); $this->marc->loadXML($xml); parent::loadXML($xml); }
/** * Load data from MARC record * * @param MarcRecord $marc */ public function loadMarc(MarcRecord $marc) { $this->marc = $marc; parent::loadXML($marc->getMarcXML()); }