Search in sources :

Example 6 with RepositoryNodeExt

use of org.talend.sqlbuilder.RepositoryNodeExt in project tdi-studio-se by Talend.

the class DBTreeProvider method addNode.

private void addNode(RepositoryNode parent, IRepositoryViewObject repositoryObject, boolean isBuildIn, Integer index) {
    ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    DatabaseConnection connection = (DatabaseConnection) ((ConnectionItem) repositoryObject.getProperty().getItem()).getConnection();
    String sid = connection.getSID();
    MetadataConnectionRepositoryObject connectionRepositoryObject = new MetadataConnectionRepositoryObject(repositoryObject);
    if (isBuildIn) {
        connectionRepositoryObject.setRepositoryName(BUILT_IN);
    } else {
        connectionRepositoryObject.setRepositoryName(repositoryObject.getLabel());
    }
    //$NON-NLS-1$
    connectionRepositoryObject.setSourceName((sid == null || sid.trim().equals("")) ? connection.getDatasourceName() : sid);
    if (!isBuildIn) {
        connectionRepositoryObject.setImage(IMAGES_CONNECTION_ICON);
    } else {
        connectionRepositoryObject.setImage(IMAGES_DATABASE_ICON);
    }
    connectionRepositoryObject.setBuildIn(isBuildIn);
    RepositoryNode node = new RepositoryNodeExt(connectionRepositoryObject, parent, ENodeType.REPOSITORY_ELEMENT);
    node.setProperties(EProperties.CONTENT_TYPE, RepositoryNodeType.DATABASE);
    node.setProperties(EProperties.LABEL, repositoryObject.getLabel());
    boolean[] isDiffs = repositoryNodeManager.isDiff(node);
    if (isDiffs[0]) {
        connectionRepositoryObject.setDiffImage(IMAGES_GRAY_ICON);
    }
    if (isDiffs[1]) {
        connectionRepositoryObject.setDiffImage(IMAGES_RED_ICON);
    }
    if (isDiffs[2]) {
        connectionRepositoryObject.setDiffImage(IMAGES_REFRESH_ICON);
    }
    if (factory.getStatus(repositoryObject) == ERepositoryStatus.DELETED) {
    // ignore recycle node
    } else {
        if (index == null) {
            parent.getChildren().add(node);
        } else {
            parent.getChildren().add(index.intValue(), node);
        }
        repositoryNodeManager.addRepositoryNode(node);
        DatabaseConnection metadataConnection = (DatabaseConnection) ((ConnectionItem) repositoryObject.getProperty().getItem()).getConnection();
        createTables(node, repositoryObject, metadataConnection, isBuildIn);
        createQueries(node, repositoryObject, metadataConnection, isBuildIn);
    }
}
Also used : ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) RepositoryNode(org.talend.repository.model.RepositoryNode) RepositoryNodeExt(org.talend.sqlbuilder.RepositoryNodeExt)

Aggregations

RepositoryNode (org.talend.repository.model.RepositoryNode)6 RepositoryNodeExt (org.talend.sqlbuilder.RepositoryNodeExt)6 Iterator (java.util.Iterator)1 Container (org.talend.commons.utils.data.container.Container)1 RootContainer (org.talend.commons.utils.data.container.RootContainer)1 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)1 QueriesConnection (org.talend.core.model.metadata.builder.connection.QueriesConnection)1 Query (org.talend.core.model.metadata.builder.connection.Query)1 MetadataTableImpl (org.talend.core.model.metadata.builder.connection.impl.MetadataTableImpl)1 Folder (org.talend.core.model.repository.Folder)1 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)1 RepositoryObject (org.talend.core.model.repository.RepositoryObject)1 RepositoryViewObject (org.talend.core.model.repository.RepositoryViewObject)1 ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)1