Skip to content
Snippets Groups Projects
Commit e371f79e authored by Demian Katz's avatar Demian Katz
Browse files

Added support for ILS drivers interacting with non-Solr backends.

parent 84051e8d
Branches
Tags
No related merge requests found
...@@ -9,3 +9,11 @@ storageRetrievalRequests = true ...@@ -9,3 +9,11 @@ storageRetrievalRequests = true
; Whether to support ILL requests ; Whether to support ILL requests
ILLRequests = true ILLRequests = true
; Configuration for retrieving sample records
[Records]
; Search backend to pull records from
source = Solr
; Query to use for record retrieval
query = "*:*"
\ No newline at end of file
...@@ -824,8 +824,9 @@ class MyResearchController extends AbstractBase ...@@ -824,8 +824,9 @@ class MyResearchController extends AbstractBase
protected function getDriverForILSRecord($current) protected function getDriverForILSRecord($current)
{ {
$id = isset($current['id']) ? $current['id'] : null; $id = isset($current['id']) ? $current['id'] : null;
$source = isset($current['source']) ? $current['source'] : 'VuFind';
$record = $this->getServiceLocator()->get('VuFind\RecordLoader') $record = $this->getServiceLocator()->get('VuFind\RecordLoader')
->load($id, 'VuFind', true); ->load($id, $source, true);
$record->setExtraDetail('ils_details', $current); $record->setExtraDetail('ils_details', $current);
return $record; return $record;
} }
...@@ -1089,9 +1090,10 @@ class MyResearchController extends AbstractBase ...@@ -1089,9 +1090,10 @@ class MyResearchController extends AbstractBase
if (!isset($row['id']) || empty($row['id'])) { if (!isset($row['id']) || empty($row['id'])) {
throw new \Exception(); throw new \Exception();
} }
$record = $this->getServiceLocator()->get('VuFind\RecordLoader') $source = isset($row['source']) ? $row['source'] : 'VuFind';
->load($row['id']); $row['driver'] = $this->getServiceLocator()->get('VuFind\RecordLoader')
$row['title'] = $record->getShortTitle(); ->load($row['id'], $source);
$row['title'] = $row['driver']->getShortTitle();
} catch (\Exception $e) { } catch (\Exception $e) {
if (!isset($row['title'])) { if (!isset($row['title'])) {
$row['title'] = null; $row['title'] = null;
......
...@@ -195,13 +195,27 @@ class Demo extends AbstractBase ...@@ -195,13 +195,27 @@ class Demo extends AbstractBase
*/ */
protected function getRandomBibId() protected function getRandomBibId()
{ {
$result = $this->searchService->random('Solr', new Query(''), 1); $source = $this->getRecordSource();
$query = isset($this->config['Records']['query'])
? $this->config['Records']['query'] : '*:*';
$result = $this->searchService->random($source, new Query($query), 1);
if (count($result) === 0) { if (count($result) === 0) {
throw new \Exception('Problem retrieving random record.'); throw new \Exception('Problem retrieving random record from $source.');
} }
return current($result->getRecords())->getUniqueId(); return current($result->getRecords())->getUniqueId();
} }
/**
* Get the name of the search backend providing records.
*
* @return string
*/
protected function getRecordSource()
{
return isset($this->config['Records']['source'])
? $this->config['Records']['source'] : 'Solr';
}
/** /**
* Generates a random, fake holding array * Generates a random, fake holding array
* *
...@@ -297,6 +311,7 @@ class Demo extends AbstractBase ...@@ -297,6 +311,7 @@ class Demo extends AbstractBase
} else { } else {
if ($this->idsInMyResearch) { if ($this->idsInMyResearch) {
$currentItem['id'] = $this->getRandomBibId(); $currentItem['id'] = $this->getRandomBibId();
$currentItem['source'] = $this->getRecordSource();
} else { } else {
$currentItem['title'] = 'Demo Title ' . $i; $currentItem['title'] = 'Demo Title ' . $i;
} }
...@@ -635,6 +650,7 @@ class Demo extends AbstractBase ...@@ -635,6 +650,7 @@ class Demo extends AbstractBase
if (rand() % 3 != 1) { if (rand() % 3 != 1) {
if ($this->idsInMyResearch) { if ($this->idsInMyResearch) {
$fineList[$i]['id'] = $this->getRandomBibId(); $fineList[$i]['id'] = $this->getRandomBibId();
$fineList[$i]['source'] = $this->getRecordSource();
} else { } else {
$fineList[$i]['title'] = 'Demo Title ' . $i; $fineList[$i]['title'] = 'Demo Title ' . $i;
} }
...@@ -782,6 +798,7 @@ class Demo extends AbstractBase ...@@ -782,6 +798,7 @@ class Demo extends AbstractBase
); );
if ($this->idsInMyResearch) { if ($this->idsInMyResearch) {
$transList[$i]['id'] = $this->getRandomBibId(); $transList[$i]['id'] = $this->getRandomBibId();
$transList[$i]['source'] = $this->getRecordSource();
} else { } else {
$transList[$i]['title'] = 'Demo Title ' . $i; $transList[$i]['title'] = 'Demo Title ' . $i;
} }
......
...@@ -26,10 +26,10 @@ ...@@ -26,10 +26,10 @@
<td> <td>
<? if (empty($record['title'])): ?> <? if (empty($record['title'])): ?>
<?=$this->transEsc('not_applicable')?> <?=$this->transEsc('not_applicable')?>
<? elseif (!isset($record['id'])): ?> <? elseif (!is_object($record['driver'])): ?>
<?=$this->escapeHtml(trim($record['title'], '/:'))?> <?=$this->escapeHtml(trim($record['title'], '/:'))?>
<? else: ?> <? else: ?>
<a href="<?=$this->url('record', array('id' => $record['id']))?>"><?=$this->escapeHtml(trim($record['title'], '/:'))?></a> <a href="<?=$this->recordLink()->getUrl($record['driver'])?>"><?=$this->escapeHtml(trim($record['title'], '/:'))?></a>
<? endif; ?> <? endif; ?>
</td> </td>
<td><?=isset($record['checkout']) ? $this->escapeHtml($record['checkout']) : ''?></td> <td><?=isset($record['checkout']) ? $this->escapeHtml($record['checkout']) : ''?></td>
......
...@@ -25,10 +25,10 @@ ...@@ -25,10 +25,10 @@
<td> <td>
<? if (empty($record['title'])): ?> <? if (empty($record['title'])): ?>
<?=$this->transEsc('not_applicable')?> <?=$this->transEsc('not_applicable')?>
<? elseif (!isset($record['id'])): ?> <? elseif (!is_object($record['driver'])): ?>
<?=$this->escapeHtml(trim($record['title'], '/:'))?> <?=$this->escapeHtml(trim($record['title'], '/:'))?>
<? else: ?> <? else: ?>
<a href="<?=$this->url('record', array('id' => $record['id']))?>"><?=$this->escapeHtml(trim($record['title'], '/:'))?></a> <a href="<?=$this->recordLink()->getUrl($record['driver'])?>"><?=$this->escapeHtml(trim($record['title'], '/:'))?></a>
<? endif; ?> <? endif; ?>
</td> </td>
<td><?=isset($record['checkout']) ? $this->escapeHtml($record['checkout']) : ''?></td> <td><?=isset($record['checkout']) ? $this->escapeHtml($record['checkout']) : ''?></td>
......
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
<ul class="results fines" data-role="listview"> <ul class="results fines" data-role="listview">
<? foreach ($this->fines as $record): ?> <? foreach ($this->fines as $record): ?>
<li> <li>
<? if ($showLink = (!empty($record['title']) && isset($record['id']))): ?> <? if ($showLink = (!empty($record['title']) && is_object($record['driver']))): ?>
<a rel="external" href="<?=$this->url('record', array('id' => $record['id']))?>"> <a rel="external" href="<?=$this->recordLink()->getUrl($record['driver'])?>">
<? endif; ?> <? endif; ?>
<div class="result"> <div class="result">
<h3> <h3>
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment