Search in sources :

Example 1 with FormatFreqPieIndicator

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

the class PhoneNumbStatisticsIndicatorImpl method basicSetFormatFreqPieIndicator.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetFormatFreqPieIndicator(FormatFreqPieIndicator newFormatFreqPieIndicator, NotificationChain msgs) {
    FormatFreqPieIndicator oldFormatFreqPieIndicator = formatFreqPieIndicator;
    formatFreqPieIndicator = newFormatFreqPieIndicator;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, IndicatorsPackage.PHONE_NUMB_STATISTICS_INDICATOR__FORMAT_FREQ_PIE_INDICATOR, oldFormatFreqPieIndicator, newFormatFreqPieIndicator);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) FormatFreqPieIndicator(org.talend.dataquality.indicators.FormatFreqPieIndicator)

Example 2 with FormatFreqPieIndicator

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

the class FormatFreqPieIndicatorImplTest method testHandle_1.

/**
 * do not use MapDB Mode to Test method for
 * {@link org.talend.dataquality.indicators.impl.FormatFreqPieIndicatorImpl#handle(java.lang.Object)}.
 *
 * note: in this test, assert about formatFreqPieIndicator.getWellFormNatiCount() depends on the local language, so
 * when run on local computer maybe get a error result like expected:<1> but was:<4>. but on the test server is
 * right. so no need to modify this test.
 */
@Test
public void testHandle_1() {
    FormatFreqPieIndicator formatFreqPieIndicator = IndicatorsFactory.eINSTANCE.createFormatFreqPieIndicator();
    ((FormatFreqPieIndicatorImpl) formatFreqPieIndicator).setUsedMapDBMode(false);
    for (Object obj : data) {
        Assert.assertTrue(formatFreqPieIndicator.handle(obj));
    }
    Assert.assertEquals(2, formatFreqPieIndicator.getWellFormE164Count());
    Assert.assertEquals(1, formatFreqPieIndicator.getWellFormInteCount());
    Assert.assertEquals(1, formatFreqPieIndicator.getWellFormNatiCount());
    Assert.assertEquals(18, formatFreqPieIndicator.getCount().intValue());
}
Also used : FormatFreqPieIndicator(org.talend.dataquality.indicators.FormatFreqPieIndicator) Test(org.junit.Test)

Example 3 with FormatFreqPieIndicator

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

the class FormatFreqPieIndicatorImplTest method testHandle_2.

/**
 * use MapDB Mode to Test method for
 * {@link org.talend.dataquality.indicators.impl.FormatFreqPieIndicatorImpl#handle(java.lang.Object)}.
 *
 * note: in this test, assert about formatFreqPieIndicator.getWellFormNatiCount() depends on the local language, so
 * when run on local computer maybe get a error result like expected:<1> but was:<4>. but on the test server is
 * right. so no need to modify this test.
 */
@Test
public void testHandle_2() {
    FormatFreqPieIndicator formatFreqPieIndicator = IndicatorsFactory.eINSTANCE.createFormatFreqPieIndicator();
    ((FormatFreqPieIndicatorImpl) formatFreqPieIndicator).setUsedMapDBMode(true);
    ResourceUtils.createAnalysis(formatFreqPieIndicator);
    formatFreqPieIndicator.reset();
    for (Object obj : data) {
        Assert.assertTrue(formatFreqPieIndicator.handle(obj));
    }
    Assert.assertEquals(2, formatFreqPieIndicator.getWellFormE164Count());
    Assert.assertEquals(1, formatFreqPieIndicator.getWellFormInteCount());
    Assert.assertEquals(1, formatFreqPieIndicator.getWellFormNatiCount());
    Assert.assertEquals(18, formatFreqPieIndicator.getCount().intValue());
}
Also used : FormatFreqPieIndicator(org.talend.dataquality.indicators.FormatFreqPieIndicator) Test(org.junit.Test)

Example 4 with FormatFreqPieIndicator

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

the class IndicatorEvaluator method initDataSet.

