Search in sources :

Example 6 with FrequencyExt

use of org.talend.dq.indicators.ext.FrequencyExt in project tdq-studio-se by Talend.

the class FrequencyDynamicChartEventReceiver method setFrequecyToDataset.

private void setFrequecyToDataset(Object customerdataset, FrequencyExt[] frequencyExt, Indicator indicator) {
    int numOfShown = frequencyExt.length;
    IndicatorParameters parameters = indicator.getParameters();
    if (parameters != null) {
        if (parameters.getTopN() < numOfShown) {
            numOfShown = parameters.getTopN();
        }
    }
    FrequencyExt[] tempFreq = handleFrequency(frequencyExt);
    clearDataEntity(customerdataset);
    boolean withRowCountIndicator = FrequencyTypeStateUtil.isWithRowCountIndicator(indicator);
    // Added TDQ-12870
    List columnKeys = TOPChartUtils.getInstance().getColumnKeys(customerdataset);
    FrequencyExt freqE = tempFreq[0];
    if (!columnKeys.contains(String.valueOf(freqE.getKey()))) {
        // columnKeys.clear();
        TOPChartUtils.getInstance().clearDataset(customerdataset);
        ICustomerDataset customerDataset = TOPChartUtils.getInstance().getCustomerDataset(customerdataset);
        if (customerDataset != null && customerDataset instanceof CustomerDefaultCategoryDataset) {
            ((CustomerDefaultCategoryDataset) customerDataset).clearAll();
        }
    }
    for (int i = 0; i < numOfShown; i++) {
        FrequencyExt freqExt = tempFreq[i];
        String keyLabel = String.valueOf(freqExt.getKey());
        if ("null".equals(keyLabel)) {
            // $NON-NLS-1$
            keyLabel = SpecialValueDisplay.NULL_FIELD;
        }
        if ("".equals(keyLabel)) {
            // $NON-NLS-1$
            keyLabel = SpecialValueDisplay.EMPTY_FIELD;
        }
        ChartDataEntity entity = FrequencyTypeStateUtil.createChartEntity(indicator, freqExt, keyLabel, withRowCountIndicator);
        if (customerdataset instanceof CustomerDefaultCategoryDataset) {
            ((CustomerDefaultCategoryDataset) customerdataset).addDataEntity(entity);
            addValueToDataset(((CustomerDefaultCategoryDataset) customerdataset).getDataset(), freqExt, keyLabel);
        } else {
            ICustomerDataset customerDataset = TOPChartUtils.getInstance().getCustomerDataset(customerdataset);
            if (customerDataset != null && customerDataset instanceof CustomerDefaultCategoryDataset) {
                customerDataset.addDataEntity(entity);
                addValueToDataset(((CustomerDefaultCategoryDataset) customerDataset).getDataset(), freqExt, keyLabel);
            }
        }
    }
}
Also used : IndicatorParameters(org.talend.dataquality.indicators.IndicatorParameters) ArrayList(java.util.ArrayList) List(java.util.List) ChartDataEntity(org.talend.dq.indicators.preview.table.ChartDataEntity) FrequencyExt(org.talend.dq.indicators.ext.FrequencyExt) CustomerDefaultCategoryDataset(org.talend.dataprofiler.common.ui.editor.preview.CustomerDefaultCategoryDataset) ICustomerDataset(org.talend.dataprofiler.common.ui.editor.preview.ICustomerDataset)

Example 7 with FrequencyExt

use of org.talend.dq.indicators.ext.FrequencyExt in project tdq-studio-se by Talend.

the class PieStatisticsTableState 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) {
        if (unit.isExcuted()) {
            FrequencyExt[] frequencyExt = (FrequencyExt[]) unit.getValue();
            int numOfShown = PieStatisticsStateUtil.getNumberOfShown(unit, frequencyExt);
            for (int i = 0; i < numOfShown; i++) {
                FrequencyExt freqExt = frequencyExt[i];
                ChartDataEntity entity = PieStatisticsStateUtil.createDataEntity(unit, freqExt, PieStatisticsStateUtil.getkeyLabel(freqExt));
                dataEnities.add(entity);
            }
        }
    }
    return dataEnities.toArray(new ChartDataEntity[dataEnities.size()]);
}
Also used : ArrayList(java.util.ArrayList) IndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit) ChartDataEntity(org.talend.dq.indicators.preview.table.ChartDataEntity) FrequencyExt(org.talend.dq.indicators.ext.FrequencyExt)

