/** * returns display column name from the actual column name. * * @param aliasName String * @param columnName String * @return String * @throws DAOException */ private String getColumnDisplayName( String childTableAliasName, String columnName, String parentTableAliasName) throws DAOException { String displayColumnName = null; try { JDBCDAO jdbcDao = (JDBCDAO) DAOFactory.getInstance().getDAO(Constants.JDBC_DAO); jdbcDao.openSession(null); Logger.out.debug("Alias Name : ............." + childTableAliasName); String sql = "SELECT sc.display_name, tab.alias_name FROM " + "catissue_search_display_data sc, catissue_table_relation tr, " + "catissue_interface_column_data col, catissue_query_table_data tab, catissue_query_table_data maintab " + "WHERE tr.relationship_id = sc.relationship_id AND " + "col.identifier = sc.col_id AND col.table_id = tab.table_id AND " + "maintab.table_id = tr.parent_table_id " + "AND maintab.alias_name = '" + parentTableAliasName + "' AND tab.alias_name='" + childTableAliasName + "' AND col.COLUMN_NAME='" + columnName + "'"; Logger.out.debug("DATA ELEMENT SQL : " + sql); List list = jdbcDao.executeQuery(sql, null, false, null); String nameSql = "select DISPLAY_NAME from CATISSUE_QUERY_TABLE_DATA where ALIAS_NAME='" + parentTableAliasName + "'"; List nameList = jdbcDao.executeQuery(nameSql, null, false, null); String tableDisplayName = new String(); if (!nameList.isEmpty()) { List rowNameList = (List) nameList.get(0); tableDisplayName = (String) rowNameList.get(0); } Logger.out.debug("tableDisplayName in getviewelements:" + tableDisplayName); Logger.out.debug("list.size()************************" + list.size()); Iterator iterator = list.iterator(); int i = 0; while (iterator.hasNext()) { List rowList = (List) iterator.next(); displayColumnName = (String) rowList.get(0) + " : " + tableDisplayName; } jdbcDao.closeSession(); } catch (ClassNotFoundException classExp) { throw new DAOException(classExp.getMessage(), classExp); } return displayColumnName; }
/** * To get the aliasName corresponding to the tableName. * * @param tableName The name of the table. * @return The aliasName corresponding to the tableName. * @throws DAOException * @throws ClassNotFoundException */ public String getAliasName(String tableName) throws DAOException, ClassNotFoundException { String aliasName = new String(); JDBCDAO jdbcDAO = (JDBCDAO) DAOFactory.getInstance().getDAO(Constants.JDBC_DAO); jdbcDAO.openSession(null); String sql = "select ALIAS_NAME from CATISSUE_QUERY_TABLE_DATA where TABLE_NAME='" + tableName + "'"; List list = jdbcDAO.executeQuery(sql, null, false, null); jdbcDAO.closeSession(); if (!list.isEmpty()) { List rowList = (List) list.get(0); aliasName = (String) rowList.get(0); } return aliasName; }
/** * Returns the Vector of DataElement objects for the select clause of the query. And also list the * column names in the columnList list. * * @param aliasNameList The Set of the alias names for which the DataElements are to be created. * @param columnList List of column names to be shown in the spreadsheet view. * @param OnlyDefaultAttribute true if the required column should be Default view columns. * @return the Vector of DataElement objects for the select clause of the query. * @throws DAOException */ public Vector getViewElements(List aliasNameList, List columnList, boolean OnlyDefaultAttribute) throws DAOException { Vector vector = new Vector(); try { JDBCDAO jdbcDao = (JDBCDAO) DAOFactory.getInstance().getDAO(Constants.JDBC_DAO); jdbcDao.openSession(null); Iterator aliasNameIterator = aliasNameList.iterator(); while (aliasNameIterator.hasNext()) { String aliasName = (String) aliasNameIterator.next(); Logger.out.debug("Alias Name : ............." + aliasName); String sql = " SELECT tableData2.ALIAS_NAME, temp.COLUMN_NAME, temp.TABLES_IN_PATH, " + " temp.DISPLAY_NAME, temp.ATTRIBUTE_TYPE " + " from CATISSUE_QUERY_TABLE_DATA tableData2 join " + " ( SELECT columnData.COLUMN_NAME, columnData.TABLE_ID, displayData.DISPLAY_NAME, " + " relationData.TABLES_IN_PATH, columnData.ATTRIBUTE_TYPE " + " FROM CATISSUE_INTERFACE_COLUMN_DATA columnData, " + " CATISSUE_TABLE_RELATION relationData, " + " CATISSUE_QUERY_TABLE_DATA tableData, " + " CATISSUE_SEARCH_DISPLAY_DATA displayData " + " where relationData.CHILD_TABLE_ID = columnData.TABLE_ID and " + " relationData.PARENT_TABLE_ID = tableData.TABLE_ID and " + " relationData.RELATIONSHIP_ID = displayData.RELATIONSHIP_ID and "; String defaultViewCondition = " displayData.DEFAULT_VIEW_ATTRIBUTE = 1 and "; String sql1 = " columnData.IDENTIFIER = displayData.COL_ID and " + " tableData.ALIAS_NAME = '" + aliasName + "') temp " + " on temp.TABLE_ID = tableData2.TABLE_ID"; if (OnlyDefaultAttribute) sql = sql + defaultViewCondition + sql1; else sql = sql + sql1; Logger.out.debug("DATA ELEMENT SQL : " + sql); List list = jdbcDao.executeQuery(sql, null, false, null); String nameSql = "select DISPLAY_NAME from CATISSUE_QUERY_TABLE_DATA where ALIAS_NAME='" + aliasName + "'"; List nameList = jdbcDao.executeQuery(nameSql, null, false, null); String tableDisplayName = new String(); if (!nameList.isEmpty()) { List rowNameList = (List) nameList.get(0); tableDisplayName = (String) rowNameList.get(0); } Logger.out.debug("tableDisplayName in getviewelements:" + tableDisplayName); Logger.out.debug("list.size()************************" + list.size()); String[] columnNames = new String[list.size()]; Iterator iterator = list.iterator(); int i = 0; while (iterator.hasNext()) { List rowList = (List) iterator.next(); DataElement dataElement = new DataElement(); dataElement.setTableName((String) rowList.get(0)); String fieldName = (String) rowList.get(1); Logger.out.debug("fieldName*********************" + fieldName); dataElement.setField(fieldName + "." + (String) rowList.get(2)); dataElement.setFieldType((String) rowList.get(4)); vector.add(dataElement); columnList.add((String) rowList.get(3) + " : " + tableDisplayName); } } jdbcDao.closeSession(); } catch (ClassNotFoundException classExp) { throw new DAOException(classExp.getMessage(), classExp); } return vector; }