Search in sources :

Example 1 with BenfordLawFrequencyIndicator

use of org.talend.dataquality.indicators.BenfordLawFrequencyIndicator in project tdq-studio-se by Talend.

the class BenfordLawFrequencyStateTest method setUp.

/**
 * init the state.
 *
 * @throws java.lang.Exception
 */
@Before
public void setUp() throws Exception {
    UnitTestBuildHelper.initProjectStructure();
    List<IndicatorUnit> units = new ArrayList<IndicatorUnit>();
    BenfordLawFrequencyIndicator benfordLawFrequencyIndicator = IndicatorsFactory.eINSTANCE.createBenfordLawFrequencyIndicator();
    List<IRepositoryViewObject> all = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.SYSTEM_INDICATORS_FRAUDDETECTION);
    Assert.assertEquals(1, all.size());
    IRepositoryViewObject iRepositoryViewObject = all.get(0);
    Assert.assertNotNull(iRepositoryViewObject);
    TDQIndicatorDefinitionItem benfordItem = (TDQIndicatorDefinitionItem) iRepositoryViewObject.getProperty().getItem();
    benfordLawFrequencyIndicator.setIndicatorDefinition(benfordItem.getIndicatorDefinition());
    ModelElementIndicator modelElementIndicator = UnitTestBuildHelper.createModelElementIndicator();
    ColumnIndicatorUnit columnIndicatorUnit = new ColumnIndicatorUnit(IndicatorEnum.BenfordLawFrequencyIndicatorEnum, benfordLawFrequencyIndicator, modelElementIndicator);
    // IndicatorUnit unit = mock(IndicatorUnit.class);
    units.add(columnIndicatorUnit);
    for (int i = 0; i < 10; i++) {
        benfordLawFrequencyIndicator.handle(i);
    }
    benState = new BenfordLawFrequencyState(units);
}
Also used : TDQIndicatorDefinitionItem(org.talend.dataquality.properties.TDQIndicatorDefinitionItem) BenfordLawFrequencyIndicator(org.talend.dataquality.indicators.BenfordLawFrequencyIndicator) ColumnIndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.ColumnIndicatorUnit) IndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit) ArrayList(java.util.ArrayList) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ColumnIndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.ColumnIndicatorUnit) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator) Before(org.junit.Before)

Example 2 with BenfordLawFrequencyIndicator

use of org.talend.dataquality.indicators.BenfordLawFrequencyIndicator in project tdq-studio-se by Talend.

the class FrequencyTypeStateUtil method createChartEntity.

public static ChartDataEntity createChartEntity(Indicator indicator, FrequencyExt freqExt, String keyLabel, boolean isWithRowCountIndicator) {
    ChartDataEntity entity = new ChartDataEntity();
    entity.setIndicator(indicator);
    // MOD mzhao feature:6307 display soundex distinct count and real count.
    entity.setKey(freqExt == null ? null : freqExt.getKey());
    entity.setLabelNull(freqExt == null || freqExt.getKey() == null);
    entity.setLabel(keyLabel);
    entity.setValue(String.valueOf(freqExt == null ? StringUtils.EMPTY : freqExt.getValue()));
    if (freqExt == null) {
        entity.setPercent(0.0);
    } else if (indicator instanceof BenfordLawFrequencyIndicator) {
        entity.setPercent(freqExt.getFrequency());
    } else {
        Double percent = isWithRowCountIndicator ? freqExt.getFrequency() : Double.NaN;
        entity.setPercent(percent);
    }
    return entity;
}
Also used : BenfordLawFrequencyIndicator(org.talend.dataquality.indicators.BenfordLawFrequencyIndicator) ChartDataEntity(org.talend.dq.indicators.preview.table.ChartDataEntity)

Aggregations

BenfordLawFrequencyIndicator (org.talend.dataquality.indicators.BenfordLawFrequencyIndicator)2 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)1 ModelElementIndicator (org.talend.dataprofiler.core.model.ModelElementIndicator)1 ColumnIndicatorUnit (org.talend.dataprofiler.core.ui.editor.preview.ColumnIndicatorUnit)1 IndicatorUnit (org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit)1 TDQIndicatorDefinitionItem (org.talend.dataquality.properties.TDQIndicatorDefinitionItem)1 ChartDataEntity (org.talend.dq.indicators.preview.table.ChartDataEntity)1