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

(-)a/Koha/Old/Biblio.pm (+42 lines)
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
(-)a/Koha/Old/Item.pm (-1 / +26 lines)
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::Item;
23
22
=head1 NAME
24
=head1 NAME
23
25
24
Koha::Old::Item - Koha Old::Item Object class
26
Koha::Old::Item - Koha Old::Item Object class
Lines 29-34 Koha::Old::Item - Koha Old::Item Object class Link Here
29
31
30
=cut
32
=cut
31
33
34
=head3 restore
35
36
    my $item = $deleted_item->restore;
37
38
Restores the deleted item record back to the items table. This removes
39
the record from the deleteditems table and re-inserts it into the items table.
40
41
Returns the newly restored Koha::Item object.
42
43
=cut
44
45
sub restore {
46
    my ($self) = @_;
47
48
    my $item_data = $self->unblessed;
49
    delete $item_data->{deleted_on};
50
51
    my $new_item = Koha::Item->new($item_data)->store;
52
53
    $self->delete;
54
55
    return $new_item;
56
}
57
32
=head2 Internal methods
58
=head2 Internal methods
33
59
34
=head3 _type
60
=head3 _type
35
- 

Return to bug 17387