-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1316 from research-software-directory/1312-openal…
…ex-support Better OpenAlex support
- Loading branch information
Showing
26 changed files
with
422 additions
and
442 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
// SPDX-FileCopyrightText: 2022 - 2023 Dusan Mijatovic (dv4all) | ||
// SPDX-FileCopyrightText: 2022 - 2023 dv4all | ||
// SPDX-FileCopyrightText: 2024 Ewan Cahen (Netherlands eScience Center) <e[email protected]> | ||
// SPDX-FileCopyrightText: 2024 Netherlands eScience Center | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
|
@@ -12,7 +14,7 @@ export default function FindMentionInfoPanel({children}:{children:any}) { | |
icon={false} | ||
> | ||
{/* <AlertTitle>Add existing publication</AlertTitle> */} | ||
We search in <strong> <a href="https://crossref.org" target="_blank">Crossref</a>, <a href="https://datacite.org" target="_blank">DataCite</a></strong> and the RSD. | ||
We search in <strong> <a href="https://www.crossref.org/" target="_blank">Crossref</a>, <a href="https://datacite.org" target="_blank">DataCite</a>, <a href="https://openalex.org/" target="_blank">OpenAlex</a></strong> and the RSD. | ||
All metadata will be imported automatically. | ||
{ children } | ||
</Alert> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,21 @@ | ||
// SPDX-FileCopyrightText: 2022 - 2023 Dusan Mijatovic (dv4all) | ||
// SPDX-FileCopyrightText: 2022 - 2023 Ewan Cahen (Netherlands eScience Center) <[email protected]> | ||
// SPDX-FileCopyrightText: 2022 - 2023 dv4all | ||
// SPDX-FileCopyrightText: 2022 - 2024 Ewan Cahen (Netherlands eScience Center) <[email protected]> | ||
// SPDX-FileCopyrightText: 2022 - 2024 Netherlands eScience Center | ||
// SPDX-FileCopyrightText: 2024 Dusan Mijatovic (Netherlands eScience Center) | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import {useAuth} from '~/auth' | ||
import {MentionItemProps} from '~/types/Mention' | ||
import {getMentionByDoiFromRsd} from '~/utils/editMentions' | ||
import {getMentionByDoiFromRsd, getMentionByOpenalexIdFromRsd} from '~/utils/editMentions' | ||
import {getMentionByDoi} from '~/utils/getDOI' | ||
import EditSectionTitle from '~/components/layout/EditSectionTitle' | ||
import FindMention from '~/components/mention/FindMention' | ||
import FindMentionInfoPanel from '~/components/mention/FindMentionInfoPanel' | ||
import useEditMentionReducer from '~/components/mention/useEditMentionReducer' | ||
import {extractSearchTerm} from '~/components/software/edit/mentions/utils' | ||
import {getMentionByOpenalexId} from '~/utils/getOpenalex' | ||
|
||
type FindProjectMentionProps={ | ||
id:string, | ||
|
@@ -39,35 +40,57 @@ export default function FindMentionSection({id,config,findPublicationByTitle}:Fi | |
const {session: {token}} = useAuth() | ||
const {onAdd} = useEditMentionReducer() | ||
|
||
async function findPublication(searchFor: string) { | ||
async function findPublication(searchFor: string): Promise<MentionItemProps[]> { | ||
const searchData = extractSearchTerm(searchFor) | ||
if (searchData.type === 'doi') { | ||
searchFor = searchData.term | ||
// look first at RSD | ||
const rsd = await getMentionByDoiFromRsd({ | ||
doi: searchFor, | ||
token | ||
}) | ||
if (rsd?.status === 200 && rsd.message?.length === 1) { | ||
// return first found item in RSD | ||
const item:MentionItemProps = rsd.message[0] | ||
return [item] | ||
switch (searchData.type) { | ||
case 'doi': { | ||
searchFor = searchData.term | ||
// look first at RSD | ||
const rsd = await getMentionByDoiFromRsd({ | ||
doi: searchFor, | ||
token | ||
}) | ||
if (rsd?.status === 200 && rsd.message?.length === 1) { | ||
// return first found item in RSD | ||
const item: MentionItemProps = rsd.message[0] | ||
return [item] | ||
} | ||
// else find by DOI | ||
const resp = await getMentionByDoi(searchFor) | ||
if (resp?.status === 200) { | ||
return [resp.message as MentionItemProps] | ||
} | ||
return [] | ||
} | ||
// else find by DOI | ||
const resp = await getMentionByDoi(searchFor) | ||
if (resp?.status === 200) { | ||
return [resp.message as MentionItemProps] | ||
case 'openalex': { | ||
searchFor = searchData.term | ||
// look first at RSD | ||
const rsd = await getMentionByOpenalexIdFromRsd({ | ||
id: searchFor, | ||
token | ||
}) | ||
if (rsd?.status === 200 && rsd.message?.length === 1) { | ||
// return first found item in RSD | ||
const item: MentionItemProps = rsd.message[0] | ||
return [item] | ||
} | ||
// else find by DOI | ||
const resp = await getMentionByOpenalexId(searchFor) | ||
if (resp?.status === 200) { | ||
return [resp.message as MentionItemProps] | ||
} | ||
return [] | ||
} | ||
case 'title': { | ||
searchFor = searchData.term | ||
// find by title | ||
const mentions = await findPublicationByTitle({ | ||
id: id, | ||
searchFor, | ||
token | ||
}) | ||
return mentions | ||
} | ||
return [] | ||
} else{ | ||
searchFor = searchData.term | ||
// find by title | ||
const mentions = await findPublicationByTitle({ | ||
id: id, | ||
searchFor, | ||
token | ||
}) | ||
return mentions | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
// SPDX-FileCopyrightText: 2022 Dusan Mijatovic (dv4all) (dv4all) | ||
// SPDX-FileCopyrightText: 2022 dv4all | ||
// SPDX-FileCopyrightText: 2024 Dusan Mijatovic (Netherlands eScience Center) | ||
// SPDX-FileCopyrightText: 2024 Ewan Cahen (Netherlands eScience Center) <[email protected]> | ||
// SPDX-FileCopyrightText: 2024 Netherlands eScience Center | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
@@ -34,7 +35,7 @@ it('findPublicationByTitle', async () => { | |
token: 'TEST-TOKEN' | ||
} | ||
|
||
const expectedUrl = `/api/fe/mention/impact?id=${props.id}&search=${encodeURIComponent(props.searchFor)}` | ||
const expectedUrl = `/api/fe/mention/find_by_title?id=${props.id}&search=${encodeURIComponent(props.searchFor)}&relation_type=impact` | ||
const expectBody = { | ||
'headers': { | ||
'Authorization': `Bearer ${props.token}`, | ||
|
Oops, something went wrong.