Search in sources :

Example 1 with PatternChartDataEntity

use of org.talend.dq.indicators.preview.table.PatternChartDataEntity in project tdq-studio-se by Talend.

the class FunctionalDependencyAnalysisResultPage method createTable.

/**
 * DOC xqliu Comment method "createTable".
 *
 * @param composite
 */
private void createTable(Composite composite) {
    final TableViewer tableViewer = new TableViewer(composite, SWT.FULL_SELECTION | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    Table resultTable = tableViewer.getTable();
    resultTable.setLinesVisible(true);
    resultTable.setHeaderVisible(true);
    // create table headers
    TableStructureEntity tableStructure = getTableStructure();
    String[] fieldNames = tableStructure.getFieldNames();
    Integer[] fieldWidths = tableStructure.getFieldWidths();
    for (int i = 0; i < fieldNames.length; ++i) {
        TableColumn columnHeader = new TableColumn(resultTable, SWT.LEFT);
        columnHeader.setText(fieldNames[i]);
        columnHeader.setWidth(fieldWidths[i]);
    }
    // create table items
    CustomerDefaultCategoryDataset dataset = initCustomerDataset();
    ChartDataEntity[] dataEntities = dataset.getDataEntities();
    if (dataEntities != null) {
        // MOD mzhao bug 8839 There might be duplicate dependencies on left and right columnSet.
        if (canShowChartForResultPage() && TOPChartUtils.getInstance().getColumnCount(dataset.getDataset()) < dataEntities.length) {
            // $NON-NLS-1$
            MessageDialog.openError(// $NON-NLS-1$
            this.getEditor().getSite().getShell(), // $NON-NLS-1$
            "Duplicate dependencies", // $NON-NLS-1$
            "There might be duplicate dependencies on left and right columnSet.");
        } else {
            for (ChartDataEntity dataEntity : dataEntities) {
                TableItem item = new TableItem(resultTable, SWT.NULL);
                String numMatch = ((PatternChartDataEntity) dataEntity).getNumMatch();
                String numNoMatch = ((PatternChartDataEntity) dataEntity).getNumNoMatch();
                Number match = Long.parseLong(numMatch);
                Number notMatch = Long.parseLong(numNoMatch);
                Number row = match.intValue() + notMatch.intValue();
                item.setText(0, dataEntity.getLabel());
                item.setText(1, String.valueOf(match.intValue()));
                // TDQ-8695 display "N/A" if it is infinite or NaN
                double percentage = match.doubleValue() / row.doubleValue();
                if (Double.isNaN(percentage) || Double.isInfinite(percentage)) {
                    item.setText(2, PluginConstant.NA_STRING);
                } else {
                    item.setText(2, StringFormatUtil.format(String.valueOf(percentage), StringFormatUtil.PERCENT).toString());
                }
                item.setText(3, String.valueOf(row));
                item.setData(dataEntity);
            }
        }
    }
    GridData gd = new GridData();
    gd.heightHint = 180;
    gd.widthHint = 450;
    resultTable.setLayoutData(gd);
    // add menus
    ChartTableFactory.addMenuAndTip(tableViewer, new ColumnDependencyExplorer(), this.masterPage.getCurrentModelElement());
}
Also used : Table(org.eclipse.swt.widgets.Table) TableItem(org.eclipse.swt.widgets.TableItem) TableStructureEntity(org.talend.dataprofiler.core.ui.editor.preview.model.entity.TableStructureEntity) PatternChartDataEntity(org.talend.dq.indicators.preview.table.PatternChartDataEntity) ChartDataEntity(org.talend.dq.indicators.preview.table.ChartDataEntity) TableColumn(org.eclipse.swt.widgets.TableColumn) CustomerDefaultCategoryDataset(org.talend.dataprofiler.common.ui.editor.preview.CustomerDefaultCategoryDataset) PatternChartDataEntity(org.talend.dq.indicators.preview.table.PatternChartDataEntity) GridData(org.eclipse.swt.layout.GridData) ColumnDependencyExplorer(org.talend.dq.analysis.explore.ColumnDependencyExplorer) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 2 with PatternChartDataEntity

use of org.talend.dq.indicators.preview.table.PatternChartDataEntity in project tdq-studio-se by Talend.

the class FunctionalDependencyAnalysisResultPage method initCustomerDataset.

/**
 * DOC xqliu Comment method "initCustomerDataset".
 *
 * @return
 */
private CustomerDefaultCategoryDataset initCustomerDataset() {
    CustomerDefaultCategoryDataset dataset = new CustomerDefaultCategoryDataset();
    Analysis analysis = this.getAnalysisHandler().getAnalysis();
    for (Indicator indicator2 : analysis.getResults().getIndicators()) {
        ColumnDependencyIndicator indicator = (ColumnDependencyIndicator) indicator2;
        String label = ColumnDependencyHelper.getIndicatorName(indicator);
        if (getAnalysisHandler().getResultMetadata().getExecutionNumber() > 0) {
            Long matchCount = indicator.getDistinctACount() == null ? 0 : indicator.getDistinctACount();
            Long notMatchCount = indicator.getACount() == null ? 0 : indicator.getACount() - matchCount;
            // $NON-NLS-1$
            dataset.addValue(matchCount, DefaultMessagesImpl.getString("ColumnDependencyResultPage.Match"), label);
            // $NON-NLS-1$
            dataset.addValue(notMatchCount, DefaultMessagesImpl.getString("ColumnDependencyResultPage.NotMatch"), label);
            PatternChartDataEntity dataEntity = new PatternChartDataEntity();
            dataEntity.setLabel(label);
            dataEntity.setIndicator(indicator);
            dataEntity.setNumMatch(matchCount.toString());
            dataEntity.setNumNoMatch(notMatchCount.toString());
            dataset.addDataEntity(dataEntity);
        }
    }
    return dataset;
}
Also used : ColumnDependencyIndicator(org.talend.dataquality.indicators.columnset.ColumnDependencyIndicator) PatternChartDataEntity(org.talend.dq.indicators.preview.table.PatternChartDataEntity) Analysis(org.talend.dataquality.analysis.Analysis) CustomerDefaultCategoryDataset(org.talend.dataprofiler.common.ui.editor.preview.CustomerDefaultCategoryDataset) Indicator(org.talend.dataquality.indicators.Indicator) ColumnDependencyIndicator(org.talend.dataquality.indicators.columnset.ColumnDependencyIndicator)

Example 3 with PatternChartDataEntity

use of org.talend.dq.indicators.preview.table.PatternChartDataEntity in project tdq-studio-se by Talend.

the class PatternStatisticsTableState method getDataEntity.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dataprofiler.core.ui.editor.preview.model.states.table.AbstractTableTypeStates#getDataEntity()
     */
@Override
public ChartDataEntity[] getDataEntity() {
    List<ChartDataEntity> dataEnities = new ArrayList<ChartDataEntity>();
    for (IndicatorUnit unit : units) {
        PatternMatchingExt patternExt = PatternStatisticeStateUtil.getUnitValue(unit.getIndicator(), unit.getValue());
        String notMathCount = PatternStatisticeStateUtil.getNotMatchCount(patternExt);
        String machCount = PatternStatisticeStateUtil.getMatchCount(patternExt);
        PatternChartDataEntity patternEntity = PatternStatisticeStateUtil.createDataEntity(unit, unit.getIndicator().getName(), notMathCount, machCount);
        dataEnities.add(patternEntity);
    }
    return dataEnities.toArray(new ChartDataEntity[dataEnities.size()]);
}
Also used : PatternChartDataEntity(org.talend.dq.indicators.preview.table.PatternChartDataEntity) ArrayList(java.util.ArrayList) IndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit) PatternMatchingExt(org.talend.dq.indicators.ext.PatternMatchingExt) PatternChartDataEntity(org.talend.dq.indicators.preview.table.PatternChartDataEntity) ChartDataEntity(org.talend.dq.indicators.preview.table.ChartDataEntity)

