1 #-------------------------------------------------------------------------------
8 if (ref($args[-1]) eq 'HASH') {
9 $args[-1]->{_placeholder} = "to_tsquery('default',?)";
11 push @args, {_placeholder => "to_tsquery('default',?)"};
13 $self->_do_search("@@" => @args);
16 #-------------------------------------------------------------------------------
17 package OpenILS::Application::Storage::FTS;
18 use OpenSRF::Utils::Logger qw/:level/;
19 my $log = 'OpenSRF::Utils::Logger';
25 $self = ref($self) || $self;
26 $self = bless {} => $self;
28 $self->decompose($term);
30 my $newterm = join('&', $self->words);
33 $newterm = '('.$newterm.')&('. join('|', $self->nots) . ')';
36 $newterm = OpenILS::Application::Storage->driver->quote($newterm);
38 $self->{fts_query} = ["to_tsquery('default',$newterm)"];
39 $self->{fts_query_nots} = [];
40 $self->{fts_op} = '@@';
46 #-------------------------------------------------------------------------------
47 package OpenILS::Application::Storage::Driver::Pg;
48 use base qw/Class::DBI DBD::Pg OpenILS::Application::Storage/;
51 use OpenSRF::Utils::Logger qw/:level/;
53 __PACKAGE__->set_sql( retrieve_limited => 'SELECT * FROM __TABLE__ ORDER BY id LIMIT ?' );
58 return $_dbh if (defined $_dbh and $_dbh->ping);
62 my %args = (%OpenILS::Application::Storage::_db_params,@_);
64 my %attrs = ( %{$self->_default_attributes},
65 RootClass => 'DBIx::ContextualFetch',
66 ShowErrorStatement => 1,
72 FetchHashKeyName => 'NAME_lc',
76 $log->debug(" Default attributes for this DB connection are:\n\t".join("\n\t",map { "$_\t==> $attrs{$_}" } keys %attrs), INTERNAL);
78 $_dbh = DBI->connect( "dbi:Pg:host=$args{host};dbname=$args{database}",$args{user},$args{pw}, \%attrs );
79 $_dbh->do("SET CLIENT_ENCODING TO 'SQL_ASCII';");
84 #-------------------------------------------------------------------------------
85 package asset::call_number;
86 use base qw/OpenILS::App::Storage::CDBI/;
88 __PACKAGE__->table( 'asset.call_number' );
89 __PACKAGE__->sequence( 'asset.call_number_id_seq' );
90 __PACKAGE__->columns( Primary => qw/id/ );
91 __PACKAGE__->columns( Essential => qw/record/ );
93 __PACKAGE__->has_a( record => 'biblio::record_entry' );
94 __PACKAGE__->has_many( copies => 'asset::copy' );
98 #-------------------------------------------------------------------------------
100 use base qw/OpenILS::App::Storage::CDBI/;
102 __PACKAGE__->table( 'asset.copy' );
103 __PACKAGE__->sequence( 'asset.copy_id_seq' );
104 __PACKAGE__->columns( Primary => qw/id/ );
105 __PACKAGE__->columns( Essential => qw/call_number barcode/ );
107 #__PACKAGE__->has_a( call_number => 'asset::call_number' );
111 #-------------------------------------------------------------------------------
112 package biblio::record_entry;
113 use base qw/OpenILS::App::Storage::CDBI/;
115 __PACKAGE__->table( 'biblio.record_entry' );
116 __PACKAGE__->sequence( 'biblio.record_entry_id_seq' );
117 __PACKAGE__->columns( Primary => qw/id/ );
119 #__PACKAGE__->columns( Essential => qw/tcn_source tcn_value metarecord creator editor create_date edit_date source active deleted/ );
120 __PACKAGE__->columns( Others => qw/tcn_source tcn_value metarecord creator editor create_date edit_date source active deleted/ );
122 __PACKAGE__->has_a( note => 'biblio::record_note' );
123 __PACKAGE__->has_many( nodes => 'biblio::record_data' );
125 #__PACKAGE__->has_a( metarecord => 'metabib::metarecord' );
126 #__PACKAGE__->has_many( field_entries => 'metabib::field_entry' );
127 #__PACKAGE__->has_many( call_numbers => 'asset::call_number' );
129 #-------------------------------------------------------------------------------
130 package biblio::record_node::subnode;
132 my $intra_doc_id = shift;
133 my $owner_doc = shift()->owner_doc;
134 return (biblio::record_node->search( owner_doc => $owner_doc, intra_doc_id => $intra_doc_id ))[0];
137 package biblio::record_node;
138 use base qw/OpenILS::App::Storage::CDBI/;
140 __PACKAGE__->table( 'biblio.record_data' );
141 __PACKAGE__->sequence( 'biblio.record_data_id_seq' );
142 __PACKAGE__->columns( Primary => qw/id/ );
143 __PACKAGE__->columns( Essential => qw/owner_doc intra_doc_id parent_node node_type namespace_uri name value/ );
145 __PACKAGE__->has_a( owner_doc => 'biblio::record_entry' );
147 parent_node => 'biblio::record_node::subnode',
148 inflate => sub { return biblio::record_node::subnode::_load(@_) },
152 #-------------------------------------------------------------------------------
153 package biblio::record_note;
154 use base qw/OpenILS::App::Storage::CDBI/;
156 __PACKAGE__->table( 'biblio.record_note' );
157 __PACKAGE__->sequence( 'biblio.record_note_id_seq' );
158 __PACKAGE__->columns( Primary => qw/id/ );
159 __PACKAGE__->columns( Stringify => qw/value/ );
160 __PACKAGE__->columns( Essential => qw/record value creator editor create_date edit_date/ );
162 __PACKAGE__->has_a( record_entry => 'biblio::record_entry' );
164 #-------------------------------------------------------------------------------
165 #-------------------------------------------------------------------------------