use of org.talend.sqlbuilder.sessiontree.model.SessionTreeNode in project tdi-studio-se by Talend.
the class ExportedKeysTab method getDataSet.
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().getExportedKeys(ti.getCatalogName(), ti.getSchemaName(), realTableName);
} else {
resultSet = node.getSession().getMetaData().getExportedKeys((tableNode.getTableInfo()));
}
DataSet dataSet = new DataSet(null, resultSet, new int[] { 4, 7, 8, 9, 10, 11, 12, 13, 14 });
resultSet.close();
return dataSet;
}
return null;
}
use of org.talend.sqlbuilder.sessiontree.model.SessionTreeNode in project tdi-studio-se by Talend.
the class SessionTreeNodeUtils method getSessionTreeNode.
public static SessionTreeNode getSessionTreeNode(DatabaseConnection dbconnection, RepositoryNode repositoryNode, String selectedContext) throws Exception {
// hyWang add for bug 0007014
IMetadataConnection iMetadataConnection = null;
iMetadataConnection = ConvertionHelper.convert(dbconnection, false, selectedContext);
String url = dbconnection.getURL();
if (url == null || url.equals("")) {
url = iMetadataConnection.getUrl();
}
// bug 17980
SQLConnection connection = null;
DriverShim wapperDriver = null;
List list = createSQLConnection(dbconnection, selectedContext, iMetadataConnection);
if (list != null && list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
if (list.get(i) instanceof SQLConnection) {
connection = (SQLConnection) list.get(i);
}
if (list.get(i) instanceof DriverShim) {
wapperDriver = (DriverShim) list.get(i);
}
}
}
ISQLAlias alias = createSQLAlias("Repository Name", url, dbconnection.getUsername(), //$NON-NLS-1$
dbconnection.getRawPassword(), // fix bug for 7014,added by hyWang
dbconnection.getSID() == null || dbconnection.getSID().length() == 0 ? (dbconnection.getDatasourceName() == null || //$NON-NLS-1$
dbconnection.getDatasourceName().length() == 0 ? //$NON-NLS-1$
"Database" : dbconnection.getDatasourceName()) : dbconnection.getSID());
SessionTreeModel stm = new SessionTreeModel();
SessionTreeNode session;
if (wapperDriver != null && (iMetadataConnection.getDriverClass().equals(EDatabase4DriverClassName.JAVADB_EMBEDED.getDriverClass()) || iMetadataConnection.getDbType().equals(EDatabaseTypeName.JAVADB_EMBEDED.getDisplayName()) || iMetadataConnection.getDbType().equals(EDatabaseTypeName.JAVADB_DERBYCLIENT.getDisplayName()) || iMetadataConnection.getDbType().equals(EDatabaseTypeName.JAVADB_JCCJDBC.getDisplayName()) || iMetadataConnection.getDbType().equals(EDatabaseTypeName.HSQLDB_IN_PROGRESS.getDisplayName()))) {
session = stm.createSessionTreeNode(new SQLConnection[] { connection, connection }, alias, null, dbconnection.getRawPassword(), repositoryNode, wapperDriver);
} else {
session = stm.createSessionTreeNode(new SQLConnection[] { connection, connection }, alias, null, dbconnection.getRawPassword(), repositoryNode);
}
return session;
}
use of org.talend.sqlbuilder.sessiontree.model.SessionTreeNode in project tdi-studio-se by Talend.
the class ColumnInfoTab method getDataSet.
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;
}
use of org.talend.sqlbuilder.sessiontree.model.SessionTreeNode in project tdi-studio-se by Talend.
the class IndexesTab method getDataSet.
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().getIndexInfo(ti.getCatalogName(), ti.getSchemaName(), realTableName, true, true);
} else {
resultSet = node.getSession().getMetaData().getIndexInfo((tableNode.getTableInfo()));
}
DataSet dataSet = new DataSet(null, resultSet, new int[] { 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 });
resultSet.close();
return dataSet;
}
return null;
}
use of org.talend.sqlbuilder.sessiontree.model.SessionTreeNode in project tdi-studio-se by Talend.
the class TableNode method isNodeSameToColumn.
/**
* Check if ColumnNode and Column are the same.
*
* @param node ColumnNode
* @param column MetadataColumnImpl
* @return isNodeSameToColumn
* @exception
*/
private boolean isNodeSameToColumn(ColumnNode node, MetadataColumnImpl column) {
SessionTreeNode sessionTreeNode = node.getSession();
TableColumnInfo[] tableColumnInfo = null;
try {
tableColumnInfo = sessionTreeNode.getMetaData().getColumnInfo(ptableInfo);
} catch (SQLException e) {
SqlBuilderPlugin.log(e.getMessage(), e);
return false;
}
// Retrive metadataColumns from Database
IMetadataConnection iMetadataConnection = ConvertionHelper.convert(connection);
List<TdColumn> metadataColumns = new ArrayList<TdColumn>();
metadataColumns = ExtractMetaDataFromDataBase.returnMetadataColumnsFormTable(iMetadataConnection, getLabelText());
Iterator iterate = metadataColumns.iterator();
while (iterate.hasNext()) {
MetadataColumn metadataColumn = (MetadataColumn) iterate.next();
for (TableColumnInfo info : tableColumnInfo) {
if (metadataColumn.getLabel().equals(node.getLabelText()) && info.getColumnName().equals(node.getLabelText())) {
boolean divergency = isEquivalent(metadataColumn, column);
metadataColumn.setDivergency(divergency);
return divergency;
}
}
}
return true;
}
Aggregations