Search in sources :

Example 51 with Indicator

use of org.talend.dataquality.indicators.Indicator in project tdq-studio-se by Talend.

the class DrillDownUtils method createDrillDownMenuForJava.

/**
 * DOC talend Comment method "createDrillDownMenu".
 *
 * @param analysis
 * @param dataEntity
 * @param menu
 * @param itemEntities
 * @param analysis
 */
public static void createDrillDownMenuForJava(final ChartDataEntity dataEntity, Menu menu, MenuItemEntity[] itemEntities, final Analysis analysis) {
    final Indicator indicator = dataEntity != null ? dataEntity.getIndicator() : null;
    AnalyzedDataSet analyDataSet = analysis.getResults().getIndicToRowMap().get(indicator);
    boolean hasData = analyDataSet != null && (analyDataSet.getData() != null && analyDataSet.getData().size() > 0 || analyDataSet.getFrequencyData() != null && analyDataSet.getFrequencyData().size() > 0 || analyDataSet.getPatternData() != null && analyDataSet.getPatternData().size() > 0);
    if (hasData) {
        createDrillDownMenu(dataEntity, menu, itemEntities, analysis);
    }
}
Also used : AnalyzedDataSet(org.talend.dataquality.analysis.AnalyzedDataSet) FrequencyIndicator(org.talend.dataquality.indicators.FrequencyIndicator) LengthIndicator(org.talend.dataquality.indicators.LengthIndicator) SimpleStatIndicator(org.talend.dataquality.indicators.columnset.SimpleStatIndicator) Indicator(org.talend.dataquality.indicators.Indicator)

Example 52 with Indicator

use of org.talend.dataquality.indicators.Indicator in project tdq-studio-se by Talend.

the class DrillDownUtils method getMapDB.

/**
 * Get MapDB which store the drill down data for current indicator
 *
 * @param analysis
 *
 * @return
 */
public static AbstractDB<Object> getMapDB(final ChartDataEntity dataEntity, Analysis analysis, MenuItemEntity itemEntitie) {
    AnalysisType analysisType = analysis.getParameters().getAnalysisType();
    if (AnalysisType.COLUMN_SET == analysisType) {
        return getColumnSetAnalysisMapDB(analysis);
    }
    Indicator indicator = dataEntity.getIndicator();
    String selectValue = dataEntity.getLabel();
    // TDQ-10785: fix the drill down menu for frequency table indicator and pattern frequency indicator can not use
    // when the data is too long
    String keyLabel = String.valueOf(dataEntity.getKey());
    // the equals on the right is the same to FrequencyTypeStateUtil.getKeyLabel()
    if (keyLabel.length() > 30 && selectValue.equals(keyLabel.substring(0, 30) + "...(" + keyLabel.length() + " characters)")) {
        // $NON-NLS-1$ //$NON-NLS-2$
        selectValue = keyLabel;
    }
    // TDQ-10785~
    String dbMapName = getDBMapName(analysisType, indicator, selectValue, itemEntitie);
    return MapDBUtils.getMapDB(dbMapName, dataEntity.getIndicator());
}
Also used : AnalysisType(org.talend.dataquality.analysis.AnalysisType) FrequencyIndicator(org.talend.dataquality.indicators.FrequencyIndicator) LengthIndicator(org.talend.dataquality.indicators.LengthIndicator) SimpleStatIndicator(org.talend.dataquality.indicators.columnset.SimpleStatIndicator) Indicator(org.talend.dataquality.indicators.Indicator)

Example 53 with Indicator

use of org.talend.dataquality.indicators.Indicator 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 54 with Indicator

use of org.talend.dataquality.indicators.Indicator in project tdq-studio-se by Talend.

the class ColumnAnalysisSqlExecutor method runAnalysisIndicatorsParallel.

/**
 * DOC xqliu Comment method "runAnalysisIndicatorsParallel".
 *
 * @param analysis
 * @param elementToIndicator
 * @param indicators
 * @param pooledConnection
 * @return
 * @throws SQLException
 */
