[Koha-patches] [PATCH] Analytical records: storing bibnumber and itemnumber in subfields 0 and 9, plus other mapping changes

savitra.sirohi at osslabs.biz savitra.sirohi at osslabs.biz
Thu Dec 2 12:31:49 CET 2010


From: Savitra Sirohi <savitra.sirohi at osslabs.biz>

---
 C4/Biblio.pm           |   51 +++++++++++++++++++++++++++++++++++++++++------
 C4/Items.pm            |    8 +++---
 cataloguing/additem.pl |   10 ++++----
 3 files changed, 53 insertions(+), 16 deletions(-)

diff --git a/C4/Biblio.pm b/C4/Biblio.pm
index eb6ea42..ae51609 100644
--- a/C4/Biblio.pm
+++ b/C4/Biblio.pm
@@ -1569,9 +1569,9 @@ sub GetMarcHosts {
     $marcflavour ||="MARC21";
     if ( $marcflavour eq "MARC21" ) {
         $tag = "773";
-        $title_subf = "a";
-        $bibnumber_subf ="w";
-        $itemnumber_subf='o';
+        $title_subf = "t";
+        $bibnumber_subf ="0";
+        $itemnumber_subf='9';
     }
     elsif ($marcflavour eq "UNIMARC") {
         $tag = "461";
@@ -1675,13 +1675,50 @@ This function returns a host field populated with data from the host record, the
 sub PrepHostMarcField {
 	my ($hostbiblionumber,$hostitemnumber) = @_;
         my $hostrecord = GetMarcBiblio($hostbiblionumber);
+	my $item = C4::Items::GetItem($hostitemnumber);
+
+	#main entry
+	my $mainentry;
+	if ($hostrecord->subfield('100','a')){
+		$mainentry = $hostrecord->subfield('100','a');
+	} elsif ($hostrecord->subfield('110','a')){
+		$mainentry = $hostrecord->subfield('110','a');
+	} else {
+		$mainentry = $hostrecord->subfield('111','a');
+	}
+
+	#other fields
+	my $ed = $hostrecord->subfield('250','a');
+	my $qualinfo = $hostrecord->subfield('260','a').(", ".$hostrecord->subfield('260','a')).(", ".$hostrecord->subfield('260','c'));
+	my $barcode = $item->{'barcode'};
+	my $title = $hostrecord->subfield('245','a');
+	
+	# record control number, 001 with 003 and prefix
+	my $recctrlno;
+	if ($hostrecord->field('001')){
+		$recctrlno = $hostrecord->field('001')->data();
+		if ($hostrecord->field('003')){
+			$recctrlno = '('.$hostrecord->field('003')->data().')'.$recctrlno;
+		}
+	}
+
+	# issn/isbn
+	my $issn = $hostrecord->subfield('022','a');
+	my $isbn = $hostrecord->subfield('020','a');
+	
 
 	my $hostmarcfield = MARC::Field->new(
 			773, '', '',
-			'w' => $hostbiblionumber,
-                        'o' => $hostitemnumber,
-                        'a' => $hostrecord->subfield('245','a'),
-                        'x' => $hostrecord->subfield('245','x')
+			'0' => $hostbiblionumber,
+                        '9' => $hostitemnumber,
+                        'a' => $mainentry,
+			'b' => $ed,
+			'd' => $qualinfo,
+			'o' => $barcode,
+			't' => $title,
+			'w' => $recctrlno,
+			'x' => $issn,
+			'z' => $isbn
                 );
 
     return $hostmarcfield;
diff --git a/C4/Items.pm b/C4/Items.pm
index 1f82db1..a908356 100644
--- a/C4/Items.pm
+++ b/C4/Items.pm
@@ -1334,8 +1334,8 @@ sub GetHostItemsInfo {
 
 	#MARC21 mapping, UNIMARC to be added
 	foreach my $hostfield ( $record->field('773') ) {
-        	my $hostbiblionumber = $hostfield->subfield("w");
-	        my $linkeditemnumber = $hostfield->subfield("o");
+        	my $hostbiblionumber = $hostfield->subfield("0");
+	        my $linkeditemnumber = $hostfield->subfield("9");
         	my @hostitemInfos = GetItemsInfo($hostbiblionumber);
 	        foreach my $hostitemInfo (@hostitemInfos){
         	        if ($hostitemInfo->{itemnumber} eq $linkeditemnumber){
@@ -1453,8 +1453,8 @@ sub get_hostitemnumbers_of {
 
         #MARC21 mapping, UNIMARC to be added
         foreach my $hostfield ( $marcrecord->field('773') ) {
-                my $hostbiblionumber = $hostfield->subfield("w");
-                my $linkeditemnumber = $hostfield->subfield("o");
+                my $hostbiblionumber = $hostfield->subfield("0");
+                my $linkeditemnumber = $hostfield->subfield("9");
 		my @itemnumbers;
                 if (my $itemnumbers = get_itemnumbers_of($hostbiblionumber)->{$hostbiblionumber})
 		{
diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl
index 32c7a4f..816e884 100755
--- a/cataloguing/additem.pl
+++ b/cataloguing/additem.pl
@@ -303,7 +303,7 @@ if ($op eq "additem") {
     $nextop="additem";
 } elsif ($op eq "delinkitem"){
 	foreach my $field ($record->field('773')){
-		if ($field->subfield('o') eq $hostitemnumber){
+		if ($field->subfield('9') eq $hostitemnumber){
 			$record->delete_field($field);
 			last;
 		}
@@ -323,12 +323,12 @@ my @fields = $temp->fields();
 
 my @hostitemnumbers;
 foreach my $hostfield ($temp->field('773')){
-	if ($hostfield->subfield('w')){
-		my $hostrecord = GetMarcBiblio($hostfield->subfield('w'));
+	if ($hostfield->subfield('0')){
+		my $hostrecord = GetMarcBiblio($hostfield->subfield('0'));
 		foreach my $hostitem ($hostrecord->field('952')){
-			if ($hostitem->subfield('9') eq $hostfield->subfield('o')){
+			if ($hostitem->subfield('9') eq $hostfield->subfield('9')){
 				push (@fields, $hostitem);
-				push (@hostitemnumbers, $hostfield->subfield('o'));
+				push (@hostitemnumbers, $hostfield->subfield('9'));
 			}
 		}
 	}
-- 
1.5.4.5



More information about the Koha-patches mailing list