Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
irma2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gerhard Gonter
irma2
Commits
1de81c92
Commit
1de81c92
authored
Jul 8, 2020
by
Gerhard Gonter
Browse files
Options
Downloads
Patches
Plain Diff
fix publicationYear in DataCite Metadata when processing Phaidra data
parent
e1de8dc9
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
dcd.pl
+18
-9
18 additions, 9 deletions
dcd.pl
with
18 additions
and
9 deletions
dcd.pl
+
18
−
9
View file @
1de81c92
...
@@ -227,17 +227,17 @@ print __LINE__, " prod_doi_string=[$prod_doi_string] pfx=[$pfx] ns=[$ns] nr=[$nr
...
@@ -227,17 +227,17 @@ print __LINE__, " prod_doi_string=[$prod_doi_string] pfx=[$pfx] ns=[$ns] nr=[$nr
return
undef
;
return
undef
;
}
}
my
$d
c
_res
=
$api_res
->
{
datacite
};
my
$d
atacite
_res
=
$api_res
->
{
datacite
};
#
print __LINE__, " d
c
_res: ", Dumper ($d
c
_res);
print
__LINE__
,
"
d
atacite
_res:
",
Dumper
(
$d
atacite
_res
);
# 2018-11-19 Phaidra's DataCite output is quite ... broken ...
# 2018-11-19 Phaidra's DataCite output is quite ... broken ...
fixup_datacite_data
(
$d
c
_res
);
fixup_datacite_data
(
$d
atacite
_res
);
# TODO:
# TODO:
# * mint new DOI
# * mint new DOI
# * insert DOI in metadata
# * insert DOI in metadata
# NOTE: if ($d
c
_res->{status} ne 'OK') request a dummy doi_string
# NOTE: if ($d
atacite
_res->{status} ne 'OK') request a dummy doi_string
my
$t_reg_obj
=
new
DataCite::
API
(
config
=>
$t_reg_cnf
,
'
xmode
'
=>
'
test
');
my
$t_reg_obj
=
new
DataCite::
API
(
config
=>
$t_reg_cnf
,
'
xmode
'
=>
'
test
');
my
$doi_string
=
$t_reg_obj
->
mint_doi
();
my
$doi_string
=
$t_reg_obj
->
mint_doi
();
...
@@ -256,7 +256,7 @@ print __LINE__, " prod_doi_string=[$prod_doi_string] pfx=[$pfx] ns=[$ns] nr=[$nr
...
@@ -256,7 +256,7 @@ print __LINE__, " prod_doi_string=[$prod_doi_string] pfx=[$pfx] ns=[$ns] nr=[$nr
};
};
print
__LINE__
,
"
doi_element:
",
main::
Dumper
(
$doi_element
);
print
__LINE__
,
"
doi_element:
",
main::
Dumper
(
$doi_element
);
my
$md
=
$d
c
_res
->
{
datacite_elements
};
my
$md
=
$d
atacite
_res
->
{
datacite_elements
};
unshift
(
@$md
,
$doi_element
);
unshift
(
@$md
,
$doi_element
);
print
__LINE__
,
"
md:
",
main::
Dumper
(
$md
);
print
__LINE__
,
"
md:
",
main::
Dumper
(
$md
);
...
@@ -281,9 +281,9 @@ print __LINE__, " prod_doi_string=[$prod_doi_string] pfx=[$pfx] ns=[$ns] nr=[$nr
...
@@ -281,9 +281,9 @@ print __LINE__, " prod_doi_string=[$prod_doi_string] pfx=[$pfx] ns=[$ns] nr=[$nr
close
(
DC_XML
);
close
(
DC_XML
);
print
"
metatada fetched:
",
get_ts
(),
"
\n
";
print
"
metatada fetched:
",
get_ts
(),
"
\n
";
if
(
$d
c
_res
->
{
status
}
ne
'
OK
')
if
(
$d
atacite
_res
->
{
status
}
ne
'
OK
')
{
{
print
"
Metadata not ok; status=[
$d
c
_res
->{status}] errors:
",
Dumper
(
$d
c
_res
->
{
errors
});
print
"
Metadata not ok; status=[
$d
atacite
_res
->{status}] errors:
",
Dumper
(
$d
atacite
_res
->
{
errors
});
return
undef
;
return
undef
;
}
}
...
@@ -440,8 +440,11 @@ sub fixup_datacite_data
...
@@ -440,8 +440,11 @@ sub fixup_datacite_data
{
{
my
$dc
=
shift
;
my
$dc
=
shift
;
my
$data
=
$dc
->
{
data
};
foreach
my
$dce
(
@
{
$dc
->
{
datacite_elements
}})
foreach
my
$dce
(
@
{
$dc
->
{
datacite_elements
}})
{
{
print
__LINE__
,
'
dce:
',
Dumper
(
$dce
);
if
(
$dce
->
{
xmlname
}
eq
'
creators
')
if
(
$dce
->
{
xmlname
}
eq
'
creators
')
{
{
my
@filtered_creators
=
();
my
@filtered_creators
=
();
...
@@ -459,7 +462,13 @@ sub fixup_datacite_data
...
@@ -459,7 +462,13 @@ sub fixup_datacite_data
}
}
elsif
(
$dce
->
{
xmlname
}
eq
'
publicationYear
')
elsif
(
$dce
->
{
xmlname
}
eq
'
publicationYear
')
{
{
if
(
$dce
->
{
value
}
=~
m#^(\d{4})(-\d{2})?(-\d{2})?$#
)
print
__LINE__
,
"
publicationYear: dce=
",
Dumper
(
$dce
);
if
(
!
defined
(
$dce
->
{
value
}))
{
my
$year
=
$data
->
{
publicationYear
}
->
[
0
]
->
{
value
};
$dce
->
{
value
}
=
$year
if
(
defined
(
$year
));
}
elsif
(
$dce
->
{
value
}
=~
m#^(\d{4})(-\d{2})?(-\d{2})?$#
)
{
{
my
$new_year
=
$
1
;
my
$new_year
=
$
1
;
print
__LINE__
,
"
publicationYear fixed from [
",
$dce
->
{
value
},
"
] to [
$new_year
]
\n
";
print
__LINE__
,
"
publicationYear fixed from [
",
$dce
->
{
value
},
"
] to [
$new_year
]
\n
";
...
@@ -524,7 +533,7 @@ number from the idenetifiers table and register them.
...
@@ -524,7 +533,7 @@ number from the idenetifiers table and register them.
Until then, this also should work
Until then, this also should work
tsv identifiers.tsv --select ticket=##### --col canoical_url -O- | xargs ./dcd.pl register --doit
tsv identifiers.tsv --select ticket=##### --col cano
n
ical_url -O- | xargs ./dcd.pl register --doit
=head1 NOTES
=head1 NOTES
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment