Search in sources :

Example 11 with TableIndicator

use of org.talend.dataprofiler.core.model.TableIndicator in project tdq-studio-se by Talend.

the class BusinessRuleAnalysisDetailsPage method recomputeIndicators.

public void recomputeIndicators() {
    analysisHandler = new TableAnalysisHandler();
    analysisHandler.setAnalysis(getCurrentModelElement());
    stringDataFilter = analysisHandler.getStringDataFilter();
    EList<ModelElement> analyzedTables = analysisHandler.getAnalyzedTables();
    List<TableIndicator> tableIndicatorList = new ArrayList<TableIndicator>();
    for (ModelElement element : analyzedTables) {
        NamedColumnSet set = SwitchHelpers.NAMED_COLUMN_SET_SWITCH.doSwitch(element);
        if (set == null) {
            continue;
        }
        TableIndicator currentTableIndicator = new TableIndicator(set);
        Collection<Indicator> indicatorList = analysisHandler.getIndicators(set);
        currentTableIndicator.setIndicators(indicatorList.toArray(new Indicator[indicatorList.size()]));
        tableIndicatorList.add(currentTableIndicator);
    }
    currentTableIndicators = tableIndicatorList.toArray(new TableIndicator[tableIndicatorList.size()]);
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) TableIndicator(org.talend.dataprofiler.core.model.TableIndicator) TableAnalysisHandler(org.talend.dq.analysis.TableAnalysisHandler) ArrayList(java.util.ArrayList) NamedColumnSet(orgomg.cwm.resource.relational.NamedColumnSet) CompositeIndicator(org.talend.dataprofiler.core.ui.editor.preview.CompositeIndicator) Indicator(org.talend.dataquality.indicators.Indicator) TableIndicator(org.talend.dataprofiler.core.model.TableIndicator)

Example 12 with TableIndicator

use of org.talend.dataprofiler.core.model.TableIndicator in project tdq-studio-se by Talend.

the class AnalysisTableTreeViewer method setInput.

/**
 * DOC xqliu Comment method "setInput".
 *
 * @param objs
 */
@Override
public void setInput(Object[] objs) {
    List<DBTableRepNode> tableNodeList = RepositoryNodeHelper.getTableNodeList(objs);
    List<TableIndicator> tableIndicatorList = new ArrayList<TableIndicator>();
    // MOD by zshen for 2011.06.13 add the support for the view.
    List<DBViewRepNode> viewNodeList = RepositoryNodeHelper.getViewNodeList(objs);
    if (tableNodeList.size() == 0 && viewNodeList.size() == 0) {
        // feature 22206 : fixed another bug, when deselect all, the view is not changed
        this.tableIndicators = tableIndicatorList.toArray(new TableIndicator[tableIndicatorList.size()]);
        this.setElements(tableIndicators);
        return;
    }
    List<RepositoryNode> setList = new ArrayList<RepositoryNode>();
    Connection tdProvider = null;
    for (DBTableRepNode tableNode : tableNodeList) {
        if (tdProvider == null) {
            tdProvider = ConnectionHelper.getTdDataProvider(TableHelper.getParentCatalogOrSchema(tableNode.getTdTable()));
        }
        if (tdProvider == null) {
            MessageUI.openError(DefaultMessagesImpl.getString("AnalysisTableTreeViewer.TableProviderIsNull", // $NON-NLS-1$
            tableNode.getLabel()));
        } else if (this.getAnalysis().getContext().getConnection() != null && !tdProvider.equals(this.getAnalysis().getContext().getConnection())) {
            MessageUI.openError(DefaultMessagesImpl.getString("AnalysisTableTreeViewer.TableDataProviderIsInvalid", // $NON-NLS-1$
            tableNode.getLabel()));
        } else {
            setList.add(tableNode);
        }
    }
    for (DBViewRepNode tableNode : viewNodeList) {
        if (tdProvider == null) {
            tdProvider = ConnectionHelper.getTdDataProvider(TableHelper.getParentCatalogOrSchema(tableNode.getTdView()));
        }
        if (tdProvider == null) {
            MessageUI.openError(DefaultMessagesImpl.getString("AnalysisTableTreeViewer.TableProviderIsNull", // $NON-NLS-1$
            tableNode.getLabel()));
        } else if (this.getAnalysis().getContext().getConnection() != null && !tdProvider.equals(this.getAnalysis().getContext().getConnection())) {
            MessageUI.openError(DefaultMessagesImpl.getString("AnalysisTableTreeViewer.TableDataProviderIsInvalid", // $NON-NLS-1$
            tableNode.getLabel()));
        } else {
            setList.add(tableNode);
        }
    }
    for (TableIndicator tableIndicator : tableIndicators) {
        // ADDED yyin 20120606 TDQ-5343
        NamedColumnSet selectedTable = tableIndicator.getColumnSet();
        DQRepositoryNode tableNode = null;
        if (selectedTable instanceof TdTable) {
            tableNode = RepositoryNodeHelper.recursiveFindTdTable(((TdTable) selectedTable));
        } else if (selectedTable instanceof TdView) {
            tableNode = RepositoryNodeHelper.recursiveFindTdView(((TdView) selectedTable));
        }
        // ~
        if (setList.contains(tableNode)) {
            tableIndicatorList.add(tableIndicator);
            setList.remove(tableNode);
        }
    }
    for (RepositoryNode set : setList) {
        TableIndicator tableIndicator = null;
        if (set instanceof DBViewRepNode) {
            tableIndicator = TableIndicator.createTableIndicatorWithRowCountIndicator(((DBViewRepNode) set).getTdView());
        } else if (set instanceof DBTableRepNode) {
            tableIndicator = TableIndicator.createTableIndicatorWithRowCountIndicator(((DBTableRepNode) set).getTdTable());
        } else {
            continue;
        }
        tableIndicatorList.add(tableIndicator);
    }
    this.tableIndicators = tableIndicatorList.toArray(new TableIndicator[tableIndicatorList.size()]);
    this.setElements(tableIndicators);
}
Also used : TableIndicator(org.talend.dataprofiler.core.model.TableIndicator) TdTable(org.talend.cwm.relational.TdTable) ArrayList(java.util.ArrayList) Connection(org.talend.core.model.metadata.builder.connection.Connection) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) TdView(org.talend.cwm.relational.TdView) DBViewRepNode(org.talend.dq.nodes.DBViewRepNode) NamedColumnSet(orgomg.cwm.resource.relational.NamedColumnSet)

