Lines 41-46
use C4::Debug;
Link Here
|
41 |
use Koha::Caches; |
41 |
use Koha::Caches; |
42 |
use Koha::Authority::Types; |
42 |
use Koha::Authority::Types; |
43 |
use Koha::Acquisition::Currencies; |
43 |
use Koha::Acquisition::Currencies; |
|
|
44 |
use Koha::Biblio::Metadata; |
45 |
use Koha::Biblio::Metadatas; |
44 |
use Koha::SearchEngine; |
46 |
use Koha::SearchEngine; |
45 |
use Koha::Libraries; |
47 |
use Koha::Libraries; |
46 |
|
48 |
|
Lines 159-165
Biblio.pm contains functions for managing storage and editing of bibliographic d
Link Here
|
159 |
|
161 |
|
160 |
=item 2. as raw MARC in the Zebra index and storage engine |
162 |
=item 2. as raw MARC in the Zebra index and storage engine |
161 |
|
163 |
|
162 |
=item 3. as MARC XML in biblioitems.marcxml |
164 |
=item 3. as MARC XML in biblio_metadata.metadata |
163 |
|
165 |
|
164 |
=back |
166 |
=back |
165 |
|
167 |
|
Lines 183-189
Because of this design choice, the process of managing storage and editing is a
Link Here
|
183 |
|
185 |
|
184 |
=item 2. _koha_* - low-level internal functions for managing the koha tables |
186 |
=item 2. _koha_* - low-level internal functions for managing the koha tables |
185 |
|
187 |
|
186 |
=item 3. Marc management function : as the MARC record is stored in biblioitems.marcxml, some subs dedicated to it's management are in this package. They should be used only internally by Biblio.pm, the only official entry points being AddBiblio, AddItem, ModBiblio, ModItem. |
188 |
=item 3. Marc management function : as the MARC record is stored in biblio_metadata.metadata, some subs dedicated to it's management are in this package. They should be used only internally by Biblio.pm, the only official entry points being AddBiblio, AddItem, ModBiblio, ModItem. |
187 |
|
189 |
|
188 |
=item 4. Zebra functions used to update the Zebra index |
190 |
=item 4. Zebra functions used to update the Zebra index |
189 |
|
191 |
|
Lines 191-197
Because of this design choice, the process of managing storage and editing is a
Link Here
|
191 |
|
193 |
|
192 |
=back |
194 |
=back |
193 |
|
195 |
|
194 |
The MARC record (in biblioitems.marcxml) contains the complete marc record, including items. It also contains the biblionumber. That is the reason why it is not stored directly by AddBiblio, with all other fields . To save a biblio, we need to : |
196 |
The MARC record (in biblio_metadata.metadata) contains the complete marc record, including items. It also contains the biblionumber. That is the reason why it is not stored directly by AddBiblio, with all other fields . To save a biblio, we need to : |
195 |
|
197 |
|
196 |
=over 4 |
198 |
=over 4 |
197 |
|
199 |
|
Lines 203-222
The MARC record (in biblioitems.marcxml) contains the complete marc record, incl
Link Here
|
203 |
|
205 |
|
204 |
=back |
206 |
=back |
205 |
|
207 |
|
206 |
When dealing with items, we must : |
|
|
207 |
|
208 |
=over 4 |
209 |
|
210 |
=item 1. save the item in items table, that gives us an itemnumber |
211 |
|
212 |
=item 2. add the itemnumber to the item MARC field |
213 |
|
214 |
=item 3. overwrite the MARC record (with the added item) into biblioitems.marcxml |
215 |
|
216 |
When modifying a biblio or an item, the behaviour is quite similar. |
217 |
|
218 |
=back |
219 |
|
220 |
=head1 EXPORTED FUNCTIONS |
208 |
=head1 EXPORTED FUNCTIONS |
221 |
|
209 |
|
222 |
=head2 AddBiblio |
210 |
=head2 AddBiblio |
Lines 232-238
framework code.
Link Here
|
232 |
This function also accepts a third, optional argument: a hashref |
220 |
This function also accepts a third, optional argument: a hashref |
233 |
to additional options. The only defined option is C<defer_marc_save>, |
221 |
to additional options. The only defined option is C<defer_marc_save>, |
234 |
which if present and mapped to a true value, causes C<AddBiblio> |
222 |
which if present and mapped to a true value, causes C<AddBiblio> |
235 |
to omit the call to save the MARC in C<bibilioitems.marcxml> |
223 |
to omit the call to save the MARC in C<biblio_metadata.metadata> |
236 |
This option is provided B<only> |
224 |
This option is provided B<only> |
237 |
for the use of scripts such as C<bulkmarcimport.pl> that may need |
225 |
for the use of scripts such as C<bulkmarcimport.pl> that may need |
238 |
to do some manipulation of the MARC record for item parsing before |
226 |
to do some manipulation of the MARC record for item parsing before |
Lines 1336-1346
sub GetMarcBiblio {
Link Here
|
1336 |
} |
1324 |
} |
1337 |
|
1325 |
|
1338 |
my $dbh = C4::Context->dbh; |
1326 |
my $dbh = C4::Context->dbh; |
1339 |
my $sth = $dbh->prepare("SELECT biblioitemnumber, marcxml FROM biblioitems WHERE biblionumber=? "); |
1327 |
my $sth = $dbh->prepare("SELECT biblioitemnumber FROM biblioitems WHERE biblionumber=? "); |
1340 |
$sth->execute($biblionumber); |
1328 |
$sth->execute($biblionumber); |
1341 |
my $row = $sth->fetchrow_hashref; |
1329 |
my $row = $sth->fetchrow_hashref; |
1342 |
my $biblioitemnumber = $row->{'biblioitemnumber'}; |
1330 |
my $biblioitemnumber = $row->{'biblioitemnumber'}; |
1343 |
my $marcxml = StripNonXmlChars( $row->{'marcxml'} ); |
1331 |
my $marcxml = GetXmlBiblio( $biblionumber ); |
|
|
1332 |
$marcxml = StripNonXmlChars( $marcxml ); |
1344 |
my $frameworkcode = GetFrameworkCode($biblionumber); |
1333 |
my $frameworkcode = GetFrameworkCode($biblionumber); |
1345 |
MARC::File::XML->default_record_format( C4::Context->preference('marcflavour') ); |
1334 |
MARC::File::XML->default_record_format( C4::Context->preference('marcflavour') ); |
1346 |
my $record = MARC::Record->new(); |
1335 |
my $record = MARC::Record->new(); |
Lines 1369-1385
sub GetMarcBiblio {
Link Here
|
1369 |
|
1358 |
|
1370 |
my $marcxml = GetXmlBiblio($biblionumber); |
1359 |
my $marcxml = GetXmlBiblio($biblionumber); |
1371 |
|
1360 |
|
1372 |
Returns biblioitems.marcxml of the biblionumber passed in parameter. |
1361 |
Returns biblio_metadata.metadata/marcxml of the biblionumber passed in parameter. |
1373 |
The XML should only contain biblio information (item information is no longer stored in marcxml field) |
1362 |
The XML should only contain biblio information (item information is no longer stored in marcxml field) |
1374 |
|
1363 |
|
1375 |
=cut |
1364 |
=cut |
1376 |
|
1365 |
|
1377 |
sub GetXmlBiblio { |
1366 |
sub GetXmlBiblio { |
1378 |
my ($biblionumber) = @_; |
1367 |
my ($biblionumber) = @_; |
1379 |
my $dbh = C4::Context->dbh; |
1368 |
my $dbh = C4::Context->dbh; |
1380 |
my $sth = $dbh->prepare("SELECT marcxml FROM biblioitems WHERE biblionumber=? "); |
1369 |
return unless $biblionumber; |
1381 |
$sth->execute($biblionumber); |
1370 |
my ($marcxml) = $dbh->selectrow_array( |
1382 |
my ($marcxml) = $sth->fetchrow; |
1371 |
q| |
|
|
1372 |
SELECT metadata |
1373 |
FROM biblio_metadata |
1374 |
WHERE biblionumber=? |
1375 |
AND format='marcxml' |
1376 |
AND marcflavour=? |
1377 |
|, undef, $biblionumber, C4::Context->preference('marcflavour') |
1378 |
); |
1383 |
return $marcxml; |
1379 |
return $marcxml; |
1384 |
} |
1380 |
} |
1385 |
|
1381 |
|
Lines 3234-3242
sub _koha_modify_biblio {
Link Here
|
3234 |
|
3230 |
|
3235 |
my ($biblioitemnumber,$error) = _koha_modify_biblioitem_nonmarc( $dbh, $biblioitem ); |
3231 |
my ($biblioitemnumber,$error) = _koha_modify_biblioitem_nonmarc( $dbh, $biblioitem ); |
3236 |
|
3232 |
|
3237 |
Updates biblioitems row except for marc and marcxml, which should be changed |
|
|
3238 |
via ModBiblioMarc |
3239 |
|
3240 |
=cut |
3233 |
=cut |
3241 |
|
3234 |
|
3242 |
sub _koha_modify_biblioitem_nonmarc { |
3235 |
sub _koha_modify_biblioitem_nonmarc { |
Lines 3523-3531
sub ModBiblioMarc {
Link Here
|
3523 |
$f005->update(sprintf("%4d%02d%02d%02d%02d%04.1f",@a)) if $f005; |
3516 |
$f005->update(sprintf("%4d%02d%02d%02d%02d%04.1f",@a)) if $f005; |
3524 |
} |
3517 |
} |
3525 |
|
3518 |
|
3526 |
$sth = $dbh->prepare("UPDATE biblioitems SET marcxml=? WHERE biblionumber=?"); |
3519 |
my $metadata = { |
3527 |
$sth->execute( $record->as_xml_record($encoding), $biblionumber ); |
3520 |
biblionumber => $biblionumber, |
3528 |
$sth->finish; |
3521 |
format => 'marcxml', |
|
|
3522 |
marcflavour => C4::Context->preference('marcflavour'), |
3523 |
}; |
3524 |
# FIXME To replace with ->find_or_create? |
3525 |
if ( my $m_rs = Koha::Biblio::Metadatas->find($metadata) ) { |
3526 |
$m_rs->metadata( $record->as_xml_record($encoding) ); |
3527 |
} else { |
3528 |
my $m_rs = Koha::Biblio::Metadata->new($metadata); |
3529 |
$m_rs->metadata( $record->as_xml_record($encoding) ); |
3530 |
$m_rs->store; |
3531 |
} |
3529 |
ModZebra( $biblionumber, "specialUpdate", "biblioserver", $record ); |
3532 |
ModZebra( $biblionumber, "specialUpdate", "biblioserver", $record ); |
3530 |
return $biblionumber; |
3533 |
return $biblionumber; |
3531 |
} |
3534 |
} |