Lines 199-204
sub fetch {
Link Here
|
199 |
my $matchcheck = {}; |
199 |
my $matchcheck = {}; |
200 |
$matchcheck->{'source_matchpoint'} = $source_matchpoint; |
200 |
$matchcheck->{'source_matchpoint'} = $source_matchpoint; |
201 |
$matchcheck->{'target_matchpoint'} = $target_matchpoint; |
201 |
$matchcheck->{'target_matchpoint'} = $target_matchpoint; |
|
|
202 |
$matchcheck->{'operator'} = $row->{'operator'}; |
202 |
push @{ $self->{'required_checks'} }, $matchcheck; |
203 |
push @{ $self->{'required_checks'} }, $matchcheck; |
203 |
} |
204 |
} |
204 |
|
205 |
|
Lines 208-214
sub fetch {
Link Here
|
208 |
sub _fetch_matchpoint { |
209 |
sub _fetch_matchpoint { |
209 |
my $self = shift; |
210 |
my $self = shift; |
210 |
my $matchpoint_id = shift; |
211 |
my $matchpoint_id = shift; |
211 |
|
212 |
|
212 |
my $dbh = C4::Context->dbh; |
213 |
my $dbh = C4::Context->dbh; |
213 |
my $sth = $dbh->prepare_cached("SELECT * FROM matchpoints WHERE matchpoint_id = ?"); |
214 |
my $sth = $dbh->prepare_cached("SELECT * FROM matchpoints WHERE matchpoint_id = ?"); |
214 |
$sth->execute($matchpoint_id); |
215 |
$sth->execute($matchpoint_id); |
Lines 223-235
sub _fetch_matchpoint {
Link Here
|
223 |
$sth->execute($matchpoint_id); |
224 |
$sth->execute($matchpoint_id); |
224 |
while ($row = $sth->fetchrow_hashref) { |
225 |
while ($row = $sth->fetchrow_hashref) { |
225 |
my $component = {}; |
226 |
my $component = {}; |
226 |
$component->{'tag'} = $row->{'tag'}; |
227 |
$component->{'tag'} = $row->{'tag'}; |
227 |
$component->{'subfields'} = { map { $_ => 1 } split(//, $row->{'subfields'}) }; |
228 |
$component->{'subfields'} = { map { $_ => 1 } split(//, $row->{'subfields'}) }; |
228 |
$component->{'offset'} = int($row->{'offset'}); |
229 |
$component->{'offset'} = int($row->{'offset'}); |
229 |
$component->{'length'} = int($row->{'length'}); |
230 |
$component->{'length'} = int($row->{'length'}); |
230 |
$component->{'norms'} = []; |
231 |
$component->{'norms'} = []; |
231 |
my $sth2 = $dbh->prepare_cached("SELECT * |
232 |
$component->{'constant'} = $row->{'constant'}; |
232 |
FROM matchpoint_component_norms |
233 |
$component->{'type'} = defined $row->{'constant'} ? 'constant' : 'field'; |
|
|
234 |
my $sth2 = $dbh->prepare_cached("SELECT * |
235 |
FROM matchpoint_component_norms |
233 |
WHERE matchpoint_component_id = ? ORDER BY sequence"); |
236 |
WHERE matchpoint_component_id = ? ORDER BY sequence"); |
234 |
$sth2->execute($row->{'matchpoint_component_id'}); |
237 |
$sth2->execute($row->{'matchpoint_component_id'}); |
235 |
while (my $row2 = $sth2->fetchrow_hashref) { |
238 |
while (my $row2 = $sth2->fetchrow_hashref) { |
Lines 319-328
sub _store_matcher_components {
Link Here
|
319 |
foreach my $matchcheck (@{ $self->{'required_checks'} }) { |
322 |
foreach my $matchcheck (@{ $self->{'required_checks'} }) { |
320 |
my $source_matchpoint_id = $self->_store_matchpoint($matchcheck->{'source_matchpoint'}); |
323 |
my $source_matchpoint_id = $self->_store_matchpoint($matchcheck->{'source_matchpoint'}); |
321 |
my $target_matchpoint_id = $self->_store_matchpoint($matchcheck->{'target_matchpoint'}); |
324 |
my $target_matchpoint_id = $self->_store_matchpoint($matchcheck->{'target_matchpoint'}); |
322 |
$sth = $dbh->prepare_cached("INSERT INTO matchchecks |
325 |
$sth = $dbh->prepare_cached( |
323 |
(matcher_id, source_matchpoint_id, target_matchpoint_id) |
326 |
"INSERT INTO matchchecks |
324 |
VALUES (?, ?, ?)"); |
327 |
(matcher_id, source_matchpoint_id, target_matchpoint_id, operator) |
325 |
$sth->execute($matcher_id, $source_matchpoint_id, $target_matchpoint_id); |
328 |
VALUES (?, ?, ?, ?)" |
|
|
329 |
); |
330 |
$sth->execute( $matcher_id, $source_matchpoint_id, $target_matchpoint_id, $matchcheck->{'operator'} ); |
326 |
} |
331 |
} |
327 |
|
332 |
|
328 |
} |
333 |
} |
Lines 341-355
sub _store_matchpoint {
Link Here
|
341 |
my $seqnum = 0; |
346 |
my $seqnum = 0; |
342 |
foreach my $component (@{ $matchpoint->{'components'} }) { |
347 |
foreach my $component (@{ $matchpoint->{'components'} }) { |
343 |
$seqnum++; |
348 |
$seqnum++; |
344 |
$sth = $dbh->prepare_cached("INSERT INTO matchpoint_components |
349 |
$sth = $dbh->prepare_cached( |
345 |
(matchpoint_id, sequence, tag, subfields, `offset`, length) |
350 |
"INSERT INTO matchpoint_components |
346 |
VALUES (?, ?, ?, ?, ?, ?)"); |
351 |
(matchpoint_id, sequence, tag, subfields, `offset`, length, `constant`) |
|
|
352 |
VALUES (?, ?, ?, ?, ?, ?, ?)" |
353 |
); |
347 |
$sth->bind_param(1, $matchpoint_id); |
354 |
$sth->bind_param(1, $matchpoint_id); |
348 |
$sth->bind_param(2, $seqnum); |
355 |
$sth->bind_param(2, $seqnum); |
349 |
$sth->bind_param(3, $component->{'tag'}); |
356 |
$sth->bind_param(3, $component->{'tag'}); |
350 |
$sth->bind_param(4, join "", sort keys %{ $component->{'subfields'} }); |
357 |
$sth->bind_param(4, join "", sort keys %{ $component->{'subfields'} }); |
351 |
$sth->bind_param(5, $component->{'offset'}||0); |
358 |
$sth->bind_param(5, $component->{'offset'}||0); |
352 |
$sth->bind_param(6, $component->{'length'}); |
359 |
$sth->bind_param(6, $component->{'length'}); |
|
|
360 |
$sth->bind_param( 7, $component->{'constant'} ); |
353 |
$sth->execute(); |
361 |
$sth->execute(); |
354 |
my $matchpoint_component_id = $dbh->{'mysql_insertid'}; |
362 |
my $matchpoint_component_id = $dbh->{'mysql_insertid'}; |
355 |
my $normseq = 0; |
363 |
my $normseq = 0; |
Lines 552-560
to the source string.
Link Here
|
552 |
|
560 |
|
553 |
sub add_required_check { |
561 |
sub add_required_check { |
554 |
my $self = shift; |
562 |
my $self = shift; |
555 |
my ($source_matchpoint, $target_matchpoint) = @_; |
563 |
my ( $source_matchpoint, $target_matchpoint, $operator ) = @_; |
556 |
|
564 |
|
557 |
my $matchcheck = {}; |
565 |
my $matchcheck = { 'operator' => $operator }; |
558 |
$matchcheck->{'source_matchpoint'}->{'index'} = ''; |
566 |
$matchcheck->{'source_matchpoint'}->{'index'} = ''; |
559 |
$matchcheck->{'source_matchpoint'}->{'score'} = 0; |
567 |
$matchcheck->{'source_matchpoint'}->{'score'} = 0; |
560 |
$matchcheck->{'source_matchpoint'}->{'components'} = []; |
568 |
$matchcheck->{'source_matchpoint'}->{'components'} = []; |
Lines 903-913
sub _parse_match_component {
Link Here
|
903 |
my $input_component = shift; |
911 |
my $input_component = shift; |
904 |
|
912 |
|
905 |
my $component = {}; |
913 |
my $component = {}; |
906 |
$component->{'tag'} = $input_component->{'tag'}; |
914 |
if ( $input_component->{'type'} eq 'constant' ) { |
907 |
$component->{'subfields'} = { map { $_ => 1 } split(//, $input_component->{'subfields'}) }; |
915 |
$component->{'tag'} = ''; |
908 |
$component->{'offset'} = exists($input_component->{'offset'}) ? $input_component->{'offset'} : -1; |
916 |
$component->{'subfields'} = {}; |
909 |
$component->{'length'} = $input_component->{'length'} ? $input_component->{'length'} : 0; |
917 |
$component->{'offset'} = 0; |
910 |
$component->{'norms'} = $input_component->{'norms'} ? $input_component->{'norms'} : []; |
918 |
$component->{'length'} = 0; |
|
|
919 |
$component->{'norms'} = []; |
920 |
$component->{'constant'} = $input_component->{'constant'}; |
921 |
} else { |
922 |
$component->{'tag'} = $input_component->{'tag'}; |
923 |
$component->{'subfields'} = { map { $_ => 1 } split( //, $input_component->{'subfields'} ) }; |
924 |
$component->{'offset'} = exists( $input_component->{'offset'} ) ? $input_component->{'offset'} : -1; |
925 |
$component->{'length'} = $input_component->{'length'} ? $input_component->{'length'} : 0; |
926 |
$component->{'norms'} = $input_component->{'norms'} ? $input_component->{'norms'} : []; |
927 |
$component->{'constant'} = undef; |
928 |
} |
911 |
|
929 |
|
912 |
return $component; |
930 |
return $component; |
913 |
} |
931 |
} |