-
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.
- Loading branch information
1 parent
bd8911b
commit d181665
Showing
24 changed files
with
1,226 additions
and
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
-- SPDX-FileCopyrightText: 2023 Dusan Mijatovic (Netherlands eScience Center) | ||
-- SPDX-FileCopyrightText: 2023 Ewan Cahen (Netherlands eScience Center) <[email protected]> | ||
-- SPDX-FileCopyrightText: 2023 Netherlands eScience Center | ||
-- | ||
|
@@ -17,3 +18,61 @@ $$ | |
SELECT mention FROM reference_paper_for_software | ||
) | ||
$$; | ||
|
||
-- UNIQUE CITATIONS BY SOFTWARE ID | ||
CREATE FUNCTION citation_by_software() RETURNS TABLE ( | ||
software UUID, | ||
id UUID, | ||
doi CITEXT, | ||
url VARCHAR, | ||
title VARCHAR, | ||
authors VARCHAR, | ||
publisher VARCHAR, | ||
publication_year SMALLINT, | ||
journal VARCHAR, | ||
page VARCHAR, | ||
image_url VARCHAR, | ||
mention_type mention_type, | ||
source VARCHAR, | ||
reference_papers UUID[] | ||
)LANGUAGE sql STABLE AS | ||
$$ | ||
SELECT | ||
reference_paper_for_software.software, | ||
mention.id, | ||
mention.doi, | ||
mention.url, | ||
mention.title, | ||
mention.authors, | ||
mention.publisher, | ||
mention.publication_year, | ||
mention.journal, | ||
mention.page, | ||
mention.image_url, | ||
mention.mention_type, | ||
mention.source, | ||
ARRAY_AGG( | ||
reference_paper_for_software.mention | ||
) AS reference_paper | ||
FROM | ||
reference_paper_for_software | ||
INNER JOIN | ||
citation_for_mention ON citation_for_mention.mention = reference_paper_for_software.mention | ||
INNER JOIN | ||
mention ON mention.id = citation_for_mention.citation | ||
GROUP BY | ||
reference_paper_for_software.software, | ||
mention.id, | ||
mention.doi, | ||
mention.url, | ||
mention.title, | ||
mention.authors, | ||
mention.publisher, | ||
mention.publication_year, | ||
mention.journal, | ||
mention.page, | ||
mention.image_url, | ||
mention.mention_type, | ||
mention.source | ||
; | ||
$$; |
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
95 changes: 95 additions & 0 deletions
95
frontend/components/software/edit/reference-papers/CitationItem.tsx
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 |
---|---|---|
@@ -0,0 +1,95 @@ | ||
// SPDX-FileCopyrightText: 2023 Dusan Mijatovic (Netherlands eScience Center) | ||
// SPDX-FileCopyrightText: 2023 Netherlands eScience Center | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import {MentionItemProps} from '~/types/Mention' | ||
import {getMentionType} from '~/components/mention/config' | ||
import MentionAuthors from '~/components/mention/MentionAuthors' | ||
import MentionDoi from '~/components/mention/MentionDoi' | ||
import {MentionTitle} from '~/components/mention/MentionItemBase' | ||
import MentionPublisherItem from '~/components/mention/MentionPublisherItem' | ||
import useEditMentionReducer from '~/components/mention/useEditMentionReducer' | ||
|
||
export type CitationItemProps = MentionItemProps & { | ||
reference_papers: string[] | ||
} | ||
|
||
function ReferencePapers({papers}:{papers:string[]}){ | ||
const {mentions} = useEditMentionReducer() | ||
const reference:{doi:string,url:string}[] =[] | ||
|
||
if (papers?.length===0 || mentions?.length===0){ | ||
return ( | ||
<div className="text-sm"> | ||
Referenced paper: | ||
</div> | ||
) | ||
} | ||
|
||
papers.forEach(uuid=>{ | ||
const found = mentions.find(item=>item.id === uuid) | ||
if (found?.doi && found.url) reference.push({doi:found.doi, url:found.url}) | ||
}) | ||
|
||
if (reference.length === 0){ | ||
return ( | ||
<div className="text-sm"> | ||
Referenced: <i>None</i> | ||
</div> | ||
) | ||
} | ||
|
||
return( | ||
<div className="flex flex-wrap gap-2 text-sm text-base-content-secondary"> | ||
Referenced: { | ||
reference.map(item=>{ | ||
return ( | ||
<a | ||
key={item.url} | ||
href={item.url} target="_blank" rel="noreferrer" | ||
className="text-sm " | ||
> | ||
{item.doi} | ||
</a> | ||
) | ||
}) | ||
} | ||
</div> | ||
) | ||
} | ||
|
||
|
||
export default function CitationItem({item}:{item:CitationItemProps}){ | ||
const title = getMentionType(item?.mention_type,'singular') | ||
return ( | ||
<div data-testid="citation-view-item-body" className="py-2 px-4 hover:bg-base-200"> | ||
<div className="text-base-content-disabled"> | ||
{title} | ||
</div> | ||
<MentionTitle | ||
title={item?.title ?? ''} | ||
role="list" | ||
url={item.url} | ||
className="text-base" | ||
/> | ||
<MentionAuthors | ||
authors={item.authors} | ||
className="text-sm text-base-content-secondary" | ||
/> | ||
<MentionPublisherItem | ||
publisher={item?.publisher ?? ''} | ||
page={item?.page ?? ''} | ||
publication_year={item.publication_year} | ||
journal = {item.journal} | ||
className="text-sm text-base-content-secondary" | ||
/> | ||
<MentionDoi | ||
url={item?.url} | ||
doi={item?.doi} | ||
className="text-sm" | ||
/> | ||
<ReferencePapers papers={item.reference_papers} /> | ||
</div> | ||
) | ||
} |
Oops, something went wrong.