Search in sources :

Example 6 with Indicator

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

the class OverviewResultPage method createResultSection.

@Override
protected void createResultSection(Composite parent) {
    statisticalSection = this.createSection(form, parent, DefaultMessagesImpl.getString("ConnectionMasterDetailsPage.statisticalinformations"), // $NON-NLS-1$
    null);
    Composite sectionClient = toolkit.createComposite(statisticalSection);
    sectionClient.setLayout(new GridLayout());
    catalogTableViewer = new TableViewer(sectionClient, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
    Table catalogTable = catalogTableViewer.getTable();
    TableUtils.addActionTooltip(catalogTable);
    catalogTable.setHeaderVisible(true);
    catalogTable.setBackgroundMode(SWT.INHERIT_FORCE);
    catalogTable.setLinesVisible(true);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(catalogTable);
    List<Catalog> catalogs = getCatalogs();
    boolean containSubSchema = false;
    for (Catalog catalog : catalogs) {
        List<Schema> schemas = CatalogHelper.getSchemas(catalog);
        if (schemas.size() > 0) {
            containSubSchema = true;
            break;
        }
    }
    if (catalogs.size() > 0 && containSubSchema) {
        createCatalogSchemaColumns(catalogTable);
        provider = new CatalogSchemaViewerProvier();
        addColumnSorters(catalogTableViewer, catalogTable.getColumns(), catalogWithSchemaSorters);
        createSchemaTableViewer(sectionClient);
        schemaTableViewer.addSelectionChangedListener(new DisplayTableAndViewListener());
        catalogTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {

            public void selectionChanged(SelectionChangedEvent event) {
                StructuredSelection selection = (StructuredSelection) event.getSelection();
                OverviewIndUIElement firstElement = (OverviewIndUIElement) selection.getFirstElement();
                List<OverviewIndUIElement> cataUIEleList = new ArrayList<OverviewIndUIElement>();
                if (firstElement != null) {
                    Indicator overviewIndicator = firstElement.getOverviewIndicator();
                    // selection.getFirstElement();
                    CatalogIndicator catalogIndicator = (CatalogIndicator) overviewIndicator;
                    // MOD qiongli bug 13093,2010-7-2,
                    // selection.getFirstElement();
                    currentCatalogIndicator = (SchemaIndicator) overviewIndicator;
                    // MOD xqliu 2009-11-30 bug 9114
                    if (catalogIndicator != null) {
                        EList<SchemaIndicator> schemaIndicators = catalogIndicator.getSchemaIndicators();
                        for (SchemaIndicator schemaIndicator : schemaIndicators) {
                            RepositoryNode schemaNode = RepositoryNodeHelper.recursiveFind(schemaIndicator.getAnalyzedElement());
                            OverviewIndUIElement cataUIEle = new OverviewIndUIElement();
                            cataUIEle.setNode(schemaNode);
                            cataUIEle.setOverviewIndicator(schemaIndicator);
                            cataUIEleList.add(cataUIEle);
                        }
                        schemaTableViewer.setInput(cataUIEleList);
                        schemaTableViewer.getTable().setVisible(true);
                        addColumnSorters(schemaTableViewer, schemaTableViewer.getTable().getColumns(), schemaSorters);
                    }
                }
            // ~
            }
        });
        createContextMenuFor(schemaTableViewer);
    } else {
        if (catalogs.size() > 0) {
            createCatalogTableColumns(catalogTable);
            provider = new CatalogViewerProvier();
        } else {
            createSchemaTableColumns(catalogTable);
            provider = new SchemaViewerProvier();
        }
        addColumnSorters(catalogTableViewer, catalogTable.getColumns(), schemaSorters);
        catalogTableViewer.addSelectionChangedListener(new DisplayTableAndViewListener());
    }
    catalogTableViewer.setLabelProvider(provider);
    catalogTableViewer.setContentProvider(provider);
    doSetInput();
    tableAndViewComposite = new Composite(sectionClient, SWT.NONE);
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(tableAndViewComposite);
    GridLayout layout = new GridLayout(2, false);
    layout.marginWidth = 0;
    layout.horizontalSpacing = 50;
    tableAndViewComposite.setLayout(layout);
    tableAndViewComposite.setVisible(false);
    sectionClient.layout();
    statisticalSection.setClient(sectionClient);
    createContextMenuFor(catalogTableViewer);
}
Also used : SchemaIndicator(org.talend.dataquality.indicators.schema.SchemaIndicator) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) Schema(orgomg.cwm.resource.relational.Schema) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) CatalogIndicator(org.talend.dataquality.indicators.schema.CatalogIndicator) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Catalog(orgomg.cwm.resource.relational.Catalog) CatalogIndicator(org.talend.dataquality.indicators.schema.CatalogIndicator) SchemaIndicator(org.talend.dataquality.indicators.schema.SchemaIndicator) Indicator(org.talend.dataquality.indicators.Indicator) TableIndicator(org.talend.dataquality.indicators.schema.TableIndicator) ViewIndicator(org.talend.dataquality.indicators.schema.ViewIndicator) GridLayout(org.eclipse.swt.layout.GridLayout) EList(org.eclipse.emf.common.util.EList) OverviewIndUIElement(org.talend.dataprofiler.core.model.OverviewIndUIElement) List(java.util.List) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 7 with Indicator

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

