use of org.talend.dq.indicators.ext.PatternMatchingExt in project tdq-studio-se by Talend.
the class PatternStatisticeStateUtilTest method testGetUnitValueCase1.
/**
* Test method for
* {@link org.talend.dataprofiler.core.ui.editor.preview.model.states.pattern.PatternStatisticeStateUtil#getUnitValue(org.talend.dataquality.indicators.Indicator, java.lang.Object)}
* .
* case1:normal RegexpMatchingIndicator case
*/
@Test
public void testGetUnitValueCase1() {
Object pMatchExt = null;
RegexpMatchingIndicator regexpMatchingIndicator = IndicatorsFactoryImpl.eINSTANCE.createRegexpMatchingIndicator();
regexpMatchingIndicator.setComputed(true);
regexpMatchingIndicator.setMatchingValueCount(40l);
regexpMatchingIndicator.setNotMatchingValueCount(50l);
PatternMatchingExt unitValue = PatternStatisticeStateUtil.getUnitValue(regexpMatchingIndicator, pMatchExt);
// $NON-NLS-1$
Assert.assertEquals("Matching count value shoud be 40l", 40l, unitValue.getMatchingValueCount());
// $NON-NLS-1$
Assert.assertEquals("Not matching count value shoud be 50l", 50l, unitValue.getNotMatchingValueCount());
}
use of org.talend.dq.indicators.ext.PatternMatchingExt in project tdq-studio-se by Talend.
the class PatternStatisticeStateUtilTest method testGetUnitValueCase2.
/**
* Test method for
* {@link org.talend.dataprofiler.core.ui.editor.preview.model.states.pattern.PatternStatisticeStateUtil#getUnitValue(org.talend.dataquality.indicators.Indicator, java.lang.Object)}
* .
* case2:normal UDI case
*/
@Test
public void testGetUnitValueCase2() {
PatternMatchingExt pMatchExt = null;
UserDefIndicator userDefIndicator = IndicatorSqlFactoryImpl.eINSTANCE.createUserDefIndicator();
userDefIndicator.setComputed(true);
userDefIndicator.setMatchingValueCount(40l);
userDefIndicator.setNotMatchingValueCount(50l);
PatternMatchingExt unitValue = PatternStatisticeStateUtil.getUnitValue(userDefIndicator, pMatchExt);
// $NON-NLS-1$
Assert.assertEquals("Matching count value shoud be 40l", 40l, unitValue.getMatchingValueCount());
// $NON-NLS-1$
Assert.assertEquals("Not matching count value shoud be 50l", 50l, unitValue.getNotMatchingValueCount());
// $NON-NLS-1$
Assert.assertNotEquals("unitValue should not same with pMatchExt but it is not now", pMatchExt, unitValue);
}
use of org.talend.dq.indicators.ext.PatternMatchingExt in project tdq-studio-se by Talend.
the class AnalysisExecutor method hasOutThreshold.
/**
* DOC qiongli Comment method "hasOutThreshold".
*
* @param indicator
* @return
*/
private boolean hasOutThreshold(Indicator indicator) {
String[] indicatorThreshold = IndicatorHelper.getIndicatorThreshold(indicator);
String[] indiPercentThreshold = IndicatorHelper.getIndicatorThresholdInPercent(indicator);
Object obj = IndicatorCommonUtil.getIndicatorValue(indicator);
if (indicatorThreshold != null || indiPercentThreshold != null) {
// MOD qiongli 2011-11-15 TDQ-3690 avoid String "null",and get the value for ValueIndicator to transfer.
if (obj != null && !PluginConstant.EMPTY_STRING.equals(obj.toString()) && !"null".equalsIgnoreCase(obj.toString())) {
// $NON-NLS-1$
String value = PluginConstant.EMPTY_STRING;
if (indicator instanceof ValueIndicator) {
value = ((ValueIndicator) indicator).getValue();
}
ChartDataEntity chartDataEntity = new ChartDataEntity(indicator, PluginConstant.EMPTY_STRING, value);
if (obj instanceof PatternMatchingExt) {
obj = (((PatternMatchingExt) obj).getMatchingValueCount());
}
if (chartDataEntity.isOutOfRange(obj.toString())) {
return true;
}
}
}
List<Indicator> leaves = IndicatorHelper.getIndicatorLeaves(indicator);
if (leaves.size() > 0 && !leaves.get(0).equals(indicator)) {
for (Indicator leaveIndicator : leaves) {
if (hasOutThreshold(leaveIndicator)) {
return true;
}
}
}
return false;
}
use of org.talend.dq.indicators.ext.PatternMatchingExt in project tdq-studio-se by Talend.
the class IndicatorCommonUtil method handleMatchingValue.
/**
* DOC xqliu Comment method "handleMatchingValue".
*
* @param indicator
* @return
*/
public static PatternMatchingExt handleMatchingValue(Indicator indicator) {
PatternMatchingExt patternExt = new PatternMatchingExt();
if (UDIHelper.isUDI(indicator)) {
UserDefIndicator udi = (UserDefIndicator) indicator;
if (udi.getMatchingValueCount() != null) {
patternExt.setMatchingValueCount(udi.getMatchingValueCount());
}
if (udi.getNotMatchingValueCount() != null) {
patternExt.setNotMatchingValueCount(udi.getNotMatchingValueCount());
}
} else {
// TDQ-12282 msjian : fix a NPE
Long matchingValueCount = ((PatternMatchingIndicator) indicator).getMatchingValueCount();
patternExt.setMatchingValueCount(matchingValueCount == null ? 0l : matchingValueCount);
Long notMatchingValueCount = ((PatternMatchingIndicator) indicator).getNotMatchingValueCount();
patternExt.setNotMatchingValueCount(notMatchingValueCount == null ? 0l : notMatchingValueCount);
}
return patternExt;
}
use of org.talend.dq.indicators.ext.PatternMatchingExt in project tdq-studio-se by Talend.
the class PatternStatisticsTableState method getDataEntity.
/*
* (non-Javadoc)
*
* @see org.talend.dataprofiler.core.ui.editor.preview.model.states.table.AbstractTableTypeStates#getDataEntity()
*/
@Override
public ChartDataEntity[] getDataEntity() {
List<ChartDataEntity> dataEnities = new ArrayList<ChartDataEntity>();
for (IndicatorUnit unit : units) {
PatternMatchingExt patternExt = PatternStatisticeStateUtil.getUnitValue(unit.getIndicator(), unit.getValue());
String notMathCount = PatternStatisticeStateUtil.getNotMatchCount(patternExt);
String machCount = PatternStatisticeStateUtil.getMatchCount(patternExt);
PatternChartDataEntity patternEntity = PatternStatisticeStateUtil.createDataEntity(unit, unit.getIndicator().getName(), notMathCount, machCount);
dataEnities.add(patternEntity);
}
return dataEnities.toArray(new ChartDataEntity[dataEnities.size()]);
}
Aggregations