Program: 121576
Project: 121576
Buggy source:
private JSONObject collectJobDetails() throws PersistenceException, JSONException {
  JSONObject jObject=new JSONObject();
  Project currentProject=ProjectManager.getInstance().getCurrentProject();
  final IProxyRepositoryFactory factory=CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
  int jobsNum=0;
  int componentsNum=0;
  int contextVarsNum=0;
  int businessModelsNum=0;
  int generatedJobDocsNum=0;
  int metadatasNum=0;
  Map<String,Integer> numComponentMap=new HashMap<String,Integer>();
  ERepositoryObjectType jobType=ERepositoryObjectType.PROCESS;
  if (jobType != null) {
    List<IRepositoryViewObject> all=factory.getAll(currentProject,jobType);
    jobsNum+=all.size();
    for (    IRepositoryViewObject rvo : all) {
      Item item=rvo.getProperty().getItem();
      if (item.eClass() == PropertiesPackage.Literals.PROCESS_ITEM) {
        ProcessType processType=((ProcessItem)item).getProcess();
        componentsNum+=processType.getNode().size();
        for (        NodeType node : (List<NodeType>)processType.getNode()) {
          String componentName=node.getComponentName();
          Integer integer=numComponentMap.get(componentName);
          if (integer == null) {
            numComponentMap.put(componentName,1);
          }
 else {
            numComponentMap.put(componentName,integer + 1);
          }
        }
        EList contexts=processType.getContext();
        if (contexts.size() > 0) {
          ContextType contextType=(ContextType)contexts.get(0);
          contextVarsNum+=contextType.getContextParameter().size();
        }
      }
    }
  }
  ERepositoryObjectType bmType=ERepositoryObjectType.BUSINESS_PROCESS;
  if (bmType != null) {
    businessModelsNum+=factory.getAll(currentProject,bmType).size();
  }
  ERepositoryObjectType jobDocType=ERepositoryObjectType.JOB_DOC;
  if (jobDocType != null) {
    generatedJobDocsNum+=factory.getAll(currentProject,jobDocType).size();
  }
  for (  DynaEnum type : ERepositoryObjectType.values()) {
    if (type instanceof ERepositoryObjectType) {
      ERepositoryObjectType repType=(ERepositoryObjectType)type;
      String folder=repType.getFolder();
      if (repType.isDIItemType() && repType.isResouce() && folder != null && folder.startsWith(ERepositoryObjectType.METADATA.getFolder())) {
        metadatasNum+=factory.getAll(currentProject,repType).size();
      }
    }
  }
  jObject.put(TOS_COUNT_JOBS.getKey(),jobsNum);
  jObject.put(TOS_COUNT_BUSINESS_MODELS.getKey(),businessModelsNum);
  jObject.put(TOS_COUNT_GENERATED_JOB_DOCS.getKey(),generatedJobDocsNum);
  jObject.put(TOS_COUNT_METADATAS.getKey(),metadatasNum);
  jObject.put(TOS_COUNT_CONTEXT_VARIABLES.getKey(),contextVarsNum);
  jObject.put(TOS_COUNT_COMPONENTS.getKey(),componentsNum);
  jObject.put(TOS_JOB_TOP20_COMPONENTS.getKey(),TokenInforUtil.convertTopComponents(numComponentMap,TOP_USED_COMPONENTS_MAX));
  return jObject;
}

Fixed version (ground truth):
private JSONObject collectJobDetails() throws PersistenceException, JSONException {
  JSONObject jObject=new JSONObject();
  Project currentProject=ProjectManager.getInstance().getCurrentProject();
  final IProxyRepositoryFactory factory=ProxyRepositoryFactory.getInstance();
  int jobsNum=0;
  int componentsNum=0;
  int contextVarsNum=0;
  int businessModelsNum=0;
  int generatedJobDocsNum=0;
  int metadatasNum=0;
  Map<String,Integer> numComponentMap=new HashMap<String,Integer>();
  IEditorReference[] reference=PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
  List<IProcess2> processes=RepositoryPlugin.getDefault().getDesignerCoreService().getOpenedProcess(reference);
  Set<String> idsOpened=new HashSet<String>();
  for (  IProcess2 process : processes) {
    idsOpened.add(process.getId());
  }
  ERepositoryObjectType jobType=ERepositoryObjectType.PROCESS;
  if (jobType != null) {
    List<IRepositoryViewObject> all=factory.getAll(currentProject,jobType);
    jobsNum+=all.size();
    for (    IRepositoryViewObject rvo : all) {
      Item item=rvo.getProperty().getItem();
      if (item.eClass() == PropertiesPackage.Literals.PROCESS_ITEM) {
        ProcessType processType=((ProcessItem)item).getProcess();
        componentsNum+=processType.getNode().size();
        for (        NodeType node : (List<NodeType>)processType.getNode()) {
          String componentName=node.getComponentName();
          Integer integer=numComponentMap.get(componentName);
          if (integer == null) {
            numComponentMap.put(componentName,1);
          }
 else {
            numComponentMap.put(componentName,integer + 1);
          }
        }
        EList contexts=processType.getContext();
        if (contexts.size() > 0) {
          ContextType contextType=(ContextType)contexts.get(0);
          contextVarsNum+=contextType.getContextParameter().size();
        }
      }
      if (factory.getStatus(item) != ERepositoryStatus.LOCK_BY_USER && !idsOpened.contains(item.getProperty().getId())) {
        if (item.getParent() instanceof FolderItem) {
          ((FolderItem)item.getParent()).getChildren().remove(item);
          item.setParent(null);
        }
        item.eResource().unload();
      }
    }
  }
  ERepositoryObjectType bmType=ERepositoryObjectType.BUSINESS_PROCESS;
  if (bmType != null) {
    businessModelsNum+=factory.getAll(currentProject,bmType).size();
  }
  ERepositoryObjectType jobDocType=ERepositoryObjectType.JOB_DOC;
  if (jobDocType != null) {
    generatedJobDocsNum+=factory.getAll(currentProject,jobDocType).size();
  }
  for (  DynaEnum type : ERepositoryObjectType.values()) {
    if (type instanceof ERepositoryObjectType) {
      ERepositoryObjectType repType=(ERepositoryObjectType)type;
      String folder=repType.getFolder();
      if (repType.isDIItemType() && repType.isResouce() && folder != null && folder.startsWith(ERepositoryObjectType.METADATA.getFolder())) {
        metadatasNum+=factory.getAll(currentProject,repType).size();
      }
    }
  }
  jObject.put(TOS_COUNT_JOBS.getKey(),jobsNum);
  jObject.put(TOS_COUNT_BUSINESS_MODELS.getKey(),businessModelsNum);
  jObject.put(TOS_COUNT_GENERATED_JOB_DOCS.getKey(),generatedJobDocsNum);
  jObject.put(TOS_COUNT_METADATAS.getKey(),metadatasNum);
  jObject.put(TOS_COUNT_CONTEXT_VARIABLES.getKey(),contextVarsNum);
  jObject.put(TOS_COUNT_COMPONENTS.getKey(),componentsNum);
  jObject.put(TOS_JOB_TOP20_COMPONENTS.getKey(),TokenInforUtil.convertTopComponents(numComponentMap,TOP_USED_COMPONENTS_MAX));
  return jObject;
}