Search in sources :

Example 1 with IndicatorEvaluator

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);
}
Also used : TdColumn(org.talend.cwm.relational.TdColumn) ReturnCode(org.talend.utils.sugars.ReturnCode) IndicatorEvaluator(org.talend.dq.indicators.IndicatorEvaluator) Package(orgomg.cwm.objectmodel.core.Package) Indicator(org.talend.dataquality.indicators.Indicator)

Example 2 with IndicatorEvaluator

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;
}
Also used : TypedReturnCode(org.talend.utils.sugars.TypedReturnCode) ReturnCode(org.talend.utils.sugars.ReturnCode) IndicatorEvaluator(org.talend.dq.indicators.IndicatorEvaluator) RulesPackage(org.talend.dataquality.rules.RulesPackage) RelationalPackage(orgomg.cwm.resource.relational.RelationalPackage) Package(orgomg.cwm.objectmodel.core.Package) Indicator(org.talend.dataquality.indicators.Indicator) WhereRuleIndicator(org.talend.dataquality.indicators.sql.WhereRuleIndicator) NamedColumnSet(orgomg.cwm.resource.relational.NamedColumnSet)

Aggregations

Indicator (org.talend.dataquality.indicators.Indicator)2 IndicatorEvaluator (org.talend.dq.indicators.IndicatorEvaluator)2 ReturnCode (org.talend.utils.sugars.ReturnCode)2 Package (orgomg.cwm.objectmodel.core.Package)2 TdColumn (org.talend.cwm.relational.TdColumn)1 WhereRuleIndicator (org.talend.dataquality.indicators.sql.WhereRuleIndicator)1 RulesPackage (org.talend.dataquality.rules.RulesPackage)1 TypedReturnCode (org.talend.utils.sugars.TypedReturnCode)1 NamedColumnSet (orgomg.cwm.resource.relational.NamedColumnSet)1 RelationalPackage (orgomg.cwm.resource.relational.RelationalPackage)1