Search in sources :

Example 36 with Indicator

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

the class DrillDownEditorInput method filterAdaptColumnHeader.

/**
 * DOC zshen Comment method "filterAdaptColumnHeader".
 *
 * @returnget the name of column which will be displayed on the drill down editor.
 */
public List<String> filterAdaptColumnHeader() {
    // get columnHeader
    Indicator indicator = this.getCurrIndicator();
    ModelElement analysisElement = indicator.getAnalyzedElement();
    String menuType = this.getMenuType();
    List<String> columnElementList = new ArrayList<String>();
    // MOD qiongli 2011-3-3,feature 19192 ,drill down for columnSet with java engine .
    if (analysisElement == null && indicator.eContainer() instanceof SimpleStatIndicator) {
        columnElementList = columnHeaderForColumnSet((SimpleStatIndicator) indicator.eContainer());
    } else {
        // MOD qiongli 2011-1-9 feature 16796
        if (DrillDownUtils.judgeMenuType(menuType, DrillDownUtils.MENU_VALUE_TYPE)) {
            columnElementList.add(ModelElementHelper.getName(indicator.getAnalyzedElement()));
        } else if (analysisElement instanceof TdColumn) {
            for (TdColumn column : getColumnsByTdColumn((TdColumn) analysisElement)) {
                columnElementList.add(column.getName());
            }
        } else if (analysisElement instanceof MetadataColumn) {
            MetadataTable mTable = ColumnHelper.getColumnOwnerAsMetadataTable((MetadataColumn) analysisElement);
            for (MetadataColumn mColumn : mTable.getColumns()) {
                columnElementList.add(mColumn.getLabel());
            }
        }
    }
    return columnElementList;
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) TdColumn(org.talend.cwm.relational.TdColumn) ArrayList(java.util.ArrayList) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) SimpleStatIndicator(org.talend.dataquality.indicators.columnset.SimpleStatIndicator) UniqueCountIndicator(org.talend.dataquality.indicators.UniqueCountIndicator) DatePatternFreqIndicator(org.talend.dataquality.indicators.DatePatternFreqIndicator) Indicator(org.talend.dataquality.indicators.Indicator) LengthIndicator(org.talend.dataquality.indicators.LengthIndicator) DistinctCountIndicator(org.talend.dataquality.indicators.DistinctCountIndicator) SimpleStatIndicator(org.talend.dataquality.indicators.columnset.SimpleStatIndicator) DuplicateCountIndicator(org.talend.dataquality.indicators.DuplicateCountIndicator) RowCountIndicator(org.talend.dataquality.indicators.RowCountIndicator)

Example 37 with Indicator

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

the class CatalogEvaluator method executeSqlQuery.

@Override
protected ReturnCode executeSqlQuery(String sqlStatement) throws SQLException {
    ReturnCode ok = new ReturnCode(true);
    // --- preconditions
    DataProvider dataProvider = this.getDataManager();
    if (this.elementToIndicators.values().isEmpty()) {
        // $NON-NLS-1$
        String msg = Messages.getString("Evaluator.NoInidcator1");
        log.error(msg);
        ok.setReturnCode(msg, false);
        return ok;
    }
    Indicator[] indics = this.getAllIndicators();
    if (indics.length == 0) {
        // $NON-NLS-1$
        String msg = Messages.getString("Evaluator.NoInidcator2", dataProvider);
        log.error(msg);
        ok.setReturnCode(msg, false);
        return ok;
    }
    for (Indicator indicator : indics) {
        CatalogIndicator catalogIndicator = DataqualitySwitchHelper.CATALOG_SWITCH.doSwitch(indicator);
        if (catalogIndicator == null) {
            continue;
        }
        Catalog catalog = (Catalog) catalogIndicator.getAnalyzedElement();
        String catName = catalog.getName();
        // MOD yyi 2009-11-30 10187
        if (!checkCatalog(catName)) {
            // $NON-NLS-1$
            ok.setReturnCode(Messages.getString("Evaluator.catalogNotExist", catName), false);
            return ok;
        }
        // MOD qiongli 2012-8-9,Method 'Method not supported' not supported for HiveConnection
        if (dbms().supportCatalogSelection()) {
            connection.setCatalog(catName);
        }
        List<Schema> schemas = CatalogHelper.getSchemas(catalog);
        if (schemas.isEmpty()) {
            // no schema
            evalCatalogIndic(catalogIndicator, catalog, ok);
        } else {
            catalogIndicator.setAnalyzedElement(catalog);
            catalogIndicator.setSchemaCount(schemas.size());
            // --- create SchemaIndicator for each pair of catalog schema
            for (Schema tdSchema : schemas) {
                // --- create SchemaIndicator for each catalog
                SchemaIndicator schemaIndic = SchemaFactory.eINSTANCE.createSchemaIndicator();
                // MOD xqliu 2009-1-21 feature 4715
                DefinitionHandler.getInstance().setDefaultIndicatorDefinition(schemaIndic);
                evalSchemaIndicLow(catalogIndicator, schemaIndic, catalog, tdSchema, ok);
            }
        }
    }
    return ok;
}
Also used : DataProvider(orgomg.cwm.foundation.softwaredeployment.DataProvider) SchemaIndicator(org.talend.dataquality.indicators.schema.SchemaIndicator) ReturnCode(org.talend.utils.sugars.ReturnCode) Schema(orgomg.cwm.resource.relational.Schema) CatalogIndicator(org.talend.dataquality.indicators.schema.CatalogIndicator) CatalogIndicator(org.talend.dataquality.indicators.schema.CatalogIndicator) SchemaIndicator(org.talend.dataquality.indicators.schema.SchemaIndicator) Indicator(org.talend.dataquality.indicators.Indicator) Catalog(orgomg.cwm.resource.relational.Catalog)

