Search in sources :

Example 1 with DynamicChartEventReceiver

use of org.talend.dataprofiler.core.ui.events.DynamicChartEventReceiver 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 DynamicChartEventReceiver

use of org.talend.dataprofiler.core.ui.events.DynamicChartEventReceiver 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 3 with DynamicChartEventReceiver

use of org.talend.dataprofiler.core.ui.events.DynamicChartEventReceiver in project tdq-studio-se by Talend.

the class ColumnAnalysisResultPage method unRegisterDynamicEvent.

/**
 * unregister every dynamic events which registered before executing analysis
 *
 * @param eventReceivers
 */
public void unRegisterDynamicEvent() {
    EventManager.getInstance().clearEvent(masterPage.getCurrentModelElement(), EventEnum.DQ_DYNAMIC_SWITCH_MASTER_RESULT_PAGE);
    for (Indicator oneIndicator : eventReceivers.keySet()) {
        DynamicChartEventReceiver eventReceiver = (DynamicChartEventReceiver) eventReceivers.get(oneIndicator);
        eventReceiver.clear();
        EventManager.getInstance().clearEvent(oneIndicator, EventEnum.DQ_DYMANIC_CHART);
    }
    eventReceivers.clear();
    EventManager.getInstance().clearEvent(chartComposite, EventEnum.DQ_DYNAMIC_REFRESH_DYNAMIC_CHART);
    if (uiPagination != null) {
        uiPagination.clearAllDynamicMapOfCurrentPage();
    }
    masterPage.clearDynamicDatasets();
}
Also used : DynamicChartEventReceiver(org.talend.dataprofiler.core.ui.events.DynamicChartEventReceiver) Indicator(org.talend.dataquality.indicators.Indicator) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Example 4 with DynamicChartEventReceiver

use of org.talend.dataprofiler.core.ui.events.DynamicChartEventReceiver in project tdq-studio-se by Talend.

the class AnalysisUtils method createDynamicBAWChartEventReceiver.

/**
 * DOC yyin Comment method "createDynamicBAWChartEventReceiver".
 *
 * @param oneCategoryIndicatorModel
 * @param categoryDataset
 * @return
 */
public static DynamicBAWChartEventReceiver createDynamicBAWChartEventReceiver(DynamicIndicatorModel oneCategoryIndicatorModel, Map<Indicator, EventReceiver> eventReceivers) {
    DynamicBAWChartEventReceiver bawReceiver = new DynamicBAWChartEventReceiver();
    Object categoryDataset = oneCategoryIndicatorModel.getDataset();
    if (categoryDataset instanceof CustomerDefaultBAWDataset) {
        // all summary selected
        bawReceiver.setBawDataset((CustomerDefaultBAWDataset) categoryDataset);
    } else {
        // not-all summary selected
        bawReceiver.setDataset(categoryDataset);
    }
    bawReceiver.setBAWparentComposite(oneCategoryIndicatorModel.getBawParentChartComp());
    bawReceiver.setTableViewer(oneCategoryIndicatorModel.getTableViewer());
    int index = 0;
    int length = oneCategoryIndicatorModel.getSummaryIndicators().size();
    for (Indicator oneIndicator : oneCategoryIndicatorModel.getSummaryIndicators()) {
        DynamicChartEventReceiver eReceiver = bawReceiver.createEventReceiver(IndicatorEnum.findIndicatorEnum(oneIndicator.eClass()), oneIndicator);
        eReceiver.setTableViewer(oneCategoryIndicatorModel.getTableViewer());
        eReceiver.setEntityIndex(index++);
        if (SummaryStatisticsState.FULL_FLAG != length) {
            eReceiver.setDataset(categoryDataset);
        }
        eReceiver.clearValue();
        eventReceivers.put(oneIndicator, eReceiver);
        EventManager.getInstance().register(oneIndicator, EventEnum.DQ_DYMANIC_CHART, eReceiver);
    }
    bawReceiver.clearValue();
    return bawReceiver;
}
Also used : DynamicChartEventReceiver(org.talend.dataprofiler.core.ui.events.DynamicChartEventReceiver) BenfordFrequencyDynamicChartEventReceiver(org.talend.dataprofiler.core.ui.events.BenfordFrequencyDynamicChartEventReceiver) PatternDynamicChartEventReceiver(org.talend.dataprofiler.core.ui.events.PatternDynamicChartEventReceiver) FrequencyDynamicChartEventReceiver(org.talend.dataprofiler.core.ui.events.FrequencyDynamicChartEventReceiver) CustomerDefaultBAWDataset(org.talend.dataprofiler.core.ui.editor.preview.model.dataset.CustomerDefaultBAWDataset) Indicator(org.talend.dataquality.indicators.Indicator) DynamicBAWChartEventReceiver(org.talend.dataprofiler.core.ui.events.DynamicBAWChartEventReceiver)

