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
5 changes: 5 additions & 0 deletions doc/release-notes/11990-controlled-vocab-edit-error.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### Bug Fix

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.
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.

7 changes: 4 additions & 3 deletions src/main/java/edu/harvard/iq/dataverse/DatasetField.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ public void setParentDatasetFieldCompoundValue(DatasetFieldCompoundValue parentD
}

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

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

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

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

if (versionOrTemplate != null) {
if (versionOrTemplate instanceof DatasetVersion) {
dsf.setDatasetVersion((DatasetVersion) versionOrTemplate);
dsf.setDatasetVersion((DatasetVersion) versionOrTemplate);
} else {
dsf.setTemplate((Template) versionOrTemplate);
}
}

dsf.setParentDatasetFieldCompoundValue(parent);
dsf.setControlledVocabularyValues(controlledVocabularyValues);

dsf.getControlledVocabularyValues().addAll(controlledVocabularyValues);

for (DatasetFieldValue dsfv : datasetFieldValues) {
dsf.getDatasetFieldValues().add(dsfv.copy(dsf));
Expand Down