Search in sources :

Example 1 with DBConnectionRepNode

use of org.talend.dq.nodes.DBConnectionRepNode in project tdq-studio-se by Talend.

the class DBConnectionDuplicateHandleTest method createConnectionNode.

/**
 * DOC zshen Comment method "createConnectionNode".
 *
 * @return
 */
private RepositoryNode createConnectionNode(DatabaseConnectionItem createConnectionItem) {
    IRepositoryViewObject connectionViewObject = null;
    try {
        connectionViewObject = factory.getLastVersion(createConnectionItem.getProperty().getId());
    } catch (PersistenceException e) {
        Assert.fail(e.getMessage());
    }
    RepositoryNode dbParentRepNode = new DBConnectionRepNode(connectionViewObject, null, ENodeType.REPOSITORY_ELEMENT, null);
    return dbParentRepNode;
}
Also used : DBConnectionRepNode(org.talend.dq.nodes.DBConnectionRepNode) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) RepositoryNode(org.talend.repository.model.RepositoryNode)

Example 2 with DBConnectionRepNode

use of org.talend.dq.nodes.DBConnectionRepNode in project tdq-studio-se by Talend.

the class RepNodeUtilsTest method testIsValidSelectionForMatchAnalysis.

/**
 * Test: 1) when the selected node is: connection, catalog,schema, folder, will not be valid; 2) when the selected
 * nodes are: multiple table/views, multiple columns from different table/view, will not be valid; 3) when the
 * selected node is: one single table/view/file table,will be valid; 4) when the selected nodes are: multiple
 * columns from one same table/view, will be valid.
 */
@Test
public void testIsValidSelectionForMatchAnalysis() {
    // 1) when the selected node is: connection, catalog,schema, folder, will not be valid;
    List<IRepositoryNode> nodes = new ArrayList<IRepositoryNode>();
    ConnectionRepNode cNode = mock(ConnectionRepNode.class);
    nodes.add(cNode);
    Assert.assertFalse(RepNodeUtils.isValidSelectionFromSameTable(nodes));
    DBConnectionRepNode dbNode = mock(DBConnectionRepNode.class);
    nodes.clear();
    nodes.add(dbNode);
    Assert.assertFalse(RepNodeUtils.isValidSelectionFromSameTable(nodes));
    DBConnectionFolderRepNode dbfNode = mock(DBConnectionFolderRepNode.class);
    nodes.clear();
    nodes.add(dbfNode);
    Assert.assertFalse(RepNodeUtils.isValidSelectionFromSameTable(nodes));
    DQDBFolderRepositoryNode folderNode = mock(DQDBFolderRepositoryNode.class);
    nodes.clear();
    nodes.add(folderNode);
    Assert.assertFalse(RepNodeUtils.isValidSelectionFromSameTable(nodes));
    DBCatalogRepNode catalogNode = mock(DBCatalogRepNode.class);
    nodes.clear();
    nodes.add(catalogNode);
    Assert.assertFalse(RepNodeUtils.isValidSelectionFromSameTable(nodes));
    DBSchemaRepNode schemaNode = mock(DBSchemaRepNode.class);
    nodes.clear();
    nodes.add(schemaNode);
    Assert.assertFalse(RepNodeUtils.isValidSelectionFromSameTable(nodes));
}
Also used : DBConnectionRepNode(org.talend.dq.nodes.DBConnectionRepNode) ConnectionRepNode(org.talend.dq.nodes.ConnectionRepNode) DBConnectionRepNode(org.talend.dq.nodes.DBConnectionRepNode) DBSchemaRepNode(org.talend.dq.nodes.DBSchemaRepNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) DBCatalogRepNode(org.talend.dq.nodes.DBCatalogRepNode) ArrayList(java.util.ArrayList) DQDBFolderRepositoryNode(org.talend.dq.nodes.DQDBFolderRepositoryNode) DBConnectionFolderRepNode(org.talend.dq.nodes.DBConnectionFolderRepNode) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 3 with DBConnectionRepNode

