Search in sources :

Example 1 with ColumnDependencyIndicator

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

the class FunctionalDependencyAnalysisDetailsPage method saveAnalysis.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dataprofiler.core.ui.editor.analysis.AbstractAnalysisMetadataPage#saveAnalysis()
     */
@Override
protected void saveAnalysis() throws DataprofilerCoreException {
    analysisHandler.changeDefaultRowLoaded(rowLoadedText.getText());
    analysisHandler.changeSampleDataShowWay(sampleDataShowWayCombo.getText());
    for (Domain domain : getCurrentModelElement().getParameters().getDataFilter()) {
        domain.setName(getCurrentModelElement().getName());
    }
    IRepositoryViewObject reposObject = null;
    getAnalysisHandler().clearAnalysis();
    List<RepositoryNode> columnListAANode = anaColumnCompareViewer.getColumnListA();
    List<RepositoryNode> columnListBBNode = anaColumnCompareViewer.getColumnListB();
    AnalysisBuilder anaBuilder = new AnalysisBuilder();
    anaBuilder.setAnalysis(getCurrentModelElement());
    Connection tdDataProvider = null;
    for (int i = 0; i < columnListAANode.size(); i++) {
        if (columnListBBNode.size() > i) {
            ColumnDependencyIndicator indicator = ColumnsetFactory.eINSTANCE.createColumnDependencyIndicator();
            TdColumn columnA = (TdColumn) ((MetadataColumnRepositoryObject) columnListAANode.get(i).getObject()).getTdColumn();
            TdColumn columnB = (TdColumn) ((MetadataColumnRepositoryObject) columnListBBNode.get(i).getObject()).getTdColumn();
            indicator.setColumnA(columnA);
            indicator.setColumnB(columnB);
            indicator.setIndicatorDefinition(DefinitionHandler.getInstance().getFDRuleDefaultIndicatorDefinition());
            getCurrentModelElement().getResults().getIndicators().add(indicator);
            anaBuilder.addElementToAnalyze(columnA, indicator);
            // ADD this line qiongli 2010-6-8
            anaBuilder.addElementToAnalyze(columnB, indicator);
        }
    }
    if (columnListAANode.size() > 0) {
        reposObject = columnListAANode.get(0).getObject();
        tdDataProvider = ((ConnectionItem) reposObject.getProperty().getItem()).getConnection();
        // MOD qiongli bug 14437:Add dependency
        getCurrentModelElement().getContext().setConnection(tdDataProvider);
        TypedReturnCode<Dependency> rc = DependenciesHandler.getInstance().setDependencyOn(getCurrentModelElement(), tdDataProvider);
        if (!rc.isOk()) {
            // $NON-NLS-1$
            log.info("fail to save dependency analysis:" + getCurrentModelElement().getFileName());
        }
    } else {
        getCurrentModelElement().getContext().setConnection(null);
    }
    // save the number of connections per analysis
    this.saveNumberOfConnectionsPerAnalysis();
    // 2011.1.12 MOD by zhsne to unify anlysis and connection id when saving.
    this.nameText.setText(getCurrentModelElement().getName());
    // MOD yyi 2012-02-08 TDQ-4621:Explicitly set true for updating dependencies.
    ReturnCode saved = ElementWriterFactory.getInstance().createAnalysisWrite().save(getCurrentRepNode().getObject().getProperty().getItem(), true);
    // MOD yyi 2012-02-03 TDQ-3602:Avoid to rewriting all analyzes after saving, no reason to update all analyzes
    // which is depended in the referred connection.
    // Extract saving log function.
    // @see org.talend.dataprofiler.core.ui.editor.analysis.AbstractAnalysisMetadataPage#logSaved(ReturnCode)
    logSaved(saved);
    anaColumnCompareViewer.setDirty(false);
    dataFilterComp.setDirty(false);
}
Also used : ColumnDependencyIndicator(org.talend.dataquality.indicators.columnset.ColumnDependencyIndicator) TdColumn(org.talend.cwm.relational.TdColumn) TypedReturnCode(org.talend.utils.sugars.TypedReturnCode) ReturnCode(org.talend.utils.sugars.ReturnCode) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Connection(org.talend.core.model.metadata.builder.connection.Connection) AnalysisBuilder(org.talend.dq.analysis.AnalysisBuilder) Dependency(orgomg.cwm.objectmodel.core.Dependency) Domain(org.talend.dataquality.domain.Domain) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode)

Example 2 with ColumnDependencyIndicator

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

the class FunctionalDependencyAnalysisResultPage method initCustomerDataset.

/**
 * DOC xqliu Comment method "initCustomerDataset".
 *
 * @return
 */
