Search in sources :

Example 1 with RowMatchingIndicator

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

the class RedundancyAnalysisDetailsPage method initialize.

@Override
public void initialize(FormEditor editor) {
    super.initialize(editor);
    // MOD xqliu 2009-06-10 bug7334
    stringDataFilterA = AnalysisHelper.getStringDataFilter(getCurrentModelElement(), 0);
    stringDataFilterB = AnalysisHelper.getStringDataFilter(getCurrentModelElement(), 1);
    // ~
    if (getCurrentModelElement().getResults().getIndicators().size() == 0) {
        ColumnsetFactory factory = ColumnsetFactory.eINSTANCE;
        rowMatchingIndicatorA = factory.createRowMatchingIndicator();
        rowMatchingIndicatorB = factory.createRowMatchingIndicator();
        Indicator[] currentIndicators = new Indicator[] { rowMatchingIndicatorA, rowMatchingIndicatorB };
        setDefaultIndDef(currentIndicators);
    } else {
        EList<Indicator> indicators = getCurrentModelElement().getResults().getIndicators();
        rowMatchingIndicatorA = (RowMatchingIndicator) indicators.get(0);
        rowMatchingIndicatorB = (RowMatchingIndicator) indicators.get(1);
    }
}
Also used : ColumnsetFactory(org.talend.dataquality.indicators.columnset.ColumnsetFactory) Indicator(org.talend.dataquality.indicators.Indicator) RowMatchingIndicator(org.talend.dataquality.indicators.columnset.RowMatchingIndicator)

Example 2 with RowMatchingIndicator

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

the class RedundancyAnalysisResultPage method createAnalyzedColumnSetsSection.

