Skip to content

Commit

Permalink
update citeproc dependency to 3.2.0 and adaptions for nested csl gene…
Browse files Browse the repository at this point in the history
…ration

4Science#352
  • Loading branch information
floriangantner committed Dec 26, 2024
1 parent 66b1f96 commit d80cc41
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 15 deletions.
6 changes: 3 additions & 3 deletions dspace-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@
<dependency>
<groupId>de.undercouch</groupId>
<artifactId>citeproc-java</artifactId>
<version>1.0.1</version>
<version>3.2.0</version>
<exclusions>
<exclusion>
<groupId>org.apache.commons</groupId>
Expand All @@ -885,12 +885,12 @@
<dependency>
<groupId>org.citationstyles</groupId>
<artifactId>locales</artifactId>
<version>1.0</version>
<version>24.12</version>
</dependency>
<dependency>
<groupId>org.citationstyles</groupId>
<artifactId>styles</artifactId>
<version>1.0</version>
<version>24.12</version>
</dependency>

<!-- required for openaire api integration -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public CSLResult generate(DSpaceListItemDataProvider itemDataProvider, String st
return null;
}
Bibliography bibliography = citeproc.makeBibliography();
return CSLResult.fromBibliography(format, bibliography);

return CSLResult.fromBibliography(format, itemDataProvider.getIds().toArray(String[]::new), bibliography);
}

private CSL createCitationProcessor(DSpaceListItemDataProvider itemDataProvider, String style, String format) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,11 @@ public CSLResult(String format, UUID[] itemIds, String[] citationEntries, String

}

public static CSLResult fromBibliography(String format, Bibliography bibliogr) {
UUID[] entryIds = convertToUUIDs(bibliogr.getEntryIds());
public static CSLResult fromBibliography(String format, String[] uuids, Bibliography bibliogr) {
UUID[] entryIds = convertToUUIDs(uuids);
// UUID[] entryIds = bibliogr.getEntryIds()
// entryID in bibliography is empty in citeproc 3. See the Format who sets the empty value while generating the
// Bibliography
return new CSLResult(format, entryIds, bibliogr.getEntries(), bibliogr.makeString());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ protected CSLItemDataBuilder handleStringFields(Item item, CSLItemDataBuilder it
consumeMetadataIfNotBlank(originalPublisherPlace, item, value -> itemBuilder.originalPublisherPlace(value));
consumeMetadataIfNotBlank(originalTitle, item, value -> itemBuilder.originalTitle(value));
consumeMetadataIfNotBlank(page, item, value -> itemBuilder.page(value));
consumeMetadataIfNotBlank(pageFirst, item, value -> itemBuilder.pageFirst(value));
//consumeMetadataIfNotBlank(pageFirst, item, value -> itemBuilder.pageFirst(value));
consumeMetadataIfNotBlank(PMCID, item, value -> itemBuilder.PMCID(value));
consumeMetadataIfNotBlank(PMID, item, value -> itemBuilder.PMID(value));
consumeMetadataIfNotBlank(publisher, item, value -> itemBuilder.publisher(value));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Smith, J., & Red, E. (2018). Publication title. V01(3). https://doi.org/10.1000/182
White, W. (2020). Another Publication title. https://doi.org/10.1000/183
Smith, J., & Red, E. (2018). Publication title. V01(03). https://doi.org/10.1000/182
White, W. (2020). Another Publication title (, Ed.). https://doi.org/10.1000/183
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="csl-bib-body">
<div class="csl-entry">
<div class="csl-left-margin">[1]</div><div class="csl-right-inline"> John Smith and Edward Red, Publication title.” 17-May-2018.</div>
<div class="csl-left-margin">[1]</div><div class="csl-right-inline">John Smith and Edward Red, &ldquo;Publication title,&rdquo; May 17, 2018, [Online Video]. Available: http://localhost:4000/handle/123456789/0001</div>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
@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}}
@article{smith_red_2018, title={Publication title}, volume={V01}, ISBN={11-22-33}, ISSN={0002}, url={http://localhost:4000/handle/123456789/0001}, DOI={10.1000/182}, number={03}, publisher={Publisher}, author={Smith, John and Red, Edward}, editor={Editor}, year={2018}, month=May, keywords={publication} }
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<div class="csl-bib-body">
<div class="csl-entry">
<div class="csl-left-margin">[1]</div><div class="csl-right-inline"> John Smith and Edward Red, Publication title.” 17-May-2018.</div>
<div class="csl-left-margin">[1]</div><div class="csl-right-inline">John Smith and Edward Red, &ldquo;Publication title,&rdquo; May 17, 2018, [Online Video]. Available: http://localhost:4000/handle/123456789/0001</div>
</div>
<div class="csl-entry">
<div class="csl-left-margin">[2]</div><div class="csl-right-inline"> Walter White, Test publication.” 31-Jan-2020.</div>
<div class="csl-left-margin">[2]</div><div class="csl-right-inline">Walter White, &ldquo;Test publication,&rdquo; Jan. 31, 2020, [Online Video]. Available: http://localhost:4000/handle/123456789/0002</div>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public void testSingleItemDisseminate() throws Exception {
.withIssueDate("2018-05-17")
.withAuthor("John Smith")
.withAuthor("Edward Red")
.withHandle("123456789/0001")
.build();
context.restoreAuthSystemState();

Expand Down Expand Up @@ -107,6 +108,7 @@ public void testManyItemsDisseminate() throws Exception {
.withTitle("Test publication")
.withEntityType("Publication")
.withIssueDate("2020-01-31")
.withHandle("123456789/0002")
.withAuthor("Walter White")
.build();

Expand All @@ -130,6 +132,7 @@ public void testBibtexDisseminate() throws Exception {
.withEntityType("Publication")
.withType("Controlled Vocabulary for Resource Type Genres::text::periodical::journal")
.withLanguage("en")
.withHandle("123456789/0001")
.withDoiIdentifier("10.1000/182")
.withIsbnIdentifier("11-22-33")
.withIssnIdentifier("0002")
Expand Down

0 comments on commit d80cc41

Please sign in to comment.