Search in sources :

Example 1 with DBTableRepNode

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

the class AbstractCommonActionProviderRealProjectTest method testGetConnectionCase8.

/**
 * Test method for
 * {@link org.talend.dataprofiler.core.ui.action.provider.AbstractCommonActionProvider#getConnection(java.lang.Object)}
 * . case8 :input parameter is DBColumnFolderRepNode
 */
@Test
public void testGetConnectionCase8() {
    // create FileConnection
    // connection
    IRepositoryViewObject lastVersion = null;
    String propertyID = createConnectionItem(connectionName, null, null);
    TdTable createTdTable = RelationalFactoryImpl.eINSTANCE.createTdTable();
    RepositoryNode dbCatalogRepNode = null;
    // $NON-NLS-1$
    createTdTable.setName("table1");
    try {
        lastVersion = factory.getLastVersion(propertyID);
        dbCatalogRepNode = DQRepNodeCreateFactory.createDBCatalogRepNode(lastVersion, null, ENodeType.TDQ_REPOSITORY_ELEMENT, null);
        lastVersion = new TdTableRepositoryObject(lastVersion, createTdTable);
    } catch (PersistenceException e) {
        log.error(e, e);
        Assert.fail(e.getMessage());
    }
    // ~connection data
    // ~FileConnection
    // create DFColumnFolderRepNode
    Assert.assertFalse(lastVersion == null);
    DBTableRepNode dbTableRepNode = new DBTableRepNode(lastVersion, dbCatalogRepNode, ENodeType.TDQ_REPOSITORY_ELEMENT, null);
    DBColumnFolderRepNode dbColumnFolderRepNode = new DBColumnFolderRepNode(null, dbTableRepNode, null, null);
    // ~DFColumnFolderRepNode
    AbstractCommonActionProvider provider = new AbstractCommonActionProvider();
    Connection connection = provider.getConnection(dbColumnFolderRepNode);
    Assert.assertTrue(connection != null);
}
Also used : DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) TdTable(org.talend.cwm.relational.TdTable) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) TdTableRepositoryObject(org.talend.core.repository.model.repositoryObject.TdTableRepositoryObject) RepositoryNode(org.talend.repository.model.RepositoryNode) DBColumnFolderRepNode(org.talend.dq.nodes.DBColumnFolderRepNode) Test(org.junit.Test)

Example 2 with DBTableRepNode

use of org.talend.dq.nodes.DBTableRepNode 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 3 with DBTableRepNode

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

the class AnalysisColumnSetTreeViewer method setInput.

@Override
public void setInput(Object[] objs) {
    if (objs != null && objs.length != 0) {
        List<DBColumnRepNode> columnList = new ArrayList<DBColumnRepNode>();
        for (Object obj : objs) {
            // default is should be sql engine.
            if (obj instanceof DBTableRepNode || obj instanceof DBViewRepNode) {
                columnList.addAll((Collection<? extends DBColumnRepNode>) ((ColumnSetRepNode) obj).getAllColumns());
            } else if (obj instanceof DBColumnRepNode) {
                columnList.add((DBColumnRepNode) obj);
            }
        }
        // MOD yyi 2010-05-13 12828
        Collections.reverse(columnList);
        // MOD qiongli 2011-3-15 set DataFilterText disabled except TdColumn.
        if (masterPage.getDataFilterComp() != null) {
            masterPage.getDataFilterComp().getDataFilterText().setEnabled(!columnList.isEmpty());
            if (columnList.isEmpty()) {
                // when the selected column is not DB type,will disable the execute engine
                // combobox.
                masterPage.changeExecuteLanguageToJava(true);
            } else {
                // when the selected column is back to DB type, should enable the execute engine combobox again.
                masterPage.enableExecuteLanguage();
            }
        }
        ModelElementIndicator[] newSelects = translateSelectedNodeIntoIndicator(objs);
        List<ModelElementIndicator> indicatorList = new ArrayList<ModelElementIndicator>();
        if (newSelects != null) {
            // indicator;
            for (ModelElementIndicator column : newSelects) {
                // if the modelElementIndicators contains selected column, add the column in modelElementIndicators
                // to ColumnIndicatorList
                boolean isOld = false;
                for (ModelElementIndicator oldColumn : modelElementIndicators) {
                    if (oldColumn.getModelElementRepositoryNode().equals(column.getModelElementRepositoryNode())) {
                        indicatorList.add(oldColumn);
                        isOld = true;
                        break;
                    }
                }
                // else add this column in filterInputData to ColumnIndicatorList
                if (!isOld) {
                    indicatorList.add(column);
                }
            }
            this.modelElementIndicators = indicatorList.toArray(new ModelElementIndicator[indicatorList.size()]);
            this.setElements(modelElementIndicators);
        }
    } else {
        TreeItem[] items = this.tree.getItems();
        for (TreeItem item : items) {
            this.removeItemBranch(item);
        }
        super.setInput(objs);
    }
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) ArrayList(java.util.ArrayList) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) ColumnSetRepNode(org.talend.dq.nodes.ColumnSetRepNode) EObject(org.eclipse.emf.ecore.EObject) DBViewRepNode(org.talend.dq.nodes.DBViewRepNode) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Example 4 with DBTableRepNode

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