the class RedundancyAnalysisDetailsPage method initialize.

@Override
public void initialize(FormEditor editor) {
    super.initialize(editor);
    // MOD xqliu 2009-06-10 bug7334
    stringDataFilterA = AnalysisHelper.getStringDataFilter(getCurrentModelElement(), 0);
    stringDataFilterB = AnalysisHelper.getStringDataFilter(getCurrentModelElement(), 1);
    // ~
    if (getCurrentModelElement().getResults().getIndicators().size() == 0) {
        ColumnsetFactory factory = ColumnsetFactory.eINSTANCE;
        rowMatchingIndicatorA = factory.createRowMatchingIndicator();
        rowMatchingIndicatorB = factory.createRowMatchingIndicator();
        Indicator[] currentIndicators = new Indicator[] { rowMatchingIndicatorA, rowMatchingIndicatorB };
        setDefaultIndDef(currentIndicators);
    } else {
        EList<Indicator> indicators = getCurrentModelElement().getResults().getIndicators();
        rowMatchingIndicatorA = (RowMatchingIndicator) indicators.get(0);
        rowMatchingIndicatorB = (RowMatchingIndicator) indicators.get(1);
    }
}
Also used : ColumnsetFactory(org.talend.dataquality.indicators.columnset.ColumnsetFactory) Indicator(org.talend.dataquality.indicators.Indicator) RowMatchingIndicator(org.talend.dataquality.indicators.columnset.RowMatchingIndicator)

Example 8 with Indicator

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

the class RedundancyAnalysisResultPage method createAnalyzedColumnSetsSection.

