Search in sources :

Example 1 with DynamicIndicatorModel

use of org.talend.dataprofiler.core.model.dynamic.DynamicIndicatorModel in project tdq-studio-se by Talend.

the class MasterPaginationInfo method createChart.

/**
 * DOC bZhou Comment method "createChart".
 *
 * @param comp
 * @param chartType
 * @param units
 */
private void createChart(Composite comp, EIndicatorChartType chartType, List<IndicatorUnit> units) {
    final IChartTypeStates chartTypeState = ChartTypeStatesFactory.getChartState(chartType, units);
    boolean isPattern = chartTypeState instanceof PatternStatisticsState;
    Object chart = null;
    try {
        // MOD 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);
        if (event == null) {
            chart = chartTypeState.getChart();
        } else {
            chart = chartTypeState.getChart(((DynamicChartEventReceiver) event).getDataset());
        }
        if (chart == null) {
            return;
        }
        if (!isPattern) {
            // need not to decorate the chart of Pattern(Regex/Sql/UdiMatch)
            TOPChartUtils.getInstance().decorateChart(chart, false);
        } else {
            TOPChartUtils.getInstance().decoratePatternMatching(chart);
        }
        Object chartComp = TOPChartUtils.getInstance().createChartComposite(comp, SWT.NONE, chart, true);
        addListenerToChartComp(chartComp, chartTypeState);
        List<Indicator> indicators = getIndicators(units);
        if (isSQLMode) {
            // use the dynamic model for SQL mode only.
            DynamicIndicatorModel dyModel = AnalysisUtils.createDynamicModel(chartType, indicators, chart);
            if (EIndicatorChartType.SUMMARY_STATISTICS.equals(chartType)) {
                if (units.size() == SummaryStatisticsState.FULL_FLAG) {
                    indicators = getIndicatorsForTable(units, false);
                }
                dyModel.setSummaryIndicators(indicators);
            }
            this.dynamicList.add(dyModel);
            if (EIndicatorChartType.SUMMARY_STATISTICS.equals(chartType)) {
                // for summary indicators: need to record the chart composite, which is used for create BAW chart
                dyModel.setBawParentChartComp(chartComp);
            }
        }
    } 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);
    }
}
Also used : IEventReceiver(org.talend.dataprofiler.core.ui.events.IEventReceiver) PatternStatisticsState(org.talend.dataprofiler.core.ui.editor.preview.model.states.pattern.PatternStatisticsState) DynamicChartEventReceiver(org.talend.dataprofiler.core.ui.events.DynamicChartEventReceiver) DynamicIndicatorModel(org.talend.dataprofiler.core.model.dynamic.DynamicIndicatorModel) 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)

Example 2 with DynamicIndicatorModel

use of org.talend.dataprofiler.core.model.dynamic.DynamicIndicatorModel 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 3 with DynamicIndicatorModel

use of org.talend.dataprofiler.core.model.dynamic.DynamicIndicatorModel 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)

Example 4 with DynamicIndicatorModel

use of org.talend.dataprofiler.core.model.dynamic.DynamicIndicatorModel in project tdq-studio-se by Talend.

the class ColumnAnalysisResultPage method registerDynamicEvent.

/**
 * Added TDQ-8787 20140613 yyin: create all charts before running, register each chart with its related indicator.
 */
