Search in sources :

Example 16 with RuleRepNode

use of org.talend.dq.nodes.RuleRepNode in project tdq-studio-se by Talend.

the class AnalysisTableTreeViewer method showAddDQRuleDialog.

/**
 * DOC xqliu Comment method "showAddDQRuleDialog".
 *
 * @param treeItem
 * @param tableIndicator
 */
private void showAddDQRuleDialog(final TreeItem treeItem, final TableIndicator tableIndicator) {
    // MOD xqliu 2009-04-30 bug 6808
    IndicatorCheckedTreeSelectionDialog dialog = new IndicatorCheckedTreeSelectionDialog(null, new DQRepositoryViewLabelProvider(), new ResourceViewContentProvider());
    dialog.setInput(AnalysisUtils.getSelectDialogInputData(EResourceConstant.RULES_SQL));
    dialog.setValidator(new ISelectionStatusValidator() {

        public IStatus validate(Object[] selection) {
            for (Object ruleNode : selection) {
                if (ruleNode instanceof RuleRepNode) {
                    IndicatorDefinition findWhereRule = ((RuleRepNode) ruleNode).getRule();
                    boolean validStatus = TaggedValueHelper.getValidStatus(findWhereRule);
                    if (!validStatus) {
                        return new Status(IStatus.ERROR, CorePlugin.PLUGIN_ID, DefaultMessagesImpl.getString(// $NON-NLS-1$
                        "AnalysisTableTreeViewer.chooseValidDQRules"));
                    }
                }
            }
            // $NON-NLS-1$
            return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, IStatus.OK, "", null);
        }
    });
    dialog.setContainerMode(true);
    // $NON-NLS-1$
    dialog.setTitle(DefaultMessagesImpl.getString("AnalysisTableTreeViewer.dqruleSelector"));
    // $NON-NLS-1$
    dialog.setMessage(DefaultMessagesImpl.getString("AnalysisTableTreeViewer.dqrules"));
    dialog.setSize(80, 30);
    dialog.create();
    // MOD xqliu 2009-04-30 bug 6808
    Object[] ownedWhereRuleNodes = getOwnedWhereRuleNodes(tableIndicator);
    dialog.setCheckedElements(ownedWhereRuleNodes);
    if (dialog.open() == Window.OK) {
        Object[] result = dialog.getResult();
        removeUncheckedWhereRuleIndicator(ownedWhereRuleNodes, result, tableIndicator);
        Object[] results = clearAddedResult(ownedWhereRuleNodes, result);
        for (Object obj : results) {
            if (obj instanceof RuleRepNode) {
                RuleRepNode node = (RuleRepNode) obj;
                TableIndicatorUnit addIndicatorUnit = DQRuleUtilities.createIndicatorUnit(node, tableIndicator, getAnalysis());
                if (addIndicatorUnit != null) {
                    createOneUnit(treeItem, addIndicatorUnit);
                    setDirty(true);
                } else {
                    IndicatorDefinition whereRule = node.getRule();
                    MessageUI.openError(// $NON-NLS-1$
                    DefaultMessagesImpl.getString(// $NON-NLS-1$
                    "AnalysisTableTreeViewer.ErrorWhenAddWhereRule", whereRule.getName()));
                }
            }
        }
    }
// ~
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) ResourceViewContentProvider(org.talend.dataprofiler.core.ui.views.provider.ResourceViewContentProvider) ISelectionStatusValidator(org.eclipse.ui.dialogs.ISelectionStatusValidator) TableIndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.TableIndicatorUnit) RuleRepNode(org.talend.dq.nodes.RuleRepNode) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) IndicatorCheckedTreeSelectionDialog(org.talend.dataprofiler.core.ui.dialog.IndicatorCheckedTreeSelectionDialog) DQRepositoryViewLabelProvider(org.talend.dataprofiler.core.ui.views.provider.DQRepositoryViewLabelProvider)

Example 17 with RuleRepNode

use of org.talend.dq.nodes.RuleRepNode 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 18 with RuleRepNode

use of org.talend.dq.nodes.RuleRepNode in project tdq-studio-se by Talend.

the class AnalysisTableTreeViewer method dropWhereRules.

