$bre_ids = [ map {$_->{target_biblio_record_entry}} @$bre_ids ];
- # build the Z39 queries for the source bib records
-
$z_indexes = $e->search_config_z3950_index_field_map({id => $z_indexes});
return OpenILS::Event->new('BAD_PARAMS',
note => q/No z_indexes/) unless @$z_indexes;
+ # build the Z39 queries for the source bib records
+
+ my $z_searches = compile_bucket_zsearch(
+ $e, $bre_ids, $z_sources, $z_indexes);
+
+ return $e->event unless $z_searches;
+
+ return $z_searches; # TODO
+}
+
+
+# creates a series of Z39.50 searchs based on the
+# in-bucket records and the selected sources and indexes
+sub compile_bucket_zsearch {
+ my ($e, $bre_ids, $z_sources, $z_indexes) = @_;
# pre-load the metabib_field's we'll need for this batch
%mb_fields = map {$_->id => $_} @$field_objs;
}
- # pre-load the referenced z3950_attrs
+ # pre-load the z3950_attrs we'll need for this batch
my %z3950_attrs;
my @z3950_attrs = grep { $_->z3950_attr } @$z_indexes;
my @z_index_attrs = grep { {defined $_->z3950_attr} } @$z_indexes;
my @z_index_types = grep { {not defined $_->z3950_attr} } @$z_indexes;
- # for each bib record, extract the indexed value for each of the
- # selected indexes.
+ # for each bib record, extract the indexed value for the selected indexes.
my %z_searches;
for my $bre_id (@$bre_ids) {
- $z_searches{$bre_id} = {}; # TODO
+ $z_searches{$bre_id} = {};
for my $z_index (@z_index_attrs, @z_index_types) {
# only applies to the z_source linked to the attr
$z_index_name = $z3950_attrs{$z_index->z3950_attr}->name;
- push(@$z_source, $z3950_attrs{$z_index->z3950_attr}->source);
+ my $src = $z3950_attrs{$z_index->z3950_attr}->source;
+
+ if (grep { $_ eq $src } @$z_sources) {
+ push(@$z_source, $src);
+ } else {
+ $logger->warn("z39: z3950_attr '$z_index_name' for '$src'".
+ " selected, but $src is not in the search list. Skipping...");
+ }
} else {
}
}
- # TODO
- $z_searches{$bre_id}{$z_index->id} = {
- z_source => $z_source,
- z_index_name => $z_index_name,
- bib_value => $bre_val
- };
-
+ if (@$z_source) {
+ $z_searches{$bre_id}{$z_index->id} = {
+ z_source => $z_source,
+ z_index_name => $z_index_name,
+ bib_value => $bre_val
+ };
+ }
}
}
- # TODO
return \%z_searches;
}