|
Lines 38-67
Koha::ERM::EHoldings::Title - Koha ERM Title Object class
Link Here
|
| 38 |
=cut |
38 |
=cut |
| 39 |
|
39 |
|
| 40 |
sub store { |
40 |
sub store { |
| 41 |
my ($self) = @_; |
41 |
my ( $self, $args ) = @_; |
|
|
42 |
|
| 43 |
my $create_linked_biblio = $args->{create_linked_biblio} || 0; |
| 42 |
|
44 |
|
| 43 |
# FIXME This is terrible and ugly, we need to: |
45 |
# FIXME This is terrible and ugly, we need to: |
| 44 |
# * Provide a mapping for each attribute of title |
46 |
# * Provide a mapping for each attribute of title |
| 45 |
# * Create a txn |
47 |
# * Create a txn |
| 46 |
|
48 |
|
| 47 |
# If the 'title' is already linked to a biblio, then we update the title subfield only |
49 |
if ($create_linked_biblio) { |
| 48 |
if ( $self->biblio_id ) { |
50 |
|
| 49 |
my $biblio = Koha::Biblios->find( $self->biblio_id ); |
51 |
# If the 'title' is already linked to a biblio, then we update the title subfield only |
| 50 |
my ( $title_tag, $title_subfield ) = GetMarcFromKohaField('biblio.title'); |
52 |
if ( $self->biblio_id ) { |
| 51 |
my $record = $biblio->metadata->record(); |
53 |
my $biblio = Koha::Biblios->find( $self->biblio_id ); |
| 52 |
my $title_field = $record->field($title_tag); |
54 |
my ( $title_tag, $title_subfield ) = GetMarcFromKohaField('biblio.title'); |
| 53 |
$title_field->update( $title_subfield => $self->publication_title ); |
55 |
my $record = $biblio->metadata->record(); |
| 54 |
C4::Biblio::ModBiblio( $record, $self->biblio_id, '' ); |
56 |
my $title_field = $record->field($title_tag); |
| 55 |
} else { |
57 |
$title_field->update( $title_subfield => $self->publication_title ); |
| 56 |
|
58 |
C4::Biblio::ModBiblio( $record, $self->biblio_id, '' ); |
| 57 |
# If it's not linked, we create a simple biblio and save the biblio id to the 'title' |
59 |
} else { |
| 58 |
my $marc_record = TransformKohaToMarc( |
60 |
|
| 59 |
{ |
61 |
# If it's not linked, we create a simple biblio and save the biblio id to the 'title' |
| 60 |
'biblio.title' => $self->publication_title, |
62 |
my $marc_record = TransformKohaToMarc( |
| 61 |
} |
63 |
{ |
| 62 |
); |
64 |
'biblio.title' => $self->publication_title, |
| 63 |
my ($biblio_id) = C4::Biblio::AddBiblio( $marc_record, '' ); |
65 |
} |
| 64 |
$self->biblio_id($biblio_id); |
66 |
); |
|
|
67 |
my ($biblio_id) = C4::Biblio::AddBiblio( $marc_record, '' ); |
| 68 |
$self->biblio_id($biblio_id); |
| 69 |
} |
| 65 |
} |
70 |
} |
| 66 |
|
71 |
|
| 67 |
$self = $self->SUPER::store; |
72 |
$self = $self->SUPER::store; |