Program: 189024
Project: 189024
Buggy source:
private void parseDataModel(AbstractWorkflowDataModel wfdm){
  boolean metadatawriteback=wfdm.isMetadataWriteBack();
  List<OozieJob> parents=new ArrayList<OozieJob>();
  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");
    }
  }
  OozieJob oJob0=new OozieJob(job0,"String_Node_Str" + this.jobs.size(),wfdm.getConfigs().get("String_Node_Str"));
  oJob0.setMetadataWriteback(metadatawriteback);
  String parentAccession=wfdm.getParent_accessions();
  if (parentAccession != null && !parentAccession.isEmpty()) {
    oJob0.setParentAccession(parentAccession);
  }
  String workflowRunAccession=wfdm.getWorkflow_run_accession();
  if (workflowRunAccession != null && !workflowRunAccession.isEmpty()) {
    oJob0.setWorkflowRunAccession(workflowRunAccession);
    oJob0.setWorkflowRunAncesstor(true);
  }
  this.jobs.add(oJob0);
  parents.add(oJob0);
  if (!wfdm.getFiles().isEmpty()) {
    Collection<OozieJob> newParents=new ArrayList<OozieJob>();
    for (    Map.Entry<String,SqwFile> entry : wfdm.getFiles().entrySet()) {
      AbstractJob job=new BashJob("String_Node_Str" + entry.getKey());
      job.addFile(entry.getValue());
      OozieProvisionFileJob ojob=new OozieProvisionFileJob(job,entry.getValue(),job.getAlgo() + this.jobs.size(),wfdm.getConfigs().get("String_Node_Str"));
      ojob.setMetadataWriteback(metadatawriteback);
      if (workflowRunAccession != null && !workflowRunAccession.isEmpty()) {
        ojob.setWorkflowRunAccession(workflowRunAccession);
      }
      this.jobs.add(ojob);
      this.fileJobMap.put(entry.getValue(),ojob);
      if (entry.getValue().isInput()) {
        newParents.add(ojob);
        for (        OozieJob parent : parents) {
          ojob.addParent(parent);
        }
        String outputDir=wfdm.getConfigs().get("String_Node_Str") + "String_Node_Str" + entry.getValue().getUniqueDir();
        job0.getCommand().addArgument("String_Node_Str" + outputDir + "String_Node_Str");
        ojob.setOutputDir(outputDir);
      }
 else {
        ojob.setMetadataOutputPrefix(wfdm.getMetadata_output_file_prefix());
        ojob.setOutputDir(wfdm.getMetadata_output_dir());
      }
    }
    parents.clear();
    parents.addAll(newParents);
  }
  Map<OozieJob,OozieJob> hasProvisionOut=new HashMap<OozieJob,OozieJob>();
  for (  AbstractJob job : wfdm.getWorkflow().getJobs()) {
    OozieJob pjob=this.createOozieJobObject(job,wfdm);
    pjob.setMetadataWriteback(metadatawriteback);
    if (workflowRunAccession != null && !workflowRunAccession.isEmpty()) {
      pjob.setWorkflowRunAccession(workflowRunAccession);
    }
    this.jobs.add(pjob);
    for (    Job parent : job.getParents()) {
      pjob.addParent(this.getOozieJobObject((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);
          OozieProvisionFileJob parentPfjob=new OozieProvisionFileJob(pfjob,file,pfjob.getAlgo() + "String_Node_Str" + jobs.size(),wfdm.getConfigs().get("String_Node_Str"));
          parentPfjob.addParent(oJob0);
          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" + "String_Node_Str" + file.getUniqueDir() + "String_Node_Str");
        }
 else {
          AbstractJob pfjob=new BashJob("String_Node_Str");
          pfjob.addFile(file);
          OozieProvisionFileJob parentPfjob=new OozieProvisionFileJob(pfjob,file,pfjob.getAlgo() + "String_Node_Str" + jobs.size(),wfdm.getConfigs().get("String_Node_Str"));
          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 (      OozieJob parent : parents) {
        pjob.addParent(parent);
      }
    }
  }
  if (!hasProvisionOut.isEmpty()) {
    for (    Map.Entry<OozieJob,OozieJob> entry : hasProvisionOut.entrySet()) {
      Collection<OozieJob> children=entry.getKey().getChildren();
      if (children.size() <= 1)       continue;
      for (      OozieJob child : children) {
        if (child == entry.getValue())         continue;
        child.addParent(entry.getValue());
      }
    }
  }
  List<OozieJob> leaves=new ArrayList<OozieJob>();
  for (  OozieJob _job : this.jobs) {
    if (_job.getChildren().isEmpty()) {
      leaves.add(_job);
    }
  }
  for (  Map.Entry<SqwFile,OozieJob> entry : fileJobMap.entrySet()) {
    if (entry.getKey().isOutput()) {
      for (      OozieJob leaf : leaves) {
        if (leaf != entry.getValue())         entry.getValue().addParent(leaf);
      }
    }
  }
  this.setEndJob();
  this.setAccessionFileRelations(oJob0);
}

Fixed version (ground truth):
private void parseDataModel(AbstractWorkflowDataModel wfdm){
  boolean metadatawriteback=wfdm.isMetadataWriteBack();
  List<OozieJob> parents=new ArrayList<OozieJob>();
  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");
    }
  }
  OozieJob oJob0=new OozieJob(job0,"String_Node_Str" + this.jobs.size(),wfdm.getEnv().getOOZIE_WORK_DIR());
  oJob0.setMetadataWriteback(metadatawriteback);
  String parentAccession=wfdm.getParent_accessions();
  if (parentAccession != null && !parentAccession.isEmpty()) {
    oJob0.setParentAccession(parentAccession);
  }
  String workflowRunAccession=wfdm.getWorkflow_run_accession();
  if (workflowRunAccession != null && !workflowRunAccession.isEmpty()) {
    oJob0.setWorkflowRunAccession(workflowRunAccession);
    oJob0.setWorkflowRunAncesstor(true);
  }
  this.jobs.add(oJob0);
  parents.add(oJob0);
  if (!wfdm.getFiles().isEmpty()) {
    Collection<OozieJob> newParents=new ArrayList<OozieJob>();
    for (    Map.Entry<String,SqwFile> entry : wfdm.getFiles().entrySet()) {
      AbstractJob job=new BashJob("String_Node_Str" + entry.getKey());
      job.addFile(entry.getValue());
      OozieProvisionFileJob ojob=new OozieProvisionFileJob(job,entry.getValue(),job.getAlgo() + this.jobs.size(),wfdm.getEnv().getOOZIE_WORK_DIR());
      ojob.setMetadataWriteback(metadatawriteback);
      if (workflowRunAccession != null && !workflowRunAccession.isEmpty()) {
        ojob.setWorkflowRunAccession(workflowRunAccession);
      }
      this.jobs.add(ojob);
      this.fileJobMap.put(entry.getValue(),ojob);
      if (entry.getValue().isInput()) {
        newParents.add(ojob);
        for (        OozieJob parent : parents) {
          ojob.addParent(parent);
        }
        String outputDir=wfdm.getEnv().getOOZIE_WORK_DIR() + "String_Node_Str" + entry.getValue().getUniqueDir();
        job0.getCommand().addArgument("String_Node_Str" + outputDir + "String_Node_Str");
        ojob.setOutputDir(outputDir);
      }
 else {
        ojob.setMetadataOutputPrefix(wfdm.getMetadata_output_file_prefix());
        ojob.setOutputDir(wfdm.getMetadata_output_dir());
      }
    }
    parents.clear();
    parents.addAll(newParents);
  }
  Map<OozieJob,OozieJob> hasProvisionOut=new HashMap<OozieJob,OozieJob>();
  for (  AbstractJob job : wfdm.getWorkflow().getJobs()) {
    OozieJob pjob=this.createOozieJobObject(job,wfdm);
    pjob.setMetadataWriteback(metadatawriteback);
    if (workflowRunAccession != null && !workflowRunAccession.isEmpty()) {
      pjob.setWorkflowRunAccession(workflowRunAccession);
    }
    this.jobs.add(pjob);
    for (    Job parent : job.getParents()) {
      pjob.addParent(this.getOozieJobObject((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);
          OozieProvisionFileJob parentPfjob=new OozieProvisionFileJob(pfjob,file,pfjob.getAlgo() + "String_Node_Str" + jobs.size(),wfdm.getEnv().getOOZIE_WORK_DIR());
          parentPfjob.addParent(oJob0);
          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" + "String_Node_Str" + file.getUniqueDir() + "String_Node_Str");
        }
 else {
          AbstractJob pfjob=new BashJob("String_Node_Str");
          pfjob.addFile(file);
          OozieProvisionFileJob parentPfjob=new OozieProvisionFileJob(pfjob,file,pfjob.getAlgo() + "String_Node_Str" + jobs.size(),wfdm.getEnv().getOOZIE_WORK_DIR());
          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 (      OozieJob parent : parents) {
        pjob.addParent(parent);
      }
    }
  }
  if (!hasProvisionOut.isEmpty()) {
    for (    Map.Entry<OozieJob,OozieJob> entry : hasProvisionOut.entrySet()) {
      Collection<OozieJob> children=entry.getKey().getChildren();
      if (children.size() <= 1)       continue;
      for (      OozieJob child : children) {
        if (child == entry.getValue())         continue;
        child.addParent(entry.getValue());
      }
    }
  }
  List<OozieJob> leaves=new ArrayList<OozieJob>();
  for (  OozieJob _job : this.jobs) {
    if (_job.getChildren().isEmpty()) {
      leaves.add(_job);
    }
  }
  for (  Map.Entry<SqwFile,OozieJob> entry : fileJobMap.entrySet()) {
    if (entry.getKey().isOutput()) {
      for (      OozieJob leaf : leaves) {
        if (leaf != entry.getValue())         entry.getValue().addParent(leaf);
      }
    }
  }
  this.setEndJob();
  this.setAccessionFileRelations(oJob0);
}