Search in sources :

Example 16 with DataminingType

use of org.talend.dataquality.indicators.DataminingType in project tdq-studio-se by Talend.

the class AnalysisColumnTreeViewer method addItemElements.

private void addItemElements(final ModelElementIndicator[] elements, boolean isExpandAll) {
    for (ModelElementIndicator element : elements) {
        final TreeItem treeItem = new TreeItem(tree, SWT.NONE);
        treeItem.setImage(ImageLib.getImage(ImageLib.TD_COLUMN));
        final ModelElementIndicator meIndicator = element;
        treeItem.setText(0, ModelElementIndicatorHelper.getModelElementDisplayName(meIndicator));
        treeItem.setData(MODELELEMENT_INDICATOR_KEY, meIndicator);
        TreeEditor comboEditor = new TreeEditor(tree);
        final CCombo combo = new CCombo(tree, SWT.BORDER);
        for (DataminingType type : DataminingType.values()) {
            // MODSCA 2008-04-10 use literal
            combo.add(type.getLiteral());
        // for presentation
        }
        final ModelElement modelElement = RepositoryNodeHelper.getSubModelElement(meIndicator.getModelElementRepositoryNode());
        DataminingType dataminingType = MetadataHelper.getDataminingType(modelElement);
        // MOD qiongli 2010-11-15 feature 16796
        if (meIndicator instanceof DelimitedFileIndicator) {
            dataminingType = MetadataHelper.getDefaultDataminingType(meIndicator.getJavaType());
        }
        if (dataminingType == null) {
            combo.select(0);
        } else {
            combo.setText(dataminingType.getLiteral());
        }
        combo.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                MetadataHelper.setDataminingType(DataminingType.get(combo.getText()), modelElement);
                setDirty(true);
            }
        });
        combo.setEditable(false);
        comboEditor.minimumWidth = WIDTH1_CELL;
        comboEditor.setEditor(combo, treeItem, 1);
        TreeEditor addPatternEditor = new TreeEditor(tree);
        // $NON-NLS-1$
        Label addPatternLabl = createTreeItemLabel(tree, ImageLib.ADD_PATTERN, "AnalysisColumnTreeViewer.addPattern");
        // MOD mzhao feature:13040, 2010-05-21
        addPatternLabl.addMouseListener(new PatternMouseAdapter(this, masterPage, meIndicator, treeItem));
        addPatternEditor.minimumWidth = addPatternLabl.getImage().getBounds().width;
        addPatternEditor.setEditor(addPatternLabl, treeItem, 2);
        // ADD xqliu 2010-02-23 feature 11617
        TreeEditor addUdiEditor = addColumnUdi(treeItem, meIndicator, 3);
        // ~
        TreeEditor delLabelEditor = new TreeEditor(tree);
        // $NON-NLS-1$
        Label delLabel = createTreeItemLabel(tree, ImageLib.DELETE_ACTION, "AnalysisColumnTreeViewer.delete");
        delLabel.setData(treeItem);
        delLabel.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseDown(MouseEvent e) {
                // // here is the delLable which is behind of column, so need to remove current column and it's all
                // of
                TreeItem currentTreeItem = (TreeItem) e.widget.getData();
                removeSelectedElements(new TreeItem[] { currentTreeItem });
                notifyObservers();
            }
        });
        delLabelEditor.minimumWidth = delLabel.getImage().getBounds().width;
        delLabelEditor.horizontalAlignment = SWT.CENTER;
        delLabelEditor.setEditor(delLabel, treeItem, 4);
        treeItem.setData(ITEM_EDITOR_KEY, new TreeEditor[] { comboEditor, delLabelEditor, addPatternEditor, addUdiEditor });
        if (meIndicator.hasIndicators()) {
            createIndicatorItems(treeItem, meIndicator.getIndicatorUnits());
        }
        treeItem.setExpanded(isExpandAll);
    }
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) TreeEditor(org.eclipse.swt.custom.TreeEditor) TreeItem(org.eclipse.swt.widgets.TreeItem) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) MouseAdapter(org.eclipse.swt.events.MouseAdapter) DataminingType(org.talend.dataquality.indicators.DataminingType) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) CCombo(org.eclipse.swt.custom.CCombo) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DelimitedFileIndicator(org.talend.dataprofiler.core.model.DelimitedFileIndicator) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Example 17 with DataminingType

