Search in sources :

Example 1 with CompositeIndicator

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

the class CorrelationAnalysisDetailsPage method initializeIndicator.

private void initializeIndicator(Indicator indicator) {
    if (indicator.getIndicatorDefinition() == null) {
        DefinitionHandler.getInstance().setDefaultIndicatorDefinition(indicator);
    }
    // MOD xqliu 2010-04-06 bug 12161
    if (indicator instanceof CountAvgNullIndicator) {
        if (((CountAvgNullIndicator) indicator).getChildIndicators().size() == 0) {
            CountAvgNullIndicator countAvgNullIndicator = (CountAvgNullIndicator) indicator;
            fillSimpleIndicators(countAvgNullIndicator);
        }
        for (Indicator child : ((CompositeIndicator) indicator).getChildIndicators()) {
            // recurse
            initializeIndicator(child);
        }
    } else if (indicator instanceof CompositeIndicator) {
        // MOD qiongli 2012-5-14 TDQ-5256 should initialize children
        for (Indicator child : ((CompositeIndicator) indicator).getChildIndicators()) {
            initializeIndicator(child);
        }
    }
}
Also used : CompositeIndicator(org.talend.dataquality.indicators.CompositeIndicator) CountAvgNullIndicator(org.talend.dataquality.indicators.columnset.CountAvgNullIndicator) ColumnSetMultiValueIndicator(org.talend.dataquality.indicators.columnset.ColumnSetMultiValueIndicator) CountAvgNullIndicator(org.talend.dataquality.indicators.columnset.CountAvgNullIndicator) Indicator(org.talend.dataquality.indicators.Indicator) CompositeIndicator(org.talend.dataquality.indicators.CompositeIndicator)

Example 2 with CompositeIndicator

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

the class CompositeIndicatorImpl method getLeafIndicators.

/**
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 *
 * @generated NOT getLeafIndicators()
 */
public EList<Indicator> getLeafIndicators() {
    EList<Indicator> leafIndicators = new BasicEList<Indicator>();
    EList<Indicator> childIndicators = getChildIndicators();
    for (Indicator indicator : childIndicators) {
        if (indicator instanceof CompositeIndicator) {
            leafIndicators.addAll(((CompositeIndicator) indicator).getLeafIndicators());
        } else {
            leafIndicators.add(indicator);
        }
    }
    return leafIndicators;
}
Also used : BasicEList(org.eclipse.emf.common.util.BasicEList) CompositeIndicator(org.talend.dataquality.indicators.CompositeIndicator) Indicator(org.talend.dataquality.indicators.Indicator) CompositeIndicator(org.talend.dataquality.indicators.CompositeIndicator)

Example 3 with CompositeIndicator

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

the class AnalysisColumnTreeViewer method createTree.

/**
 * @param parent
 */
