Search in sources :

Example 1 with ColumnRepNode

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

the class NumericalDPSelectionPage method addListeners.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dataprofiler.core.ui.wizard.analysis.column.ColumnAnalysisDOSelectionPage#addListeners()
     */
@Override
protected void addListeners() {
    addListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            Object object = ((IStructuredSelection) event.getSelection()).getFirstElement();
            nodes = new ArrayList<IRepositoryNode>();
            if (object instanceof ColumnRepNode) {
                // only support interger type
                RepositoryNode repositoryNode = (ColumnRepNode) object;
                nodes.add(repositoryNode);
                if (RepNodeUtils.isAllNumberalColumns(nodes)) {
                    advanceToNextPageOrFinish();
                }
            }
        }
    });
    addListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            try {
                Object object = ((IStructuredSelection) event.getSelection()).getFirstElement();
                nodes = new ArrayList<IRepositoryNode>();
                if (object instanceof ColumnRepNode) {
                    List<IRepositoryNode> list = ((IStructuredSelection) event.getSelection()).toList();
                    nodes.addAll(list);
                    if (nodes.size() == 0 || RepNodeUtils.isValidSelectionFromSameTable(nodes)) {
                        if (RepNodeUtils.isAllNumberalColumns(nodes)) {
                            setPageComplete(true);
                            setMessage(chooseConnStr);
                        } else {
                            setPageComplete(false);
                            setMessage(DefaultMessagesImpl.getString("ColumnAnalysisDOSelectionPage.selectColumnError2"), // $NON-NLS-1$
                            ERROR);
                        }
                    } else {
                        setPageComplete(false);
                        // $NON-NLS-1$
                        setMessage(DefaultMessagesImpl.getString("ColumnAnalysisDOSelectionPage.selectColumnError1"), ERROR);
                    }
                } else {
                    setPageComplete(false);
                    setMessage(chooseConnStr);
                }
            } catch (Exception e) {
                log.error(e, e);
            }
        }
    });
}
Also used : ColumnRepNode(org.talend.dq.nodes.ColumnRepNode) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ArrayList(java.util.ArrayList) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) ArrayList(java.util.ArrayList) List(java.util.List) IRepositoryNode(org.talend.repository.model.IRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode)

Example 2 with ColumnRepNode

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

the class MatchWizard method updateAnalysisBySelectedNode.

// when calling this method, the validation of the selection has been approved.the nodes will only contains one
// column set, or some columns from one same column set.
private void updateAnalysisBySelectedNode(AnalysisEditor editor) {
    MatchAnalysisDetailsPage masterPage = (MatchAnalysisDetailsPage) editor.getMasterPage();
    List<IRepositoryNode> nodes = selectionPage.nodes;
    if (nodes != null && nodes.size() > 0) {
        // if the first selected node is not column type(there should only one column set in the selected node then)
        if (!(nodes.get(0) instanceof ColumnRepNode)) {
            nodes = ((ColumnSetRepNode) nodes.get(0)).getAllColumns();
        }
        // update analyze data label by selected nodes names(don't cotain columnRepNode).
        if (nodes.size() > 0) {
            masterPage.updateAnalyzeDataLabel(nodes.get(0));
        }
        // give the selected columns to the master page
        masterPage.setSelectedNodes(nodes.toArray(new RepositoryNode[nodes.size()]));
        masterPage.doSave(new NullProgressMonitor());
        masterPage.updateAllColumnsToKeySection();
    }
}
Also used : ColumnRepNode(org.talend.dq.nodes.ColumnRepNode) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IRepositoryNode(org.talend.repository.model.IRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) MatchAnalysisDetailsPage(org.talend.dataprofiler.core.ui.editor.analysis.MatchAnalysisDetailsPage)

Example 3 with ColumnRepNode

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

the class NominalValuesDPSelectionPage method addListeners.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dataprofiler.core.ui.wizard.analysis.column.ColumnAnalysisDOSelectionPage#addListeners()
     */
