Program: 97600
Project: 97600
Buggy source:
@Override public Result saveToArtifact(SkynetTransaction transaction) throws OseeCoreException {
  Artifact aiArt=getArtifact();
  if (aiArt == null) {
    throw new OseeArgumentException("String_Node_Str");
  }
  IAtsActionableItem aia=getActionableItem();
  aiArt.setName(aia.getName());
  aiArt.setSoleAttributeValue(AtsAttributeTypes.Active,aia.isActive());
  boolean actionable=aiArt.getSoleAttributeValue(AtsAttributeTypes.Actionable,true);
  if (actionable != aia.isActionable()) {
    aiArt.setSoleAttributeValue(AtsAttributeTypes.Actionable,aia.isActionable());
  }
  if (Strings.isValid(aia.getDescription())) {
    aiArt.setSoleAttributeValue(AtsAttributeTypes.Description,aia.getDescription());
  }
  if (aia.getTeamDefinition() != null) {
    Artifact teamDefArt=new TeamDefinitionArtifactStore(aia.getTeamDefinition()).getArtifact();
    if (teamDefArt != null && !teamDefArt.getRelatedArtifacts(AtsRelationTypes.TeamActionableItem_ActionableItem).contains(aiArt)) {
      aiArt.deleteRelations(AtsRelationTypes.TeamActionableItem_Team);
      aiArt.addRelation(AtsRelationTypes.TeamActionableItem_Team,teamDefArt);
      teamDefArt.persist(transaction);
    }
  }
  List<String> newGuids=AtsObjects.toGuids(aia.getChildrenActionableItems());
  List<String> currGuids=Artifacts.toGuids(aiArt.getChildren());
  for (  Artifact child : aiArt.getChildren()) {
    if (child.isOfType(AtsArtifactTypes.ActionableItem)) {
      if (!newGuids.contains(child.getGuid())) {
        aiArt.deleteRelation(CoreRelationTypes.Default_Hierarchical__Child,child);
      }
    }
  }
  for (  String newGuid : newGuids) {
    if (!currGuids.contains(newGuid)) {
      Artifact newArt=null;
      IAtsActionableItem newAi=AtsConfigCache.getSoleByGuid(newGuid,IAtsActionableItem.class);
      if (newAi != null) {
        newArt=AtsObjectsClient.getSoleArtifact(newAi);
      }
      if (newArt == null) {
        newArt=ArtifactCache.getActive(newGuid,AtsUtilCore.getAtsBranchToken());
      }
      aiArt.addRelation(CoreRelationTypes.Default_Hierarchical__Child,newArt);
    }
  }
  setRelationsOfType(aiArt,aia.getSubscribed(),AtsRelationTypes.SubscribedUser_User);
  setRelationsOfType(aiArt,aia.getLeads(),AtsRelationTypes.ActionableItemLead_Lead);
  if (!aia.getStaticIds().isEmpty()) {
    aiArt.setAttributeValues(CoreAttributeTypes.StaticId,aia.getStaticIds());
  }
  if (aia.getParentActionableItem() == null && !aia.getGuid().equals(ActionableItems.getTopActionableItem().getGuid())) {
    Artifact topAIArt=AtsObjectsClient.getSoleArtifact(ActionableItems.getTopActionableItem());
    topAIArt.addChild(aiArt);
    topAIArt.persist(transaction);
  }
 else {
    Artifact parentAiArt=aiArt.getParent();
    if (parentAiArt != null) {
      if (parentAiArt.isOfType(AtsArtifactTypes.ActionableItem)) {
        if (!parentAiArt.getGuid().equals(aia.getParentActionableItem().getGuid())) {
          Artifact newParentAIArt=AtsObjectsClient.getSoleArtifact(aia);
          newParentAIArt.addChild(aiArt);
          newParentAIArt.persist(transaction);
          parentAiArt.persist(transaction);
        }
      }
    }
  }
  aiArt.persist(transaction);
  return Result.TrueResult;
}

