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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gerhard Gonter
irma2
Commits
2d639dd1
Commit
2d639dd1
authored
1 year ago
by
Gerhard Gonter
Browse files
Options
Downloads
Patches
Plain Diff
added code to inject metadata fields "publisher" and "publicationYear", if missing
parent
dcc214c7
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dcd.pl
+30
-2
30 additions, 2 deletions
dcd.pl
with
30 additions
and
2 deletions
dcd.pl
+
30
−
2
View file @
2d639dd1
...
@@ -291,6 +291,8 @@ print __LINE__, " prod_doi_string=[$prod_doi_string] pfx=[$pfx] ns=[$ns] nr=[$nr
...
@@ -291,6 +291,8 @@ print __LINE__, " prod_doi_string=[$prod_doi_string] pfx=[$pfx] ns=[$ns] nr=[$nr
unshift
(
@$md
,
$doi_element
);
unshift
(
@$md
,
$doi_element
);
print
__LINE__
,
"
md:
",
main::
Dumper
(
$md
);
print
__LINE__
,
"
md:
",
main::
Dumper
(
$md
);
fixup_phaidra_metadata
(
$md
);
my
$xml_new
=
$repo_obj
->
json_2_xml
(
$md
);
my
$xml_new
=
$repo_obj
->
json_2_xml
(
$md
);
print
__LINE__
,
"
xml_new=[
$xml_new
]
\n
";
print
__LINE__
,
"
xml_new=[
$xml_new
]
\n
";
...
@@ -311,8 +313,10 @@ print __LINE__, " prod_doi_string=[$prod_doi_string] pfx=[$pfx] ns=[$ns] nr=[$nr
...
@@ -311,8 +313,10 @@ print __LINE__, " prod_doi_string=[$prod_doi_string] pfx=[$pfx] ns=[$ns] nr=[$nr
syswrite
(
DC_XML
,
$prod_xml_new
);
syswrite
(
DC_XML
,
$prod_xml_new
);
close
(
DC_XML
);
close
(
DC_XML
);
print
"
metatada fetched:
",
get_ts
(),
"
\n
";
print
__LINE__
,
"
metatada fetched:
",
get_ts
(),
"
\n
";
if
(
$datacite_res
->
{
status
}
ne
'
OK
')
if
(
$datacite_res
->
{
status
}
ne
'
OK
'
&&
$datacite_res
->
{
status
}
ne
'
INCOMPLETE
'
# maybe we should check, what was missing
)
{
{
print
"
Metadata not ok; status=[
$datacite_res
->{status}] errors:
",
Dumper
(
$datacite_res
->
{
errors
});
print
"
Metadata not ok; status=[
$datacite_res
->{status}] errors:
",
Dumper
(
$datacite_res
->
{
errors
});
return
undef
;
return
undef
;
...
@@ -352,6 +356,30 @@ print __LINE__, " prod_doi_string=[$prod_doi_string] pfx=[$pfx] ns=[$ns] nr=[$nr
...
@@ -352,6 +356,30 @@ print __LINE__, " prod_doi_string=[$prod_doi_string] pfx=[$pfx] ns=[$ns] nr=[$nr
}
}
# TODO: shema checking could work differently
sub
fixup_phaidra_metadata
{
my
$md
=
shift
;
# should be an array
# print __LINE__, " fixup_phaidra_metadata: md= ", Dumper($md);
die
'
not an array reference
'
unless
(
ref
(
$md
)
eq
'
ARRAY
');
my
$cnt
=
@$md
;
print
__LINE__
,
"
md element count=[
$cnt
]
\n
";
my
%pos
;
for
(
my
$i
=
0
;
$i
<
$cnt
;
$i
++
)
{
my
$e
=
$md
->
[
$i
];
print
__LINE__
,
"
fpm: i=[
$i
] e=
",
Dumper
(
$e
);
$pos
{
$e
->
{
xmlname
}}
=
$i
;
}
print
__LINE__
,
"
pos:
",
Dumper
(
\
%pos
);
splice
(
@$md
,
3
,
0
,
{
xmlname
=>
'
publisher
',
'
value
'
=>
'
:none
'
})
unless
(
exists
(
$pos
{
publisher
}));
splice
(
@$md
,
4
,
0
,
{
xmlname
=>
'
publicationYear
',
'
value
'
=>
'
2023
'
})
unless
(
exists
(
$pos
{
publicationYear
}));
}
sub
get_ts
sub
get_ts
{
{
my
$time
=
shift
||
time
();
my
$time
=
shift
||
time
();
...
...
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