Program: 50152
Project: 50152
Buggy source:
/** 
 * The synthesis method for creating the draft tree. Uses the refactored synthesis classes. This will store the synthesized topology as SYNTHCHILDOF relationships in the graph.
 * @param startNode this is the beginning node for analysis
 * @param preferredSourceIds this includes the list of preferred sources
 * @param test this will just run through the motions but won't store the synthesis 
 * @throws Exception 
 */
public boolean synthesizeAndStoreDraftTreeBranches(Node startNode,Iterable<String> preferredSourceIds,boolean test) throws Exception {
  ArrayList<Object> sourceIdPriorityList=new ArrayList<Object>();
  for (  String sourceId : preferredSourceIds) {
    sourceIdPriorityList.add(sourceId);
  }
  String synthName="String_Node_Str";
  String[] sourceIdPriorityListString=new String[sourceIdPriorityList.size()];
  int iii=0;
  ArrayList<Object> justSourcePriorityList=new ArrayList<Object>();
  for (  String sourceId : preferredSourceIds) {
    if (sourceId.startsWith("String_Node_Str")) {
      justSourcePriorityList.add("String_Node_Str" + sourceId.split("String_Node_Str")[1]);
    }
 else     if (sourceId.startsWith("String_Node_Str")) {
      justSourcePriorityList.add("String_Node_Str" + sourceId.split("String_Node_Str")[1]);
    }
 else {
      justSourcePriorityList.add(sourceId.split("String_Node_Str")[0]);
    }
    if (synthName == "String_Node_Str") {
      synthName=sourceId;
    }
 else {
      synthName+="String_Node_Str" + sourceId;
    }
    sourceIdPriorityListString[iii]=sourceId;
    iii++;
  }
  System.out.println("String_Node_Str" + synthName + "String_Node_Str");
  boolean done=false;
  String tempSynthTreeName=DRAFTTREENAME;
  int jj=0;
  while (!done) {
    String terp=tempSynthTreeName;
    if (jj > 0) {
      terp+="String_Node_Str" + jj;
    }
    IndexHits<Node> hits=synthMetaIndex.query("String_Node_Str",terp);
    if (hits.size() > 0) {
      System.out.println("String_Node_Str" + terp + "String_Node_Str");
    }
 else {
      tempSynthTreeName=terp;
      System.out.println("String_Node_Str" + terp + "String_Node_Str");
      done=true;
    }
    jj++;
  }
  SynthesisExpander draftSynthesisMethod=new SynthesisExpander();
  RelationshipFilter rf=new RelationshipFilter();
  HashSet<String> filteredsources=new HashSet<String>();
  IndexHits<Node> hits=sourceMetaIndex.query("String_Node_Str","String_Node_Str");
  boolean studyids=false;
  while (hits.hasNext()) {
    Node n=hits.next();
    if (n.hasProperty("String_Node_Str")) {
      if (justSourcePriorityList.contains(n.getProperty("String_Node_Str")) == false) {
        filteredsources.add((String)n.getProperty("String_Node_Str"));
        studyids=true;
      }
    }
 else {
      if (sourceIdPriorityList.contains(n.getProperty("String_Node_Str")) == false) {
        filteredsources.add((String)n.getProperty("String_Node_Str"));
      }
    }
  }
  System.out.println("String_Node_Str" + filteredsources);
  if (filteredsources.size() > 0) {
    if (studyids == true) {
      rf.addCriterion(new FilterCriterion(Directive.INCLUDE,new SourcePropertySetTest(filteredsources,SetComparison.CONTAINS_ANY,SourceProperty.STUDY_ID,sourceMetaIndex)));
    }
 else {
      rf.addCriterion(new FilterCriterion(Directive.INCLUDE,new SourcePropertySetTest(filteredsources,SetComparison.CONTAINS_ANY,SourceProperty.SOURCE,sourceMetaIndex)));
    }
    draftSynthesisMethod.setFilter(rf);
  }
  RelationshipRanker rs=new RelationshipRanker();
  if (studyids == true) {
    rs.addCriterion(new SourcePropertyPrioritizedRankingCriterion(SourceProperty.STUDY_ID,sourceIdPriorityList,sourceMetaIndex));
  }
 else {
    rs.addCriterion(new SourcePropertyPrioritizedRankingCriterion(SourceProperty.SOURCE,sourceIdPriorityList,sourceMetaIndex));
  }
  draftSynthesisMethod.setRanker(rs);
  RelationshipConflictResolver rcr=new RelationshipConflictResolver(new RankResolutionMethod());
  draftSynthesisMethod.setConflictResolver(rcr);
  draftSynthesisMethod=new RootwardSynthesisExpander(startNode);
  System.out.println("String_Node_Str" + draftSynthesisMethod.getDescription());
  Transaction tx=graphDb.beginTx();
  String synthTreeName=tempSynthTreeName;
  try {
    Node metadatanode=graphDb.createNode();
    metadatanode.createRelationshipTo(startNode,RelType.SYNTHMETADATAFOR);
    metadatanode.setProperty("String_Node_Str",synthTreeName);
    Date date=new Date();
    metadatanode.setProperty("String_Node_Str",date.toString());
    metadatanode.setProperty("String_Node_Str",sourceIdPriorityListString);
    if (getTaxonomyVersion() != null) {
      metadatanode.setProperty("String_Node_Str",getTaxonomyVersion());
    }
 else {
      metadatanode.setProperty("String_Node_Str","String_Node_Str");
    }
    metadatanode.setProperty("String_Node_Str",startNode.getId());
    synthMetaIndex.add(metadatanode,"String_Node_Str",synthTreeName);
    this.graphDb.setGraphProperty("String_Node_Str",startNode.getId());
    tx.success();
  }
 catch (  Exception ex) {
    tx.failure();
    throw ex;
  }
 finally {
    tx.finish();
  }
  knownIdsInTree=new HashSet<Long>();
  tx=graphDb.beginTx();
  try {
    for (    Relationship rel : Traversal.description().breadthFirst().expand(draftSynthesisMethod).traverse(startNode).relationships()) {
      System.out.println("String_Node_Str" + rel.getId());
      Node parentNode=rel.getEndNode();
      Node curNode=rel.getStartNode();
      if (parentNode != null && test == false) {
        Relationship newRel=curNode.createRelationshipTo(parentNode,RelType.SYNTHCHILDOF);
        newRel.setProperty("String_Node_Str",synthTreeName);
        synthRelIndex.add(newRel,"String_Node_Str",synthTreeName);
        HashSet<String> sources=new HashSet<String>();
        for (        Relationship rel2 : curNode.getRelationships(RelType.STREECHILDOF)) {
          if (rel2.hasProperty("String_Node_Str")) {
            sources.add(String.valueOf(rel2.getProperty("String_Node_Str")));
          }
        }
        String[] sourcesArray=new String[sources.size()];
        Iterator<String> sourcesIter=sources.iterator();
        for (int i=0; i < sources.size(); i++) {
          sourcesArray[i]=sourcesIter.next();
        }
        newRel.setProperty("String_Node_Str",sourcesArray);
      }
      knownIdsInTree.add(curNode.getId());
    }
    System.out.println("String_Node_Str" + draftSynthesisMethod.getDeadNodes().size());
    TLongArrayList deadnodes=new TLongArrayList(draftSynthesisMethod.getDeadNodes());
    System.out.println("String_Node_Str");
    TLongHashSet vd=new TLongHashSet();
    int actual=0;
    for (int i=0; i < deadnodes.size(); i++) {
      long cnd=deadnodes.get(i);
      if (vd.contains(cnd)) {
        continue;
      }
 else {
        vd.add(cnd);
      }
      Node cn=graphDb.getNodeById(cnd);
      if (cn.hasRelationship(RelType.STREECHILDOF,Direction.INCOMING) == false) {
        vd.add(cnd);
      }
 else {
        System.out.println("String_Node_Str" + cnd);
        actual++;
        boolean going=true;
        Node curnode=cn;
        while (going) {
          if (curnode.hasRelationship(RelType.SYNTHCHILDOF,Direction.INCOMING) == false) {
            vd.add(curnode.getId());
            Relationship tr=curnode.getSingleRelationship(RelType.SYNTHCHILDOF,Direction.OUTGOING);
            curnode=tr.getEndNode();
            System.out.println("String_Node_Str" + tr);
            synthRelIndex.remove(tr,"String_Node_Str",synthTreeName);
            tr.delete();
          }
 else {
            break;
          }
        }
      }
    }
    System.out.println("String_Node_Str" + actual);
    System.out.println("String_Node_Str");
    System.out.println("String_Node_Str" + draftSynthesisMethod.getReport());
    tx.success();
  }
 catch (  Exception ex) {
    tx.failure();
    throw ex;
  }
 finally {
    tx.finish();
  }
  System.out.println("String_Node_Str");
  return true;
}

