Program: 125362
Project: 125362
Buggy source:
/** 
 * ggu Comment method "checkJobItemsForUpdate".
 * @param types - need update types of jobs.
 * @param sourceIdMap - map old source id to new one.
 * @param sourceItem - modified repository item.
 * @return
 */
private List<UpdateResult> checkJobItemsForUpdate(IProgressMonitor parentMonitor,final Set<IUpdateItemType> types,final boolean onlySimpleShow) throws InterruptedException {
  if (types == null || types.isEmpty()) {
    return null;
  }
  RepositoryUpdateManagerHelper helper=new RepositoryUpdateManagerHelper(){
    @Override protected boolean enableCheckItem(){
      return parameter != null && relations != null && !onlyOpeningJob;
    }
    @Override protected List<Relation> getRelations(){
      return relations;
    }
    @Override protected List<UpdateResult> getOtherUpdateResults(    IProgressMonitor parentMonitor,    List<IProcess2> openedProcessList,    Set<IUpdateItemType> types){
      List<UpdateResult> resultList=new ArrayList<UpdateResult>();
      if (isDetectAndUpdate) {
        resultList=updateAllProcess(parentMonitor,resultList,openedProcessList,types,false);
      }
      if (!onlyOpeningJob) {
        List<UpdateResult> templateSetUpdate=checkSettingInJobTemplateWizard();
        if (templateSetUpdate != null) {
          resultList.addAll(templateSetUpdate);
        }
      }
      return resultList;
    }
    @Override protected void checkAndSetParameters(    IProcess2 process2){
      IContextManager contextManager=process2.getContextManager();
      if (contextManager instanceof JobContextManager) {
        JobContextManager jobContextManager=(JobContextManager)contextManager;
        jobContextManager.setRepositoryRenamedMap(getContextRenamedMap());
        jobContextManager.setNewParametersMap(getNewParametersMap());
        Map<ContextItem,List<IContext>> repositoryAddGroupContext=getRepositoryAddGroupContext();
        if (checkAddContextGroup && repositoryAddGroupContext.isEmpty() && parameter instanceof ContextItem) {
          List<IContext> addContextGroupList=new ArrayList<IContext>();
          List<IContext> jobContexts=process2.getContextManager().getListContext();
          List<ContextType> repositoryContexts=((ContextItem)parameter).getContext();
          String repositoryId=((ContextItem)parameter).getProperty().getId();
          for (          ContextType repoContext : repositoryContexts) {
            boolean found=false;
            for (            IContext jobContext : jobContexts) {
              if (jobContext.getName().equals(repoContext.getName())) {
                found=true;
              }
            }
            if (!found) {
              IContext jobContext=new JobContext(repoContext.getName());
              List<ContextParameterType> repoParams=repoContext.getContextParameter();
              for (              ContextParameterType repoParam : repoParams) {
                IContextParameter jobParam=new JobContextParameter();
                jobParam.setName(repoParam.getName());
                jobParam.setContext(jobContext);
                jobParam.setComment(repoParam.getComment());
                jobParam.setPrompt(repoParam.getPrompt());
                jobParam.setSource(repositoryId);
                jobParam.setType(repoParam.getType());
                jobParam.setValue(repoParam.getValue());
                jobContext.getContextParameterList().add(jobParam);
              }
              addContextGroupList.add(jobContext);
            }
          }
          repositoryAddGroupContext.put((ContextItem)parameter,addContextGroupList);
        }
        List<IContext> listIContext=new ArrayList<IContext>();
        for (        ContextItem item : repositoryAddGroupContext.keySet()) {
          List<IContext> list=repositoryAddGroupContext.get(item);
          ListIterator<IContext> listIterator=list.listIterator();
          while (listIterator.hasNext()) {
            IContext context=listIterator.next();
            JobContext newJobContext=new JobContext(context.getName());
            List<IContextParameter> existedParameters=new ArrayList<IContextParameter>();
            for (int j=0; j < context.getContextParameterList().size(); j++) {
              IContextParameter param=context.getContextParameterList().get(j);
              IContextParameter contextParameter=jobContextManager.getDefaultContext().getContextParameter(param.getName());
              if (contextParameter != null && param.getName().equals(contextParameter.getName()) && item.getProperty().getId().equals(contextParameter.getSource())) {
                IContextParameter clone=param.clone();
                clone.setContext(newJobContext);
                existedParameters.add(clone);
              }
            }
            if (!existedParameters.isEmpty()) {
              newJobContext.setContextParameterList(existedParameters);
              listIContext.add(newJobContext);
            }
          }
        }
        jobContextManager.setAddGroupContext(listIContext);
        jobContextManager.setAddContextGroupMap(repositoryAddGroupContext);
        Map<ContextItem,List<IContext>> repositoryRemoveGroupContext=getRepositoryRemoveGroupContext();
        List<IContext> removeListIContext=new ArrayList<IContext>();
        for (        ContextItem item : repositoryRemoveGroupContext.keySet()) {
          List<IContext> list=repositoryRemoveGroupContext.get(item);
          ListIterator<IContext> listIterator=list.listIterator();
          while (listIterator.hasNext()) {
            IContext context=listIterator.next();
            if (!removeListIContext.contains(context)) {
              removeListIContext.add(context);
            }
          }
        }
        jobContextManager.setRemoveGroupContext(removeListIContext);
        jobContextManager.setRemoveContextGroupMap(repositoryRemoveGroupContext);
        Map<ContextItem,List<IContext>> repositoryRenameGroupContext=getRepositoryRenameGroupContext();
        jobContextManager.setRenameGroupContext(getRenameContextGroup());
        jobContextManager.setRenameContextGroupMap(repositoryRenameGroupContext);
      }
      IUpdateManager updateManager=process2.getUpdateManager();
      if (updateManager instanceof AbstractUpdateManager) {
        AbstractUpdateManager manager=(AbstractUpdateManager)updateManager;
        if (getSchemaRenamedMap() != null && !getSchemaRenamedMap().isEmpty()) {
          manager.setSchemaRenamedMap(getSchemaRenamedMap());
        }
        if (getColumnRenamedMap() != null && !getColumnRenamedMap().isEmpty()) {
          manager.setColumnRenamedMap(getColumnRenamedMap());
        }
        if (getDeletedOrReselectTablesMap() != null && !getDeletedOrReselectTablesMap().isEmpty()) {
          manager.setDeletedOrReselectTablesMap(getDeletedOrReselectTablesMap());
        }
        manager.setFromRepository(true);
        if (isAddColumn) {
          manager.setAddColumn(true);
          isAddColumn=false;
        }
      }
      for (      INode node : process2.getGraphicalNodes()) {
        if (node.getElementName().startsWith("String_Node_Str") && parameter instanceof Item) {
          String id=((Item)parameter).getProperty().getId();
          IElementParameter repoProperty=node.getElementParameter("String_Node_Str");
          if (repoProperty != null) {
            repoProperty.setValue(id);
          }
        }
      }
    }
  }
;
  return helper.checkJobItemsForUpdate(parentMonitor,types);
}

