Program: 188931
Project: 188931
Buggy source:
/** 
 * <p>updateWorkflowRun.</p>
 * @param newWR a {@link net.sourceforge.seqware.common.model.WorkflowRun} object.
 * @return a {@link net.sourceforge.seqware.common.model.WorkflowRun} object.
 * @throws org.restlet.resource.ResourceException if any.
 * @throws java.sql.SQLException if any.
 */
public WorkflowRun updateWorkflowRun(WorkflowRun newWR) throws ResourceException, SQLException {
  authenticate();
  WorkflowRunService wrs=BeanFactory.getWorkflowRunServiceBean();
  WorkflowRun wr=(WorkflowRun)testIfNull(wrs.findBySWAccession(newWR.getSwAccession()));
  wr.givesPermission(registration);
  if (newWR.getIus() != null) {
    SortedSet<IUS> iuses=newWR.getIus();
    if (iuses != null) {
      SortedSet<IUS> set=new TreeSet<IUS>();
      for (      IUS ius : iuses) {
        IUSService is=BeanFactory.getIUSServiceBean();
        IUS newI=is.findBySWAccession(ius.getSwAccession());
        newI.givesPermission(registration);
        set.add(newI);
      }
      wr.setIus(set);
    }
 else {
      Log.info("String_Node_Str");
    }
  }
  if (newWR.getLanes() != null) {
    SortedSet<Lane> lanes=newWR.getLanes();
    if (lanes != null) {
      SortedSet<Lane> set=new TreeSet<Lane>();
      for (      Lane lane : lanes) {
        LaneService ls=BeanFactory.getLaneServiceBean();
        Lane newL=ls.findBySWAccession(lane.getSwAccession());
        newL.givesPermission(registration);
        set.add(newL);
      }
      wr.setLanes(set);
    }
 else {
      Log.info("String_Node_Str");
    }
  }
  wr.setCommand(newWR.getCommand());
  wr.setCurrentWorkingDir(newWR.getCurrentWorkingDir());
  wr.setDax(newWR.getDax());
  wr.setHost(newWR.getHost());
  wr.setIniFile(newWR.getIniFile());
  wr.setName(newWR.getName());
  wr.setStatus(newWR.getStatus());
  wr.setStatusCmd(newWR.getStatusCmd());
  wr.setTemplate(newWR.getTemplate());
  wr.setSeqwareRevision(newWR.getSeqwareRevision());
  wr.setUserName(newWR.getUserName());
  wr.setUpdateTimestamp(new Date());
  wr.setStdErr(newWR.getStdErr());
  wr.setStdOut(newWR.getStdOut());
  if (newWR.getWorkflow() != null) {
    WorkflowService ws=BeanFactory.getWorkflowServiceBean();
    Workflow w=ws.findByID(newWR.getWorkflow().getWorkflowId());
    if (w != null) {
      wr.setWorkflow(w);
    }
 else {
      Log.info("String_Node_Str" + newWR.getWorkflow());
    }
  }
  if (newWR.getOwner() != null) {
    Registration reg=BeanFactory.getRegistrationServiceBean().findByEmailAddress(newWR.getOwner().getEmailAddress());
    if (reg != null) {
      wr.setOwner(reg);
    }
 else {
      Log.info("String_Node_Str" + newWR.getOwner());
    }
  }
 else   if (wr.getOwner() == null) {
    wr.setOwner(registration);
  }
  if (newWR.getWorkflowRunAttributes() != null) {
    wr.getWorkflowRunAttributes().clear();
    for (    WorkflowRunAttribute wra : newWR.getWorkflowRunAttributes()) {
      wra.setWorkflowRun(wr);
      wr.getWorkflowRunAttributes().add(wra);
    }
  }
  wrs.update(registration,wr);
  if (newWR.getIus() != null) {
    addNewIUSes(newWR,wr);
  }
  if (newWR.getLanes() != null) {
    addNewLanes(newWR,wr);
  }
  return wr;
}