Example 13 with TableIndicator

use of org.talend.dataprofiler.core.model.TableIndicator in project tdq-studio-se by Talend.

the class AnalysisTableTreeViewer method canDrop.

@Override
public boolean canDrop(NamedColumnSet set) {
    Connection tdProvider = ConnectionHelper.getTdDataProvider(TableHelper.getParentCatalogOrSchema(set));
    if (tdProvider == null) {
        return false;
    } else if (this.getAnalysis().getContext().getConnection() != null && !tdProvider.equals(this.getAnalysis().getContext().getConnection())) {
        return false;
    }
    List<NamedColumnSet> existSets = new ArrayList<NamedColumnSet>();
    for (TableIndicator tableIndicator : getTableIndicator()) {
        existSets.add(tableIndicator.getColumnSet());
    }
    if (existSets.contains(set)) {
        return false;
    }
    return true;
}
Also used : TableIndicator(org.talend.dataprofiler.core.model.TableIndicator) Connection(org.talend.core.model.metadata.builder.connection.Connection) ArrayList(java.util.ArrayList) NamedColumnSet(orgomg.cwm.resource.relational.NamedColumnSet)

Example 14 with TableIndicator

use of org.talend.dataprofiler.core.model.TableIndicator in project tdq-studio-se by Talend.

the class AnalysisTableTreeViewer method getOwnedWhereRuleNodes.

/**
 * DOC xqliu Comment method "getOwnedWhereRuleFiles". ADD xqliu 2009-04-30 bug 6808
 *
 * @param tableIndicator
 * @param whereRuleFolder
 * @return
 */
private Object[] getOwnedWhereRuleNodes(TableIndicator tableIndicator) {
    ArrayList<RuleRepNode> ret = new ArrayList<RuleRepNode>();
    Indicator[] indicators = tableIndicator.getIndicators();
    for (Indicator indicator : indicators) {
        if (IndicatorHelper.isWhereRuleIndicator(indicator)) {
            Object obj = indicator.getIndicatorDefinition();
            if (obj != null && obj instanceof WhereRule) {
                WhereRule wr = (WhereRule) obj;
                RuleRepNode recursiveFindRuleSql = RepositoryNodeHelper.recursiveFindRuleSql(wr);
                if (recursiveFindRuleSql != null) {
                    ret.add(recursiveFindRuleSql);
                }
            }
        }
    }
    return ret.toArray();
}
Also used : WhereRule(org.talend.dataquality.rules.WhereRule) ArrayList(java.util.ArrayList) RuleRepNode(org.talend.dq.nodes.RuleRepNode) FrequencyIndicator(org.talend.dataquality.indicators.FrequencyIndicator) RowCountIndicator(org.talend.dataquality.indicators.RowCountIndicator) Indicator(org.talend.dataquality.indicators.Indicator) CompositeIndicator(org.talend.dataquality.indicators.CompositeIndicator) TableIndicator(org.talend.dataprofiler.core.model.TableIndicator) WhereRuleIndicator(org.talend.dataquality.indicators.sql.WhereRuleIndicator)

Example 15 with TableIndicator

use of org.talend.dataprofiler.core.model.TableIndicator in project tdq-studio-se by Talend.

the class AnalysisTableTreeViewer method deleteTableItems.

private void deleteTableItems(TableIndicator deleteTableIndiciator) {
    TableIndicator[] remainIndicators = new TableIndicator[tableIndicators.length - 1];
    int i = 0;
    for (TableIndicator indicator : tableIndicators) {
        if (deleteTableIndiciator.equals(indicator)) {
            continue;
        } else {
            remainIndicators[i] = indicator;
            i++;
        }
    }
    this.tableIndicators = remainIndicators;
}
Also used : TableIndicator(org.talend.dataprofiler.core.model.TableIndicator)

Aggregations

TableIndicator (org.talend.dataprofiler.core.model.TableIndicator)18 NamedColumnSet (orgomg.cwm.resource.relational.NamedColumnSet)8 ArrayList (java.util.ArrayList)7 TableIndicatorUnit (org.talend.dataprofiler.core.ui.editor.preview.TableIndicatorUnit)5 Indicator (org.talend.dataquality.indicators.Indicator)5 Composite (org.eclipse.swt.widgets.Composite)4 ExpandableComposite (org.eclipse.ui.forms.widgets.ExpandableComposite)4 Connection (org.talend.core.model.metadata.builder.connection.Connection)4 MouseAdapter (org.eclipse.swt.events.MouseAdapter)3 MouseEvent (org.eclipse.swt.events.MouseEvent)3 GridData (org.eclipse.swt.layout.GridData)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 TreeItem (org.eclipse.swt.widgets.TreeItem)3 ExpansionAdapter (org.eclipse.ui.forms.events.ExpansionAdapter)3 ExpansionEvent (org.eclipse.ui.forms.events.ExpansionEvent)3 CompositeIndicator (org.talend.dataprofiler.core.ui.editor.preview.CompositeIndicator)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 List (java.util.List)2 Map (java.util.Map)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2