Search in sources :

Example 1 with DBViewRepNode

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

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

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

the class RepositoryNodeHelper method recursiveFindTdView.

public static DBViewRepNode recursiveFindTdView(TdView tdView) {
    if (tdView == null) {
        return null;
    }
    String uuidTdView = getUUID(tdView);
    if (uuidTdView == null) {
        return null;
    }
    IRepositoryNode schemaOrCatalogNode = recursiveFind(ColumnSetHelper.getParentCatalogOrSchema(tdView));
    if (schemaOrCatalogNode == null) {
        return null;
    }
    List<IRepositoryNode> children = schemaOrCatalogNode.getChildren().get(1).getChildren();
    if (children.size() > 0) {
        IRepositoryNode iRepositoryNode = children.get(0);
        if (iRepositoryNode != null && iRepositoryNode instanceof DBViewRepNode) {
            for (IRepositoryNode childNode : children) {
                if (childNode != null && childNode instanceof DBViewRepNode) {
                    DBViewRepNode dbViewRepNode = (DBViewRepNode) childNode;
                    if (uuidTdView.equals(getUUID(dbViewRepNode.getTdView()))) {
                        return dbViewRepNode;
                    }
                }
            }
        }
    }
    return null;
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) DBViewRepNode(org.talend.dq.nodes.DBViewRepNode)

Example 4 with DBViewRepNode

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

the class RepositoryNodeHelper method createDBViewRepNode.

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

Example 5 with DBViewRepNode

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

Aggregations

DBViewRepNode (org.talend.dq.nodes.DBViewRepNode)25 DBTableRepNode (org.talend.dq.nodes.DBTableRepNode)21 IRepositoryNode (org.talend.repository.model.IRepositoryNode)16 ArrayList (java.util.ArrayList)11 DFTableRepNode (org.talend.dq.nodes.DFTableRepNode)11 RepositoryNode (org.talend.repository.model.RepositoryNode)8 DBColumnRepNode (org.talend.dq.nodes.DBColumnRepNode)7 TreeSelection (org.eclipse.jface.viewers.TreeSelection)6 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)5 DFColumnRepNode (org.talend.dq.nodes.DFColumnRepNode)5 List (java.util.List)4 Test (org.junit.Test)4 ExchangeComponentRepNode (org.talend.dataprofiler.core.ui.exchange.ExchangeComponentRepNode)4 AnalysisRepNode (org.talend.dq.nodes.AnalysisRepNode)4 DBCatalogRepNode (org.talend.dq.nodes.DBCatalogRepNode)4 DBConnectionRepNode (org.talend.dq.nodes.DBConnectionRepNode)4 DBSchemaRepNode (org.talend.dq.nodes.DBSchemaRepNode)4 DFConnectionRepNode (org.talend.dq.nodes.DFConnectionRepNode)4 RuleRepNode (org.talend.dq.nodes.RuleRepNode)4 TreeItem (org.eclipse.swt.widgets.TreeItem)3