-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathverify_data.pl
executable file
·72 lines (52 loc) · 1.36 KB
/
verify_data.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/perl -I/usr/share/eprints/perl_lib
use strict;
use warnings;
use EPrints;
my $repo_id = 'medmus';
my $repo = EPrints::Repository->new($repo_id);
die "Couldn't create repository: $repo_id\n" unless $repo;
my $seen = {};
$repo->dataset('eprint')->map(
$repo, sub
{
my ($repo, $ds, $item) = @_;
my $type = $item->value('medmus_type');
if ($type eq 'refrain')
{
my $p = $repo->call('refrain_parent', $item);
my $id = $item->value('refrain_id');
my $inst = $item->value('instance_number');
if ($seen->{$id}->{$inst})
{
$repo->log("Duplicate ID: r$id/$inst");
}
$seen->{'r'}->{$id}->{$inst}++
}
elsif ($type eq 'work')
{
my $h = $repo->call('work_host', $item);
#check we have at least one refrain or child work
my $rs = $repo->call('refrains_in_work', $item);
if (!$rs)
{
my $str = "No children for ";
$str .= $item->value('work_id') . '/' . $item->value('instance_number');
$repo->log($str);
}
my $id = $item->value('work_id');
my $inst = $item->value('instance_number');
if ($seen->{$id}->{$inst})
{
$repo->log("Duplicate ID: w$id/$inst");
}
$seen->{'w'}->{$id}->{$inst}++
}
else
{
$repo->loc("Item " . $item->value('id') . " has no type");
}
#count parent works
#count host works
#works - check we have at least one or work contained within
}
);