public void registerDynamicEvent() {
    // get all indicators and datasets
    List<DynamicIndicatorModel> indiAndDatasets = uiPagination.getAllIndcatorAndDatasetOfCurrentPage();
    // register dynamic event,for the indicator (for each column)
    for (DynamicIndicatorModel oneCategoryIndicatorModel : indiAndDatasets) {
        TableViewer tableViewer = oneCategoryIndicatorModel.getTableViewer();
        if (EIndicatorChartType.SUMMARY_STATISTICS.equals(oneCategoryIndicatorModel.getChartType())) {
            // when all/not-all summary indicators are selected
            DynamicBAWChartEventReceiver bawReceiver = AnalysisUtils.createDynamicBAWChartEventReceiver(oneCategoryIndicatorModel, eventReceivers);
            bawReceiver.setChartComposite(chartComposite);
            bawReceiver.setParentChartComposite((Composite) oneCategoryIndicatorModel.getBawParentChartComp());
            bawReceiver.refreshChart();
            bawReceiver.setTableViewer(tableViewer);
        // no need to register the parent baw receiver with one of summary indicator, no need to handle baw
        // actually
        } else {
            int index = 0;
            for (Indicator oneIndicator : oneCategoryIndicatorModel.getIndicatorList()) {
                DynamicChartEventReceiver eReceiver = AnalysisUtils.createDynamicChartEventReceiver(oneCategoryIndicatorModel, index++, oneIndicator);
                eReceiver.setChartComposite(chartComposite);
                eReceiver.refreshChart();
                eReceiver.setTableViewer(tableViewer);
                // clear data
                eReceiver.clearValue();
                registerIndicatorEvent(oneIndicator, eReceiver);
            }
        }
    }
    reLayoutChartComposite();
    registerOtherDynamicEvent();
}
Also used : DynamicChartEventReceiver(org.talend.dataprofiler.core.ui.events.DynamicChartEventReceiver) DynamicIndicatorModel(org.talend.dataprofiler.core.model.dynamic.DynamicIndicatorModel) TableViewer(org.eclipse.jface.viewers.TableViewer) Indicator(org.talend.dataquality.indicators.Indicator) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator) DynamicBAWChartEventReceiver(org.talend.dataprofiler.core.ui.events.DynamicBAWChartEventReceiver)

Example 5 with DynamicIndicatorModel

use of org.talend.dataprofiler.core.model.dynamic.DynamicIndicatorModel in project tdq-studio-se by Talend.

the class AnalysisUtils method createDynamicModel.

/**
 * create a Dynamic Model for one category of indicators, who related to the same chart.
 *
 * @param chartType
 * @param indicators
 * @param chart
 * @return
 */
public static DynamicIndicatorModel createDynamicModel(EIndicatorChartType chartType, List<Indicator> indicators, Object chart) {
    DynamicIndicatorModel dyModel = new DynamicIndicatorModel();
    // one dataset <--> several indicators in same category
    if (chart != null) {
        Object dataset = TOPChartUtils.getInstance().getDatasetFromChart(chart, -1);
        // Added TDQ-8787 20140612 : store the dataset, and the index of the current indicator
        if (EIndicatorChartType.BENFORD_LAW_STATISTICS.equals(chartType)) {
            dataset = TOPChartUtils.getInstance().getDatasetFromChart(chart, 1);
            dyModel.setSecondDataset(TOPChartUtils.getInstance().getDatasetFromChart(chart, 0));
        }
        dyModel.setDataset(dataset);
    }
    dyModel.setIndicatorList(indicators);
    dyModel.setChartType(chartType);
    return dyModel;
}
Also used : DynamicIndicatorModel(org.talend.dataprofiler.core.model.dynamic.DynamicIndicatorModel)

Aggregations

DynamicIndicatorModel (org.talend.dataprofiler.core.model.dynamic.DynamicIndicatorModel)9 Indicator (org.talend.dataquality.indicators.Indicator)8 CompositeIndicator (org.talend.dataprofiler.core.ui.editor.preview.CompositeIndicator)6 TableViewer (org.eclipse.jface.viewers.TableViewer)4 TableIndicator (org.talend.dataprofiler.core.model.TableIndicator)4 IChartTypeStates (org.talend.dataprofiler.core.ui.editor.preview.model.states.IChartTypeStates)4 DynamicChartEventReceiver (org.talend.dataprofiler.core.ui.events.DynamicChartEventReceiver)4 IEventReceiver (org.talend.dataprofiler.core.ui.events.IEventReceiver)4 GridData (org.eclipse.swt.layout.GridData)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 Composite (org.eclipse.swt.widgets.Composite)3 ExpansionAdapter (org.eclipse.ui.forms.events.ExpansionAdapter)3 ExpansionEvent (org.eclipse.ui.forms.events.ExpansionEvent)3 ExpandableComposite (org.eclipse.ui.forms.widgets.ExpandableComposite)3 ModelElementIndicator (org.talend.dataprofiler.core.model.ModelElementIndicator)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Map (java.util.Map)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2