Bugzilla – Attachment 80827 Details for
Bug 20447
Add support for MARC holdings records
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20447: Add a batch rebuild script for holdings table.
Bug-20447-Add-a-batch-rebuild-script-for-holdings-.patch (text/plain), 3.10 KB, created by
Ere Maijala
on 2018-10-18 12:45:24 UTC
(
hide
)
Description:
Bug 20447: Add a batch rebuild script for holdings table.
Filename:
MIME Type:
Creator:
Ere Maijala
Created:
2018-10-18 12:45:24 UTC
Size:
3.10 KB
patch
obsolete
>From a77cffa1cf7d4ee6798379ed6efe59b208d3bd5c Mon Sep 17 00:00:00 2001 >From: Ere Maijala <ere.maijala@helsinki.fi> >Date: Wed, 26 Sep 2018 13:06:04 +0300 >Subject: [PATCH] Bug 20447: Add a batch rebuild script for holdings table. > >This script can be used to update the columns in the holdings table from the MARC record using the rules in the framework. In practice this will only be required if the koha link field is changed in the framework, and that's disabled in the UI so it must be done in the database. >--- > C4/Holdings.pm | 1 + > misc/batchRebuildHoldingsTables.pl | 71 ++++++++++++++++++++++++++++++++++++++ > 2 files changed, 72 insertions(+) > create mode 100755 misc/batchRebuildHoldingsTables.pl > >diff --git a/C4/Holdings.pm b/C4/Holdings.pm >index 5fbcc0b..dce6c13 100644 >--- a/C4/Holdings.pm >+++ b/C4/Holdings.pm >@@ -32,6 +32,7 @@ use MARC::File::USMARC; > use MARC::File::XML; > use POSIX qw(strftime); > >+use C4::Biblio; > use C4::Koha; > use C4::Log; # logaction > use C4::ClassSource; >diff --git a/misc/batchRebuildHoldingsTables.pl b/misc/batchRebuildHoldingsTables.pl >new file mode 100755 >index 0000000..4c25118 >--- /dev/null >+++ b/misc/batchRebuildHoldingsTables.pl >@@ -0,0 +1,71 @@ >+#!/usr/bin/perl >+# Small script that rebuilds the non-MARC Holdings DB >+ >+use strict; >+use warnings; >+ >+BEGIN { >+ # find Koha's Perl modules >+ # test carefully before changing this >+ use FindBin; >+ eval { require "$FindBin::Bin/kohalib.pl" }; >+} >+ >+# Koha modules used >+use MARC::Record; >+use C4::Context; >+use C4::Holdings; >+ >+use Getopt::Long; >+ >+my ($input_marc_file, $number) = ('', 0); >+my ($help, $confirm, $test_parameter); >+GetOptions( >+ 'c' => \$confirm, >+ 'h' => \$help, >+ 't' => \$test_parameter, >+); >+ >+if ($help || !$confirm) { >+ print <<EOF >+This script rebuilds the non-MARC Holdings DB from the MARC values. >+You can/must use it when you change the mappings. >+ >+Example: you decide to map holdings.callnumber to 852\$k\$l\$m (it was previously mapped to 852\$k). >+ >+Syntax: >+\t./batchRebuildHoldingsTables.pl -h (or without arguments => shows this screen) >+\t./batchRebuildHoldingsTables.pl -c (c like confirm => rebuild non-MARC DB (may takes long) >+\t-t => test only, change nothing in DB >+EOF >+; >+ exit; >+} >+ >+my $dbh = C4::Context->dbh; >+my $i = 0; >+my $starttime = time(); >+ >+$| = 1; # flushes output >+$starttime = time(); >+ >+my $sth = $dbh->prepare("SELECT holding_id FROM holdings"); >+$sth->execute(); >+my @errors; >+while (my ($holding_id) = $sth->fetchrow()) { >+ my $record = C4::Holdings::GetMarcHolding($holding_id); >+ if (not defined $record) { >+ push @errors, $holding_id; >+ next; >+ } >+ my $rowData = C4::Holdings::TransformMarcHoldingToKoha($record); >+ my $frameworkcode = C4::Holdings::GetHoldingFrameworkCode($holding_id); >+ C4::Holdings::_koha_modify_holding($dbh, $holding_id, $rowData, $frameworkcode) unless $test_parameter; >+ ++$i; >+} >+$sth->finish(); >+my $timeneeded = time() - $starttime; >+print "$i MARC records done in $timeneeded seconds\n"; >+if (scalar(@errors) > 0) { >+ print 'Records that could not be processed: ', join(' ', @errors); >+} >-- >2.7.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 20447
:
73703
|
73704
|
76485
|
76542
|
76670
|
76671
|
76672
|
76735
|
76736
|
78178
|
78179
|
78180
|
78738
|
78739
|
78740
|
78907
|
79403
|
79413
|
79565
|
79566
|
79567
|
79568
|
79569
|
79570
|
79812
|
79813
|
79814
|
79815
|
79816
|
79819
|
80320
|
80321
|
80322
|
80323
|
80324
|
80823
|
80824
|
80825
|
80826
|
80827
|
81264
|
81265
|
81266
|
81267
|
81268
|
82669
|
82670
|
82671
|
82672
|
82673
|
83550
|
83551
|
83552
|
83553
|
83554
|
83555
|
83556
|
83557
|
83558
|
83559
|
85364
|
85368
|
85369
|
85370
|
85371
|
85416
|
85417
|
85418
|
85419
|
85906
|
85907
|
85908
|
85909
|
85994
|
85995
|
85996
|
85997
|
86088
|
86089
|
86090
|
86091
|
87307
|
87308
|
87309
|
87310
|
87346
|
87347
|
87348
|
87349
|
88751
|
88752
|
88753
|
88754
|
88755
|
91743
|
91744
|
91745
|
91746
|
91747
|
94539
|
94540
|
94541
|
94542
|
97796
|
97797
|
97798
|
97799
|
97800
|
97843
|
97844
|
97845
|
97846
|
99143
|
99144
|
99145
|
99146
|
99176
|
99177
|
99178
|
99179
|
99235
|
99236
|
99237
|
99238
|
99239
|
105068
|
105069
|
105070
|
105071
|
105072
|
105259
|
105260
|
105261
|
105262
|
105263
|
106147
|
106148
|
106149
|
106150
|
106151
|
108250
|
108251
|
108252
|
108253
|
108254
|
108255
|
108336
|
108337
|
108338
|
108339
|
108340
|
108341
|
108789
|
108790
|
108791
|
108792
|
108793
|
108794
|
109695
|
109696
|
109697
|
109698
|
109699
|
109700
|
109703
|
109704
|
109705
|
109706
|
109707
|
109708
|
109711
|
109712
|
109713
|
109714
|
109715
|
109717
|
109718
|
109719
|
109720
|
109721
|
109722
|
109741
|
109742
|
109743
|
109744
|
109745
|
109746
|
109765
|
109766
|
109767
|
109768
|
109769
|
109770
|
109873
|
109874
|
109875
|
109877
|
109878
|
109879
|
110115
|
110174
|
110313
|
110314
|
110315
|
110316
|
110317
|
110318
|
110319
|
110320
|
110467
|
110468
|
110469
|
110471
|
110472
|
110473
|
110474
|
110475
|
112176
|
112177
|
112179
|
112180
|
112181
|
112182
|
112189
|
112190
|
112191
|
112192
|
112193
|
112194
|
112570
|
112571
|
112572
|
112573
|
112574
|
112575
|
113943
|
113944
|
113945
|
113946
|
113947
|
113948
|
113952
|
113953
|
113954
|
113955
|
113956
|
113957
|
113958
|
113959
|
115239
|
115240
|
115241
|
115242
|
115243
|
115244
|
115245
|
115654
|
115655
|
115656
|
115657
|
115658
|
115659
|
115660
|
115722
|
115723
|
115724
|
115725
|
115726
|
115727
|
115728
|
115729
|
116797
|
116798
|
116799
|
116800
|
116801
|
116802
|
116803
|
116804
|
116805
|
116806
|
116807
|
116808
|
116809
|
116810
|
116811
|
116812
|
118382
|
118383
|
118385
|
118386
|
118387
|
118388
|
118389
|
118390
|
118397
|
118398
|
118399
|
118400
|
118401
|
118402
|
118403
|
118404
|
118405
|
118406
|
118407
|
118408
|
118409
|
118410
|
118411
|
118412
|
118429
|
118430
|
118431
|
118432
|
118433
|
118434
|
118435
|
118436
|
118527
|
118528
|
118529
|
118530
|
118531
|
118532
|
118533
|
118534
|
118535
|
118536
|
119265
|
119266
|
119267
|
119268
|
119269
|
119270
|
119271
|
119272
|
119273
|
119274
|
119514
|
119515
|
119516
|
119517
|
119518
|
119519
|
119520
|
119521
|
119522
|
119523
|
119570
|
119571
|
121216
|
121217
|
121220
|
121221
|
121222
|
121223
|
121226
|
121227
|
121228
|
121229
|
121230
|
121231
|
121379
|
121380
|
121381
|
121382
|
121383
|
121406
|
121407
|
121408
|
121409
|
121410
|
122501
|
122502
|
122503
|
122504
|
122505
|
122851
|
122852
|
122853
|
122854
|
122855
|
122856
|
122891
|
122892
|
122893
|
122894
|
122895
|
122896
|
122897
|
123047
|
123048
|
123049
|
123050
|
123051
|
123052
|
123053
|
123054
|
123055
|
123056
|
123057
|
123058
|
123059
|
123060
|
123061
|
124012
|
124013
|
124014
|
124015
|
124016
|
124017
|
124018
|
124944
|
124945
|
124946
|
124947
|
124948
|
124949
|
124950
|
126204
|
126205
|
126206
|
126207
|
126208
|
126209
|
126210
|
126211
|
126212
|
126296
|
126391
|
126392
|
126394
|
126395
|
126396
|
126397
|
126398
|
126399
|
126400
|
126401
|
126402
|
126403
|
126404
|
126405
|
126932
|
126933
|
126934
|
126935
|
126936
|
126937
|
126938
|
126939
|
126940
|
126941
|
126942
|
126943
|
127040
|
128079
|
128131
|
128134
|
130776
|
130777
|
130778
|
130779
|
130780
|
130781
|
130782
|
130783
|
130784
|
130785
|
130786
|
130787
|
130788
|
130789
|
130790
|
130791
|
130792
|
130793
|
130794
|
130795
|
130796
|
130797
|
130798
|
130799
|
130800
|
130801
|
130802
|
130803
|
130804
|
130805
|
130806
|
130807
|
131458
|
131459
|
131460
|
131461
|
131462
|
131463
|
131464
|
131465
|
131466
|
131467
|
131468
|
131469
|
131470
|
131471
|
131472
|
131473
|
131474
|
131475
|
131476
|
131477
|
131478
|
131479
|
131480
|
131481
|
131482
|
139865
|
139866
|
139867
|
139868
|
139869
|
139870
|
139871
|
139872
|
139873
|
139874
|
139875
|
139876
|
139877
|
139878
|
139879
|
139880
|
139881
|
139882
|
139883
|
139884
|
139885
|
139886
|
139887
|
139888
|
139889
|
139890
|
139891
|
139892
|
139893
|
139894
|
139895
|
139896
|
157492
|
157493