-
Notifications
You must be signed in to change notification settings - Fork 1
/
mk_symplectic_config.pl
executable file
·60 lines (48 loc) · 1.07 KB
/
mk_symplectic_config.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
#!/usr/bin/perl -w
use FindBin;
use lib "$FindBin::Bin/../../../../../perl_lib";
# generate symplectic_xwalks_toolkit_config_eprints.xml
use EPrints;
use XML::Simple;
use strict;
my $repoid = $ARGV[0];
my $session = new EPrints::Session( 1 , $repoid );
if( !defined $session )
{
print STDERR "Failed to load repository: $repoid\n";
exit 1;
}
my @FIELDS;
my $dataset = $session->dataset( "eprint" );
foreach my $field ( $dataset->fields )
{
next if defined $field->{parent}; # skip subfields
my $F = {
name => $field->name,
type => $field->type,
};
$F->{multiple} = "true" if $field->property( "multiple" );
if( $field->type eq "compound" )
{
foreach my $subfield ( @{ $field->property( "fields" ) } )
{
push @{ $F->{"epconfig:subfield"} }, {
name => $subfield->{sub_name},
type => $subfield->{type},
};
}
}
push @FIELDS, $F;
}
print XMLout(
{
epconfig => {
"xmlns:epconfig" => "http://www.symplectic.co.uk/ep3/config",
"epconfig:fields" => {
"epconfig:field" => \@FIELDS,
},
},
},
RootName => undef,
);
$session->terminate();