Program: 188911
Project: 188911
Buggy source:
private void parseWorkflow(AbstractWorkflowDataModel wfdm){
  boolean metadatawriteback=wfdm.isMetadataWriteBack();
  List<PegasusJob> parents=new ArrayList<PegasusJob>();
  AbstractJob job0=new BashJob("String_Node_Str");
  job0.getCommand().addArgument("String_Node_Str");
  if (!wfdm.getDirectories().isEmpty()) {
    for (    String dir : wfdm.getDirectories()) {
      job0.getCommand().addArgument("String_Node_Str" + dir + "String_Node_Str");
    }
  }
  PegasusJob pjob0=new PegasusJob(job0,wfdm.getWorkflowBaseDir(),wfdm.getTags().get("String_Node_Str"));
  pjob0.setId(this.jobs.size());
  pjob0.setMetadataWriteback(metadatawriteback);
  Collection<String> parentAccession=wfdm.getParentAccessions();
  if (parentAccession != null && !parentAccession.isEmpty()) {
    pjob0.setParentAccessions(parentAccession);
  }
  String workflowRunAccession=wfdm.getWorkflow_run_accession();
  if (workflowRunAccession != null && !workflowRunAccession.isEmpty()) {
    pjob0.setWorkflowRunAccession(workflowRunAccession);
    pjob0.setWorkflowRunAncesstor(true);
  }
  this.jobs.add(pjob0);
  parents.add(pjob0);
  if (!wfdm.getFiles().isEmpty()) {
    Collection<PegasusJob> newParents=new ArrayList<PegasusJob>();
    for (    Map.Entry<String,SqwFile> entry : wfdm.getFiles().entrySet()) {
      AbstractJob job=new BashJob("String_Node_Str" + entry.getKey());
      SqwFile file=entry.getValue();
      job.addFile(file);
      ProvisionFilesJob pjob=new ProvisionFilesJob(job,wfdm.getWorkflowBaseDir(),file,wfdm.getTags().get("String_Node_Str"));
      pjob.setId(this.jobs.size());
      pjob.setMetadataWriteback(metadatawriteback);
      if (workflowRunAccession != null && !workflowRunAccession.isEmpty()) {
        pjob.setWorkflowRunAccession(workflowRunAccession);
      }
      if (!file.getParentAccessions().isEmpty()) {
        pjob.setParentAccessions(file.getParentAccessions());
      }
      this.jobs.add(pjob);
      this.fileJobMap.put(file,pjob);
      if (file.isInput()) {
        newParents.add(pjob);
        for (        PegasusJob parent : parents) {
          pjob.addParent(parent);
        }
        String outputDir="String_Node_Str" + file.getUniqueDir();
        job0.getCommand().addArgument("String_Node_Str" + outputDir + "String_Node_Str");
        pjob.setOutputDir(outputDir);
      }
 else {
        pjob.setMetadataOutputPrefix(wfdm.getMetadata_output_file_prefix());
        pjob.setOutputDir(wfdm.getMetadata_output_dir());
      }
    }
    parents.clear();
    parents.addAll(newParents);
  }
  int idCount=this.jobs.size();
  Map<PegasusJob,PegasusJob> hasProvisionOut=new HashMap<PegasusJob,PegasusJob>();
  for (  AbstractJob job : wfdm.getWorkflow().getJobs()) {
    PegasusJob pjob=this.createPegasusJobObject(job,wfdm);
    pjob.setId(idCount);
    pjob.setMetadataWriteback(metadatawriteback);
    if (workflowRunAccession != null && !workflowRunAccession.isEmpty()) {
      pjob.setWorkflowRunAccession(workflowRunAccession);
    }
    if (!job.getParentAccessions().isEmpty()) {
      pjob.setParentAccessions(job.getParentAccessions());
    }
    this.jobs.add(pjob);
    idCount++;
    for (    Job parent : job.getParents()) {
      pjob.addParent(this.getPegasusJobObject((AbstractJob)parent));
    }
    if (job.getFiles().isEmpty() == false) {
      for (      SqwFile file : job.getFiles()) {
        if (file.isInput()) {
          AbstractJob pfjob=new BashJob("String_Node_Str");
          pfjob.addFile(file);
          ProvisionFilesJob parentPfjob=new ProvisionFilesJob(pfjob,wfdm.getWorkflowBaseDir(),file,wfdm.getTags().get("String_Node_Str"));
          parentPfjob.setId(this.jobs.size());
          parentPfjob.addParent(pjob0);
          parentPfjob.setMetadataWriteback(metadatawriteback);
          if (workflowRunAccession != null && !workflowRunAccession.isEmpty()) {
            parentPfjob.setWorkflowRunAccession(workflowRunAccession);
          }
          if (!file.getParentAccessions().isEmpty()) {
            parentPfjob.setParentAccessions(file.getParentAccessions());
          }
          this.jobs.add(parentPfjob);
          parentPfjob.setOutputDir("String_Node_Str" + file.getUniqueDir());
          pjob.addParent(parentPfjob);
          job0.getCommand().addArgument("String_Node_Str" + "String_Node_Str" + file.getUniqueDir() + "String_Node_Str");
        }
 else {
          AbstractJob pfjob=new BashJob("String_Node_Str");
          pfjob.addFile(file);
          ProvisionFilesJob parentPfjob=new ProvisionFilesJob(pfjob,wfdm.getWorkflowBaseDir(),file,wfdm.getTags().get("String_Node_Str"));
          parentPfjob.setId(this.jobs.size());
          parentPfjob.addParent(pjob);
          parentPfjob.setMetadataWriteback(metadatawriteback);
          parentPfjob.setMetadataOutputPrefix(wfdm.getMetadata_output_file_prefix());
          parentPfjob.setOutputDir(wfdm.getMetadata_output_dir());
          if (workflowRunAccession != null && !workflowRunAccession.isEmpty()) {
            parentPfjob.setWorkflowRunAccession(workflowRunAccession);
          }
          if (!file.getParentAccessions().isEmpty()) {
            parentPfjob.setParentAccessions(file.getParentAccessions());
          }
          this.jobs.add(parentPfjob);
          hasProvisionOut.put(pjob,parentPfjob);
        }
      }
    }
    if (pjob.getParents().isEmpty()) {
      for (      PegasusJob parent : parents) {
        pjob.addParent(parent);
      }
    }
  }
  if (!hasProvisionOut.isEmpty()) {
    for (    Map.Entry<PegasusJob,PegasusJob> entry : hasProvisionOut.entrySet()) {
      Collection<PegasusJob> children=entry.getKey().getChildren();
      if (children.size() <= 1)       continue;
      for (      PegasusJob child : children) {
        if (child == entry.getValue())         continue;
        child.addParent(entry.getValue());
      }
    }
  }
  List<PegasusJob> leaves=new ArrayList<PegasusJob>();
  for (  PegasusJob _job : this.jobs) {
    if (_job.getChildren().isEmpty()) {
      leaves.add(_job);
    }
  }
  for (  Map.Entry<SqwFile,PegasusJob> entry : fileJobMap.entrySet()) {
    if (entry.getKey().isOutput()) {
      for (      PegasusJob leaf : leaves) {
        if (leaf != entry.getValue())         entry.getValue().addParent(leaf);
      }
    }
  }
  this.setAccessionFileRelations(pjob0);
}

