Skip to content

Commit

Permalink
Merge pull request #10938 from IQSS/5051-ddi-tabular-file-description
Browse files Browse the repository at this point in the history
adding description info to the fileDsc seciton in DDI CodeBook. #5051
  • Loading branch information
ofahimIQSS authored Nov 13, 2024
2 parents 61b8046 + 84e0fad commit dc1de87
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,10 @@ public class DDIExportServiceBean {
public static final String LEVEL_FILE = "file";
public static final String NOTE_TYPE_UNF = "VDC:UNF";
public static final String NOTE_TYPE_TAG = "DATAVERSE:TAG";
public static final String NOTE_TYPE_FILEDESCRIPTION = "DATAVERSE:FILEDESC";
public static final String NOTE_SUBJECT_UNF = "Universal Numeric Fingerprint";
public static final String NOTE_SUBJECT_TAG = "Data File Tag";
public static final String NOTE_SUBJECT_FILEDESCRIPTION = "DataFile Description";

/*
* Internal service objects:
Expand Down Expand Up @@ -742,11 +744,6 @@ private void createFileDscr(XMLStreamWriter xmlw, Set<String> excludedFieldSet,
xmlw.writeEndElement(); // fileName
}

/*
xmlw.writeStartElement("fileCont");
xmlw.writeCharacters( df.getContentType() );
xmlw.writeEndElement(); // fileCont
*/
// dimensions
if (checkField("dimensns", excludedFieldSet, includedFieldSet)) {
if (dt.getCaseQuantity() != null || dt.getVarQuantity() != null || dt.getRecordsPerCase() != null) {
Expand Down Expand Up @@ -801,26 +798,6 @@ private void createFileDscr(XMLStreamWriter xmlw, Set<String> excludedFieldSet,
xmlw.writeEndElement(); // notes
}

/*
xmlw.writeStartElement("notes");
writeAttribute( xmlw, "type", "vdc:category" );
xmlw.writeCharacters( fm.getCategory() );
xmlw.writeEndElement(); // notes
*/
// A special note for LOCKSS crawlers indicating the restricted
// status of the file:

/*
if (tdf != null && isRestrictedFile(tdf)) {
xmlw.writeStartElement("notes");
writeAttribute( xmlw, "type", NOTE_TYPE_LOCKSS_CRAWL );
writeAttribute( xmlw, "level", LEVEL_FILE );
writeAttribute( xmlw, "subject", NOTE_SUBJECT_LOCKSS_PERM );
xmlw.writeCharacters( "restricted" );
xmlw.writeEndElement(); // notes
}
*/
if (checkField("tags", excludedFieldSet, includedFieldSet) && df.getTags() != null) {
for (int i = 0; i < df.getTags().size(); i++) {
xmlw.writeStartElement("notes");
Expand All @@ -831,6 +808,17 @@ private void createFileDscr(XMLStreamWriter xmlw, Set<String> excludedFieldSet,
xmlw.writeEndElement(); // notes
}
}

// A dedicated node for the Description entry
if (!StringUtilisEmpty(fm.getDescription())) {
xmlw.writeStartElement("notes");
xmlw.writeAttribute("level", LEVEL_FILE);
xmlw.writeAttribute("type", NOTE_TYPE_FILEDESCRIPTION);
xmlw.writeAttribute("subject", NOTE_SUBJECT_FILEDESCRIPTION);
xmlw.writeCharacters(fm.getDescription());
xmlw.writeEndElement(); // notes
}

xmlw.writeEndElement(); // fileDscr
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
import static edu.harvard.iq.dataverse.export.DDIExportServiceBean.LEVEL_FILE;
import static edu.harvard.iq.dataverse.export.DDIExportServiceBean.NOTE_SUBJECT_TAG;
import static edu.harvard.iq.dataverse.export.DDIExportServiceBean.NOTE_SUBJECT_UNF;
import static edu.harvard.iq.dataverse.export.DDIExportServiceBean.NOTE_SUBJECT_FILEDESCRIPTION;
import static edu.harvard.iq.dataverse.export.DDIExportServiceBean.NOTE_TYPE_TAG;
import static edu.harvard.iq.dataverse.export.DDIExportServiceBean.NOTE_TYPE_UNF;
import static edu.harvard.iq.dataverse.export.DDIExportServiceBean.NOTE_TYPE_FILEDESCRIPTION;
import edu.harvard.iq.dataverse.export.DDIExporter;
import edu.harvard.iq.dataverse.pidproviders.PidUtil;
import edu.harvard.iq.dataverse.settings.SettingsServiceBean;
Expand Down Expand Up @@ -1901,6 +1903,8 @@ private static void createFileDscr(XMLStreamWriter xmlw, JsonArray fileDetails)
xmlw.writeEndElement(); // notes
}

// If any tabular tags are present, each is formatted in a
// dedicated note:
if (fileJson.containsKey("tabularTags")) {
JsonArray tags = fileJson.getJsonArray("tabularTags");
for (int j = 0; j < tags.size(); j++) {
Expand All @@ -1912,6 +1916,17 @@ private static void createFileDscr(XMLStreamWriter xmlw, JsonArray fileDetails)
xmlw.writeEndElement(); // notes
}
}

// Adding a dedicated node for the description entry (for
// non-tabular files we format it under the <txt> field)
if (fileJson.containsKey("description")) {
xmlw.writeStartElement("notes");
xmlw.writeAttribute("level", LEVEL_FILE);
xmlw.writeAttribute("type", NOTE_TYPE_FILEDESCRIPTION);
xmlw.writeAttribute("subject", NOTE_SUBJECT_FILEDESCRIPTION);
xmlw.writeCharacters(fileJson.getString("description"));
xmlw.writeEndElement(); // notes
}

// TODO: add the remaining fileDscr elements!
xmlw.writeEndElement(); // fileDscr
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/propertyFiles/Bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1464,7 +1464,7 @@ dataset.editBtn.itemLabel.deleteDataset=Delete Dataset
dataset.editBtn.itemLabel.deleteDraft=Delete Draft Version
dataset.editBtn.itemLabel.deaccession=Deaccession Dataset
dataset.exportBtn=Export Metadata
dataset.exportBtn.itemLabel.ddi=DDI
dataset.exportBtn.itemLabel.ddi=DDI Codebook v2
dataset.exportBtn.itemLabel.dublinCore=Dublin Core
dataset.exportBtn.itemLabel.schemaDotOrg=Schema.org JSON-LD
dataset.exportBtn.itemLabel.datacite=DataCite
Expand Down Expand Up @@ -1934,7 +1934,7 @@ file.downloadBtn.format.all=All File Formats + Information
file.downloadBtn.format.tab=Tab-Delimited
file.downloadBtn.format.original={0} (Original File Format)
file.downloadBtn.format.rdata=RData
file.downloadBtn.format.var=Variable Metadata
file.downloadBtn.format.var=DDI Codebook v2
file.downloadBtn.format.citation=Data File Citation
file.download.filetype.unknown=Original File Format
file.more.information.link=Link to more file information for
Expand Down

0 comments on commit dc1de87

Please sign in to comment.