Search in sources :

Example 11 with FrequencyExt

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

the class DateFrequencyStateUtil method getCustomerDataset.

public static ICustomerDataset getCustomerDataset(List<IndicatorUnit> units, int sortType) {
    CustomerDefaultCategoryDataset customerdataset = new CustomerDefaultCategoryDataset();
    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);
                customerdataset.addValue(freqExt.getValue(), unit.getIndicatorName(), keyLabel);
                ChartDataEntity entity = createDataEntity(unit, freqExt, keyLabel);
                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 12 with FrequencyExt

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

the class BenfordLawFrequencyStateTest method testSortIndicator.

/**
 * Test method for
 * {@link org.talend.dataprofiler.core.ui.editor.preview.model.states.freq.BenfordLawFrequencyState#sortIndicator(org.talend.dq.indicators.ext.FrequencyExt[])}
 * . just test normal cases: contains 1~9
 */
@SuppressWarnings("deprecation")
@Test
public void testSortIndicator() {
    FrequencyExt[] frequencyExt = new FrequencyExt[9];
    Long value = 100l;
    for (int i = 0; i < 9; i++) {
        frequencyExt[i] = new FrequencyExt();
        frequencyExt[i].setKey(i + 1);
        frequencyExt[i].setValue(value);
        if (i > 4) {
            value = value * 2;
        } else {
            value = value / 2;
        }
    }
    benState.sortIndicator(frequencyExt);
    for (int i = 0; i < 8; i++) {
        // Assert.assertTrue(frequencyExt[i].getValue() > frequencyExt[i + 1].getValue());
        Assert.assertTrue(NumberUtils.stringToInt(frequencyExt[i].getKey().toString()) < NumberUtils.stringToInt(frequencyExt[i + 1].getKey().toString()));
    }
}
Also used : FrequencyExt(org.talend.dq.indicators.ext.FrequencyExt) Test(org.junit.Test)

Example 13 with FrequencyExt

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

the class BenfordLawFrequencyStateTest method testSetValueToDataset.

/**
 * Test method for
 * {@link org.talend.dataprofiler.core.ui.editor.preview.model.states.freq.BenfordLawFrequencyState#setValueToDataset(org.talend.dataprofiler.core.ui.editor.preview.model.dataset.CustomerDefaultCategoryDataset, org.talend.dq.indicators.ext.FrequencyExt, java.lang.String)}
 * .
 */
@Test
public void testSetValueToDataset() {
    CustomerDefaultCategoryDataset customerdataset = new CustomerDefaultCategoryDataset();
    FrequencyExt fre = new FrequencyExt();
    fre.setKey(2);
    fre.setValue(3l);
    fre.setFrequency(0.33);
    // $NON-NLS-1$
    benState.setValueToDataset(customerdataset, fre, "2");
    Number n = TOPChartUtils.getInstance().getValue(customerdataset.getDataset(), 0, 0);
    Assert.assertEquals(0.33, n);
}
Also used : CustomerDefaultCategoryDataset(org.talend.dataprofiler.common.ui.editor.preview.CustomerDefaultCategoryDataset) FrequencyExt(org.talend.dq.indicators.ext.FrequencyExt) Test(org.junit.Test)

Example 14 with FrequencyExt

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

the class ComparatorsFactoryTest method testSortObject_1.

/**
 * Test method for {@link org.talend.dataprofiler.core.ui.utils.ComparatorsFactory#sort(java.lang.Object[], int)}.
 */
@Test
public void testSortObject_1() {
    FrequencyExt[] frequencyExt = new FrequencyExt[9];
    Long value = 100l;
    for (int i = 0; i < 9; i++) {
        frequencyExt[i] = new FrequencyExt();
        frequencyExt[i].setKey(i);
        frequencyExt[i].setValue(value);
        if (i > 5) {
            value = value * 2;
        } else {
            value = value / 2;
        }
    }
    Assert.assertEquals("0", frequencyExt[0].getKey().toString());
    ComparatorsFactory.sort(frequencyExt, ComparatorsFactory.BENFORDLAW_FREQUENCY_COMPARATOR_ID);
    for (int i = 0; i < 7; i++) {
        Assert.assertTrue(frequencyExt[i].getKey().toString().compareTo(frequencyExt[i + 1].getKey().toString()) < 0);
    }
    Assert.assertEquals("0", frequencyExt[8].getKey().toString());
}
Also used : FrequencyExt(org.talend.dq.indicators.ext.FrequencyExt) Test(org.junit.Test)

Example 15 with FrequencyExt

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

the class ComparatorsFactoryTest method testSortObject_2.

@SuppressWarnings("deprecation")
@Test
public void testSortObject_2() {
    FrequencyExt[] frequencyExt = new FrequencyExt[9];
    Long value = 100l;
    double key = 1d;
    for (int i = 0; i < 9; i++) {
        frequencyExt[i] = new FrequencyExt();
        frequencyExt[i].setKey(key);
        frequencyExt[i].setValue(value);
        if (i > 5) {
            value = value * 2;
        } else {
            value = value / 2;
        }
        key++;
    }
    ComparatorsFactory.sort(frequencyExt, ComparatorsFactory.BENFORDLAW_FREQUENCY_COMPARATOR_ID);
    for (int i = 0; i < 8; i++) {
        Assert.assertTrue(frequencyExt[i].getKey().toString().compareTo(frequencyExt[i + 1].getKey().toString()) < 0);
    }
}
Also used : FrequencyExt(org.talend.dq.indicators.ext.FrequencyExt) Test(org.junit.Test)

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