Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
digibib
deichman
Commits
48afd9ef
Commit
48afd9ef
authored
Feb 26, 2021
by
Petter Goksøyr Åsen
Browse files
DEICH-5603
fetch work data from euler; fix in redia-api
parent
a9eed2fe
Changes
1
Hide whitespace changes
Inline
Side-by-side
redia-api/server/routes/resources.js
View file @
48afd9ef
...
...
@@ -38,14 +38,11 @@ const publicationLinkScore = binding => {
return
score
;
};
async
function
decorateRelation
(
key
,
publicationId
,
relation
)
{
const
query
=
sparqlQueries
.
decorateRelation
(
publicationId
,
relation
.
uri
);
return
fetch
(
virtuosoEndpoint
,
{
method
:
"
POST
"
,
body
:
`query=
${
encodeURIComponent
(
query
)}
`
,
async
function
decorateRelation
(
key
,
publicationId
,
relation
,
deichmanCallId
)
{
Torstein
@Torstein
·
Mar 08, 2021
Contributor
Godt å få fjernet Virtuoso-koblingen
👏
Godt å få fjernet Virtuoso-koblingen :clap:
Please
register
or
sign in
to reply
const
url
=
`
${
INTERNAL_URL_EULER
}
/api/authorities/decorateRelation?id=
${
publicationId
}
&relation=
${
encodeURIComponent
(
relation
.
uri
)}
`
;
return
fetch
(
url
,
{
headers
:
{
Accept
:
"
application/sparql-results+json
"
,
"
Content-Type
"
:
"
application/x-www-form-urlencoded
"
"
Deichman-CallID
"
:
deichmanCallId
}
})
.
then
(
res
=>
{
...
...
@@ -56,30 +53,42 @@ async function decorateRelation(key, publicationId, relation) {
})
.
then
(
json
=>
{
let
selected
=
false
;
json
.
results
.
bindings
.
forEach
(
binding
=>
{
(
json
||
[])
.
forEach
(
binding
=>
{
const
score
=
publicationLinkScore
(
binding
);
if
(
!
selected
||
score
>
selected
.
score
)
{
if
(
binding
.
targetPub
)
{
selected
=
{
score
,
publicationId
:
binding
.
targetPub
.
value
.
replace
(
publicationId
:
binding
.
targetPub
.
replace
(
"
http://data.deichman.no/publication/
"
,
""
),
mainTitle
:
binding
.
targetMainTitle
.
value
mainTitle
:
binding
.
targetMainTitle
};
if
(
binding
.
targetSubtitle
)
{
selected
.
subtitle
=
binding
.
targetSubtitle
;
}
if
(
binding
.
targetPartNumber
)
{
selected
.
partNumber
=
binding
.
targetPartNumber
;
}
if
(
binding
.
targetPartTitle
)
{
selected
.
partTitle
=
binding
.
targetPartTitle
;
}
}
}
});
relation
.
publicationId
=
selected
.
publicationId
;
relation
.
mainTitle
=
selected
.
mainTitle
;
relation
.
subtitle
=
selected
.
subtitle
;
relation
.
partNumber
=
selected
.
partNumber
;
relation
.
partTitle
=
selected
.
partTitle
;
if
(
!
selected
&&
json
.
results
.
bindings
.
length
>
0
&&
json
.
results
.
bindings
[
0
].
workMainTitle
json
.
length
>
0
&&
json
[
0
].
workMainTitle
)
{
// Related work has no publications yet, so we use the title from the work.
relation
.
mainTitle
=
json
.
results
.
bindings
[
0
].
workMainTitle
.
value
;
relation
.
mainTitle
=
json
[
0
].
workMainTitle
;
}
return
{
key
,
relation
};
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment