View | Details | Raw Unified | Return to bug 33960
Collapse All | Expand All

(-)a/Koha/Old/Biblio.pm (-3 / +58 lines)
Lines 20-25 use Modern::Perl; Link Here
20
use base qw(Koha::Object);
20
use base qw(Koha::Object);
21
21
22
use Koha::Old::Biblio::Metadatas;
22
use Koha::Old::Biblio::Metadatas;
23
use Koha::Old::Biblioitems;
23
24
24
=head1 NAME
25
=head1 NAME
25
26
Lines 40-46 Returns a Koha::Biblio::Metadata object Link Here
40
=cut
41
=cut
41
42
42
sub metadata {
43
sub metadata {
43
    my ( $self ) = @_;
44
    my ($self) = @_;
44
45
45
    my $metadata = $self->_result->metadata;
46
    my $metadata = $self->_result->metadata;
46
    return Koha::Old::Biblio::Metadata->_new_from_dbic($metadata);
47
    return Koha::Old::Biblio::Metadata->_new_from_dbic($metadata);
Lines 55-61 Returns a Marc::Record object Link Here
55
=cut
56
=cut
56
57
57
sub record {
58
sub record {
58
    my ( $self ) = @_;
59
    my ($self) = @_;
59
60
60
    return $self->metadata->record;
61
    return $self->metadata->record;
61
}
62
}
Lines 69-79 Returns the record schema (MARC21, USMARC or UNIMARC). Link Here
69
=cut
70
=cut
70
71
71
sub record_schema {
72
sub record_schema {
72
    my ( $self ) = @_;
73
    my ($self) = @_;
73
74
74
    return $self->metadata->schema // C4::Context->preference("marcflavour");
75
    return $self->metadata->schema // C4::Context->preference("marcflavour");
75
}
76
}
76
77
78
=head3 biblioitem
79
80
my $field = $self->biblioitem
81
82
Returns the related Koha::Old::Biblioitem object for this Biblio object
83
84
=cut
85
86
sub biblioitem {
87
    my ($self) = @_;
88
    return Koha::Old::Biblioitems->find( { biblionumber => $self->biblionumber } );
89
}
90
91
=head3 to_api
92
93
    my $json = $deleted_biblio->to_api;
94
95
Overloaded method that returns a JSON representation of the Koha::Old::Biblio object,
96
suitable for API output. The related Koha::Old::Biblioitem object is merged as expected
97
on the API.
98
99
=cut
100
101
sub to_api {
102
    my ( $self, $args ) = @_;
103
104
    my $response = $self->SUPER::to_api($args);
105
106
    $args = defined $args ? {%$args} : {};
107
    delete $args->{embed};
108
109
    my $biblioitem = $self->biblioitem->to_api($args);
110
111
    return { %$response, %$biblioitem };
112
}
113
114
=head3 to_api_mapping
115
116
This method returns the mapping for representing a Koha::Old::Biblio object
117
on the API.
118
119
=cut
120
121
sub to_api_mapping {
122
    return {
123
        biblionumber  => 'biblio_id',
124
        frameworkcode => 'framework_id',
125
        unititle      => 'uniform_title',
126
        seriestitle   => 'series_title',
127
        copyrightdate => 'copyright_date',
128
        datecreated   => 'creation_date',
129
        deleted_on    => 'timestamp',
130
    };
131
}
77
132
78
=head2 Internal methods
133
=head2 Internal methods
79
134
(-)a/Koha/Old/Biblios.pm (-1 / +28 lines)
Lines 33-38 Koha::Old::Biblios - Koha Old::Biblio Object set class Link Here
33
33
34
=head2 Internal Methods
34
=head2 Internal Methods
35
35
36
=head3 api_query_fixer
37
38
    $query_string = $biblios->api_query_fixer( $query_string, $context, $no_quotes );
39
40
Method that takes care of adjusting I<$query_string> as required. An optional I<$context> parameter
41
will be used to prefix the relevant query atoms if present. A I<$no_quotes> boolean parameter
42
can be passed to choose not to use quotes on matching. This is particularly useful in the context of I<order_by>.
43
44
=cut
45
46
sub api_query_fixer {
47
    my ( $self, $query, $context, $no_quotes ) = @_;
48
49
    my $quotes = $no_quotes ? '' : '"';
50
51
    if ($context) {
52
        $query =~
53
            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;
54
    } else {
55
        $query =~
56
            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;
57
        $query =~ # handle ambiguous 'biblionumber'
58
            s/${quotes}(biblio_id)${quotes}/${quotes}me\.$1${quotes}/g;
59
    }
60
61
    return $query;
62
}
63
36
=head3 _type
64
=head3 _type
37
65
38
=cut
66
=cut
39
- 

Return to bug 33960