Search in sources :

Example 6 with DFColumnRepNode

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

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

the class RepositoryNodeHelper method recursiveFindMetadataColumn.

public static DFColumnRepNode recursiveFindMetadataColumn(MetadataColumn metadataColumn) {
    if (metadataColumn == null) {
        return null;
    }
    String uuidMetadataColumn = getUUID(metadataColumn);
    if (uuidMetadataColumn == null) {
        return null;
    }
    IRepositoryNode columnSetNode = recursiveFind(ColumnHelper.getColumnOwnerAsMetadataTable(metadataColumn));
    if (columnSetNode == null) {
        return null;
    }
    List<IRepositoryNode> children = columnSetNode.getChildren().get(0).getChildren();
    if (children.size() > 0) {
        for (IRepositoryNode childNode : children) {
            if (childNode != null && childNode instanceof DFColumnRepNode) {
                DFColumnRepNode dfColumnRepNode = (DFColumnRepNode) childNode;
                if (uuidMetadataColumn.equals(getUUID(dfColumnRepNode.getMetadataColumn()))) {
                    return dfColumnRepNode;
                }
            }
        }
    }
    return null;
}
Also used : DFColumnRepNode(org.talend.dq.nodes.DFColumnRepNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode)

Example 8 with DFColumnRepNode

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

the class DQRepositoryViewLabelProvider method getImage.