use of org.talend.dataquality.indicators.DataminingType in project tdq-studio-se by Talend.

the class ColumnIndicatorUnit method getForms.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit#getForms()
     */
@Override
public FormEnum[] getForms() {
    int sqlType = null != modelElementIndicator ? modelElementIndicator.getJavaType() : 0;
    ColumnIndicator columnIndicator = ModelElementIndicatorHelper.switchColumnIndicator(this);
    DataminingType dataminingType = columnIndicator == null ? null : MetadataHelper.getDataminingType(columnIndicator.getTdColumn());
    if (dataminingType == null) {
        dataminingType = null != modelElementIndicator ? MetadataHelper.getDefaultDataminingType(modelElementIndicator.getJavaType()) : DataminingType.NOMINAL;
    }
    return FormEnum.getFormEnumArray(this.getIndicator().getIndicatorDefinition(), sqlType, dataminingType, type, getExecutionLanguage());
}
Also used : DataminingType(org.talend.dataquality.indicators.DataminingType) ColumnIndicator(org.talend.dataprofiler.core.model.ColumnIndicator)

Example 18 with DataminingType

use of org.talend.dataquality.indicators.DataminingType in project tdq-studio-se by Talend.

the class ColumnSetIndicatorUnit method getForms.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit#getForms()
     */
@Override
public FormEnum[] getForms() {
    int sqlType = 0;
    DataminingType dataminingType = DataminingType.NOMINAL;
    IndicatorDefinition indicatorDefinition = this.getIndicator().getIndicatorDefinition();
    return FormEnum.getFormEnumArray(indicatorDefinition, sqlType, dataminingType, type, getExecutionLanguage());
}
Also used : DataminingType(org.talend.dataquality.indicators.DataminingType) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition)

Example 19 with DataminingType

use of org.talend.dataquality.indicators.DataminingType in project tdq-studio-se by Talend.

the class ChangeConnectionAction method synAnalyzedElements.

private boolean synAnalyzedElements(AnalyzedElementSynDialog anaEleSynDialog, Analysis synAnalysis, Connection oldDataProvider, Connection newDataProv) {
    // Change connection uuid.
    Map<ModelElement, ModelElement> synEleMap = anaEleSynDialog == null ? null : anaEleSynDialog.getSynedEleMap();
    AnalysisBuilder anaBuilder = new AnalysisBuilder();
    anaBuilder.setAnalysis(synAnalysis);
    // Remove old dependencies.
    boolean isRemovedDependency = DependenciesHandler.getInstance().removeConnDependencyAndSave(analysisItem);
    if (!isRemovedDependency) {
        return false;
    }
    synAnalysis.getContext().setConnection(newDataProv);
    // Synchronize analysis result.
    EList<Indicator> indcList = synAnalysis.getResults().getIndicators();
    Indicator[] copiedIndArray = new Indicator[indcList.size()];
    System.arraycopy(indcList.toArray(), 0, copiedIndArray, 0, indcList.size());
    // MOD qiongli 2010-6-13,bug 12766:To column analysis, which has same
    // construct connection with before and maybe have not indicator
    boolean isExistSynedElement = false;
    AnalysisType analysisType = synAnalysis.getParameters().getAnalysisType();
    if (analysisType == AnalysisType.MULTIPLE_COLUMN) {
        EList<ModelElement> meLs = synAnalysis.getContext().getAnalysedElements();
        ModelElement[] mes = new ModelElement[meLs.size()];
        System.arraycopy(meLs.toArray(), 0, mes, 0, meLs.size());
        synAnalysis.getContext().getAnalysedElements().clear();
        for (ModelElement me : mes) {
            if (synEleMap != null && synEleMap.get(me) != null) {
                TdColumn newColumn = (TdColumn) synEleMap.get(me);
                synAnalysis.getContext().getAnalysedElements().add(newColumn);
                isExistSynedElement = true;
            }
        }
    }
    if (!isExistSynedElement) {
        synAnalysis.getContext().getAnalysedElements().clear();
    }
    // ~
    synAnalysis.getResults().getIndicators().clear();
    for (Indicator indicator : copiedIndArray) {
        // connection.
        if (indicator instanceof ColumnSetMultiValueIndicator) {
            ColumnSetMultiValueIndicator compositeInd = (ColumnSetMultiValueIndicator) indicator;
            ModelElement[] mes = new ModelElement[compositeInd.getAnalyzedColumns().size()];
            ((ColumnSetMultiValueIndicator) indicator).getAnalyzedColumns().toArray(mes);
            compositeInd.getAnalyzedColumns().clear();
            for (ModelElement me : mes) {
                if (synEleMap != null && synEleMap.get(me) != null) {
                    TdColumn newColumn = (TdColumn) synEleMap.get(me);
                    DataminingType dataminingType = MetadataHelper.getDataminingType((TdColumn) me);
                    if (dataminingType == null) {
                        dataminingType = MetadataHelper.getDefaultDataminingType(((TdColumn) me).getSqlDataType().getJavaDataType());
                    }
                    MetadataHelper.setDataminingType(dataminingType, newColumn);
                    compositeInd.getAnalyzedColumns().add(newColumn);
                    anaBuilder.addElementToAnalyze(newColumn, indicator);
                    isExistSynedElement = true;
                }
            }
        } else if (indicator instanceof ColumnsCompareIndicator) {
            // Correlation compare
            ColumnsCompareIndicator compInd = (ColumnsCompareIndicator) indicator;
            if ((compInd.getColumnSetA() == null || compInd.getColumnSetA().size() == 0) || (compInd.getColumnSetB() == null || compInd.getColumnSetB().size() == 0)) {
                return false;
            }
            // Column set(Columns)
            ModelElement[] mesA = new ModelElement[compInd.getColumnSetA().size()];
            compInd.getColumnSetA().toArray(mesA);
            compInd.getColumnSetA().clear();
            for (ModelElement me : mesA) {
                if (synEleMap != null && synEleMap.get(me) != null) {
                    TdColumn newColumn = (TdColumn) synEleMap.get(me);
                    compInd.getColumnSetA().add(newColumn);
                    anaBuilder.addElementToAnalyze(newColumn, indicator);
                    isExistSynedElement = true;
                }
            }
            ModelElement[] mesB = new ModelElement[compInd.getColumnSetB().size()];
            compInd.getColumnSetB().toArray(mesB);
            compInd.getColumnSetB().clear();
            for (ModelElement me : mesB) {
                if (synEleMap != null && synEleMap.get(me) != null) {
                    TdColumn newColumn = (TdColumn) synEleMap.get(me);
                    compInd.getColumnSetB().add(newColumn);
                    anaBuilder.addElementToAnalyze(newColumn, indicator);
                    isExistSynedElement = true;
                }
            }
            // Analyzed element(Table)
            ModelElement oldAnaEle = compInd.getAnalyzedElement();
            compInd.setAnalyzedElement(null);
            ColumnSet oldColSetA = ColumnHelper.getColumnOwnerAsColumnSet(mesA[0]);
            ColumnSet oldColSetB = ColumnHelper.getColumnOwnerAsColumnSet(mesB[0]);
            if (oldColSetA == oldAnaEle) {
                if (synEleMap != null && synEleMap.get(mesA[0]) != null) {
                    compInd.setAnalyzedElement(ColumnHelper.getColumnOwnerAsColumnSet(synEleMap.get(mesA[0])));
                }
            }
            if (oldColSetB == oldAnaEle) {
                if (synEleMap != null && synEleMap.get(mesB[0]) != null) {
                    compInd.setAnalyzedElement(ColumnHelper.getColumnOwnerAsColumnSet(synEleMap.get(mesB[0])));
                }
            }
        } else if (indicator instanceof ColumnDependencyIndicator) {
            // ADD qiongli bug 0012766
            // Functional Dependency indicator
            ColumnDependencyIndicator funDepInd = (ColumnDependencyIndicator) indicator;
            if (funDepInd.getColumnA() == null || funDepInd.getColumnB() == null) {
                return false;
            }
            // Column A
            if (synEleMap != null && synEleMap.get(funDepInd.getColumnA()) != null) {
                TdColumn newColumn = (TdColumn) synEleMap.get(funDepInd.getColumnA());
                funDepInd.setColumnA(newColumn);
                anaBuilder.addElementToAnalyze(newColumn, indicator);
                isExistSynedElement = true;
            }
            // Column B
            if (synEleMap != null && synEleMap.get(funDepInd.getColumnB()) != null) {
                TdColumn newColumn = (TdColumn) synEleMap.get(funDepInd.getColumnB());
                funDepInd.setColumnB(newColumn);
                anaBuilder.addElementToAnalyze(newColumn, indicator);
                isExistSynedElement = true;
            }
            // Analyzed element(Table)
            ModelElement oldAnaEle = funDepInd.getAnalyzedElement();
            funDepInd.setAnalyzedElement(null);
            ColumnSet oldColSetA = ColumnHelper.getColumnOwnerAsColumnSet(funDepInd.getColumnA());
            ColumnSet oldColSetB = ColumnHelper.getColumnOwnerAsColumnSet(funDepInd.getColumnB());
            if (oldColSetA == oldAnaEle) {
                if (synEleMap != null && synEleMap.get(funDepInd.getColumnA()) != null) {
                    funDepInd.setAnalyzedElement(ColumnHelper.getColumnOwnerAsColumnSet(synEleMap.get(funDepInd.getColumnA())));
                }
            }
            if (oldColSetB == oldAnaEle) {
                if (synEleMap != null && synEleMap.get(funDepInd.getColumnB()) != null) {
                    funDepInd.setAnalyzedElement(ColumnHelper.getColumnOwnerAsColumnSet(synEleMap.get(funDepInd.getColumnB())));
                }
            }
        } else {
            ModelElement me = indicator.getAnalyzedElement();
            if (synEleMap != null && synEleMap.get(me) != null) {
                indicator.setAnalyzedElement(synEleMap.get(me));
                if (analysisType == AnalysisType.MULTIPLE_COLUMN) {
                    synAnalysis.getResults().getIndicators().add(indicator);
                } else {
                    anaBuilder.addElementToAnalyze(synEleMap.get(me), indicator);
                }
                isExistSynedElement = true;
            }
        }
    }
    return isExistSynedElement;
}
Also used : AnalysisType(org.talend.dataquality.analysis.AnalysisType) ColumnDependencyIndicator(org.talend.dataquality.indicators.columnset.ColumnDependencyIndicator) ColumnSet(orgomg.cwm.resource.relational.ColumnSet) ColumnSetMultiValueIndicator(org.talend.dataquality.indicators.columnset.ColumnSetMultiValueIndicator) ColumnSetMultiValueIndicator(org.talend.dataquality.indicators.columnset.ColumnSetMultiValueIndicator) ColumnsCompareIndicator(org.talend.dataquality.indicators.columnset.ColumnsCompareIndicator) Indicator(org.talend.dataquality.indicators.Indicator) ColumnDependencyIndicator(org.talend.dataquality.indicators.columnset.ColumnDependencyIndicator) DataminingType(org.talend.dataquality.indicators.DataminingType) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) TdColumn(org.talend.cwm.relational.TdColumn) ColumnsCompareIndicator(org.talend.dataquality.indicators.columnset.ColumnsCompareIndicator) AnalysisBuilder(org.talend.dq.analysis.AnalysisBuilder)

Aggregations

DataminingType (org.talend.dataquality.indicators.DataminingType)19 TdColumn (org.talend.cwm.relational.TdColumn)8 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)8 ModelElementIndicator (org.talend.dataprofiler.core.model.ModelElementIndicator)6 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)5 Indicator (org.talend.dataquality.indicators.Indicator)4 Resource (org.eclipse.emf.ecore.resource.Resource)3 CCombo (org.eclipse.swt.custom.CCombo)3 TreeEditor (org.eclipse.swt.custom.TreeEditor)3 MouseAdapter (org.eclipse.swt.events.MouseAdapter)3 MouseEvent (org.eclipse.swt.events.MouseEvent)3 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 Label (org.eclipse.swt.widgets.Label)3 TreeItem (org.eclipse.swt.widgets.TreeItem)3 RepositoryNode (org.talend.repository.model.RepositoryNode)3 ArrayList (java.util.ArrayList)2 Connection (org.talend.core.model.metadata.builder.connection.Connection)2 ColumnsetFactory (org.talend.dataquality.indicators.columnset.ColumnsetFactory)2 IFolder (org.eclipse.core.resources.IFolder)1