Program: 189033
Project: 189033
Buggy source:
private void parseWorkflow(AbstractWorkflowDataModel wfdm){
  boolean metadatawriteback=Boolean.parseBoolean(wfdm.getConfigs().get("String_Node_Str"));
  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());
  pjob0.setId(this.jobs.size());
  pjob0.setMetadataWriteback(metadatawriteback);
  String parentAccession=wfdm.getParent_accessions();
  if (parentAccession != null && !parentAccession.isEmpty()) {
    pjob0.setParentAccession(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());
      job.addFile(entry.getValue());
      ProvisionFilesJob pjob=new ProvisionFilesJob(job,wfdm.getWorkflowBaseDir(),entry.getValue());
      pjob.setId(this.jobs.size());
      pjob.setMetadataWriteback(metadatawriteback);
      if (workflowRunAccession != null && !workflowRunAccession.isEmpty()) {
        pjob.setWorkflowRunAccession(workflowRunAccession);
      }
      this.jobs.add(pjob);
      this.fileJobMap.put(entry.getValue(),pjob);
      if (entry.getValue().isInput()) {
        newParents.add(pjob);
        for (        PegasusJob parent : parents) {
          pjob.addParent(parent);
        }
        String outputDir="String_Node_Str" + entry.getValue().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);
    }
    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);
          parentPfjob.setId(this.jobs.size());
          parentPfjob.addParent(pjob0);
          parentPfjob.setMetadataWriteback(metadatawriteback);
          if (workflowRunAccession != null && !workflowRunAccession.isEmpty()) {
            parentPfjob.setWorkflowRunAccession(workflowRunAccession);
          }
          this.jobs.add(parentPfjob);
          parentPfjob.setOutputDir(file.getProvisionedPath());
          pjob.addParent(parentPfjob);
          job0.getCommand().addArgument("String_Node_Str" + file.getProvisionedPath() + "String_Node_Str");
        }
 else {
          AbstractJob pfjob=new BashJob("String_Node_Str");
          pfjob.addFile(file);
          ProvisionFilesJob parentPfjob=new ProvisionFilesJob(pfjob,wfdm.getWorkflowBaseDir(),file);
          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);
          }
          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=Boolean.parseBoolean(wfdm.getConfigs().get("String_Node_Str"));
  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());
  pjob0.setId(this.jobs.size());
  pjob0.setMetadataWriteback(metadatawriteback);
  String parentAccession=wfdm.getParent_accessions();
  if (parentAccession != null && !parentAccession.isEmpty()) {
    pjob0.setParentAccession(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());
      job.addFile(entry.getValue());
      ProvisionFilesJob pjob=new ProvisionFilesJob(job,wfdm.getWorkflowBaseDir(),entry.getValue());
      pjob.setId(this.jobs.size());
      pjob.setMetadataWriteback(metadatawriteback);
      if (workflowRunAccession != null && !workflowRunAccession.isEmpty()) {
        pjob.setWorkflowRunAccession(workflowRunAccession);
      }
      this.jobs.add(pjob);
      this.fileJobMap.put(entry.getValue(),pjob);
      if (entry.getValue().isInput()) {
        newParents.add(pjob);
        for (        PegasusJob parent : parents) {
          pjob.addParent(parent);
        }
        String outputDir="String_Node_Str" + entry.getValue().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);
    }
    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);
          parentPfjob.setId(this.jobs.size());
          parentPfjob.addParent(pjob0);
          parentPfjob.setMetadataWriteback(metadatawriteback);
          if (workflowRunAccession != null && !workflowRunAccession.isEmpty()) {
            parentPfjob.setWorkflowRunAccession(workflowRunAccession);
          }
          this.jobs.add(parentPfjob);
          parentPfjob.setOutputDir("String_Node_Str" + file.getUniqueDir());
          pjob.addParent(parentPfjob);
          job0.getCommand().addArgument("String_Node_Str" + file.getProvisionedPath() + "String_Node_Str");
        }
 else {
          AbstractJob pfjob=new BashJob("String_Node_Str");
          pfjob.addFile(file);
          ProvisionFilesJob parentPfjob=new ProvisionFilesJob(pfjob,wfdm.getWorkflowBaseDir(),file);
          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);
          }
          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);
}