Skip to content

Commit 3aea148

Browse files
authored
Merge pull request #10790 from vera/fix/perma-exporters-and-citations
fix: issues in exporters and citations for PermaLink/non-DOI PIDs
2 parents 4e1238e + b078516 commit 3aea148

19 files changed

Lines changed: 529 additions & 45 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
### Improvements to PID formatting in exports and citations
2+
3+
Multiple small issues with the formatting of PIDs in the
4+
DDI exporters, and EndNote and BibTeX citation formats have
5+
been addressed. These should improve the ability to import
6+
Dataverse citations into reference managers and fix potential
7+
issues harvesting datasets using PermaLinks.
8+
9+
Backward Incompatibility
10+
11+
Changes to PID formatting occur in the DDI/DDI Html export formats
12+
and the EndNote and BibTex citation formats. These changes correct
13+
errors and improve conformance with best practices but could break
14+
parsing of these formats.
15+
16+
For more information, see #10790.

doc/sphinx-guides/source/installation/config.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,7 @@ Note:
581581

582582
- If you configure ``base-url``, it should include a "/" after the hostname like this: ``https://demo.dataverse.org/``.
583583
- When using multiple PermaLink providers, you should avoid ambiguous authority/separator/shoulder combinations that would result in the same overall prefix.
584+
- Configuring PermaLink providers differing only by their separator values is not supported.
584585
- 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.
585586

586587
.. _dataverse.pid.*.handlenet:

src/main/java/edu/harvard/iq/dataverse/DataCitation.java

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
import org.apache.commons.text.StringEscapeUtils;
3939
import org.apache.commons.lang3.StringUtils;
4040

41+
import static edu.harvard.iq.dataverse.pidproviders.doi.AbstractDOIProvider.DOI_PROTOCOL;
42+
import static edu.harvard.iq.dataverse.pidproviders.handle.HandlePidProvider.HDL_PROTOCOL;
43+
import static edu.harvard.iq.dataverse.pidproviders.perma.PermaLinkPidProvider.PERMA_PROTOCOL;
44+
4145
/**
4246
*
4347
* @author gdurand, qqmyers
@@ -293,11 +297,13 @@ public void writeAsBibtexCitation(OutputStream os) throws IOException {
293297
out.write("version = {");
294298
out.write(version);
295299
out.write("},\r\n");
296-
out.write("doi = {");
297-
out.write(persistentId.getAuthority());
298-
out.write("/");
299-
out.write(persistentId.getIdentifier());
300-
out.write("},\r\n");
300+
if("doi".equals(persistentId.getProtocol())) {
301+
out.write("doi = {");
302+
out.write(persistentId.getAuthority());
303+
out.write("/");
304+
out.write(persistentId.getIdentifier());
305+
out.write("},\r\n");
306+
}
301307
out.write("url = {");
302308
out.write(persistentId.asURL());
303309
out.write("}\r\n");
@@ -595,11 +601,21 @@ private void createEndNoteXML(XMLStreamWriter xmlw) throws XMLStreamException {
595601
}
596602

597603
xmlw.writeStartElement("urls");
598-
xmlw.writeStartElement("related-urls");
599-
xmlw.writeStartElement("url");
600-
xmlw.writeCharacters(getPersistentId().asURL());
601-
xmlw.writeEndElement(); // url
602-
xmlw.writeEndElement(); // related-urls
604+
if (persistentId != null) {
605+
if (PERMA_PROTOCOL.equals(persistentId.getProtocol()) || HDL_PROTOCOL.equals(persistentId.getProtocol())) {
606+
xmlw.writeStartElement("web-urls");
607+
xmlw.writeStartElement("url");
608+
xmlw.writeCharacters(getPersistentId().asURL());
609+
xmlw.writeEndElement(); // url
610+
xmlw.writeEndElement(); // web-urls
611+
} else if (DOI_PROTOCOL.equals(persistentId.getProtocol())) {
612+
xmlw.writeStartElement("related-urls");
613+
xmlw.writeStartElement("url");
614+
xmlw.writeCharacters(getPersistentId().asURL());
615+
xmlw.writeEndElement(); // url
616+
xmlw.writeEndElement(); // related-urls
617+
}
618+
}
603619
xmlw.writeEndElement(); // urls
604620

605621
// a DataFile citation also includes the filename and (for Tabular
@@ -617,10 +633,9 @@ private void createEndNoteXML(XMLStreamWriter xmlw) throws XMLStreamException {
617633
xmlw.writeEndElement(); // custom2
618634
}
619635
}
620-
if (persistentId != null) {
636+
if (persistentId != null && "doi".equals(persistentId.getProtocol())) {
621637
xmlw.writeStartElement("electronic-resource-num");
622-
String electResourceNum = persistentId.getProtocol() + "/" + persistentId.getAuthority() + "/"
623-
+ persistentId.getIdentifier();
638+
String electResourceNum = persistentId.asRawIdentifier();
624639
xmlw.writeCharacters(electResourceNum);
625640
xmlw.writeEndElement();
626641
}

src/main/java/edu/harvard/iq/dataverse/DvObject.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,14 @@ public String visit(DataFile df) {
143143
@Column(insertable = false, updatable = false) private String dtype;
144144

145145
/*
146-
* Add DOI related fields
146+
* Add PID related fields
147147
*/
148148