Example 8 with FrequencyExt

use of org.talend.dq.indicators.ext.FrequencyExt in project tdq-studio-se by Talend.

the class IndicatorCommonUtil method handleFrequency.

/**
 * DOC xqliu Comment method "handleFrequency".
 *
 * @param indicator
 * @return
 */
private static Object handleFrequency(Indicator indicator) {
    FrequencyExt[] frequencyExt = null;
    if (UDIHelper.isUDI(indicator)) {
        UserDefIndicator udi = (UserDefIndicator) indicator;
        Set<Object> valueSet = udi.getDistinctValues();
        if (valueSet == null) {
            return null;
        }
        frequencyExt = new FrequencyExt[valueSet.size()];
        int i = 0;
        for (Object o : valueSet) {
            frequencyExt[i] = new FrequencyExt();
            frequencyExt[i].setKey(o);
            frequencyExt[i].setValue(udi.getCount(o));
            frequencyExt[i].setFrequency(udi.getFrequency(o));
            i++;
        }
    } else if (IndicatorEnum.DatePatternFreqIndicatorEnum.getIndicatorType().isInstance(indicator)) {
        DatePatternFreqIndicator datePatternFrequency = (DatePatternFreqIndicator) indicator;
        Map<String, Long> results = datePatternFrequency.getResult();
        frequencyExt = new FrequencyExt[results.size()];
        int i = 0;
        for (String key : results.keySet()) {
            Long value = results.get(key);
            Double frequency = datePatternFrequency.getFrequency(key);
            frequencyExt[i] = new FrequencyExt();
            frequencyExt[i].setKey(key);
            frequencyExt[i].setValue(value);
            frequencyExt[i].setFrequency(frequency);
            i++;
        }
    } else {
        FrequencyIndicator frequency = (FrequencyIndicator) indicator;
        Set<Object> valueSet = frequency.getDistinctValues();
        if (valueSet == null) {
            return null;
        }
        frequencyExt = new FrequencyExt[valueSet.size()];
        int i = 0;
        for (Object o : valueSet) {
            frequencyExt[i] = new FrequencyExt();
            frequencyExt[i].setKey(o);
            if (IndicatorsPackage.eINSTANCE.getSoundexFreqIndicator().equals(frequency.eClass()) || IndicatorsPackage.eINSTANCE.getSoundexLowFreqIndicator().equals(frequency.eClass())) {
                // MOD scorreia 2009-03-23 display distinct count when working with Soundex
                frequencyExt[i].setValue(((SoundexFreqIndicator) frequency).getDistinctCount(o));
            } else {
                frequencyExt[i].setValue(frequency.getCount(o));
            }
            frequencyExt[i].setFrequency(frequency.getFrequency(o));
            i++;
        }
    }
    return frequencyExt;
}
Also used : Set(java.util.Set) SoundexFreqIndicator(org.talend.dataquality.indicators.SoundexFreqIndicator) FrequencyIndicator(org.talend.dataquality.indicators.FrequencyIndicator) DatePatternFreqIndicator(org.talend.dataquality.indicators.DatePatternFreqIndicator) FrequencyExt(org.talend.dq.indicators.ext.FrequencyExt) UserDefIndicator(org.talend.dataquality.indicators.sql.UserDefIndicator) Map(java.util.Map) HashMap(java.util.HashMap)

Example 9 with FrequencyExt

use of org.talend.dq.indicators.ext.FrequencyExt in project tdq-studio-se by Talend.

the class FrequencyDynamicChartEventReceiver method handle.