@Override
public Image getImage(Object element) {
    Image image = super.getImage(element);
    if (element instanceof IRepositoryNode) {
        IRepositoryNode node = (IRepositoryNode) element;
        if (node instanceof ReportAnalysisRepNode) {
            image = ImageLib.getImage(ImageLib.ANALYSIS_OBJECT);
        } else if (node instanceof ExchangeCategoryRepNode || node instanceof ExchangeComponentRepNode) {
            image = ImageLib.getImage(ImageLib.EXCHANGE);
        } else if (node instanceof RecycleBinRepNode) {
            image = ImageLib.getImage(ImageLib.RECYCLEBIN_EMPTY);
        } else {
            IRepositoryViewObject viewObject = node.getObject();
            ENodeType type = node.getType();
            if (type.equals(ENodeType.SYSTEM_FOLDER)) {
                if (EResourceConstant.REFERENCED_PROJECT.getName().equals(node.getProperties(EProperties.LABEL))) {
                    image = ImageLib.getImage(ImageLib.REFERENCED_PROJECT);
                } else {
                    String label = viewObject.getLabel();
                    if (label.equals(EResourceConstant.DATA_PROFILING.getName())) {
                        image = ImageLib.getImage(ImageLib.DATA_PROFILING);
                    } else if (label.equals(EResourceConstant.METADATA.getName())) {
                        image = ImageLib.getImage(ImageLib.METADATA);
                    } else if (node instanceof DBConnectionFolderRepNode) {
                        image = ImageLib.getImage(ImageLib.CONNECTION);
                    } else if (label.equals(EResourceConstant.FILEDELIMITED.getName())) {
                        image = ImageLib.getImage(ImageLib.FILE_DELIMITED);
                    } else if (label.equals(EResourceConstant.LIBRARIES.getName())) {
                        image = ImageLib.getImage(ImageLib.LIBRARIES);
                    } else if (label.equals(EResourceConstant.EXCHANGE.getName())) {
                        image = ImageLib.getImage(ImageLib.EXCHANGE);
                    } else if (label.equals(EResourceConstant.HADOOP_CLUSTER.getName())) {
                        image = ImageLib.getImage(ImageLib.HADOOP_CLUSTER);
                    } else if (label.equals(EResourceConstant.CONTEXT.getName())) {
                        image = ImageLib.getImage(ImageLib.CONTEXT);
                    } else {
                        image = ImageLib.getImage(ImageLib.FOLDERNODE_IMAGE);
                    }
                }
            } else if (type.equals(ENodeType.SIMPLE_FOLDER)) {
                image = ImageLib.getImage(ImageLib.FOLDERNODE_IMAGE);
            } else if (type.equals(ENodeType.REFERENCED_PROJECT)) {
                image = ImageLib.getImage(ImageLib.REFERENCED_PROJECT);
            } else if (type.equals(ENodeType.REPOSITORY_ELEMENT)) {
                // TDQ-7560 when the image is a overlay image,use originalImageName to get the corresponding one.
                String originalImageName = null;
                if (node instanceof DBConnectionRepNode) {
                    originalImageName = ImageLib.TD_DATAPROVIDER;
                    if (!RepositoryNodeHelper.isSupportedConnection(node) || isNeedAddDriverConnection(node)) {
                        image = ImageLib.createErrorIcon(originalImageName);
                    } else if (isInvalidJDBCConnection(node)) {
                        image = ImageLib.createInvalidIcon(originalImageName);
                    } else {
                        image = ImageLib.getImage(originalImageName);
                    }
                } else if (node instanceof DFConnectionRepNode) {
                    originalImageName = ImageLib.FILE_DELIMITED;
                } else if (node instanceof AnalysisRepNode) {
                    originalImageName = ImageLib.ANALYSIS_OBJECT;
                    image = addWarnIconIfNeeded(node, originalImageName);
                } else if (node instanceof ReportRepNode) {
                    originalImageName = ImageLib.REPORT_OBJECT;
                    image = addWarnIconIfNeeded(node, originalImageName);
                } else if (node instanceof SysIndicatorDefinitionRepNode) {
                    originalImageName = ImageLib.IND_DEFINITION;
                } else if (node instanceof PatternRepNode) {
                    originalImageName = ImageLib.PATTERN_REG;
                } else if (node instanceof RuleRepNode) {
                    if (((RuleRepNode) node).getRule() instanceof MatchRuleDefinition) {
                        originalImageName = ImageLib.MATCH_RULE_ICON;
                    } else {
                        originalImageName = ImageLib.DQ_RULE;
                    }
                } else if (node instanceof SourceFileRepNode) {
                    originalImageName = ImageLib.SOURCE_FILE;
                } else if (node instanceof HadoopClusterConnectionRepNode) {
                    originalImageName = ImageLib.HADOOP_CLUSTER;
                } else if (node instanceof HDFSOfHCConnectionNode) {
                    originalImageName = ImageLib.HDFS;
                } else if (node instanceof HiveOfHCConnectionNode) {
                    originalImageName = ImageLib.HIVE_LINK;
                } else if (node instanceof ExchangeCategoryRepNode || node instanceof ExchangeComponentRepNode) {
                    originalImageName = ImageLib.EXCHANGE;
                } else if (node instanceof ContextRepNode) {
                    originalImageName = ImageLib.CONTEXT;
                } else if (node instanceof RepositoryNode) {
                    // MOD qiongli 2011-1-18 get image for nodes in recycle bin
                    Image imageNode = getImageByContentType((RepositoryNode) node);
                    if (image != null) {
                        image = imageNode;
                    }
                }
                if (originalImageName != null && !(node instanceof DBConnectionRepNode || node instanceof AnalysisRepNode || node instanceof ReportRepNode)) {
                    image = ImageLib.getImage(originalImageName);
                }
                // exchange folder did not contain viewObject.
                if (viewObject != null) {
                    // MOD yyi 2011-04-07 19696: "Lock element"
                    ERepositoryStatus status = ProxyRepositoryFactory.getInstance().getStatus(viewObject);
                    Context ctx = CoreRuntimePlugin.getInstance().getContext();
                    RepositoryContext rc = (RepositoryContext) ctx.getProperty(Context.REPOSITORY_CONTEXT_KEY);
                    // will be enhanced later by TDI-29265.
                    if (rc.isEditableAsReadOnly()) {
                        if (status == ERepositoryStatus.LOCK_BY_USER) {
                            status = ERepositoryStatus.DEFAULT;
                        }
                    }
                    if (ERepositoryStatus.DEFAULT != status && originalImageName != null) {
                        if (ERepositoryStatus.LOCK_BY_USER == status) {
                            image = ImageLib.createLockedByOwnIcon(originalImageName);
                        } else if (ERepositoryStatus.LOCK_BY_OTHER == status) {
                            image = ImageLib.createLockedByOtherIcon(originalImageName);
                        }
                    }
                }
            } else if (type.equals(ENodeType.TDQ_REPOSITORY_ELEMENT)) {
                if (node instanceof DBCatalogRepNode) {
                    image = ImageLib.getImage(ImageLib.CATALOG);
                } else if (node instanceof DBSchemaRepNode) {
                    image = ImageLib.getImage(ImageLib.SCHEMA);
                } else if (node instanceof DBTableFolderRepNode) {
                    image = ImageLib.getImage(ImageLib.FOLDERNODE_IMAGE);
                } else if (node instanceof DBViewFolderRepNode) {
                    image = ImageLib.getImage(ImageLib.FOLDERNODE_IMAGE);
                } else if (node instanceof DBTableRepNode || node instanceof DFTableRepNode) {
                    image = ImageLib.getImage(ImageLib.TABLE);
                } else if (node instanceof DBViewRepNode) {
                    image = ImageLib.getImage(ImageLib.VIEW);
                } else if (node instanceof DBColumnRepNode) {
                    if (((DBColumnRepNode) node).isKey()) {
                        image = ImageLib.getImage(ImageLib.PK_COLUMN);
                    } else {
                        image = ImageLib.getImage(ImageLib.TD_COLUMN);
                    }
                } else if (node instanceof DFColumnRepNode) {
                    image = ImageLib.getImage(ImageLib.TD_COLUMN);
                } else if (node instanceof DBColumnFolderRepNode || node instanceof DFColumnFolderRepNode) {
                    image = ImageLib.getImage(ImageLib.FOLDERNODE_IMAGE);
                } else if (node instanceof JrxmlTempleteRepNode) {
                    image = ImageLib.getImage(ImageLib.JRXML_ICON);
                }
            }
        }
    }
    return image;
}
Also used : DBConnectionRepNode(org.talend.dq.nodes.DBConnectionRepNode) ERepositoryStatus(org.talend.commons.runtime.model.repository.ERepositoryStatus) RepositoryContext(org.talend.core.context.RepositoryContext) HDFSOfHCConnectionNode(org.talend.dq.nodes.hadoopcluster.HDFSOfHCConnectionNode) MatchRuleDefinition(org.talend.dataquality.rules.MatchRuleDefinition) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) Image(org.eclipse.swt.graphics.Image) 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) AnalysisContext(org.talend.dataquality.analysis.AnalysisContext) Context(org.talend.core.context.Context) RepositoryContext(org.talend.core.context.RepositoryContext) DBTableFolderRepNode(org.talend.dq.nodes.DBTableFolderRepNode) DFColumnFolderRepNode(org.talend.dq.nodes.DFColumnFolderRepNode) DBSchemaRepNode(org.talend.dq.nodes.DBSchemaRepNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) HiveOfHCConnectionNode(org.talend.dq.nodes.hadoopcluster.HiveOfHCConnectionNode) RuleRepNode(org.talend.dq.nodes.RuleRepNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) 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) ExchangeCategoryRepNode(org.talend.dataprofiler.core.ui.exchange.ExchangeCategoryRepNode) ReportAnalysisRepNode(org.talend.dq.nodes.ReportAnalysisRepNode) AnalysisRepNode(org.talend.dq.nodes.AnalysisRepNode) DFConnectionRepNode(org.talend.dq.nodes.DFConnectionRepNode) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ENodeType(org.talend.repository.model.IRepositoryNode.ENodeType) HadoopClusterConnectionRepNode(org.talend.dq.nodes.hadoopcluster.HadoopClusterConnectionRepNode) ReportAnalysisRepNode(org.talend.dq.nodes.ReportAnalysisRepNode) ContextRepNode(org.talend.dq.nodes.ContextRepNode)

