Search in sources :

Example 11 with DataminingType

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

the class ColumnAnalysisDetailsPage method recomputeIndicators.

public void recomputeIndicators() {
    analysisHandler = new ModelElementAnalysisHandler();
    analysisHandler.setAnalysis(getCurrentModelElement());
    // Handle JUDIs
    UDIHelper.updateJUDIsForAnalysis(getCurrentModelElement());
    stringDataFilter = analysisHandler.getStringDataFilterwithContext();
    EList<ModelElement> analyzedColumns = analysisHandler.getAnalyzedColumns();
    List<ModelElementIndicator> meIndicatorList = new ArrayList<ModelElementIndicator>();
    ModelElementIndicator currentIndicator = null;
    for (ModelElement element : analyzedColumns) {
        TdColumn tdColumn = SwitchHelpers.COLUMN_SWITCH.doSwitch(element);
        // MOD qiongli 2011-1-10,16796:delimitefile
        MetadataColumn mdColumn = SwitchHelpers.METADATA_COLUMN_SWITCH.doSwitch(element);
        if (tdColumn == null && mdColumn == null) {
            continue;
        }
        // MOD qiongli TDQ-7052 if the node is filtered ,it will be return null,so should create a new node.
        RepositoryNode repNode = RepositoryNodeHelper.recursiveFind(element);
        if (repNode == null) {
            repNode = RepositoryNodeHelper.createRepositoryNode(element);
        }
        // MOD mzhao feature 15750, The column is recompute from the file, here create a new repository view object.
        if (tdColumn == null && mdColumn != null) {
            currentIndicator = ModelElementIndicatorHelper.createDFColumnIndicator(repNode);
        } else if (tdColumn != null) {
            currentIndicator = ModelElementIndicatorHelper.createModelElementIndicator(repNode);
        }
        DataminingType dataminingType = DataminingType.get(analysisHandler.getDatamingType(element));
        MetadataHelper.setDataminingType(dataminingType == null ? DataminingType.NOMINAL : dataminingType, element);
        Collection<Indicator> indicatorList = analysisHandler.getIndicators(element);
        if (currentIndicator != null) {
            currentIndicator.setIndicators(indicatorList.toArray(new Indicator[indicatorList.size()]));
            meIndicatorList.add(currentIndicator);
        }
    }
    currentModelElementIndicators = meIndicatorList.toArray(new ModelElementIndicator[meIndicatorList.size()]);
}
Also used : DataminingType(org.talend.dataquality.indicators.DataminingType) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) TdColumn(org.talend.cwm.relational.TdColumn) ModelElementAnalysisHandler(org.talend.dq.analysis.ModelElementAnalysisHandler) ArrayList(java.util.ArrayList) RepositoryNode(org.talend.repository.model.RepositoryNode) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator) UserDefIndicator(org.talend.dataquality.indicators.sql.UserDefIndicator) Indicator(org.talend.dataquality.indicators.Indicator) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Example 12 with DataminingType

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

the class CorrelationAnalysisDetailsPage method recomputeIndicators.

public void recomputeIndicators() {
    correlationAnalysisHandler = new ColumnCorrelationAnalysisHandler();
    correlationAnalysisHandler.setAnalysis(getCurrentModelElement());
    stringDataFilter = correlationAnalysisHandler.getStringDataFilter();
    analyzedColumns = correlationAnalysisHandler.getAnalyzedColumns();
    if (correlationAnalysisHandler.getIndicator() == null && columnSetMultiIndicator != null) {
        ColumnsetFactory columnsetFactory = ColumnsetFactory.eINSTANCE;
        // MOD qiongli 2010-6-18 bug 12766
        if (ColumnsetPackage.eINSTANCE.getCountAvgNullIndicator() == columnSetMultiIndicator.eClass()) {
            columnSetMultiIndicator = columnsetFactory.createCountAvgNullIndicator();
            // MOD xqliu 2010-04-06 bug 12161
            fillSimpleIndicators(columnSetMultiIndicator);
        // ~12161
        }
        if (ColumnsetPackage.eINSTANCE.getMinMaxDateIndicator() == columnSetMultiIndicator.eClass()) {
            columnSetMultiIndicator = columnsetFactory.createMinMaxDateIndicator();
        }
        if (ColumnsetPackage.eINSTANCE.getWeakCorrelationIndicator() == columnSetMultiIndicator.eClass()) {
            columnSetMultiIndicator = columnsetFactory.createWeakCorrelationIndicator();
        }
    } else {
        columnSetMultiIndicator = (ColumnSetMultiValueIndicator) correlationAnalysisHandler.getIndicator();
    }
    if (columnSetMultiIndicator == null) {
        columnSetMultiIndicator = ColumnsetFactory.eINSTANCE.createCountAvgNullIndicator();
    }
    initializeIndicator(columnSetMultiIndicator);
    columnSetMultiIndicator.setStoreData(true);
    for (ModelElement element : analyzedColumns) {
        TdColumn tdColumn = SwitchHelpers.COLUMN_SWITCH.doSwitch(element);
        if (tdColumn == null) {
            continue;
        }
        // currentColumnIndicator = new ColumnIndicator(tdColumn);
        DataminingType dataminingType = correlationAnalysisHandler.getDatamingType(tdColumn);
        MetadataHelper.setDataminingType(dataminingType == null ? DataminingType.NOMINAL : dataminingType, tdColumn);
    }
}
Also used : ColumnCorrelationAnalysisHandler(org.talend.dq.analysis.ColumnCorrelationAnalysisHandler) DataminingType(org.talend.dataquality.indicators.DataminingType) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) TdColumn(org.talend.cwm.relational.TdColumn) ColumnsetFactory(org.talend.dataquality.indicators.columnset.ColumnsetFactory)

Example 13 with DataminingType

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

the class ColumnSetAnalysisHandler method setDatamingType.

/**
 * Method "setDatamingType".
 *
 * @param dataminingTypeLiteral the literal expression of the datamining type used for the analysis
 * @param column a column
 */
public void setDatamingType(String dataminingTypeLiteral, TdColumn column) {
    DataminingType type = DataminingType.get(dataminingTypeLiteral);
    MetadataHelper.setDataminingType(type, column);
    Resource resource = column.eResource();
    if (resource != null) {
        // tell that the resource has been modified.
        resource.setModified(true);
    // it would be better to handle modifications with EMF Commands
    // this.modifiedResources.add(resource);
    }
}
Also used : DataminingType(org.talend.dataquality.indicators.DataminingType) Resource(org.eclipse.emf.ecore.resource.Resource)

Example 14 with DataminingType

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

the class AnalysisColumnNominalIntervalTreeViewer method addItemElements.

private void addItemElements(final List<IRepositoryNode> columns, int index) {
    for (int i = 0; i < columns.size(); i++) {
        final RepositoryNode columnNode = (RepositoryNode) columns.get(i);
        final TdColumn column = (TdColumn) ((MetadataColumnRepositoryObject) columnNode.getObject()).getTdColumn();
        final TreeItem treeItem = new TreeItem(tree, SWT.NONE, index);
        columnSetMultiValueList.add(index, columnNode);
        String columnName = column.getName();
        treeItem.setImage(ImageLib.getImage(ImageLib.TD_COLUMN));
        treeItem.setText(0, columnName != null ? columnName + PluginConstant.SPACE_STRING + PluginConstant.PARENTHESIS_LEFT + column.getSqlDataType().getName() + PluginConstant.PARENTHESIS_RIGHT : // $NON-NLS-1$
        "null");
        treeItem.setData(COLUMN_INDICATOR_KEY, columnNode);
        TreeEditor comboEditor = new TreeEditor(tree);
        // $NON-NLS-1$
        tree.setData(DefaultMessagesImpl.getString("AnalysisColumnNominalIntervalTreeViewer.TreeEditor"), comboEditor);
        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
        }
        DataminingType dataminingType = MetadataHelper.getDataminingType(column);
        if (dataminingType == null) {
            dataminingType = MetadataHelper.getDefaultDataminingType(column.getSqlDataType().getJavaDataType());
        }
        if (dataminingType == null) {
            combo.select(0);
        } else {
            combo.setText(dataminingType.getLiteral());
        }
        MetadataHelper.setDataminingType(DataminingType.get(combo.getText()), column);
        /**
         * DOC zhaoxinyi AnalysisColumnNominalIntervalTreeViewer class global comment. Detailled comment
         */
        class Selection extends SelectionAdapter {

            @Override
            public void widgetSelected(SelectionEvent e) {
                MetadataHelper.setDataminingType(DataminingType.get(combo.getText()), column);
                setDirty(true);
            }
        }
        combo.addSelectionListener(new Selection());
        // comboTextList.add(combo.getText().trim());
        combo.setEditable(false);
        comboEditor.minimumWidth = WIDTH1_CELL;
        comboEditor.setEditor(combo, treeItem, 1);
        TreeEditor delLabelEditor = new TreeEditor(tree);
        // $NON-NLS-1$
        Label delLabel = createTreeItemLabel(tree, ImageLib.DELETE_ACTION, "AnalysisColumnTreeViewer.delete");
        delLabel.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseDown(MouseEvent e) {
                deleteColumnItems(columnNode);
                removeItemBranch(treeItem);
                enabledButtons(false);
            // MOD mzhao 2005-05-05 bug 6587.
            // MOD mzhao 2009-06-8, bug 5887.
            // updateBindConnection(masterPage, tree);
            }
        });
        delLabelEditor.minimumWidth = delLabel.getImage().getBounds().width;
        delLabelEditor.horizontalAlignment = SWT.CENTER;
        delLabelEditor.setEditor(delLabel, treeItem, 2);
        treeItem.setData(ITEM_EDITOR_KEY, new TreeEditor[] { comboEditor, delLabelEditor });
        /*
             * if (columnIndicator.hasIndicators()) { createIndicatorItems(treeItem,
             * columnIndicator.getIndicatorUnits()); }
             */
        delLabelEditor.layout();
        treeItem.setExpanded(true);
    }
    tree.layout();
    tree.redraw();
    this.setDirty(true);
    tree.forceFocus();
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) TreeEditor(org.eclipse.swt.custom.TreeEditor) TreeItem(org.eclipse.swt.widgets.TreeItem) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) MouseAdapter(org.eclipse.swt.events.MouseAdapter) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) DataminingType(org.talend.dataquality.indicators.DataminingType) TdColumn(org.talend.cwm.relational.TdColumn) CCombo(org.eclipse.swt.custom.CCombo) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 15 with DataminingType

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

the class AnalysisColumnSetTreeViewer method addItemElements.

private void addItemElements(final ModelElementIndicator[] elements) {
    // MOD qiongli 2011-1-27,change TdColumn to MetadataColumn for supporting delimited file.
    for (ModelElementIndicator element2 : elements) {
        final ModelElementIndicator meIndicator = element2;
        final ModelElement modelElement = RepositoryNodeHelper.getSubModelElement(meIndicator.getModelElementRepositoryNode());
        final TreeItem treeItem = new TreeItem(tree, SWT.NONE);
        MetadataHelper.setDefaultDataminingType(modelElement);
        columnSetMultiValueList.add(meIndicator.getModelElementRepositoryNode());
        treeItem.setImage(ImageLib.getImage(ImageLib.TD_COLUMN));
        treeItem.setText(0, getModelElemetnDisplayName(meIndicator));
        treeItem.setData(COLUMN_INDICATOR_KEY, modelElement);
        treeItem.setData(MODELELEMENT_INDICATOR_KEY, meIndicator);
        // MOD mzhao feature 13040 , 2010-05-21
        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
        }
        DataminingType dataminingType = MetadataHelper.getDataminingType(modelElement);
        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");
        PatternMouseAdapter mouseAdapter = new PatternMouseAdapter(this, masterPage, meIndicator, treeItem);
        mouseAdapter.addFilter(new ViewerFilter() {

            @Override
            public boolean select(Viewer viewer, Object parentElement, Object element) {
                if (element instanceof IFolder) {
                    IFolder folder = (IFolder) element;
                    // $NON-NLS-1$
                    return !folder.getName().endsWith("SQL");
                }
                return true;
            }
        });
        addPatternLabl.addMouseListener(mouseAdapter);
        addPatternEditor.minimumWidth = addPatternLabl.getImage().getBounds().width;
        addPatternEditor.setEditor(addPatternLabl, treeItem, 2);
        TreeEditor delLabelEditor = new TreeEditor(tree);
        // $NON-NLS-1$
        Label delLabel = createTreeItemLabel(tree, ImageLib.DELETE_ACTION, "AnalysisColumnTreeViewer.delete");
        delLabel.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseDown(MouseEvent e) {
                deleteColumnItems(meIndicator.getModelElementRepositoryNode());
                if (treeItem.getParentItem() != null && treeItem.getParentItem().getData(INDICATOR_UNIT_KEY) != null) {
                    setElements(modelElementIndicators);
                } else {
                    deleteIndicatorItems(meIndicator);
                    removeItemBranch(treeItem);
                    enabledButtons(false);
                }
                notifyObservers();
            }
        });
        delLabelEditor.minimumWidth = delLabel.getImage().getBounds().width;
        delLabelEditor.horizontalAlignment = SWT.CENTER;
        delLabelEditor.setEditor(delLabel, treeItem, 3);
        treeItem.setData(ITEM_EDITOR_KEY, new TreeEditor[] { comboEditor, addPatternEditor, delLabelEditor });
        if (meIndicator.hasIndicators()) {
            createIndicatorItems(treeItem, meIndicator.getIndicatorUnits());
        }
        delLabelEditor.layout();
        treeItem.setExpanded(false);
    }
    tree.layout();
    tree.redraw();
    this.setDirty(true);
    tree.forceFocus();
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) TreeEditor(org.eclipse.swt.custom.TreeEditor) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) TreeItem(org.eclipse.swt.widgets.TreeItem) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) MouseAdapter(org.eclipse.swt.events.MouseAdapter) Viewer(org.eclipse.jface.viewers.Viewer) DataminingType(org.talend.dataquality.indicators.DataminingType) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) CCombo(org.eclipse.swt.custom.CCombo) SelectionEvent(org.eclipse.swt.events.SelectionEvent) EObject(org.eclipse.emf.ecore.EObject) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator) IFolder(org.eclipse.core.resources.IFolder)

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