Search in sources :

Example 51 with TdColumn

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

the class AnalysisColumnCompareTreeViewer method setColumnABForMatchingIndicator.

/**
 * DOC rli Comment method "setColumnAB".
 */
public void setColumnABForMatchingIndicator(RowMatchingIndicator rowMatchingIndicator, List<RepositoryNode> columnsA, List<RepositoryNode> columnsB) {
    if (columnsA.size() != 0 && columnsA.get(0).getObject() instanceof MetadataColumnRepositoryObject) {
        RepositoryNode node = columnsA.get(0);
        MetadataColumnRepositoryObject columnObject = (MetadataColumnRepositoryObject) node.getObject();
        TdColumn column = ((TdColumn) columnObject.getTdColumn());
        ColumnSet columnSetOwner = ColumnHelper.getColumnOwnerAsColumnSet(column);
        rowMatchingIndicator.setAnalyzedElement(columnSetOwner);
    }
    rowMatchingIndicator.getColumnSetA().clear();
    for (RepositoryNode reposNode : columnsA) {
        rowMatchingIndicator.getColumnSetA().add((TdColumn) ((MetadataColumnRepositoryObject) reposNode.getObject()).getTdColumn());
    }
    rowMatchingIndicator.getColumnSetB().clear();
    for (RepositoryNode reposNode : columnsB) {
        rowMatchingIndicator.getColumnSetB().add((TdColumn) ((MetadataColumnRepositoryObject) reposNode.getObject()).getTdColumn());
    }
}
Also used : TdColumn(org.talend.cwm.relational.TdColumn) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) ColumnSet(orgomg.cwm.resource.relational.ColumnSet) RepositoryNode(org.talend.repository.model.RepositoryNode)

Example 52 with TdColumn

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

the class DrillDownEditorInput method getColumnIndexArray.

/**
 * Get index of column whiche will be used on the dirll down. Note that One indicator only belong one column so that
 * the array of retrun value just contain one element.
 *
 * And if we create new map for view values menu rather than used same map with view rows menu then method can be
 * removed
 *
 * @return
 */
public Integer[] getColumnIndexArray() {
    if (!DrillDownUtils.judgeMenuType(this.getMenuType(), DrillDownUtils.MENU_VALUE_TYPE) || !UniqueCountIndicator.class.isInstance(currIndicator)) {
        return null;
    }
    List<Integer> indexArray = new ArrayList<Integer>();
    Indicator indicator = this.getCurrIndicator();
    ModelElement analysisElement = indicator.getAnalyzedElement();
    int index = 0;
    if (analysisElement instanceof TdColumn) {
        List<TdColumn> columns = getColumnsByTdColumn((TdColumn) analysisElement);
        for (TdColumn column : columns) {
            if (column.getName().equals(analysisElement.getName())) {
                indexArray.add(index);
                // break at here.
                break;
            }
            index++;
        }
    } else if (analysisElement instanceof MetadataColumn) {
        MetadataTable mTable = ColumnHelper.getColumnOwnerAsMetadataTable((MetadataColumn) analysisElement);
        for (MetadataColumn mColumn : mTable.getColumns()) {
            if (mColumn.getLabel().equals(analysisElement.getName())) {
                indexArray.add(index);
                // break at here.
                break;
            }
            index++;
        }
    }
    return indexArray.toArray(new Integer[indexArray.size()]);
}
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) 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 53 with TdColumn

use of org.talend.cwm.relational.TdColumn 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 54 with TdColumn

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

the class RowMatchExplorer method getRowsNotMatchStatement.

/**
 * get Rows for NotMatched Statement.
 *
 * @return
 */