use of org.talend.dq.nodes.DBConnectionRepNode in project tdq-studio-se by Talend.

the class SelectedCompareUIProvider method fillContextMenu.

@Override
public void fillContextMenu(IMenuManager menu) {
    // TDQ-9394 hide all "Reload" menu.
    if (!isShowMenu()) {
        return;
    }
    if (isShowMenu()) {
        return;
    }
    Iterator<?> iter = ((TreeSelection) this.getContext().getSelection()).iterator();
    while (iter.hasNext()) {
        Object obj = iter.next();
        if (!(obj instanceof RepositoryNode)) {
            return;
        }
    }
    TreeSelection treeSelection = (TreeSelection) getContext().getSelection();
    if (treeSelection == null) {
        return;
    }
    Object firstElement = treeSelection.getFirstElement();
    RepositoryNode rNode = (RepositoryNode) firstElement;
    IFolder folder = WorkbenchUtils.getFolder(rNode);
    IFolder metadataFolder = ResourceManager.getMetadataFolder();
    if (!folder.getFullPath().toOSString().startsWith(metadataFolder.getFullPath().toOSString())) {
        return;
    }
    Object[] selectedObj = treeSelection.toArray();
    if (selectedObj.length < 2) {
        return;
    }
    List<Object> objects = new ArrayList<Object>();
    for (Object obj : selectedObj) {
        Connection conn = getConnection(obj);
        if (!MetadataConnectionUtils.isTDQSupportDBTemplate(conn)) {
            return;
        }
        RepositoryNode node = (RepositoryNode) obj;
        if (node instanceof DBConnectionRepNode) {
            Property property = ((DBConnectionRepNode) node).getObject().getProperty();
            DatabaseConnectionItem databaseConnectionItem = (DatabaseConnectionItem) property.getItem();
            Connection databaseConnection = databaseConnectionItem.getConnection();
            objects.add(databaseConnection);
        } else if (node instanceof DBCatalogRepNode) {
            Catalog catalog = ((DBCatalogRepNode) node).getCatalog();
            objects.add(catalog);
        } else if (node instanceof DBSchemaRepNode) {
            Schema schema = ((DBSchemaRepNode) node).getSchema();
            objects.add(schema);
        } else if (node instanceof DBTableRepNode) {
            TdTable tdTable = ((DBTableRepNode) node).getTdTable();
            objects.add(tdTable);
        } else if (node instanceof DBColumnRepNode) {
            TdColumn tdColumn = ((DBColumnRepNode) node).getTdColumn();
            objects.add(tdColumn);
        }
    }
    // MOD yyi 2011-03-22 17871:hide compare action for flat file column
    if (2 == objects.size()) {
        selectionCompareAction.refreshSelectedObj(objects.get(0), objects.get(1));
        menu.add(selectionCompareAction);
    }
}
Also used : DBConnectionRepNode(org.talend.dq.nodes.DBConnectionRepNode) DBSchemaRepNode(org.talend.dq.nodes.DBSchemaRepNode) TdTable(org.talend.cwm.relational.TdTable) Schema(orgomg.cwm.resource.relational.Schema) ArrayList(java.util.ArrayList) Connection(org.talend.core.model.metadata.builder.connection.Connection) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) RepositoryNode(org.talend.repository.model.RepositoryNode) Catalog(orgomg.cwm.resource.relational.Catalog) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) TdColumn(org.talend.cwm.relational.TdColumn) DBCatalogRepNode(org.talend.dq.nodes.DBCatalogRepNode) TreeSelection(org.eclipse.jface.viewers.TreeSelection) Property(org.talend.core.model.properties.Property) IFolder(org.eclipse.core.resources.IFolder)

Example 4 with DBConnectionRepNode

use of org.talend.dq.nodes.DBConnectionRepNode in project tdq-studio-se by Talend.

the class ConnectionEditor method doSave.

