Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: issues in exporters and citations for PermaLink/non-DOI PIDs #10790

Open
wants to merge 19 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
2b2da99
fix: remove unnecessary slash in perma PIDs in DDI exporters
vera Aug 22, 2024
c8cdb8b
fix: remove doi property for perma PIDs in BibTeX citation
vera Aug 22, 2024
ccf74f9
fix: fix PID formatting in EndNote XML citation
vera Aug 22, 2024
34a795c
fix: use correct PID separator in DDI exporters (WIP)
vera Aug 22, 2024
825d503
fix: use correct PID separator in DDI exporters (WIP)
vera Aug 23, 2024
b8a068e
fix: use correct PID separator in DDI exporters
vera Aug 23, 2024
70031f3
fix: use GlobalId methods to create PID URLs/strings in DdiExportUtil
vera Aug 26, 2024
f6e1b06
fix: set separator when creating new dataset
vera Aug 27, 2024
46de8fb
test: add tests for DDI exports for datasets with PermaLinks
vera Aug 27, 2024
3275eba
Merge branch 'develop' into fix/perma-exporters-and-citations
vera Oct 23, 2024
07e327c
fix: fix failing DdiExportUtilTest by updating PermaLink config
vera Oct 23, 2024
a553458
fix: improve PID formatting in EndNote XML citation output
vera Oct 25, 2024
ae058d1
release note
qqmyers Oct 25, 2024
7317ac9
Merge branch 'develop' into fix/perma-exporters-and-citations
vera Dec 5, 2024
cf3ced8
Merge branch 'develop' into fix/perma-exporters-and-citations #10790
pdurbin Dec 18, 2024
0d75b88
rename sql script #10790
pdurbin Dec 18, 2024
746b2b4
new test and doc update
qqmyers Jan 17, 2025
43dcb00
Merge pull request #2 from GlobalDataverseCommunityConsortium/fix/per…
vera Jan 20, 2025
ed03452
Merge branch 'develop' into fix/perma-exporters-and-citations
vera Jan 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
### Improvements to PID formatting in exports and citations

Multiple small issues with the formatting of PIDs in the
DDI exporters, and EndNote and BibTeX citation formats have
been addressed. These should improve the ability to import
Dataverse citations into reference managers and fix potential
issues harvesting datasets using PermaLinks.

Backward Incompatibility

Changes to PID formatting occur in the DDI/DDI Html export formats
and the EndNote and BibTex citation formats. These changes correct
errors and improve conformance with best practices but could break
parsing of these formats.

For more information, see #10790.
1 change: 1 addition & 0 deletions doc/sphinx-guides/source/installation/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,7 @@ Note:

- If you configure ``base-url``, it should include a "/" after the hostname like this: ``https://demo.dataverse.org/``.
- When using multiple PermaLink providers, you should avoid ambiguous authority/separator/shoulder combinations that would result in the same overall prefix.
- Configuring PermaLink providers differing only by their separator values is not supported.
- In general, PermaLink authority/shoulder values should be alphanumeric. For other cases, admins may need to consider the potential impact of special characters in S3 storage identifiers, resolver URLs, exports, etc.

.. _dataverse.pid.*.handlenet:
Expand Down
41 changes: 28 additions & 13 deletions src/main/java/edu/harvard/iq/dataverse/DataCitation.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
import org.apache.commons.text.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;

import static edu.harvard.iq.dataverse.pidproviders.doi.AbstractDOIProvider.DOI_PROTOCOL;
import static edu.harvard.iq.dataverse.pidproviders.handle.HandlePidProvider.HDL_PROTOCOL;
import static edu.harvard.iq.dataverse.pidproviders.perma.PermaLinkPidProvider.PERMA_PROTOCOL;