private void createAnalyzedColumnSetsSection(Composite parent) {
    columnSetSection = createSection(form, parent, DefaultMessagesImpl.getString("ColumnsComparisonAnalysisResultPage.analyzedColumnSets"), // $NON-NLS-1$
    null);
    Composite sectionClient = toolkit.createComposite(columnSetSection);
    sectionClient.setLayout(new GridLayout());
    sectionClient.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    TableViewer elementsTableViewer = new TableViewer(sectionClient, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    Table table = elementsTableViewer.getTable();
    GridDataFactory.fillDefaults().applyTo(table);
    ((GridData) table.getLayoutData()).heightHint = 240;
    ((GridData) table.getLayoutData()).widthHint = 600;
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    table.setDragDetect(true);
    // $NON-NLS-1$
    table.setToolTipText(DefaultMessagesImpl.getString("ColumnsComparisonAnalysisResultPage.dragAndDropToolTip"));
    final TableColumn columnHeader1 = new TableColumn(table, SWT.LEAD);
    columnHeader1.setWidth(300);
    final TableColumn columnHeader2 = new TableColumn(table, SWT.LEAD);
    columnHeader2.setWidth(300);
    Analysis analysis = this.masterPage.getAnalysisHandler().getAnalysis();
    isHasDeactivatedIndicator = analysis.getParameters().getDeactivatedIndicators().size() != 0;
    EList<Indicator> indicators = analysis.getResults().getIndicators();
    if (indicators.size() != 0) {
        rowMatchingIndicatorA = (RowMatchingIndicator) indicators.get(0);
        rowMatchingIndicatorB = (RowMatchingIndicator) indicators.get(1);
        TdColumn columnA = null;
        if (rowMatchingIndicatorA.getColumnSetA().size() > 0) {
            columnA = rowMatchingIndicatorA.getColumnSetA().get(0);
            if (columnA.eIsProxy()) {
                columnA = (TdColumn) EObjectHelper.resolveObject(columnA);
            }
        }
        String columnName = rowMatchingIndicatorA.getColumnSetA().size() > 0 ? ColumnHelper.getColumnOwnerAsColumnSet(columnA).getName() : PluginConstant.EMPTY_STRING;
        columnHeader1.setText(columnName.equals(PluginConstant.EMPTY_STRING) ? columnName : DefaultMessagesImpl.getString("ColumnsComparisonAnalysisResultPage.elementsFrom", // $NON-NLS-1$
        columnName));
        TdColumn columnB = null;
        if (rowMatchingIndicatorA.getColumnSetB().size() > 0) {
            columnB = rowMatchingIndicatorA.getColumnSetB().get(0);
            if (columnB.eIsProxy()) {
                columnB = (TdColumn) EObjectHelper.resolveObject(columnB);
            }
        }
        columnName = rowMatchingIndicatorA.getColumnSetA().size() > 0 ? ColumnHelper.getColumnOwnerAsColumnSet(columnB).getName() : PluginConstant.EMPTY_STRING;
        columnHeader2.setText(columnName.equals(PluginConstant.EMPTY_STRING) ? columnName : DefaultMessagesImpl.getString("ColumnsComparisonAnalysisResultPage.elementsFrom", // $NON-NLS-1$
        columnName));
    }
    ColumnPairsViewerProvider provider = new ColumnPairsViewerProvider();
    elementsTableViewer.setContentProvider(provider);
    elementsTableViewer.setLabelProvider(provider);
    elementsTableViewer.setInput(rowMatchingIndicatorA);
    columnSetSection.setClient(sectionClient);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Table(org.eclipse.swt.widgets.Table) TdColumn(org.talend.cwm.relational.TdColumn) Composite(org.eclipse.swt.widgets.Composite) Analysis(org.talend.dataquality.analysis.Analysis) GridData(org.eclipse.swt.layout.GridData) TableViewer(org.eclipse.jface.viewers.TableViewer) TableColumn(org.eclipse.swt.widgets.TableColumn) Indicator(org.talend.dataquality.indicators.Indicator) RowMatchingIndicator(org.talend.dataquality.indicators.columnset.RowMatchingIndicator)

Example 9 with Indicator

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

the class ResultPaginationInfo method createChart.

/**
 * DOC bZhou Comment method "createChart".
 *
 * @param comp
 * @param chartType
 * @param units
 */
private void createChart(Composite comp, EIndicatorChartType chartType, List<IndicatorUnit> units) {
    DynamicIndicatorModel dyModel = new DynamicIndicatorModel();
    // MOD TDQ-8787 20140618 yyin: to let the chart and table use the same dataset
    Object chart = null;
    Object dataset = null;
    // Added TDQ-8787 20140722 yyin:(when first switch from master to result) if there is some dynamic event for the
    // current indicator, use its dataset directly (TDQ-9241)
    IEventReceiver event = EventManager.getInstance().findRegisteredEvent(units.get(0).getIndicator(), EventEnum.DQ_DYMANIC_CHART, 0);
    // get the dataset from the event
    if (event != null) {
        dataset = ((DynamicChartEventReceiver) event).getDataset();
    }
    // ~
    // Added TDQ-8787 2014-06-18 yyin: add the current units and dataset into the list
    List<Indicator> indicators = null;
    dyModel.setChartType(chartType);
    this.dynamicList.add(dyModel);
    if (EIndicatorChartType.SUMMARY_STATISTICS.equals(chartType)) {
        // for the summary indicators, the table show 2 more than the bar chart
        dyModel.setSummaryIndicators(getIndicatorsForTable(units, true));
    }
    // create UI
    ExpandableComposite subComp = uiPagination.getToolkit().createExpandableComposite(comp, ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT | ExpandableComposite.EXPANDED);
    subComp.setText(chartType.getLiteral());
    subComp.setLayoutData(new GridData(GridData.FILL_BOTH));
    // MOD xqliu 2009-06-23 bug 7481
    subComp.setExpanded(EditorPreferencePage.isUnfoldingIndicatorsResultPage());
    // ~
    final Composite composite = uiPagination.getToolkit().createComposite(subComp, SWT.NULL);
    composite.setLayout(new GridLayout(2, false));
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    Analysis analysis = masterPage.getAnalysisHandler().getAnalysis();
    // create table viewer firstly
    ITableTypeStates tableTypeState = TableTypeStatesFactory.getInstance().getTableState(chartType, units);
    ChartDataEntity[] dataEntities = tableTypeState.getDataEntity();
    TableWithData chartData = new TableWithData(chartType, dataEntities);
    TableViewer tableviewer = tableTypeState.getTableForm(composite);
    tableviewer.setInput(chartData);
    tableviewer.getTable().pack();
    dyModel.setTableViewer(tableviewer);
    DataExplorer dataExplorer = tableTypeState.getDataExplorer();
    ChartTableFactory.addMenuAndTip(tableviewer, dataExplorer, analysis);
    if (EIndicatorChartType.TEXT_STATISTICS.equals(chartType) && dataEntities != null && dataEntities.length > 0) {
        // only text indicator need
        indicators = getIndicators(dataEntities);
    } else {
        indicators = getIndicators(units);
    }
    dyModel.setIndicatorList(indicators);
    // create chart
    try {
        if (!EditorPreferencePage.isHideGraphicsForResultPage() && TOPChartUtils.getInstance().isTOPChartInstalled()) {
            IChartTypeStates chartTypeState = ChartTypeStatesFactory.getChartState(chartType, units);
            boolean isPattern = chartTypeState instanceof PatternStatisticsState;
            if (event == null) {
                chart = chartTypeState.getChart();
                if (chart != null && isSQLMode) {
                    // chart is null for MODE. Get the dataset by this way for SQL mode
                    if (EIndicatorChartType.BENFORD_LAW_STATISTICS.equals(chartType)) {
                        dataset = TOPChartUtils.getInstance().getDatasetFromChart(chart, 2);
                        if (dataset == null) {
                            dataset = TOPChartUtils.getInstance().getDatasetFromChart(chart, 1);
                        }
                        dyModel.setSecondDataset(TOPChartUtils.getInstance().getDatasetFromChart(chart, 0));
                    } else {
                        dataset = TOPChartUtils.getInstance().getDatasetFromChart(chart, 1);
                        if (dataset == null) {
                            dataset = TOPChartUtils.getInstance().getDatasetFromChart(chart, -1);
                        }
                    }
                }
            } else {
                chart = chartTypeState.getChart(dataset);
            }
            dyModel.setDataset(dataset);
            if (chart != null) {
                if (!isPattern) {
                    // need not to decorate the chart of Pattern(Regex/Sql/UdiMatch)
                    TOPChartUtils.getInstance().decorateChart(chart, false);
                } else {
                    TOPChartUtils.getInstance().decoratePatternMatching(chart);
                }
                Object chartComposite = TOPChartUtils.getInstance().createTalendChartComposite(composite, SWT.NONE, chart, true);
                dyModel.setBawParentChartComp(chartComposite);
                Map<String, Object> menuMap = createMenuForAllDataEntity((Composite) chartComposite, dataExplorer, analysis, ((ICustomerDataset) chartTypeState.getDataset()).getDataEntities());
                // call chart service to create related mouse listener
                if (EIndicatorChartType.BENFORD_LAW_STATISTICS.equals(chartType) || EIndicatorChartType.FREQUENCE_STATISTICS.equals(chartType)) {
                    TOPChartUtils.getInstance().addMouseListenerForChart(chartComposite, menuMap, false);
                } else {
                    TOPChartUtils.getInstance().addMouseListenerForChart(chartComposite, menuMap, true);
                }
            }
        }
    // TDQ-11886 add these 2 catches.make it continue to work even if encounter some problems.
    } catch (Error e) {
        // $NON-NLS-1$
        log.error(DefaultMessagesImpl.getString("IndicatorPaginationInfo.FailToCreateChart"), e);
    } catch (Exception exp) {
        // $NON-NLS-1$
        log.error(DefaultMessagesImpl.getString("IndicatorPaginationInfo.FailToCreateChart"), exp);
    }
    subComp.setClient(composite);
    subComp.addExpansionListener(new ExpansionAdapter() {

        @Override
        public void expansionStateChanged(ExpansionEvent e) {
            form.reflow(true);
        }
    });
    masterPage.registerSection(subComp);
}
Also used : IEventReceiver(org.talend.dataprofiler.core.ui.events.IEventReceiver) DataExplorer(org.talend.dq.analysis.explore.DataExplorer) TableWithData(org.talend.dataprofiler.core.ui.editor.preview.model.TableWithData) GridLayout(org.eclipse.swt.layout.GridLayout) DynamicIndicatorModel(org.talend.dataprofiler.core.model.dynamic.DynamicIndicatorModel) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ChartDataEntity(org.talend.dq.indicators.preview.table.ChartDataEntity) ExpansionAdapter(org.eclipse.ui.forms.events.ExpansionAdapter) Indicator(org.talend.dataquality.indicators.Indicator) CompositeIndicator(org.talend.dataprofiler.core.ui.editor.preview.CompositeIndicator) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator) IChartTypeStates(org.talend.dataprofiler.core.ui.editor.preview.model.states.IChartTypeStates) ITableTypeStates(org.talend.dataprofiler.core.ui.editor.preview.model.states.table.ITableTypeStates) Analysis(org.talend.dataquality.analysis.Analysis) GridData(org.eclipse.swt.layout.GridData) PatternStatisticsState(org.talend.dataprofiler.core.ui.editor.preview.model.states.pattern.PatternStatisticsState) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) TableViewer(org.eclipse.jface.viewers.TableViewer) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent)

