foreach ($cgi->param('modifier')) {
# The unless bit is to avoid stacking modifiers.
- $query = ('#' . $_ . ' ' . $query) unless $query =~ qr/\#\Q$_/;
+ $query = ('#' . $_ . ' ' . $query) unless
+ $query =~ qr/\#\Q$_/ or $_ eq 'metabib';
}
# filters
my $ctx = $self->ctx;
my $e = $self->editor;
+ my @mods = $cgi->param('modifier');
+ my $is_meta = @mods and grep { $_ eq 'metabib' } @mods;
+ my $id_key = $is_meta ? 'mmr_id' : 'bre_id';
+
# find the last record in the set, then redirect
my $find_last = $cgi->param('find_last');
return $bbag_err;
}
- $ctx->{page} = 'rresult' unless $internal;
+ if (!$internal) {
+ $ctx->{page} = $is_meta ? 'mresult' : 'rresult';
+ }
$ctx->{ids} = [];
$ctx->{records} = [];
$ctx->{search_facets} = {};
$query = "$_ $query" for @facets;
- $logger->activity("EGWeb: [search] $query");
+ my $ltag = $is_meta ? '[mmr search]' : '[bre search]';
+ $logger->activity("EGWeb: $ltag $query");
try {
my $method = 'open-ils.search.biblio.multiclass.query';
$method .= '.staff' if $ctx->{is_staff};
+ $method =~ s/biblio/metabib/ if $is_meta;
my $ses = OpenSRF::AppSession->create('open-ils.search');
my $rec_id = pop @$rec_ids;
$cgi->delete('find_last');
my $url = $cgi->url(-full => 1, -path => 1, -query => 1);
+ # TODO: metarecord => /rresults?metarecord=$mmr_id
$url =~ s|/results|/record/$rec_id|;
return $self->generic_redirect($url);
}
{
flesh => '{holdings_xml,mra,acp,acnp,acns,bmp}',
site => $site,
+ metarecord => $is_meta,
depth => $depth,
pref_lib => $ctx->{pref_ou},
}
$self->timelog("Returned from get_records_and_facets()");
if ($page == 0) {
+ # TODO: handle metarecords
my $stat = $self->check_1hit_redirect($rec_ids);
return $stat if $stat;
}
for my $rec_id (@$rec_ids) {
push(
@{$ctx->{records}},
- grep { $_->{id} == $rec_id } @data
+ grep { $_->{$id_key} == $rec_id } @data
);
}
if ($tag_circs) {
for my $rec (@{$ctx->{records}}) {
- my ($res_rec) = grep { $_->[0] == $rec->{id} } @{$results->{ids}};
+ my ($res_rec) = grep { $_->[0] == $rec->{$id_key} } @{$results->{ids}};
# index 1 in the per-record result array is a boolean which
# indicates whether the record in question is in the users
# accessible circ history list
my $xml = XML::LibXML->new->parse_string($data->{$unapi_type})->documentElement;
- # NOTE: in metarecord mode, the bre_id will be that of the master
- # record, in which case the bre_id acts as a secondary identifier
- # for the metarecord. Caching via $bre_id (w/ is_meta key_suffix
- # adjustments from above) should still produce unique cache
- # values for each MR. IOW, there' no particular need to extract
- # the MR id.
-
$outer_self->timelog("get_records_and_facets(): parsed xml");
# Protect against legacy invalid MARCXML that might not have a 901c
my $bre_id;
+ my $mmr_id;
my $bre_id_nodes = $xml->find('*[@tag="901"]/*[@code="c"]');
if ($bre_id_nodes) {
$bre_id = $bre_id_nodes->[0]->textContent;
} else {
$logger->warn("Missing 901 subfield 'c' in " . $xml->toString());
}
- $tmp_data{$bre_id} = {id => $bre_id, marc_xml => $xml};
- if ($bre_id) {
+ if ($is_meta) {
+ # extract metarecord ID from mmr.unapi tag
+ for my $node ($xml->getElementsByTagName('abbr')) {
+ my $title = $node->getAttribute('title');
+ ($mmr_id = $title) =~
+ s/tag:open-ils.org:U2\@mmr\/(\d+)\/.*/$1/g;
+ last if $mmr_id;
+ }
+ }
+
+ my $rec_id = $mmr_id ? $mmr_id : $bre_id;
+ $tmp_data{$bre_id} = {
+ id => $rec_id, # for backwards compat
+ bre_id => $bre_id,
+ mmr_id => $mmr_id,
+ marc_xml => $xml
+ };
+
+ if ($rec_id) {
# Let other backends grab our data now that we're done.
- my $key = 'TPAC_unapi_cache_'.$bre_id.'_'.$unapi_cache_key_suffix;
+ my $key = 'TPAC_unapi_cache_'.$rec_id.'_'.$unapi_cache_key_suffix;
my $cache_data = $unapi_cache->get_cache($key);
if ($$cache_data{running}) {
- $unapi_cache->put_cache($key, { id => $bre_id, marc_xml => $data->{$unapi_type} }, 10);
+ $unapi_cache->put_cache($key,
+ {id => $rec_id, marc_xml => $data->{$unapi_type} }, 10);
}
}
-
$outer_self->timelog("get_records_and_facets(): end of success handler");
}
);
my $sdepth = $unapi_args->{flesh_depth};
my $slimit = "acn=>$sdepth,acp=>$sdepth";
$slimit .= ",bre=>$sdepth" if $is_meta;
+ my $flesh = $unapi_args->{flesh} || '';
+
+ # tag the record with the MR id
+ $flesh =~ s/}$/,mmr.unapi}/g if $is_meta;
$ses->request(
'open-ils.cstore.json_query',
{from => [
- $unapi_type, $bid, 'marcxml','record',
- $unapi_args->{flesh},
+ $unapi_type, $bid, 'marcxml','record', $flesh,
$unapi_args->{site},
$unapi_args->{depth},
$slimit,
CASE "sort_selector";
INCLUDE "opac/parts/filtersort.tt2"
value=CGI.param('sort') class='results_header_sel';
+ %]
- CASE "copy_location" %]
+ <!-- applies metarecord search -->
+ <div class="adv_search_available">
+ <input type='checkbox' name="modifier" value="metabib"
+ [%- CGI.param('modifier').grep('metabib').size ?
+ ' checked="checked"' : '' %]
+ id='opac.result.ismetabib' />
+ <label for='opac.result.ismetabib'>
+ [% l("Group Formats and Editions") %]</label>
+ </div>
+
+ [% CASE "copy_location" %]
<select id="adv_copy_location_selector"
aria-label="[% l('Select Shelving Location') %]"
name="fi:locations" size="3" multiple="multiple">
IF CGI.param('detail_record_view');
attrs.title = attrs.title_extended;
END;
+ # note: rec.id refers to the record identifier, regardless
+ # of the type of record. i.e. rec.id = mmr_id ? mmr_id : bre_id
+ IF rec.mmr_id;
+ # metarecords link to record list page
+ record_url = mkurl(ctx.opac_root _ '/results', {metarecord => rec.mmr_id});
+ hold_type = 'M';
+ ELSE;
+ record_url = mkurl(ctx.opac_root _ '/record/' _ rec.bre_id);
+ hold_type = 'T';
+ END;
-%]
<tr class="result_table_row">
<td class="results_row_count" name="results_row_count">[%
result_count; result_count = result_count + 1
%].</td>
<td class='result_table_pic_header'>
- <a href="[% mkurl(ctx.opac_root _ '/record/' _ rec.id) %]"><img alt="[% l('Image of item') %]"
+ <a href="[% record_url %]"><img alt="[% l('Image of item') %]"
name='item_jacket' class='result_table_pic' width="55"
- src='[% ctx.media_prefix %]/opac/extras/ac/jacket/small/r/[% rec.id | uri %]' /></a><br />
+ src='[% ctx.media_prefix %]/opac/extras/ac/jacket/small/r/[% rec.bre_id | uri %]' /></a><br />
</td>
<td class='result_table_title_cell' name='result_table_title_cell'>
<div class="result_metadata">
- <abbr class="unapi-id" title='tag:[% ctx.hostname %],[% date.format(date.now, '%Y') %]:biblio-record_entry/[% rec.id %]'></abbr>
+ [% IF rec.mmr_id %]
+ <abbr class="unapi-id"
+ title='tag:[% ctx.hostname %],[% date.format(date.now, '%Y') %]:metabib-metarecord/[% rec.mmr_id %]'>
+ </abbr>
+ [% ELSE %]
+ <abbr class="unapi-id"
+ title='tag:[% ctx.hostname %],[% date.format(date.now, '%Y') %]:biblio-record_entry/[% rec.bre_id %]'>
+ </abbr>
+ [% END %]
<a class='record_title' name='record_[% rec.id %]' name='item_title'
- href="[% mkurl(ctx.opac_root _ '/record/' _ rec.id) %]"
+ href="[% record_url %]"
[% HTML.attributes(title => l('Display record details for "[_1]"', attrs.title)) %]
class='search_link'>[% attrs.title | html %]</a>
[%-
%]
<div class="results_aux_utils place_hold"><a
href="[% mkurl(ctx.opac_root _ '/place_hold',
- {hold_target => rec.id, hold_type => 'T', hold_source_page => mkurl()}, ['query']) %]"
+ {hold_target => rec.id, hold_type => hold_type,
+ hold_source_page => mkurl()}, ['query']) %]"
name="place_hold_link" class="no-dec"><img
src="[% ctx.media_prefix %]/images/green_check.png"
alt=""/><span class="result_place_hold">[% l('Place Hold') %]</span></a>