private Tree createTree(Composite parent) {
    final Tree newTree = new TooltipTree(parent, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION) {

        @Override
        protected boolean isValidItem(TreeItem item) {
            if (item == null) {
                return false;
            }
            Object itemData = item.getData(INDICATOR_UNIT_KEY);
            Object columnItemData = item.getData(MODELELEMENT_INDICATOR_KEY);
            if (itemData != null) {
                IndicatorUnit indicatorUnit = (IndicatorUnit) item.getData(INDICATOR_UNIT_KEY);
                if (indicatorUnit != null && !(indicatorUnit.getIndicator() instanceof CompositeIndicator)) {
                    return true;
                }
                return false;
            } else {
                if (columnItemData != null) {
                    ModelElementIndicator modelElementIndicator = (ModelElementIndicator) columnItemData;
                    IRepositoryNode modelElementRepositoryNode = modelElementIndicator.getModelElementRepositoryNode();
                    return modelElementRepositoryNode == null ? false : true;
                }
                return false;
            }
        }

        @Override
        protected String getItemTooltipText(TreeItem item) {
            String expCont = isExpressionNull(item);
            if (expCont == null) {
                // $NON-NLS-1$
                return DefaultMessagesImpl.getString("AnalysisColumnTreeViewer.queryNotGen");
            }
            return expCont;
        }
    };
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(newTree);
    newTree.setHeaderVisible(true);
    // $NON-NLS-1$
    createTreeItem(newTree, 300, "AnalysisColumnTreeViewer.analyzedColumns");
    createTreeDataminingItem(newTree);
    // $NON-NLS-1$
    createTreeItem(newTree, 80, "AnalysisColumnTreeViewer.pattern");
    // $NON-NLS-1$
    createTreeItem(newTree, 80, "AnalysisColumnTreeViewer.udi");
    // $NON-NLS-1$
    createTreeItem(newTree, 80, "AnalysisColumnTreeViewer.operation");
    // TDQ-11622 : add a column here, let the width = 1 and text = EMPTY_STRING TODO need to find a better solution!
    TreeColumn blankColumn = new TreeColumn(newTree, SWT.CENTER);
    blankColumn.setWidth(1);
    // ~ TDQ-11622
    parent.layout();
    AbstractAnalysisActionHandler actionHandler = new AbstractAnalysisActionHandler(parent) {

        @Override
        protected void handleRemove() {
            removeSelectedElements(newTree);
        }
    };
    parent.setData(AbstractMetadataFormPage.ACTION_HANDLER, actionHandler);
    ColumnViewerDND.installDND(newTree);
    this.addTreeListener(newTree);
    newTree.setData(this);
    return newTree;
}
Also used : AbstractAnalysisActionHandler(org.talend.dataprofiler.core.ui.editor.AbstractAnalysisActionHandler) IRepositoryNode(org.talend.repository.model.IRepositoryNode) TreeItem(org.eclipse.swt.widgets.TreeItem) TreeColumn(org.eclipse.swt.widgets.TreeColumn) CompositeIndicator(org.talend.dataquality.indicators.CompositeIndicator) IndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit) TooltipTree(org.talend.dataprofiler.core.ui.dialog.composite.TooltipTree) Tree(org.eclipse.swt.widgets.Tree) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) MetadataXmlElementTypeRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataXmlElementTypeRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) TooltipTree(org.talend.dataprofiler.core.ui.dialog.composite.TooltipTree) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator)

Example 4 with CompositeIndicator

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

the class AnalysisTableTreeViewer method createTree.

private Tree createTree(Composite parent) {
    final Tree newTree = new TooltipTree(parent, SWT.MULTI | SWT.BORDER) {

        @Override
        protected boolean isValidItem(TreeItem item) {
            if (item == null) {
                return false;
            }
            Object itemData = item.getData(INDICATOR_UNIT_KEY);
            if (itemData != null) {
                TableIndicatorUnit indicatorUnit = (TableIndicatorUnit) item.getData(INDICATOR_UNIT_KEY);
                if (indicatorUnit != null && !(indicatorUnit.getIndicator() instanceof CompositeIndicator)) {
                    return true;
                }
                return false;
            } else {
                return false;
            }
        }

        @Override
        protected String getItemTooltipText(TreeItem item) {
            String expCont = isExpressionNull(item);
            if (expCont == null) {
                // $NON-NLS-1$
                return DefaultMessagesImpl.getString("AnalysisTableTreeViewer.queryNotGen");
            }
            return expCont;
        }
    };
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(newTree);
    newTree.setHeaderVisible(true);
    // $NON-NLS-1$
    createTreeItem(newTree, 190, "AnalysisTableTreeViewer.analyzedTables");
    // $NON-NLS-1$
    createTreeItem(newTree, 80, "AnalysisTableTreeViewer.dqrule");
    // $NON-NLS-1$
    createTreeItem(newTree, 80, "AnalysisColumnTreeViewer.operation");
    parent.layout();
    AbstractAnalysisActionHandler actionHandler = new AbstractAnalysisActionHandler(parent) {

        @Override
        protected void handleRemove() {
            removeSelectedElements(newTree);
        }
    };
    parent.setData(AbstractMetadataFormPage.ACTION_HANDLER, actionHandler);
    TableViewerDND.installDND(newTree);
    this.addTreeListener(newTree);
    newTree.setData(this);
    return newTree;
}
Also used : AbstractAnalysisActionHandler(org.talend.dataprofiler.core.ui.editor.AbstractAnalysisActionHandler) TreeItem(org.eclipse.swt.widgets.TreeItem) CompositeIndicator(org.talend.dataquality.indicators.CompositeIndicator) TooltipTree(org.talend.dataprofiler.core.ui.dialog.composite.TooltipTree) Tree(org.eclipse.swt.widgets.Tree) TableIndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.TableIndicatorUnit) TooltipTree(org.talend.dataprofiler.core.ui.dialog.composite.TooltipTree)

