Program: 126271
Project: 126271
Buggy source:
@Override public Set<ItemReferenceBean> checkItemReferenceBeans(IProxyRepositoryFactory factory,DeleteActionCache deleteActionCache,IRepositoryViewObject object){
  Item nodeItem=object.getProperty().getItem();
  boolean needCheckJobIfUsedInProcess=false;
  if (nodeItem instanceof ProcessItem) {
    needCheckJobIfUsedInProcess=true;
  }
  Set<ItemReferenceBean> list=new HashSet<ItemReferenceBean>();
  if (needCheckJobIfUsedInProcess) {
    Property property=object.getProperty();
    if (property != null) {
      String label=property.getLabel();
      String version=property.getVersion();
      ERepositoryObjectType type=object.getRepositoryObjectType();
      boolean isItemDeleted=factory.getStatus(object) == ERepositoryStatus.DELETED;
      Item item=property.getItem();
      if (!(item instanceof ProcessItem)) {
        return list;
      }
      List<Relation> relations=RelationshipItemBuilder.getInstance().getItemsHaveRelationWith(property.getId());
      if (relations.isEmpty()) {
        return list;
      }
      Set<Project> refParentProjects=new HashSet<Project>();
      try {
        refParentProjects.add(ProjectManager.getInstance().getCurrentProject());
        refParentProjects.addAll(ProjectManager.getInstance().getReferencedProjects());
        for (        Project refP : refParentProjects) {
          List<IRepositoryViewObject> processes=factory.getAll(refP,ERepositoryObjectType.PROCESS,true);
          deleteActionCache.setProcessList(processes);
          for (          IRepositoryViewObject process : deleteActionCache.getProcessList()) {
            Property property2=process.getProperty();
            if (isOpenedItem(property2,deleteActionCache.getOpenProcessMap())) {
              continue;
            }
            Relation current=new Relation();
            current.setId(property2.getId());
            current.setType(RelationshipItemBuilder.JOB_RELATION);
            current.setVersion(property2.getVersion());
            if (!relations.contains(current)) {
              continue;
            }
            boolean isDelete=factory.getStatus(process) == ERepositoryStatus.DELETED;
            Item item2=property2.getItem();
            if (item == item2) {
              continue;
            }
            String path=item2.getState().getPath();
            boolean found=false;
            ItemReferenceBean bean=new ItemReferenceBean();
            bean.setItemName(label);
            bean.setItemVersion(version);
            bean.setItemType(type);
            bean.setItemDeleted(isItemDeleted);
            bean.setReferenceItemName(property2.getLabel());
            bean.setReferenceItemVersion(property2.getVersion());
            bean.setReferenceItemType(process.getRepositoryObjectType());
            bean.setReferenceItemPath(path);
            bean.setReferenceProjectName(refP.getLabel());
            bean.setReferenceItemDeleted(isDelete);
            for (            ItemReferenceBean b : list) {
              if (b.equals(bean)) {
                found=true;
                b.addNodeNum();
                break;
              }
            }
            if (!found) {
              list.add(bean);
            }
          }
        }
        for (        IProcess2 openedProcess : deleteActionCache.getOpenedProcessList()) {
          for (          INode node : openedProcess.getGraphicalNodes()) {
            boolean equals=false;
            IElementParameter processTypeParam=node.getElementParameter(PROCESS_TYPE_PROCESS);
            if (processTypeParam != null) {
              IElementParameter isUseDynamicJob=node.getElementParameter(USE_DYNAMIC_JOB);
              if (isUseDynamicJob != null && (Boolean)isUseDynamicJob.getValue()) {
                String[] jobsID=((String)processTypeParam.getValue()).split("String_Node_Str");
                for (                String jobID : jobsID) {
                  if (property.getId().equals(jobID)) {
                    equals=true;
                    break;
                  }
                }
              }
 else               if (property.getId().equals(processTypeParam.getValue())) {
                equals=true;
              }
            }
            boolean isDelete=factory.getStatus(openedProcess) == ERepositoryStatus.DELETED;
            Property property2=openedProcess.getProperty();
            Item item2=property2.getItem();
            String path=item2.getState().getPath();
            if (equals) {
              boolean found=false;
              ItemReferenceBean bean=new ItemReferenceBean();
              bean.setItemName(label);
              bean.setItemVersion(version);
              bean.setItemType(type);
              bean.setItemDeleted(isItemDeleted);
              bean.setReferenceItemName(property2.getLabel());
              bean.setReferenceItemVersion(property2.getVersion());
              bean.setReferenceItemType(ERepositoryObjectType.getItemType(item2));
              bean.setReferenceItemPath(path);
              bean.setReferenceProjectName(ProjectManager.getInstance().getProject(property2).getLabel());
              bean.setReferenceItemDeleted(isDelete);
              for (              ItemReferenceBean b : list) {
                if (b.equals(bean)) {
                  found=true;
                  b.addNodeNum();
                  break;
                }
              }
              if (!found) {
                list.add(bean);
              }
            }
          }
        }
      }
 catch (      PersistenceException e) {
        ExceptionHandler.process(e);
      }
    }
  }
  Iterator<ItemReferenceBean> it=list.iterator();
  while (it.hasNext()) {
    ItemReferenceBean bean=it.next();
    if ((!bean.isItemDeleted() && bean.isReferenceItemDeleted()) || (bean.isItemDeleted() && bean.isReferenceItemDeleted() && isItemInDeleteList(bean,true)) || (!bean.isItemDeleted() && !bean.isReferenceItemDeleted() && isItemInDeleteList(bean,true))) {
      it.remove();
    }
  }
  return list;
}

