-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreate-ids.pl
More file actions
executable file
·99 lines (79 loc) · 2.19 KB
/
Copy pathcreate-ids.pl
File metadata and controls
executable file
·99 lines (79 loc) · 2.19 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/env perl
use Getopt::Long qw/GetOptions/;
use Pod::Usage qw/pod2usage/;
use Gcis::Client;
use Data::Dumper;
use YAML::XS qw/Dump Load/;
use Org;
use strict;
use v5.14;
my $n_max = 40;
my @nasa_orgs = (
'national-aeronautics-space-administration',
'national-snow-ice-data-center-distributed-active-archive-center',
'oak-ridge-national-laboratory-distributed-active-archive-center',
);
my @nasa_daacs = qw(NSIDC ORNL LARC SEDAC LANCE GSFC);
# my $url = qq(https://data.gcis-dev-front.joss.ucar.edu);
my $url = qq(https://data-stage.globalchange.gov);
# my $url = qq(http://data.globalchange.gov);
&main;
sub main {
my $g = Gcis::Client->new(url => $url);
my $o = Org->new($g);
my $r = load_list();
my @d;
my $i = 0;
for (sort keys %$r) {
$i++;
last if $n_max > 1 && $i > $n_max;
my $n = $_;
my $c = $r->{$n};
my $v = $c->{organization};
my $u = $o->uri($v) or next;
next unless grep $u eq "/organization/$_", @nasa_orgs;
next unless $c->{landingPage} =~ /reverb/;
if (!(grep $c->{landingPage} =~ "@_", @nasa_daacs)) {
" warning - not a NASA DAAC : $c->{landingPage}";
next;
}
my %s;
$s{name} = $n;
$s{organization} = $v;
$s{uri} = $u;
$s{echoId} = $c->{idAgency};
$s{landingPage} = $c->{landingPage};
push @d, \%s;
}
say Dump(\@d);
}
sub load_list {
my $yml = do { local $/; <> };
my $e = Load($yml);
my %r;
for (@$e) {
my $n = $_->{_ckan}->{name};
if (!$n) {
say " warning : null name";
next;
}
if (%r{$n}) {
say " error : duplicate name";
exit;
}
$r{$n} = undef;
my $o = $_->{_poc_org};
$o =~ s/^'+//;
$o =~ s/'+$//;
$o =~ s/^\s+//;
$o =~ s/\s+$//;
$r{$n}->{organization} = $o;
my $b = $_->{_ckan}->{bureauCode};
$b =~ s/^\s+//;
$b =~ s/\s+$//;
$r{$n}->{bureauCode} = $b;
$r{$n}->{idAgency} = $_->{_ckan}->{idAgency};
$r{$n}->{landingPage} = $_->{_ckan}->{landingPage};
}
return \%r;
}