Example 38 with Indicator

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

the class Evaluator method prepareIndicators.

private boolean prepareIndicators() {
    boolean ok = true;
    for (Indicator indic : allIndicators) {
        if (!indic.prepare()) {
            javaPatternMessage = indic.getName();
            ok = false;
        }
    }
    return ok;
}
Also used : Indicator(org.talend.dataquality.indicators.Indicator)

Example 39 with Indicator

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

the class ColumnSetIndicatorEvaluator method evaluateBySql.

/**
 * orgnize EList 'objectLs' by SQL.
 *
 * @param sqlStatement
 * @param ok
 * @return
 * @throws SQLException
 */
private ReturnCode evaluateBySql(String sqlStatement, ReturnCode ok) throws SQLException {
    Statement statement = null;
    ResultSet resultSet = null;
    try {
        statement = createStatement();
        if (continueRun()) {
            if (log.isInfoEnabled()) {
                // $NON-NLS-1$
                log.info("Executing query: " + sqlStatement);
            }
            statement.execute(sqlStatement);
        }
        // get the results
        resultSet = statement.getResultSet();
        List<String> columnNames = getAnalyzedElementsName();
        if (resultSet == null) {
            // $NON-NLS-1$
            String mess = Messages.getString("Evaluator.NoResultSet", sqlStatement);
            log.warn(mess);
            ok.setReturnCode(mess, false);
            return ok;
        }
        EMap<Indicator, AnalyzedDataSet> indicToRowMap = analysis.getResults().getIndicToRowMap();
        indicToRowMap.clear();
        while (resultSet.next()) {
            // MOD yyi 2012-04-11 TDQ-4916:Add memory control for java analysis.
            if (!continueRun()) {
                break;
            }
            EList<Object> objectLs = new BasicEList<Object>();
            Iterator<String> it = columnNames.iterator();
            while (it.hasNext()) {
                Object obj = ResultSetUtils.getBigObject(resultSet, it.next());
                objectLs.add(obj);
            }
            if (objectLs.size() == 0) {
                continue;
            }
            handleObjects(objectLs, resultSet);
        }
    } finally {
        if (resultSet != null) {
            resultSet.close();
        }
        if (statement != null) {
            statement.close();
        }
        closeConnection();
    }
    return ok;
}
Also used : AnalyzedDataSet(org.talend.dataquality.analysis.AnalyzedDataSet) Statement(java.sql.Statement) BasicEList(org.eclipse.emf.common.util.BasicEList) ResultSet(java.sql.ResultSet) UniqueCountIndicator(org.talend.dataquality.indicators.UniqueCountIndicator) Indicator(org.talend.dataquality.indicators.Indicator) DistinctCountIndicator(org.talend.dataquality.indicators.DistinctCountIndicator) AllMatchIndicator(org.talend.dataquality.indicators.columnset.AllMatchIndicator) SimpleStatIndicator(org.talend.dataquality.indicators.columnset.SimpleStatIndicator) DuplicateCountIndicator(org.talend.dataquality.indicators.DuplicateCountIndicator) RowCountIndicator(org.talend.dataquality.indicators.RowCountIndicator)

Example 40 with Indicator

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

the class ColumnSetIndicatorEvaluator method executeSqlQuery.

@Override
protected ReturnCode executeSqlQuery(String sqlStatement) throws SQLException {
    ReturnCode ok = new ReturnCode(true);
    AnalysisResult anaResult = analysis.getResults();
    EMap<Indicator, AnalyzedDataSet> indicToRowMap = anaResult.getIndicToRowMap();
    indicToRowMap.clear();
    if (isDelimitedFile) {
        ok = evaluateByDelimitedFile(sqlStatement, ok);
    } else {
        ok = evaluateBySql(sqlStatement, ok);
    }
    return ok;
}
Also used : ReturnCode(org.talend.utils.sugars.ReturnCode) AnalyzedDataSet(org.talend.dataquality.analysis.AnalyzedDataSet) AnalysisResult(org.talend.dataquality.analysis.AnalysisResult) UniqueCountIndicator(org.talend.dataquality.indicators.UniqueCountIndicator) Indicator(org.talend.dataquality.indicators.Indicator) DistinctCountIndicator(org.talend.dataquality.indicators.DistinctCountIndicator) AllMatchIndicator(org.talend.dataquality.indicators.columnset.AllMatchIndicator) SimpleStatIndicator(org.talend.dataquality.indicators.columnset.SimpleStatIndicator) DuplicateCountIndicator(org.talend.dataquality.indicators.DuplicateCountIndicator) RowCountIndicator(org.talend.dataquality.indicators.RowCountIndicator)

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