Fixed version (ground truth):
/** 
 * <p>updateWorkflowRun.</p>
 * @param newWR a {@link net.sourceforge.seqware.common.model.WorkflowRun} object.
 * @return a {@link net.sourceforge.seqware.common.model.WorkflowRun} object.
 * @throws org.restlet.resource.ResourceException if any.
 * @throws java.sql.SQLException if any.
 */
public WorkflowRun updateWorkflowRun(WorkflowRun newWR) throws ResourceException, SQLException {
  authenticate();
  WorkflowRunService wrs=BeanFactory.getWorkflowRunServiceBean();
  WorkflowRun wr=(WorkflowRun)testIfNull(wrs.findBySWAccession(newWR.getSwAccession()));
  wr.givesPermission(registration);
  if (newWR.getIus() != null) {
    SortedSet<IUS> iuses=newWR.getIus();
    if (iuses != null) {
      SortedSet<IUS> set=new TreeSet<IUS>();
      for (      IUS ius : iuses) {
        IUSService is=BeanFactory.getIUSServiceBean();
        IUS newI=is.findBySWAccession(ius.getSwAccession());
        newI.givesPermission(registration);
        set.add(newI);
      }
      wr.setIus(set);
    }
 else {
      Log.info("String_Node_Str");
    }
  }
  if (newWR.getLanes() != null) {
    SortedSet<Lane> lanes=newWR.getLanes();
    if (lanes != null) {
      SortedSet<Lane> set=new TreeSet<Lane>();
      for (      Lane lane : lanes) {
        LaneService ls=BeanFactory.getLaneServiceBean();
        Lane newL=ls.findBySWAccession(lane.getSwAccession());
        newL.givesPermission(registration);
        set.add(newL);
      }
      wr.setLanes(set);
    }
 else {
      Log.info("String_Node_Str");
    }
  }
  wr.setCommand(newWR.getCommand());
  wr.setCurrentWorkingDir(newWR.getCurrentWorkingDir());
  wr.setDax(newWR.getDax());
  wr.setHost(newWR.getHost());
  wr.setIniFile(newWR.getIniFile());
  wr.setName(newWR.getName());
  wr.setStatus(newWR.getStatus());
  wr.setStatusCmd(newWR.getStatusCmd());
  wr.setTemplate(newWR.getTemplate());
  wr.setSeqwareRevision(newWR.getSeqwareRevision());
  wr.setUserName(newWR.getUserName());
  wr.setUpdateTimestamp(new Date());
  wr.setStdErr(newWR.getStdErr());
  wr.setStdOut(newWR.getStdOut());
  if (newWR.getWorkflow() != null) {
    WorkflowService ws=BeanFactory.getWorkflowServiceBean();
    Workflow w=ws.findByID(newWR.getWorkflow().getWorkflowId());
    if (w != null) {
      wr.setWorkflow(w);
    }
 else {
      Log.info("String_Node_Str" + newWR.getWorkflow());
    }
  }
  if (newWR.getOwner() != null) {
    Registration reg=BeanFactory.getRegistrationServiceBean().findByEmailAddress(newWR.getOwner().getEmailAddress());
    if (reg != null) {
      wr.setOwner(reg);
    }
 else {
      Log.info("String_Node_Str" + newWR.getOwner());
    }
  }
 else   if (wr.getOwner() == null) {
    wr.setOwner(registration);
  }
  if (newWR.getWorkflowRunAttributes() != null) {
    for (    WorkflowRunAttribute wra : newWR.getWorkflowRunAttributes()) {
      wra.setWorkflowRun(wr);
      wr.getWorkflowRunAttributes().add(wra);
    }
  }
  wrs.update(registration,wr);
  if (newWR.getIus() != null) {
    addNewIUSes(newWR,wr);
  }
  if (newWR.getLanes() != null) {
    addNewLanes(newWR,wr);
  }
  return wr;
}