metabib::metarecord->table( 'metabib.metarecord' );
metabib::metarecord->sequence( 'metabib.metarecord_id_seq' );
- OpenILS::Application::Storage->register_method(
- api_name => 'open-ils.storage.direct.metabib.metarecord.batch.create',
- method => 'copy_create',
- api_level => 1,
- 'package' => 'OpenILS::Application::Storage',
- cdbi => 'metabib::metarecord',
- );
-
#-------------------------------------------------------------------------------
# before_update => \&OpenILS::Application::Storage::Driver::Pg::tsearch2_trigger
# );
- OpenILS::Application::Storage->register_method(
- api_name => 'open-ils.storage.direct.metabib.title_field_entry.batch.create',
- method => 'copy_create',
- api_level => 1,
- 'package' => 'OpenILS::Application::Storage',
- cdbi => 'metabib::title_field_entry',
- );
-
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
metabib::author_field_entry->sequence( 'metabib.author_field_entry_id_seq' );
metabib::author_field_entry->columns( 'FTS' => 'index_vector' );
- OpenILS::Application::Storage->register_method(
- api_name => 'open-ils.storage.direct.metabib.author_field_entry.batch.create',
- method => 'copy_create',
- api_level => 1,
- 'package' => 'OpenILS::Application::Storage',
- cdbi => 'metabib::author_field_entry',
- );
-
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
metabib::subject_field_entry->sequence( 'metabib.subject_field_entry_id_seq' );
metabib::subject_field_entry->columns( 'FTS' => 'index_vector' );
- OpenILS::Application::Storage->register_method(
- api_name => 'open-ils.storage.direct.metabib.subject_field_entry.batch.create',
- method => 'copy_create',
- api_level => 1,
- 'package' => 'OpenILS::Application::Storage',
- cdbi => 'metabib::subject_field_entry',
- );
-
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
metabib::keyword_field_entry->sequence( 'metabib.keyword_field_entry_id_seq' );
metabib::keyword_field_entry->columns( 'FTS' => 'index_vector' );
- OpenILS::Application::Storage->register_method(
- api_name => 'open-ils.storage.direct.metabib.keyword_field_entry.batch.create',
- method => 'copy_create',
- api_level => 1,
- 'package' => 'OpenILS::Application::Storage',
- cdbi => 'metabib::keyword_field_entry',
- );
-
#-------------------------------------------------------------------------------
package metabib::series_field_entry;
metabib::series_field_entry->sequence( 'metabib.series_field_entry_id_seq' );
metabib::series_field_entry->columns( 'FTS' => 'index_vector' );
- OpenILS::Application::Storage->register_method(
- api_name => 'open-ils.storage.direct.metabib.series_field_entry.batch.create',
- method => 'copy_create',
- api_level => 1,
- 'package' => 'OpenILS::Application::Storage',
- cdbi => 'metabib::series_field_entry',
- );
-
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
metabib::metarecord_source_map->table( 'metabib.metarecord_source_map' );
metabib::metarecord_source_map->sequence( 'metabib.metarecord_source_map_id_seq' );
- OpenILS::Application::Storage->register_method(
- api_name => 'open-ils.storage.direct.metabib.metarecord_source_map.batch.create',
- method => 'copy_create',
- api_level => 1,
- 'package' => 'OpenILS::Application::Storage',
- cdbi => 'metabib::metarecord_source_map',
- );
-
#-------------------------------------------------------------------------------
package authority::record_descriptor;
authority::record_descriptor->table( 'authority.rec_descriptor' );
authority::record_descriptor->sequence( 'authority.rec_descriptor_id_seq' );
- OpenILS::Application::Storage->register_method(
- api_name => 'open-ils.storage.direct.authority.record_descriptor.batch.create',
- method => 'copy_create',
- api_level => 1,
- 'package' => 'OpenILS::Application::Storage',
- cdbi => 'authority::record_descriptor',
- );
-
#-------------------------------------------------------------------------------
package metabib::record_descriptor;
metabib::record_descriptor->table( 'metabib.rec_descriptor' );
metabib::record_descriptor->sequence( 'metabib.rec_descriptor_id_seq' );
- OpenILS::Application::Storage->register_method(
- api_name => 'open-ils.storage.direct.metabib.record_descriptor.batch.create',
- method => 'copy_create',
- api_level => 1,
- 'package' => 'OpenILS::Application::Storage',
- cdbi => 'metabib::record_descriptor',
- );
-
#-------------------------------------------------------------------------------
authority::full_rec->sequence( 'authority.full_rec_id_seq' );
authority::full_rec->columns( 'FTS' => 'index_vector' );
- OpenILS::Application::Storage->register_method(
- api_name => 'open-ils.storage.direct.authority.full_rec.batch.create',
- method => 'copy_create',
- api_level => 1,
- 'package' => 'OpenILS::Application::Storage',
- cdbi => 'authority::full_rec',
- );
-
-
#-------------------------------------------------------------------------------
package metabib::full_rec;
metabib::full_rec->sequence( 'metabib.full_rec_id_seq' );
metabib::full_rec->columns( 'FTS' => 'index_vector' );
- OpenILS::Application::Storage->register_method(
- api_name => 'open-ils.storage.direct.metabib.full_rec.batch.create',
- method => 'copy_create',
- api_level => 1,
- 'package' => 'OpenILS::Application::Storage',
- cdbi => 'metabib::full_rec',
- );
-
-
#-------------------------------------------------------------------------------
package permission::perm_list;
}
+for my $class ( qw/
+ biblio::record_entry
+ metabib::metarecord
+ metabib::title_field_entry
+ metabib::author_field_entry
+ metabib::subject_field_entry
+ metabib::keyword_field_entry
+ metabib::series_field_entry
+ metabib::metarecord_source_map
+ metabib::record_descriptor
+ metabib::full_rec
+ authority::record_descriptor
+ authority::full_rec
+ / ) {
+
+ (my $method_class = $class) =~ s/::/./go;
+
+ for my $type ( qw/create create_start create_push create_finish/ ) {
+ my ($name,$part) = split('_', $type);
+
+ my $apiname = "open-ils.storage.direct.$method_class.batch.$name";
+ $apiname .= ".$part" if ($part);
+
+ OpenILS::Application::Storage->register_method(
+ api_name => $apiname,
+ method => "copy_$type",
+ api_level => 1,
+ 'package' => 'OpenILS::Application::Storage',
+ cdbi => $class,
+ );
+ }
+}
+
+
1;
+
{
package OpenILS::Application::Storage;
use OpenSRF::Utils::Logger;
+ our $NOPRIMARY = 0;
my $log = 'OpenSRF::Utils::Logger';
my $pg = 'OpenILS::Application::Storage::Driver::Pg';
);
- sub copy_create {
+ sub copy_create_start {
my $self = shift;
my $client = shift;
- my @fm_nodes = @_;
local $OpenILS::Application::Storage::WRITE = 1;
#return undef unless ($pg->current_xact_session);
- my $cdbi = $self->{cdbi};
+ my @cols = $self->{cdbi}->columns('Essential');
+ if ($NOPRIMARY) {
+ my ($p) = $self->{cdbi}->columns('Primary');
+ @cols = grep { $_ ne $p } @cols;
+ }
- my $pri = $cdbi->columns('Primary');
+ my $col_list = join ',', @cols;
- my @cols = grep {$_ ne $pri} $cdbi->columns('Essential');
+ $log->debug('Starting COPY import for '.$self->{cdbi}->table." ($col_list)", DEBUG);
+ $self->{cdbi}->sql_copy_start($self->{cdbi}->table, $col_list)->execute;
- my $col_list = join ',', @cols;
+ return 1;
+ }
- $log->debug('Starting COPY import for '.$cdbi->table." ($col_list)", DEBUG);
- $cdbi->sql_copy_start($cdbi->table, $col_list)->execute;
+ sub copy_create_push {
+ my $self = shift;
+ my $client = shift;
+ my @fm_nodes = @_;
- my $dbh = $cdbi->db_Main;
+ local $OpenILS::Application::Storage::WRITE = 1;
+
+ #return undef unless ($pg->current_xact_session);
+
+ my @cols = $self->{cdbi}->columns('Essential');
+ if ($NOPRIMARY) {
+ my ($p) = $self->{cdbi}->columns('Primary');
+ @cols = grep { $_ ne $p } @cols;
+ }
+
+ my $dbh = $self->{cdbi}->db_Main;
for my $node ( @fm_nodes ) {
next unless ($node);
my $line = join("\t", map { defined($node->$_()) ? $node->$_() : '\N' } @cols);
$dbh->pg_putline($line."\n");
}
+ return scalar(@fm_nodes);
+ }
+
+ sub copy_create_finish {
+ my $self = shift;
+ my $client = shift;
+ my @fm_nodes = @_;
+
+ local $OpenILS::Application::Storage::WRITE = 1;
+
+ #return undef unless ($pg->current_xact_session);
+
+ my $dbh = $self->{cdbi}->db_Main;
+
$dbh->pg_endcopy || $log->debug("Could not end COPY with pg_endcopy", WARN);
- $log->debug('COPY import for '.$cdbi->table." ($col_list) complete", DEBUG);
+ $log->debug('COPY import for '.$self->{cdbi}->table." ($col_list) complete", DEBUG);
+
+ return 1;
+ }
+
+ sub copy_create {
+ my $self = shift;
+ my $client = shift;
+ my @fm_nodes = @_;
+
+ local $NOPRIMARY = 1;
+
+ copy_create_start( $self => $client );
+ copy_create_push( $self => $client => @fm_nodes );
+ copy_create_finish( $self => $client );
return scalar(@fm_nodes);
}
+ sub autoprimary {
+ my $class = shift;
+ my $val = shift;
+ $NOPRIMARY = $val if (defined $val);
+ return $NOPRIMARY;
+ }
+
}
1;