Fixed version (ground truth):
/** 
 * The synthesis method for creating the draft tree. Uses the refactored synthesis classes. This will store the synthesized topology as SYNTHCHILDOF relationships in the graph.
 * @param startNode this is the beginning node for analysis
 * @param preferredSourceIds this includes the list of preferred sources
 * @param test this will just run through the motions but won't store the synthesis 
 * @throws Exception 
 */
public boolean synthesizeAndStoreDraftTreeBranches(Node startNode,Iterable<String> preferredSourceIds,boolean test) throws Exception {
  ArrayList<Object> sourceIdPriorityList=new ArrayList<Object>();
  for (  String sourceId : preferredSourceIds) {
    sourceIdPriorityList.add(sourceId);
  }
  String synthName="String_Node_Str";
  String[] sourceIdPriorityListString=new String[sourceIdPriorityList.size()];
  int iii=0;
  ArrayList<Object> justSourcePriorityList=new ArrayList<Object>();
  for (  String sourceId : preferredSourceIds) {
    if (sourceId.startsWith("String_Node_Str")) {
      justSourcePriorityList.add("String_Node_Str" + sourceId.split("String_Node_Str")[1]);
    }
 else     if (sourceId.startsWith("String_Node_Str")) {
      justSourcePriorityList.add("String_Node_Str" + sourceId.split("String_Node_Str")[1]);
    }
 else {
      justSourcePriorityList.add(sourceId.split("String_Node_Str")[0]);
    }
    if (synthName == "String_Node_Str") {
      synthName=sourceId;
    }
 else {
      synthName+="String_Node_Str" + sourceId;
    }
    sourceIdPriorityListString[iii]=sourceId;
    iii++;
  }
  System.out.println("String_Node_Str" + synthName + "String_Node_Str");
  boolean done=false;
  String tempSynthTreeName=DRAFTTREENAME;
  int jj=0;
  while (!done) {
    String terp=tempSynthTreeName;
    if (jj > 0) {
      terp+="String_Node_Str" + jj;
    }
    IndexHits<Node> hits=synthMetaIndex.query("String_Node_Str",terp);
    if (hits.size() > 0) {
      System.out.println("String_Node_Str" + terp + "String_Node_Str");
    }
 else {
      tempSynthTreeName=terp;
      System.out.println("String_Node_Str" + terp + "String_Node_Str");
      done=true;
    }
    jj++;
  }
  SynthesisExpander draftSynthesisMethod=new SynthesisExpander();
  RelationshipFilter rf=new RelationshipFilter();
  HashSet<String> filteredsources=new HashSet<String>();
  IndexHits<Node> hits=sourceMetaIndex.query("String_Node_Str","String_Node_Str");
  boolean studyids=false;
  while (hits.hasNext()) {
    Node n=hits.next();
    if (n.hasProperty("String_Node_Str")) {
      if (justSourcePriorityList.contains(n.getProperty("String_Node_Str")) == false) {
        filteredsources.add((String)n.getProperty("String_Node_Str"));
        studyids=true;
      }
    }
 else {
      if (sourceIdPriorityList.contains(n.getProperty("String_Node_Str")) == false) {
        filteredsources.add((String)n.getProperty("String_Node_Str"));
      }
    }
  }
  System.out.println("String_Node_Str" + filteredsources);
  if (filteredsources.size() > 0) {
    if (studyids == true) {
      rf.addCriterion(new FilterCriterion(Directive.INCLUDE,new SourcePropertySetTest(filteredsources,SetComparison.CONTAINS_ANY,SourceProperty.STUDY_ID,sourceMetaIndex)));
    }
 else {
      rf.addCriterion(new FilterCriterion(Directive.INCLUDE,new SourcePropertySetTest(filteredsources,SetComparison.CONTAINS_ANY,SourceProperty.SOURCE,sourceMetaIndex)));
    }
    draftSynthesisMethod.setFilter(rf);
  }
  RelationshipRanker rs=new RelationshipRanker();
  if (studyids == true) {
    rs.addCriterion(new SourcePropertyPrioritizedRankingCriterion(SourceProperty.STUDY_ID,sourceIdPriorityList,sourceMetaIndex));
  }
 else {
    rs.addCriterion(new SourcePropertyPrioritizedRankingCriterion(SourceProperty.SOURCE,sourceIdPriorityList,sourceMetaIndex));
  }
  draftSynthesisMethod.setRanker(rs);
  RelationshipConflictResolver rcr=new RelationshipConflictResolver(new RankResolutionMethod());
  draftSynthesisMethod.setConflictResolver(rcr);
  draftSynthesisMethod=new RootwardNodeCountSynthesisExpander(startNode);
  System.out.println("String_Node_Str" + draftSynthesisMethod.getDescription());
  Transaction tx=graphDb.beginTx();
  String synthTreeName=tempSynthTreeName;
  try {
    Node metadatanode=graphDb.createNode();
    metadatanode.createRelationshipTo(startNode,RelType.SYNTHMETADATAFOR);
    metadatanode.setProperty("String_Node_Str",synthTreeName);
    Date date=new Date();
    metadatanode.setProperty("String_Node_Str",date.toString());
    metadatanode.setProperty("String_Node_Str",sourceIdPriorityListString);
    if (getTaxonomyVersion() != null) {
      metadatanode.setProperty("String_Node_Str",getTaxonomyVersion());
    }
 else {
      metadatanode.setProperty("String_Node_Str","String_Node_Str");
    }
    metadatanode.setProperty("String_Node_Str",startNode.getId());
    synthMetaIndex.add(metadatanode,"String_Node_Str",synthTreeName);
    this.graphDb.setGraphProperty("String_Node_Str",startNode.getId());
    tx.success();
  }
 catch (  Exception ex) {
    tx.failure();
    throw ex;
  }
 finally {
    tx.finish();
  }
  knownIdsInTree=new HashSet<Long>();
  tx=graphDb.beginTx();
  try {
    for (    Relationship rel : Traversal.description().breadthFirst().expand(draftSynthesisMethod).traverse(startNode).relationships()) {
      System.out.println("String_Node_Str" + rel.getId());
      Node parentNode=rel.getEndNode();
      Node curNode=rel.getStartNode();
      if (parentNode != null && test == false) {
        Relationship newRel=curNode.createRelationshipTo(parentNode,RelType.SYNTHCHILDOF);
        newRel.setProperty("String_Node_Str",synthTreeName);
        synthRelIndex.add(newRel,"String_Node_Str",synthTreeName);
        HashSet<String> sources=new HashSet<String>();
        for (        Relationship rel2 : curNode.getRelationships(RelType.STREECHILDOF)) {
          if (rel2.hasProperty("String_Node_Str")) {
            sources.add(String.valueOf(rel2.getProperty("String_Node_Str")));
          }
        }
        String[] sourcesArray=new String[sources.size()];
        Iterator<String> sourcesIter=sources.iterator();
        for (int i=0; i < sources.size(); i++) {
          sourcesArray[i]=sourcesIter.next();
        }
        newRel.setProperty("String_Node_Str",sourcesArray);
      }
      knownIdsInTree.add(curNode.getId());
    }
    System.out.println("String_Node_Str" + draftSynthesisMethod.getDeadNodes().size());
    TLongArrayList deadnodes=new TLongArrayList(draftSynthesisMethod.getDeadNodes());
    System.out.println("String_Node_Str");
    TLongHashSet vd=new TLongHashSet();
    int actual=0;
    for (int i=0; i < deadnodes.size(); i++) {
      long cnd=deadnodes.get(i);
      if (vd.contains(cnd)) {
        continue;
      }
 else {
        vd.add(cnd);
      }
      Node cn=graphDb.getNodeById(cnd);
      if (cn.hasRelationship(RelType.STREECHILDOF,Direction.INCOMING) == false) {
        vd.add(cnd);
      }
 else {
        System.out.println("String_Node_Str" + cnd);
        actual++;
        boolean going=true;
        Node curnode=cn;
        while (going) {
          if (curnode.hasRelationship(RelType.SYNTHCHILDOF,Direction.INCOMING) == false) {
            vd.add(curnode.getId());
            Relationship tr=curnode.getSingleRelationship(RelType.SYNTHCHILDOF,Direction.OUTGOING);
            curnode=tr.getEndNode();
            System.out.println("String_Node_Str" + tr);
            synthRelIndex.remove(tr,"String_Node_Str",synthTreeName);
            tr.delete();
          }
 else {
            break;
          }
        }
      }
    }
    System.out.println("String_Node_Str" + actual);
    System.out.println("String_Node_Str");
    System.out.println("String_Node_Str" + draftSynthesisMethod.getReport());
    tx.success();
  }
 catch (  Exception ex) {
    tx.failure();
    throw ex;
  }
 finally {
    tx.finish();
  }
  System.out.println("String_Node_Str");
  return true;
}