Skip to content

Commit

Permalink
Merge pull request IQSS#10790 from vera/fix/perma-exporters-and-citat…
Browse files Browse the repository at this point in the history
…ions

fix: issues in exporters and citations for PermaLink/non-DOI PIDs
  • Loading branch information
ofahimIQSS authored Feb 6, 2025
2 parents 4e1238e + b078516 commit 3aea148
Show file tree
Hide file tree
Showing 19 changed files with 529 additions and 45 deletions.
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

0 comments on commit 3aea148

Please sign in to comment.