Example 9 with DFColumnRepNode

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

the class RepNodeUtils method translateSelectedToStandardReposityoryNode.

public static List<IRepositoryNode> translateSelectedToStandardReposityoryNode(Object[] objs) {
    List<IRepositoryNode> reposList = new ArrayList<IRepositoryNode>();
    for (Object obj : objs) {
        // MOD klliu 2011-02-16 feature 15387
        if (obj instanceof DBColumnRepNode || obj instanceof DFColumnRepNode) {
            reposList.add((RepositoryNode) obj);
        } else if (obj instanceof DBTableRepNode || obj instanceof DBViewRepNode || obj instanceof DFTableRepNode) {
            List<IRepositoryNode> children = ((IRepositoryNode) obj).getChildren().get(0).getChildren();
            reposList.addAll(children);
        } else if (obj instanceof MetadataColumn) {
            // MOD qiongli TDQ-7052 if the node is filtered ,it will be return null,so should create a new node.
            RepositoryNode repNode = RepositoryNodeHelper.recursiveFind((ModelElement) obj);
            if (repNode == null) {
                repNode = RepositoryNodeHelper.createRepositoryNode((ModelElement) obj);
            }
            reposList.add(repNode);
        }
    }
    return reposList;
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) ArrayList(java.util.ArrayList) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) DFColumnRepNode(org.talend.dq.nodes.DFColumnRepNode) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) DFTableRepNode(org.talend.dq.nodes.DFTableRepNode) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) List(java.util.List) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) DBViewRepNode(org.talend.dq.nodes.DBViewRepNode)