Fixed version (ground truth):
/** 
 * ggu Comment method "checkJobItemsForUpdate".
 * @param types - need update types of jobs.
 * @param sourceIdMap - map old source id to new one.
 * @param sourceItem - modified repository item.
 * @return
 */
private List<UpdateResult> checkJobItemsForUpdate(IProgressMonitor parentMonitor,final Set<IUpdateItemType> types,final boolean onlySimpleShow) throws InterruptedException {
  if (types == null || types.isEmpty()) {
    return null;
  }
  RepositoryUpdateManagerHelper helper=new RepositoryUpdateManagerHelper(){
    @Override protected boolean enableCheckItem(){
      return parameter != null && relations != null && !onlyOpeningJob;
    }
    @Override protected List<Relation> getRelations(){
      return relations;
    }
    @Override protected List<UpdateResult> getOtherUpdateResults(    IProgressMonitor parentMonitor,    List<IProcess2> openedProcessList,    Set<IUpdateItemType> types){
      List<UpdateResult> resultList=new ArrayList<UpdateResult>();
      if (isDetectAndUpdate) {
        resultList=updateAllProcess(parentMonitor,resultList,openedProcessList,types,false);
      }
      if (!onlyOpeningJob) {
        List<UpdateResult> templateSetUpdate=checkSettingInJobTemplateWizard();
        if (templateSetUpdate != null) {
          resultList.addAll(templateSetUpdate);
        }
      }
      return resultList;
    }
    @Override protected void checkAndSetParameters(    IProcess2 process2){
      IContextManager contextManager=process2.getContextManager();
      if (contextManager instanceof JobContextManager) {
        JobContextManager jobContextManager=(JobContextManager)contextManager;
        jobContextManager.setRepositoryRenamedMap(getContextRenamedMap());
        jobContextManager.setNewParametersMap(getNewParametersMap());
        Map<ContextItem,List<IContext>> repositoryAddGroupContext=getRepositoryAddGroupContext();
        if (checkAddContextGroup && repositoryAddGroupContext.isEmpty() && parameter instanceof ContextItem) {
          List<IContext> addContextGroupList=new ArrayList<IContext>();
          List<IContext> jobContexts=process2.getContextManager().getListContext();
          List<ContextType> repositoryContexts=((ContextItem)parameter).getContext();
          String repositoryId=((ContextItem)parameter).getProperty().getId();
          for (          ContextType repoContext : repositoryContexts) {
            boolean found=false;
            for (            IContext jobContext : jobContexts) {
              if (jobContext.getName().equals(repoContext.getName())) {
                found=true;
              }
            }
            if (!found) {
              IContext jobContext=new JobContext(repoContext.getName());
              List<ContextParameterType> repoParams=repoContext.getContextParameter();
              for (              ContextParameterType repoParam : repoParams) {
                IContextParameter jobParam=new JobContextParameter();
                jobParam.setName(repoParam.getName());
                jobParam.setContext(jobContext);
                jobParam.setComment(repoParam.getComment());
                jobParam.setPrompt(repoParam.getPrompt());
                jobParam.setSource(repositoryId);
                jobParam.setType(repoParam.getType());
                jobParam.setValue(repoParam.getValue());
                jobContext.getContextParameterList().add(jobParam);
              }
              addContextGroupList.add(jobContext);
            }
          }
          repositoryAddGroupContext.put((ContextItem)parameter,addContextGroupList);
        }
        List<IContext> listIContext=new ArrayList<IContext>();
        for (        ContextItem item : repositoryAddGroupContext.keySet()) {
          List<IContext> list=repositoryAddGroupContext.get(item);
          ListIterator<IContext> listIterator=list.listIterator();
          while (listIterator.hasNext()) {
            IContext context=listIterator.next();
            JobContext newJobContext=new JobContext(context.getName());
            List<IContextParameter> existedParameters=new ArrayList<IContextParameter>();
            for (int j=0; j < context.getContextParameterList().size(); j++) {
              IContextParameter param=context.getContextParameterList().get(j);
              IContextParameter contextParameter=jobContextManager.getDefaultContext().getContextParameter(param.getName());
              if (contextParameter != null && param.getName().equals(contextParameter.getName()) && item.getProperty().getId().equals(contextParameter.getSource())) {
                IContextParameter clone=param.clone();
                clone.setContext(newJobContext);
                existedParameters.add(clone);
              }
            }
            if (!existedParameters.isEmpty()) {
              newJobContext.setContextParameterList(existedParameters);
              listIContext.add(newJobContext);
            }
          }
        }
        jobContextManager.setAddGroupContext(listIContext);
        jobContextManager.setAddContextGroupMap(repositoryAddGroupContext);
        Map<ContextItem,List<IContext>> repositoryRemoveGroupContext=getRepositoryRemoveGroupContext();
        List<IContext> removeListIContext=new ArrayList<IContext>();
        for (        ContextItem item : repositoryRemoveGroupContext.keySet()) {
          List<IContext> list=repositoryRemoveGroupContext.get(item);
          ListIterator<IContext> listIterator=list.listIterator();
          while (listIterator.hasNext()) {
            IContext context=listIterator.next();
            if (!removeListIContext.contains(context)) {
              removeListIContext.add(context);
            }
          }
        }
        jobContextManager.setRemoveGroupContext(removeListIContext);
        jobContextManager.setRemoveContextGroupMap(repositoryRemoveGroupContext);
        Map<ContextItem,List<IContext>> repositoryRenameGroupContext=getRepositoryRenameGroupContext();
        jobContextManager.setRenameGroupContext(getRenameContextGroup());
        jobContextManager.setRenameContextGroupMap(repositoryRenameGroupContext);
      }
      IUpdateManager updateManager=process2.getUpdateManager();
      if (updateManager instanceof AbstractUpdateManager) {
        AbstractUpdateManager manager=(AbstractUpdateManager)updateManager;
        if (getSchemaRenamedMap() != null && !getSchemaRenamedMap().isEmpty()) {
          manager.setSchemaRenamedMap(getSchemaRenamedMap());
        }
        if (getColumnRenamedMap() != null && !getColumnRenamedMap().isEmpty()) {
          manager.setColumnRenamedMap(getColumnRenamedMap());
        }
        if (getDeletedOrReselectTablesMap() != null && !getDeletedOrReselectTablesMap().isEmpty()) {
          manager.setDeletedOrReselectTablesMap(getDeletedOrReselectTablesMap());
        }
        manager.setFromRepository(true);
        if (isAddColumn) {
          manager.setAddColumn(true);
          isAddColumn=false;
        }
      }
      for (      INode node : process2.getGraphicalNodes()) {
        if (node.getComponent().getName().startsWith("String_Node_Str") && parameter instanceof Item) {
          String id=((Item)parameter).getProperty().getId();
          IElementParameter repoProperty=node.getElementParameter("String_Node_Str");
          if (repoProperty != null) {
            repoProperty.setValue(id);
          }
        }
      }
    }
  }
;
  return helper.checkJobItemsForUpdate(parentMonitor,types);
}