private CustomerDefaultCategoryDataset initCustomerDataset() {
    CustomerDefaultCategoryDataset dataset = new CustomerDefaultCategoryDataset();
    Analysis analysis = this.getAnalysisHandler().getAnalysis();
    for (Indicator indicator2 : analysis.getResults().getIndicators()) {
        ColumnDependencyIndicator indicator = (ColumnDependencyIndicator) indicator2;
        String label = ColumnDependencyHelper.getIndicatorName(indicator);
        if (getAnalysisHandler().getResultMetadata().getExecutionNumber() > 0) {
            Long matchCount = indicator.getDistinctACount() == null ? 0 : indicator.getDistinctACount();
            Long notMatchCount = indicator.getACount() == null ? 0 : indicator.getACount() - matchCount;
            // $NON-NLS-1$
            dataset.addValue(matchCount, DefaultMessagesImpl.getString("ColumnDependencyResultPage.Match"), label);
            // $NON-NLS-1$
            dataset.addValue(notMatchCount, DefaultMessagesImpl.getString("ColumnDependencyResultPage.NotMatch"), label);
            PatternChartDataEntity dataEntity = new PatternChartDataEntity();
            dataEntity.setLabel(label);
            dataEntity.setIndicator(indicator);
            dataEntity.setNumMatch(matchCount.toString());
            dataEntity.setNumNoMatch(notMatchCount.toString());
            dataset.addDataEntity(dataEntity);
        }
    }
    return dataset;
}
Also used : ColumnDependencyIndicator(org.talend.dataquality.indicators.columnset.ColumnDependencyIndicator) PatternChartDataEntity(org.talend.dq.indicators.preview.table.PatternChartDataEntity) Analysis(org.talend.dataquality.analysis.Analysis) CustomerDefaultCategoryDataset(org.talend.dataprofiler.common.ui.editor.preview.CustomerDefaultCategoryDataset) Indicator(org.talend.dataquality.indicators.Indicator) ColumnDependencyIndicator(org.talend.dataquality.indicators.columnset.ColumnDependencyIndicator)

Example 3 with ColumnDependencyIndicator

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

the class ColumnDependencyExplorer method getDetailedInvalidValuesStatement.

private String getDetailedInvalidValuesStatement() {
    // MOD by zshen fixed 12039 to distinguish the same name of column.
    String genericSQL = dbmsLanguage.getFDGenericInvalidDetailedValues();
    ColumnDependencyIndicator cdIndicator = ((ColumnDependencyIndicator) this.indicator);
    TdColumn columnA = cdIndicator.getColumnA();
    TdColumn columnB = cdIndicator.getColumnB();
    if (columnA.getName().equals(columnB.getName())) {
        genericSQL = genericSQL.replaceFirst(GenericSQLHandler.COLUMN_NAMES_A, // $NON-NLS-1$
        dbmsLanguage.quote(columnA.getName()) + " AS " + columnA.getName() + // $NON-NLS-1$
        "_A");
        genericSQL = genericSQL.replaceFirst(GenericSQLHandler.COLUMN_NAMES_B, // $NON-NLS-1$
        dbmsLanguage.quote(columnB.getName()) + " AS " + columnA.getName() + // $NON-NLS-1$
        "_B");
    }
    return getStatement(genericSQL);
}
Also used : ColumnDependencyIndicator(org.talend.dataquality.indicators.columnset.ColumnDependencyIndicator) TdColumn(org.talend.cwm.relational.TdColumn)

Example 4 with ColumnDependencyIndicator

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

the class ColumnDependencyExplorer method getDetailedValidValuesStatement.

private String getDetailedValidValuesStatement() {
    // MOD by zshen fixed 12039 to distinguish the same name of column.
    String genericSQL = dbmsLanguage.getFDGenericValidDetailedValues();
    ColumnDependencyIndicator cdIndicator = ((ColumnDependencyIndicator) this.indicator);
    TdColumn columnA = cdIndicator.getColumnA();
    TdColumn columnB = cdIndicator.getColumnB();
    if (columnA.getName().equals(columnB.getName())) {
        genericSQL = genericSQL.replaceFirst(GenericSQLHandler.COLUMN_NAMES_A, // $NON-NLS-1$
        dbmsLanguage.quote(columnA.getName()) + " AS " + columnA.getName() + // $NON-NLS-1$
        "_A");
        genericSQL = genericSQL.replaceFirst(GenericSQLHandler.COLUMN_NAMES_B, // $NON-NLS-1$
        dbmsLanguage.quote(columnB.getName()) + " AS " + columnA.getName() + // $NON-NLS-1$
        "_B");
    }
    return getStatement(genericSQL);
}
Also used : ColumnDependencyIndicator(org.talend.dataquality.indicators.columnset.ColumnDependencyIndicator) TdColumn(org.talend.cwm.relational.TdColumn)

Example 5 with ColumnDependencyIndicator

use of org.talend.dataquality.indicators.columnset.ColumnDependencyIndicator 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)

Aggregations

ColumnDependencyIndicator (org.talend.dataquality.indicators.columnset.ColumnDependencyIndicator)9 TdColumn (org.talend.cwm.relational.TdColumn)7 Indicator (org.talend.dataquality.indicators.Indicator)4 Analysis (org.talend.dataquality.analysis.Analysis)2 AnalysisBuilder (org.talend.dq.analysis.AnalysisBuilder)2 ArrayList (java.util.ArrayList)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 Connection (org.talend.core.model.metadata.builder.connection.Connection)1 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)1 CustomerDefaultCategoryDataset (org.talend.dataprofiler.common.ui.editor.preview.CustomerDefaultCategoryDataset)1 AnalysisType (org.talend.dataquality.analysis.AnalysisType)1 Domain (org.talend.dataquality.domain.Domain)1 DataminingType (org.talend.dataquality.indicators.DataminingType)1 ColumnSetMultiValueIndicator (org.talend.dataquality.indicators.columnset.ColumnSetMultiValueIndicator)1 ColumnsCompareIndicator (org.talend.dataquality.indicators.columnset.ColumnsCompareIndicator)1 RowMatchingIndicator (org.talend.dataquality.indicators.columnset.RowMatchingIndicator)1 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)1 GenericSQLHandler (org.talend.dq.dbms.GenericSQLHandler)1