Skip to content

Commit f0ae22d

Browse files
authored
Merge pull request #11685 from QualitativeDataRepository/IQSS/9247-CurationStatus_updates
Re-fix Curation Status bug
2 parents b7c31ac + 9f837dc commit f0ae22d

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
The updates to support keeping the history of curation status labels added in #11268
2+
will incorrectly show curation statuses added prior to v6.7 as the current one, regardless of
3+
whether newer statuses exist. This PR corrects the problem.
4+
5+
(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
6+
for entries that have null createtimes. The code fix in this version properly handles null dates as indicating older/pre v6.7 curationstatuses.)

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,10 @@ public enum VersionState {
216216
@OneToMany(mappedBy = "datasetVersion", cascade={CascadeType.REMOVE, CascadeType.MERGE, CascadeType.PERSIST})
217217
private List<WorkflowComment> workflowComments;
218218

219+
/*
220+
* 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
221+
* in the future, it is presumably more efficient that sorting in our code.
222+
*/
219223
@OneToMany(mappedBy = "datasetVersion", cascade = CascadeType.ALL, orphanRemoval = true)
220224
@OrderBy("createTime DESC NULLS LAST")
221225
private List<CurationStatus> curationStatuses = new ArrayList<>();
@@ -2159,6 +2163,18 @@ public String getLocaleLastUpdateTime() {
21592163

21602164
// Add methods to manage curationLabels
21612165
public List<CurationStatus> getCurationStatuses() {
2166+
// Sort the list to ensure null createTime values appear last
2167+
/*
2168+
* Note that the ORDER DESC NULLS LAST annotation on this list should sort this way,
2169+
* but, as of v6.7, the NULLS LAST aspect is not working.
2170+
* The code here assured both the DESC order and NULLS LAST.
2171+
*/
2172+
if (curationStatuses != null) {
2173+
curationStatuses.sort(Comparator.comparing(
2174+
CurationStatus::getCreateTime,
2175+
Comparator.nullsLast(Comparator.reverseOrder())
2176+
));
2177+
}
21622178
return curationStatuses;
21632179
}
21642180

0 commit comments

Comments
 (0)