Example 10 with Indicator

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

the class BusinessRuleAnalysisResultPage method registerDynamicEvent.

/**
 * Added TDQ-8787 20140613 yyin: create all charts before running, register each chart with its related indicator.
 */
public void registerDynamicEvent() {
    // register dynamic event,for the indicator (for each column)
    for (DynamicIndicatorModel oneCategoryIndicatorModel : dynamicList) {
        Object categoryDataset = oneCategoryIndicatorModel.getDataset();
        TableViewer tableViewer = oneCategoryIndicatorModel.getTableViewer();
        int index = 0;
        for (Indicator oneIndicator : oneCategoryIndicatorModel.getIndicatorList()) {
            TableDynamicChartEventReceiver eReceiver = new TableDynamicChartEventReceiver();
            eReceiver.setDataset(categoryDataset);
            eReceiver.setIndexInDataset(index++);
            eReceiver.setIndicatorName(oneIndicator.getName());
            eReceiver.setIndicator(oneIndicator);
            eReceiver.setIndicatorType(IndicatorEnum.findIndicatorEnum(oneIndicator.eClass()));
            eReceiver.setChartComposite(sectionClient);
            eReceiver.setTableViewer(tableViewer);
            // clear data
            eReceiver.clearValue();
            registerIndicatorEvent(oneIndicator, eReceiver);
        }
    }
    reLayoutChartComposite();
    registerRefreshDynamicChartEvent();
}
Also used : TableDynamicChartEventReceiver(org.talend.dataprofiler.core.ui.events.TableDynamicChartEventReceiver) DynamicIndicatorModel(org.talend.dataprofiler.core.model.dynamic.DynamicIndicatorModel) TableViewer(org.eclipse.jface.viewers.TableViewer) CompositeIndicator(org.talend.dataprofiler.core.ui.editor.preview.CompositeIndicator) Indicator(org.talend.dataquality.indicators.Indicator) TableIndicator(org.talend.dataprofiler.core.model.TableIndicator)

