Skip to content

Commit

Permalink
Merge pull request #9256 from philippconzett/patch-3
Browse files Browse the repository at this point in the history
Make Series multiple #9255
  • Loading branch information
kcondon authored May 2, 2023
2 parents 90d76e9 + ec69508 commit 8181854
Show file tree
Hide file tree
Showing 13 changed files with 151 additions and 80 deletions.
6 changes: 3 additions & 3 deletions conf/solr/8.11.1/schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,9 @@
<field name="responseRate" type="text_en" multiValued="false" stored="true" indexed="true"/>
<field name="samplingErrorEstimates" type="text_en" multiValued="false" stored="true" indexed="true"/>
<field name="samplingProcedure" type="text_en" multiValued="false" stored="true" indexed="true"/>
<field name="series" type="text_en" multiValued="false" stored="true" indexed="true"/>
<field name="seriesInformation" type="text_en" multiValued="false" stored="true" indexed="true"/>
<field name="seriesName" type="text_en" multiValued="false" stored="true" indexed="true"/>
<field name="series" type="text_en" multiValued="true" stored="true" indexed="true"/>
<field name="seriesInformation" type="text_en" multiValued="true" stored="true" indexed="true"/>
<field name="seriesName" type="text_en" multiValued="true" stored="true" indexed="true"/>
<field name="socialScienceNotes" type="text_en" multiValued="false" stored="true" indexed="true"/>
<field name="socialScienceNotesSubject" type="text_en" multiValued="false" stored="true" indexed="true"/>
<field name="socialScienceNotesText" type="text_en" multiValued="false" stored="true" indexed="true"/>
Expand Down
42 changes: 42 additions & 0 deletions doc/release-notes/9256-series.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
## Metadata field Series now repeatable
This enhancement allows depositors to define multiple instances of the metadata field Series in the Citation Metadata block.

