Search in sources :

Example 11 with DBTableRepNode

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

the class ColumnsSelectionDialog method getAllCheckElements.

protected void getAllCheckElements() {
    // Added TDQ-8718 20140506 yyin: should not load from DB(connect) when get checked elements
    DQDBFolderRepositoryNode.setCallingFromColumnDialog(true);
    DQDBFolderRepositoryNode.setLoadDBFromDialog(false);
    try {
        Object[] checkedNodes = this.getTreeViewer().getCheckedElements();
        for (Object checkedNode : checkedNodes) {
            IRepositoryNode repNode = (IRepositoryNode) checkedNode;
            if (repNode instanceof DBColumnRepNode || repNode instanceof DFColumnRepNode) {
                if (!allCheckedElements.contains(repNode)) {
                    allCheckedElements.add(repNode);
                }
            } else if (repNode instanceof DFTableRepNode || repNode instanceof DBTableRepNode || repNode instanceof DBViewRepNode) {
                if (!getTableviewCheckedElements(allCheckedElements, repNode)) {
                    List<IRepositoryNode> children = repNode.getChildren().get(0).getChildren();
                    for (IRepositoryNode node : children) {
                        if (!allCheckedElements.contains(node)) {
                            allCheckedElements.add(node);
                        }
                    }
                }
            }
        }
    } finally {
        // Added TDQ-8718 20140506 yyin
        DQDBFolderRepositoryNode.setCallingFromColumnDialog(false);
        DQDBFolderRepositoryNode.setLoadDBFromDialog(true);
    }
    // ADD msjian 2011-7-8 feature 22206: Add filters
    Iterator<?> it = modelElementCheckedMap.keySet().iterator();
    while (it.hasNext()) {
        RepositoryNode reposNode = (RepositoryNode) it.next();
        List<?> columnList = (ArrayList<?>) modelElementCheckedMap.get(reposNode);
        for (int i = 0; i < columnList.size(); i++) {
            if (columnList.get(i) instanceof DBColumnRepNode || columnList.get(i) instanceof DFColumnRepNode) {
                if (!allCheckedElements.contains(columnList.get(i))) {
                    allCheckedElements.add((IRepositoryNode) columnList.get(i));
                }
            }
        }
    }
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) ArrayList(java.util.ArrayList) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) RepositoryNode(org.talend.repository.model.RepositoryNode) DQDBFolderRepositoryNode(org.talend.dq.nodes.DQDBFolderRepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) DFColumnRepNode(org.talend.dq.nodes.DFColumnRepNode) DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) DFTableRepNode(org.talend.dq.nodes.DFTableRepNode) ArrayList(java.util.ArrayList) List(java.util.List) DBViewRepNode(org.talend.dq.nodes.DBViewRepNode)

Example 12 with DBTableRepNode

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

the class SemanticDiscoveryActionProvider method fillContextMenu.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.ui.actions.ActionGroup#fillContextMenu(org.eclipse.jface.action.IMenuManager)
     */
@Override
public void fillContextMenu(IMenuManager menu) {
    // MOD mzhao user readonly role on svn repository mode.
    if (!isShowMenu()) {
        return;
    }
    TreeSelection currentSelection = ((TreeSelection) this.getContext().getSelection());
    Object firstElement = currentSelection.getFirstElement();
    boolean selectedMoreThanOne = currentSelection.size() > 1;
    // keep all of columns belong to same one table and create SemanticDiscoveryAction.
    if (selectedMoreThanOne || firstElement instanceof ColumnRepNode) {
        Set<String> currentTableSet = new HashSet<String>();
        MetadataTable createTable = ConnectionFactory.eINSTANCE.createMetadataTable();
        List<String> filterNames = new ArrayList<String>();
        Iterator<Object> columnIterator = currentSelection.iterator();
        while (columnIterator.hasNext()) {
            Object columnNode = columnIterator.next();
            MetadataColumn metadataColumn = null;
            if (DBColumnRepNode.class.isInstance(columnNode)) {
                metadataColumn = ((DBColumnRepNode) columnNode).getTdColumn();
                createTable = ColumnHelper.getColumnOwnerAsMetadataTable(metadataColumn);
            } else if (DFColumnRepNode.class.isInstance(columnNode)) {
                metadataColumn = ((DFColumnRepNode) columnNode).getMetadataColumn();
                createTable = ColumnHelper.getColumnOwnerAsMetadataTable(metadataColumn);
            } else {
                // If not all of elements which be selected is columns
                return;
            }
            currentTableSet.add(ResourceHelper.getUUID(createTable));
            // all of columns should come from same table
            if (currentTableSet.size() > 1) {
                return;
            }
            filterNames.add(metadataColumn.getName());
        }
        MetadataTable metadataTableWithFilter = new MetadataTableWithFilter(filterNames, createTable);
        semanticDiscoveryAction = new SemanticDiscoveryAction(metadataTableWithFilter);
    } else {
        // otherwise the selection is valid, only two possible status: only one columnset is select.
        if (firstElement instanceof DBTableRepNode) {
            DBTableRepNode node = (DBTableRepNode) firstElement;
            semanticDiscoveryAction = new SemanticDiscoveryAction(node.getTdTable());
        } else if (firstElement instanceof DBViewRepNode) {
            DBViewRepNode node = (DBViewRepNode) firstElement;
            semanticDiscoveryAction = new SemanticDiscoveryAction(node.getTdView());
        } else if (firstElement instanceof DFTableRepNode) {
            DFTableRepNode node = (DFTableRepNode) firstElement;
            semanticDiscoveryAction = new SemanticDiscoveryAction(node.getMetadataTable());
        }
    }
    menu.add(semanticDiscoveryAction);
}
Also used : DFColumnRepNode(org.talend.dq.nodes.DFColumnRepNode) ColumnRepNode(org.talend.dq.nodes.ColumnRepNode) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) ArrayList(java.util.ArrayList) SemanticDiscoveryAction(org.talend.dataprofiler.core.ui.action.actions.predefined.SemanticDiscoveryAction) DFColumnRepNode(org.talend.dq.nodes.DFColumnRepNode) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) TreeSelection(org.eclipse.jface.viewers.TreeSelection) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) DFTableRepNode(org.talend.dq.nodes.DFTableRepNode) DBViewRepNode(org.talend.dq.nodes.DBViewRepNode) MetadataTableWithFilter(org.talend.dataprofiler.core.model.MetadataTableWithFilter) HashSet(java.util.HashSet)

