Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
Admin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
osuny
Admin
Commits
26d84390
Commit
26d84390
authored
1 year ago
by
Arnaud Levy
Browse files
Options
Downloads
Patches
Plain Diff
hal importer
parent
9c70fe62
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/models/research/hal/author.rb
+1
-1
1 addition, 1 deletion
app/models/research/hal/author.rb
app/models/research/publication.rb
+1
-56
1 addition, 56 deletions
app/models/research/publication.rb
app/services/importers/hal.rb
+60
-0
60 additions, 0 deletions
app/services/importers/hal.rb
with
62 additions
and
57 deletions
app/models/research/hal/author.rb
+
1
−
1
View file @
26d84390
...
...
@@ -68,7 +68,7 @@ class Research::Hal::Author < ApplicationRecord
publications
.
clear
# Do not overuse the API if no researcher is concerned
return
if
researchers
.
none?
Research
::
Hal
::
Publication
.
import_from_hal
_for_author
(
self
).
each
do
|
publication
|
Importers
::
Hal
.
import_publications
_for_author
(
self
).
each
do
|
publication
|
publications
<<
publication
end
publications
...
...
This diff is collapsed.
Click to expand it.
app/models/research/publication.rb
+
1
−
56
View file @
26d84390
...
...
@@ -59,61 +59,6 @@ class Research::Publication < ApplicationRecord
source
==
:osuny
end
# https://api.archives-ouvertes.fr/search/?q=03713859&fl=*
def
self
.
import_from_hal_for_author
(
author
)
fields
=
[
'docid'
,
'title_s'
,
'citationRef_s'
,
'citationFull_s'
,
'uri_s'
,
'doiId_s'
,
'publicationDate_tdate'
,
'linkExtUrl_s'
,
'abstract_s'
,
'openAccess_bool'
,
'journalTitle_s'
,
'authFullName_s'
,
'authLastName_s'
,
'authFirstName_s'
,
'files_s'
# '*',
]
publications
=
[]
response
=
HalOpenscience
::
Document
.
search
"authIdFormPerson_s:
#{
author
.
docid
}
"
,
fields:
fields
,
limit:
1000
response
.
results
.
each
do
|
doc
|
publication
=
create_from
doc
publications
<<
publication
end
publications
end
def
self
.
create_from
(
doc
)
publication
=
where
(
hal_docid:
doc
.
docid
).
first_or_create
puts
"HAL sync publication
#{
doc
.
docid
}
"
publication
.
title
=
Osuny
::
Sanitizer
.
sanitize
doc
.
title_s
.
first
,
'string'
publication
.
ref
=
doc
.
attributes
[
'citationRef_s'
]
publication
.
citation_full
=
doc
.
attributes
[
'citationFull_s'
]
publication
.
abstract
=
doc
.
attributes
[
'abstract_s'
]
&
.
first
publication
.
hal_url
=
doc
.
attributes
[
'uri_s'
]
publication
.
doi
=
doc
.
attributes
[
'doiId_s'
]
publication
.
publication_date
=
doc
.
attributes
[
'publicationDate_tdate'
]
publication
.
url
=
doc
.
attributes
[
'linkExtUrl_s'
]
publication
.
open_access
=
doc
.
attributes
[
'openAccess_bool'
]
publication
.
journal_title
=
doc
.
attributes
[
'journalTitle_s'
]
publication
.
file
=
doc
.
attributes
[
'files_s'
]
&
.
first
publication
.
authors_list
=
doc
.
attributes
[
'authFullName_s'
].
join
(
', '
)
publication
.
authors_citeproc
=
[]
doc
.
attributes
[
'authLastName_s'
].
each_with_index
do
|
last_name
,
index
|
publication
.
authors_citeproc
<<
{
"family"
=>
last_name
,
"given"
=>
doc
.
attributes
[
'authFirstName_s'
][
index
]
}
end
publication
.
save
publication
end
def
template_static
"admin/research/publications/static"
end
...
...
@@ -140,7 +85,7 @@ class Research::Publication < ApplicationRecord
{
"title"
=>
title
,
"author"
=>
authors_citeproc
,
"URL"
=>
hal
_url
,
"URL"
=>
best
_url
,
"container-title"
=>
journal_title
,
"pdf"
=>
file
,
"month-numeric"
=>
publication_date
.
present?
?
publication_date
.
month
.
to_s
:
nil
,
...
...
This diff is collapsed.
Click to expand it.
app/services/importers/hal.rb
0 → 100644
+
60
−
0
View file @
26d84390
module
Importers
class
HAL
# https://api.archives-ouvertes.fr/search/?q=03713859&fl=*
def
self
.
import_publications_for_author
(
author
)
fields
=
[
'docid'
,
'title_s'
,
'citationRef_s'
,
'citationFull_s'
,
'uri_s'
,
'doiId_s'
,
'publicationDate_tdate'
,
'linkExtUrl_s'
,
'abstract_s'
,
'openAccess_bool'
,
'journalTitle_s'
,
'authFullName_s'
,
'authLastName_s'
,
'authFirstName_s'
,
'files_s'
# '*',
]
publications
=
[]
response
=
HalOpenscience
::
Document
.
search
"authIdFormPerson_s:
#{
author
.
docid
}
"
,
fields:
fields
,
limit:
1000
response
.
results
.
each
do
|
doc
|
publication
=
create_publication_from
doc
publications
<<
publication
end
publications
end
def
self
.
create_publication_from
(
doc
)
publication
=
Research
::
Publication
.
where
(
hal_docid:
doc
.
docid
).
first_or_create
puts
"HAL sync publication
#{
doc
.
docid
}
"
publication
.
title
=
Osuny
::
Sanitizer
.
sanitize
doc
.
title_s
.
first
,
'string'
publication
.
ref
=
doc
.
attributes
[
'citationRef_s'
]
publication
.
citation_full
=
doc
.
attributes
[
'citationFull_s'
]
publication
.
abstract
=
doc
.
attributes
[
'abstract_s'
]
&
.
first
publication
.
hal_url
=
doc
.
attributes
[
'uri_s'
]
publication
.
doi
=
doc
.
attributes
[
'doiId_s'
]
publication
.
publication_date
=
doc
.
attributes
[
'publicationDate_tdate'
]
publication
.
url
=
doc
.
attributes
[
'linkExtUrl_s'
]
publication
.
open_access
=
doc
.
attributes
[
'openAccess_bool'
]
publication
.
journal_title
=
doc
.
attributes
[
'journalTitle_s'
]
publication
.
file
=
doc
.
attributes
[
'files_s'
]
&
.
first
publication
.
authors_list
=
doc
.
attributes
[
'authFullName_s'
].
join
(
', '
)
publication
.
authors_citeproc
=
[]
doc
.
attributes
[
'authLastName_s'
].
each_with_index
do
|
last_name
,
index
|
publication
.
authors_citeproc
<<
{
"family"
=>
last_name
,
"given"
=>
doc
.
attributes
[
'authFirstName_s'
][
index
]
}
end
publication
.
save
publication
end
end
end
\ No newline at end of file
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