Search in sources :

Example 1 with DFTableRepNode

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

the class ImageLib method getImageNameByRepositoryNode.

public static String getImageNameByRepositoryNode(IRepositoryNode node) {
    String imageName = null;
    IRepositoryViewObject viewObject = node.getObject();
    ENodeType type = node.getType();
    if (node instanceof ReportAnalysisRepNode) {
        imageName = ImageLib.ANALYSIS_OBJECT;
    } else if (node instanceof RecycleBinRepNode) {
        imageName = ImageLib.RECYCLEBIN_EMPTY;
    } else if (type.equals(ENodeType.SYSTEM_FOLDER)) {
        String label = viewObject.getLabel();
        if (label.equals(EResourceConstant.DATA_PROFILING.getName())) {
            imageName = ImageLib.DATA_PROFILING;
        } else if (label.equals(EResourceConstant.METADATA.getName())) {
            imageName = ImageLib.METADATA;
        } else if (node instanceof DBConnectionFolderRepNode) {
            imageName = ImageLib.CONNECTION;
        } else if (label.equals(EResourceConstant.FILEDELIMITED.getName())) {
            imageName = ImageLib.FILE_DELIMITED;
        } else if (label.equals(EResourceConstant.HADOOP_CLUSTER.getName())) {
            imageName = ImageLib.HADOOP_CLUSTER;
        } else if (label.equals(EResourceConstant.LIBRARIES.getName())) {
            imageName = ImageLib.LIBRARIES;
        } else if (label.equals(EResourceConstant.EXCHANGE.getName())) {
            imageName = ImageLib.EXCHANGE;
        } else {
            imageName = ImageLib.FOLDERNODE_IMAGE;
        }
    } else if (type.equals(ENodeType.SIMPLE_FOLDER)) {
        imageName = ImageLib.FOLDERNODE_IMAGE;
    } else if (type.equals(ENodeType.REPOSITORY_ELEMENT)) {
        if (node instanceof DBConnectionRepNode) {
            imageName = ImageLib.TD_DATAPROVIDER;
        } else if (node instanceof DFConnectionRepNode) {
            imageName = ImageLib.FILE_DELIMITED;
        } else if (node instanceof AnalysisRepNode) {
            imageName = ImageLib.ANALYSIS_OBJECT;
        } else if (node instanceof ReportRepNode) {
            imageName = ImageLib.REPORT_OBJECT;
        } else if (node instanceof SysIndicatorDefinitionRepNode) {
            imageName = ImageLib.IND_DEFINITION;
        } else if (node instanceof PatternRepNode) {
            imageName = ImageLib.PATTERN_REG;
        } else if (node instanceof RuleRepNode) {
            imageName = ImageLib.DQ_RULE;
        } else if (node instanceof SourceFileRepNode) {
            imageName = ImageLib.SOURCE_FILE;
        } else if (node instanceof ExchangeCategoryRepNode || node instanceof ExchangeComponentRepNode) {
            imageName = ImageLib.EXCHANGE;
        } else if (node instanceof JrxmlTempleteRepNode) {
            imageName = ImageLib.JRXML_ICON;
        }
    } else if (type.equals(ENodeType.TDQ_REPOSITORY_ELEMENT)) {
        if (node instanceof DBCatalogRepNode) {
            imageName = ImageLib.CATALOG;
        } else if (node instanceof DBSchemaRepNode) {
            imageName = ImageLib.SCHEMA;
        } else if (node instanceof DBTableFolderRepNode) {
            imageName = ImageLib.FOLDERNODE_IMAGE;
        } else if (node instanceof DBViewFolderRepNode) {
            imageName = ImageLib.FOLDERNODE_IMAGE;
        } else if (node instanceof DBTableRepNode || node instanceof DFTableRepNode) {
            imageName = ImageLib.TABLE;
        } else if (node instanceof DBViewRepNode) {
            imageName = ImageLib.VIEW;
        } else if (node instanceof DBColumnRepNode) {
            if (((DBColumnRepNode) node).isKey()) {
                imageName = ImageLib.PK_COLUMN;
            } else {
                imageName = ImageLib.TD_COLUMN;
            }
        } else if (node instanceof DFColumnRepNode) {
            imageName = ImageLib.TD_COLUMN;
        } else if (node instanceof DBColumnFolderRepNode || node instanceof DFColumnFolderRepNode) {
            imageName = ImageLib.FOLDERNODE_IMAGE;
        }
    }
    return imageName;
}
Also used : DBConnectionRepNode(org.talend.dq.nodes.DBConnectionRepNode) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) SourceFileRepNode(org.talend.dq.nodes.SourceFileRepNode) DBViewFolderRepNode(org.talend.dq.nodes.DBViewFolderRepNode) DBCatalogRepNode(org.talend.dq.nodes.DBCatalogRepNode) ReportRepNode(org.talend.dq.nodes.ReportRepNode) ExchangeComponentRepNode(org.talend.dataprofiler.core.ui.exchange.ExchangeComponentRepNode) SysIndicatorDefinitionRepNode(org.talend.dq.nodes.SysIndicatorDefinitionRepNode) DFTableRepNode(org.talend.dq.nodes.DFTableRepNode) DBConnectionFolderRepNode(org.talend.dq.nodes.DBConnectionFolderRepNode) DBViewRepNode(org.talend.dq.nodes.DBViewRepNode) PatternRepNode(org.talend.dq.nodes.PatternRepNode) DBTableFolderRepNode(org.talend.dq.nodes.DBTableFolderRepNode) DFColumnFolderRepNode(org.talend.dq.nodes.DFColumnFolderRepNode) DBSchemaRepNode(org.talend.dq.nodes.DBSchemaRepNode) RuleRepNode(org.talend.dq.nodes.RuleRepNode) JrxmlTempleteRepNode(org.talend.dq.nodes.JrxmlTempleteRepNode) RecycleBinRepNode(org.talend.dq.nodes.RecycleBinRepNode) DBColumnFolderRepNode(org.talend.dq.nodes.DBColumnFolderRepNode) DFColumnRepNode(org.talend.dq.nodes.DFColumnRepNode) DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) ReportAnalysisRepNode(org.talend.dq.nodes.ReportAnalysisRepNode) AnalysisRepNode(org.talend.dq.nodes.AnalysisRepNode) ExchangeCategoryRepNode(org.talend.dataprofiler.core.ui.exchange.ExchangeCategoryRepNode) DFConnectionRepNode(org.talend.dq.nodes.DFConnectionRepNode) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ENodeType(org.talend.repository.model.IRepositoryNode.ENodeType) ReportAnalysisRepNode(org.talend.dq.nodes.ReportAnalysisRepNode)