Example 4 with PatternChartDataEntity

use of org.talend.dq.indicators.preview.table.PatternChartDataEntity in project tdq-studio-se by Talend.

the class PatternStatisticsState method getCustomerDataset.

public ICustomerDataset getCustomerDataset() {
    CustomerDefaultCategoryDataset customerdataset = new CustomerDefaultCategoryDataset();
    for (IndicatorUnit unit : units) {
        String label = unit.getIndicator().getName();
        PatternMatchingExt patternExt = PatternStatisticeStateUtil.getUnitValue(unit.getIndicator(), unit.getValue());
        String notMathCount = PatternStatisticeStateUtil.getNotMatchCount(patternExt);
        String machCount = PatternStatisticeStateUtil.getMatchCount(patternExt);
        customerdataset.addValue(Double.parseDouble(notMathCount), DefaultMessagesImpl.getString("PatternStatisticsState.NotMatching"), // $NON-NLS-1$
        label);
        customerdataset.addValue(Double.parseDouble(machCount), DefaultMessagesImpl.getString("PatternStatisticsState.Matching"), // $NON-NLS-1$
        label);
        PatternChartDataEntity patternEntity = PatternStatisticeStateUtil.createDataEntity(unit, label, notMathCount, machCount);
        customerdataset.addDataEntity(patternEntity);
    }
    return customerdataset;
}
Also used : PatternChartDataEntity(org.talend.dq.indicators.preview.table.PatternChartDataEntity) IndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit) PatternMatchingExt(org.talend.dq.indicators.ext.PatternMatchingExt) CustomerDefaultCategoryDataset(org.talend.dataprofiler.common.ui.editor.preview.CustomerDefaultCategoryDataset)

