Program: 136473
Project: 136473
Buggy source:
/** 
 * get the ItemEditorInput according to the repNode, if there no ItemEditorInput return null.
 * @param repNode
 * @param isOpenItemEditorAction
 * @return IEditorInput
 * @throws PersistenceException
 */
public IEditorInput computeEditorInput(IRepositoryNode repNode,boolean isOpenItemEditorAction) throws BusinessException {
  if (repNode != null && !isOpenItemEditorAction) {
    IRepositoryNode currentNode=repNode;
    do {
      RepositoryNode parentNode=currentNode.getParent();
      if (parentNode != null && parentNode instanceof RecycleBinRepNode) {
        return null;
      }
      currentNode=parentNode;
    }
 while (currentNode != null);
  }
  IEditorInput result=null;
  IRepositoryViewObject repViewObj=repNode.getObject();
  if (repViewObj != null) {
    String key=repViewObj.getRepositoryObjectType().getKey();
    Item item=repViewObj.getProperty().getItem();
    if (item instanceof TDQItem && !(item instanceof TDQFileItem)) {
      ModelElement modelElement=PropertyHelper.getModelElement(repViewObj.getProperty());
      if (modelElement.eIsProxy() && repNode != null) {
        modelElement=EMFSharedResources.getInstance().reloadModelElementInNode(repNode);
        item=repViewObj.getProperty().getItem();
      }
      if (modelElement == null || modelElement.eResource() == null) {
        throw ExceptionFactory.getInstance().createBusinessException(((TDQItem)item).getFilename());
      }
    }
    if (ERepositoryObjectType.METADATA_CONNECTIONS.getKey().equals(key)) {
      result=new ConnectionItemEditorInput(repNode);
      editorID=ConnectionEditor.class.getName();
    }
 else     if (ERepositoryObjectType.TDQ_ANALYSIS_ELEMENT.getKey().equals(key)) {
      result=new AnalysisItemEditorInput(repNode);
      Analysis analysis=((TDQAnalysisItem)item).getAnalysis();
      if (analysis == null || analysis.getContext() == null) {
        throw ExceptionFactory.getInstance().createBusinessException(repViewObj);
      }
      EList<ModelElement> analysedElements=analysis.getContext().getAnalysedElements();
      RepositoryNode connectionRepositoryNode=null;
      if (!analysedElements.isEmpty()) {
        Connection connection=null;
        ModelElement modelElement=analysedElements.get(0);
        if (modelElement instanceof Connection) {
          connection=(Connection)modelElement;
        }
 else         if (modelElement instanceof Catalog) {
          Catalog catalog=SwitchHelpers.CATALOG_SWITCH.caseCatalog((Catalog)modelElement);
          connection=ConnectionHelper.getConnection(catalog);
        }
 else         if (modelElement instanceof Schema) {
          Schema schema=SwitchHelpers.SCHEMA_SWITCH.caseSchema((Schema)modelElement);
          if (schema != null) {
            connection=ConnectionHelper.getConnection(schema);
          }
        }
 else         if (modelElement instanceof TdTable) {
          TdTable tdTable=SwitchHelpers.TABLE_SWITCH.caseTdTable((TdTable)modelElement);
          connection=ConnectionHelper.getConnection(tdTable);
        }
 else         if (modelElement instanceof TdView) {
          TdView tdView=SwitchHelpers.VIEW_SWITCH.caseTdView((TdView)modelElement);
          connection=ConnectionHelper.getConnection(tdView);
        }
 else         if (modelElement instanceof TdColumn) {
          TdColumn tdColumn=SwitchHelpers.COLUMN_SWITCH.caseTdColumn((TdColumn)modelElement);
          connection=ConnectionHelper.getConnection(tdColumn);
        }
 else         if (modelElement instanceof MetadataColumn) {
          MetadataColumn mColumn=SwitchHelpers.METADATA_COLUMN_SWITCH.doSwitch(modelElement);
          connection=ConnectionHelper.getTdDataProvider(mColumn);
        }
        connectionRepositoryNode=RepositoryNodeHelper.recursiveFind(connection);
      }
      ((AnalysisItemEditorInput)result).setConnectionNode(connectionRepositoryNode);
      if (analysis.getParameters() != null && analysis.getParameters().getAnalysisType().equals(AnalysisType.MATCH_ANALYSIS)) {
        editorID=MatchAnalysisEditor.class.getName();
      }
 else {
        editorID=AnalysisEditor.class.getName();
      }
    }
 else     if (ERepositoryObjectType.TDQ_INDICATOR_ELEMENT.getKey().equals(key)) {
      result=new IndicatorDefinitionItemEditorInput(repNode);
      TDQIndicatorDefinitionItem definitionItem=(TDQIndicatorDefinitionItem)item;
      if (definitionItem.getIndicatorDefinition().eResource() == null) {
        throw ExceptionFactory.getInstance().createBusinessException(definitionItem.getFilename());
      }
      if (UDIHelper.getUDICategory(definitionItem.getIndicatorDefinition()) == null) {
        throw ExceptionFactory.getInstance().createBusinessException(definitionItem.getFilename());
      }
      editorID=IndicatorEditor.class.getName();
    }
 else     if (ERepositoryObjectType.TDQ_RULES_SQL.getKey().equals(key) || ERepositoryObjectType.TDQ_RULES_PARSER.getKey().equals(key) || ERepositoryObjectType.TDQ_RULES_MATCHER.getKey().equals(key)) {
      result=new BusinessRuleItemEditorInput(repNode);
      editorID=DQRuleEditor.class.getName();
    }
 else     if (ERepositoryObjectType.TDQ_PATTERN_ELEMENT.getKey().equals(key)) {
      result=new PatternItemEditorInput(repNode);
      TDQPatternItem patternItem=(TDQPatternItem)item;
      if (patternItem.getPattern() == null || patternItem.getPattern().eResource() == null) {
        throw ExceptionFactory.getInstance().createBusinessException(patternItem.getFilename());
      }
      editorID=PatternEditor.class.getName();
    }
 else     if (ERepositoryObjectType.TDQ_REPORT_ELEMENT.getKey().equals(key)) {
      result=new ReportItemEditorInput(repNode);
      TDQReportItem reportItem=(TDQReportItem)item;
      if (!(reportItem.getReport() instanceof TdReport)) {
        throw ExceptionFactory.getInstance().createBusinessException(reportItem.getFilename());
      }
      for (      AnalysisMap anaMap : ((TdReport)reportItem.getReport()).getAnalysisMap()) {
        Analysis analysis=anaMap.getAnalysis();
        if (analysis.eResource() == null) {
          throw ExceptionFactory.getInstance().createBusinessException(reportItem.getFilename());
        }
      }
      editorID="String_Node_Str";
    }
 else     if (ERepositoryObjectType.TDQ_SOURCE_FILE_ELEMENT.getKey().equals(key) || ERepositoryObjectType.TDQ_JRAXML_ELEMENT.getKey().equals(key)) {
      IPath append=WorkbenchUtils.getFilePath(repViewObj.getRepositoryNode());
      DQRepositoryNode node=(DQRepositoryNode)repViewObj.getRepositoryNode();
      file=ResourceManager.getRoot().getProject(node.getProject().getTechnicalLabel()).getFile(append);
      if (!file.exists()) {
        throw ExceptionFactory.getInstance().createBusinessException(repViewObj);
      }
      if (ERepositoryObjectType.TDQ_SOURCE_FILE_ELEMENT.getKey().equals(key)) {
        editorID=SqlExplorerUtils.SQLEDITOR_ID;
      }
 else {
        editorID=TDQFileEditorInput.DEFAULT_EDITOR_ID;
      }
      result=new TDQFileEditorInput(file);
      ((TDQFileEditorInput)result).setFileItem(item);
      CorePlugin.getDefault().refreshDQView(repNode);
    }
    if (!isOpenItemEditorAction) {
      if (ERepositoryObjectType.TDQ_JRAXML_ELEMENT.getKey().equals(key) || ERepositoryObjectType.TDQ_SOURCE_FILE_ELEMENT.getKey().equals(key)) {
        result=new FileEditorInput(file);
        editorID=FileEditorInput.class.getName();
      }
    }
  }
  return result;
}

