Bugzilla – Attachment 159999 Details for
Bug 33960
Add ability to retrieve deleted bibliographic records
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33960: Add api mapping and biblioitems to Old::Biblios to match Biblio
Bug-33960-Add-api-mapping-and-biblioitems-to-OldBi.patch (text/plain), 4.56 KB, created by
Nick Clemens (kidclamp)
on 2023-12-19 13:48:18 UTC
(
hide
)
Description:
Bug 33960: Add api mapping and biblioitems to Old::Biblios to match Biblio
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2023-12-19 13:48:18 UTC
Size:
4.56 KB
patch
obsolete
>From cc15da34586e50b1862fabf7dd3324c311084ee8 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Thu, 7 Sep 2023 16:27:07 +0000 >Subject: [PATCH] Bug 33960: Add api mapping and biblioitems to Old::Biblios to > match Biblio > >Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/Old/Biblio.pm | 61 ++++++++++++++++++++++++++++++++++++++++++--- > Koha/Old/Biblios.pm | 28 +++++++++++++++++++++ > 2 files changed, 86 insertions(+), 3 deletions(-) > >diff --git a/Koha/Old/Biblio.pm b/Koha/Old/Biblio.pm >index 5c0e416619c..204f1456479 100644 >--- a/Koha/Old/Biblio.pm >+++ b/Koha/Old/Biblio.pm >@@ -20,6 +20,7 @@ use Modern::Perl; > use base qw(Koha::Object); > > use Koha::Old::Biblio::Metadatas; >+use Koha::Old::Biblioitems; > > =head1 NAME > >@@ -40,7 +41,7 @@ Returns a Koha::Biblio::Metadata object > =cut > > sub metadata { >- my ( $self ) = @_; >+ my ($self) = @_; > > my $metadata = $self->_result->metadata; > return Koha::Old::Biblio::Metadata->_new_from_dbic($metadata); >@@ -55,7 +56,7 @@ Returns a Marc::Record object > =cut > > sub record { >- my ( $self ) = @_; >+ my ($self) = @_; > > return $self->metadata->record; > } >@@ -69,11 +70,65 @@ Returns the record schema (MARC21, USMARC or UNIMARC). > =cut > > sub record_schema { >- my ( $self ) = @_; >+ my ($self) = @_; > > return $self->metadata->schema // C4::Context->preference("marcflavour"); > } > >+=head3 biblioitem >+ >+my $field = $self->biblioitem >+ >+Returns the related Koha::Old::Biblioitem object for this Biblio object >+ >+=cut >+ >+sub biblioitem { >+ my ($self) = @_; >+ return Koha::Old::Biblioitems->find( { biblionumber => $self->biblionumber } ); >+} >+ >+=head3 to_api >+ >+ my $json = $deleted_biblio->to_api; >+ >+Overloaded method that returns a JSON representation of the Koha::Old::Biblio object, >+suitable for API output. The related Koha::Old::Biblioitem object is merged as expected >+on the API. >+ >+=cut >+ >+sub to_api { >+ my ( $self, $args ) = @_; >+ >+ my $response = $self->SUPER::to_api($args); >+ >+ $args = defined $args ? {%$args} : {}; >+ delete $args->{embed}; >+ >+ my $biblioitem = $self->biblioitem->to_api($args); >+ >+ return { %$response, %$biblioitem }; >+} >+ >+=head3 to_api_mapping >+ >+This method returns the mapping for representing a Koha::Old::Biblio object >+on the API. >+ >+=cut >+ >+sub to_api_mapping { >+ return { >+ biblionumber => 'biblio_id', >+ frameworkcode => 'framework_id', >+ unititle => 'uniform_title', >+ seriestitle => 'series_title', >+ copyrightdate => 'copyright_date', >+ datecreated => 'creation_date', >+ deleted_on => 'timestamp', >+ }; >+} > > =head2 Internal methods > >diff --git a/Koha/Old/Biblios.pm b/Koha/Old/Biblios.pm >index 990d067a180..20341677c8f 100644 >--- a/Koha/Old/Biblios.pm >+++ b/Koha/Old/Biblios.pm >@@ -33,6 +33,34 @@ Koha::Old::Biblios - Koha Old::Biblio Object set class > > =head2 Internal Methods > >+=head3 api_query_fixer >+ >+ $query_string = $biblios->api_query_fixer( $query_string, $context, $no_quotes ); >+ >+Method that takes care of adjusting I<$query_string> as required. An optional I<$context> parameter >+will be used to prefix the relevant query atoms if present. A I<$no_quotes> boolean parameter >+can be passed to choose not to use quotes on matching. This is particularly useful in the context of I<order_by>. >+ >+=cut >+ >+sub api_query_fixer { >+ my ( $self, $query, $context, $no_quotes ) = @_; >+ >+ my $quotes = $no_quotes ? '' : '"'; >+ >+ if ($context) { >+ $query =~ >+ s/${quotes}${context}\.(age_restriction|cn_class|cn_item|cn_sort|cn_source|cn_suffix|collection_issn|collection_title|collection_volume|ean|edition_statement|illustrations|isbn|issn|item_type|lc_control_number|notes|number|pages|publication_place|publication_year|publisher|material_size|serial_total_issues|url|volume|volume_date|volume_description)${quotes}/${quotes}${context}\.deletedbiblioitem\.$1${quotes}/g; >+ } else { >+ $query =~ >+ s/${quotes}(age_restriction|cn_class|cn_item|cn_sort|cn_source|cn_suffix|collection_issn|collection_title|collection_volume|ean|edition_statement|illustrations|isbn|issn|item_type|lc_control_number|notes|number|pages|publication_place|publication_year|publisher|material_size|serial_total_issues|url|volume|volume_date|volume_description)${quotes}/${quotes}deletedbiblioitem\.$1${quotes}/g; >+ $query =~ # handle ambiguous 'biblionumber' >+ s/${quotes}(biblio_id)${quotes}/${quotes}me\.$1${quotes}/g; >+ } >+ >+ return $query; >+} >+ > =head3 _type > > =cut >-- >2.30.2
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 33960
:
152199
|
152200
|
152201
|
152215
|
155331
|
155332
|
155333
|
155334
|
155335
|
155416
|
155417
|
155418
|
155419
|
155420
|
157899
|
157900
|
157901
|
157902
|
157903
|
157904
|
158071
|
159998
|
159999
|
160000
|
160001
|
160002
|
160552
|
163852
|
163853
|
163854
|
163855
|
163948
|
163949
|
163950
|
163951