use Modern::Perl;
+use MARC::Record;
+
use Koha::Database;
+use Koha::Biblios;
use Koha::ERM::EHoldings::Title;
use Koha::ERM::EHoldings::Package;
=cut
+=head3 store
+
+=cut
+
+sub store {
+ my ($self) = @_;
+
+ # FIXME This is terrible and ugly, we need to:
+ # * Provide a mapping for each attribute of title
+ # * Deal with marcflavour
+ # * Create a txn
+ my $title = $self->title;
+ my $biblio = $title->biblio_id ? Koha::Biblios->find($title->biblio_id) : undef;
+ my $marc_record = $biblio ? $biblio->metadata->record : MARC::Record->new;
+ eval {$marc_record->field('245')->delete_subfield('a');};
+ $marc_record->add_fields(MARC::Field->new(245, '', '', a => $title->publication_title));
+
+ my $biblio_id;
+ if ( $biblio ) {
+ $biblio_id = $title->biblio_id;
+ C4::Biblio::ModBiblio($marc_record, $title->biblio_id, '');
+ } else {
+ ( $biblio_id ) = C4::Biblio::AddBiblio($marc_record, '');
+ }
+
+ $title->biblio_id($biblio_id)->store;
+
+ $self = $self->SUPER::store;
+ return $self;
+}
+
=head3 package
Return the package for this resource
sub {
$self->resources->delete;
- for my $resources (@$resources) {
- $self->_result->add_to_erm_eholdings_resources($resources);
+ # Cannot use the dbic RS, we need to trigger ->store overwrite
+ for my $resource (@$resources) {
+ Koha::ERM::EHoldings::Resource->new(
+ { %$resource, title_id => $self->title_id } )->store;
}
}
);
type: integer
description: internally assigned identifier
readOnly: true
+ biblio_id:
+ type:
+ - integer
+ - "null"
+ description: internally assigned identifier for the linked biblio
+ readOnly: true
vendor_id:
description: foreign key to aqbooksellers
type:
$dbh->do(q{
CREATE TABLE `erm_eholdings_titles` (
`title_id` INT(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key',
+ `biblio_id` INT(11) DEFAULT NULL,
`vendor_id` INT(11) DEFAULT NULL,
`publication_title` VARCHAR(255) DEFAULT NULL,
`external_id` VARCHAR(255) DEFAULT NULL,
`preceeding_publication_title_id` VARCHAR(255) DEFAULT NULL,
`access_type` VARCHAR(255) DEFAULT NULL,
CONSTRAINT `erm_eholdings_titles_ibfk_1` FOREIGN KEY (`vendor_id`) REFERENCES `aqbooksellers` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
+ CONSTRAINT `erm_eholdings_titles_ibfk_2` FOREIGN KEY (`biblio_id`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE CASCADE,
PRIMARY KEY(`title_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
});
DROP TABLE IF EXISTS `erm_eholdings_titles`;
CREATE TABLE `erm_eholdings_titles` (
`title_id` INT(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key',
+ `biblio_id` INT(11) DEFAULT NULL,
`vendor_id` INT(11) DEFAULT NULL,
`publication_title` VARCHAR(255) DEFAULT NULL,
`external_id` VARCHAR(255) DEFAULT NULL,
`preceeding_publication_title_id` VARCHAR(255) DEFAULT NULL,
`access_type` VARCHAR(255) DEFAULT NULL,
CONSTRAINT `erm_eholdings_titles_ibfk_1` FOREIGN KEY (`vendor_id`) REFERENCES `aqbooksellers` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
+ CONSTRAINT `erm_eholdings_titles_ibfk_2` FOREIGN KEY (`biblio_id`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE CASCADE,
PRIMARY KEY(`title_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
apiUrl += '/' + title.title_id
}
delete title.title_id
+ delete title.biblio_id
title.resources.forEach(r => {
r.started_on = r.started_on ? $date_to_rfc3339(r.started_on) : null
<fieldset class="rows">
<ol>
<li v-if="title.title_id">
- <label
- >{{ $t("Title identifier") }}:</label
- >
+ <label>{{ $t("Title identifier") }}:</label>
<span>
- {{ title.title_id}}
+ {{ title.title_id }}
</span>
</li>
<li>
<label>{{ $t("Publication title") }}:</label>
<span>
{{ title.publication_title }}
+ <a
+ v-if="title.biblio_id"
+ :href="`/cgi-bin/koha/catalogue/detail.pl?biblionumber=${title.biblio_id}`"
+ >
+ {{ $t("Local bibliographic record") }}
+ </a>
</span>
</li>
<li v-if="title.external_id">
</thead>
<tbody>
<tr
- v-for="(
- r, counter
- ) in title.resources"
+ v-for="(r, counter) in title.resources"
v-bind:key="counter"
>
<td>
},
methods: {
async getTitle(title_id) {
- const title= await fetchTitle(title_id)
+ const title = await fetchTitle(title_id)
this.title = title
this.initialized = true
},