58 |
|
|
59 |
=cut |
=cut |
60 |
|
|
61 |
|
my $created_with_marc_template; |
62 |
|
|
63 |
sub marc_template { |
sub marc_template { |
64 |
my $args = {@_}; |
my $args = {@_}; |
65 |
warn "## marc_template(",dump($args),")",$/ if $debug; |
warn "## marc_template(",dump($args),")",$/ if $debug; |
136 |
|
|
137 |
my $i1 = $r->{i1} || ' '; |
my $i1 = $r->{i1} || ' '; |
138 |
my $i2 = $r->{i2} || ' '; |
my $i2 = $r->{i2} || ' '; |
139 |
$m = [ $args->{to}, $i1, $i2 ]; |
my $to = $args->{to}; |
140 |
|
$m = [ $to, $i1, $i2 ]; |
141 |
|
|
142 |
|
$created_with_marc_template->{ $to }++; |
143 |
|
|
144 |
warn "### r = ",dump( $r ),$/ if $debug; |
warn "### r = ",dump( $r ),$/ if $debug; |
145 |
|
|
615 |
return $#{ $marc_record }; |
return $#{ $marc_record }; |
616 |
} |
} |
617 |
|
|
618 |
|
=head1 PRIVATE FUNCTIONS |
619 |
|
|
620 |
=head2 _marc_push |
=head2 _marc_push |
621 |
|
|
622 |
_marc_push( $marc ); |
_marc_push( $marc ); |
628 |
push @{ $marc_record->[ $marc_record_offset ] }, $marc; |
push @{ $marc_record->[ $marc_record_offset ] }, $marc; |
629 |
} |
} |
630 |
|
|
|
=head1 PRIVATE FUNCTIONS |
|
|
|
|
631 |
=head2 _clean |
=head2 _clean |
632 |
|
|
633 |
Clean internal structures |
Clean internal structures |
635 |
=cut |
=cut |
636 |
|
|
637 |
sub _clean { |
sub _clean { |
638 |
($marc_record, $marc_encoding, $marc_repeatable_subfield, $marc_indicators, $marc_leader) = (); |
($marc_record, $marc_encoding, $marc_repeatable_subfield, $marc_indicators, $marc_leader, $created_with_marc_template) = (); |
639 |
($marc_record_offset, $marc_fetch_offset) = (0,0); |
($marc_record_offset, $marc_fetch_offset) = (0,0); |
640 |
} |
} |
641 |
|
|
649 |
We are using I<magic> which detect repeatable fields only from |
We are using I<magic> which detect repeatable fields only from |
650 |
sequence of field/subfield data generated by normalization. |
sequence of field/subfield data generated by normalization. |
651 |
|
|
652 |
|
This magic is disabled for all records created with C<marc_template>. |
653 |
|
|
654 |
Repeatable field is created when there is second occurence of same subfield or |
Repeatable field is created when there is second occurence of same subfield or |
655 |
if any of indicators are different. |
if any of indicators are different. |
656 |
|
|
722 |
|
|
723 |
# first, sort all existing fields |
# first, sort all existing fields |
724 |
# XXX might not be needed, but modern perl might randomize elements in hash |
# XXX might not be needed, but modern perl might randomize elements in hash |
725 |
my @sorted_marc_record = sort { |
# my @sorted_marc_record = sort { |
726 |
$a->[0] . ( $a->[3] || '' ) cmp $b->[0] . ( $b->[3] || '') |
# $a->[0] . ( $a->[3] || '' ) cmp $b->[0] . ( $b->[3] || '') |
727 |
} @{ $marc_rec }; |
# } @{ $marc_rec }; |
728 |
|
|
729 |
@sorted_marc_record = @{ $marc_rec }; ### FIXME disable sorting |
@sorted_marc_record = @{ $marc_rec }; ### FIXME disable sorting |
730 |
|
|
759 |
|
|
760 |
my $row = dclone( $sorted_marc_record[$i] ); |
my $row = dclone( $sorted_marc_record[$i] ); |
761 |
|
|
762 |
|
if ( $created_with_marc_template->{ $row->[0] } ) { |
763 |
|
push @m, $row; |
764 |
|
warn "## copied marc_template created ", dump( $row ),$/ if $debug; |
765 |
|
next; |
766 |
|
} |
767 |
# field and subfield which is key for |
# field and subfield which is key for |
768 |
# marc_repeatable_subfield and u |
# marc_repeatable_subfield and u |
769 |
my $fsf = $row->[0] . ( $row->[3] || '' ); |
my $fsf = $row->[0] . ( $row->[3] || '' ); |