Search in sources :

Example 1 with FrequencyExt

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

the class PieStatisticsState method getPieDataset.

@Override
public Object getPieDataset() {
    Map<String, Double> valueMap = new HashMap<String, Double>();
    for (IndicatorUnit unit : units) {
        if (unit.isExcuted()) {
            FrequencyExt[] frequencyExt = (FrequencyExt[]) unit.getValue();
            ComparatorsFactory.sort(frequencyExt, ComparatorsFactory.FREQUENCY_COMPARATOR_ID);
            int numOfShown = frequencyExt.length;
            for (int i = 0; i < numOfShown; i++) {
                FrequencyExt freqExt = frequencyExt[i];
                String keyLabel = PieStatisticsStateUtil.getkeyLabel(freqExt);
                Double percent = freqExt.getFrequency();
                valueMap.put(keyLabel, percent);
            }
        }
    }
    return TOPChartUtils.getInstance().createPieDataset(valueMap);
}
Also used : HashMap(java.util.HashMap) IndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit) FrequencyExt(org.talend.dq.indicators.ext.FrequencyExt)

Example 2 with FrequencyExt

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

the class FrequencyTypeStates method getCustomerDataset.

public ICustomerDataset getCustomerDataset() {
    CustomerDefaultCategoryDataset customerdataset = new CustomerDefaultCategoryDataset();
    boolean withRowCountIndicator = isWithRowCountIndicator();
    for (IndicatorUnit unit : units) {
        if (unit.isExcuted() && !this.isSupportDynamicChart) {
            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, 200);
                setValueToDataset(customerdataset, freqExt, keyLabel);
                ChartDataEntity entity = FrequencyTypeStateUtil.createChartEntity(unit.getIndicator(), freqExt, keyLabel, withRowCountIndicator);
                customerdataset.addDataEntity(entity);
            }
        } else {
            ChartDataEntity entity = FrequencyTypeStateUtil.createChartEntity(unit.getIndicator(), null, SpecialValueDisplay.EMPTY_FIELD, false);
            FrequencyExt fre = new FrequencyExt();
            fre.setValue(0l);
            fre.setFrequency(0d);
            setValueToDataset(customerdataset, fre, unit.getIndicatorName());
            customerdataset.addDataEntity(entity);
        }
    }
    return customerdataset;
}
Also used : IndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit) ChartDataEntity(org.talend.dq.indicators.preview.table.ChartDataEntity) CustomerDefaultCategoryDataset(org.talend.dataprofiler.common.ui.editor.preview.CustomerDefaultCategoryDataset) FrequencyExt(org.talend.dq.indicators.ext.FrequencyExt)

Example 3 with FrequencyExt

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

the class IndicatorCommonUtil method handleFreqPie.

/**
 * DOC qiongli Comment method "handleFreqPie".
 *
 * @param indicator
 * @return
 */
@SuppressWarnings("rawtypes")
private static Object handleFreqPie(Indicator indicator) {
    FrequencyExt[] frequencyExt = null;
    FormatFreqPieIndicator formatFreqIndicator = (FormatFreqPieIndicator) indicator;
    HashMap<Object, Long> valueToFreq = formatFreqIndicator.getValueToFreq();
    if (valueToFreq == null) {
        return null;
    }
    int i = 0;
    frequencyExt = new FrequencyExt[valueToFreq.size()];
    Iterator iter = valueToFreq.entrySet().iterator();
    while (iter.hasNext()) {
        Entry entry = (Entry) iter.next();
        frequencyExt[i] = new FrequencyExt();
        Object key = entry.getKey();
        long value = Long.valueOf(entry.getValue().toString());
        frequencyExt[i].setKey(key.toString());
        frequencyExt[i].setValue(value);
        frequencyExt[i].setFrequency(formatFreqIndicator.getFrequency(key));
        i++;
    }
    return frequencyExt;
}
Also used : Entry(java.util.Map.Entry) FormatFreqPieIndicator(org.talend.dataquality.indicators.FormatFreqPieIndicator) Iterator(java.util.Iterator) FrequencyExt(org.talend.dq.indicators.ext.FrequencyExt)

Example 4 with FrequencyExt

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

the class BenfordLawFrequencyStateUtil method recomputerForBenfordLaw.

public static FrequencyExt[] recomputerForBenfordLaw(FrequencyExt[] frequencyExt) {
    FrequencyExt[] tempFreq = frequencyExt;
    // get the sum
    double sum = 0d;
    for (FrequencyExt ext : frequencyExt) {
        sum += ext.getValue();
    }
    // set the values from count to percentage
    for (FrequencyExt ext : tempFreq) {
        ext.setFrequency(ext.getValue() / sum);
    }
    return tempFreq;
}
Also used : FrequencyExt(org.talend.dq.indicators.ext.FrequencyExt)

Example 5 with FrequencyExt

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

the class DateFrequencyStateUtil method getDataEntity.

public static ChartDataEntity[] getDataEntity(List<IndicatorUnit> units, int sortType) {
    List<ChartDataEntity> dataEnities = new ArrayList<ChartDataEntity>();
    for (IndicatorUnit unit : units) {
        if (unit.isExcuted()) {
            FrequencyExt[] frequencyExt = (FrequencyExt[]) unit.getValue();
            ComparatorsFactory.sort(frequencyExt, sortType);
            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(DateFrequencyStateUtil.createDataEntity(unit, freqExt, keyLabel));
            }
        }
    }
    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