@SuppressWarnings("unchecked")
protected List<Object[]> initDataSet(Indicator indicator, EMap<Indicator, AnalyzedDataSet> indicToRowMap, Object object) {
    AnalyzedDataSet analyzedDataSet = indicToRowMap.get(indicator);
    List<Object[]> valueObjectList = null;
    if (analyzedDataSet == null) {
        analyzedDataSet = AnalysisFactory.eINSTANCE.createAnalyzedDataSet();
        indicToRowMap.put(indicator, analyzedDataSet);
        analyzedDataSet.setDataCount(analysis.getParameters().getMaxNumberRows());
        analyzedDataSet.setRecordSize(0);
    }
    if (indicator instanceof FrequencyIndicator || indicator instanceof MinLengthIndicator || indicator instanceof MaxLengthIndicator) {
        Map<Object, List<Object[]>> valueObjectListMap = analyzedDataSet.getFrequencyData();
        if (valueObjectListMap == null) {
            valueObjectListMap = new HashMap<Object, List<Object[]>>();
            analyzedDataSet.setFrequencyData(valueObjectListMap);
        }
        String key = null;
        if (object == null) {
            key = SpecialValueDisplay.NULL_FIELD;
        } else if (indicator instanceof MinLengthIndicator || indicator instanceof MaxLengthIndicator) {
            key = String.valueOf(object.toString().length());
        } else if (object.equals(PluginConstant.EMPTY_STRING)) {
            key = SpecialValueDisplay.EMPTY_FIELD;
        } else if (indicator instanceof PatternLowFreqIndicator) {
            key = ((PatternLowFreqIndicator) indicator).convertCharacters(object.toString());
        } else if (indicator instanceof PatternFreqIndicator) {
            key = ((PatternFreqIndicator) indicator).convertCharacters(object.toString());
        } else if (indicator instanceof FormatFreqPieIndicator) {
            // MOD qiongli 2011-8-26,feature TDQ-3253.
            key = ((FormatFreqPieIndicator) indicator).getCurrentKey();
        } else {
            key = object.toString();
        }
        valueObjectList = valueObjectListMap.get(key);
        if (valueObjectList == null) {
            valueObjectList = new ArrayList<Object[]>();
            valueObjectListMap.put(key, valueObjectList);
        }
    } else if (indicator.isInValidRow() || indicator.isValidRow()) {
        List<Object> patternData = analyzedDataSet.getPatternData();
        if (patternData == null) {
            patternData = new ArrayList<Object>();
            // mapping with AnalyzedDataSetImpl.VALID_VALUE
            patternData.add(new ArrayList<Object[]>());
            // mapping with AnalyzedDataSetImpl.INVALID_VALUE
            patternData.add(new ArrayList<Object[]>());
            analyzedDataSet.setPatternData(patternData);
        }
        Object listObject = indicator.isInValidRow() ? patternData.get(AnalyzedDataSetImpl.INVALID_VALUE) : patternData.get(AnalyzedDataSetImpl.VALID_VALUE);
        if (listObject instanceof ArrayList<?>) {
            valueObjectList = (ArrayList<Object[]>) listObject;
        }
    } else {
        valueObjectList = analyzedDataSet.getData();
        if (valueObjectList == null) {
            valueObjectList = new ArrayList<Object[]>();
            analyzedDataSet.setData(valueObjectList);
        }
    }
    return valueObjectList;
}
Also used : MaxLengthIndicator(org.talend.dataquality.indicators.MaxLengthIndicator) AnalyzedDataSet(org.talend.dataquality.analysis.AnalyzedDataSet) FormatFreqPieIndicator(org.talend.dataquality.indicators.FormatFreqPieIndicator) ArrayList(java.util.ArrayList) MinLengthIndicator(org.talend.dataquality.indicators.MinLengthIndicator) PatternLowFreqIndicator(org.talend.dataquality.indicators.PatternLowFreqIndicator) FrequencyIndicator(org.talend.dataquality.indicators.FrequencyIndicator) ArrayList(java.util.ArrayList) List(java.util.List) PatternFreqIndicator(org.talend.dataquality.indicators.PatternFreqIndicator)

Example 5 with FormatFreqPieIndicator

use of org.talend.dataquality.indicators.FormatFreqPieIndicator 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)

Aggregations

FormatFreqPieIndicator (org.talend.dataquality.indicators.FormatFreqPieIndicator)6 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Entry (java.util.Map.Entry)1 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)1 AnalyzedDataSet (org.talend.dataquality.analysis.AnalyzedDataSet)1 FrequencyIndicator (org.talend.dataquality.indicators.FrequencyIndicator)1 MaxLengthIndicator (org.talend.dataquality.indicators.MaxLengthIndicator)1 MinLengthIndicator (org.talend.dataquality.indicators.MinLengthIndicator)1 PatternFreqIndicator (org.talend.dataquality.indicators.PatternFreqIndicator)1 PatternLowFreqIndicator (org.talend.dataquality.indicators.PatternLowFreqIndicator)1 PhoneNumbStatisticsIndicator (org.talend.dataquality.indicators.PhoneNumbStatisticsIndicator)1 PossiblePhoneCountIndicator (org.talend.dataquality.indicators.PossiblePhoneCountIndicator)1 ValidPhoneCountIndicator (org.talend.dataquality.indicators.ValidPhoneCountIndicator)1 WellFormE164PhoneCountIndicator (org.talend.dataquality.indicators.WellFormE164PhoneCountIndicator)1 WellFormIntePhoneCountIndicator (org.talend.dataquality.indicators.WellFormIntePhoneCountIndicator)1 WellFormNationalPhoneCountIndicator (org.talend.dataquality.indicators.WellFormNationalPhoneCountIndicator)1 FrequencyExt (org.talend.dq.indicators.ext.FrequencyExt)1