149149
private String protocol;
150150
private String authority;
151151

152+
private String separator;
153+
152154
@Temporal(value = TemporalType.TIMESTAMP)
153155
private Date globalIdCreateTime;
154156

@@ -323,6 +325,16 @@ public void setAuthority(String authority) {
323325
globalId=null;
324326
}
325327

328+
public String getSeparator() {
329+
return separator;
330+
}
331+
332+
public void setSeparator(String separator) {
333+
this.separator = separator;
334+
//Remove cached value
335+
globalId=null;
336+
}
337+
326338
public Date getGlobalIdCreateTime() {
327339
return globalIdCreateTime;
328340
}
@@ -353,11 +365,13 @@ public void setGlobalId( GlobalId pid ) {
353365
if ( pid == null ) {
354366
setProtocol(null);
355367
setAuthority(null);
368+
setSeparator(null);
356369
setIdentifier(null);
357370
} else {
358371
//These reset globalId=null
359372
setProtocol(pid.getProtocol());
360373
setAuthority(pid.getAuthority());
374+
setSeparator(pid.getSeparator());
361375
setIdentifier(pid.getIdentifier());
362376
}
363377
}

src/main/java/edu/harvard/iq/dataverse/GlobalId.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ public String getAuthority() {
6363
return authority;
6464
}
6565

66+
public String getSeparator() {
67+
return separator;
68+
}
69+
6670
public String getIdentifier() {
6771
return identifier;
6872
}

src/main/java/edu/harvard/iq/dataverse/api/dto/DatasetDTO.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public class DatasetDTO implements java.io.Serializable {
1212
private String identifier;
1313
private String protocol;
1414
private String authority;
15+
private String separator;
1516
private String globalIdCreateTime;
1617
private String publisher;
1718
private String publicationDate;
@@ -51,6 +52,14 @@ public void setAuthority(String authority) {
5152
this.authority = authority;
5253
}
5354

55+
public String getSeparator() {
56+
return separator;
57+
}
58+
59+
public void setSeparator(String separator) {
60+
this.separator = separator;
61+
}
62+
5463
public String getGlobalIdCreateTime() {
5564
return globalIdCreateTime;
5665
}
@@ -94,7 +103,7 @@ public void setPublicationDate(String publicationDate) {
94103

95104
@Override
96105
public String toString() {
97-
return "DatasetDTO{" + "id=" + id + ", identifier=" + identifier + ", protocol=" + protocol + ", authority=" + authority + ", globalIdCreateTime=" + globalIdCreateTime + ", datasetVersion=" + datasetVersion + ", dataFiles=" + dataFiles + '}';
106+
return "DatasetDTO{" + "id=" + id + ", identifier=" + identifier + ", protocol=" + protocol + ", authority=" + authority + ", separator=" + separator + ", globalIdCreateTime=" + globalIdCreateTime + ", datasetVersion=" + datasetVersion + ", dataFiles=" + dataFiles + '}';
98107
}
99108

100109
public void setMetadataLanguage(String metadataLanguage) {

0 commit comments

Comments
 (0)