Fixed version (ground truth):
/** 
 * get the ItemEditorInput according to the repNode, if there no ItemEditorInput return null.
 * @param repNode
 * @param isOpenItemEditorAction
 * @return IEditorInput
 * @throws PersistenceException
 */
public IEditorInput computeEditorInput(IRepositoryNode repNode,boolean isOpenItemEditorAction) throws BusinessException {
  if (repNode != null && !isOpenItemEditorAction) {
    IRepositoryNode currentNode=repNode;
    do {
      RepositoryNode parentNode=currentNode.getParent();
      if (parentNode != null && parentNode instanceof RecycleBinRepNode) {
        return null;
      }
      currentNode=parentNode;
    }
 while (currentNode != null);
  }
  IEditorInput result=null;
  IRepositoryViewObject repViewObj=repNode.getObject();
  if (repViewObj != null) {
    String key=repViewObj.getRepositoryObjectType().getKey();
    Item item=repViewObj.getProperty().getItem();
    if (item instanceof TDQItem && !(item instanceof TDQFileItem)) {
      ModelElement modelElement=PropertyHelper.getModelElement(repViewObj.getProperty());
      if (modelElement.eIsProxy() && repNode != null) {
        modelElement=EMFSharedResources.getInstance().reloadModelElementInNode(repNode);
        item=repViewObj.getProperty().getItem();
      }
      if (modelElement == null || modelElement.eResource() == null) {
        throw ExceptionFactory.getInstance().createBusinessException(((TDQItem)item).getFilename());
      }
    }
    if (ERepositoryObjectType.METADATA_CONNECTIONS.getKey().equals(key)) {
      result=new ConnectionItemEditorInput(repNode);
      Connection connection=((ConnectionItem)item).getConnection();
      if (connection == null || connection.getDataPackage().size() == 0) {
        throw ExceptionFactory.getInstance().createBusinessException(repViewObj);
      }
      editorID=ConnectionEditor.class.getName();
    }
 else     if (ERepositoryObjectType.TDQ_ANALYSIS_ELEMENT.getKey().equals(key)) {
      result=new AnalysisItemEditorInput(repNode);
      Analysis analysis=((TDQAnalysisItem)item).getAnalysis();
      if (analysis == null || analysis.getContext() == null) {
        throw ExceptionFactory.getInstance().createBusinessException(repViewObj);
      }
      EList<ModelElement> analysedElements=analysis.getContext().getAnalysedElements();
      RepositoryNode connectionRepositoryNode=null;
      if (!analysedElements.isEmpty()) {
        Connection connection=null;
        ModelElement modelElement=analysedElements.get(0);
        if (modelElement instanceof Connection) {
          connection=(Connection)modelElement;
        }
 else         if (modelElement instanceof Catalog) {
          Catalog catalog=SwitchHelpers.CATALOG_SWITCH.caseCatalog((Catalog)modelElement);
          connection=ConnectionHelper.getConnection(catalog);
        }
 else         if (modelElement instanceof Schema) {
          Schema schema=SwitchHelpers.SCHEMA_SWITCH.caseSchema((Schema)modelElement);
          if (schema != null) {
            connection=ConnectionHelper.getConnection(schema);
          }
        }
 else         if (modelElement instanceof TdTable) {
          TdTable tdTable=SwitchHelpers.TABLE_SWITCH.caseTdTable((TdTable)modelElement);
          connection=ConnectionHelper.getConnection(tdTable);
        }
 else         if (modelElement instanceof TdView) {
          TdView tdView=SwitchHelpers.VIEW_SWITCH.caseTdView((TdView)modelElement);
          connection=ConnectionHelper.getConnection(tdView);
        }
 else         if (modelElement instanceof TdColumn) {
          TdColumn tdColumn=SwitchHelpers.COLUMN_SWITCH.caseTdColumn((TdColumn)modelElement);
          connection=ConnectionHelper.getConnection(tdColumn);
        }
 else         if (modelElement instanceof MetadataColumn) {
          MetadataColumn mColumn=SwitchHelpers.METADATA_COLUMN_SWITCH.doSwitch(modelElement);
          connection=ConnectionHelper.getTdDataProvider(mColumn);
        }
        connectionRepositoryNode=RepositoryNodeHelper.recursiveFind(connection);
      }
      ((AnalysisItemEditorInput)result).setConnectionNode(connectionRepositoryNode);
      if (analysis.getParameters() != null && analysis.getParameters().getAnalysisType().equals(AnalysisType.MATCH_ANALYSIS)) {
        editorID=MatchAnalysisEditor.class.getName();
      }
 else {
        editorID=AnalysisEditor.class.getName();
      }
    }
 else     if (ERepositoryObjectType.TDQ_INDICATOR_ELEMENT.getKey().equals(key)) {
      result=new IndicatorDefinitionItemEditorInput(repNode);
      TDQIndicatorDefinitionItem definitionItem=(TDQIndicatorDefinitionItem)item;
      if (definitionItem.getIndicatorDefinition().eResource() == null) {
        throw ExceptionFactory.getInstance().createBusinessException(definitionItem.getFilename());
      }
      if (UDIHelper.getUDICategory(definitionItem.getIndicatorDefinition()) == null) {
        throw ExceptionFactory.getInstance().createBusinessException(definitionItem.getFilename());
      }
      editorID=IndicatorEditor.class.getName();
    }
 else     if (ERepositoryObjectType.TDQ_RULES_SQL.getKey().equals(key) || ERepositoryObjectType.TDQ_RULES_PARSER.getKey().equals(key) || ERepositoryObjectType.TDQ_RULES_MATCHER.getKey().equals(key)) {
      result=new BusinessRuleItemEditorInput(repNode);
      editorID=DQRuleEditor.class.getName();
    }
 else     if (ERepositoryObjectType.TDQ_PATTERN_ELEMENT.getKey().equals(key)) {
      result=new PatternItemEditorInput(repNode);
      TDQPatternItem patternItem=(TDQPatternItem)item;
      if (patternItem.getPattern() == null || patternItem.getPattern().eResource() == null) {
        throw ExceptionFactory.getInstance().createBusinessException(patternItem.getFilename());
      }
      editorID=PatternEditor.class.getName();
    }
 else     if (ERepositoryObjectType.TDQ_REPORT_ELEMENT.getKey().equals(key)) {
      result=new ReportItemEditorInput(repNode);
      TDQReportItem reportItem=(TDQReportItem)item;
      if (!(reportItem.getReport() instanceof TdReport)) {
        throw ExceptionFactory.getInstance().createBusinessException(reportItem.getFilename());
      }
      for (      AnalysisMap anaMap : ((TdReport)reportItem.getReport()).getAnalysisMap()) {
        Analysis analysis=anaMap.getAnalysis();
        if (analysis.eResource() == null) {
          throw ExceptionFactory.getInstance().createBusinessException(reportItem.getFilename());
        }
      }
      editorID="String_Node_Str";
    }
 else     if (ERepositoryObjectType.TDQ_SOURCE_FILE_ELEMENT.getKey().equals(key) || ERepositoryObjectType.TDQ_JRAXML_ELEMENT.getKey().equals(key)) {
      IPath append=WorkbenchUtils.getFilePath(repViewObj.getRepositoryNode());
      DQRepositoryNode node=(DQRepositoryNode)repViewObj.getRepositoryNode();
      file=ResourceManager.getRoot().getProject(node.getProject().getTechnicalLabel()).getFile(append);
      if (!file.exists()) {
        throw ExceptionFactory.getInstance().createBusinessException(repViewObj);
      }
      if (ERepositoryObjectType.TDQ_SOURCE_FILE_ELEMENT.getKey().equals(key)) {
        editorID=SqlExplorerUtils.SQLEDITOR_ID;
      }
 else {
        editorID=TDQFileEditorInput.DEFAULT_EDITOR_ID;
      }
      result=new TDQFileEditorInput(file);
      ((TDQFileEditorInput)result).setFileItem(item);
      CorePlugin.getDefault().refreshDQView(repNode);
    }
    if (!isOpenItemEditorAction) {
      if (ERepositoryObjectType.TDQ_JRAXML_ELEMENT.getKey().equals(key) || ERepositoryObjectType.TDQ_SOURCE_FILE_ELEMENT.getKey().equals(key)) {
        result=new FileEditorInput(file);
        editorID=FileEditorInput.class.getName();
      }
    }
  }
  return result;
}