@@ -348,8 +348,8 @@ List<String> validateComponents(Components components) {
348348 if (components .getParameters () != null ) {
349349
350350 for (String key : components .getParameters ().keySet ()) {
351- if (isValidComponentKey (key )) {
352- errors .add ("'Component parameter " + key + " is invalid (should match regex " + getComponentKeyRegularExpression () + ")" );
351+ if (! isValidComponentKey (key )) {
352+ errors .add ("'Component parameter name " + key + " is invalid (should match regex " + getComponentKeyRegularExpression () + ")" );
353353 }
354354 }
355355
@@ -358,13 +358,11 @@ List<String> validateComponents(Components components) {
358358 }
359359 }
360360 if (components .getInputs () != null ) {
361-
362361 for (String key : components .getInputs ().keySet ()) {
363- if (isValidComponentKey (key )) {
362+ if (! isValidComponentKey (key )) {
364363 errors .add ("'Component input " + key + " is invalid (should match regex " + getComponentKeyRegularExpression () + ")" );
365364 }
366365 }
367-
368366 }
369367 }
370368
@@ -402,18 +400,24 @@ String getOutputsKeyRegularExpression() {
402400 return "^[a-zA-Z0-9\\ .\\ -_]+$" ;
403401 }
404402
405- List <String > loadWorkflowIds (List < Workflow > workflows ) {
403+ List <String > loadWorkflowIds (OpenAPIWorkflow openAPIWorkflow ) {
406404 List <String > errors = new ArrayList <>();
407405
408- if (workflows != null ) {
409- for (Workflow workflow : workflows ) {
410- if (!this .workflowIds .add (workflow .getWorkflowId ())) {
411- // id already exists
412- errors .add ("WorkflowId is not unique: " + workflow .getWorkflowId ());
413- }
406+ boolean multipleWorkflowsSpec = getNumWorkflowsSpecSourceDescriptions (openAPIWorkflow .getSourceDescriptions ()) > 1 ? true : false ;
407+
408+
409+ if (openAPIWorkflow .getWorkflows () != null ) {
410+ validateWorkflowIdsUniqueness (openAPIWorkflow .getWorkflows ());
411+
412+ for (Workflow workflow : openAPIWorkflow .getWorkflows ()) {
413+ errors .addAll (validateStepsWorkflowIds (workflow .getSteps (), multipleWorkflowsSpec ));
414+ }
415+
416+ for (Workflow workflow : openAPIWorkflow .getWorkflows ()) {
417+ this .workflowIds .add (workflow .getWorkflowId ());
414418 }
415- }
416419
420+ }
417421 return errors ;
418422 }
419423
@@ -489,6 +493,35 @@ boolean stepExists(String workflowId, String stepId) {
489493 return this .stepIds .get (workflowId ) != null && this .stepIds .get (workflowId ).contains (stepId );
490494 }
491495
496+ List <String > validateWorkflowIdsUniqueness (List <Workflow > workflows ) {
497+ List <String > errors = new ArrayList <>();
498+
499+ Set <String > ids = new HashSet <>();
500+ for (Workflow workflow : workflows ) {
501+ if (!ids .add (workflow .getWorkflowId ())) {
502+ // id already exists
503+ errors .add ("WorkflowId is not unique: " + workflow .getWorkflowId ());
504+ }
505+ }
506+ return errors ;
507+ }
508+
509+ List <String > validateStepsWorkflowIds (List <Step > steps , boolean multipleWorkflowsSpecFiles ) {
510+ List <String > errors = new ArrayList <>();
511+
512+ for (Step step : steps ) {
513+ if (multipleWorkflowsSpecFiles ) {
514+ // must use runtime expression to map applicable SourceDescription
515+ if (step .getWorkflowId () != null && !step .getWorkflowId ().startsWith ("$sourceDescriptions." )) {
516+ errors .add ("Operation " + step .getWorkflowId () + " must be specified using a runtime expression (e.g., $sourceDescriptions.<name>.<workflowId>)" );
517+ }
518+ }
519+ }
520+
521+ return errors ;
522+ }
523+
524+
492525 public boolean isValidJsonPointer (String jsonPointerString ) {
493526
494527 boolean ret ;
0 commit comments