Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#4235 trim trailing spaces #5391

Merged
merged 3 commits into from Dec 17, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/DatasetField.java
Expand Up @@ -550,6 +550,22 @@ public void setValueDisplayOrder() {
}
}
}

public void trimTrailingSpaces() {
if (this.getDatasetFieldType().isPrimitive() && !this.getDatasetFieldType().isControlledVocabulary()) {
for (int i = 0; i < datasetFieldValues.size(); i++) {
datasetFieldValues.get(i).setValue(datasetFieldValues.get(i).getValue().trim());
}
} else if (this.getDatasetFieldType().isCompound()) {
for (int i = 0; i < datasetFieldCompoundValues.size(); i++) {
DatasetFieldCompoundValue compoundValue = datasetFieldCompoundValues.get(i);
for (DatasetField dsf : compoundValue.getChildDatasetFields()) {
dsf.trimTrailingSpaces();
}
}
}
}


public void addDatasetFieldValue(int index) {
datasetFieldValues.add(index, new DatasetFieldValue(this));
Expand Down
Expand Up @@ -130,6 +130,10 @@ protected void tidyUpFields(DatasetVersion dsv) {
while (dsfItSort.hasNext()) {
dsfItSort.next().setValueDisplayOrder();
}
Iterator<DatasetField> dsfItTrim = dsv.getDatasetFields().iterator();
while (dsfItTrim.hasNext()) {
dsfItTrim.next().trimTrailingSpaces();
}
}

/**
Expand Down