@@ -433,9 +433,6 @@ public void setValidationMessage(String validationMessage) {
433433 private Boolean required ;
434434 @ Transient
435435 private Boolean hasRequiredChildren ;
436-
437- @ Transient
438- private Boolean hasRequiredChildrenDV ;
439436
440437 public boolean isRequired () {
441438 if (required == null ) {
@@ -478,70 +475,46 @@ public boolean isRequired() {
478475 return required ;
479476 }
480477
481- public boolean isHasRequiredChildrenDV () {
482-
483- if (hasRequiredChildrenDV == null ) {
484- hasRequiredChildrenDV = false ;
478+ public boolean isHasRequiredChildren () {
479+ if (hasRequiredChildren == null ) {
480+ hasRequiredChildren = this .datasetFieldType .isHasRequiredChildren () || checkRequiredChildren (false );
485481 }
482+ return hasRequiredChildren ;
483+ }
486484
485+ public boolean isHasRequiredChildrenDV () {
486+ return isHasRequiredChildren () && checkRequiredChildren (true );
487+ }
488+
489+ private boolean checkRequiredChildren (boolean checkDVOnly ) {
487490 Dataverse dv = getDataverse ();
488491 while (!dv .isMetadataBlockRoot ()) {
489492 if (dv .getOwner () == null ) {
490- break ; // we are at the root; which by defintion is metadata blcok root, regarldess of the value
493+ break ; // we are at the root; which by defintion is metadata block root, regardless of the value
491494 }
492495 dv = dv .getOwner ();
493496 }
494497
495498 List <DataverseFieldTypeInputLevel > dftilListFirst = dv .getDataverseFieldTypeInputLevels ();
496499
497- if (getDatasetFieldType ().isHasChildren () && (!dftilListFirst .isEmpty ())) {
498- for (DatasetFieldType child : getDatasetFieldType ().getChildDatasetFieldTypes ()) {
499- for (DataverseFieldTypeInputLevel dftilTest : dftilListFirst ) {
500- if (child .equals (dftilTest .getDatasetFieldType ())) {
501- //We only want to get it here if it is required by
502- //the DV and not by default at the installation/DB level
503- if (dftilTest .isRequired () && !child .isRequired ()) {
504- hasRequiredChildrenDV = true ;
505- break ;
506- }
507- }
508- }
509- }
510- }
511- return hasRequiredChildrenDV ;
512- }
513-
514- public boolean isHasRequiredChildren () {
515- if (hasRequiredChildren == null ) {
516- hasRequiredChildren = false ;
517- }
518-
519- if (this .datasetFieldType .isHasRequiredChildren ()) {
520- hasRequiredChildren = true ;
521- }
522-
523- Dataverse dv = getDataverse ();
524- while (!dv .isMetadataBlockRoot ()) {
525- if (dv .getOwner () == null ) {
526- break ; // we are at the root; which by defintion is metadata blcok root, regarldess of the value
527- }
528- dv = dv .getOwner ();
529- }
530-
531- List <DataverseFieldTypeInputLevel > dftilListFirst = dv .getDataverseFieldTypeInputLevels ();
532-
533500 if (getDatasetFieldType ().isHasChildren () && (!dftilListFirst .isEmpty ())) {
534501 for (DatasetFieldType child : getDatasetFieldType ().getChildDatasetFieldTypes ()) {
535502 for (DataverseFieldTypeInputLevel dftilTest : dftilListFirst ) {
536503 if (child .equals (dftilTest .getDatasetFieldType ())) {
537504 if (dftilTest .isRequired ()) {
538- hasRequiredChildren = true ;
505+ if (checkDVOnly ) {
506+ if (!child .isRequired ()) {
507+ return true ;
508+ }
509+ } else {
510+ return true ;
511+ }
539512 }
540513 }
541514 }
542515 }
543- }
544- return hasRequiredChildren ;
516+ }
517+ return false ;
545518 }
546519
547520 public Dataverse getDataverse () {
0 commit comments