|
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 |
|