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 13cf643dae05b0e93e8c77d68a280b4d0f5260ad..8af282e645262dd7f8dfa8c17826e1d4c4fd43a6 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 3ffe19fef7193059855155a43c65df28de45059b..ad48a2bd59fb10d5e25acc9323288c6c16e0df49 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 67f9e13035097bb4587d2f3ff1a5199ff4d65996..602b73deed44278af106e3a946a1b1aa55996c36 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 3cd28a9bd8e5fe5e5f1646f40ffe004afdfeabc7..3d52208f994c8d145a2d2bd734e10f6b0089de47 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 fe9f69340028cfbc9d1971bf7afea184a8a874e6..f33ff8911b976e33338e6af8f6f8428c00fb1084 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());