#!/usr/bin/perl -I /usr/share/eprints3/perl_lib
use warnings;
use strict;
use autodie;
use utf8;

# export single record to get structure:
use Encode;
use Data::Dump qw(dump);
use Storable;

use EPrints;

my $stat;

my $ep = EPrints->new();
my $repo = $ep->repository( 'ffzg' );
#$repo->{config}->{enable_file_imports} = 1;
#$repo->{config}->{enable_web_imports} = 1;
my $dataset = $repo->dataset( 'eprint' );
my $list = $dataset->search;
my $count = $list->count;
warn "# found [$count] eprints\n";

warn ref( $list );

warn "# ids = ",dump( $list->ids );

my $info = { count => 0 };
$list->map( sub {
	my( $session, $dataset, $eprint, $info ) = @_;

	if ( my $biblionumber = $eprint->get_value('biblionumber') ) {
		push @{ $info->{biblionumber}->{$biblionumber} }, $eprint->id;
	} else {
		$info->{no_biblionumber}++;
	}
	$info->{count}++;

}, $info );
warn "# map info ",dump( $info );

warn "# stat ", dump($stat);
