@@ -354,20 +354,18 @@ protected Set<String> getInvolvedTables(Table table, Set<String> tables) {
354354 if (table == null )
355355 return tables ;
356356
357- if (table .getTableRows () == null || table .getTableRows ().isEmpty ())
358- throw new IllegalStateException ("Table not initialized" );
359-
360357 tables .add (table .getId ());
361358
362- for (TableRow tableRow : table .getTableRows ()) {
363- for (Endpoint endpoint : tableRow .getEndpoints ()) {
364- if (endpoint != null && EndpointType .JUMP .equals (endpoint .getType ())) {
365- // if table has already been visited, don't call getInvolvedTables again; otherwise we could have infinite recursion
366- if (!tables .contains (endpoint .getValue ()))
367- getInvolvedTables (getProvider ().getTable (endpoint .getValue ()), tables );
359+ if (table .getTableRows () != null )
360+ for (TableRow tableRow : table .getTableRows ()) {
361+ for (Endpoint endpoint : tableRow .getEndpoints ()) {
362+ if (endpoint != null && EndpointType .JUMP .equals (endpoint .getType ())) {
363+ // if table has already been visited, don't call getInvolvedTables again; otherwise we could have infinite recursion
364+ if (!tables .contains (endpoint .getValue ()))
365+ getInvolvedTables (getProvider ().getTable (endpoint .getValue ()), tables );
366+ }
368367 }
369368 }
370- }
371369
372370 return tables ;
373371 }
@@ -602,15 +600,13 @@ public Result process(Definition definition, Map<String, String> context) {
602600
603601 List <? extends Endpoint > endpoints = matchTable (lookup , context );
604602 if (endpoints == null ) {
605- result .addError (new ErrorBuilder (Boolean .TRUE .equals (input .getUsedForStaging ()) ? Type .INVALID_REQUIRED_INPUT : Type .INVALID_NON_REQUIRED_INPUT )
606- .message ("Invalid '" + input .getKey () + "' value (" + (value .isEmpty () ? _BLANK_OUTPUT : value ) + ")" )
607- .key (input .getKey ()).table (input .getTable ())
608- .build ());
603+ result .addError (new ErrorBuilder (Boolean .TRUE .equals (input .getUsedForStaging ()) ? Type .INVALID_REQUIRED_INPUT : Type .INVALID_NON_REQUIRED_INPUT ).message (
604+ "Invalid '" + input .getKey () + "' value (" + (value .isEmpty () ? _BLANK_OUTPUT : value ) + ")" ).key (input .getKey ()).table (input .getTable ()).build ());
609605
610606 // if the schema error handling is set to FAIL or if the input is required for staging and the error handling is set to FAIL_WHEN_REQUIRED_FOR_STAGING,
611607 // then stop processing and return a failure result
612- if (Definition .StagingInputErrorHandler .FAIL .equals (definition .getOnInvalidInput ()) ||
613- ( Boolean . TRUE . equals ( input . getUsedForStaging ()) && Definition .StagingInputErrorHandler .FAIL_WHEN_USED_FOR_STAGING .equals (definition .getOnInvalidInput ())))
608+ if (Definition .StagingInputErrorHandler .FAIL .equals (definition .getOnInvalidInput ()) || ( Boolean . TRUE . equals ( input . getUsedForStaging ())
609+ && Definition .StagingInputErrorHandler .FAIL_WHEN_USED_FOR_STAGING .equals (definition .getOnInvalidInput ())))
614610 stopForBadInput = true ;
615611 }
616612 }
@@ -661,10 +657,8 @@ public Result process(Definition definition, Map<String, String> context) {
661657 String mapFromKey = key .getFrom ();
662658
663659 if (!context .containsKey (mapFromKey )) {
664- result .addError (new ErrorBuilder (Type .UNKNOWN_INPUT_MAPPING )
665- .message ("Input mapping '" + mapFromKey + "' does not exist for table '" + tableId + "'" )
666- .key (mapFromKey )
667- .table (tableId ).build ());
660+ result .addError (new ErrorBuilder (Type .UNKNOWN_INPUT_MAPPING ).message ("Input mapping '" + mapFromKey + "' does not exist for table '" + tableId + "'" ).key (
661+ mapFromKey ).table (tableId ).build ());
668662 continue ;
669663 }
670664
@@ -715,10 +709,8 @@ else if (output.getTable() != null) {
715709 List <? extends Endpoint > endpoints = matchTable (lookup , context );
716710 if (endpoints == null ) {
717711 String value = context .get (output .getKey ());
718- result .addError (new ErrorBuilder (Type .INVALID_OUTPUT )
719- .message ("Invalid '" + output .getKey () + "' value (" + (value .isEmpty () ? _BLANK_OUTPUT : value ) + ")" )
720- .key (output .getKey ()).table (output .getTable ())
721- .build ());
712+ result .addError (new ErrorBuilder (Type .INVALID_OUTPUT ).message ("Invalid '" + output .getKey () + "' value (" + (value .isEmpty () ? _BLANK_OUTPUT : value ) + ")" ).key (
713+ output .getKey ()).table (output .getTable ()).build ());
722714 }
723715 }
724716 }
@@ -742,17 +734,15 @@ protected boolean process(String mappingId, String tableId, TablePath path, Resu
742734
743735 Table table = getProvider ().getTable (tableId );
744736 if (table == null ) {
745- result .addError (new ErrorBuilder (Type .UNKNOWN_TABLE )
746- .message ("The processing of '" + path .getId () + "' contains a reference to an unknown table: '" + tableId + "'" )
747- .table (tableId ).build ());
737+ result .addError (new ErrorBuilder (Type .UNKNOWN_TABLE ).message ("The processing of '" + path .getId () + "' contains a reference to an unknown table: '" + tableId + "'" ).table (tableId )
738+ .build ());
748739 return true ;
749740 }
750741
751742 // track the path history to make sure no table is reached twice
752743 if (stack .contains (tableId )) {
753- result .addError (new ErrorBuilder (Type .INFINITE_LOOP )
754- .message ("The processing of '" + path .getId () + "' has entered an infinite recursive state. Table '" + tableId + "' was accessed multiple times." )
755- .table (tableId ).build ());
744+ result .addError (new ErrorBuilder (Type .INFINITE_LOOP ).message (
745+ "The processing of '" + path .getId () + "' has entered an infinite recursive state. Table '" + tableId + "' was accessed multiple times." ).table (tableId ).build ());
756746 return true ;
757747 }
758748
@@ -765,8 +755,8 @@ protected boolean process(String mappingId, String tableId, TablePath path, Resu
765755 // look for the match in the mapping table; if no match is found, used the table-specific no_match value
766756 List <? extends Endpoint > endpoints = matchTable (table , result .getContext ());
767757 if (endpoints == null )
768- result .addError (new ErrorBuilder (Type .MATCH_NOT_FOUND ).message ("Match not found in table '" + tableId + "' (" + getTableInputsAsString (table , result .getContext ()) + ")" )
769- .table ( tableId ). build ());
758+ result .addError (new ErrorBuilder (Type .MATCH_NOT_FOUND ).message ("Match not found in table '" + tableId + "' (" + getTableInputsAsString (table , result .getContext ()) + ")" ). table ( tableId )
759+ .build ());
770760 else {
771761 for (Endpoint endpoint : endpoints ) {
772762 if (EndpointType .STOP .equals (endpoint .getType ()))
0 commit comments