/**
*
* @author gdurand, qqmyers
Expand Down Expand Up @@ -293,11 +297,13 @@ public void writeAsBibtexCitation(OutputStream os) throws IOException {
out.write("version = {");
out.write(version);
out.write("},\r\n");
out.write("doi = {");
out.write(persistentId.getAuthority());
out.write("/");
out.write(persistentId.getIdentifier());
out.write("},\r\n");
if("doi".equals(persistentId.getProtocol())) {
out.write("doi = {");
out.write(persistentId.getAuthority());
out.write("/");
out.write(persistentId.getIdentifier());
out.write("},\r\n");
}
out.write("url = {");
out.write(persistentId.asURL());
out.write("}\r\n");
Expand Down Expand Up @@ -595,11 +601,21 @@ private void createEndNoteXML(XMLStreamWriter xmlw) throws XMLStreamException {
}

xmlw.writeStartElement("urls");
xmlw.writeStartElement("related-urls");
xmlw.writeStartElement("url");
xmlw.writeCharacters(getPersistentId().asURL());
xmlw.writeEndElement(); // url
xmlw.writeEndElement(); // related-urls
if (persistentId != null) {
if (PERMA_PROTOCOL.equals(persistentId.getProtocol()) || HDL_PROTOCOL.equals(persistentId.getProtocol())) {
xmlw.writeStartElement("web-urls");
xmlw.writeStartElement("url");
xmlw.writeCharacters(getPersistentId().asURL());
xmlw.writeEndElement(); // url
xmlw.writeEndElement(); // web-urls
} else if (DOI_PROTOCOL.equals(persistentId.getProtocol())) {
xmlw.writeStartElement("related-urls");
xmlw.writeStartElement("url");
xmlw.writeCharacters(getPersistentId().asURL());
xmlw.writeEndElement(); // url
xmlw.writeEndElement(); // related-urls
}
}
xmlw.writeEndElement(); // urls

// a DataFile citation also includes the filename and (for Tabular
Expand All @@ -617,10 +633,9 @@ private void createEndNoteXML(XMLStreamWriter xmlw) throws XMLStreamException {
xmlw.writeEndElement(); // custom2
}
}
if (persistentId != null) {
if (persistentId != null && "doi".equals(persistentId.getProtocol())) {
xmlw.writeStartElement("electronic-resource-num");
String electResourceNum = persistentId.getProtocol() + "/" + persistentId.getAuthority() + "/"
+ persistentId.getIdentifier();
String electResourceNum = persistentId.asRawIdentifier();
xmlw.writeCharacters(electResourceNum);
xmlw.writeEndElement();
}
Expand Down
16 changes: 15 additions & 1 deletion src/main/java/edu/harvard/iq/dataverse/DvObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,14 @@ public String visit(DataFile df) {
@Column(insertable = false, updatable = false) private String dtype;

/*
* Add DOI related fields
* Add PID related fields
*/

private String protocol;
private String authority;

private String separator;

@Temporal(value = TemporalType.TIMESTAMP)
private Date globalIdCreateTime;

Expand Down Expand Up @@ -323,6 +325,16 @@ public void setAuthority(String authority) {
globalId=null;
}

public String getSeparator() {
return separator;
}

public void setSeparator(String separator) {
this.separator = separator;
//Remove cached value
globalId=null;
}

public Date getGlobalIdCreateTime() {
return globalIdCreateTime;
}
Expand Down Expand Up @@ -353,11 +365,13 @@ public void setGlobalId( GlobalId pid ) {
if ( pid == null ) {
setProtocol(null);
setAuthority(null);
setSeparator(null);
setIdentifier(null);
} else {
//These reset globalId=null
setProtocol(pid.getProtocol());
setAuthority(pid.getAuthority());
setSeparator(pid.getSeparator());
setIdentifier(pid.getIdentifier());
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/GlobalId.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ public String getAuthority() {
return authority;
}

public String getSeparator() {
return separator;
}

public String getIdentifier() {
return identifier;
}
Expand Down
11 changes: 10 additions & 1 deletion src/main/java/edu/harvard/iq/dataverse/api/dto/DatasetDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class DatasetDTO implements java.io.Serializable {
private String identifier;
private String protocol;
private String authority;
private String separator;
private String globalIdCreateTime;
private String publisher;
private String publicationDate;
Expand Down Expand Up @@ -51,6 +52,14 @@ public void setAuthority(String authority) {
this.authority = authority;
}

public String getSeparator() {
return separator;
}

public void setSeparator(String separator) {
this.separator = separator;
}

public String getGlobalIdCreateTime() {
return globalIdCreateTime;
}
Expand Down Expand Up @@ -94,7 +103,7 @@ public void setPublicationDate(String publicationDate) {

@Override
public String toString() {
return "DatasetDTO{" + "id=" + id + ", identifier=" + identifier + ", protocol=" + protocol + ", authority=" + authority + ", globalIdCreateTime=" + globalIdCreateTime + ", datasetVersion=" + datasetVersion + ", dataFiles=" + dataFiles + '}';
return "DatasetDTO{" + "id=" + id + ", identifier=" + identifier + ", protocol=" + protocol + ", authority=" + authority + ", separator=" + separator + ", globalIdCreateTime=" + globalIdCreateTime + ", datasetVersion=" + datasetVersion + ", dataFiles=" + dataFiles + '}';
}

public void setMetadataLanguage(String metadataLanguage) {
Expand Down
Loading
Loading