[Koha-cvs] koha/misc/migration_tools check_marc_definition.pl [rel_2_2]
paul poulain
paul at koha-fr.org
Tue Sep 12 11:27:39 CEST 2006
CVSROOT: /cvsroot/koha
Module name: koha
Branch: rel_2_2
Changes by: paul poulain <tipaul> 06/09/12 09:27:39
Modified files:
misc/migration_tools: check_marc_definition.pl
Log message:
improving check_marc_definition.pl to be able to automatically set used subfields & unset unused subfields (run without parameters to see new parameters)
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/misc/migration_tools/check_marc_definition.pl?cvsroot=koha&only_with_tag=rel_2_2&r1=1.1.2.3&r2=1.1.2.4
Patches:
Index: check_marc_definition.pl
===================================================================
RCS file: /cvsroot/koha/koha/misc/migration_tools/check_marc_definition.pl,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -b -r1.1.2.3 -r1.1.2.4
--- check_marc_definition.pl 16 Jun 2005 15:45:59 -0000 1.1.2.3
+++ check_marc_definition.pl 12 Sep 2006 09:27:39 -0000 1.1.2.4
@@ -14,11 +14,13 @@
use Getopt::Long;
my ( $input_marc_file, $number) = ('',0);
-my ($version,$confirm,$all);
+my ($version,$confirm,$all,$autoclean,$autoactivate);
GetOptions(
'h' => \$version,
'c' => \$confirm,
'a' => \$all,
+ 'l' => \$autoclean,
+ 'm' => \$autoactivate,
);
if ($version || ($confirm eq '')) {
@@ -27,6 +29,8 @@
It show all fields/subfields that are in the MARC DB but NOT in any tab (= fields used but not visible) Usually, this means you made an error in your MARC editor. Sometimes, this is something normal.
options
+\t-l : autoclean => all unused subfields will be unactivated automatically in frameworks. Use carefully !!!!
+\t-m : autoactivate => all subfields used but unactivated will automatically be activated in tab 1. Use carrefully !!!
\t-a : will show all subfields usages, not only subfields in tab ignore that are used.
Enter $0 -c to run this script (the -c being here only to "confirm"
EOF
@@ -43,6 +47,7 @@
if ($all) {
print "framework|tag|subfield|value|used|tab\n";
}
+my $sth3 = $dbh->prepare("update marc_subfield_structure set tab=1 where frameworkcode=? and tagfield=? and tagsubfield=?");
while (my ($total,$tag,$subfield,$frameworkcode) = $sth->fetchrow) {
$sth2->execute($tag,$subfield,$frameworkcode);
$tags{$frameworkcode." / ".$tag." / ".$subfield} ++;
@@ -52,6 +57,8 @@
} else {
if ($tab eq -1 && $kohafield ne "biblio.biblionumber" && $kohafield ne "biblioitems.biblioitemnumber" && $kohafield ne "items.itemnumber") {
print "Tab ignore for framework $frameworkcode, $tag\$$subfield - $liblibrarian (used $total times)\n";
+ $sth3->execute($frameworkcode,$tag,$subfield) if $autoactivate && tab eq -1;
+
}
}
}
@@ -59,7 +66,12 @@
$sth = $dbh->prepare("select frameworkcode,tagfield,tagsubfield from marc_subfield_structure where tab<>-1 order by frameworkcode,tagfield,tagsubfield");
$sth->execute;
print "===================\n";
+# for autoclean...
+my $sth2 = $dbh->prepare("update marc_subfield_structure set tab=-1 where frameworkcode=? and tagfield=? and tagsubfield=?");
while (my ($frameworkcode,$tag,$subfield) = $sth->fetchrow) {
- print "$tag, $subfield in framework $frameworkcode is active, but never filled\n" unless $tags{$frameworkcode." / ".$tag." / ".$subfield};
+ print "$tag, $subfield in framework $frameworkcode is active, but never filled" unless $tags{$frameworkcode." / ".$tag." / ".$subfield};
+ print "... auto cleaned" if $autoclean;
+ print "\n" unless $tags{$frameworkcode." / ".$tag." / ".$subfield};
+ $sth2->execute($frameworkcode,$tag,$subfield) if $autoclean;
}
print "Done\n";
More information about the Koha-cvs
mailing list