generate tsv with biblionumber -> eprintid mapping
[koha-eprints] / ffzg-search.pl
index 553842c..8e3f77f 100755 (executable)
@@ -11,10 +11,13 @@ use Storable;
 
 use EPrints;
 
+my $repository_name = shift @ARGV || 'ffzg';
+warn "# repository name: $repository_name";
+
 my $stat;
 
 my $ep = EPrints->new();
-my $repo = $ep->repository( 'ffzg' );
+my $repo = $ep->repository( $repository_name );
 #$repo->{config}->{enable_file_imports} = 1;
 #$repo->{config}->{enable_web_imports} = 1;
 my $dataset = $repo->dataset( 'eprint' );
@@ -26,6 +29,8 @@ warn ref( $list );
 
 warn "# ids = ",dump( $list->ids );
 
+open(my $tsv_fh, '>', "/tmp/$repository_name.biblionumber.eprintid");
+
 my $info = { count => 0 };
 $list->map( sub {
        my( $session, $dataset, $eprint, $info ) = @_;
@@ -35,6 +40,9 @@ $list->map( sub {
                if ($#{ $info->{biblionumber}->{$biblionumber} } >= 1 ) {
                        $eprint->delete;
                        warn "# DELETE duplicate $biblionumber ", $eprint->id;
+               } else {
+                       print $tsv_fh "$biblionumber\t", $eprint->id, "\n";
+                       $info->{have_biblionumber}++;
                }
        } else {
                $info->{no_biblionumber}++;
@@ -45,3 +53,5 @@ $list->map( sub {
 warn "# map info ",dump( $info );
 
 warn "# stat ", dump($stat);
+
+system "ls -alt /tmp/$repository_name*";