Example 5 with DynamicChartEventReceiver

use of org.talend.dataprofiler.core.ui.events.DynamicChartEventReceiver in project tdq-studio-se by Talend.

the class AnalysisUtils method createDynamicChartEventReceiver.

/**
 * create a DynamicChart Event Receiver, according to its type
 *
 * @param categoryDataset
 * @param index
 * @param oneIndicator
 * @param eIndicatorChartType
 * @return
 */
public static DynamicChartEventReceiver createDynamicChartEventReceiver(DynamicIndicatorModel indicatorModel, int index, Indicator oneIndicator) {
    DynamicChartEventReceiver eReceiver = null;
    if (isBenford(indicatorModel.getChartType())) {
        eReceiver = new BenfordFrequencyDynamicChartEventReceiver();
        ((BenfordFrequencyDynamicChartEventReceiver) eReceiver).setSecondDataset(indicatorModel.getSecondDataset());
    } else if (isFrequency(indicatorModel.getChartType())) {
        // TDQ-12870, should clear the last result
        oneIndicator.setCount(0l);
        eReceiver = new FrequencyDynamicChartEventReceiver();
    } else if (isPattern(indicatorModel.getChartType())) {
        eReceiver = new PatternDynamicChartEventReceiver();
    } else {
        eReceiver = new DynamicChartEventReceiver();
    }
    eReceiver.setDataset(indicatorModel.getDataset());
    eReceiver.setIndexInDataset(index);
    eReceiver.setIndicatorName(oneIndicator.getName());
    eReceiver.setIndicator(oneIndicator);
    return eReceiver;
}
Also used : BenfordFrequencyDynamicChartEventReceiver(org.talend.dataprofiler.core.ui.events.BenfordFrequencyDynamicChartEventReceiver) BenfordFrequencyDynamicChartEventReceiver(org.talend.dataprofiler.core.ui.events.BenfordFrequencyDynamicChartEventReceiver) FrequencyDynamicChartEventReceiver(org.talend.dataprofiler.core.ui.events.FrequencyDynamicChartEventReceiver) PatternDynamicChartEventReceiver(org.talend.dataprofiler.core.ui.events.PatternDynamicChartEventReceiver) DynamicChartEventReceiver(org.talend.dataprofiler.core.ui.events.DynamicChartEventReceiver) BenfordFrequencyDynamicChartEventReceiver(org.talend.dataprofiler.core.ui.events.BenfordFrequencyDynamicChartEventReceiver) PatternDynamicChartEventReceiver(org.talend.dataprofiler.core.ui.events.PatternDynamicChartEventReceiver) FrequencyDynamicChartEventReceiver(org.talend.dataprofiler.core.ui.events.FrequencyDynamicChartEventReceiver)

Aggregations

DynamicChartEventReceiver (org.talend.dataprofiler.core.ui.events.DynamicChartEventReceiver)8 Indicator (org.talend.dataquality.indicators.Indicator)7 DynamicIndicatorModel (org.talend.dataprofiler.core.model.dynamic.DynamicIndicatorModel)4 ModelElementIndicator (org.talend.dataprofiler.core.model.ModelElementIndicator)3 DynamicBAWChartEventReceiver (org.talend.dataprofiler.core.ui.events.DynamicBAWChartEventReceiver)3 CompositeIndicator (org.talend.dataprofiler.core.ui.editor.preview.CompositeIndicator)2 BenfordFrequencyDynamicChartEventReceiver (org.talend.dataprofiler.core.ui.events.BenfordFrequencyDynamicChartEventReceiver)2 FrequencyDynamicChartEventReceiver (org.talend.dataprofiler.core.ui.events.FrequencyDynamicChartEventReceiver)2 PatternDynamicChartEventReceiver (org.talend.dataprofiler.core.ui.events.PatternDynamicChartEventReceiver)2 TableViewer (org.eclipse.jface.viewers.TableViewer)1 TableIndicator (org.talend.dataprofiler.core.model.TableIndicator)1 CustomerDefaultBAWDataset (org.talend.dataprofiler.core.ui.editor.preview.model.dataset.CustomerDefaultBAWDataset)1 IChartTypeStates (org.talend.dataprofiler.core.ui.editor.preview.model.states.IChartTypeStates)1 PatternStatisticsState (org.talend.dataprofiler.core.ui.editor.preview.model.states.pattern.PatternStatisticsState)1 IEventReceiver (org.talend.dataprofiler.core.ui.events.IEventReceiver)1 TableDynamicChartEventReceiver (org.talend.dataprofiler.core.ui.events.TableDynamicChartEventReceiver)1