Program: 97243
Project: 97243
Buggy source:
private void handleCreateDuplicate(Collection<TeamWorkFlowArtifact> teamArts,boolean duplicateTasks,String title) throws OseeCoreException {
  Set<TeamWorkFlowArtifact> newTeamArts=new HashSet<TeamWorkFlowArtifact>();
  AtsChangeSet changes=new AtsChangeSet("String_Node_Str");
  for (  TeamWorkFlowArtifact teamArt : teamArts) {
    TeamWorkFlowArtifact dupArt=(TeamWorkFlowArtifact)teamArt.duplicate(AtsUtilCore.getAtsBranch(),Arrays.asList(AtsAttributeTypes.AtsId));
    if (Strings.isValid(title)) {
      dupArt.setName(title);
    }
    dupArt.addRelation(AtsRelationTypes.ActionToWorkflow_Action,teamArt.getParentActionArtifact());
    dupArt.getLog().addLog(LogType.Note,null,"String_Node_Str" + teamArt.getAtsId(),AtsClientService.get().getUserService().getCurrentUser().getUserId());
    changes.add(dupArt);
    if (duplicateTasks) {
      for (      TaskArtifact taskArt : teamArt.getTaskArtifacts()) {
        TaskArtifact dupTaskArt=(TaskArtifact)taskArt.duplicate(AtsUtilCore.getAtsBranch());
        dupTaskArt.getLog().addLog(LogType.Note,null,"String_Node_Str" + taskArt.getAtsId(),AtsClientService.get().getUserService().getCurrentUser().getUserId());
        dupArt.addRelation(AtsRelationTypes.TeamWfToTask_Task,dupTaskArt);
        changes.add(dupTaskArt);
      }
    }
    ActionManager.addActionToConfiguredGoal(dupArt.getTeamDefinition(),dupArt,dupArt.getActionableItems(),changes);
    newTeamArts.add(dupArt);
    for (    ITeamWorkflowProvider teamExtension : TeamWorkFlowManager.getTeamWorkflowProviders()) {
      teamExtension.teamWorkflowDuplicating(teamArt,dupArt);
    }
  }
  changes.execute();
  for (  TeamWorkFlowArtifact newTeamArt : newTeamArts) {
    SMAEditor.editArtifact(newTeamArt);
  }
}

Fixed version (ground truth):
private void handleCreateDuplicate(Collection<TeamWorkFlowArtifact> teamArts,boolean duplicateTasks,String title) throws OseeCoreException {
  Set<TeamWorkFlowArtifact> newTeamArts=new HashSet<TeamWorkFlowArtifact>();
  AtsChangeSet changes=new AtsChangeSet("String_Node_Str");
  for (  TeamWorkFlowArtifact teamArt : teamArts) {
    TeamWorkFlowArtifact dupArt=(TeamWorkFlowArtifact)teamArt.duplicate(AtsUtilCore.getAtsBranch(),Arrays.asList(AtsAttributeTypes.AtsId));
    if (Strings.isValid(title)) {
      dupArt.setName(title);
    }
    dupArt.setSoleAttributeFromString(AtsAttributeTypes.AtsId,getNexAtsId(teamArt));
    dupArt.addRelation(AtsRelationTypes.ActionToWorkflow_Action,teamArt.getParentActionArtifact());
    dupArt.getLog().addLog(LogType.Note,null,"String_Node_Str" + teamArt.getAtsId(),AtsClientService.get().getUserService().getCurrentUser().getUserId());
    changes.add(dupArt);
    if (duplicateTasks) {
      for (      TaskArtifact taskArt : teamArt.getTaskArtifacts()) {
        TaskArtifact dupTaskArt=(TaskArtifact)taskArt.duplicate(AtsUtilCore.getAtsBranch());
        dupTaskArt.getLog().addLog(LogType.Note,null,"String_Node_Str" + taskArt.getAtsId(),AtsClientService.get().getUserService().getCurrentUser().getUserId());
        dupArt.addRelation(AtsRelationTypes.TeamWfToTask_Task,dupTaskArt);
        changes.add(dupTaskArt);
      }
    }
    ActionManager.addActionToConfiguredGoal(dupArt.getTeamDefinition(),dupArt,dupArt.getActionableItems(),changes);
    newTeamArts.add(dupArt);
    for (    ITeamWorkflowProvider teamExtension : TeamWorkFlowManager.getTeamWorkflowProviders()) {
      teamExtension.teamWorkflowDuplicating(teamArt,dupArt);
    }
  }
  changes.execute();
  for (  TeamWorkFlowArtifact newTeamArt : newTeamArts) {
    SMAEditor.editArtifact(newTeamArt);
  }
}