the class TablesSelectionDialog method addCheckedListener.

@Override
protected void addCheckedListener() {
    // When user checks a checkbox in the tree, check all its children
    getTreeViewer().addCheckStateListener(new ICheckStateListener() {

        public void checkStateChanged(CheckStateChangedEvent event) {
            TreePath treePath = new TreePath(new Object[] { event.getElement() });
            getTreeViewer().setSelection(new TreeSelection(treePath));
            if (event.getChecked()) {
                Object element = event.getElement();
                getTreeViewer().setSubtreeChecked(element, true);
                if (element instanceof IRepositoryNode) {
                    setOutput(element);
                    handleTablesChecked((IRepositoryNode) element, true);
                }
            } else {
                Object element = event.getElement();
                getTreeViewer().setSubtreeChecked(element, false);
                if (element instanceof IRepositoryNode) {
                    setOutput(element);
                    handleTablesChecked((IRepositoryNode) element, false);
                }
            }
            updateOKStatus();
        }
    });
    getTableViewer().addCheckStateListener(new ICheckStateListener() {

        public void checkStateChanged(CheckStateChangedEvent event) {
            Object element = event.getElement();
            if (element instanceof DBTableRepNode || element instanceof DBViewRepNode) {
                handleTableChecked((IRepositoryNode) element, event.getChecked());
            }
        }
    });
}
Also used : DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) TreePath(org.eclipse.jface.viewers.TreePath) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) TreeSelection(org.eclipse.jface.viewers.TreeSelection) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) DBViewRepNode(org.talend.dq.nodes.DBViewRepNode)

Example 5 with DBTableRepNode

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

the class ColumnViewerDND method installDND.

/**
 * DOC qzhang Comment method "installDND".
 */
