[open-ils-commits] r16361 - in trunk/Open-ILS/src: perlmods/OpenILS/Application/Cat sql/Pg sql/Pg/upgrade (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Apr 30 11:43:13 EDT 2010
Author: erickson
Date: 2010-04-30 11:43:10 -0400 (Fri, 30 Apr 2010)
New Revision: 16361
Added:
trunk/Open-ILS/src/sql/Pg/upgrade/0249.data.id_as_tcn_global_flag.sql
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Application/Cat/BibCommon.pm
trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql
Log:
Added global_flag and support for using the internal record
identifier as the tcn_value for newly imported records
TODO: add support to vandelay stored import procedures
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Cat/BibCommon.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Cat/BibCommon.pm 2010-04-30 14:52:04 UTC (rev 16360)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Cat/BibCommon.pm 2010-04-30 15:43:10 UTC (rev 16361)
@@ -78,7 +78,10 @@
my( $evt, $tcn, $tcn_source, $marcdoc );
- if( $auto_tcn ) {
+ my $use_id = $e->retrieve_config_global_flag('cat.bib.use_id_for_tcn');
+ $use_id = ($use_id and $U->is_true($use_id->enabled));
+
+ if( $auto_tcn or $use_id ) {
# auto_tcn forces a blank TCN value so the DB will have to generate one for us
$marcdoc = __make_marc_doc($xml);
} else {
@@ -101,8 +104,27 @@
$record->marc($U->entityize($marcdoc->documentElement->toString));
$record = $e->create_biblio_record_entry($record) or return $e->die_event;
+
+ if($use_id) {
+ my $existing = $e->search_biblio_record_entry(
+ {
+ tcn_value => $record->id,
+ deleted => 'f'
+ }, {
+ idlist => 1
+ }
+ );
+
+ if(@$existing) {
+ # leave the auto-generated tcn_value in place
+ $logger->warn("Collision using internal ID as tcn_value for record " . $record->id);
+ } else {
+ $record->tcn_value($record->id);
+ $e->update_biblio_record_entry($record) or return $e->die_event;
+ }
+ }
+
$logger->info("marc create/import created new record ".$record->id);
-
return $record;
}
Modified: trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2010-04-30 14:52:04 UTC (rev 16360)
+++ trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2010-04-30 15:43:10 UTC (rev 16361)
@@ -65,7 +65,7 @@
install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);
-INSERT INTO config.upgrade_log (version) VALUES ('0248'); -- miker
+INSERT INTO config.upgrade_log (version) VALUES ('0249'); -- berick
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
Modified: trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql 2010-04-30 14:52:04 UTC (rev 16360)
+++ trunk/Open-ILS/src/sql/Pg/950.data.seed-values.sql 2010-04-30 15:43:10 UTC (rev 16361)
@@ -4716,3 +4716,16 @@
'bool'
);
+INSERT INTO config.global_flag (name, label) -- defaults to enabled=FALSE
+ VALUES (
+ 'cat.bib.use_id_for_tcn',
+ oils_i18n_gettext(
+ 'cat.bib.use_id_for_tcn',
+ 'Cat: Use Internal ID for TCN Value',
+ 'cgf',
+ 'label'
+ )
+ );
+
+
+
Added: trunk/Open-ILS/src/sql/Pg/upgrade/0249.data.id_as_tcn_global_flag.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0249.data.id_as_tcn_global_flag.sql (rev 0)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0249.data.id_as_tcn_global_flag.sql 2010-04-30 15:43:10 UTC (rev 16361)
@@ -0,0 +1,16 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0249');
+
+INSERT INTO config.global_flag (name, label) -- defaults to enabled=FALSE
+ VALUES (
+ 'cat.bib.use_id_for_tcn',
+ oils_i18n_gettext(
+ 'cat.bib.use_id_for_tcn',
+ 'Cat: Use Internal ID for TCN Value',
+ 'cgf',
+ 'label'
+ )
+ );
+
+COMMIT;
More information about the open-ils-commits
mailing list