Example 10 with DFColumnRepNode

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

the class CreateNominalAnalysisAction method preDo.

@Override
protected boolean preDo() {
    // MOD msjian TDQ-5530 2012-12-20: make the icon and text have the same look&feel as in the DQ repository view.
    List<DFColumnRepNode> tempList = new ArrayList<DFColumnRepNode>();
    addTextIndicator = true;
    for (IRepositoryNode repositoryNode : getColumns()) {
        DFColumnRepNode columnNode = new DFColumnRepNode(repositoryNode.getObject(), repositoryNode.getParent(), ENodeType.TDQ_REPOSITORY_ELEMENT, ((DQRepositoryNode) repositoryNode).getProject());
        int javaSQLType = TalendTypeConvert.convertToJDBCType(columnNode.getMetadataColumn().getTalendType());
        if (!Java2SqlType.isTextInSQL(javaSQLType)) {
            tempList.add(columnNode);
            addTextIndicator = false;
        }
    }
    if (!tempList.isEmpty()) {
        ElementListSelectionDialog dialog = new ElementListSelectionDialog(null, new DQRepositoryViewLabelProvider());
        dialog.setElements(tempList.toArray());
        // $NON-NLS-1$
        dialog.setTitle(DefaultMessagesImpl.getString("CreateNominalAnalysisAction.dataTypeWarning"));
        // $NON-NLS-1$
        dialog.setMessage(DefaultMessagesImpl.getString("CreateNominalAnalysisAction.string"));
        dialog.setSize(80, 20);
        dialog.create();
        if (Window.OK == dialog.open()) {
            // use MetadataHelper
            for (DFColumnRepNode column : tempList) {
                MetadataHelper.setDataminingType(DataminingType.NOMINAL, column.getMetadataColumn());
            }
            return true;
        } else {
            return false;
        }
    }
    return true;
}
Also used : DFColumnRepNode(org.talend.dq.nodes.DFColumnRepNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ElementListSelectionDialog(org.eclipse.ui.dialogs.ElementListSelectionDialog) ArrayList(java.util.ArrayList) DQRepositoryViewLabelProvider(org.talend.dataprofiler.core.ui.views.provider.DQRepositoryViewLabelProvider)

Aggregations

DFColumnRepNode (org.talend.dq.nodes.DFColumnRepNode)10 IRepositoryNode (org.talend.repository.model.IRepositoryNode)7 DBColumnRepNode (org.talend.dq.nodes.DBColumnRepNode)6 DBTableRepNode (org.talend.dq.nodes.DBTableRepNode)6 ArrayList (java.util.ArrayList)5 DBViewRepNode (org.talend.dq.nodes.DBViewRepNode)5 DFTableRepNode (org.talend.dq.nodes.DFTableRepNode)5 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)4 RepositoryNode (org.talend.repository.model.RepositoryNode)4 List (java.util.List)3 MetadataColumnRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject)3 PatternRepNode (org.talend.dq.nodes.PatternRepNode)3 ElementListSelectionDialog (org.eclipse.ui.dialogs.ElementListSelectionDialog)2 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)2 MetadataTableRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject)2 ExchangeCategoryRepNode (org.talend.dataprofiler.core.ui.exchange.ExchangeCategoryRepNode)2 ExchangeComponentRepNode (org.talend.dataprofiler.core.ui.exchange.ExchangeComponentRepNode)2 DQRepositoryViewLabelProvider (org.talend.dataprofiler.core.ui.views.provider.DQRepositoryViewLabelProvider)2 ColumnRepNode (org.talend.dq.nodes.ColumnRepNode)2 SysIndicatorDefinitionRepNode (org.talend.dq.nodes.SysIndicatorDefinitionRepNode)2