Lines 48-53
BEGIN {
Link Here
|
48 |
@ISA = qw(Exporter); |
48 |
@ISA = qw(Exporter); |
49 |
@EXPORT_OK = qw( |
49 |
@EXPORT_OK = qw( |
50 |
FindDuplicate |
50 |
FindDuplicate |
|
|
51 |
FindBiblioFromMetadata |
51 |
SimpleSearch |
52 |
SimpleSearch |
52 |
searchResults |
53 |
searchResults |
53 |
getRecords |
54 |
getRecords |
Lines 80-86
This module provides searching functions for Koha's bibliographic databases
Link Here
|
80 |
|
81 |
|
81 |
=head2 FindDuplicate |
82 |
=head2 FindDuplicate |
82 |
|
83 |
|
83 |
($biblionumber,$biblionumber,$title) = FindDuplicate($record); |
84 |
($biblionumber,$title) = FindDuplicate($record); |
84 |
|
85 |
|
85 |
This function attempts to find duplicate records using a hard-coded, fairly simplistic algorithm |
86 |
This function attempts to find duplicate records using a hard-coded, fairly simplistic algorithm |
86 |
|
87 |
|
Lines 88-124
This function attempts to find duplicate records using a hard-coded, fairly simp
Link Here
|
88 |
|
89 |
|
89 |
sub FindDuplicate { |
90 |
sub FindDuplicate { |
90 |
my ($record) = @_; |
91 |
my ($record) = @_; |
91 |
my $dbh = C4::Context->dbh; |
92 |
my $result = TransformMarcToKoha( { record => $record } ); |
92 |
my $result = TransformMarcToKoha( { record => $record } ); |
93 |
return FindBiblioFromMetadata($result); |
93 |
my $sth; |
94 |
} |
|
|
95 |
|
96 |
=head2 FindBiblioFromMetadata |
97 |
|
98 |
($biblionumber, $title) = FindBiblioFromData($data); |
99 |
|
100 |
This function attempts to find records matching data using a hard-coded, fairly simplistic algorithm |
101 |
|
102 |
=cut |
103 |
|
104 |
sub FindBiblioFromMetadata { |
105 |
my $data = shift; |
94 |
my $query; |
106 |
my $query; |
95 |
|
107 |
|
96 |
# search duplicate on ISBN, easy and fast.. |
108 |
# search duplicate on ISBN, easy and fast.. |
97 |
# ... normalize first |
109 |
# ... normalize first |
98 |
if ( $result->{isbn} ) { |
110 |
if ( $data->{isbn} ) { |
99 |
$result->{isbn} =~ s/\(.*$//; |
111 |
$data->{isbn} =~ s/\(.*$//; |
100 |
$result->{isbn} =~ s/\s+$//; |
112 |
$data->{isbn} =~ s/\s+$//; |
101 |
$result->{isbn} =~ s/\|/OR/; |
113 |
$data->{isbn} =~ s/\|/OR/; |
102 |
$query = "isbn:$result->{isbn}"; |
114 |
$query = "isbn:$data->{isbn}"; |
103 |
} else { |
115 |
} else { |
104 |
|
116 |
|
105 |
my $titleindex = 'ti,ext'; |
117 |
my $titleindex = 'ti,ext'; |
106 |
my $authorindex = 'au,ext'; |
118 |
my $authorindex = 'au,ext'; |
107 |
my $op = 'AND'; |
119 |
my $op = 'AND'; |
108 |
|
120 |
|
109 |
$result->{title} =~ s /\\//g; |
121 |
$data->{title} =~ s /\\//g; |
110 |
$result->{title} =~ s /\"//g; |
122 |
$data->{title} =~ s /\"//g; |
111 |
$result->{title} =~ s /\(//g; |
123 |
$data->{title} =~ s /\(//g; |
112 |
$result->{title} =~ s /\)//g; |
124 |
$data->{title} =~ s /\)//g; |
113 |
|
125 |
|
114 |
$query = "$titleindex:\"$result->{title}\""; |
126 |
$query = "$titleindex:\"$data->{title}\""; |
115 |
if ( $result->{author} ) { |
127 |
if ( $data->{author} ) { |
116 |
$result->{author} =~ s /\\//g; |
128 |
$data->{author} =~ s /\\//g; |
117 |
$result->{author} =~ s /\"//g; |
129 |
$data->{author} =~ s /\"//g; |
118 |
$result->{author} =~ s /\(//g; |
130 |
$data->{author} =~ s /\(//g; |
119 |
$result->{author} =~ s /\)//g; |
131 |
$data->{author} =~ s /\)//g; |
120 |
|
132 |
|
121 |
$query .= " $op $authorindex:\"$result->{author}\""; |
133 |
$query .= " $op $authorindex:\"$data->{author}\""; |
122 |
} |
134 |
} |
123 |
} |
135 |
} |
124 |
|
136 |
|