Skip to content

Commit 0ee4268

Browse files
authored
Merge pull request #11991 from GlobalDataverseCommunityConsortium/IQSS/11990-controlledvocab_editing_error
IQSS/11990 Controlled Vocabulary Field editing error
2 parents 46fb69d + 722a0bf commit 0ee4268

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
### Bug Fix
2+
3+
Editing a controlled vocabulary field (i.e. one with values specified in the field's metadatablock) that only allows a single selection would also update the value in the prior published version if (and only if) the edit was made starting from the published version (versus an existing draft). This is now fixed.
4+
The bug appears to be 11+ years old and previously unreported. As the value in the database was overwritten, there is no simple way to detect if/when this occurred without looking at backups or archival file copies.
5+

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ public void setParentDatasetFieldCompoundValue(DatasetFieldCompoundValue parentD
172172
}
173173

174174
@OneToMany(mappedBy = "parentDatasetField", orphanRemoval = true, cascade = {CascadeType.REMOVE, CascadeType.MERGE, CascadeType.PERSIST})
175-
@OrderBy("displayOrder ASC")
176175
private List<DatasetFieldCompoundValue> datasetFieldCompoundValues = new ArrayList<>();
177176

178177
public List<DatasetFieldCompoundValue> getDatasetFieldCompoundValues() {
@@ -197,6 +196,7 @@ public void setDatasetFieldValues(List<DatasetFieldValue> datasetFieldValues) {
197196

198197
@ManyToMany(cascade = {CascadeType.MERGE})
199198
@JoinTable(indexes = {@Index(columnList="datasetfield_id"),@Index(columnList="controlledvocabularyvalues_id")})
199+
@OrderBy("displayOrder ASC")
200200
private List<ControlledVocabularyValue> controlledVocabularyValues = new ArrayList<>();
201201

202202
public List<ControlledVocabularyValue> getControlledVocabularyValues() {
@@ -604,14 +604,15 @@ private DatasetField copy(Object versionOrTemplate, DatasetFieldCompoundValue pa
604604

605605
if (versionOrTemplate != null) {
606606
if (versionOrTemplate instanceof DatasetVersion) {
607-
dsf.setDatasetVersion((DatasetVersion) versionOrTemplate);
607+
dsf.setDatasetVersion((DatasetVersion) versionOrTemplate);
608608
} else {
609609
dsf.setTemplate((Template) versionOrTemplate);
610610
}
611611
}
612612

613613
dsf.setParentDatasetFieldCompoundValue(parent);
614-
dsf.setControlledVocabularyValues(controlledVocabularyValues);
614+
615+
dsf.getControlledVocabularyValues().addAll(controlledVocabularyValues);
615616

616617
for (DatasetFieldValue dsfv : datasetFieldValues) {
617618
dsf.getDatasetFieldValues().add(dsfv.copy(dsf));

0 commit comments

Comments
 (0)