1 package Koha::Preservation::Train::Item;
3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
20 use JSON qw( to_json );
25 use base qw(Koha::Object);
28 use Koha::Preservation::Processings;
29 use Koha::Preservation::Train::Item::Attributes;
33 Koha::Preservation::Train::Item - Koha Train::Item Object class
43 Return the processing object for this item
49 my $rs = $self->_result->processing; # FIXME Should we return train's default processing if there is no specific?
50 return Koha::Preservation::Processing->_new_from_dbic($rs);
55 Return the catalogue item object for this train item
61 my $item_rs = $self->_result->item;
62 return Koha::Item->_new_from_dbic($item_rs);
68 Return the train object for this item
74 my $rs = $self->_result->train;
75 return Koha::Preservation::Train->_new_from_dbic($rs);
80 Getter and setter for the attributes
85 my ( $self, $attributes ) = @_;
88 my $schema = $self->_result->result_source->schema;
91 $self->attributes->delete;
93 for my $attribute (@$attributes) {
94 $self->_result->add_to_preservation_processing_attributes_items($attribute);
100 my $attributes_rs = $self->_result->preservation_processing_attributes_items;
101 return Koha::Preservation::Train::Item::Attributes->_new_from_dbic($attributes_rs);
104 =head2 Internal methods
111 return 'PreservationTrainsItem';