Example 2 with DFTableRepNode

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

the class ColumnsSelectionDialog method addCheckedListener.

/*
     * (non-Javadoc)
     * 
     * @seeorg.talend.dataprofiler.core.ui.dialog.TwoPartCheckSelectionDialog# 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) {
            // Added TDQ-8718 20140506 yyin: should not load from db when checking
            DQDBFolderRepositoryNode.setCallingFromColumnDialog(true);
            DQDBFolderRepositoryNode.setLoadDBFromDialog(false);
            try {
                ColumnSelectionViewer columnViewer = (ColumnSelectionViewer) event.getSource();
                TreePath treePath = new TreePath(new Object[] { event.getElement() });
                columnViewer.setSelection(new TreeSelection(treePath));
                setOutput(event.getElement());
                RepositoryNode selectedNode = (RepositoryNode) event.getElement();
                if (selectedNode instanceof DBTableRepNode || selectedNode instanceof DBViewRepNode || selectedNode instanceof DFTableRepNode) {
                    handleTreeElementsChecked(selectedNode, event.getChecked());
                } else {
                    checkChildrenElements(selectedNode, event.getChecked());
                }
                getTreeViewer().setSubtreeChecked(event.getElement(), event.getChecked());
                updateStatusBySelection();
            } finally {
                // Added TDQ-8718 20140506 yyin
                DQDBFolderRepositoryNode.setCallingFromColumnDialog(false);
                DQDBFolderRepositoryNode.setLoadDBFromDialog(true);
            }
        }

        private void checkChildrenElements(RepositoryNode repNode, Boolean checkedFlag) {
            Set<?> keySet = modelElementCheckedMap.keySet();
            RepositoryNode[] repNodeArray = (RepositoryNode[]) modelElementCheckedMap.keySet().toArray(new RepositoryNode[keySet.size()]);
            for (RepositoryNode reposNode : repNodeArray) {
                RepositoryNode parentNode = reposNode.getParent();
                while (parentNode != null) {
                    if (repNode.equals(parentNode)) {
                        handleTreeElementsChecked(reposNode, checkedFlag);
                        break;
                    } else {
                        parentNode = parentNode.getParent();
                    }
                }
            }
        }
    });
    getTableViewer().addCheckStateListener(new ICheckStateListener() {

        public void checkStateChanged(CheckStateChangedEvent event) {
            handleTableElementsChecked((RepositoryNode) event.getElement(), event.getChecked());
            updateStatusBySelection();
        }
    });
}
Also used : DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) Set(java.util.Set) TreePath(org.eclipse.jface.viewers.TreePath) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) TreeSelection(org.eclipse.jface.viewers.TreeSelection) DFTableRepNode(org.talend.dq.nodes.DFTableRepNode) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) RepositoryNode(org.talend.repository.model.RepositoryNode) DQDBFolderRepositoryNode(org.talend.dq.nodes.DQDBFolderRepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) DBViewRepNode(org.talend.dq.nodes.DBViewRepNode)

Example 3 with DFTableRepNode

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

the class ColumnsSelectionDialog method getAllCheckedTableNodes.

/**
 * Compute the checked Table Nodes.
 *
 * @param repNodeArray
 * @return
 */