public void dropWhereRules(Object data, List<RuleRepNode> nodes, int index, TreeItem item) {
    TreeItem treeItem = null;
    if (item == null) {
        if (getTree().getItemCount() > 0) {
            treeItem = getTree().getItem(0);
        }
    } else {
        treeItem = item;
    }
    if (data != null && treeItem != null && nodes.size() > 0) {
        Analysis analysis = getAnalysis();
        for (RuleRepNode node : nodes) {
            TableIndicatorUnit addIndicatorUnit = DQRuleUtilities.createIndicatorUnit(node, (TableIndicator) data, analysis);
            if (addIndicatorUnit != null) {
                createOneUnit(treeItem, addIndicatorUnit);
                setDirty(true);
            }
        }
    }
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) Analysis(org.talend.dataquality.analysis.Analysis) TableIndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.TableIndicatorUnit) RuleRepNode(org.talend.dq.nodes.RuleRepNode)

Example 19 with RuleRepNode

use of org.talend.dq.nodes.RuleRepNode in project tdq-studio-se by Talend.

the class ImportMatchRuleAction method run.

@Override
public void run() {
    MatchRuleElementTreeSelectionDialog dialog = new MatchRuleElementTreeSelectionDialog(null, new DQRepositoryViewLabelProvider(), new ResourceViewContentProvider(), MatchRuleElementTreeSelectionDialog.MATCH_ANALYSIS_TYPE);
    List<String> inputColumnNames = new ArrayList<String>();
    Map<String, String> columnName2Type = new HashMap<String, String>();
    Analysis analysis = masterPage.getCurrentModelElement();
    EList<ModelElement> elements = analysis.getContext().getAnalysedElements();
    for (ModelElement me : elements) {
        inputColumnNames.add(me.getName());
        if (me instanceof MetadataColumn) {
            columnName2Type.put(me.getName(), ((MetadataColumn) me).getTalendType());
        }
    }
    dialog.setInputColumnNames(inputColumnNames);
    dialog.setColumnName2Type(columnName2Type);
    AnalysisResult anaResults = analysis.getResults();
    if (anaResults != null) {
        for (Indicator ind : anaResults.getIndicators()) {
            if (ind != null && ind instanceof RecordMatchingIndicator) {
                RecordMatchingIndicator rmInd = (RecordMatchingIndicator) ind;
                MatchRuleDefinition builtInMatchRuleDefinition = rmInd.getBuiltInMatchRuleDefinition();
                if (builtInMatchRuleDefinition != null) {
                    if (builtInMatchRuleDefinition.getBlockKeys() != null && builtInMatchRuleDefinition.getBlockKeys().size() > 0) {
                        List<String> blockKeyName = new ArrayList<String>();
                        for (BlockKeyDefinition blockKey : builtInMatchRuleDefinition.getBlockKeys()) {
                            blockKeyName.add(blockKey.getName());
                        }
                        dialog.setCurrentAnaBlockKeys(blockKeyName);
                    }
                    List<String> matchKeysName = new ArrayList<String>();
                    for (MatchRule matchRule : builtInMatchRuleDefinition.getMatchRules()) {
                        EList<MatchKeyDefinition> matchKeys = matchRule.getMatchKeys();
                        for (MatchKeyDefinition mkd : matchKeys) {
                            // same
                            if (!matchKeysName.contains(mkd.getName())) {
                                matchKeysName.add(mkd.getName());
                            }
                        }
                    }
                    dialog.setAnalysisCurrentMatchKeys(matchKeysName);
                    List<String> pdsdKeysName = new ArrayList<String>();
                    for (ParticularDefaultSurvivorshipDefinitions pdsd : builtInMatchRuleDefinition.getParticularDefaultSurvivorshipDefinitions()) {
                        pdsdKeysName.add(pdsd.getColumn());
                    }
                    dialog.setAnalysisCurrentParticularColumns(pdsdKeysName);
                }
            }
        }
    }
    dialog.create();
    if (dialog.open() == Window.OK) {
        Object[] results = dialog.getResult();
        for (Object obj : results) {
            if (obj instanceof RuleRepNode) {
                RuleRepNode node = (RuleRepNode) obj;
                MatchRuleDefinition matchRule = (MatchRuleDefinition) node.getRule();
                if (matchRule != null) {
                    updateMatchRule(matchRule, dialog.isOverwrite());
                }
            }
        }
    }
}
Also used : ParticularDefaultSurvivorshipDefinitions(org.talend.dataquality.rules.ParticularDefaultSurvivorshipDefinitions) HashMap(java.util.HashMap) MatchRuleElementTreeSelectionDialog(org.talend.dataprofiler.core.ui.dialog.MatchRuleElementTreeSelectionDialog) ResourceViewContentProvider(org.talend.dataprofiler.core.ui.views.provider.ResourceViewContentProvider) ArrayList(java.util.ArrayList) MatchRuleDefinition(org.talend.dataquality.rules.MatchRuleDefinition) MatchRule(org.talend.dataquality.rules.MatchRule) RecordMatchingIndicator(org.talend.dataquality.indicators.columnset.RecordMatchingIndicator) RuleRepNode(org.talend.dq.nodes.RuleRepNode) AnalysisResult(org.talend.dataquality.analysis.AnalysisResult) RecordMatchingIndicator(org.talend.dataquality.indicators.columnset.RecordMatchingIndicator) Indicator(org.talend.dataquality.indicators.Indicator) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) Analysis(org.talend.dataquality.analysis.Analysis) BlockKeyDefinition(org.talend.dataquality.rules.BlockKeyDefinition) MatchKeyDefinition(org.talend.dataquality.rules.MatchKeyDefinition) DQRepositoryViewLabelProvider(org.talend.dataprofiler.core.ui.views.provider.DQRepositoryViewLabelProvider)

