From c75506f6f404d759d757837ac2b2ae2e57f40a23 Mon Sep 17 00:00:00 2001 From: Jawad Mouza <96312791+JawadTUE@users.noreply.github.com> Date: Tue, 14 Nov 2023 11:11:27 +0100 Subject: [PATCH] Added parent field to Hayagriva YAML export (#10633) * added parent field to support publisher and series * added testcase for parent field * changelog * Update CHANGELOG.md Co-authored-by: Christoph --------- Co-authored-by: Christoph --- CHANGELOG.md | 1 + .../resource/layout/hayagrivayaml.layout | 17 ++++++++-- .../exporter/HayagrivaYamlExporterTest.java | 31 +++++++++++++++++++ 3 files changed, 47 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 992f0055839..ffaa0b80b05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv - We fixed an issue where the added protected term has unwanted leading and trailing whitespaces, where the formatted text has unwanted empty brackets and where the word at the cursor in the textbox can be added to the list. [#10415](https://github.com/JabRef/jabref/issues/10415) - We fixed an issue where in the merge dialog the file field of entries was not correctly merged when the first and second entry both contained values inside the file field. [#10572](https://github.com/JabRef/jabref/issues/10572) - We fixed some small inconsistencies in the user interface. [#10507](https://github.com/JabRef/jabref/issues/10507) [#10458](https://github.com/JabRef/jabref/issues/10458) +- We fixed the issue where the Hayagriva YAML exporter would not include a parent field for the publisher/series. [#10596](https://github.com/JabRef/jabref/issues/10596) ### Removed diff --git a/src/main/resources/resource/layout/hayagrivayaml.layout b/src/main/resources/resource/layout/hayagrivayaml.layout index cd19524d406..b60553bec16 100644 --- a/src/main/resources/resource/layout/hayagrivayaml.layout +++ b/src/main/resources/resource/layout/hayagrivayaml.layout @@ -6,11 +6,24 @@ - \format[Authors(LastFirst, MiddleInitial, Sep =\n - , LastSep =\n - )]{\author} \end{author} \begin{date} date: \date\end{date} +\begin{journal} + parent: + type: periodical + title: \journal +\end{journal} + \begin{journal&&volume}volume: \volume\end{journal&&volume} + \begin{journal&&number}issue: \number\end{journal&&number} + \begin{journal&&publisher}publisher: \publisher\end{journal&&publisher} +\begin{series} + parent: + type: book + title: "\series" +\end{series} +\begin{editor&&number} issue: \number\end{editor&&number} +\begin{editor&&publisher} publisher: \publisher\end{editor&&publisher} \begin{editor} editor: \editor\end{editor} -\begin{publisher} publisher: \publisher\end{publisher} \begin{address} location: \address\end{address} \begin{institution} organization: \institution\end{institution} -\begin{volume} volume: \volume\end{volume} \begin{edition} edition: \edition\end{edition} \begin{pages} page-range: \pages\end{pages} \begin{url} url: \url\end{url} diff --git a/src/test/java/org/jabref/logic/exporter/HayagrivaYamlExporterTest.java b/src/test/java/org/jabref/logic/exporter/HayagrivaYamlExporterTest.java index 7a058ec059d..0b6356906e9 100644 --- a/src/test/java/org/jabref/logic/exporter/HayagrivaYamlExporterTest.java +++ b/src/test/java/org/jabref/logic/exporter/HayagrivaYamlExporterTest.java @@ -183,4 +183,35 @@ void passesModifiedCharsetNull(@TempDir Path tempFile) throws Exception { "---"); assertEquals(expected, Files.readAllLines(file)); } + + @Test + public final void exportsCorrectParentField(@TempDir Path tempFile) throws Exception { + BibEntry entry = new BibEntry(StandardEntryType.Article) + .withCitationKey("test") + .withField(StandardField.AUTHOR, "Test Author") + .withField(StandardField.TITLE, "Test Title") + .withField(StandardField.JOURNAL, "Test Publisher") + .withField(StandardField.URL, "http://example.com") + .withField(StandardField.DATE, "2020-10-14"); + + Path file = tempFile.resolve("RandomFileName"); + Files.createFile(file); + hayagrivaYamlExporter.export(databaseContext, file, Collections.singletonList(entry)); + + List expected = List.of( + "---", + "test:", + " type: article", + " title: \"Test Title\"", + " author:", + " - Author, Test", + " date: 2020-10-14", + " parent:", + " type: periodical", + " title: Test Publisher", + " url: http://example.com", + "---"); + + assertEquals(expected, Files.readAllLines(file)); + } }