From 0c9d1e45502413718c946062c14505eb6b663bdd Mon Sep 17 00:00:00 2001 From: "Gantner, Florian Klaus" Date: Tue, 2 Apr 2024 17:34:43 +0200 Subject: [PATCH 1/2] also export bibtex format in multiple mode --- dspace/config/spring/api/crosswalks.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dspace/config/spring/api/crosswalks.xml b/dspace/config/spring/api/crosswalks.xml index 9184a56482da..b123dc26a5f7 100644 --- a/dspace/config/spring/api/crosswalks.xml +++ b/dspace/config/spring/api/crosswalks.xml @@ -78,7 +78,7 @@ - + From 773be293885ee93b109c3d205b8152935be00578 Mon Sep 17 00:00:00 2001 From: "Gantner, Florian Klaus" Date: Tue, 2 Apr 2024 17:38:10 +0200 Subject: [PATCH 2/2] test for multiple bibtex export --- .../assetstore/crosswalk/publications.bib | 2 + .../crosswalks/CSLItemDataCrosswalkIT.java | 49 +++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 dspace-api/src/test/data/dspaceFolder/assetstore/crosswalk/publications.bib diff --git a/dspace-api/src/test/data/dspaceFolder/assetstore/crosswalk/publications.bib b/dspace-api/src/test/data/dspaceFolder/assetstore/crosswalk/publications.bib new file mode 100644 index 000000000000..4381ab279bac --- /dev/null +++ b/dspace-api/src/test/data/dspaceFolder/assetstore/crosswalk/publications.bib @@ -0,0 +1,2 @@ + @article{Smith_Red_2018, title={Publication title}, volume={V01}, ISBN={11-22-33}, url={http://localhost:4000/handle/123456789/0001}, DOI={10.1000/182}, number={3}, publisher={Publisher}, author={Smith, John and Red, Edward}, editor={EditorEditor}, year={2018}, month={May}} + @book{White_2020, title={Another Publication title}, url={http://localhost:4000/handle/123456789/0002}, DOI={10.1000/183}, author={White, Walter}, year={2020}, month={Jan}} diff --git a/dspace-api/src/test/java/org/dspace/content/integration/crosswalks/CSLItemDataCrosswalkIT.java b/dspace-api/src/test/java/org/dspace/content/integration/crosswalks/CSLItemDataCrosswalkIT.java index 4aa64c8b0ebb..3bda43cad59a 100644 --- a/dspace-api/src/test/java/org/dspace/content/integration/crosswalks/CSLItemDataCrosswalkIT.java +++ b/dspace-api/src/test/java/org/dspace/content/integration/crosswalks/CSLItemDataCrosswalkIT.java @@ -296,6 +296,55 @@ public void testMutlipleItemsApaDisseminate() throws Exception { } } + @Test + public void testMultipleItemsBibtexDisseminate() throws Exception { + context.turnOffAuthorisationSystem(); + + Item item = createItem(context, collection) + .withEntityType("Publication") + .withType("Controlled Vocabulary for Resource Type Genres::text::periodical::journal") + .withLanguage("en") + .withDoiIdentifier("10.1000/182") + .withIsbnIdentifier("11-22-33") + .withIssnIdentifier("0002") + .withSubject("publication") + .withPublisher("Publisher") + .withVolume("V01") + .withIssue("03") + .withRelationConference("Conference") + .withTitle("Publication title") + .withIssueDate("2018-05-17") + .withAuthor("Smith, John") + .withAuthor("Red, Edward") + .withEditor("Editor") + .withHandle("123456789/0001") + .build(); + + Item anotherItem = createItem(context, collection) + .withEntityType("Publication") + .withType("Controlled Vocabulary for Resource Type Genres::text::book") + .withLanguage("en") + .withDoiIdentifier("10.1000/183") + .withTitle("Another Publication title") + .withIssueDate("2020-01-01") + .withAuthor("White, Walter") + .withHandle("123456789/0002") + .build(); + + context.restoreAuthSystemState(); + + StreamDisseminationCrosswalk crosswalk = crosswalkMapper.getByType("bibtex"); + assertThat(crosswalk, notNullValue()); + + ByteArrayOutputStream out = new ByteArrayOutputStream(); + crosswalk.disseminate(context, Arrays.asList(item, anotherItem).iterator(), out); + + try (FileInputStream fis = getFileInputStream("publications.bib")) { + String expectedContent = IOUtils.toString(fis, Charset.defaultCharset()); + compareEachLine(out.toString(), expectedContent, true); + } + } + private void compareEachLine(String result, String expectedResult, boolean skipId) { String[] resultLines = result.split("\n");