From f03c10e94b52c6e4516a3972d1545a6ae628dd15 Mon Sep 17 00:00:00 2001 From: grantnert48 <tobias.grantner@tuwien.ac.at> Date: Tue, 28 Mar 2023 23:58:34 +0200 Subject: [PATCH] Adjusted metadata xml export and citation export to include DOIs --- .../src/main/resources/templates/cite_apa.txt | 2 +- .../src/main/resources/templates/cite_bibtex.txt | 2 +- .../src/main/resources/templates/cite_ieee.txt | 2 +- .../src/main/resources/templates/doi.xml | 2 +- .../service/impl/IdentifierServiceImpl.java | 15 +++++++++++---- 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/dbrepo-identifier-service/rest-service/src/main/resources/templates/cite_apa.txt b/dbrepo-identifier-service/rest-service/src/main/resources/templates/cite_apa.txt index 13cf643dae..8af282e645 100644 --- a/dbrepo-identifier-service/rest-service/src/main/resources/templates/cite_apa.txt +++ b/dbrepo-identifier-service/rest-service/src/main/resources/templates/cite_apa.txt @@ -1 +1 @@ -[# th:each="creator,idx: ${creators}"][# th:if="${idx.index} > 0 and ${idx.index} != ${idx.size} - 1 and ${idx.index} != 0"], [/][# th:if="${idx.index} == ${idx.size} - 1 and ${idx.size} != 1"] & [/][[${creator.firstname.substring(0,1)}]]., [[${creator.lastname}]][/][# th:if="${creators.size()} > 0"]. [/]([[${publicationYear}]]). [[${title}]]. [[${publisher}]]. [[${doi}]] \ No newline at end of file +[# th:each="creator,idx: ${creators}"][# th:if="${idx.index} > 0 and ${idx.index} != ${idx.size} - 1 and ${idx.index} != 0"], [/][# th:if="${idx.index} == ${idx.size} - 1 and ${idx.size} != 1"] & [/][[${creator.firstname.substring(0,1)}]]., [[${creator.lastname}]][/][# th:if="${creators.size()} > 0"]. [/]([[${publicationYear}]]). [[${title}]]. [[${publisher}]]. [[${identifierType} == 'doi' ? 'https://doi.org/' : '']][[${identifier}]] \ No newline at end of file diff --git a/dbrepo-identifier-service/rest-service/src/main/resources/templates/cite_bibtex.txt b/dbrepo-identifier-service/rest-service/src/main/resources/templates/cite_bibtex.txt index 3ffe19fef7..ad48a2bd59 100644 --- a/dbrepo-identifier-service/rest-service/src/main/resources/templates/cite_bibtex.txt +++ b/dbrepo-identifier-service/rest-service/src/main/resources/templates/cite_bibtex.txt @@ -1,7 +1,7 @@ @misc{dbrepo[[${publicationYear}]], author = {[# th:each="creator,idx: ${creators}"][# th:if="${idx.index} > 0"] and [/][[${creator.lastname}]], [[${creator.firstname}]][/]}, title = {[[${title}]]}, - howpublished = {\url{[[${doi}]]}}, + [[${identifierType}]] = {[[${identifierType} == 'url' ? '\url{' : '']][[${identifier}]][[${identifierType} == 'url' ? '}' : '']]}, month = {[[${publicationMonth}]]}, year = {[[${publicationYear}]]} } \ No newline at end of file diff --git a/dbrepo-identifier-service/rest-service/src/main/resources/templates/cite_ieee.txt b/dbrepo-identifier-service/rest-service/src/main/resources/templates/cite_ieee.txt index 67f9e13035..602b73deed 100644 --- a/dbrepo-identifier-service/rest-service/src/main/resources/templates/cite_ieee.txt +++ b/dbrepo-identifier-service/rest-service/src/main/resources/templates/cite_ieee.txt @@ -1 +1 @@ -[1] [# th:each="creator,idx: ${creators}"][# th:if="${idx.index} > 0"] and [/][[${creator.firstname.substring(0,1)}]]. [[${creator.lastname}]][/][# th:if="${creators.size()} > 0"], [/]“[[${title}]]“, [[${publisher}]], [[${publicationYear}]], doi: [[${doi}]]. \ No newline at end of file +[1] [# th:each="creator,idx: ${creators}"][# th:if="${idx.index} > 0"] and [/][[${creator.firstname.substring(0,1)}]]. [[${creator.lastname}]][/][# th:if="${creators.size()} > 0"], [/]“[[${title}]]“, [[${publisher}]], [[${publicationYear}]], [[${identifierType} == 'url' ? 'Available: ' : '']][[${identifier}]]. \ No newline at end of file diff --git a/dbrepo-identifier-service/rest-service/src/main/resources/templates/doi.xml b/dbrepo-identifier-service/rest-service/src/main/resources/templates/doi.xml index 3cd28a9bd8..3d52208f99 100644 --- a/dbrepo-identifier-service/rest-service/src/main/resources/templates/doi.xml +++ b/dbrepo-identifier-service/rest-service/src/main/resources/templates/doi.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <resource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://datacite.org/schema/kernel-4" xsi:schemaLocation="http://datacite.org/schema/kernel-4 https://schema.datacite.org/meta/kernel-4.4/metadata.xsd"> - <identifier identifierType="PID">[[${doi}]]</identifier> + <identifier th:attr="identifierType=${identifierType}">[[${identifier}]]</identifier> <creators th:if="${not #lists.isEmpty(creators)}"> <creator th:each="creator: ${creators}"> <creatorName nameType="Personal">[[${creator.lastname}]], [[${creator.firstname}]]</creatorName> diff --git a/dbrepo-identifier-service/services/src/main/java/at/tuwien/service/impl/IdentifierServiceImpl.java b/dbrepo-identifier-service/services/src/main/java/at/tuwien/service/impl/IdentifierServiceImpl.java index fe9f693400..f33ff8911b 100644 --- a/dbrepo-identifier-service/services/src/main/java/at/tuwien/service/impl/IdentifierServiceImpl.java +++ b/dbrepo-identifier-service/services/src/main/java/at/tuwien/service/impl/IdentifierServiceImpl.java @@ -37,7 +37,6 @@ import java.util.Optional; import java.util.stream.Collectors; @Slf4j -@Profile("!doi") @Service public class IdentifierServiceImpl implements IdentifierService { @@ -180,9 +179,11 @@ public class IdentifierServiceImpl implements IdentifierService { /* context */ final Context context = new Context(); if(identifier.getDoi() != null) { - context.setVariable("doi", identifier.getDoi()); + context.setVariable("identifierType", "DOI"); + context.setVariable("identifier", identifier.getDoi()); } else { - context.setVariable("doi", endpointConfig.getWebsiteUrl() + "/pid/" + identifier.getId()); + context.setVariable("identifierType", "PID"); + context.setVariable("identifier", endpointConfig.getWebsiteUrl() + "/pid/" + identifier.getId()); } context.setVariable("creators", identifier.getCreators()); context.setVariable("title", identifier.getTitle()); @@ -207,7 +208,13 @@ public class IdentifierServiceImpl implements IdentifierService { final Identifier identifier = find(id); /* context */ final Context context = new Context(); - context.setVariable("doi", endpointConfig.getWebsiteUrl() + "/pid/" + identifier.getId()); + if(identifier.getDoi() != null) { + context.setVariable("identifierType", "doi"); + context.setVariable("identifier", identifier.getDoi()); + } else { + context.setVariable("identifierType", "url"); + context.setVariable("identifier", endpointConfig.getWebsiteUrl() + "/pid/" + identifier.getId()); + } context.setVariable("creator", identifier.getCreator()); context.setVariable("creators", identifier.getCreators()); context.setVariable("title", identifier.getTitle()); -- GitLab