parseCallElement()

in src/parser/WDL/entities/WDLWorkflow.js [233:270]


  parseCallElement(item, parent) {
    const parentStep = parent;
    const task = item.attributes.task.source_string;
    const alias = item.attributes.alias ? item.attributes.alias.source_string : task;

    let actionName = task;
    if (this.isSubWorkflow) {
      let namespace = this.parentNamespace ? `${this.parentNamespace}.` : '';
      if (this.workflowStep.namespace) {
        namespace = `${namespace}${this.workflowStep.namespace}.`;
      }
      actionName = `${namespace}${actionName}`;
    }

    if (!_.has(this.context.actionMap, actionName)) {
      const errorMessage = this.isSubWorkflow
        ? `Undeclared task call: '${task}' in imported workflow (${this.name}).`
        : `Undeclared task call: '${task}'.`;
      throw new WDLParserError(errorMessage);
    }

    const action = _.get(this.context.actionMap, actionName);

    let childStep;
    if (action.type === Constants.WORKFLOW) {
      const cloneAst = _.clone(action.ast);
      cloneAst.attributes.name.source_string = alias;
      const parentNameSpace = this.parentNamespace
        ? `${this.parentNamespace}.${this.workflowStep.namespace}`
        : this.workflowStep.namespace;
      childStep = new WDLWorkflow(cloneAst.attributes, this.context, task, true, parentNameSpace).workflowStep;
      childStep.imported = true;
    } else {
      childStep = new Step(alias, action, {}, task);
    }

    parentStep.add(childStep);
  }