Example 5 with PatternChartDataEntity

use of org.talend.dq.indicators.preview.table.PatternChartDataEntity in project tdq-studio-se by Talend.

the class PatternDynamicChartEventReceiver method refreshPatternTable.

private void refreshPatternTable(PatternMatchingExt matchExt) {
    TableWithData input = (TableWithData) tableViewer.getInput();
    if (input != null) {
        ChartDataEntity[] dataEntities = input.getEnity();
        if (dataEntities != null && dataEntities.length > getIndexInDataset()) {
            ((PatternChartDataEntity) dataEntities[getIndexInDataset()]).setNumMatch(String.valueOf(matchExt.getMatchingValueCount()));
            ((PatternChartDataEntity) dataEntities[getIndexInDataset()]).setNumNoMatch(String.valueOf(matchExt.getNotMatchingValueCount()));
            tableViewer.getTable().clearAll();
            tableViewer.setInput(input);
        }
    }
}
Also used : PatternChartDataEntity(org.talend.dq.indicators.preview.table.PatternChartDataEntity) TableWithData(org.talend.dataprofiler.core.ui.editor.preview.model.TableWithData) PatternChartDataEntity(org.talend.dq.indicators.preview.table.PatternChartDataEntity) ChartDataEntity(org.talend.dq.indicators.preview.table.ChartDataEntity)

Aggregations

PatternChartDataEntity (org.talend.dq.indicators.preview.table.PatternChartDataEntity)8 CustomerDefaultCategoryDataset (org.talend.dataprofiler.common.ui.editor.preview.CustomerDefaultCategoryDataset)4 ChartDataEntity (org.talend.dq.indicators.preview.table.ChartDataEntity)4 IndicatorUnit (org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit)2 TableWithData (org.talend.dataprofiler.core.ui.editor.preview.model.TableWithData)2 PatternMatchingExt (org.talend.dq.indicators.ext.PatternMatchingExt)2 ArrayList (java.util.ArrayList)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 GridData (org.eclipse.swt.layout.GridData)1 Table (org.eclipse.swt.widgets.Table)1 TableColumn (org.eclipse.swt.widgets.TableColumn)1 TableItem (org.eclipse.swt.widgets.TableItem)1 TableStructureEntity (org.talend.dataprofiler.core.ui.editor.preview.model.entity.TableStructureEntity)1 Analysis (org.talend.dataquality.analysis.Analysis)1 Indicator (org.talend.dataquality.indicators.Indicator)1 ColumnDependencyIndicator (org.talend.dataquality.indicators.columnset.ColumnDependencyIndicator)1 ColumnDependencyExplorer (org.talend.dq.analysis.explore.ColumnDependencyExplorer)1 RowMatchExplorer (org.talend.dq.analysis.explore.RowMatchExplorer)1