private List<RepositoryNode> getAllCheckedTableNodes() {
    Set<?> keySet = modelElementCheckedMap.keySet();
    RepositoryNode[] tableNodesFromMap = keySet.toArray(new RepositoryNode[keySet.size()]);
    List<RepositoryNode> allcheckedTableNodes = new ArrayList<RepositoryNode>();
    for (Object checkElement : this.getTreeViewer().getCheckedElements()) {
        if ((checkElement instanceof DBTableRepNode || checkElement instanceof DBViewRepNode || checkElement instanceof DFTableRepNode) && ((RepositoryNode) checkElement).getId() != null) {
            allcheckedTableNodes.add((RepositoryNode) checkElement);
        }
    }
    for (RepositoryNode node : tableNodesFromMap) {
        if (node.getId() == null) {
            continue;
        }
        if (!allcheckedTableNodes.contains(node)) {
            allcheckedTableNodes.add(node);
        }
    }
    return allcheckedTableNodes;
}
Also used : DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) ArrayList(java.util.ArrayList) DFTableRepNode(org.talend.dq.nodes.DFTableRepNode) RepositoryNode(org.talend.repository.model.RepositoryNode) DQDBFolderRepositoryNode(org.talend.dq.nodes.DQDBFolderRepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) DBViewRepNode(org.talend.dq.nodes.DBViewRepNode)

Example 4 with DFTableRepNode

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

use of org.talend.dq.nodes.DFTableRepNode 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)

Aggregations

DBTableRepNode (org.talend.dq.nodes.DBTableRepNode)11 DBViewRepNode (org.talend.dq.nodes.DBViewRepNode)11 DFTableRepNode (org.talend.dq.nodes.DFTableRepNode)11 IRepositoryNode (org.talend.repository.model.IRepositoryNode)9 ArrayList (java.util.ArrayList)7 RepositoryNode (org.talend.repository.model.RepositoryNode)6 DBColumnRepNode (org.talend.dq.nodes.DBColumnRepNode)5 DFColumnRepNode (org.talend.dq.nodes.DFColumnRepNode)5 List (java.util.List)3 TreeSelection (org.eclipse.jface.viewers.TreeSelection)3 AnalysisRepNode (org.talend.dq.nodes.AnalysisRepNode)3 DFConnectionRepNode (org.talend.dq.nodes.DFConnectionRepNode)3 DQDBFolderRepositoryNode (org.talend.dq.nodes.DQDBFolderRepositoryNode)3 PatternRepNode (org.talend.dq.nodes.PatternRepNode)3 ReportRepNode (org.talend.dq.nodes.ReportRepNode)3 RuleRepNode (org.talend.dq.nodes.RuleRepNode)3 Test (org.junit.Test)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 ContextRepNode (org.talend.dq.nodes.ContextRepNode)2 SysIndicatorDefinitionRepNode (org.talend.dq.nodes.SysIndicatorDefinitionRepNode)2