Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions doc/release-notes/11685-CurationStatus_fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
The updates to support keeping the history of curation status labels added in #11268
will incorrectly show curation statuses added prior to v6.7 as the current one, regardless of
whether newer statuses exist. This PR corrects the problem.

(As a work-around for 6.7 admins can add createtime dates (must be prior to when 6.7 was installed) to the curationstatus table
for entries that have null createtimes. The code fix in this version properly handles null dates as indicating older/pre v6.7 curationstatuses.)
16 changes: 16 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/DatasetVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ public enum VersionState {
@OneToMany(mappedBy = "datasetVersion", cascade={CascadeType.REMOVE, CascadeType.MERGE, CascadeType.PERSIST})
private List<WorkflowComment> workflowComments;

/*
* As of v6.7, the NULLS LAST part of the annotation below appears to not be working. Explicit sorting has been added in the getCurationStatuses() method. The annotation is kept since, if it does work
* in the future, it is presumably more efficient that sorting in our code.
*/
@OneToMany(mappedBy = "datasetVersion", cascade = CascadeType.ALL, orphanRemoval = true)
@OrderBy("createTime DESC NULLS LAST")
private List<CurationStatus> curationStatuses = new ArrayList<>();
Expand Down Expand Up @@ -2159,6 +2163,18 @@ public String getLocaleLastUpdateTime() {

// Add methods to manage curationLabels
public List<CurationStatus> getCurationStatuses() {
// Sort the list to ensure null createTime values appear last
/*
* Note that the ORDER DESC NULLS LAST annotation on this list should sort this way,
* but, as of v6.7, the NULLS LAST aspect is not working.
* The code here assured both the DESC order and NULLS LAST.
*/
if (curationStatuses != null) {
curationStatuses.sort(Comparator.comparing(
CurationStatus::getCreateTime,
Comparator.nullsLast(Comparator.reverseOrder())
));
}
return curationStatuses;
}

Expand Down