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

feat: add "string" type for metadata fields #11321

Merged
merged 5 commits into from
Mar 31, 2025
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/11147-string-field-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
The "string" type has been added as a new field type for metadata fields.

In contrast to "text" fields, "string" fields are stored and indexed exactly as provided, without any text analysis or transformations.

This field type is suitable for fields like IDs (e.g. ORCIDs) or enums, where exact matches are required when searching.
7 changes: 7 additions & 0 deletions doc/sphinx-guides/source/admin/metadatacustomization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ Each of the three main sections own sets of properties:
| | | | \• email |
| | | | \• text |
| | | | \• textbox |
| | | | \• string |
| | | | \• url |
| | | | \• int |
| | | | \• float |
Expand Down Expand Up @@ -315,6 +316,12 @@ FieldType definitions
| | section of the Dataset + File |
| | Management page in the User Guide. |
+---------------+------------------------------------+
| string | Any text may be entered into this |
| | field. The value is stored and |
| | indexed exactly as provided, |
| | without any text analysis or |
| | transformations. |
+---------------+------------------------------------+
| url | If not empty, field must contain |
| | a valid URL. |
+---------------+------------------------------------+
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/edu/harvard/iq/dataverse/DatasetFieldType.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public class DatasetFieldType implements Serializable, Comparable<DatasetFieldTy
* The set of possible metatypes of the field. Used for validation and layout.
*/
public enum FieldType {
TEXT, TEXTBOX, DATE, EMAIL, URL, FLOAT, INT, NONE
};
TEXT, TEXTBOX, STRING, DATE, EMAIL, URL, FLOAT, INT, NONE
};

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand Down Expand Up @@ -558,6 +558,8 @@ public SolrField getSolrField() {
solrType = SolrField.SolrType.INTEGER;
} else if (fieldType.equals(FieldType.FLOAT)) {
solrType = SolrField.SolrType.FLOAT;
} else if (fieldType.equals(FieldType.STRING)) {
solrType = SolrField.SolrType.STRING;
}

Boolean anyParentAllowsMultiplesBoolean = false;
Expand Down
3 changes: 3 additions & 0 deletions src/main/webapp/datasetFieldForEditFragment.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
styleClass="form-control #{dsfv.datasetField.datasetFieldType.name == 'title' and DatasetPage.editMode == 'CREATE' ? 'datasetfield-title' : ''}"
rendered="#{!dsfv.datasetField.datasetFieldType.controlledVocabulary
and (dsfv.datasetField.datasetFieldType.fieldType == 'TEXT'
or dsfv.datasetField.datasetFieldType.fieldType == 'STRING'
or dsfv.datasetField.datasetFieldType.fieldType == 'INT'
or dsfv.datasetField.datasetFieldType.fieldType == 'FLOAT'
or dsfv.datasetField.datasetFieldType.fieldType == 'URL'
Expand All @@ -32,6 +33,7 @@
styleClass="form-control #{dsfv.datasetField.datasetFieldType.name == 'title' and DatasetPage.editMode == 'CREATE' ? 'datasetfield-title' : ''}"
rendered="#{!dsfv.datasetField.datasetFieldType.controlledVocabulary
and (dsfv.datasetField.datasetFieldType.fieldType == 'TEXT'
or dsfv.datasetField.datasetFieldType.fieldType == 'STRING'
or dsfv.datasetField.datasetFieldType.fieldType == 'INT'
or dsfv.datasetField.datasetFieldType.fieldType == 'FLOAT'
or dsfv.datasetField.datasetFieldType.fieldType == 'URL'
Expand All @@ -56,6 +58,7 @@
styleClass="form-control #{dsfv.datasetField.datasetFieldType.name == 'title' and DatasetPage.editMode == 'CREATE' ? 'datasetfield-title' : ''}"
rendered="#{!dsfv.datasetField.datasetFieldType.controlledVocabulary
and (dsfv.datasetField.datasetFieldType.fieldType == 'TEXT'
or dsfv.datasetField.datasetFieldType.fieldType == 'STRING'
or dsfv.datasetField.datasetFieldType.fieldType == 'INT'
or dsfv.datasetField.datasetFieldType.fieldType == 'FLOAT'
or dsfv.datasetField.datasetFieldType.fieldType == 'URL'
Expand Down