@Override
protected void addListeners() {
    addListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            Object object = ((IStructuredSelection) event.getSelection()).getFirstElement();
            if (object instanceof ColumnRepNode) {
                RepositoryNode repositoryNode = (ColumnRepNode) object;
                DFColumnRepNode columnNode = new DFColumnRepNode(repositoryNode.getObject(), repositoryNode.getParent(), ENodeType.TDQ_REPOSITORY_ELEMENT, ((DQRepositoryNode) repositoryNode).getProject());
                int javaSQLType = TalendTypeConvert.convertToJDBCType(columnNode.getMetadataColumn().getTalendType());
                // int javaSQLType = TalendTypeConvert.convertToJDBCType(column.getTalendType());
                if (Java2SqlType.isTextInSQL(javaSQLType)) {
                    advanceToNextPageOrFinish();
                } else {
                    List<DFColumnRepNode> tempList = new ArrayList<DFColumnRepNode>();
                    tempList.add(columnNode);
                    setAddTextIndicator(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 col : tempList) {
                                MetadataHelper.setDataminingType(DataminingType.NOMINAL, col.getMetadataColumn());
                            }
                            advanceToNextPageOrFinish();
                        }
                    }
                }
            }
        }
    });
    addListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            try {
                Object object = ((IStructuredSelection) event.getSelection()).getFirstElement();
                nodes = new ArrayList<IRepositoryNode>();
                if (object instanceof ColumnRepNode) {
                    List<IRepositoryNode> list = ((IStructuredSelection) event.getSelection()).toList();
                    nodes.addAll(list);
                    if (nodes.size() == 0 || RepNodeUtils.isValidSelectionFromSameTable(nodes)) {
                        List<DFColumnRepNode> tempList = new ArrayList<DFColumnRepNode>();
                        for (IRepositoryNode obj : nodes) {
                            if (object instanceof ColumnRepNode) {
                                RepositoryNode repositoryNode = (ColumnRepNode) obj;
                                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);
                                    setAddTextIndicator(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()) {
                                // zqin get the column and change their datamining type to "Nominal"
                                for (DFColumnRepNode column : tempList) {
                                    MetadataHelper.setDataminingType(DataminingType.NOMINAL, column.getMetadataColumn());
                                }
                                setPageComplete(true);
                                setMessage(chooseConnStr);
                            }
                        } else {
                            setPageComplete(true);
                            setMessage(chooseConnStr);
                        }
                    } else {
                        setPageComplete(false);
                        // $NON-NLS-1$
                        setMessage(DefaultMessagesImpl.getString("ColumnAnalysisDOSelectionPage.selectColumnError1"), ERROR);
                    }
                } else {
                    setPageComplete(false);
                    setMessage(chooseConnStr);
                }
            } catch (Exception e) {
                log.error(e, e);
            }
        }
    });
}
Also used : DFColumnRepNode(org.talend.dq.nodes.DFColumnRepNode) ColumnRepNode(org.talend.dq.nodes.ColumnRepNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ArrayList(java.util.ArrayList) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IRepositoryNode(org.talend.repository.model.IRepositoryNode) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) DFColumnRepNode(org.talend.dq.nodes.DFColumnRepNode) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) ElementListSelectionDialog(org.eclipse.ui.dialogs.ElementListSelectionDialog) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ArrayList(java.util.ArrayList) List(java.util.List) DQRepositoryViewLabelProvider(org.talend.dataprofiler.core.ui.views.provider.DQRepositoryViewLabelProvider)

Example 4 with ColumnRepNode

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

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

the class MatchAnalysisDetailsPage method updateAllKeys.

/**
 * if some columns are deleted : remove the blocking/match key which used this column ; if some column still there :
 * update the index info in their keys; if some new columns added : do nothing
 *
 * @param oldSelectedColumns
 */
private void updateAllKeys(List<IRepositoryNode> oldSelectedColumns) {
    for (IRepositoryNode oldSelectNode : oldSelectedColumns) {
        int newPosition = positionInNewSelectColumns(oldSelectNode);
        if (newPosition > -1) {
            // update the position of the column
            addColumnGivenIndex(oldSelectNode, newPosition);
        } else {
            // delete all keys which used this column
            if (selectAlgorithmSection.isVSRMode()) {
                matchingKeySection.removeKeyFromAllTab(oldSelectNode.getLabel());
            } else {
                matchAndSurvivorKeySection.removeKeyFromAllTab(oldSelectNode.getLabel());
            }
            blockingKeySection.removeBlockingKey(oldSelectNode.getLabel());
            this.particularDefaultSurvivorshipSection.removeParticularKey(oldSelectNode.getLabel());
        }
    }
    // add new columns
    for (IRepositoryNode selectedOne : this.selectedNodes) {
        if (!oldSelectedColumns.contains(selectedOne)) {
            // the old doesnot contain the current, it need to be added to the columnMap
            int positionInNewSelectColumns = positionInNewSelectColumns(selectedOne);
            if (selectedOne instanceof ColumnRepNode) {
                addColumnGivenIndex(selectedOne, positionInNewSelectColumns);
            } else if (selectedOne instanceof ColumnSetRepNode) {
                List<IRepositoryNode> colNodes = ((ColumnSetRepNode) selectedOne).getAllColumns();
                for (IRepositoryNode colNode : colNodes) {
                    addColumnGivenIndex(colNode, positionInNewSelectColumns);
                }
            }
        }
    }
    if (selectAlgorithmSection.isVSRMode()) {
        this.matchingKeySection.redrawnSubTableContent();
    } else {
        matchAndSurvivorKeySection.redrawnSubTableContent();
    }
    this.blockingKeySection.redrawnSubTableContent();
    this.particularDefaultSurvivorshipSection.redrawnSubTableContent();
}
Also used : ColumnRepNode(org.talend.dq.nodes.ColumnRepNode) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ColumnSetRepNode(org.talend.dq.nodes.ColumnSetRepNode) List(java.util.List) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList)

Aggregations

ColumnRepNode (org.talend.dq.nodes.ColumnRepNode)10 IRepositoryNode (org.talend.repository.model.IRepositoryNode)8 ArrayList (java.util.ArrayList)6 DBColumnRepNode (org.talend.dq.nodes.DBColumnRepNode)5 DFColumnRepNode (org.talend.dq.nodes.DFColumnRepNode)5 List (java.util.List)3 DBTableRepNode (org.talend.dq.nodes.DBTableRepNode)3 DBViewRepNode (org.talend.dq.nodes.DBViewRepNode)3 RepositoryNode (org.talend.repository.model.RepositoryNode)3 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)2 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)2 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)2 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)2 Test (org.junit.Test)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)2 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)2 ColumnSetRepNode (org.talend.dq.nodes.ColumnSetRepNode)2 DFTableRepNode (org.talend.dq.nodes.DFTableRepNode)2 HashSet (java.util.HashSet)1