Example 20 with RuleRepNode

use of org.talend.dq.nodes.RuleRepNode in project tdq-studio-se by Talend.

the class MatchRuleElementTreeSelectionDialog method getBlockingKeysFromNodes.

public List<Map<String, String>> getBlockingKeysFromNodes(Object[] nodes, boolean retrieveDisplayValue) {
    List<Map<String, String>> ruleValues = new ArrayList<Map<String, String>>();
    for (Object rule : nodes) {
        if (rule instanceof RuleRepNode) {
            RuleRepNode node = (RuleRepNode) rule;
            MatchRuleDefinition matchRuleDefinition = (MatchRuleDefinition) node.getRule();
            ruleValues.addAll(getBlockingKeysFromRules(matchRuleDefinition, retrieveDisplayValue));
        }
    }
    return ruleValues;
}
Also used : ArrayList(java.util.ArrayList) MatchRuleDefinition(org.talend.dataquality.rules.MatchRuleDefinition) RuleRepNode(org.talend.dq.nodes.RuleRepNode) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

RuleRepNode (org.talend.dq.nodes.RuleRepNode)20 ArrayList (java.util.ArrayList)7 MatchRuleDefinition (org.talend.dataquality.rules.MatchRuleDefinition)6 IRepositoryNode (org.talend.repository.model.IRepositoryNode)6 AnalysisRepNode (org.talend.dq.nodes.AnalysisRepNode)5 DBTableRepNode (org.talend.dq.nodes.DBTableRepNode)5 DBViewRepNode (org.talend.dq.nodes.DBViewRepNode)5 HashMap (java.util.HashMap)4 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)4 DFConnectionRepNode (org.talend.dq.nodes.DFConnectionRepNode)4 PatternRepNode (org.talend.dq.nodes.PatternRepNode)4 ReportRepNode (org.talend.dq.nodes.ReportRepNode)4 SysIndicatorDefinitionRepNode (org.talend.dq.nodes.SysIndicatorDefinitionRepNode)4 Map (java.util.Map)3 TreeItem (org.eclipse.swt.widgets.TreeItem)3 TableIndicatorUnit (org.talend.dataprofiler.core.ui.editor.preview.TableIndicatorUnit)3 ExchangeComponentRepNode (org.talend.dataprofiler.core.ui.exchange.ExchangeComponentRepNode)3 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)3 DBCatalogRepNode (org.talend.dq.nodes.DBCatalogRepNode)3 DBColumnRepNode (org.talend.dq.nodes.DBColumnRepNode)3