public String getRowsNotMatchStatement() {
    ColumnSet tablea = (ColumnSet) indicator.getAnalyzedElement();
    String tableA = tablea.getName();
    // $NON-NLS-1$
    String query = "SELECT A.*" + dbmsLanguage.from();
    if (ColumnsetPackage.eINSTANCE.getRowMatchingIndicator() == indicator.eClass()) {
        ColumnSet tableb = ColumnHelper.getColumnOwnerAsColumnSet(((RowMatchingIndicator) indicator).getColumnSetB().get(0));
        String tableB = tableb.getName();
        EList<TdColumn> columnSetA = ((RowMatchingIndicator) indicator).getColumnSetA();
        EList<TdColumn> columnSetB = ((RowMatchingIndicator) indicator).getColumnSetB();
        // $NON-NLS-1$
        String clauseA = " (SELECT *" + dbmsLanguage.from() + getFullyQualifiedTableName(tablea);
        // $NON-NLS-1$
        String clauseB = " (SELECT *" + dbmsLanguage.from() + getFullyQualifiedTableName(tableb);
        String where = null;
        // $NON-NLS-1$
        String onClause = " ON ";
        String realWhereClause = dbmsLanguage.where();
        for (int i = 0; i < columnSetA.size(); i++) {
            where = dbmsLanguage.and();
            if (i == 0) {
                where = dbmsLanguage.where();
            } else {
                onClause += where;
                realWhereClause += where;
            }
            realWhereClause += // $NON-NLS-1$
            " B" + dbmsLanguage.getDelimiter() + dbmsLanguage.quote(columnSetB.get(i).getName()) + dbmsLanguage.isNull();
            onClause += // $NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
            " (A" + dbmsLanguage.getDelimiter() + dbmsLanguage.quote(columnSetA.get(i).getName()) + "=" + " B" + dbmsLanguage.getDelimiter() + dbmsLanguage.quote(columnSetB.get(i).getName()) + // $NON-NLS-1$
            ") ";
        }
        clauseA += (tableA.equals(tableB) ? whereDataFilter(tableA, (getdataFilterIndex(null) == AnalysisHelper.DATA_FILTER_A ? AnalysisHelper.DATA_FILTER_A : AnalysisHelper.DATA_FILTER_B)) : whereDataFilter(tableA, null)) + // $NON-NLS-1$
        ") A";
        clauseB += (tableB.equals(tableA) ? whereDataFilter(tableB, (getdataFilterIndex(null) == AnalysisHelper.DATA_FILTER_A ? AnalysisHelper.DATA_FILTER_B : AnalysisHelper.DATA_FILTER_A)) : whereDataFilter(tableB, null)) + // $NON-NLS-1$
        ") B";
        // MOD qiongli 2012-8-14 TDQ-5907.
        if (dbmsLanguage instanceof HiveDbmsLanguage) {
            // $NON-NLS-1$
            query += clauseA + " LEFT OUTER JOIN " + clauseB + onClause + realWhereClause;
        } else {
            // $NON-NLS-1$
            query += clauseA + " LEFT JOIN " + clauseB + onClause + realWhereClause;
        }
    }
    return getComment(MENU_VIEW_NOT_MATCH_ROWS) + query;
}
Also used : HiveDbmsLanguage(org.talend.dq.dbms.HiveDbmsLanguage) TdColumn(org.talend.cwm.relational.TdColumn) RowMatchingIndicator(org.talend.dataquality.indicators.columnset.RowMatchingIndicator) ColumnSet(orgomg.cwm.resource.relational.ColumnSet)

Example 55 with TdColumn

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

the class SummaryStastictisExplorer method getInvalidRowsStatement.

/**
 * zqin use this method in a menu ".
 *
 * View invalid rows" Method "getInvalidRowsStatement".
 *
 * @return the query to get the invalid rows (or null when all rows are valid)
 */
private String getInvalidRowsStatement() {
    double value = Double.valueOf(entity.getValue());
    String whereClause = null;
    TdColumn column = (TdColumn) indicator.getAnalyzedElement();
    IndicatorParameters parameters = indicator.getParameters();
    if (parameters != null) {
        String where1 = null;
        Domain domain = parameters.getIndicatorValidDomain();
        if (domain != null) {
            where1 = getWhereInvalidClause(value, domain);
        }
        String where2 = null;
        domain = parameters.getDataValidDomain();
        if (domain != null) {
            where2 = getWhereInvalidClause(value, domain);
        }
        if (where1 != null) {
            whereClause = where1;
            if (where2 != null) {
                whereClause += dbmsLanguage.or() + where2;
            }
        } else if (where2 != null) {
            whereClause = where2;
        }
    }
    // add the data filter where clause
    return whereClause != null ? SELECT_ALL + dbmsLanguage.from() + getFullyQualifiedTableName(column) + dbmsLanguage.where() + inBrackets(whereClause) + andDataFilterClause() : null;
}
Also used : TdColumn(org.talend.cwm.relational.TdColumn) IndicatorParameters(org.talend.dataquality.indicators.IndicatorParameters) Domain(org.talend.dataquality.domain.Domain)

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