Fixed version (ground truth):
private void parseWorkflow(AbstractWorkflowDataModel wfdm){
  boolean metadatawriteback=wfdm.isMetadataWriteBack();
  List<PegasusJob> parents=new ArrayList<PegasusJob>();
  AbstractJob job0=new BashJob("String_Node_Str");
  job0.getCommand().addArgument("String_Node_Str");
  if (!wfdm.getDirectories().isEmpty()) {
    for (    String dir : wfdm.getDirectories()) {
      job0.getCommand().addArgument("String_Node_Str" + dir + "String_Node_Str");
    }
  }
  PegasusJob pjob0=new PegasusJob(job0,wfdm.getWorkflowBaseDir(),wfdm.getTags().get("String_Node_Str"));
  pjob0.setId(this.jobs.size());
  pjob0.setMetadataWriteback(metadatawriteback);
  Collection<String> parentAccession=wfdm.getParentAccessions();
  if (parentAccession != null && !parentAccession.isEmpty()) {
    pjob0.setParentAccessions(parentAccession);
  }
  String workflowRunAccession=wfdm.getWorkflow_run_accession();
  if (workflowRunAccession != null && !workflowRunAccession.isEmpty()) {
    pjob0.setWorkflowRunAccession(workflowRunAccession);
    pjob0.setWorkflowRunAncesstor(true);
  }
  this.jobs.add(pjob0);
  parents.add(pjob0);
  if (!wfdm.getFiles().isEmpty()) {
    Collection<PegasusJob> newParents=new ArrayList<PegasusJob>();
    for (    Map.Entry<String,SqwFile> entry : wfdm.getFiles().entrySet()) {
      AbstractJob job=new BashJob("String_Node_Str" + entry.getKey());
      SqwFile file=entry.getValue();
      job.addFile(file);
      ProvisionFilesJob pjob=new ProvisionFilesJob(job,wfdm.getWorkflowBaseDir(),file,wfdm.getTags().get("String_Node_Str"));
      pjob.setId(this.jobs.size());
      pjob.setMetadataWriteback(metadatawriteback);
      if (workflowRunAccession != null && !workflowRunAccession.isEmpty()) {
        pjob.setWorkflowRunAccession(workflowRunAccession);
      }
      if (!file.getParentAccessions().isEmpty()) {
        pjob.setParentAccessions(file.getParentAccessions());
      }
      this.jobs.add(pjob);
      this.fileJobMap.put(file,pjob);
      if (file.isInput()) {
        newParents.add(pjob);
        for (        PegasusJob parent : parents) {
          pjob.addParent(parent);
        }
        String outputDir="String_Node_Str" + file.getUniqueDir();
        job0.getCommand().addArgument("String_Node_Str" + outputDir + "String_Node_Str");
        pjob.setOutputDir(outputDir);
      }
 else {
        pjob.setMetadataOutputPrefix(wfdm.getMetadata_output_file_prefix());
        pjob.setOutputDir(wfdm.getMetadata_output_dir());
      }
    }
    parents.clear();
    parents.addAll(newParents);
  }
  int idCount=this.jobs.size();
  Map<PegasusJob,PegasusJob> hasProvisionOut=new HashMap<PegasusJob,PegasusJob>();
  for (  AbstractJob job : wfdm.getWorkflow().getJobs()) {
    PegasusJob pjob=this.createPegasusJobObject(job,wfdm);
    pjob.setId(idCount);
    pjob.setMetadataWriteback(metadatawriteback);
    if (workflowRunAccession != null && !workflowRunAccession.isEmpty()) {
      pjob.setWorkflowRunAccession(workflowRunAccession);
    }
    if (!job.getParentAccessions().isEmpty()) {
      pjob.setParentAccessions(job.getParentAccessions());
    }
    this.jobs.add(pjob);
    idCount++;
    for (    Job parent : job.getParents()) {
      pjob.addParent(this.getPegasusJobObject((AbstractJob)parent));
    }
    if (job.getFiles().isEmpty() == false) {
      for (      SqwFile file : job.getFiles()) {
        if (file.isInput()) {
          AbstractJob pfjob=new BashJob("String_Node_Str");
          pfjob.addFile(file);
          ProvisionFilesJob parentPfjob=new ProvisionFilesJob(pfjob,wfdm.getWorkflowBaseDir(),file,wfdm.getTags().get("String_Node_Str"));
          parentPfjob.setId(this.jobs.size());
          parentPfjob.addParent(pjob0);
          parentPfjob.setMetadataWriteback(metadatawriteback);
          if (workflowRunAccession != null && !workflowRunAccession.isEmpty()) {
            parentPfjob.setWorkflowRunAccession(workflowRunAccession);
          }
          if (!file.getParentAccessions().isEmpty()) {
            parentPfjob.setParentAccessions(file.getParentAccessions());
          }
          this.jobs.add(parentPfjob);
          parentPfjob.setOutputDir("String_Node_Str" + file.getUniqueDir());
          pjob.addParent(parentPfjob);
          job0.getCommand().addArgument("String_Node_Str" + "String_Node_Str" + file.getUniqueDir() + "String_Node_Str");
        }
 else {
          AbstractJob pfjob=new BashJob("String_Node_Str");
          pfjob.addFile(file);
          ProvisionFilesJob parentPfjob=new ProvisionFilesJob(pfjob,wfdm.getWorkflowBaseDir(),file,wfdm.getTags().get("String_Node_Str"));
          parentPfjob.setId(this.jobs.size());
          parentPfjob.addParent(pjob);
          parentPfjob.setMetadataWriteback(metadatawriteback);
          parentPfjob.setMetadataOutputPrefix(wfdm.getMetadata_output_file_prefix());
          parentPfjob.setOutputDir(wfdm.getMetadata_output_dir());
          if (workflowRunAccession != null && !workflowRunAccession.isEmpty()) {
            parentPfjob.setWorkflowRunAccession(workflowRunAccession);
          }
          if (!file.getParentAccessions().isEmpty()) {
            parentPfjob.setParentAccessions(file.getParentAccessions());
          }
          this.jobs.add(parentPfjob);
          hasProvisionOut.put(pjob,parentPfjob);
        }
      }
    }
    if (pjob.getParents().isEmpty()) {
      for (      PegasusJob parent : parents) {
        pjob.addParent(parent);
      }
    }
  }
  if (!hasProvisionOut.isEmpty()) {
    for (    Map.Entry<PegasusJob,PegasusJob> entry : hasProvisionOut.entrySet()) {
      Collection<PegasusJob> children=entry.getKey().getChildren();
      if (children.size() <= 1)       continue;
      for (      PegasusJob child : children) {
        if (child == entry.getValue())         continue;
        child.addParent(entry.getValue());
      }
    }
  }
  List<PegasusJob> leaves=new ArrayList<PegasusJob>();
  for (  PegasusJob _job : this.jobs) {
    if ((_job instanceof ProvisionFilesJob == false) && _job.getChildren().isEmpty()) {
      leaves.add(_job);
    }
  }
  for (  Map.Entry<SqwFile,ProvisionFilesJob> entry : fileJobMap.entrySet()) {
    if (entry.getKey().isOutput()) {
      for (      PegasusJob leaf : leaves) {
        entry.getValue().addParent(leaf);
      }
    }
  }
  this.setAccessionFileRelations(pjob0);
}