@Override
public void doSave(IProgressMonitor monitor) {
    if (masterPage.isDirty()) {
        masterPage.doSave(monitor);
        setPartName(masterPage.getIntactElemenetName());
        // MOD qiongli 2012-11-29 avoid item is proxy(get item form IRepositoryViewObject).
        ConnectionRepNode connectionRepNode = ((ConnectionInfoPage) getMasterPage()).getCurrentRepNode();
        if (connectionRepNode != null && connectionRepNode instanceof DBConnectionRepNode) {
            IRepositoryViewObject object = connectionRepNode.getObject();
            if (object != null) {
                ConnectionItem item = (ConnectionItem) object.getProperty().getItem();
                String name = ((DatabaseConnectionItem) item).getConnection().getName();
                CWMPlugin.getDefault().updateConnetionAliasByName(item.getConnection(), masterPage.getOldDataproviderName());
                masterPage.setOldDataproviderName(name);
            }
        }
        // refresh the analysis editor
        if (masterPage.isNameTextUpdate()) {
            WorkbenchUtils.nodifyDependedAnalysis((ConnectionItem) connectionRepNode.getObject().getProperty().getItem());
            // WorkbenchUtils.refreshCurrentAnalysisEditor();
            masterPage.setModify(false);
            // TDQ-11312
            if (this.getEditorInput() instanceof FileEditorInput) {
                this.setInput(masterPage.getEditorInput());
            }
        }
    }
    setEditorObject(((ConnectionInfoPage) getMasterPage()).getCurrentRepNode());
    super.doSave(monitor);
}
Also used : DBConnectionRepNode(org.talend.dq.nodes.DBConnectionRepNode) ConnectionRepNode(org.talend.dq.nodes.ConnectionRepNode) DBConnectionRepNode(org.talend.dq.nodes.DBConnectionRepNode) ConnectionItem(org.talend.core.model.properties.ConnectionItem) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) FileEditorInput(org.eclipse.ui.part.FileEditorInput) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject)

Example 5 with DBConnectionRepNode

use of org.talend.dq.nodes.DBConnectionRepNode in project tdq-studio-se by Talend.

the class ConnectionInfoPage method changeConnectionInformations.

/**
 * Change connection informations with server, port etc., and update related analyses.
 *
 * MOD yyi 9082 2010-02-25
 */
protected void changeConnectionInformations() {
    DBConnectionRepNode node = getCurrentRepNode();
    if (node != null) {
        IWizard wizard = new DatabaseWizard(PlatformUI.getWorkbench(), false, node, null);
        WizardDialog dialog = new WizardDialog(null, wizard);
        dialog.setPageSize(780, 550);
        wizard.setContainer(dialog);
        dialog.open();
    }
}
Also used : DBConnectionRepNode(org.talend.dq.nodes.DBConnectionRepNode) DatabaseWizard(org.talend.repository.ui.wizards.metadata.connection.database.DatabaseWizard) IWizard(org.eclipse.jface.wizard.IWizard) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Aggregations

DBConnectionRepNode (org.talend.dq.nodes.DBConnectionRepNode)26 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)14 IRepositoryNode (org.talend.repository.model.IRepositoryNode)12 DBCatalogRepNode (org.talend.dq.nodes.DBCatalogRepNode)9 Connection (org.talend.core.model.metadata.builder.connection.Connection)8 DBSchemaRepNode (org.talend.dq.nodes.DBSchemaRepNode)8 RepositoryNode (org.talend.repository.model.RepositoryNode)8 ArrayList (java.util.ArrayList)6 DBTableRepNode (org.talend.dq.nodes.DBTableRepNode)6 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)4 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)4 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)4 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)4 PersistenceException (org.talend.commons.exception.PersistenceException)4 DBColumnRepNode (org.talend.dq.nodes.DBColumnRepNode)4 DBConnectionFolderRepNode (org.talend.dq.nodes.DBConnectionFolderRepNode)4 DFConnectionRepNode (org.talend.dq.nodes.DFConnectionRepNode)4 List (java.util.List)3 Test (org.junit.Test)3 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)3