Program: 189027
Project: 189027
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.getConfigs().get("String_Node_Str"));
  pjob0.setId(this.jobs.size());
  pjob0.setMetadataWriteback(metadatawriteback);
  String parentAccession=wfdm.getConfigs().get("String_Node_Str");
  if (parentAccession != null && !parentAccession.isEmpty()) {
    pjob0.setParentAccession(parentAccession);
  }
  String workflowRunAccession=wfdm.getConfigs().get("String_Node_Str");
  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.getConfigs().get("String_Node_Str"),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.getConfigs().get("String_Node_Str"));
        pjob.setOutputDir(wfdm.getConfigs().get("String_Node_Str"));
      }
    }
    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.getConfigs().get("String_Node_Str"),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" + provisionFileCount);
          pjob.addParent(parentPfjob);
          job0.getCommand().addArgument("String_Node_Str" + provisionFileCount + "String_Node_Str");
          provisionFileCount++;
        }
 else {
          AbstractJob pfjob=new BashJob("String_Node_Str");
          pfjob.addFile(file);
          ProvisionFilesJob parentPfjob=new ProvisionFilesJob(pfjob,wfdm.getConfigs().get("String_Node_Str"),file);
          parentPfjob.setId(this.jobs.size());
          parentPfjob.addParent(pjob);
          parentPfjob.setMetadataWriteback(metadatawriteback);
          parentPfjob.setMetadataOutputPrefix(wfdm.getConfigs().get("String_Node_Str"));
          parentPfjob.setOutputDir(wfdm.getConfigs().get("String_Node_Str"));
          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.getConfigs().get("String_Node_Str"));
  pjob0.setId(this.jobs.size());
  pjob0.setMetadataWriteback(metadatawriteback);
  String parentAccession=wfdm.getConfigs().get("String_Node_Str");
  if (parentAccession != null && !parentAccession.isEmpty()) {
    pjob0.setParentAccession(parentAccession);
  }
  String workflowRunAccession=wfdm.getConfigs().get("String_Node_Str");
  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.getConfigs().get("String_Node_Str"),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.getConfigs().get("String_Node_Str"));
        pjob.setOutputDir(wfdm.getConfigs().get("String_Node_Str"));
      }
    }
    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.getConfigs().get("String_Node_Str"),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.getConfigs().get("String_Node_Str"),file);
          parentPfjob.setId(this.jobs.size());
          parentPfjob.addParent(pjob);
          parentPfjob.setMetadataWriteback(metadatawriteback);
          parentPfjob.setMetadataOutputPrefix(wfdm.getConfigs().get("String_Node_Str"));
          parentPfjob.setOutputDir(wfdm.getConfigs().get("String_Node_Str"));
          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);
}