|
Lines 26-31
use C4::Charset;
Link Here
|
| 26 |
use C4::Items; |
26 |
use C4::Items; |
| 27 |
use C4::MarcModificationTemplates; |
27 |
use C4::MarcModificationTemplates; |
| 28 |
|
28 |
|
|
|
29 |
use Encode; |
| 29 |
use YAML; |
30 |
use YAML; |
| 30 |
use Unicode::Normalize; |
31 |
use Unicode::Normalize; |
| 31 |
use Time::HiRes qw(gettimeofday); |
32 |
use Time::HiRes qw(gettimeofday); |
|
Lines 48-53
my $framework = '';
Link Here
|
| 48 |
my $localcust; |
49 |
my $localcust; |
| 49 |
my $marc_mod_template = ''; |
50 |
my $marc_mod_template = ''; |
| 50 |
my $marc_mod_template_id = -1; |
51 |
my $marc_mod_template_id = -1; |
|
|
52 |
my ($incoming_filter, $local_filter); |
| 53 |
|
| 51 |
|
54 |
|
| 52 |
$|=1; |
55 |
$|=1; |
| 53 |
|
56 |
|
|
Lines 85-93
GetOptions(
Link Here
|
| 85 |
'framework=s' => \$framework, |
88 |
'framework=s' => \$framework, |
| 86 |
'custom:s' => \$localcust, |
89 |
'custom:s' => \$localcust, |
| 87 |
'marcmodtemplate:s' => \$marc_mod_template, |
90 |
'marcmodtemplate:s' => \$marc_mod_template, |
|
|
91 |
'incomingfilter=s' => \$incoming_filter, |
| 92 |
'localfilter=s' => \$local_filter, |
| 88 |
); |
93 |
); |
| 89 |
$biblios ||= !$authorities; |
94 |
$biblios ||= !$authorities; |
| 90 |
$insert ||= !$update; |
95 |
$insert ||= !$update; |
|
|
96 |
|
| 97 |
$incoming_filter = decode('UTF-8', $incoming_filter) if ($incoming_filter); |
| 98 |
$local_filter = decode('UTF-8', $local_filter) if ($local_filter); |
| 99 |
|
| 91 |
my $writemode = ($append) ? "a" : "w"; |
100 |
my $writemode = ($append) ? "a" : "w"; |
| 92 |
|
101 |
|
| 93 |
pod2usage( -msg => "\nYou must specify either --biblios or --authorities, not both.\n", -exitval ) if $biblios && $authorities; |
102 |
pod2usage( -msg => "\nYou must specify either --biblios or --authorities, not both.\n", -exitval ) if $biblios && $authorities; |
|
Lines 291-296
RECORD: while ( ) {
Link Here
|
| 291 |
} |
300 |
} |
| 292 |
} |
301 |
} |
| 293 |
SetUTF8Flag($record); |
302 |
SetUTF8Flag($record); |
|
|
303 |
if ($incoming_filter) { |
| 304 |
my ($fieldsubfieldtag, $value) = split('=', $incoming_filter); |
| 305 |
die "Unable to get field/subfield and value to discard record (-incomingfilter=$incoming_filter)\n" unless ($fieldsubfieldtag && $value); |
| 306 |
my ($fieldtag, $subfieldtag) = split('\$', $fieldsubfieldtag); |
| 307 |
die "Unable to get field and subfield to discard record (-incomingfilter=$incoming_filter)\n" unless ($fieldtag && $subfieldtag); |
| 308 |
foreach my $field ($record->field($fieldtag)) { |
| 309 |
foreach my $subfield ($field->subfield($subfieldtag)) { |
| 310 |
if ($subfield eq $value) { |
| 311 |
$debug and warn "Discarding record (incoming record contains $fieldsubfieldtag = $value)\n"; |
| 312 |
next RECORD; |
| 313 |
} |
| 314 |
} |
| 315 |
} |
| 316 |
} |
| 294 |
if($marc_mod_template_id > 0) { |
317 |
if($marc_mod_template_id > 0) { |
| 295 |
print "Modifying MARC\n" if $verbose; |
318 |
print "Modifying MARC\n" if $verbose; |
| 296 |
ModifyRecordWithTemplate( $marc_mod_template_id, $record ); |
319 |
ModifyRecordWithTemplate( $marc_mod_template_id, $record ); |
|
Lines 328-333
RECORD: while ( ) {
Link Here
|
| 328 |
my $marcrecord = C4::Search::new_record_from_zebra( $server, $results->[0] ); |
351 |
my $marcrecord = C4::Search::new_record_from_zebra( $server, $results->[0] ); |
| 329 |
SetUTF8Flag($marcrecord); |
352 |
SetUTF8Flag($marcrecord); |
| 330 |
$id = GetRecordId( $marcrecord, $tagid, $subfieldid ); |
353 |
$id = GetRecordId( $marcrecord, $tagid, $subfieldid ); |
|
|
354 |
|
| 355 |
if ($local_filter) { |
| 356 |
my ($fieldsubfieldtag, $value) = split('=', $local_filter); |
| 357 |
die "Unable to get field/subfield and value to discard record (-localfilter=$local_filter)\n" unless ($fieldsubfieldtag && $value); |
| 358 |
my ($fieldtag, $subfieldtag) = split('\$', $fieldsubfieldtag); |
| 359 |
die "Unable to get field and subfield to discard record (-localfilter=$local_filter)\n" unless ($fieldtag && $subfieldtag); |
| 360 |
foreach my $field ($marcrecord->field($fieldtag)) { |
| 361 |
foreach my $subfield ($field->subfield($subfieldtag)) { |
| 362 |
if ($subfield eq $value) { |
| 363 |
$debug and warn "Discarding record (koha record contains $fieldsubfieldtag = $value)\n"; |
| 364 |
next RECORD; |
| 365 |
} |
| 366 |
} |
| 367 |
} |
| 368 |
} |
| 369 |
|
| 331 |
if ( $authorities && $marcFlavour ) { |
370 |
if ( $authorities && $marcFlavour ) { |
| 332 |
#Skip if authority in database is the same as the on in database |
371 |
#Skip if authority in database is the same as the on in database |
| 333 |
if ( $marcrecord->field('005') && $record->field('005') && |
372 |
if ( $marcrecord->field('005') && $record->field('005') && |
|
Lines 832-837
modification template to apply as the MARC records are imported (these
Link Here
|
| 832 |
templates are created in the "MARC modification templates" tool in Koha). |
871 |
templates are created in the "MARC modification templates" tool in Koha). |
| 833 |
If not specified, no MARC modification templates are used (default). |
872 |
If not specified, no MARC modification templates are used (default). |
| 834 |
|
873 |
|
|
|
874 |
=item B<-incomingfilter>='<FIELD>$<SUBFIELD>=<VALUE>' |
| 875 |
|
| 876 |
This parameter allows you to prevent this script from importing a record when a |
| 877 |
given value is present in the record to be imported. |
| 878 |
|
| 879 |
=item B<-localfilter>='<FIELD>$<SUBFIELD>=<VALUE>' |
| 880 |
|
| 881 |
This parameter allows you to prevent this script from importing a record when a |
| 882 |
given value is present in the koha record that would be replaced by the record |
| 883 |
to be imported. |
| 884 |
|
| 885 |
|
| 835 |
=back |
886 |
=back |
| 836 |
|
887 |
|
| 837 |
=cut |
888 |
=cut |
| 838 |
- |
|
|