private boolean runAnalysisIndicatorsParallel(Analysis analysis, Map<ModelElement, List<Indicator>> elementToIndicator, List<Indicator> indicators, boolean pooledConnection) throws SQLException {
    // reset the connection pool before run this analysis
    resetConnectionPool(analysis);
    // MOD gdbu 2011-6-10 bug : 21273
    try {
        final int totleWork = compIndicatorsWorked;
        List<ExecutiveAnalysisJob> jobs = new ArrayList<ExecutiveAnalysisJob>();
        final IProgressMonitor monitor = this.getMonitor();
        if (monitor != null) {
            // $NON-NLS-1$
            monitor.subTask("Run Indicators Parallel");
        }
        int temp = 0;
        for (int i = 0; i < indicators.size(); i++) {
            final Indicator indicator = indicators.get(i);
            if (!this.continueRun()) {
                return false;
            }
            // TDQ-11851,in order to syn UI and backend-threads, add this Display.
            if (monitor != null) {
                Display.getDefault().syncExec(new Runnable() {

                    public void run() {
                        monitor.subTask(Messages.getString("ColumnAnalysisSqlExecutor.AnalyzedElement", // $NON-NLS-1$
                        indicator.getAnalyzedElement().getName()));
                    }
                });
                int current = (i + 1) * totleWork / indicators.size();
                if (current > temp) {
                    monitor.worked(current - temp);
                    temp = current;
                }
            }
            Connection conn = null;
            if (pooledConnection) {
                conn = getPooledConnection(analysis).getObject();
            } else {
                conn = getConnection(analysis).getObject();
            }
            if (conn != null) {
                ExecutiveAnalysisJob eaj = new ExecutiveAnalysisJob(ColumnAnalysisSqlExecutor.this, conn, elementToIndicator, indicator);
                eaj.setName(AnalysisExecutorHelper.getIndicatorName(indicator));
                eaj.schedule();
                jobs.add(eaj);
            }
        }
        boolean hasErrorMessage = false;
        // should call join() after schedule all the jobs
        for (int i = 0; i < jobs.size(); i++) {
            ExecutiveAnalysisJob eaj = jobs.get(i);
            if (!this.continueRun()) {
                break;
            }
            eaj.join();
            if (eaj.errorMessage != null) {
                hasErrorMessage = true;
                ColumnAnalysisSqlExecutor.this.parallelExeStatus = false;
            }
        }
        // Added TDQ-8388 20140530 yyin: only show one message to let the user check detail in error log.
        if (hasErrorMessage) {
            // $NON-NLS-1$
            setError(Messages.getString("ColumnAnalysisSqlExecutor.ERRORREFERTOLOG"));
        }
    } catch (Throwable thr) {
        log.error(thr);
    } finally {
        resetConnectionPool(analysis);
    }
    // ~21273
    return parallelExeStatus;
// ~
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ArrayList(java.util.ArrayList) Connection(java.sql.Connection) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) IMetadataConnection(org.talend.core.model.metadata.IMetadataConnection) RowCountIndicator(org.talend.dataquality.indicators.RowCountIndicator) NullCountIndicator(org.talend.dataquality.indicators.NullCountIndicator) Indicator(org.talend.dataquality.indicators.Indicator) CompositeIndicator(org.talend.dataquality.indicators.CompositeIndicator)

Example 55 with Indicator

use of org.talend.dataquality.indicators.Indicator 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

Indicator (org.talend.dataquality.indicators.Indicator)178 ArrayList (java.util.ArrayList)58 RowCountIndicator (org.talend.dataquality.indicators.RowCountIndicator)40 CompositeIndicator (org.talend.dataquality.indicators.CompositeIndicator)31 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)31 ModelElementIndicator (org.talend.dataprofiler.core.model.ModelElementIndicator)28 Analysis (org.talend.dataquality.analysis.Analysis)27 DuplicateCountIndicator (org.talend.dataquality.indicators.DuplicateCountIndicator)27 UniqueCountIndicator (org.talend.dataquality.indicators.UniqueCountIndicator)27 AllMatchIndicator (org.talend.dataquality.indicators.columnset.AllMatchIndicator)26 ReturnCode (org.talend.utils.sugars.ReturnCode)25 SimpleStatIndicator (org.talend.dataquality.indicators.columnset.SimpleStatIndicator)24 UserDefIndicator (org.talend.dataquality.indicators.sql.UserDefIndicator)24 PatternMatchingIndicator (org.talend.dataquality.indicators.PatternMatchingIndicator)23 DistinctCountIndicator (org.talend.dataquality.indicators.DistinctCountIndicator)22 NullCountIndicator (org.talend.dataquality.indicators.NullCountIndicator)22 TdColumn (org.talend.cwm.relational.TdColumn)20 WhereRuleIndicator (org.talend.dataquality.indicators.sql.WhereRuleIndicator)18 FrequencyIndicator (org.talend.dataquality.indicators.FrequencyIndicator)17 Test (org.junit.Test)16