Skip to content

Commit 56cfa92

Browse files
committed
#10476 fix DataversesIT
1 parent 67bbd37 commit 56cfa92

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/main/java/edu/harvard/iq/dataverse/util/json/JsonPrinter.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -675,18 +675,21 @@ public static JsonObjectBuilder json(MetadataBlock metadataBlock, boolean printO
675675
if (!datasetFieldType.isChild()) {
676676
Boolean fieldDisplayOnCreate = datasetFieldType.isDisplayOnCreate();
677677
Boolean fieldRequired = datasetFieldType.isRequired();
678+
Boolean fieldExcludedDisplayOnCreateCollection = false;
679+
Boolean fieldIncludedDisplayOnCreateCollection = false;
678680
Boolean fieldExcludedCollection = false;
679-
Boolean fieldIncludedCollection = false;
681+
680682
if (ownerDataverse != null){
681683
DataverseFieldTypeInputLevel custom = datasetFieldInputLevelService.findByDataverseIdDatasetFieldTypeId(ownerDataverse.getId(), datasetFieldType.getId() );
682684
if(custom != null){
683-
fieldIncludedCollection = custom.isDisplayOnCreate();
684-
fieldExcludedCollection = !custom.isDisplayOnCreate();
685+
fieldIncludedDisplayOnCreateCollection = custom.isDisplayOnCreate();
686+
fieldExcludedDisplayOnCreateCollection = !custom.isDisplayOnCreate();
687+
fieldExcludedCollection = !custom.isInclude();
685688
}
686689
}
687690

688-
if (!printOnlyDisplayedOnCreateDatasetFieldTypes || (fieldDisplayOnCreate != null && fieldDisplayOnCreate && !fieldExcludedCollection)
689-
|| fieldRequired || fieldIncludedCollection ) {
691+
if ((!printOnlyDisplayedOnCreateDatasetFieldTypes && !fieldExcludedCollection) || (fieldDisplayOnCreate != null && fieldDisplayOnCreate && !fieldExcludedDisplayOnCreateCollection)
692+
|| fieldRequired || fieldIncludedDisplayOnCreateCollection ) {
690693
fieldsBuilder.add(datasetFieldType.getName(), json(datasetFieldType, ownerDataverse));
691694
}
692695
}

src/test/java/edu/harvard/iq/dataverse/api/DataversesIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,7 @@ public void testListMetadataBlocks() {
10821082

10831083
// notesText has displayOnCreate=true but has include=false, so should not be retrieved
10841084
String notesTextCitationMetadataField = listMetadataBlocksResponse.then().extract().path(String.format("data[%d].fields.notesText.name", citationMetadataBlockIndex));
1085-
assertNotNull(notesTextCitationMetadataField);
1085+
assertNull(notesTextCitationMetadataField);
10861086

10871087
// producerName is a conditionally required field, so should not be retrieved
10881088
String producerNameCitationMetadataField = listMetadataBlocksResponse.then().extract().path(String.format("data[%d].fields.producerName.name", citationMetadataBlockIndex));

0 commit comments

Comments
 (0)