|
Lines 19-24
use Modern::Perl;
Link Here
|
| 19 |
|
19 |
|
| 20 |
use base qw(Koha::Object); |
20 |
use base qw(Koha::Object); |
| 21 |
|
21 |
|
|
|
22 |
use Koha::Database; |
| 23 |
use Koha::Biblio; |
| 24 |
use Koha::Biblioitem; |
| 25 |
use Koha::Biblio::Metadata; |
| 22 |
use Koha::Old::Biblio::Metadatas; |
26 |
use Koha::Old::Biblio::Metadatas; |
| 23 |
use Koha::Old::Biblioitems; |
27 |
use Koha::Old::Biblioitems; |
| 24 |
|
28 |
|
|
Lines 130-135
sub to_api_mapping {
Link Here
|
| 130 |
}; |
134 |
}; |
| 131 |
} |
135 |
} |
| 132 |
|
136 |
|
|
|
137 |
=head3 restore |
| 138 |
|
| 139 |
my $biblio = $deleted_biblio->restore; |
| 140 |
|
| 141 |
Restores the deleted biblio record back to the biblio table along with |
| 142 |
its biblioitems and metadata. This removes the record from the deleted tables |
| 143 |
and re-inserts it into the active tables. |
| 144 |
|
| 145 |
Returns the newly restored Koha::Biblio object. |
| 146 |
|
| 147 |
=cut |
| 148 |
|
| 149 |
sub restore { |
| 150 |
my ($self) = @_; |
| 151 |
|
| 152 |
my $biblio_data = $self->unblessed; |
| 153 |
my $biblioitem = $self->biblioitem; |
| 154 |
my $biblioitem_data = $biblioitem->unblessed; |
| 155 |
my $metadata = $self->metadata; |
| 156 |
my $metadata_data = $metadata->unblessed; |
| 157 |
|
| 158 |
my $new_biblio = Koha::Biblio->new($biblio_data)->store; |
| 159 |
|
| 160 |
$biblioitem_data->{biblionumber} = $new_biblio->biblionumber; |
| 161 |
$biblioitem_data->{biblioitemnumber} = $new_biblio->biblionumber; |
| 162 |
Koha::Biblioitem->new($biblioitem_data)->store; |
| 163 |
|
| 164 |
delete $metadata_data->{id}; |
| 165 |
$metadata_data->{biblionumber} = $new_biblio->biblionumber; |
| 166 |
Koha::Biblio::Metadata->new($metadata_data)->store; |
| 167 |
|
| 168 |
$metadata->delete; |
| 169 |
$biblioitem->delete; |
| 170 |
$self->delete; |
| 171 |
|
| 172 |
return $new_biblio; |
| 173 |
} |
| 174 |
|
| 133 |
=head2 Internal methods |
175 |
=head2 Internal methods |
| 134 |
|
176 |
|
| 135 |
=head3 _type |
177 |
=head3 _type |