use of org.talend.dq.indicators.IndicatorEvaluator in project tdq-studio-se by Talend.
the class ColumnAnalysisExecutor method evaluate.
@Override
protected ReturnCode evaluate(Analysis analysis, java.sql.Connection connection, String sqlStatement) {
IndicatorEvaluator eval = CreateIndicatorEvaluator(analysis);
// MOD xqliu 2009-02-09 bug 6237
eval.setMonitor(getMonitor());
// set it into the evaluator
eval.setConnection(connection);
// use pooled connection
eval.setPooledConnection(POOLED_CONNECTION);
// --- add indicators
EList<Indicator> indicators = analysis.getResults().getIndicators();
RowCountIndicatorsAdapter.getInstance().clear();
for (Indicator indicator : indicators) {
assert indicator != null;
TdColumn tdColumn = SwitchHelpers.COLUMN_SWITCH.doSwitch(indicator.getAnalyzedElement());
if (tdColumn == null) {
continue;
}
// --- get the schema owner
if (!belongToSameSchemata(tdColumn)) {
// $NON-NLS-1$
setError(Messages.getString("ColumnAnalysisExecutor.GivenColumn", tdColumn.getName()));
return new ReturnCode(getErrorMessage(), Boolean.FALSE);
}
String columnName = ColumnHelper.getFullName(tdColumn);
eval.storeIndicator(columnName, indicator);
}
// when to close connection
boolean closeAtTheEnd = true;
Package catalog = schemata.values().iterator().next();
if (!eval.selectCatalog(catalog.getName())) {
// $NON-NLS-1$
log.warn(Messages.getString("ColumnAnalysisExecutor.FAILEDTOSELECTCATALOG", catalog.getName()));
}
return eval.evaluateIndicators(sqlStatement, closeAtTheEnd);
}
use of org.talend.dq.indicators.IndicatorEvaluator in project tdq-studio-se by Talend.
the class TableAnalysisSqlExecutor method evaluate.
@Override
protected ReturnCode evaluate(Analysis analysis, java.sql.Connection connection, String sqlStatement) {
IndicatorEvaluator eval = new IndicatorEvaluator(analysis);
eval.setMonitor(getMonitor());
// --- add indicators
EList<Indicator> indicators = analysis.getResults().getIndicators();
for (Indicator indicator : indicators) {
assert indicator != null;
NamedColumnSet set = SwitchHelpers.NAMED_COLUMN_SET_SWITCH.doSwitch(indicator.getAnalyzedElement());
if (set == null) {
continue;
}
// --- get the schema owner
if (!belongToSameSchemata(set)) {
// $NON-NLS-1$
setError(Messages.getString("TableAnalysisExecutor.GivenTable", set.getName()));
return new ReturnCode(getErrorMessage(), Boolean.FALSE);
}
String setName = dbms().getQueryColumnSetWithPrefix(set);
eval.storeIndicator(setName, indicator);
}
// set it into the evaluator
eval.setConnection(connection);
// use pooled connection
eval.setPooledConnection(POOLED_CONNECTION);
// when to close connection
boolean closeAtTheEnd = true;
Package catalog = schemata.values().iterator().next();
if (!eval.selectCatalog(catalog.getName())) {
// $NON-NLS-1$//$NON-NLS-2$
log.warn("Failed to select catalog " + catalog.getName() + " for connection.");
}
ReturnCode retCode = eval.evaluateIndicators(sqlStatement, closeAtTheEnd);
if (getMonitor() != null) {
getMonitor().worked(compIndicatorsWorked);
}
return retCode;
}
Aggregations