Search in sources :

Example 76 with TdColumn

use of org.talend.cwm.relational.TdColumn in project tdq-studio-se by Talend.

the class ColumnDependencyExplorer method getStatement.

/**
 * DOC xqliu Comment method "getStatement".
 *
 * @param genericSQL
 * @return
 */
private String getStatement(String genericSQL) {
    ColumnDependencyIndicator cdIndicator = ((ColumnDependencyIndicator) this.indicator);
    TdColumn columnA = cdIndicator.getColumnA();
    TdColumn columnB = cdIndicator.getColumnB();
    GenericSQLHandler sqlHandler = new GenericSQLHandler(genericSQL);
    sqlHandler.replaceColumnA(dbmsLanguage.quote(columnA.getName())).replaceColumnB(dbmsLanguage.quote(columnB.getName())).replaceTable(dbmsLanguage.quote(getFullyQualifiedTableName(columnA)));
    String instantiatedSQL = sqlHandler.getSqlString();
    List<String> whereClauses = new ArrayList<String>();
    String dataFilter = ContextHelper.getDataFilterWithoutContext(this.analysis);
    if (!StringUtils.isEmpty(dataFilter)) {
        whereClauses.add(dataFilter);
    }
    instantiatedSQL = dbmsLanguage.addWhereToSqlStringStatement(instantiatedSQL, whereClauses);
    return instantiatedSQL;
}
Also used : ColumnDependencyIndicator(org.talend.dataquality.indicators.columnset.ColumnDependencyIndicator) TdColumn(org.talend.cwm.relational.TdColumn) ArrayList(java.util.ArrayList) GenericSQLHandler(org.talend.dq.dbms.GenericSQLHandler)

Example 77 with TdColumn

use of org.talend.cwm.relational.TdColumn in project tdq-studio-se by Talend.

the class FunctionFrequencyStatExplorer method getInstantiatedClause.

@Override
protected String getInstantiatedClause() {
    // get function which convert data into a pattern
    String colName = columnName;
    String function = null;
    TdColumn column = (TdColumn) indicator.getAnalyzedElement();
    int javaType = column.getSqlDataType().getJavaDataType();
    if (!Java2SqlType.isNumbericInSQL(javaType)) {
        function = getFunction();
    } else {
        colName = columnNameConvert();
    }
    // MOD mzhao bug 9681 2009-11-09
    Object value = null;
    if (Java2SqlType.isNumbericInSQL(javaType) && dbmsLanguage instanceof DB2DbmsLanguage) {
        value = entity.getKey();
    } else {
        // $NON-NLS-1$//$NON-NLS-2$
        value = "'" + entity.getKey() + "'";
    }
    String clause = entity.isLabelNull() ? columnName + dbmsLanguage.isNull() : ((function == null ? colName : function) + dbmsLanguage.equal() + value);
    // ADD xqliu 2011-06-03 bug 20600's note 86482
    if (dbmsLanguage instanceof InfomixDbmsLanguage) {
        clause = clause.replaceAll(InfomixDbmsLanguage.AS_REPLACE_COLUMN, PluginConstant.EMPTY_STRING);
    }
    // ~ 20600
    return clause;
}
Also used : TdColumn(org.talend.cwm.relational.TdColumn) InfomixDbmsLanguage(org.talend.dq.dbms.InfomixDbmsLanguage) DB2DbmsLanguage(org.talend.dq.dbms.DB2DbmsLanguage)

Example 78 with TdColumn

use of org.talend.cwm.relational.TdColumn in project tdq-studio-se by Talend.

the class FunctionFrequencyStatExplorer method getFreqRowsStatement.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dq.analysis.explore.FrequencyStatisticsExplorer#getFreqRowsStatement()
     */
@Override
protected String getFreqRowsStatement() {
    // generate SELECT * FROM TABLE WHERE function(columnName) = labelToFind
    TdColumn column = (TdColumn) indicator.getAnalyzedElement();
    String clause = getInstantiatedClause();
    return // $NON-NLS-1$
    "SELECT * FROM " + getFullyQualifiedTableName(column) + dbmsLanguage.where() + inBrackets(clause) + andDataFilterClause();
}
Also used : TdColumn(org.talend.cwm.relational.TdColumn)

Example 79 with TdColumn

use of org.talend.cwm.relational.TdColumn in project tdq-studio-se by Talend.

