Esempio n. 1
0
  public DataSet getDataSet() throws Exception {

    INode node = getNode();

    if (node == null) {
      return null;
    }
    if (node.getSession() == null) {
      return null;
    }

    if (node instanceof TableNode) {
      TableNode tableNode = (TableNode) node;
      ITableInfo ti = tableNode.getTableInfo();
      if (tableNode.getTableInfo() == null) {
        return null;
      }
      ResultSet resultSet = null;
      SessionTreeNode treeNode = node.getSession();

      // For synonym table, should get the corresponding table.
      if (ti.getType().equals("SYNONYM")) { // $NON-NLS-1$

        String realTableName =
            ExtractMetaDataFromDataBase.getTableNameBySynonym(
                treeNode.getInteractiveConnection().getConnection(), ti.getSimpleName());

        resultSet =
            treeNode
                .getMetaData()
                .getJDBCMetaData()
                .getColumns(
                    ti.getCatalogName(), ti.getSchemaName(), realTableName, "%"); // $NON-NLS-1$

      } else {
        // https://jira.talendforge.org/browse/TDI-28578
        String tableName = ti.getSimpleName();

        if (tableName.contains("/")) {
          tableName = tableName.replaceAll("/", "//");
        }
        resultSet =
            node.getSession()
                .getMetaData()
                .getJDBCMetaData()
                .getColumns(ti.getCatalogName(), ti.getSchemaName(), tableName, "%");
        // resultSet = node.getSession().getMetaData().getColumns(tableNode.getTableInfo());
      }

      DataSet dataSet =
          new DataSet(
              null, resultSet, new int[] {4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18});
      resultSet.close();
      return dataSet;
    }

    return null;
  }