Fixed version (ground truth):
@Override public Set<ItemReferenceBean> checkItemReferenceBeans(IProxyRepositoryFactory factory,DeleteActionCache deleteActionCache,IRepositoryViewObject object){
  Item nodeItem=object.getProperty().getItem();
  boolean needCheckJobIfUsedInProcess=false;
  if (nodeItem instanceof ProcessItem) {
    needCheckJobIfUsedInProcess=true;
  }
  Set<ItemReferenceBean> list=new HashSet<ItemReferenceBean>();
  if (needCheckJobIfUsedInProcess) {
    Property property=object.getProperty();
    if (property != null) {
      String label=property.getLabel();
      String version=property.getVersion();
      ERepositoryObjectType type=object.getRepositoryObjectType();
      boolean isItemDeleted=factory.getStatus(object) == ERepositoryStatus.DELETED;
      Item item=property.getItem();
      if (!(item instanceof ProcessItem)) {
        return list;
      }
      List<Relation> relations=RelationshipItemBuilder.getInstance().getItemsHaveRelationWith(property.getId());
      if (relations.isEmpty()) {
        return list;
      }
      Set<Project> refParentProjects=new HashSet<Project>();
      try {
        refParentProjects.add(ProjectManager.getInstance().getCurrentProject());
        refParentProjects.addAll(ProjectManager.getInstance().getReferencedProjects());
        for (        Project refP : refParentProjects) {
          List<IRepositoryViewObject> processes=new LinkedList<IRepositoryViewObject>();
          List<ERepositoryObjectType> allTypesOfProcess=ERepositoryObjectType.getAllTypesOfProcess();
          Iterator<ERepositoryObjectType> processIter=allTypesOfProcess.iterator();
          while (processIter.hasNext()) {
            ERepositoryObjectType process=processIter.next();
            List<IRepositoryViewObject> repositoryViewObjectList=factory.getAll(refP,process,true);
            if (repositoryViewObjectList != null) {
              processes.addAll(repositoryViewObjectList);
            }
          }
          deleteActionCache.setProcessList(processes);
          Iterator<IRepositoryViewObject> processObjectIter=deleteActionCache.getProcessList().iterator();
          while (processObjectIter.hasNext()) {
            IRepositoryViewObject process=processObjectIter.next();
            Property property2=process.getProperty();
            if (isOpenedItem(property2,deleteActionCache.getOpenProcessMap())) {
              continue;
            }
            Relation current=new Relation();
            current.setId(property2.getId());
            current.setType(RelationshipItemBuilder.JOB_RELATION);
            current.setVersion(property2.getVersion());
            if (!relations.contains(current)) {
              continue;
            }
            boolean isDelete=factory.getStatus(process) == ERepositoryStatus.DELETED;
            Item item2=property2.getItem();
            if (item == item2) {
              continue;
            }
            String path=item2.getState().getPath();
            boolean found=false;
            ItemReferenceBean bean=new ItemReferenceBean();
            bean.setItemName(label);
            bean.setItemVersion(version);
            bean.setItemType(type);
            bean.setItemDeleted(isItemDeleted);
            bean.setReferenceItemName(property2.getLabel());
            bean.setReferenceItemVersion(property2.getVersion());
            bean.setReferenceItemType(process.getRepositoryObjectType());
            bean.setReferenceItemPath(path);
            bean.setReferenceProjectName(refP.getLabel());
            bean.setReferenceItemDeleted(isDelete);
            for (            ItemReferenceBean b : list) {
              if (b.equals(bean)) {
                found=true;
                b.addNodeNum();
                break;
              }
            }
            if (!found) {
              list.add(bean);
            }
          }
        }
        for (        IProcess2 openedProcess : deleteActionCache.getOpenedProcessList()) {
          for (          INode node : openedProcess.getGraphicalNodes()) {
            boolean equals=false;
            IElementParameter processTypeParam=node.getElementParameter(PROCESS_TYPE_PROCESS);
            if (processTypeParam != null) {
              IElementParameter isUseDynamicJob=node.getElementParameter(USE_DYNAMIC_JOB);
              if (isUseDynamicJob != null && (Boolean)isUseDynamicJob.getValue()) {
                String[] jobsID=((String)processTypeParam.getValue()).split("String_Node_Str");
                for (                String jobID : jobsID) {
                  if (property.getId().equals(jobID)) {
                    equals=true;
                    break;
                  }
                }
              }
 else               if (property.getId().equals(processTypeParam.getValue())) {
                equals=true;
              }
            }
            boolean isDelete=factory.getStatus(openedProcess) == ERepositoryStatus.DELETED;
            Property property2=openedProcess.getProperty();
            Item item2=property2.getItem();
            String path=item2.getState().getPath();
            if (equals) {
              boolean found=false;
              ItemReferenceBean bean=new ItemReferenceBean();
              bean.setItemName(label);
              bean.setItemVersion(version);
              bean.setItemType(type);
              bean.setItemDeleted(isItemDeleted);
              bean.setReferenceItemName(property2.getLabel());
              bean.setReferenceItemVersion(property2.getVersion());
              bean.setReferenceItemType(ERepositoryObjectType.getItemType(item2));
              bean.setReferenceItemPath(path);
              bean.setReferenceProjectName(ProjectManager.getInstance().getProject(property2).getLabel());
              bean.setReferenceItemDeleted(isDelete);
              for (              ItemReferenceBean b : list) {
                if (b.equals(bean)) {
                  found=true;
                  b.addNodeNum();
                  break;
                }
              }
              if (!found) {
                list.add(bean);
              }
            }
          }
        }
      }
 catch (      PersistenceException e) {
        ExceptionHandler.process(e);
      }
    }
  }
  Iterator<ItemReferenceBean> it=list.iterator();
  while (it.hasNext()) {
    ItemReferenceBean bean=it.next();
    if ((!bean.isItemDeleted() && bean.isReferenceItemDeleted()) || (bean.isItemDeleted() && bean.isReferenceItemDeleted() && isItemInDeleteList(bean,true)) || (!bean.isItemDeleted() && !bean.isReferenceItemDeleted() && isItemInDeleteList(bean,true))) {
      it.remove();
    }
  }
  return list;
}