Skip to content

Commit

Permalink
one more addition for IQSS#2243 - added temporalCoverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
landreev committed Nov 7, 2017
1 parent 8c74e37 commit 9f1d057
Showing 1 changed file with 50 additions and 4 deletions.
54 changes: 50 additions & 4 deletions src/main/java/edu/harvard/iq/dataverse/DatasetVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,39 @@ public List<DatasetAuthor> getDatasetAuthors() {
return retList;
}

public List<String> getTimePeriodsCovered() {
List <String> retList = new ArrayList<>();
for (DatasetField dsf : this.getDatasetFields()) {
if (dsf.getDatasetFieldType().getName().equals(DatasetFieldConstant.timePeriodCovered)) {
for (DatasetFieldCompoundValue timePeriodValue : dsf.getDatasetFieldCompoundValues()) {
String start = "";
String end = "";
for (DatasetField subField : timePeriodValue.getChildDatasetFields()) {
if (subField.getDatasetFieldType().getName().equals(DatasetFieldConstant.timePeriodCoveredStart)) {
if (subField.isEmptyForDisplay()) {
start = null;
} else {
start = subField.getDisplayValue();
}
}
if (subField.getDatasetFieldType().getName().equals(DatasetFieldConstant.timePeriodCoveredEnd)) {
if (subField.isEmptyForDisplay()) {
end = null;
} else {
end = subField.getDisplayValue();
}
}

}
if (start != null && end != null) {
retList.add(start + "/" + end);
}
}
}
}
return retList;
}

/**
* @return List of Strings containing the names of the authors.
*/
Expand Down Expand Up @@ -1151,7 +1184,10 @@ public String getJsonLd() {
* (Per @jggautier's comment 03/11/2017 in #2243, we are putting datePublished
* back -- L.A.)
*/
job.add("datePublished", this.getDataset().getPublicationDateFormattedYYYYMMDD());
String datePublished = this.getDataset().getPublicationDateFormattedYYYYMMDD();
if (datePublished != null) {
job.add("datePublished", datePublished);
}

/**
* "dateModified" is more appropriate for a version: "The date on which
Expand All @@ -1173,16 +1209,26 @@ public String getJsonLd() {
citation.add("@type", "Dataset");
citation.add("text", this.getCitation());
job.add("citation", citation);
/* TODO: should we use the HTML-style citation, i.e. this.getCitation(true) instead -- L.A.?) */
/* should we use the HTML-style citation, i.e. this.getCitation(true) instead -- L.A.?) */

/**
* temporalCoverage:
* TODO (if available)
* (if available)
*/

List<String> timePeriodsCovered = this.getTimePeriodsCovered();
if (timePeriodsCovered.size() > 0) {
JsonArrayBuilder temporalCoverage = Json.createArrayBuilder();
for (String timePeriod : timePeriodsCovered) {
temporalCoverage.add(timePeriod);
}
job.add("temporalCoverage", temporalCoverage);
}

/**
* spatialCoverage:
* TODO (if available)
* (if available)
* TODO
*/

/**
Expand Down

0 comments on commit 9f1d057

Please sign in to comment.