Search in sources :

Example 1 with SessionTreeModel

use of org.talend.sqlbuilder.sessiontree.model.SessionTreeModel 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;
}
Also used : SQLConnection(net.sourceforge.squirrel_sql.fw.sql.SQLConnection) SessionTreeNode(org.talend.sqlbuilder.sessiontree.model.SessionTreeNode) IMetadataConnection(org.talend.core.model.metadata.IMetadataConnection) ArrayList(java.util.ArrayList) List(java.util.List) DriverShim(org.talend.core.model.metadata.builder.database.DriverShim) SessionTreeModel(org.talend.sqlbuilder.sessiontree.model.SessionTreeModel) ISQLAlias(net.sourceforge.squirrel_sql.fw.sql.ISQLAlias)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 ISQLAlias (net.sourceforge.squirrel_sql.fw.sql.ISQLAlias)1 SQLConnection (net.sourceforge.squirrel_sql.fw.sql.SQLConnection)1 IMetadataConnection (org.talend.core.model.metadata.IMetadataConnection)1 DriverShim (org.talend.core.model.metadata.builder.database.DriverShim)1 SessionTreeModel (org.talend.sqlbuilder.sessiontree.model.SessionTreeModel)1 SessionTreeNode (org.talend.sqlbuilder.sessiontree.model.SessionTreeNode)1