Skip to content

Commit dee174a

Browse files
Dyrconajdavis-sitka
authored andcommitted
LP2045440: marc_export Exports Public Copy Notes
Public copy notes are now exported by `marc_export` in the 852 subfield z when the `--items` option is used. To test: 1. Find some copies with copy notes where pub is true. 2. Export the bibs for these copies via `marc_export` with the `--items` option. 3. Check the 852s in the exported file to see that they have no subfiled z. 4. Apply the patch/commit, rebuild and install marc_export. 5. Repeat #2. 6. Check the output for the presence of subfield z in the 852 with the value from the copy notes from the database. You can repeat this test with records that have non-public notes and see that they do not show up in the 852. Signed-off-by: Jason Stephenson <jason@sigio.com> Signed-off-by: Jeff Davis <jdavis@sitka.bclibraries.ca>
1 parent 3f8f18c commit dee174a

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

Open-ILS/src/support-scripts/marc_export.in

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ sub new {
415415
$self->{breClass} = Fieldmapper::class_for_hint('bre');
416416
$self->{acnClass} = Fieldmapper::class_for_hint('acn');
417417
$self->{acpClass} = Fieldmapper::class_for_hint('acp');
418+
$self->{acpnClass} = Fieldmapper::class_for_hint('acpn');
418419
$self->{sreClass} = Fieldmapper::class_for_hint('sre');
419420
$self->{acnpClass} = Fieldmapper::class_for_hint('acnp');
420421
$self->{acnsClass} = Fieldmapper::class_for_hint('acns');
@@ -736,7 +737,8 @@ sub next {
736737
($U->is_true($acp->ref()) ? (x => 'reference') : ()),
737738
(!$U->is_true($acp->holdable()) ? (x => 'unholdable') : ()),
738739
(!$U->is_true($acp->circulate()) ? (x => 'noncirculating') : ()),
739-
(!$U->is_true($acp->opac_visible()) ? (x => 'hidden') : ())
740+
(!$U->is_true($acp->opac_visible()) ? (x => 'hidden') : ()),
741+
((defined($acp->notes()) && @{$acp->notes()}) ? map {(z => ($_->title()) ? $_->title() . ": " . $_->value() : $_->value())} @{$acp->notes()} : ())
740742
));
741743
};
742744
if ($@) {
@@ -1025,6 +1027,10 @@ sub acps_for_bre {
10251027
$_->status($statuses->{$_->status()});
10261028
$_->call_number->prefix($prefixes->{$acn->prefix()});
10271029
$_->call_number->suffix($suffixes->{$acn->suffix()});
1030+
my @acpns = $self->public_acpns_for_acp($_);
1031+
if (@acpns) {
1032+
$_->notes(\@acpns);
1033+
}
10281034
}
10291035
return @acps;
10301036
}
@@ -1034,7 +1040,27 @@ sub acps_for_bre {
10341040
return undef;
10351041
}
10361042

1037-
# Retreive an array for sre objects when the --mfhd option is used.
1043+
# Retrieves an array of public copy notes for a given copy
1044+
sub public_acpns_for_acp {
1045+
my $self = shift;
1046+
my $acp = shift;
1047+
$acp = $acp->id() if (ref($acp));
1048+
unless ($self->{acpnHandle}) {
1049+
my $query = "select " . join(',', $self->{acpnClass}->real_fields());
1050+
$query .= " from asset.copy_note where pub is true";
1051+
$query .= " and owning_copy = ? and value <> ''";
1052+
$self->{acpnHandle} = $self->{handle}->prepare($query);
1053+
}
1054+
if ($self->{acpnHandle}->execute($acp)) {
1055+
my $result = $self->{acpnHandle}->fetchall_arrayref( {} );
1056+
if ($result && @{$result}) {
1057+
return map {$self->{acpnClass}->from_bare_hash($_)} @{$result};
1058+
}
1059+
}
1060+
return ();
1061+
}
1062+
1063+
# Retrieve an array of sre objects when the --mfhd option is used.
10381064
sub sres_for_bre {
10391065
my $self = shift;
10401066
my $bre = shift;

0 commit comments

Comments
 (0)