# the marclist may contain "mainentry". In this case, search the tag_to_report, that depends on
# the authtypecode. Then, search on $a of this tag_to_report
+ # also store main entry MARC tag, to extract it at end of search
+ my $mainentrytag;
+ my $sth = $dbh->prepare("select auth_tag_to_report from auth_types where authtypecode=?");
+ $sth->execute($authtypecode);
+ my ($tag_to_report) = $sth->fetchrow;
+ $mainentrytag = $tag_to_report;
for (my $i=0;$i<$#{$tags};$i++) {
if (@$tags[$i] eq "mainentry") {
- my $sth = $dbh->prepare("select auth_tag_to_report from auth_types where authtypecode=?");
- $sth->execute($authtypecode);
- my ($tag_to_report) = $sth->fetchrow;
@$tags[$i] = $tag_to_report."a";
}
}
# "Normal" statements
# quote marc fields/subfields
for (my $i=0;$i<=$#{$tags};$i++) {
-# warn " $i: ".@$tags[$i];
if (@$tags[$i]) {
@$tags[$i] = $dbh->quote(@$tags[$i]);
-# warn " $i After process: ".@$tags[$i];
}
}
my @normal_tags = ();
# Extracts the NOT statements from the list of statements
for(my $i = 0 ; $i <= $#{$value} ; $i++)
{
+ # replace * by %
+ @$value[$i] =~ s/\*/%/g;
+ # remove % at the beginning
+ @$value[$i] =~ s/^%//g;
+ @$value[$i] =~ s/(\.|\?|\:|\!|\'|,|\-|\"|\(|\)|\[|\]|\{|\}|\/)/ /g if @$operator[$i] eq "contains";
if(@$operator[$i] eq "contains") # if operator is contains, splits the words in separate requests
{
foreach my $word (split(/ /, @$value[$i]))
$newline{authid} = $result[$counter];
$newline{used} = &AUTHcount_usage($result[$counter]);
$newline{biblio_fields} = $tags_using_authtype;
+ $newline{even} = $counter % 2;
+ $newline{mainentry} = $record->field($mainentrytag)->subfield('a') if $record->field($mainentrytag);
$counter++;
push @finalresult, \%newline;
}
sub FindDuplicate {
my ($record,$authtypecode)=@_;
+ warn "IN for ".$record->as_formatted;
my $dbh = C4::Context->dbh;
-
+
# warn "".$record->as_formatted;
- # search duplicate on ISBN, easy and fast...
my $sth = $dbh->prepare("select auth_tag_to_report,summary from auth_types where authtypecode=?");
$sth->execute($authtypecode);
my ($auth_tag_to_report,$taglist) = $sth->fetchrow;
$sth->finish;
- # a more complex search : build a request for authoritysearch
+ # build a request for authoritysearch
my (@tags, @and_or, @excluding, @operator, @value, $offset, $length);
# search on biblio.title
# warn " tag a reporter : $auth_tag_to_report";
- warn "taglist ".$taglist;
+# warn "taglist ".$taglist;
my @subfield = split /\[/, $taglist;
my $max = @subfield;
for (my $i=1; $i<$max;$i++){
warn " ".$subfield[$i];
$subfield[$i]=substr($subfield[$i],3,1);
- warn " ".$subfield[$i];
+# warn " ".$subfield[$i];
}
if ($record->fields($auth_tag_to_report)) {
-# foreach my $subfieldcount (1..$#subfield){
-# if ($record->field($auth_tag_to_report)->subfields($subfield[$subfieldcount])) {
-# # warn "tag :".$tag." subfield: $subfield value : ".$record->field($tag)->subfield($subfield);
-# push @tags, $auth_tag_to_report.$subfield[$subfieldcount];
-# # warn "'".$tag.$subfield."' value :". $record->field($tag)->subfield($subfield);
-# push @and_or, "and";
-# push @excluding, "";
-# push @operator, "contains";
-# push @value, $record->field($auth_tag_to_report)->subfield($subfield[$subfieldcount]);
-# }
-# }
-
- my $sth = $dbh->prepare("select tagfield,tagsubfield from auth_subfield_structure where tagfield=? and authtypecode=? ");
- $sth->execute($auth_tag_to_report,$authtypecode);
- # warn " field $auth_tag_to_report exists";
- while (my ($tag,$subfield) = $sth->fetchrow){
- if ($record->field($tag)->subfield($subfield)) {
- # warn "tag :".$tag." subfield: $subfield value : ".$record->field($tag)->subfield($subfield);
- push @tags, $tag.$subfield;
- # warn "'".$tag.$subfield."' value :". $record->field($tag)->subfield($subfield);
- push @and_or, "and";
- push @excluding, "";
- push @operator, "contains";
- push @value, $record->field($tag)->subfield($subfield);
- }
- }
- }
+ my $sth = $dbh->prepare("select tagfield,tagsubfield from auth_subfield_structure where tagfield=? and authtypecode=? ");
+ $sth->execute($auth_tag_to_report,$authtypecode);
+# warn " field $auth_tag_to_report exists";
+ while (my ($tag,$subfield) = $sth->fetchrow){
+ if ($record->field($tag)->subfield($subfield)) {
+ warn "tag :".$tag." subfield: $subfield value : ".$record->field($tag)->subfield($subfield);
+ push @tags, $tag.$subfield;
+# warn "'".$tag.$subfield."' value :". $record->field($tag)->subfield($subfield);
+ push @and_or, "and";
+ push @excluding, "";
+ push @operator, "=";
+ push @value, $record->field($tag)->subfield($subfield);
+ }
+ }
+ }
my ($finalresult,$nbresult) = authoritysearch($dbh,\@tags,\@and_or,\@excluding,\@operator,\@value,0,10,$authtypecode);
# there is at least 1 result => return the 1st one
if ($nbresult) {
- warn "$nbresult => ".@$finalresult[0]->{authid},$record->field($auth_tag_to_report)->subfield('a');
- return @$finalresult[0]->{authid},@$finalresult[0]->{authid},$record->field($auth_tag_to_report)->subfield('a');
+ warn "XXXXX $nbresult => ".@$finalresult[0]->{authid},@$finalresult[0]->{summary};
+ return @$finalresult[0]->{authid},@$finalresult[0]->{summary};
}
# no result, returns nothing
return;
}
+
END { } # module clean-up code here (global destructor)
=back
# $Id$
# $Log$
-# Revision 1.14 2005/04/05 17:07:46 hdl
-# Scanning every the Subfields of auth_tag_to_report for FindDuplicate
-#
-# Revision 1.13 2005/04/05 15:23:41 hdl
-# Searching for double entries when adding a new authority.
+# Revision 1.17 2005/06/01 12:51:02 tipaul
+# some fixes & improvements for dictionnary search in librarian interface
#
-# Revision 1.12 2005/04/05 09:58:48 hdl
-# Adding double authority search before creating a new authority
+# Revision 1.16 2005/05/04 15:43:43 tipaul
+# synch'ing 2.2 and head
#
-# Revision 1.11 2005/03/07 08:55:29 tipaul
-# synch'ing with 2.2
+# Revision 1.9.2.3 2005/04/28 08:45:33 tipaul
+# porting FindDuplicate feature for authorities from HEAD to rel_2_2, works correctly now.
#
# Revision 1.9.2.2 2005/02/28 14:03:13 tipaul
# * adding search on "main entry" (ie $a subfield) on a given authority (the "search everywhere" field is still here).