Example 13 with DBTableRepNode

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

the class RepositoryNodeHelper method createDBTableRepNode.

/**
 * DOC talend Comment method "createDBTableRepNode".
 *
 * @param findModelElement
 * @return
 */
private static RepositoryNode createDBTableRepNode(TdTable findModelElement, IRepositoryViewObject lastVersion) {
    TdTableRepositoryObject tdTableRepositoryObject = new TdTableRepositoryObject(lastVersion, findModelElement);
    tdTableRepositoryObject.setId(findModelElement.getName());
    tdTableRepositoryObject.setLabel(findModelElement.getName());
    DBTableRepNode dbTableRepNode = new DBTableRepNode(tdTableRepositoryObject, null, ENodeType.TDQ_REPOSITORY_ELEMENT, null);
    dbTableRepNode.setProperties(EProperties.LABEL, ERepositoryObjectType.METADATA_CON_COLUMN);
    dbTableRepNode.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.METADATA_CON_COLUMN);
    tdTableRepositoryObject.setRepositoryNode(dbTableRepNode);
    return dbTableRepNode;
}
Also used : DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) TdTableRepositoryObject(org.talend.core.repository.model.repositoryObject.TdTableRepositoryObject)

Example 14 with DBTableRepNode

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

the class RepositoryNodeHelper method recursiveFindTdTable.

public static DBTableRepNode recursiveFindTdTable(TdTable tdTable) {
    if (tdTable == null) {
        return null;
    }
    String uuidTdTable = getUUID(tdTable);
    if (uuidTdTable == null) {
        return null;
    }
    IRepositoryNode schemaOrCatalogNode = recursiveFind(ColumnSetHelper.getParentCatalogOrSchema(tdTable));
    if (schemaOrCatalogNode == null) {
        return null;
    }
    List<IRepositoryNode> childrens = schemaOrCatalogNode.getChildren();
    List<IRepositoryNode> children = null;
    if (!childrens.isEmpty()) {
        children = childrens.get(0).getChildren();
    }
    if (null != children && children.size() > 0) {
        IRepositoryNode iRepositoryNode = children.get(0);
        if (iRepositoryNode != null && iRepositoryNode instanceof DBTableRepNode) {
            for (IRepositoryNode childNode : children) {
                if (childNode != null && childNode instanceof DBTableRepNode) {
                    DBTableRepNode dbTableRepNode = (DBTableRepNode) childNode;
                    if (uuidTdTable.equals(getUUID(dbTableRepNode.getTdTable()))) {
                        return dbTableRepNode;
                    }
                }
            }
        }
    }
    return null;
}
Also used : DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode)

Example 15 with DBTableRepNode

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

the class PreviewProvider method fillContextMenu.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.ui.actions.ActionGroup#fillContextMenu(org.eclipse.jface.action.IMenuManager)
     */
@Override
public void fillContextMenu(IMenuManager menu) {
    // MOD mzhao user readonly role on svn repository mode.
    if (!isShowMenu()) {
        return;
    }
    TreeSelection treeSelection = ((TreeSelection) this.getContext().getSelection());
    Object firstElement = treeSelection.getFirstElement();
    NamedColumnSet set = null;
    if (firstElement instanceof DBTableRepNode) {
        set = ((DBTableRepNode) firstElement).getTdTable();
    } else if (firstElement instanceof DBViewRepNode) {
        set = ((DBViewRepNode) firstElement).getTdView();
    }
    if (set != null) {
        PreviewAction action = new PreviewAction(set);
        menu.add(action);
    }
}
Also used : DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) TreeSelection(org.eclipse.jface.viewers.TreeSelection) PreviewAction(org.talend.dataprofiler.core.ui.action.actions.predefined.PreviewAction) DBViewRepNode(org.talend.dq.nodes.DBViewRepNode) NamedColumnSet(orgomg.cwm.resource.relational.NamedColumnSet)

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