@Override
public boolean handle(Object value) {
    Object indValue = value;
    if (value == null) {
        indValue = 0;
    }
    if (dataset != null) {
        // no sort needed here
        if (indValue instanceof FrequencyExt[]) {
            FrequencyExt[] frequencyExt = (FrequencyExt[]) indValue;
            setFrequecyToDataset(dataset, frequencyExt, indicator);
        }
    }
    if (tableViewer != null && dataset != null) {
        TableWithData input = (TableWithData) tableViewer.getInput();
        if (input != null) {
            if (this.indicator instanceof ModeIndicator) {
                ChartDataEntity entity = new ChartDataEntity();
                entity.setIndicator(indicator);
                entity.setLabel(this.indicatorName);
                entity.setValue(String.valueOf(indValue));
                // mode indicator has not a chart so that no dataset too
                input.setEntities(new ChartDataEntity[] { entity });
            } else {
                ICustomerDataset customerDataset = TOPChartUtils.getInstance().getCustomerDataset(dataset);
                if (customerDataset != null) {
                    input.setEntities((customerDataset).getDataEntities());
                } else {
                    input.setEntities(((ICustomerDataset) dataset).getDataEntities());
                }
            }
        }
        if (!tableViewer.getTable().isDisposed()) {
            tableViewer.getTable().clearAll();
            tableViewer.setInput(input);
        }
    }
    if (registerChart != TOPChartUtils.getInstance().getChartFromChartComposite(parentChartComposite)) {
        restoreChart();
    }
    // need to refresh the parent composite of the chart to show the changes
    if (!(indicator instanceof ModeIndicator)) {
        EventManager.getInstance().publish(chartComposite, EventEnum.DQ_DYNAMIC_REFRESH_DYNAMIC_CHART, null);
    }
    return true;
}
Also used : TableWithData(org.talend.dataprofiler.core.ui.editor.preview.model.TableWithData) ChartDataEntity(org.talend.dq.indicators.preview.table.ChartDataEntity) ModeIndicator(org.talend.dataquality.indicators.ModeIndicator) FrequencyExt(org.talend.dq.indicators.ext.FrequencyExt) ICustomerDataset(org.talend.dataprofiler.common.ui.editor.preview.ICustomerDataset)

Example 10 with FrequencyExt

use of org.talend.dq.indicators.ext.FrequencyExt in project tdq-studio-se by Talend.

the class FrequencyTableState 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>();
    boolean withRowCountIndicator = isWithRowCountIndicator();
    for (IndicatorUnit unit : units) {
        if (unit.isExcuted()) {
            FrequencyExt[] frequencyExt = (FrequencyExt[]) unit.getValue();
            sortIndicator(frequencyExt);
            int numOfShown = FrequencyTypeStateUtil.getNumberOfShown(unit, frequencyExt);
            for (int i = 0; i < numOfShown; i++) {
                FrequencyExt freqExt = frequencyExt[i];
                String keyLabel = FrequencyTypeStateUtil.getKeyLabel(freqExt, 30);
                dataEnities.add(FrequencyTypeStateUtil.createChartEntity(unit.getIndicator(), freqExt, keyLabel, withRowCountIndicator));
            }
        } else {
        // TDQ-11422: before analysis run turn to Analysis Results page, there should show nothing data
        // dataEnities.add(FrequencyTypeStateUtil.createChartEntity(unit.getIndicator(), null, null, false));
        }
    }
    return dataEnities.toArray(new ChartDataEntity[dataEnities.size()]);
}
Also used : ArrayList(java.util.ArrayList) IndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit) ChartDataEntity(org.talend.dq.indicators.preview.table.ChartDataEntity) FrequencyExt(org.talend.dq.indicators.ext.FrequencyExt)

Aggregations

FrequencyExt (org.talend.dq.indicators.ext.FrequencyExt)16 ChartDataEntity (org.talend.dq.indicators.preview.table.ChartDataEntity)8 IndicatorUnit (org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit)7 CustomerDefaultCategoryDataset (org.talend.dataprofiler.common.ui.editor.preview.CustomerDefaultCategoryDataset)5 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 HashMap (java.util.HashMap)2 ICustomerDataset (org.talend.dataprofiler.common.ui.editor.preview.ICustomerDataset)2 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Set (java.util.Set)1 TableWithData (org.talend.dataprofiler.core.ui.editor.preview.model.TableWithData)1 DatePatternFreqIndicator (org.talend.dataquality.indicators.DatePatternFreqIndicator)1 FormatFreqPieIndicator (org.talend.dataquality.indicators.FormatFreqPieIndicator)1 FrequencyIndicator (org.talend.dataquality.indicators.FrequencyIndicator)1 IndicatorParameters (org.talend.dataquality.indicators.IndicatorParameters)1 ModeIndicator (org.talend.dataquality.indicators.ModeIndicator)1 SoundexFreqIndicator (org.talend.dataquality.indicators.SoundexFreqIndicator)1