]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg.pm
ae9485223193c8e40e01cbb392bef9c4208031cb
[Evergreen.git] / Open-ILS / src / perlmods / OpenILS / Application / Storage / Driver / Pg.pm
1 { # Based on the change to Class::DBI in OpenILS::Application::Storage.  This will
2   # allow us to use TSearch2 via a simple cdbi "search" interface.
3         #-------------------------------------------------------------------------------
4         use Class::DBI;
5         package Class::DBI;
6
7         sub search_fti {
8                 my $self = shift;
9                 my @args = @_;
10                 if (ref($args[-1]) eq 'HASH') {
11                         $args[-1]->{_placeholder} = "to_tsquery('default',?)";
12                 } else {
13                         push @args, {_placeholder => "to_tsquery('default',?)"};
14                 }
15                 $self->_do_search("@@"  => @args);
16         }
17 }
18
19 { # Every driver needs to provide a 'compile()' method to OpenILS::Application::Storage::FTS.
20   # If that driver wants to support FTI, that is...
21         #-------------------------------------------------------------------------------
22         package OpenILS::Application::Storage::FTS;
23         use OpenSRF::Utils::Logger qw/:level/;
24         my $log = 'OpenSRF::Utils::Logger';
25
26         sub compile {
27                 my $self = shift;
28                 my $term = shift;
29
30                 $self = ref($self) || $self;
31                 $self = bless {} => $self;
32
33                 $self->decompose($term);
34
35                 my $newterm = join('&', $self->words);
36
37                 if (@{$self->nots}) {
38                         $newterm = '('.$newterm.')&('. join('|', $self->nots) . ')';
39                 }
40
41                 $log->debug("Compiled term is [$newterm]", DEBUG);
42                 $newterm = OpenILS::Application::Storage::Driver::Pg->quote($newterm);
43                 $log->debug("Quoted term is [$newterm]", DEBUG);
44
45                 $self->{fts_query} = ["to_tsquery('default',$newterm)"];
46                 $self->{fts_query_nots} = [];
47                 $self->{fts_op} = '@@';
48                 $self->{text_col} = shift;
49                 $self->{fts_col} = shift;
50
51                 return $self;
52         }
53
54         sub sql_where_clause {
55                 my $self = shift;
56                 my $column = $self->fts_col;
57                 my @output;
58         
59                 my @ranks;
60                 for my $fts ( $self->fts_query ) {
61                         push @output, join(' ', $self->fts_col, $self->{fts_op}, $fts);
62                         push @ranks, "rank($column, $fts)";
63                 }
64                 $self->{fts_rank} = \@ranks;
65         
66                 my $phrase_match = $self->sql_exact_phrase_match();
67                 return join(' AND ', @output) . $phrase_match;
68         }
69
70 }
71
72
73 { # The driver package itself just needs a db_Main method (or db_Slaves if
74   #Class::DBI::Replication is in use) for Class::DBI to call.
75   #
76   # Any other fixups can go in here too... Also, the drivers should subclass the
77   # DBI driver that they are wrapping, or provide a 'quote()' method that calls
78   # the DBD::xxx::quote() method on FTI's behalf.
79   #
80   # The dirver MUST be a subclass of Class::DBI(::Replication) and
81   # OpenILS::Application::Storage.
82   #-------------------------------------------------------------------------------
83         package OpenILS::Application::Storage::Driver::Pg;
84         use Class::DBI;
85         use base qw/Class::DBI OpenILS::Application::Storage/;
86         use DBI;
87         use OpenSRF::EX qw/:try/;
88         use OpenSRF::DomainObject::oilsResponse;
89         use OpenSRF::Utils::Logger qw/:level/;
90         my $log = 'OpenSRF::Utils::Logger';
91
92         __PACKAGE__->set_sql( retrieve_limited => 'SELECT * FROM __TABLE__ ORDER BY id LIMIT ?' );
93         __PACKAGE__->set_sql( copy_start => 'COPY %s (%s) FROM STDIN;' );
94         __PACKAGE__->set_sql( copy_end => '\.' );
95
96         my $master_db;
97         my @slave_dbs;
98         my $_db_params;
99         sub child_init {
100                 my $self = shift;
101                 $_db_params = shift;
102
103                 $log->debug("Running child_init inside ".__PACKAGE__, INTERNAL);
104
105                 $_db_params = [ $_db_params ] unless (ref($_db_params) eq 'ARRAY');
106
107                 my %attrs = (   %{$self->_default_attributes},
108                                 RootClass => 'DBIx::ContextualFetch',
109                                 ShowErrorStatement => 1,
110                                 RaiseError => 1,
111                                 AutoCommit => 1,
112                                 PrintError => 1,
113                                 Taint => 1,
114                                 pg_enable_utf8 => 1,
115                                 FetchHashKeyName => 'NAME_lc',
116                                 ChopBlanks => 1,
117                 );
118
119                 my $master = shift @$_db_params;
120                 $master_db = DBI->connect("dbi:Pg:host=$$master{host};dbname=$$master{db}",$$master{user},$$master{pw}, \%attrs);
121                 $master_db->do("SET NAMES '$$master{client_encoding}';") if ($$master{client_encoding});
122
123                 $log->debug("Connected to MASTER db '$$master{db} at $$master{host}", INFO);
124                 
125                 for my $db (@$_db_params) {
126                         push @slave_dbs, DBI->connect("dbi:Pg:host=$$db{host};dbname=$$db{db}",$$db{user},$$db{pw}, \%attrs);
127                         $slave_dbs[-1]->do("SET NAMES '$$db{client_encoding}';") if ($$master{client_encoding});
128
129                         $log->debug("Connected to MASTER db '$$master{db} at $$master{host}", INFO);
130                 }
131
132                 $log->debug("All is well on the western front", INTERNAL);
133         }
134
135         sub db_Main {
136                 my $self = shift;
137                 return $master_db if ($self->current_xact_session);
138                 return $master_db unless (@slave_dbs);
139                 return ($master_db, @slave_dbs)[rand(scalar(@slave_dbs))];
140         }
141
142         sub quote {
143                 my $self = shift;
144                 return $self->db_Main->quote(@_)
145         }
146
147 #       sub tsearch2_trigger {
148 #               my $self = shift;
149 #               return unless ($self->value);
150 #               $self->index_vector(
151 #                       $self->db_Slaves->selectrow_array(
152 #                               "SELECT to_tsvector('default',?);",
153 #                               {},
154 #                               $self->value
155 #                       )
156 #               );
157 #       }
158
159         my $_xact_session;
160
161         sub current_xact_session {
162                 my $self = shift;
163                 if (defined($_xact_session)) {
164                         return $_xact_session;
165                 }
166                 return undef;
167         }
168
169         sub current_xact_is_auto {
170                 my $self = shift;
171                 my $auto = shift;
172                 if (defined($_xact_session) and ref($_xact_session)) {
173                         if (defined $auto) {
174                                 $_xact_session->session_data(autocommit => $auto);
175                         }
176                         return $_xact_session->session_data('autocommit'); 
177                 }
178         }
179
180         sub current_xact_id {
181                 my $self = shift;
182                 if (defined($_xact_session) and ref($_xact_session)) {
183                         return $_xact_session->session_id;
184                 }
185                 return undef;
186         }
187
188         sub set_xact_session {
189                 my $self = shift;
190                 my $ses = shift;
191                 if (!defined($ses)) {
192                         return undef;
193                 }
194                 $_xact_session = $ses;
195                 return $_xact_session;
196         }
197
198         sub unset_xact_session {
199                 my $self = shift;
200                 my $ses = $_xact_session;
201                 undef $_xact_session;
202                 return $ses;
203         }
204
205 }
206
207
208 {
209         package OpenILS::Application::Storage;
210         use OpenSRF::Utils::Logger;
211         my $log = 'OpenSRF::Utils::Logger';
212
213         my $pg = 'OpenILS::Application::Storage::Driver::Pg';
214
215
216         sub current_xact {
217                 my $self = shift;
218                 my $client = shift;
219                 return $pg->current_xact_id;
220         }
221         __PACKAGE__->register_method(
222                 method          => 'current_xact',
223                 api_name        => 'open-ils.storage.transaction.current',
224                 api_level       => 1,
225                 argc            => 0,
226         );
227
228
229         sub pg_begin_xaction {
230                 my $self = shift;
231                 my $client = shift;
232
233                 if (my $old_xact = $pg->current_xact_session) {
234                         if ($pg->current_xact_is_auto) {
235                                 $log->debug("Commiting old autocommit transaction with Open-ILS XACT-ID [$old_xact]", INFO);
236                                 $self->pg_commit_xaction($client);
237                         } else {
238                                 $log->debug("Rolling back old NON-autocommit transaction with Open-ILS XACT-ID [$old_xact]", INFO);
239                                 $self->pg_rollback_xaction($client);
240                                 throw OpenSRF::DomainObject::oilsException->new(
241                                                 statusCode => 500,
242                                                 status => "Previous transaction rolled back!",
243                                 );
244                         }
245                 }
246                 
247                 $pg->set_xact_session( $client->session );
248                 my $xact_id = $pg->current_xact_id;
249
250                 $log->debug("Beginning a new trasaction with Open-ILS XACT-ID [$xact_id]", INFO);
251
252                 my $dbh = OpenILS::Application::Storage::CDBI->db_Main;
253                 
254                 try {
255                         $dbh->begin_work;
256
257                 } catch Error with {
258                         my $e = shift;
259                         $log->debug("Failed to begin a new trasaction with Open-ILS XACT-ID [$xact_id]: ".$e, INFO);
260                         throw $e;
261                 };
262
263
264                 my $death_cb = $client->session->register_callback(
265                         death => sub {
266                                 __PACKAGE__->pg_rollback_xaction;
267                         }
268                 );
269
270                 $log->debug("Registered 'death' callback [$death_cb] for new trasaction with Open-ILS XACT-ID [$xact_id]", DEBUG);
271
272                 $client->session->session_data( death_cb => $death_cb );
273
274                 if ($self->api_name =~ /autocommit$/o) {
275                         $pg->current_xact_is_auto(1);
276                         my $dc_cb = $client->session->register_callback(
277                                 disconnect => sub {
278                                         my $ses = shift;
279                                         $ses->unregister_callback(death => $death_cb);
280                                         __PACKAGE__->pg_commit_xaction;
281                                 }
282                         );
283                         $log->debug("Registered 'disconnect' callback [$dc_cb] for new trasaction with Open-ILS XACT-ID [$xact_id]", DEBUG);
284                         if ($client and $client->session) {
285                                 $client->session->session_data( disconnect_cb => $dc_cb );
286                         }
287                 }
288
289                 return 1;
290
291         }
292         __PACKAGE__->register_method(
293                 method          => 'pg_begin_xaction',
294                 api_name        => 'open-ils.storage.transaction.begin',
295                 api_level       => 1,
296                 argc            => 0,
297         );
298         __PACKAGE__->register_method(
299                 method          => 'pg_begin_xaction',
300                 api_name        => 'open-ils.storage.transaction.begin.autocommit',
301                 api_level       => 1,
302                 argc            => 0,
303         );
304
305         sub pg_commit_xaction {
306                 my $self = shift;
307
308                 my $xact_id = $pg->current_xact_id;
309
310                 try {
311                         $log->debug("Committing trasaction with Open-ILS XACT-ID [$xact_id]", INFO);
312                         my $dbh = OpenILS::Application::Storage::CDBI->db_Main;
313                         $dbh->commit;
314
315                 } catch Error with {
316                         my $e = shift;
317                         $log->debug("Failed to commit trasaction with Open-ILS XACT-ID [$xact_id]: ".$e, INFO);
318                         return 0;
319                 };
320                 
321                 $pg->current_xact_session->unregister_callback( death => 
322                         $pg->current_xact_session->session_data( 'death_cb' )
323                 ) if ($pg->current_xact_session);
324
325                 if ($pg->current_xact_is_auto) {
326                         $pg->current_xact_session->unregister_callback( disconnect => 
327                                 $pg->current_xact_session->session_data( 'disconnect_cb' )
328                         );
329                 }
330
331                 $pg->unset_xact_session;
332
333                 return 1;
334                 
335         }
336         __PACKAGE__->register_method(
337                 method          => 'pg_commit_xaction',
338                 api_name        => 'open-ils.storage.transaction.commit',
339                 api_level       => 1,
340                 argc            => 0,
341         );
342
343         sub pg_rollback_xaction {
344                 my $self = shift;
345
346                 my $xact_id = $pg->current_xact_id;
347                 try {
348                         my $dbh = OpenILS::Application::Storage::CDBI->db_Main;
349                         $log->debug("Rolling back a trasaction with Open-ILS XACT-ID [$xact_id]", INFO);
350                         $dbh->rollback;
351
352                 } catch Error with {
353                         my $e = shift;
354                         $log->debug("Failed to roll back trasaction with Open-ILS XACT-ID [$xact_id]: ".$e, INFO);
355                         return 0;
356                 };
357         
358                 $pg->current_xact_session->unregister_callback( death =>
359                         $pg->current_xact_session->session_data( 'death_cb' )
360                 ) if ($pg->current_xact_session);
361
362                 if ($pg->current_xact_is_auto) {
363                         $pg->current_xact_session->unregister_callback( disconnect =>
364                                 $pg->current_xact_session->session_data( 'disconnect_cb' )
365                         );
366                 }
367
368                 $pg->unset_xact_session;
369
370                 return 1;
371         }
372         __PACKAGE__->register_method(
373                 method          => 'pg_rollback_xaction',
374                 api_name        => 'open-ils.storage.transaction.rollback',
375                 api_level       => 1,
376                 argc            => 0,
377         );
378
379         sub copy_create {
380                 my $self = shift;
381                 my $client = shift;
382                 my @fm_nodes = @_;
383
384                 return undef unless ($pg->current_xact_session);
385
386                 my $cdbi = $self->{cdbi};
387
388                 my $pri = $cdbi->columns('Primary');
389
390                 my @cols = grep {$_ ne $pri} $cdbi->columns('All');
391
392                 my $col_list = join ',', @cols;
393
394                 $log->debug('Starting COPY import for '.$cdbi->table." ($col_list)", DEBUG);
395                 $cdbi->sql_copy_start($cdbi->table, $col_list)->execute;
396
397                 my $dbh = $cdbi->db_Main;
398                 for my $node ( @fm_nodes ) {
399                         next unless ($node);
400                         my $line = join("\t", map { defined($node->$_()) ? $node->$_() : '\N' } @cols);
401                         $log->debug("COPY line: [$line]",DEBUG);
402                         $dbh->func($line."\n", 'putline');
403                 }
404
405                 $dbh->func('endcopy');
406
407                 return scalar(@fm_nodes);
408         }
409
410 }
411
412 {
413         #---------------------------------------------------------------------
414         package action::survey;
415         
416         action::survey->table( 'action.survey' );
417         action::survey->sequence( 'action.survey_id_seq' );
418         
419         #---------------------------------------------------------------------
420         package action::survey_question;
421         
422         action::survey_question->table( 'action.survey_question' );
423         action::survey_question->sequence( 'action.survey_question_id_seq' );
424         
425         #---------------------------------------------------------------------
426         package action::survey_answer;
427         
428         action::survey_answer->table( 'action.survey_answer' );
429         action::survey_answer->sequence( 'action.survey_answer_id_seq' );
430         
431         #---------------------------------------------------------------------
432         package action::survey_response;
433         
434         action::survey_response->table( 'action.survey_response' );
435         action::survey_response->sequence( 'action.survey_response_id_seq' );
436         
437         #---------------------------------------------------------------------
438         package config::standing;
439         
440         config::standing->table( 'config.standing' );
441         config::standing->sequence( 'config.standing_id_seq' );
442         
443         #---------------------------------------------------------------------
444         package config::metabib_field;
445         
446         config::metabib_field->table( 'config.metabib_field' );
447         config::metabib_field->sequence( 'config.metabib_field_id_seq' );
448         
449         #---------------------------------------------------------------------
450         package config::bib_source;
451         
452         config::bib_source->table( 'config.bib_source' );
453         config::bib_source->sequence( 'config.bib_source_id_seq' );
454         
455         #---------------------------------------------------------------------
456         package config::identification_type;
457         
458         config::identification_type->table( 'config.identification_type' );
459         config::identification_type->sequence( 'config.identification_type_id_seq' );
460         
461         #---------------------------------------------------------------------
462         package asset::call_number_note;
463         
464         asset::call_number->table( 'asset.call_number_note' );
465         asset::call_number->sequence( 'asset.call_number_note_id_seq' );
466         
467         #---------------------------------------------------------------------
468         package asset::copy_note;
469         
470         asset::copy->table( 'asset.copy_note' );
471         asset::copy->sequence( 'asset.copy_note_id_seq' );
472
473         #---------------------------------------------------------------------
474         package asset::call_number;
475         
476         asset::call_number->table( 'asset.call_number' );
477         asset::call_number->sequence( 'asset.call_number_id_seq' );
478         
479         #---------------------------------------------------------------------
480         package asset::copy;
481         
482         asset::copy->table( 'asset.copy' );
483         asset::copy->sequence( 'asset.copy_id_seq' );
484
485         #---------------------------------------------------------------------
486         package asset::stat_cat;
487         
488         asset::stat_cat->table( 'asset.stat_cat' );
489         asset::stat_cat->sequence( 'asset.stat_cat_id_seq' );
490         
491         #---------------------------------------------------------------------
492         package asset::stat_cat_entry;
493         
494         asset::stat_cat_entry->table( 'asset.stat_cat_entry' );
495         asset::stat_cat_entry->sequence( 'asset.stat_cat_entry_id_seq' );
496         
497         #---------------------------------------------------------------------
498         package asset::stat_cat_entry_copy_map;
499         
500         asset::stat_cat_entry_copy_map->table( 'asset.stat_cat_entry_copy_map' );
501         asset::stat_cat_entry_copy_map->sequence( 'asset.stat_cat_entry_copy_map_id_seq' );
502         
503         #---------------------------------------------------------------------
504         package biblio::record_entry;
505         
506         biblio::record_entry->table( 'biblio.record_entry' );
507         biblio::record_entry->sequence( 'biblio.record_entry_id_seq' );
508
509         #---------------------------------------------------------------------
510         #package biblio::record_marc;
511         #
512         #biblio::record_marc->table( 'biblio.record_marc' );
513         #biblio::record_marc->sequence( 'biblio.record_marc_id_seq' );
514         #
515         #---------------------------------------------------------------------
516         package biblio::record_note;
517         
518         biblio::record_note->table( 'biblio.record_note' );
519         biblio::record_note->sequence( 'biblio.record_note_id_seq' );
520         
521         #---------------------------------------------------------------------
522         package actor::user;
523         
524         actor::user->table( 'actor.usr' );
525         actor::user->sequence( 'actor.usr_id_seq' );
526
527         #---------------------------------------------------------------------
528         package actor::user_address;
529         
530         actor::user_address->table( 'actor.usr_address' );
531         actor::user_address->sequence( 'actor.usr_address_id_seq' );
532         
533         #---------------------------------------------------------------------
534         package actor::profile;
535         
536         actor::profile->table( 'actor.profile' );
537         actor::profile->sequence( 'actor.profile_id_seq' );
538         
539         #---------------------------------------------------------------------
540         package actor::org_unit_type;
541         
542         actor::org_unit_type->table( 'actor.org_unit_type' );
543         actor::org_unit_type->sequence( 'actor.org_unit_type_id_seq' );
544
545         #---------------------------------------------------------------------
546         package actor::org_unit;
547         
548         actor::org_unit->table( 'actor.org_unit' );
549         actor::org_unit->sequence( 'actor.org_unit_id_seq' );
550
551         #---------------------------------------------------------------------
552         package actor::stat_cat;
553         
554         actor::stat_cat->table( 'actor.stat_cat' );
555         actor::stat_cat->sequence( 'actor.stat_cat_id_seq' );
556         
557         #---------------------------------------------------------------------
558         package actor::stat_cat_entry;
559         
560         actor::stat_cat_entry->table( 'actor.stat_cat_entry' );
561         actor::stat_cat_entry->sequence( 'actor.stat_cat_entry_id_seq' );
562         
563         #---------------------------------------------------------------------
564         package actor::stat_cat_entry_user_map;
565         
566         actor::stat_cat_entry_user_map->table( 'actor.stat_cat_entry_copy_map' );
567         actor::stat_cat_entry_user_map->sequence( 'actor.stat_cat_entry_usr_map_id_seq' );
568         
569         #---------------------------------------------------------------------
570         package actor::card;
571         
572         actor::card->table( 'actor.card' );
573         actor::card->sequence( 'actor.card_id_seq' );
574         
575
576         #---------------------------------------------------------------------
577
578         #-------------------------------------------------------------------------------
579         package metabib::metarecord;
580
581         metabib::metarecord->table( 'metabib.metarecord' );
582         metabib::metarecord->sequence( 'metabib.metarecord_id_seq' );
583
584         OpenILS::Application::Storage->register_method(
585                 api_name        => 'open-ils.storage.direct.metabib.metarecord.batch.create',
586                 method          => 'copy_create',
587                 api_level       => 1,
588                 'package'       => 'OpenILS::Application::Storage',
589                 cdbi            => 'metabib::metarecord',
590         );
591
592
593         #-------------------------------------------------------------------------------
594
595         #-------------------------------------------------------------------------------
596         package metabib::title_field_entry;
597
598         metabib::title_field_entry->table( 'metabib.title_field_entry' );
599         metabib::title_field_entry->sequence( 'metabib.title_field_entry_id_seq' );
600         metabib::title_field_entry->columns( 'FTS' => 'index_vector' );
601
602 #       metabib::title_field_entry->add_trigger(
603 #               before_create => \&OpenILS::Application::Storage::Driver::Pg::tsearch2_trigger
604 #       );
605 #       metabib::title_field_entry->add_trigger(
606 #               before_update => \&OpenILS::Application::Storage::Driver::Pg::tsearch2_trigger
607 #       );
608
609         OpenILS::Application::Storage->register_method(
610                 api_name        => 'open-ils.storage.direct.metabib.title_field_entry.batch.create',
611                 method          => 'copy_create',
612                 api_level       => 1,
613                 'package'       => 'OpenILS::Application::Storage',
614                 cdbi            => 'metabib::title_field_entry',
615         );
616
617         #-------------------------------------------------------------------------------
618
619         #-------------------------------------------------------------------------------
620         package metabib::author_field_entry;
621
622         metabib::author_field_entry->table( 'metabib.author_field_entry' );
623         metabib::author_field_entry->sequence( 'metabib.author_field_entry_id_seq' );
624         metabib::author_field_entry->columns( 'FTS' => 'index_vector' );
625
626         OpenILS::Application::Storage->register_method(
627                 api_name        => 'open-ils.storage.direct.metabib.author_field_entry.batch.create',
628                 method          => 'copy_create',
629                 api_level       => 1,
630                 'package'       => 'OpenILS::Application::Storage',
631                 cdbi            => 'metabib::author_field_entry',
632         );
633
634         #-------------------------------------------------------------------------------
635
636         #-------------------------------------------------------------------------------
637         package metabib::subject_field_entry;
638
639         metabib::subject_field_entry->table( 'metabib.subject_field_entry' );
640         metabib::subject_field_entry->sequence( 'metabib.subject_field_entry_id_seq' );
641         metabib::subject_field_entry->columns( 'FTS' => 'index_vector' );
642
643         OpenILS::Application::Storage->register_method(
644                 api_name        => 'open-ils.storage.direct.metabib.subject_field_entry.batch.create',
645                 method          => 'copy_create',
646                 api_level       => 1,
647                 'package'       => 'OpenILS::Application::Storage',
648                 cdbi            => 'metabib::subject_field_entry',
649         );
650
651         #-------------------------------------------------------------------------------
652
653         #-------------------------------------------------------------------------------
654         package metabib::keyword_field_entry;
655
656         metabib::keyword_field_entry->table( 'metabib.keyword_field_entry' );
657         metabib::keyword_field_entry->sequence( 'metabib.keyword_field_entry_id_seq' );
658         metabib::keyword_field_entry->columns( 'FTS' => 'index_vector' );
659
660         OpenILS::Application::Storage->register_method(
661                 api_name        => 'open-ils.storage.direct.metabib.keyword_field_entry.batch.create',
662                 method          => 'copy_create',
663                 api_level       => 1,
664                 'package'       => 'OpenILS::Application::Storage',
665                 cdbi            => 'metabib::keyword_field_entry',
666         );
667
668         #-------------------------------------------------------------------------------
669
670         #-------------------------------------------------------------------------------
671         #package metabib::title_field_entry_source_map;
672
673         #metabib::title_field_entry_source_map->table( 'metabib.title_field_entry_source_map' );
674
675         #-------------------------------------------------------------------------------
676
677         #-------------------------------------------------------------------------------
678         #package metabib::author_field_entry_source_map;
679
680         #metabib::author_field_entry_source_map->table( 'metabib.author_field_entry_source_map' );
681
682         #-------------------------------------------------------------------------------
683
684         #-------------------------------------------------------------------------------
685         #package metabib::subject_field_entry_source_map;
686
687         #metabib::subject_field_entry_source_map->table( 'metabib.subject_field_entry_source_map' );
688
689         #-------------------------------------------------------------------------------
690
691         #-------------------------------------------------------------------------------
692         #package metabib::keyword_field_entry_source_map;
693
694         #metabib::keyword_field_entry_source_map->table( 'metabib.keyword_field_entry_source_map' );
695
696         #-------------------------------------------------------------------------------
697
698         #-------------------------------------------------------------------------------
699         package metabib::metarecord_source_map;
700
701         metabib::metarecord_source_map->table( 'metabib.metarecord_source_map' );
702         OpenILS::Application::Storage->register_method(
703                 api_name        => 'open-ils.storage.direct.metabib.metarecord_source_map.batch.create',
704                 method          => 'copy_create',
705                 api_level       => 1,
706                 'package'       => 'OpenILS::Application::Storage',
707                 cdbi            => 'metabib::metarecord_source_map',
708         );
709
710
711         #-------------------------------------------------------------------------------
712         package metabib::record_descriptor;
713
714         metabib::record_descriptor->table( 'metabib.rec_descriptor' );
715         metabib::record_descriptor->sequence( 'metabib.rec_descriptor_id_seq' );
716
717         OpenILS::Application::Storage->register_method(
718                 api_name        => 'open-ils.storage.direct.metabib.record_descriptor.batch.create',
719                 method          => 'copy_create',
720                 api_level       => 1,
721                 'package'       => 'OpenILS::Application::Storage',
722                 cdbi            => 'metabib::record_descriptor',
723         );
724
725         #-------------------------------------------------------------------------------
726
727
728         #-------------------------------------------------------------------------------
729         package metabib::full_rec;
730
731         metabib::full_rec->table( 'metabib.full_rec' );
732         metabib::full_rec->sequence( 'metabib.full_rec_id_seq' );
733         metabib::full_rec->columns( 'FTS' => 'index_vector' );
734
735         OpenILS::Application::Storage->register_method(
736                 api_name        => 'open-ils.storage.direct.metabib.full_rec.batch.create',
737                 method          => 'copy_create',
738                 api_level       => 1,
739                 'package'       => 'OpenILS::Application::Storage',
740                 cdbi            => 'metabib::full_rec',
741         );
742
743
744         #-------------------------------------------------------------------------------
745 }
746
747 1;