From 1606a12ce8bc9dac5129dc85fb1ff32da6bbc5ea Mon Sep 17 00:00:00 2001 From: GPortas Date: Wed, 19 Jun 2024 16:53:37 +0100 Subject: [PATCH] Fixed: JsonPrinter metadata blocks dataset field type isRequired logic --- .../java/edu/harvard/iq/dataverse/util/json/JsonPrinter.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/edu/harvard/iq/dataverse/util/json/JsonPrinter.java b/src/main/java/edu/harvard/iq/dataverse/util/json/JsonPrinter.java index fbb9e22e929..4da17c5d58b 100644 --- a/src/main/java/edu/harvard/iq/dataverse/util/json/JsonPrinter.java +++ b/src/main/java/edu/harvard/iq/dataverse/util/json/JsonPrinter.java @@ -647,8 +647,11 @@ public static JsonObjectBuilder json(MetadataBlock metadataBlock, boolean printO boolean requiredAsInputLevel = isInputLevel && ownerDataverse.isDatasetFieldTypeRequiredAsInputLevel(datasetFieldTypeId); boolean includedAsInputLevel = isInputLevel && ownerDataverse.isDatasetFieldTypeIncludedAsInputLevel(datasetFieldTypeId); + DatasetFieldType parentDatasetFieldType = datasetFieldType.getParentDatasetFieldType(); + boolean isRequired = parentDatasetFieldType == null ? datasetFieldType.isRequired() : parentDatasetFieldType.isRequired(); + boolean displayCondition = printOnlyDisplayedOnCreateDatasetFieldTypes - ? (datasetFieldType.isDisplayOnCreate() || datasetFieldType.isRequired() || requiredAsInputLevel) + ? (datasetFieldType.isDisplayOnCreate() || isRequired || requiredAsInputLevel) : !isInputLevel || includedAsInputLevel; if (displayCondition) {