Lines 44-65
sub store {
Link Here
|
44 |
# * Provide a mapping for each attribute of title |
44 |
# * Provide a mapping for each attribute of title |
45 |
# * Create a txn |
45 |
# * Create a txn |
46 |
|
46 |
|
47 |
# If the 'title' is alreay linked to a biblio, then we update the title subfield only |
47 |
# If the 'title' is already linked to a biblio, then we update the title subfield only |
48 |
if ( $self->biblio_id ){ |
48 |
if ( $self->biblio_id ) { |
49 |
my $biblio = Koha::Biblios->find( $self->biblio_id ); |
49 |
my $biblio = Koha::Biblios->find( $self->biblio_id ); |
50 |
my ($title_tag, $title_subfield) = GetMarcFromKohaField( 'biblio.title' ); |
50 |
my ( $title_tag, $title_subfield ) = GetMarcFromKohaField('biblio.title'); |
51 |
my $record = $biblio->metadata->record(); |
51 |
my $record = $biblio->metadata->record(); |
52 |
my $title_field = $record->field($title_tag); |
52 |
my $title_field = $record->field($title_tag); |
53 |
$title_field->update( $title_subfield => $self->publication_title ); |
53 |
$title_field->update( $title_subfield => $self->publication_title ); |
54 |
C4::Biblio::ModBiblio( $record, $self->biblio_id, '' ); |
54 |
C4::Biblio::ModBiblio( $record, $self->biblio_id, '' ); |
55 |
} else { |
55 |
} else { |
56 |
# If it's not linked, we create a simple biblio and save the biblio id to the 'title' |
56 |
|
|
|
57 |
# If it's not linked, we create a simple biblio and save the biblio id to the 'title' |
57 |
my $marc_record = TransformKohaToMarc( |
58 |
my $marc_record = TransformKohaToMarc( |
58 |
{ |
59 |
{ |
59 |
'biblio.title' => $self->publication_title, |
60 |
'biblio.title' => $self->publication_title, |
60 |
} |
61 |
} |
61 |
); |
62 |
); |
62 |
my ( $biblio_id ) = C4::Biblio::AddBiblio($marc_record, ''); |
63 |
my ($biblio_id) = C4::Biblio::AddBiblio( $marc_record, '' ); |
63 |
$self->biblio_id($biblio_id); |
64 |
$self->biblio_id($biblio_id); |
64 |
} |
65 |
} |
65 |
|
66 |
|
Lines 77-83
Returns the resources linked to this title
Link Here
|
77 |
sub resources { |
78 |
sub resources { |
78 |
my ( $self, $resources ) = @_; |
79 |
my ( $self, $resources ) = @_; |
79 |
|
80 |
|
80 |
if ( $resources ) { |
81 |
if ($resources) { |
81 |
my $schema = $self->_result->result_source->schema; |
82 |
my $schema = $self->_result->result_source->schema; |
82 |
$schema->txn_do( |
83 |
$schema->txn_do( |
83 |
sub { |
84 |
sub { |
Lines 85-92
sub resources {
Link Here
|
85 |
|
86 |
|
86 |
# Cannot use the dbic RS, we need to trigger ->store overwrite |
87 |
# Cannot use the dbic RS, we need to trigger ->store overwrite |
87 |
for my $resource (@$resources) { |
88 |
for my $resource (@$resources) { |
88 |
Koha::ERM::EHoldings::Resource->new( |
89 |
Koha::ERM::EHoldings::Resource->new( { %$resource, title_id => $self->title_id } )->store; |
89 |
{ %$resource, title_id => $self->title_id } )->store; |
|
|
90 |
} |
90 |
} |
91 |
} |
91 |
} |
92 |
); |
92 |
); |