@@ -460,14 +460,17 @@ public static void setMetadataDomain(Metadata metadata, RulesetManagementInterfa
460460 public static void addAllowedMetadataRecursive (Division <?> division , Collection <String > keys , String value ,
461461 RulesetManagementInterface rulesetManagement , String acquisitionStage ,
462462 List <Locale .LanguageRange > priorityList ) {
463- StructuralElementViewInterface divisionView = rulesetManagement .getStructuralElementView (division .getType (),
464- acquisitionStage , priorityList );
465- for (MetadataViewInterface metadataView : divisionView .getAllowedMetadata ()) {
466- if (metadataView instanceof SimpleMetadataViewInterface && keys .contains (metadataView .getId ())
467- && division .getMetadata ().parallelStream ()
468- .filter (metadata -> metadataView .getId ().equals (metadata .getKey ()))
469- .count () < metadataView .getMaxOccurs ()) {
470- MetadataEditor .writeMetadataEntry (division , (SimpleMetadataViewInterface ) metadataView , value );
463+ String type = division .getType ();
464+ if (Objects .nonNull (type ) && !type .isEmpty ()) {
465+ StructuralElementViewInterface divisionView = rulesetManagement .getStructuralElementView (type ,
466+ acquisitionStage , priorityList );
467+ for (MetadataViewInterface metadataView : divisionView .getAllowedMetadata ()) {
468+ if (metadataView instanceof SimpleMetadataViewInterface && keys .contains (metadataView .getId ())
469+ && division .getMetadata ().parallelStream ()
470+ .filter (metadata -> metadataView .getId ().equals (metadata .getKey ()))
471+ .count () < metadataView .getMaxOccurs ()) {
472+ MetadataEditor .writeMetadataEntry (division , (SimpleMetadataViewInterface ) metadataView , value );
473+ }
471474 }
472475 }
473476 for (Division <?> child : division .getChildren ()) {
@@ -510,8 +513,6 @@ private static void setProcessTitleMetadata(Workpiece workpiece, String processT
510513 if (!processTitleKeys .isEmpty ()) {
511514 ProcessHelper .addAllowedMetadataRecursive (workpiece .getLogicalStructure (), processTitleKeys , processTitle ,
512515 rulesetManagement , acquisitionStage , priorityList );
513- ProcessHelper .addAllowedMetadataRecursive (workpiece .getPhysicalStructure (), processTitleKeys , processTitle ,
514- rulesetManagement , acquisitionStage , priorityList );
515516 }
516517 }
517518
0 commit comments