Fixed version (ground truth):
@Override public Result saveToArtifact(SkynetTransaction transaction) throws OseeCoreException {
  Artifact aiArt=getArtifact();
  if (aiArt == null) {
    throw new OseeArgumentException("String_Node_Str");
  }
  IAtsActionableItem aia=getActionableItem();
  aiArt.setName(aia.getName());
  aiArt.setSoleAttributeValue(AtsAttributeTypes.Active,aia.isActive());
  boolean actionable=aiArt.getSoleAttributeValue(AtsAttributeTypes.Actionable,false);
  if (actionable != aia.isActionable()) {
    aiArt.setSoleAttributeValue(AtsAttributeTypes.Actionable,aia.isActionable());
  }
  if (Strings.isValid(aia.getDescription())) {
    aiArt.setSoleAttributeValue(AtsAttributeTypes.Description,aia.getDescription());
  }
  if (aia.getTeamDefinition() != null) {
    Artifact teamDefArt=new TeamDefinitionArtifactStore(aia.getTeamDefinition()).getArtifact();
    if (teamDefArt != null && !teamDefArt.getRelatedArtifacts(AtsRelationTypes.TeamActionableItem_ActionableItem).contains(aiArt)) {
      aiArt.deleteRelations(AtsRelationTypes.TeamActionableItem_Team);
      aiArt.addRelation(AtsRelationTypes.TeamActionableItem_Team,teamDefArt);
      teamDefArt.persist(transaction);
    }
  }
  List<String> newGuids=AtsObjects.toGuids(aia.getChildrenActionableItems());
  List<String> currGuids=Artifacts.toGuids(aiArt.getChildren());
  for (  Artifact child : aiArt.getChildren()) {
    if (child.isOfType(AtsArtifactTypes.ActionableItem)) {
      if (!newGuids.contains(child.getGuid())) {
        aiArt.deleteRelation(CoreRelationTypes.Default_Hierarchical__Child,child);
      }
    }
  }
  for (  String newGuid : newGuids) {
    if (!currGuids.contains(newGuid)) {
      Artifact newArt=null;
      IAtsActionableItem newAi=AtsConfigCache.getSoleByGuid(newGuid,IAtsActionableItem.class);
      if (newAi != null) {
        newArt=AtsObjectsClient.getSoleArtifact(newAi);
      }
      if (newArt == null) {
        newArt=ArtifactCache.getActive(newGuid,AtsUtilCore.getAtsBranchToken());
      }
      aiArt.addRelation(CoreRelationTypes.Default_Hierarchical__Child,newArt);
    }
  }
  setRelationsOfType(aiArt,aia.getSubscribed(),AtsRelationTypes.SubscribedUser_User);
  setRelationsOfType(aiArt,aia.getLeads(),AtsRelationTypes.ActionableItemLead_Lead);
  if (!aia.getStaticIds().isEmpty()) {
    aiArt.setAttributeValues(CoreAttributeTypes.StaticId,aia.getStaticIds());
  }
  if (aia.getParentActionableItem() == null && !aia.getGuid().equals(ActionableItems.getTopActionableItem().getGuid())) {
    Artifact topAIArt=AtsObjectsClient.getSoleArtifact(ActionableItems.getTopActionableItem());
    topAIArt.addChild(aiArt);
    topAIArt.persist(transaction);
  }
 else {
    Artifact parentAiArt=aiArt.getParent();
    if (parentAiArt != null) {
      if (parentAiArt.isOfType(AtsArtifactTypes.ActionableItem)) {
        if (!parentAiArt.getGuid().equals(aia.getParentActionableItem().getGuid())) {
          Artifact newParentAIArt=AtsObjectsClient.getSoleArtifact(aia);
          newParentAIArt.addChild(aiArt);
          newParentAIArt.persist(transaction);
          parentAiArt.persist(transaction);
        }
      }
    }
  }
  aiArt.persist(transaction);
  return Result.TrueResult;
}