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;
}
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());
}
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());
}
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;
}
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;
}
Aggregations