|
Lines 21-26
use base 'Exporter';
Link Here
|
| 21 |
BEGIN { |
21 |
BEGIN { |
| 22 |
our @EXPORT_OK = qw( |
22 |
our @EXPORT_OK = qw( |
| 23 |
FindDuplicate |
23 |
FindDuplicate |
|
|
24 |
FindBiblioFromMetadata |
| 24 |
SimpleSearch |
25 |
SimpleSearch |
| 25 |
searchResults |
26 |
searchResults |
| 26 |
getRecords |
27 |
getRecords |
|
Lines 90-124
sub FindDuplicate {
Link Here
|
| 90 |
my ($record) = @_; |
91 |
my ($record) = @_; |
| 91 |
my $dbh = C4::Context->dbh; |
92 |
my $dbh = C4::Context->dbh; |
| 92 |
my $result = TransformMarcToKoha( { record => $record } ); |
93 |
my $result = TransformMarcToKoha( { record => $record } ); |
|
|
94 |
return FindBiblioFromMetadata($result); |
| 95 |
} |
| 96 |
|
| 97 |
=head2 FindBiblioFromMetadata |
| 98 |
|
| 99 |
($biblionumber, $title) = FindBiblioFromMetadata($data); |
| 100 |
|
| 101 |
This function attempts to find records matching data using a hard-coded, fairly simplistic algorithm |
| 102 |
|
| 103 |
=cut |
| 104 |
|
| 105 |
sub FindBiblioFromMetadata { |
| 106 |
my $metadata = shift; |
| 93 |
my $sth; |
107 |
my $sth; |
| 94 |
my $query; |
108 |
my $query; |
| 95 |
|
109 |
|
| 96 |
# search duplicate on ISBN, easy and fast.. |
110 |
# search duplicate on ISBN, easy and fast.. |
| 97 |
# ... normalize first |
111 |
# ... normalize first |
| 98 |
if ( $result->{isbn} ) { |
112 |
if ( $metadata->{isbn} ) { |
| 99 |
$result->{isbn} =~ s/\(.*$//; |
113 |
$metadata->{isbn} =~ s/\(.*$//; |
| 100 |
$result->{isbn} =~ s/\s+$//; |
114 |
$metadata->{isbn} =~ s/\s+$//; |
| 101 |
$result->{isbn} =~ s/\|/OR/; |
115 |
$metadata->{isbn} =~ s/\|/OR/; |
| 102 |
$query = "isbn:$result->{isbn}"; |
116 |
$query = "isbn:$metadata->{isbn}"; |
| 103 |
} else { |
117 |
} else { |
| 104 |
|
118 |
|
| 105 |
my $titleindex = 'ti,ext'; |
119 |
my $titleindex = 'ti,ext'; |
| 106 |
my $authorindex = 'au,ext'; |
120 |
my $authorindex = 'au,ext'; |
| 107 |
my $op = 'AND'; |
121 |
my $op = 'AND'; |
| 108 |
|
122 |
|
| 109 |
$result->{title} =~ s /\\//g; |
123 |
$metadata->{title} =~ s /\\//g; |
| 110 |
$result->{title} =~ s /\"//g; |
124 |
$metadata->{title} =~ s /\"//g; |
| 111 |
$result->{title} =~ s /\(//g; |
125 |
$metadata->{title} =~ s /\(//g; |
| 112 |
$result->{title} =~ s /\)//g; |
126 |
$metadata->{title} =~ s /\)//g; |
| 113 |
|
127 |
|
| 114 |
$query = "$titleindex:\"$result->{title}\""; |
128 |
$query = "$titleindex:\"$metadata->{title}\""; |
| 115 |
if ( $result->{author} ) { |
129 |
if ( $metadata->{author} ) { |
| 116 |
$result->{author} =~ s /\\//g; |
130 |
$metadata->{author} =~ s /\\//g; |
| 117 |
$result->{author} =~ s /\"//g; |
131 |
$metadata->{author} =~ s /\"//g; |
| 118 |
$result->{author} =~ s /\(//g; |
132 |
$metadata->{author} =~ s /\(//g; |
| 119 |
$result->{author} =~ s /\)//g; |
133 |
$metadata->{author} =~ s /\)//g; |
| 120 |
|
134 |
|
| 121 |
$query .= " $op $authorindex:\"$result->{author}\""; |
135 |
$query .= " $op $authorindex:\"$metadata->{author}\""; |
| 122 |
} |
136 |
} |
| 123 |
} |
137 |
} |
| 124 |
|
138 |
|
|
Lines 132-143
sub FindDuplicate {
Link Here
|
| 132 |
$possible_duplicate_record |
146 |
$possible_duplicate_record |
| 133 |
); |
147 |
); |
| 134 |
|
148 |
|
| 135 |
my $result = TransformMarcToKoha( { record => $marcrecord } ); |
149 |
my $metadata = TransformMarcToKoha( { record => $marcrecord } ); |
| 136 |
|
150 |
|
| 137 |
# FIXME :: why 2 $biblionumber ? |
151 |
# FIXME :: why 2 $biblionumber ? |
| 138 |
if ($result) { |
152 |
if ($metadata) { |
| 139 |
push @results, $result->{'biblionumber'}; |
153 |
push @results, $metadata->{'biblionumber'}; |
| 140 |
push @results, $result->{'title'}; |
154 |
push @results, $metadata->{'title'}; |
| 141 |
} |
155 |
} |
| 142 |
} |
156 |
} |
| 143 |
} |
157 |
} |