private void createAnalyzedColumnSetsSection(Composite parent) {
    columnSetSection = createSection(form, parent, DefaultMessagesImpl.getString("ColumnsComparisonAnalysisResultPage.analyzedColumnSets"), // $NON-NLS-1$
    null);
    Composite sectionClient = toolkit.createComposite(columnSetSection);
    sectionClient.setLayout(new GridLayout());
    sectionClient.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    TableViewer elementsTableViewer = new TableViewer(sectionClient, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    Table table = elementsTableViewer.getTable();
    GridDataFactory.fillDefaults().applyTo(table);
    ((GridData) table.getLayoutData()).heightHint = 240;
    ((GridData) table.getLayoutData()).widthHint = 600;
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    table.setDragDetect(true);
    // $NON-NLS-1$
    table.setToolTipText(DefaultMessagesImpl.getString("ColumnsComparisonAnalysisResultPage.dragAndDropToolTip"));
    final TableColumn columnHeader1 = new TableColumn(table, SWT.LEAD);
    columnHeader1.setWidth(300);
    final TableColumn columnHeader2 = new TableColumn(table, SWT.LEAD);
    columnHeader2.setWidth(300);
    Analysis analysis = this.masterPage.getAnalysisHandler().getAnalysis();
    isHasDeactivatedIndicator = analysis.getParameters().getDeactivatedIndicators().size() != 0;
    EList<Indicator> indicators = analysis.getResults().getIndicators();
    if (indicators.size() != 0) {
        rowMatchingIndicatorA = (RowMatchingIndicator) indicators.get(0);
        rowMatchingIndicatorB = (RowMatchingIndicator) indicators.get(1);
        TdColumn columnA = null;
        if (rowMatchingIndicatorA.getColumnSetA().size() > 0) {
            columnA = rowMatchingIndicatorA.getColumnSetA().get(0);
            if (columnA.eIsProxy()) {
                columnA = (TdColumn) EObjectHelper.resolveObject(columnA);
            }
        }
        String columnName = rowMatchingIndicatorA.getColumnSetA().size() > 0 ? ColumnHelper.getColumnOwnerAsColumnSet(columnA).getName() : PluginConstant.EMPTY_STRING;
        columnHeader1.setText(columnName.equals(PluginConstant.EMPTY_STRING) ? columnName : DefaultMessagesImpl.getString("ColumnsComparisonAnalysisResultPage.elementsFrom", // $NON-NLS-1$
        columnName));
        TdColumn columnB = null;
        if (rowMatchingIndicatorA.getColumnSetB().size() > 0) {
            columnB = rowMatchingIndicatorA.getColumnSetB().get(0);
            if (columnB.eIsProxy()) {
                columnB = (TdColumn) EObjectHelper.resolveObject(columnB);
            }
        }
        columnName = rowMatchingIndicatorA.getColumnSetA().size() > 0 ? ColumnHelper.getColumnOwnerAsColumnSet(columnB).getName() : PluginConstant.EMPTY_STRING;
        columnHeader2.setText(columnName.equals(PluginConstant.EMPTY_STRING) ? columnName : DefaultMessagesImpl.getString("ColumnsComparisonAnalysisResultPage.elementsFrom", // $NON-NLS-1$
        columnName));
    }
    ColumnPairsViewerProvider provider = new ColumnPairsViewerProvider();
    elementsTableViewer.setContentProvider(provider);
    elementsTableViewer.setLabelProvider(provider);
    elementsTableViewer.setInput(rowMatchingIndicatorA);
    columnSetSection.setClient(sectionClient);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Table(org.eclipse.swt.widgets.Table) TdColumn(org.talend.cwm.relational.TdColumn) Composite(org.eclipse.swt.widgets.Composite) Analysis(org.talend.dataquality.analysis.Analysis) GridData(org.eclipse.swt.layout.GridData) TableViewer(org.eclipse.jface.viewers.TableViewer) TableColumn(org.eclipse.swt.widgets.TableColumn) Indicator(org.talend.dataquality.indicators.Indicator) RowMatchingIndicator(org.talend.dataquality.indicators.columnset.RowMatchingIndicator)

Example 3 with RowMatchingIndicator

use of org.talend.dataquality.indicators.columnset.RowMatchingIndicator 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 4 with RowMatchingIndicator

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

the class RedundancyAnalysisResultPage method createResultSection.

@Override
protected void createResultSection(Composite parent) {
    resultSection = createSection(form, parent, DefaultMessagesImpl.getString("ColumnsComparisonAnalysisResultPage.analysisResults"), // $NON-NLS-1$ //$NON-NLS-2$
    "");
    Composite sectionClient = toolkit.createComposite(resultSection);
    sectionClient.setLayout(new GridLayout(2, false));
    sectionClient.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    resultSection.setClient(sectionClient);
    if (executeData == null || executeData.equals(PluginConstant.EMPTY_STRING)) {
        return;
    }
    Table resultTable = new Table(sectionClient, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    resultTable.setLinesVisible(true);
    resultTable.setHeaderVisible(true);
    final TableColumn columnHeader0 = new TableColumn(resultTable, SWT.LEAD);
    columnHeader0.setWidth(100);
    final TableColumn columnHeader1 = new TableColumn(resultTable, SWT.LEAD);
    columnHeader1.setWidth(150);
    // add by hcheng for 6503:change the "set A" and "set B" labels
    Analysis analysis = this.masterPage.getAnalysisHandler().getAnalysis();
    EList<Indicator> indicators = analysis.getResults().getIndicators();
    rowMatchingIndicatorA = (RowMatchingIndicator) indicators.get(0);
    rowMatchingIndicatorB = (RowMatchingIndicator) indicators.get(1);
    // MOD yyi 2009-10-27 9100: not save when remove element in comparison analysis
    int sizeA = rowMatchingIndicatorA.getColumnSetA().size();
    int sizeB = rowMatchingIndicatorA.getColumnSetB().size();
    if (sizeA > 0 && sizeB > 0) {
        TdColumn columnA = rowMatchingIndicatorA.getColumnSetA().get(0);
        if (columnA.eIsProxy()) {
            columnA = (TdColumn) EObjectHelper.resolveObject(columnA);
        }
        String tableNameA = ColumnHelper.getColumnOwnerAsColumnSet(columnA).getName();
        TdColumn columnB = rowMatchingIndicatorA.getColumnSetB().get(0);
        if (columnB.eIsProxy()) {
            columnB = (TdColumn) EObjectHelper.resolveObject(columnB);
        }
        String tableNameB = ColumnHelper.getColumnOwnerAsColumnSet(columnB).getName();
        // MOD zshen 11136: the chart of result lose one table
        if (tableNameA.equals(tableNameB)) {
            // $NON-NLS-1$
            tableNameB = tableNameB + "(*)";
        }
        // ~11136
        columnHeader1.setText(tableNameA);
        if (!isHasDeactivatedIndicator) {
            final TableColumn columnHeader2 = new TableColumn(resultTable, SWT.LEAD);
            columnHeader2.setWidth(150);
            columnHeader2.setText(tableNameB);
        }
        createTableItems(resultTable);
        if (canShowChartForResultPage()) {
            creatChart(sectionClient, tableNameA, tableNameB);
        }
        StringBuilder description = new StringBuilder();
        description.append(DefaultMessagesImpl.getString("ColumnsComparisonAnalysisResultPage.ASetFoundInB", setAMatchPercent, tableNameA, // $NON-NLS-1$
        tableNameB));
        if (!isHasDeactivatedIndicator) {
            // $NON-NLS-1$
            description.append("\n");
            description.append(DefaultMessagesImpl.getString("ColumnsComparisonAnalysisResultPage.BSetFoundInA", setBMatchPercent, tableNameB, // $NON-NLS-1$
            tableNameA));
        }
        resultSection.setDescription(description.toString());
    }
    resultSection.layout();
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Table(org.eclipse.swt.widgets.Table) TdColumn(org.talend.cwm.relational.TdColumn) Composite(org.eclipse.swt.widgets.Composite) Analysis(org.talend.dataquality.analysis.Analysis) GridData(org.eclipse.swt.layout.GridData) TableColumn(org.eclipse.swt.widgets.TableColumn) Indicator(org.talend.dataquality.indicators.Indicator) RowMatchingIndicator(org.talend.dataquality.indicators.columnset.RowMatchingIndicator)

Example 5 with RowMatchingIndicator

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

the class RowMatchExplorerTest method setUpBeforeClass.

@BeforeClass
public static void setUpBeforeClass() throws Exception {
    // analysis
    analysis = AnalysisFactory.eINSTANCE.createAnalysis();
    AnalysisContext context = AnalysisFactory.eINSTANCE.createAnalysisContext();
    analysis.setContext(context);
    AnalysisResult mockResults = AnalysisFactory.eINSTANCE.createAnalysisResult();
    analysis.setResults(mockResults);
    // connection
    connection = ConnectionFactory.eINSTANCE.createDatabaseConnection();
    analysis.getContext().setConnection(connection);
    TaggedValueHelper.setTaggedValue(connection, TaggedValueHelper.DB_PRODUCT_NAME, TaggedValueHelper.DB_PRODUCT_NAME);
    // ------------------------- table A ------------------------------
    Catalog catalogA = orgomg.cwm.resource.relational.RelationalFactory.eINSTANCE.createCatalog();
    // $NON-NLS-1$
    catalogA.setName("catalogA");
    Schema schemaA = orgomg.cwm.resource.relational.RelationalFactory.eINSTANCE.createSchema();
    // $NON-NLS-1$
    schemaA.setName("schemaA");
    catalogA.getOwnedElement().add(schemaA);
    TdTable tableA = RelationalFactory.eINSTANCE.createTdTable();
    // $NON-NLS-1$
    tableA.setName("tableA");
    schemaA.getOwnedElement().add(tableA);
    TdColumn tdColumnA = RelationalFactory.eINSTANCE.createTdColumn();
    // $NON-NLS-1$
    tdColumnA.setName("columnA");
    tableA.getFeature().add(tdColumnA);
    // ------------------------- table B ------------------------------
    Catalog catalogB = orgomg.cwm.resource.relational.RelationalFactory.eINSTANCE.createCatalog();
    // $NON-NLS-1$
    catalogB.setName("catalogB");
    Schema schemaB = orgomg.cwm.resource.relational.RelationalFactory.eINSTANCE.createSchema();
    // $NON-NLS-1$
    schemaB.setName("schemaB");
    catalogB.getOwnedElement().add(schemaB);
    TdTable tableB = org.talend.cwm.relational.RelationalFactory.eINSTANCE.createTdTable();
    // $NON-NLS-1$
    tableB.setName("tableB");
    schemaB.getOwnedElement().add(tableB);
    TdColumn tdColumnB = org.talend.cwm.relational.RelationalFactory.eINSTANCE.createTdColumn();
    // $NON-NLS-1$
    tdColumnB.setName("columnB");
    tableB.getFeature().add(tdColumnB);
    // indicator
    RowMatchingIndicator rowMatchingIndicator = ColumnsetFactory.eINSTANCE.createRowMatchingIndicator();
    // create indicatorDefinition
    IndicatorDefinition testIndicatorDefinition = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
    // $NON-NLS-1$
    testIndicatorDefinition.setName("RowMatchingIndicator");
    rowMatchingIndicator.setIndicatorDefinition(testIndicatorDefinition);
    analysis.getResults().getIndicators().add(rowMatchingIndicator);
    TaggedValueHelper.setTaggedValue(analysis, TaggedValueHelper.PURPOSE, TaggedValueHelper.PURPOSE);
    TaggedValueHelper.setTaggedValue(analysis, TaggedValueHelper.DESCRIPTION, TaggedValueHelper.DESCRIPTION);
    rowMatchingIndicator.setAnalyzedElement(tableA);
    rowMatchingIndicator.getColumnSetA().add(tdColumnA);
    rowMatchingIndicator.getColumnSetB().add(tdColumnB);
    explorer = new RowMatchExplorer();
    entity = new ChartDataEntity();
    entity.setIndicator(rowMatchingIndicator);
}
Also used : TdTable(org.talend.cwm.relational.TdTable) TdColumn(org.talend.cwm.relational.TdColumn) Schema(orgomg.cwm.resource.relational.Schema) RowMatchingIndicator(org.talend.dataquality.indicators.columnset.RowMatchingIndicator) AnalysisContext(org.talend.dataquality.analysis.AnalysisContext) ChartDataEntity(org.talend.dq.indicators.preview.table.ChartDataEntity) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) AnalysisResult(org.talend.dataquality.analysis.AnalysisResult) Catalog(orgomg.cwm.resource.relational.Catalog) BeforeClass(org.junit.BeforeClass)

Aggregations

RowMatchingIndicator (org.talend.dataquality.indicators.columnset.RowMatchingIndicator)10 TdColumn (org.talend.cwm.relational.TdColumn)7 Indicator (org.talend.dataquality.indicators.Indicator)4 ColumnSet (orgomg.cwm.resource.relational.ColumnSet)3 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Composite (org.eclipse.swt.widgets.Composite)2 Table (org.eclipse.swt.widgets.Table)2 TableColumn (org.eclipse.swt.widgets.TableColumn)2 Analysis (org.talend.dataquality.analysis.Analysis)2 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)2 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 BeforeClass (org.junit.BeforeClass)1 AnalysisExecutionException (org.talend.cwm.exception.AnalysisExecutionException)1 TdTable (org.talend.cwm.relational.TdTable)1 AnalysisContext (org.talend.dataquality.analysis.AnalysisContext)1 AnalysisResult (org.talend.dataquality.analysis.AnalysisResult)1 ColumnDependencyIndicator (org.talend.dataquality.indicators.columnset.ColumnDependencyIndicator)1