the class FunctionFrequencyStatExplorer method columnNameConvert.

@SuppressWarnings("deprecation")
private String columnNameConvert() {
    String colName = columnName;
    TdColumn column = (TdColumn) indicator.getAnalyzedElement();
    IndicatorDefinition indicatorDefinition;
    String label = indicator.getIndicatorDefinition().getLabel();
    if (label == null || PluginConstant.EMPTY_STRING.equals(label)) {
        indicatorDefinition = indicator.getIndicatorDefinition();
    } else {
        indicatorDefinition = DefinitionHandler.getInstance().getIndicatorDefinition(label);
    }
    if (indicator.eClass().equals(IndicatorsPackage.eINSTANCE.getPatternFreqIndicator()) || indicator.eClass().equals(IndicatorsPackage.eINSTANCE.getPatternLowFreqIndicator())) {
        // MOD zshen for bug 12675 2010-05-12
        if (Java2SqlType.isNumbericInSQL(column.getSqlDataType().getJavaDataType())) {
            colName = addFunctionTypeConvert(colName);
        }
        // ~12675
        final EList<CharactersMapping> charactersMapping = indicatorDefinition.getCharactersMapping();
        colName = dbmsLanguage.getPatternFinderFunction(colName, charactersMapping);
        if (columnName == null) {
            // no replacement found, try the default one
            colName = dbmsLanguage.getPatternFinderDefaultFunction(colName);
        }
    }
    return colName;
}
Also used : CharactersMapping(org.talend.dataquality.indicators.definition.CharactersMapping) TdColumn(org.talend.cwm.relational.TdColumn) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition)

Example 80 with TdColumn

use of org.talend.cwm.relational.TdColumn in project tdq-studio-se by Talend.

the class AnalysisHandler method getColumnSetOwnerNames.

private String[] getColumnSetOwnerNames() {
    List<String> existingTables = new ArrayList<String>();
    for (ModelElement element : getAnalyzedColumns()) {
        if (element instanceof TdColumn && element.eContainer() instanceof Table) {
            String tableName = ColumnHelper.getTableFullName((TdColumn) element);
            if (!existingTables.contains(tableName)) {
                existingTables.add(tableName);
            }
        } else if (element instanceof Table) {
            String tableName = ((Table) element).getName();
            if (!existingTables.contains(tableName)) {
                existingTables.add(tableName);
            }
        } else if (element instanceof MetadataColumn) {
            // the result page
            if (!(element instanceof TdColumn)) {
                // MOD qiongli 2011-1-28,for delimited file
                try {
                    MetadataTable table = ColumnHelper.getColumnOwnerAsMetadataTable((MetadataColumn) element);
                    String tableName = table.getLabel();
                    if (!existingTables.contains(tableName)) {
                        existingTables.add(tableName);
                    }
                } catch (java.lang.NullPointerException e) {
                    // $NON-NLS-1$
                    log.error(Messages.getString("AnalysisHandler.CanNotFindColumnParent", element.getName()), e);
                }
            }
        }
    }
    return existingTables.toArray(new String[existingTables.size()]);
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) TdColumn(org.talend.cwm.relational.TdColumn) Table(orgomg.cwm.resource.relational.Table) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) ArrayList(java.util.ArrayList) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable)

Aggregations

TdColumn (org.talend.cwm.relational.TdColumn)182 ArrayList (java.util.ArrayList)49 TdTable (org.talend.cwm.relational.TdTable)49 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)40 Test (org.junit.Test)37 ColumnSet (orgomg.cwm.resource.relational.ColumnSet)35 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)28 RepositoryNode (org.talend.repository.model.RepositoryNode)26 IRepositoryNode (org.talend.repository.model.IRepositoryNode)23 Indicator (org.talend.dataquality.indicators.Indicator)20 Catalog (orgomg.cwm.resource.relational.Catalog)19 Connection (org.talend.core.model.metadata.builder.connection.Connection)17 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)16 TdSqlDataType (org.talend.cwm.relational.TdSqlDataType)16 Analysis (org.talend.dataquality.analysis.Analysis)16 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)15 IndicatorParameters (org.talend.dataquality.indicators.IndicatorParameters)14 DBColumnRepNode (org.talend.dq.nodes.DBColumnRepNode)14 Package (orgomg.cwm.objectmodel.core.Package)14 MetadataColumnRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject)13