Example 5 with CompositeIndicator

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

the class ColumnAnalysisSqlParallelExecutor method run.

/**
 * run analysis when SqlParallelExecutor.
 *
 * @return true if successfull , false otherwise.
 */
public Boolean run() {
    Expression query = null;
    try {
        if (!continueRun()) {
            return Boolean.FALSE;
        }
        // skip composite indicators that do not require a sql execution
        if (indicator instanceof CompositeIndicator) {
            // options of composite indicators are handled elsewhere
            return Boolean.TRUE;
        }
        synchronized (schemata) {
            // set the connection's catalog
            if (belongToSameSchemata(indicator.getAnalyzedElement())) {
                if (needChangeCatalog(connection)) {
                    String catalogName = getCatalogOrSchemaName(indicator.getAnalyzedElement());
                    if (catalogName != null) {
                        // check whether null argument can be given
                        changeCatalog(catalogName, connection);
                    }
                }
            }
        }
        // add mapping of analyzed elements to their indicators
        synchronized (elementToIndicator) {
            addElements2IndicatorsMapping(elementToIndicator, indicator);
        }
        query = dbms().getInstantiatedExpression(indicator);
        if (query == null) {
            traceError(getErrorMessageForQuery(query));
            return Boolean.FALSE;
        }
        try {
            boolean execStatus = executeQuery(indicator, connection, query.getBody());
            if (!execStatus) {
                traceError(getErrorMessageForQuery(query));
                return Boolean.FALSE;
            }
        } catch (SQLException e) {
            log.error(e, e);
            traceError(getErrorMessageForQuery(query));
            return Boolean.FALSE;
        }
        // set computation done
        indicator.setComputed(true);
    } finally {
        // return the connection after run
        if (POOLED_CONNECTION) {
            TdqAnalysisConnectionPool.returnPooledConnection(cachedAnalysis, connection);
        }
    }
    return Boolean.TRUE;
}
Also used : Expression(orgomg.cwm.objectmodel.core.Expression) SQLException(java.sql.SQLException) CompositeIndicator(org.talend.dataquality.indicators.CompositeIndicator)

Aggregations

CompositeIndicator (org.talend.dataquality.indicators.CompositeIndicator)9 Indicator (org.talend.dataquality.indicators.Indicator)6 BasicEList (org.eclipse.emf.common.util.BasicEList)2 Tree (org.eclipse.swt.widgets.Tree)2 TreeItem (org.eclipse.swt.widgets.TreeItem)2 TooltipTree (org.talend.dataprofiler.core.ui.dialog.composite.TooltipTree)2 AbstractAnalysisActionHandler (org.talend.dataprofiler.core.ui.editor.AbstractAnalysisActionHandler)2 NullCountIndicator (org.talend.dataquality.indicators.NullCountIndicator)2 RowCountIndicator (org.talend.dataquality.indicators.RowCountIndicator)2 UserDefIndicator (org.talend.dataquality.indicators.sql.UserDefIndicator)2 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 IFile (org.eclipse.core.resources.IFile)1 IFolder (org.eclipse.core.resources.IFolder)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 URI (org.eclipse.emf.common.util.URI)1 TreeColumn (org.eclipse.swt.widgets.TreeColumn)1 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)1 MetadataColumnRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject)1