## Major Use Cases and Infrastructure Enhancements
* Data contained in a dataset may belong to multiple series. Making the field Series repeatable will make it possible to reflect this fact in the dataset metadata. (Issue #9255, PR #9256)

### Additional Upgrade Steps

Update the Citation metadata block:

wget https://github.com/IQSS/dataverse/releases/download/v5.14/citation.tsv
curl http://localhost:8080/api/admin/datasetfield/load -X POST --data-binary @citation.tsv -H "Content-type: text/tab-separated-values"

## Additional Release Steps

1. Replace Solr schema.xml to allow multiple series to be used. See specific instructions below for those installations without custom metadata blocks (1a) and those with custom metadata blocks (1b).

1a.

For installations without Custom Metadata Blocks:

-stop solr instance (usually service solr stop, depending on solr installation/OS, see the Installation Guide

-replace schema.xml

cp /tmp/dvinstall/schema.xml /usr/local/solr/solr-8.11.1/server/solr/collection1/conf

-start solr instance (usually service solr start, depending on solr/OS)

1b.

For installations with Custom Metadata Blocks:

-stop solr instance (usually service solr stop, depending on solr installation/OS, see the Installation Guide

edit the following lines to your schema.xml (to indicate that series and its components are now multiValued='true"):

<field name="series" type="string" stored="true" indexed="true" multiValued="true"/>
<field name="seriesInformation" type="text_en" multiValued="true" stored="true" indexed="true"/>
<field name="seriesName" type="text_en" multiValued="true" stored="true" indexed="true"/>

-restart solr instance (usually service solr start, depending on solr/OS)
8 changes: 6 additions & 2 deletions doc/sphinx-guides/source/_static/api/ddi_dataset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,12 @@
<depDate>1002-01-01</depDate>
</distStmt>
<serStmt>
<serName>SeriesName</serName>
<serInfo>SeriesInformation</serInfo>
<serName>SeriesName One</serName>
<serInfo>SeriesInformation One</serInfo>
</serStmt>
<serStmt>
<serName>SeriesName Two</serName>
<serInfo>SeriesInformation Two</serInfo>
</serStmt>
</citation>
<stdyInfo>
Expand Down
2 changes: 1 addition & 1 deletion scripts/api/data/metadatablocks/citation.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
dateOfCollectionStart Start Date The date when the data collection started YYYY-MM-DD date 62 #NAME: #VALUE FALSE FALSE FALSE FALSE FALSE FALSE dateOfCollection citation
dateOfCollectionEnd End Date The date when the data collection ended YYYY-MM-DD date 63 #NAME: #VALUE FALSE FALSE FALSE FALSE FALSE FALSE dateOfCollection citation
kindOfData Data Type The type of data included in the files (e.g. survey data, clinical data, or machine-readable text) text 64 TRUE FALSE TRUE TRUE FALSE FALSE citation http://rdf-vocabulary.ddialliance.org/discovery#kindOfData
series Series Information about the dataset series to which the Dataset belong none 65 : FALSE FALSE FALSE FALSE FALSE FALSE citation
series Series Information about the dataset series to which the Dataset belong none 65 : FALSE FALSE TRUE FALSE FALSE FALSE citation
seriesName Name The name of the dataset series text 66 #VALUE TRUE FALSE FALSE TRUE FALSE FALSE series citation
seriesInformation Information Can include 1) a history of the series and 2) a summary of features that apply to the series textbox 67 #VALUE FALSE FALSE FALSE FALSE FALSE FALSE series citation
software Software Information about the software used to generate the Dataset none 68 , FALSE FALSE TRUE FALSE FALSE FALSE citation https://www.w3.org/TR/prov-o/#wasGeneratedBy
Expand Down
28 changes: 20 additions & 8 deletions src/main/java/edu/harvard/iq/dataverse/DataCitation.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class DataCitation {
private String publisher;
private boolean direct;
private List<String> funders;
private String seriesTitle;
private List<String> seriesTitles;
private String description;
private List<String> datesOfCollection;
private List<String> keywords;
Expand Down Expand Up @@ -135,7 +135,7 @@ private void getCommonValuesFrom(DatasetVersion dsv) {

datesOfCollection = dsv.getDatesOfCollection();
title = dsv.getTitle();
seriesTitle = dsv.getSeriesTitle();
seriesTitles = dsv.getSeriesTitles();
keywords = dsv.getKeywords();
languages = dsv.getLanguages();
spatialCoverages = dsv.getSpatialCoverages();
Expand Down Expand Up @@ -330,8 +330,10 @@ public void writeAsRISCitation(OutputStream os) throws IOException {
out.write("TY - DATA" + "\r\n");
out.write("T1 - " + getTitle() + "\r\n");
}
if (seriesTitle != null) {
out.write("T3 - " + seriesTitle + "\r\n");
if (seriesTitles != null) {
for (String seriesTitle : seriesTitles) {
out.write("T3 - " + seriesTitle + "\r\n");
}
}
/* Removing abstract/description per Request from G. King in #3759
if(description!=null) {
Expand Down Expand Up @@ -505,12 +507,22 @@ private void createEndNoteXML(XMLStreamWriter xmlw) throws XMLStreamException {
xmlw.writeCharacters(title);
xmlw.writeEndElement(); // title
}

if (seriesTitle != null) {
xmlw.writeStartElement("tertiary-title");
xmlw.writeCharacters(seriesTitle);

/*
If I say just !"isEmpty" for series titles I get a failure
on testToEndNoteString_withoutTitleAndAuthor
with a null pointer on build -SEK 3/31/23
*/
if (seriesTitles != null && !seriesTitles.isEmpty() ) {
xmlw.writeStartElement("tertiary-titles");
for (String seriesTitle : seriesTitles){
xmlw.writeStartElement("tertiary-title");
xmlw.writeCharacters(seriesTitle);
xmlw.writeEndElement(); // tertiary-title
}
xmlw.writeEndElement(); // tertiary-title
}

xmlw.writeEndElement(); // titles

xmlw.writeStartElement("section");
Expand Down
9 changes: 3 additions & 6 deletions src/main/java/edu/harvard/iq/dataverse/DatasetVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -1366,17 +1366,14 @@ public List<String> getUniqueGrantAgencyValues() {
}

/**
* @return String containing the version's series title
* @return List of Strings containing the version's series title(s)
*/
public String getSeriesTitle() {
public List<String> getSeriesTitles() {

List<String> seriesNames = getCompoundChildFieldValues(DatasetFieldConstant.series,
DatasetFieldConstant.seriesName);
if (seriesNames.size() > 1) {
logger.warning("More than one series title found for datasetVersion: " + this.id);
}
if (!seriesNames.isEmpty()) {
return seriesNames.get(0);
return seriesNames;
} else {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1266,24 +1266,26 @@ private void parseVersionNumber(DatasetVersionDTO dvDTO, String versionNumber) {

}

private void processSerStmt(XMLStreamReader xmlr, MetadataBlockDTO citation) throws XMLStreamException {
FieldDTO seriesName=null;
FieldDTO seriesInformation=null;
for (int event = xmlr.next(); event != XMLStreamConstants.END_DOCUMENT; event = xmlr.next()) {
private void processSerStmt(XMLStreamReader xmlr, MetadataBlockDTO citation) throws XMLStreamException {
FieldDTO seriesInformation = null;
FieldDTO seriesName = null;
for (int event = xmlr.next(); event != XMLStreamConstants.END_DOCUMENT; event = xmlr.next()) {
if (event == XMLStreamConstants.START_ELEMENT) {
if (xmlr.getLocalName().equals("serInfo")) {
seriesInformation = FieldDTO.createPrimitiveFieldDTO("seriesInformation", parseText(xmlr));
}
if (xmlr.getLocalName().equals("serName")) {
seriesName = FieldDTO.createPrimitiveFieldDTO("seriesName", parseText(xmlr));

} else if (xmlr.getLocalName().equals("serInfo")) {
seriesInformation=FieldDTO.createPrimitiveFieldDTO("seriesInformation", parseText(xmlr) );
seriesName = FieldDTO.createPrimitiveFieldDTO("seriesName", parseText(xmlr));
}
} else if (event == XMLStreamConstants.END_ELEMENT) {
if (xmlr.getLocalName().equals("serStmt")) {
citation.getFields().add(FieldDTO.createCompoundFieldDTO("series",seriesName,seriesInformation ));
if (seriesInformation != null || seriesName != null) {
citation.addField(FieldDTO.createMultipleCompoundFieldDTO("series", seriesName, seriesInformation ));
}
return;
}
}
}
}
}

private void processDistStmt(XMLStreamReader xmlr, MetadataBlockDTO citation) throws XMLStreamException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1292,33 +1292,34 @@ private static void writeSeriesElement(XMLStreamWriter xmlw, DatasetVersionDTO d
for (Map.Entry<String, MetadataBlockDTO> entry : datasetVersionDTO.getMetadataBlocks().entrySet()) {
String key = entry.getKey();
MetadataBlockDTO value = entry.getValue();
if ("citation".equals(key)) {
if ("citation".equals(key)) {
for (FieldDTO fieldDTO : value.getFields()) {
if (DatasetFieldConstant.series.equals(fieldDTO.getTypeName())) {
xmlw.writeStartElement("serStmt");
String seriesName = "";
String seriesInformation = "";
Set<FieldDTO> foo = fieldDTO.getSingleCompound();
for (HashSet<FieldDTO> foo : fieldDTO.getMultipleCompound()) {
xmlw.writeStartElement("serStmt");
for (Iterator<FieldDTO> iterator = foo.iterator(); iterator.hasNext();) {
FieldDTO next = iterator.next();
if (DatasetFieldConstant.seriesName.equals(next.getTypeName())) {
seriesName = next.getSinglePrimitive();
seriesName = next.getSinglePrimitive();
}
if (DatasetFieldConstant.seriesInformation.equals(next.getTypeName())) {
seriesInformation = next.getSinglePrimitive();
seriesInformation = next.getSinglePrimitive();
}
}
if (!seriesName.isEmpty()){
xmlw.writeStartElement("serName");
if (!seriesName.isEmpty()) {
xmlw.writeStartElement("serName");
xmlw.writeCharacters(seriesName);
xmlw.writeEndElement(); //grantno
xmlw.writeEndElement(); //serName
}
if (!seriesInformation.isEmpty()){
xmlw.writeStartElement("serInfo");
if (!seriesInformation.isEmpty()) {
xmlw.writeStartElement("serInfo");
xmlw.writeCharacters(seriesInformation);
xmlw.writeEndElement(); //grantno
xmlw.writeEndElement(); //serInfo
}
xmlw.writeEndElement(); //serStmt
xmlw.writeEndElement(); //serStmt
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1266,26 +1266,17 @@ public static void writeDescriptionsElement(XMLStreamWriter xmlw, DatasetVersion
if (DatasetFieldConstant.series.equals(fieldDTO.getTypeName())) {
// String seriesName = null;
String seriesInformation = null;

Set<FieldDTO> fieldDTOs = fieldDTO.getSingleCompound();
for (Iterator<FieldDTO> iterator = fieldDTOs.iterator(); iterator.hasNext();) {
FieldDTO next = iterator.next();
/*if (DatasetFieldConstant.seriesName.equals(next.getTypeName())) {
seriesName = next.getSinglePrimitive();
}*/
if (DatasetFieldConstant.seriesInformation.equals(next.getTypeName())) {
seriesInformation = next.getSinglePrimitive();
for (HashSet<FieldDTO> fieldDTOs : fieldDTO.getMultipleCompound()) {
for (Iterator<FieldDTO> iterator = fieldDTOs.iterator(); iterator.hasNext();) {
FieldDTO next = iterator.next();
if (DatasetFieldConstant.seriesInformation.equals(next.getTypeName())) {
seriesInformation = next.getSinglePrimitive();
}
}
if (StringUtils.isNotBlank(seriesInformation)) {
description_check = writeOpenTag(xmlw, "descriptions", description_check);
writeDescriptionElement(xmlw, "SeriesInformation", seriesInformation, language);
}
}

/*if (StringUtils.isNotBlank(seriesName)){
contributor_check = writeOpenTag(xmlw, "descriptions", description_check);
writeDescriptionElement(xmlw, "SeriesInformation", seriesName);
}*/
if (StringUtils.isNotBlank(seriesInformation)) {
description_check = writeOpenTag(xmlw, "descriptions", description_check);
writeDescriptionElement(xmlw, "SeriesInformation", seriesInformation, language);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ public void testImportDDI() throws IOException, InterruptedException {
// destroyDataset() line lately)

Thread.sleep(1000L);

Integer datasetIdIntRelease = JsonPath.from(importDDIRelease.body().asString()).getInt("data.id");
Response destroyDatasetResponseRelease = UtilIT.destroyDataset(datasetIdIntRelease, apiToken);
assertEquals(200, destroyDatasetResponseRelease.getStatusCode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -694,9 +694,10 @@
},
{
"typeName": "series",
"multiple": false,
"multiple": true,
"typeClass": "compound",
"value": {
"value": [
{
"seriesName": {
"typeName": "seriesName",
"multiple": false,
Expand All @@ -710,6 +711,7 @@
"value": "SeriesInformation"
}
}
]
},
{
"typeName": "software",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -653,22 +653,38 @@
},
{
"typeName": "series",
"multiple": false,
"multiple": true,
"typeClass": "compound",
"value": {
"seriesName": {
"typeName": "seriesName",
"multiple": false,
"typeClass": "primitive",
"value": "SeriesName"
"value": [
{
"seriesName": {
"typeName": "seriesName",
"multiple": false,
"typeClass": "primitive",
"value": "SeriesName1"
},
"seriesInformation": {
"typeName": "seriesInformation",
"multiple": false,
"typeClass": "primitive",
"value": "SeriesInformation1"
}
},
"seriesInformation": {
"typeName": "seriesInformation",
"multiple": false,
"typeClass": "primitive",
"value": "SeriesInformation"
}
}
{
"seriesName": {
"typeName": "seriesName",
"multiple": false,
"typeClass": "primitive",
"value": "SeriesName2"
},
"seriesInformation": {
"typeName": "seriesInformation",
"multiple": false,
"typeClass": "primitive",
"value": "SeriesInformation2"
}
}
]
},
{
"typeName": "software",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,12 @@
<distDate>1004-01-01</distDate>
</distStmt>
<serStmt>
<serName>SeriesName</serName>
<serInfo>SeriesInformation</serInfo>
<serName>SeriesName1</serName>
<serInfo>SeriesInformation1</serInfo>
</serStmt>
<serStmt>
<serName>SeriesName2</serName>
<serInfo>SeriesInformation2</serInfo>
</serStmt>
<holdings URI="https://doi.org/10.5072/FK2/WKUKGV"/>
</citation>
Expand Down

0 comments on commit 8181854

Please sign in to comment.