Bugzilla – Attachment 7083 Details for
Bug 7284
Authority matching algorithm improvements
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 7284: Clean up authority code and add tests
Bug-7284-Clean-up-authority-code-and-add-tests.patch (text/plain), 6.61 KB, created by
Jared Camins-Esakov
on 2012-01-07 22:32:58 UTC
(
hide
)
Description:
Bug 7284: Clean up authority code and add tests
Filename:
MIME Type:
Creator:
Jared Camins-Esakov
Created:
2012-01-07 22:32:58 UTC
Size:
6.61 KB
patch
obsolete
>From 51b06aa3c2feffe1f427f91dc466ff5b8245d23d Mon Sep 17 00:00:00 2001 >From: Jared Camins-Esakov <jcamins@cpbibliography.com> >Date: Sat, 31 Dec 2011 12:17:41 -0500 >Subject: [PATCH] Bug 7284: Clean up authority code and add tests >Content-Type: text/plain; charset="UTF-8" > >Cleaned up authorities code by removing unused functions and adding >unimplemented functions and added some unit tests. >--- > C4/AuthoritiesMarc.pm | 71 ++++-------------------- > C4/Heading.pm | 19 +++++- > t/Heading_MARC21.t | 8 ++- > t/db_dependent/lib/KohaTest/AuthoritiesMarc.pm | 1 - > 4 files changed, 33 insertions(+), 66 deletions(-) > >diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm >index b3c5070..e55183a 100644 >--- a/C4/AuthoritiesMarc.pm >+++ b/C4/AuthoritiesMarc.pm >@@ -17,9 +17,8 @@ package C4::AuthoritiesMarc; > # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. > > use strict; >-#use warnings; FIXME - Bug 2505 >+use warnings; > use C4::Context; >-use C4::Koha; > use MARC::Record; > use C4::Biblio; > use C4::Search; >@@ -41,7 +40,6 @@ BEGIN { > &GetAuthType > &GetAuthTypeCode > &GetAuthMARCFromKohaField >- &AUTHhtml2marc > > &AddAuthority > &ModAuthority >@@ -251,7 +249,7 @@ sub SearchAuthorities { > }#if value > } > ##Add how many queries generated >- if ($query=~/\S+/){ >+ if (defined $query && $query=~/\S+/){ > $query= $and x $attr_cnt . $query . $q2; > } else { > $query= $q2; >@@ -854,53 +852,6 @@ sub GetAuthType { > } > > >-sub AUTHhtml2marc { >- my ($rtags,$rsubfields,$rvalues,%indicators) = @_; >- my $dbh=C4::Context->dbh; >- my $prevtag = -1; >- my $record = MARC::Record->new(); >-#---- TODO : the leader is missing >- >-# my %subfieldlist=(); >- my $prevvalue; # if tag <10 >- my $field; # if tag >=10 >- for (my $i=0; $i< @$rtags; $i++) { >- # rebuild MARC::Record >- if (@$rtags[$i] ne $prevtag) { >- if ($prevtag < 10) { >- if ($prevvalue) { >- $record->add_fields((sprintf "%03s",$prevtag),$prevvalue); >- } >- } else { >- if ($field) { >- $record->add_fields($field); >- } >- } >- $indicators{@$rtags[$i]}.=' '; >- if (@$rtags[$i] <10) { >- $prevvalue= @$rvalues[$i]; >- undef $field; >- } else { >- undef $prevvalue; >- $field = MARC::Field->new( (sprintf "%03s",@$rtags[$i]), substr($indicators{@$rtags[$i]},0,1),substr($indicators{@$rtags[$i]},1,1), @$rsubfields[$i] => @$rvalues[$i]); >- } >- $prevtag = @$rtags[$i]; >- } else { >- if (@$rtags[$i] <10) { >- $prevvalue=@$rvalues[$i]; >- } else { >- if (length(@$rvalues[$i])>0) { >- $field->add_subfields(@$rsubfields[$i] => @$rvalues[$i]); >- } >- } >- $prevtag= @$rtags[$i]; >- } >- } >- # the last has not been included inside the loop... do it now ! >- $record->add_fields($field) if $field; >- return $record; >-} >- > =head2 FindDuplicateAuthority > > $record= &FindDuplicateAuthority( $record, $authtypecode) >@@ -1015,14 +966,14 @@ sub BuildSummary{ > $resultstring =~ s/\n/<br>/g; > $summary = $resultstring; > } else { >- my $heading; >- my $altheading; >- my $seealso; >- my $broaderterms; >- my $narrowerterms; >- my $see; >- my $seeheading; >- my $notes; >+ my $heading = ''; >+ my $altheading = ''; >+ my $seealso = ''; >+ my $broaderterms = ''; >+ my $narrowerterms = ''; >+ my $see = ''; >+ my $seeheading = ''; >+ my $notes = ''; > my @fields = $record->fields(); > if (C4::Context->preference('marcflavour') eq 'UNIMARC') { > # construct UNIMARC summary, that is quite different from MARC21 one >@@ -1471,7 +1422,7 @@ sub get_auth_type_location { > my $auth_type_code = @_ ? shift : ''; > > my ($tag, $subfield) = GetAuthMARCFromKohaField('auth_header.authtypecode', $auth_type_code); >- if (defined $tag and defined $subfield and $tag != 0 and $subfield != 0) { >+ if (defined $tag and defined $subfield and $tag != 0 and $subfield ne '' and $subfield ne ' ') { > return ($tag, $subfield); > } else { > if (C4::Context->preference('marcflavour') eq "MARC21") { >diff --git a/C4/Heading.pm b/C4/Heading.pm >index ba9d23f..ff7a198 100644 >--- a/C4/Heading.pm >+++ b/C4/Heading.pm >@@ -18,7 +18,7 @@ package C4::Heading; > # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. > > use strict; >-#use warnings; FIXME - Bug 2505 >+use warnings; > use MARC::Record; > use MARC::Field; > use C4::Context; >@@ -38,8 +38,8 @@ C4::Heading > my $heading = C4::Heading->new_from_bib_field($field); > my $thesaurus = $heading->thesaurus(); > my $type = $heading->type(); >- my $display_heading = $heading->display(); >- my $search_string = $heading->search_string(); >+ my $display_heading = $heading->display_form(); >+ my $search_form = $heading->search_form(); > > =head1 DESCRIPTION > >@@ -96,6 +96,19 @@ sub display_form { > return $self->{'display_form'}; > } > >+=head2 search_form >+ >+ my $search_form = $heading->search_form(); >+ >+Return the "canonical" search form of the heading. >+ >+=cut >+ >+sub search_form { >+ my $self = shift; >+ return $self->{'search_form'}; >+} >+ > =head2 authorities > > my $authorities = $heading->authorities; >diff --git a/t/Heading_MARC21.t b/t/Heading_MARC21.t >index a0ca21b..198eaea 100755 >--- a/t/Heading_MARC21.t >+++ b/t/Heading_MARC21.t >@@ -6,9 +6,13 @@ > use strict; > use warnings; > >-use Test::More tests => 1; >+use Test::More tests => 3; > > BEGIN { >- use_ok('C4::External::Amazon'); >+ use_ok('C4::Heading'); > } > >+my $field = MARC::Field->new( '650', ' ', '0', a => 'Uncles', x => 'Fiction' ); >+my $heading = C4::Heading->new_from_bib_field($field); >+is($heading->display_form(), 'Uncles--Fiction', 'Display form generation'); >+is($heading->search_form(), 'Uncles generalsubdiv Fiction', 'Search form generation'); >diff --git a/t/db_dependent/lib/KohaTest/AuthoritiesMarc.pm b/t/db_dependent/lib/KohaTest/AuthoritiesMarc.pm >index 6114843..4938ccf 100644 >--- a/t/db_dependent/lib/KohaTest/AuthoritiesMarc.pm >+++ b/t/db_dependent/lib/KohaTest/AuthoritiesMarc.pm >@@ -24,7 +24,6 @@ sub methods : Test( 1 ) { > GetAuthorityXML > GetAuthority > GetAuthType >- AUTHhtml2marc > FindDuplicateAuthority > BuildSummary > BuildUnimarcHierarchies >-- >1.7.2.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 7284
:
7083
|
7084
|
7085
|
7086
|
7087
|
7091
|
7266
|
7323
|
7457
|
7548
|
7688
|
7714
|
7788
|
7829
|
7938
|
8060
|
8066
|
8137
|
8862
|
8864