Aggregations

Indicator (org.talend.dataquality.indicators.Indicator)178 ArrayList (java.util.ArrayList)58 RowCountIndicator (org.talend.dataquality.indicators.RowCountIndicator)40 CompositeIndicator (org.talend.dataquality.indicators.CompositeIndicator)31 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)31 ModelElementIndicator (org.talend.dataprofiler.core.model.ModelElementIndicator)28 Analysis (org.talend.dataquality.analysis.Analysis)27 DuplicateCountIndicator (org.talend.dataquality.indicators.DuplicateCountIndicator)27 UniqueCountIndicator (org.talend.dataquality.indicators.UniqueCountIndicator)27 AllMatchIndicator (org.talend.dataquality.indicators.columnset.AllMatchIndicator)26 ReturnCode (org.talend.utils.sugars.ReturnCode)25 SimpleStatIndicator (org.talend.dataquality.indicators.columnset.SimpleStatIndicator)24 UserDefIndicator (org.talend.dataquality.indicators.sql.UserDefIndicator)24 PatternMatchingIndicator (org.talend.dataquality.indicators.PatternMatchingIndicator)23 DistinctCountIndicator (org.talend.dataquality.indicators.DistinctCountIndicator)22 NullCountIndicator (org.talend.dataquality.indicators.NullCountIndicator)22 TdColumn (org.talend.cwm.relational.TdColumn)20 WhereRuleIndicator (org.talend.dataquality.indicators.sql.WhereRuleIndicator)18 FrequencyIndicator (org.talend.dataquality.indicators.FrequencyIndicator)17 Test (org.junit.Test)16