Search in sources :

Example 1 with ColumnSetIndicatorEvaluator

use of org.talend.dq.indicators.ColumnSetIndicatorEvaluator in project tdq-studio-se by Talend.

the class ColumnSetAnalysisExecutor method runAnalysis.

/*
     * (non-Jsdoc)
     * 
     * @see org.talend.dq.analysis.AnalysisExecutor#runAnalysis(org.talend.dataquality.analysis.Analysis,
     * java.lang.String)
     */
@Override
protected boolean runAnalysis(Analysis analysis, String sqlStatement) {
    ColumnSetIndicatorEvaluator eval = createIndicatorEvaluator(analysis);
    eval.setMonitor(getMonitor());
    // --- add indicators
    EList<Indicator> indicators = analysis.getResults().getIndicators();
    for (Indicator indicator : indicators) {
        if (ColumnsetPackage.eINSTANCE.getColumnSetMultiValueIndicator().isSuperTypeOf(indicator.eClass())) {
            ColumnSetMultiValueIndicator colSetMultValIndicator = (ColumnSetMultiValueIndicator) indicator;
            colSetMultValIndicator.prepare();
            eval.storeIndicator(indicator.getName(), colSetMultValIndicator);
        }
    }
    TypedReturnCode<java.sql.Connection> connection = null;
    // MOD yyi 2011-02-22 17871:delimitefile
    if (!isDelimitedFile) {
        connection = initConnection(analysis, eval);
        if (!connection.isOk()) {
            return false;
        }
    }
    // when to close connection
    boolean closeAtTheEnd = true;
    ReturnCode rc = eval.evaluateIndicators(sqlStatement, closeAtTheEnd);
    // close connection
    if (connection != null) {
        if (POOLED_CONNECTION) {
            // release the pooled connection
            resetConnectionPool(analysis);
        } else {
            ConnectionUtils.closeConnection(connection.getObject());
        }
    }
    if (!rc.isOk()) {
        traceError(rc.getMessage());
    }
    if (getMonitor() != null) {
        getMonitor().worked(compIndicatorsWorked);
    }
    return rc.isOk();
}
Also used : ColumnSetIndicatorEvaluator(org.talend.dq.indicators.ColumnSetIndicatorEvaluator) TypedReturnCode(org.talend.utils.sugars.TypedReturnCode) ReturnCode(org.talend.utils.sugars.ReturnCode) Connection(java.sql.Connection) ColumnSetMultiValueIndicator(org.talend.dataquality.indicators.columnset.ColumnSetMultiValueIndicator) ColumnSetMultiValueIndicator(org.talend.dataquality.indicators.columnset.ColumnSetMultiValueIndicator) RegexpMatchingIndicator(org.talend.dataquality.indicators.RegexpMatchingIndicator) Indicator(org.talend.dataquality.indicators.Indicator) AllMatchIndicator(org.talend.dataquality.indicators.columnset.AllMatchIndicator)

Aggregations

Connection (java.sql.Connection)1 Indicator (org.talend.dataquality.indicators.Indicator)1 RegexpMatchingIndicator (org.talend.dataquality.indicators.RegexpMatchingIndicator)1 AllMatchIndicator (org.talend.dataquality.indicators.columnset.AllMatchIndicator)1 ColumnSetMultiValueIndicator (org.talend.dataquality.indicators.columnset.ColumnSetMultiValueIndicator)1 ColumnSetIndicatorEvaluator (org.talend.dq.indicators.ColumnSetIndicatorEvaluator)1 ReturnCode (org.talend.utils.sugars.ReturnCode)1 TypedReturnCode (org.talend.utils.sugars.TypedReturnCode)1