public static void installDND(final Tree targetControl) {
    IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    DQRespositoryView findView = (DQRespositoryView) activePage.findView(DQRespositoryView.ID);
    final CommonViewer commonViewer = findView.getCommonViewer();
    final LocalSelectionTransfer transfer = LocalSelectionTransfer.getTransfer();
    int operations = DND.DROP_COPY | DND.DROP_MOVE;
    Transfer[] transfers = new Transfer[] { transfer };
    DropTarget dropTarget = new DropTarget(targetControl, operations);
    dropTarget.setTransfer(transfers);
    DropTargetListener dndListener = new TreeDropTargetEffect(targetControl) {

        ISelectionReceiver receiver = null;

        /*
             * (non-Javadoc)
             * 
             * @see org.eclipse.swt.dnd.DropTargetAdapter#dragEnter(org.eclipse.swt .dnd.DropTargetEvent)
             */
        @Override
        public void dragEnter(DropTargetEvent event) {
            super.dragEnter(event);
            IStructuredSelection selection = (IStructuredSelection) LocalSelectionTransfer.getTransfer().getSelection();
            Object object = selection.getFirstElement();
            // if (object instanceof IFile) {
            if (object instanceof SysIndicatorDefinitionRepNode) {
                receiver = new UDIReceiver();
            } else if (object instanceof PatternRepNode) {
                receiver = new PatternReceiver();
            }
            // MOD klliu 15750 2011-01-17 for Drag&Drop On columnset
            if (object instanceof DBColumnRepNode || object instanceof DBTableRepNode || object instanceof DFColumnRepNode) {
                receiver = new ColumnReceiver();
            }
            if (receiver == null) {
                event.detail = DND.DROP_NONE;
            } else {
                event.feedback = DND.FEEDBACK_EXPAND;
                receiver.doDropValidation(event, commonViewer);
            }
        }

        /*
             * (non-Javadoc)
             * 
             * @see org.eclipse.swt.dnd.TreeDropTargetEffect#dragOver(org.eclipse .swt.dnd.DropTargetEvent)
             */
        @Override
        public void dragOver(DropTargetEvent event) {
            super.dragOver(event);
            // MOD yyi 2009-09-18 bug: 9044
            if (null != receiver) {
                receiver.doDropValidation(event, commonViewer);
            }
        }

        /*
             * (non-Javadoc)
             * 
             * @see org.eclipse.swt.dnd.DropTargetAdapter#drop(org.eclipse.swt.dnd .DropTargetEvent)
             */
        @Override
        public void drop(DropTargetEvent event) {
            int index = targetControl.getItemCount();
            super.drop(event);
            if (event.item == null) {
                // TreeItem item = new TreeItem(targetControl, SWT.NONE);
                // item.setText(texts);
                // item.setText(text);
                index = 0;
            } else {
                TreeItem item = (TreeItem) event.item;
                TreeItem[] items = targetControl.getItems();
                for (int i = 0; i < items.length; i++) {
                    if (items[i] == item) {
                        index = i;
                        break;
                    }
                }
            }
            receiver.drop(event, commonViewer, index);
        }
    };
    dropTarget.addDropListener(dndListener);
}
Also used : CommonViewer(org.eclipse.ui.navigator.CommonViewer) TreeItem(org.eclipse.swt.widgets.TreeItem) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) TreeDropTargetEffect(org.eclipse.swt.dnd.TreeDropTargetEffect) DFColumnRepNode(org.talend.dq.nodes.DFColumnRepNode) DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) DropTargetListener(org.eclipse.swt.dnd.DropTargetListener) LocalSelectionTransfer(org.eclipse.jface.util.LocalSelectionTransfer) Transfer(org.eclipse.swt.dnd.Transfer) SysIndicatorDefinitionRepNode(org.talend.dq.nodes.SysIndicatorDefinitionRepNode) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) DropTarget(org.eclipse.swt.dnd.DropTarget) LocalSelectionTransfer(org.eclipse.jface.util.LocalSelectionTransfer) PatternRepNode(org.talend.dq.nodes.PatternRepNode)

Aggregations

DBTableRepNode (org.talend.dq.nodes.DBTableRepNode)31 DBViewRepNode (org.talend.dq.nodes.DBViewRepNode)21 IRepositoryNode (org.talend.repository.model.IRepositoryNode)18 ArrayList (java.util.ArrayList)13 RepositoryNode (org.talend.repository.model.RepositoryNode)12 DFTableRepNode (org.talend.dq.nodes.DFTableRepNode)11 DBColumnRepNode (org.talend.dq.nodes.DBColumnRepNode)9 TreeSelection (org.eclipse.jface.viewers.TreeSelection)8 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)7 TdTable (org.talend.cwm.relational.TdTable)6 DBCatalogRepNode (org.talend.dq.nodes.DBCatalogRepNode)6 DBConnectionRepNode (org.talend.dq.nodes.DBConnectionRepNode)6 DBSchemaRepNode (org.talend.dq.nodes.DBSchemaRepNode)6 DFColumnRepNode (org.talend.dq.nodes.DFColumnRepNode)6 List (java.util.List)5 Test (org.junit.Test)5 PatternRepNode (org.talend.dq.nodes.PatternRepNode)5 SysIndicatorDefinitionRepNode (org.talend.dq.nodes.SysIndicatorDefinitionRepNode)5 TreeItem (org.eclipse.swt.widgets.TreeItem)4 DBColumnFolderRepNode (org.talend.dq.nodes.DBColumnFolderRepNode)4