- Timestamp:
- 2018-10-24T20:41:01+13:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/plugins/GreenstoneSQLPlugin.pm
r32537 r32538 124 124 } 125 125 126 # need to store current section127 #sub xml_start_tag {128 # my $self = shift(@_);129 # $self->SUPER::xml_start_tag(@_);130 # $self->{'stored_section'} = $self->{'section'};131 # $self->{'stored_section_level'} = $self->{'section_level'}132 #}133 126 134 127 # TODO Q: Why are there 3 passes when we're only indexing at doc and section level (2 passes)? … … 145 138 146 139 my $oid = $self->{'doc_oid'}; # we stored current doc's OID during sub read() 147 print $outhandle " @@@@@@OID of document (meta|text) to be read in from DB: $oid\n"140 print $outhandle "==== OID of document (meta|text) to be read in from DB: $oid\n" 148 141 if $self->{'verbosity'} > 1; 149 142 150 # print STDERR "@@@@ section: |" . $self->{'stored_section'} . "|\n"; 151 # print STDERR "@@@@ section_level: " . $self->{'stored_section_level'} . "\n"; 152 153 # for now, we have access to doc_obj (until just before super::close_document() terminates) 154 #$self->{'doc_obj'}->set_OID($oid); 143 144 # For now, we have access to doc_obj (until just before super::close_document() terminates) 145 146 $self->{'doc_obj'}->set_OID($oid); # complex method. Is this necessary, since we just want to write meta and txt for the docobj to index? 147 148 # checking that complicated looking method set_OID() hasn't modified oid 149 if($oid ne $self->{'doc_obj'}->get_OID()) { 150 print STDERR "@@@@ WARNING: OID after setting on doc_obj = " . $self->{'doc_obj'}->get_OID() . " and is not the same as original OID $oid from docsqloid.xml filename\n"; 151 } 152 155 153 156 154 # TODO: This function is called on a per doc.xml file basis … … 164 162 # read in meta for the collection (i.e. select * from <col>_metadata table 165 163 166 my $meta_table = $gs_sql->get_metadata_table_name(); 167 164 my $sth = $gs_sql->select_from_metatable_matching_docid($oid); 165 print $outhandle "### stmt: ".$sth->{'Statement'}."\n" if $self->{'verbosity'} > 1; 166 167 print $outhandle "----------SQL DB contains meta-----------\n" if $self->{'verbosity'} > 1; 168 168 # https://www.effectiveperlprogramming.com/2010/07/set-custom-dbi-error-handlers/ 169 my $sth = $gs_sql->get_db_handle()->prepare(qq{SELECT * FROM $meta_table WHERE did = ?});170 print $outhandle "### stmt: ".$sth->{'Statement'}."\n"171 if $self->{'verbosity'} > 1;172 $sth->execute( $oid ); # will print msg on fail173 174 print $outhandle "----------SQL DB contains meta-----------\n" if $self->{'verbosity'} > 1;175 169 while( my @row = $sth->fetchrow_array() ) { 176 170 #print $outhandle "row: @row\n"; … … 196 190 197 191 198 my $sth = $gs_sql->get_db_handle()->prepare(qq{SELECT * FROM $fulltxt_table WHERE did = ?}); 199 print $outhandle "### stmt: ".$sth->{'Statement'}."\n" 200 if $self->{'verbosity'} > 1; 201 $sth->execute( $oid ); # will print msg on fail 192 my $sth = $gs_sql->select_from_texttable_matching_docid($oid); 193 print $outhandle "### stmt: ".$sth->{'Statement'}."\n" if $self->{'verbosity'} > 1; 202 194 203 195 print $outhandle "----------\nSQL DB contains txt entries for-----------\n" … … 226 218 227 219 228 # TODO: only want to work with sql db if buildcol.pl 220 # TODO: only want to work with sql db if buildcol.pl. Unfortunately, also runs on import.pl 229 221 # call init() not begin() because there can be multiple plugin passes 230 222 # and init() should be called before all passes: 231 223 # one for doc level and another for section level indexing 224 # This way, we can connect to the SQL database once per buildcol run. 232 225 sub init { 233 226 my ($self) = shift (@_); … … 290 283 } 291 284 292 285 # This method also runs on import.pl if gs_sql has a value. But we just want to run it on buildcol 293 286 # Call deinit() not end() because there can be multiple plugin passes: 294 287 # one for doc level and another for section level indexing 295 288 # and deinit() should be called before all passes 289 # This way, we can close the SQL database once per buildcol run. 296 290 sub deinit { 297 291 my ($self) = shift (@_);
Note:
See TracChangeset
for help on using the changeset viewer.