use of org.talend.dataquality.indicators.RegexpMatchingIndicator in project tdq-studio-se by Talend.
the class ColumnSetAnalysisResultPage method getMatchColor.
/**
* zshen Comment method "getMatchColor".
*
* @param element
* @param columnIndex
* @return get the color of the element.
*/
private Color getMatchColor(Object element, int columnIndex) {
if (tableFilterResult.getTableFilterResult() != null) {
for (Map<Integer, RegexpMatchingIndicator> tableItem : this.tableFilterResult.getTableFilterResult()) {
RegexpMatchingIndicator regMatIndicator = tableItem.get(columnIndex);
if (regMatIndicator == null) {
continue;
}
String regex = regMatIndicator.getRegex();
Pattern p = java.util.regex.Pattern.compile(regex);
if (element instanceof Object[]) {
Object theElement = ((Object[]) element)[columnIndex];
if (theElement == null) {
// $NON-NLS-1$
theElement = "null";
}
Matcher m = p.matcher(String.valueOf(theElement));
if (!m.find()) {
return new Color(null, 255, 0, 0);
}
}
}
}
return new Color(null, 0, 0, 0);
}
use of org.talend.dataquality.indicators.RegexpMatchingIndicator in project tdq-studio-se by Talend.
the class PatternStatisticeStateUtilTest method testGetUnitValueCase4.
/**
* Test method for
* {@link org.talend.dataprofiler.core.ui.editor.preview.model.states.pattern.PatternStatisticeStateUtil#getUnitValue(org.talend.dataquality.indicators.Indicator, java.lang.Object)}
* .
* case4:Input value is PatternMatchingExt so that return directly
*/
@Test
public void testGetUnitValueCase4() {
PatternMatchingExt pMatchExt = new PatternMatchingExt();
pMatchExt.setMatchingValueCount(40l);
pMatchExt.setNotMatchingValueCount(50l);
RegexpMatchingIndicator regexpMatchingIndicator = IndicatorsFactoryImpl.eINSTANCE.createRegexpMatchingIndicator();
regexpMatchingIndicator.setComputed(true);
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());
// $NON-NLS-1$
Assert.assertEquals("unitValue should same with pMatchExt but it is not now", pMatchExt, unitValue);
}
use of org.talend.dataquality.indicators.RegexpMatchingIndicator in project tdq-studio-se by Talend.
the class PatternStatisticsStateTest method setUp.
/**
* init the state.
*
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
List<IndicatorUnit> units = new ArrayList<IndicatorUnit>();
RegexpMatchingIndicator indicator = IndicatorsFactory.eINSTANCE.createRegexpMatchingIndicator();
// $NON-NLS-1$
indicator.setName("Blank text");
indicator.setComputed(true);
units.add(new ColumnSetIndicatorUnit(IndicatorEnum.AllMatchIndicatorEnum, indicator));
patternStatisticsState = new PatternStatisticsState(units);
}
use of org.talend.dataquality.indicators.RegexpMatchingIndicator in project tdq-studio-se by Talend.
the class ColumnSetAnalysisExecutor method checkAllMatchIndicator.
protected boolean checkAllMatchIndicator(AllMatchIndicator indicator) {
EList<RegexpMatchingIndicator> indicators = indicator.getCompositeRegexMatchingIndicators();
String patternNames = PluginConstant.EMPTY_STRING;
for (RegexpMatchingIndicator rmi : indicators) {
if (null == rmi.getRegex()) {
// $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
patternNames += System.getProperty("line.separator") + "\"" + rmi.getName() + "\"";
} else if (rmi.getRegex().equals(rmi.getName())) {
// $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
patternNames += System.getProperty("line.separator") + "\"" + rmi.getName() + "\"";
}
}
if (PluginConstant.EMPTY_STRING != patternNames) {
// $NON-NLS-1$
traceError(Messages.getString("MultiColumnAnalysisExecutor.checkAllMatchIndicatorForDbType", patternNames));
return false;
}
return true;
}
use of org.talend.dataquality.indicators.RegexpMatchingIndicator in project tdq-studio-se by Talend.
the class PatternsDataValidation method isValid.
/*
* (non-Javadoc)
*
* @see org.talend.cwm.indicator.DataValidation#isValid(java.lang.Object)
*/
@Override
public boolean isValid(Object inputData) {
if (tableFilterResult == null) {
return true;
}
for (Map<Integer, RegexpMatchingIndicator> tableItem : tableFilterResult) {
if (inputData instanceof ArrayList) {
for (int index = 0; index < ((ArrayList<?>) inputData).size(); index++) {
RegexpMatchingIndicator regMatIndicator = tableItem.get(index);
if (regMatIndicator == null) {
continue;
}
String regex = regMatIndicator.getRegex();
Pattern p = java.util.regex.Pattern.compile(regex);
Object theElement = ((ArrayList<?>) inputData).get(index);
if (theElement == null) {
// $NON-NLS-1$
theElement = "null";
}
Matcher m = p.matcher(String.valueOf(theElement));
if (!m.find()) {
if (DataFilterType.MATCHES.equals(filterType)) {
return false;
} else if (DataFilterType.non_matches.equals(filterType)) {
return true;
}
}
}
}
}
return DataFilterType.MATCHES.equals(filterType);
}
Aggregations