Search in sources :

Example 6 with RuleRepNode

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

the class TOPRepositoryService method createParserRuleItem.

public void createParserRuleItem(ArrayList<HashMap<String, Object>> values, String parserRuleName) {
    ParserRule parserRule = null;
    DqRuleBuilder ruleBuilder = new DqRuleBuilder();
    boolean ruleInitialized = ruleBuilder.initializeParserRuleBuilder(parserRuleName);
    if (ruleInitialized) {
        parserRule = ruleBuilder.getParserRule();
    }
    TaggedValueHelper.setValidStatus(true, parserRule);
    for (HashMap<String, Object> expression : values) {
        parserRule.addExpression(expression.get(RULE_NAME).toString(), expression.get(RULE_TYPE) instanceof Integer ? Integer.toString((Integer) expression.get(RULE_TYPE)) : expression.get(RULE_TYPE).toString(), expression.get(RULE_VALUE).toString());
    }
    IndicatorCategory ruleIndicatorCategory = DefinitionHandler.getInstance().getDQRuleIndicatorCategory();
    if (ruleIndicatorCategory != null && !parserRule.getCategories().contains(ruleIndicatorCategory)) {
        parserRule.getCategories().add(ruleIndicatorCategory);
    }
    IFolder folder = ResourceManager.getRulesParserFolder();
    TypedReturnCode<Object> returnObject = ElementWriterFactory.getInstance().createdRuleWriter().create(parserRule, folder);
    Object object = returnObject.getObject();
    RuleRepNode parserRuleNode = RepositoryNodeHelper.recursiveFindRuleParser(parserRule);
    BusinessRuleItemEditorInput parserRuleEditorInput = new BusinessRuleItemEditorInput(parserRuleNode);
    CorePlugin.getDefault().openEditor(parserRuleEditorInput, DQRuleEditor.class.getName());
    refresh(object);
}
Also used : ParserRule(org.talend.dataquality.rules.ParserRule) BusinessRuleItemEditorInput(org.talend.dataprofiler.core.ui.editor.dqrules.BusinessRuleItemEditorInput) DQRuleEditor(org.talend.dataprofiler.core.ui.editor.dqrules.DQRuleEditor) DqRuleBuilder(org.talend.dq.dqrule.DqRuleBuilder) RuleRepNode(org.talend.dq.nodes.RuleRepNode) IndicatorCategory(org.talend.dataquality.indicators.definition.IndicatorCategory) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IFolder(org.eclipse.core.resources.IFolder)

Example 7 with RuleRepNode

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

the class MatchRuleElementTreeSelectionDialog method getParticularRulesFromNodes.

/**
 * Get particular rules from nodes
 *
 * @param nodes
 * @param retrieveDisplayValue get the display value when this parameter is set to true, otherwise, get the
 * component value.
 * @return
 */
public List<Map<String, String>> getParticularRulesFromNodes(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(getParticularSurvivorshipRulesFromRules(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)

Example 8 with RuleRepNode

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

the class MatchRuleElementTreeSelectionDialog method createDialogArea.

@Override
protected Control createDialogArea(final Composite parent) {
    final SashForm form = new SashForm(parent, SWT.SMOOTH | SWT.VERTICAL | SWT.FILL);
    form.setSize(Math.min(Display.getCurrent().getActiveShell().getSize().x, 800), 580);
    GridData data = new GridData(SWT.FILL, SWT.FILL, true, true, 0, 0);
    form.setLayoutData(data);
    Composite composite = (Composite) super.createDialogArea(form);
    getTreeViewer().addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            if (dialogType != SUGGEST_TYPE) {
                IStructuredSelection selection = (IStructuredSelection) event.getSelection();
                Object[] array = selection.toArray();
                if (array.length == 1) {
                    if (array[0] != null) {
                        MatchRuleDefinition matchRuleDefinition = null;
                        if (array[0] instanceof RuleRepNode) {
                            RuleRepNode node = (RuleRepNode) array[0];
                            matchRuleDefinition = (MatchRuleDefinition) node.getRule();
                        }
                        if (matchRuleDefinition != null) {
                            // MatchAnalysis tmatchGroup tRecordMatching tGenKey will come here
                            algorithmValue.setText(RecordMatcherType.valueOf(matchRuleDefinition.getRecordLinkageAlgorithm()).getLabel());
                            if (blockingKeysTable != null) {
                                blockingKeysTable.setInput(getBlockingKeysFromNodes(array, true));
                            }
                            if (matchingRulesTable != null) {
                                matchRulesTableComposite.dispose();
                                if (StringUtils.equals(RecordMatcherType.T_SwooshAlgorithm.name(), matchRuleDefinition.getRecordLinkageAlgorithm())) {
                                    if (particularSurvivRulesTableComposite != null) {
                                        particularSurvivRulesTableComposite.dispose();
                                        particularSurvivRulesTableComposite = null;
                                    }
                                    createSelectMatchRulesTableTswoosh(form);
                                    if (dialogType == MATCHGROUP_TYPE) {
                                        createParticularSurvivorshipRulesTableTswoosh(form);
                                        form.setWeights(new int[] { 5, 3, 2 });
                                    } else if (dialogType == MATCH_ANALYSIS_TYPE) {
                                        createParticularSurvivorshipRulesTableTswoosh(form);
                                        form.setWeights(new int[] { 4, 2, 2, 2 });
                                    }
                                    // MatchAnalysis tmatchGroup tRecordMatching will come here
                                    if (particularSurvivRulesTable != null) {
                                        // MatchAnalysis tmatchGroup will come here
                                        particularSurvivRulesTable.setInput(getParticularRulesFromNodes(array, true));
                                    }
                                } else {
                                    createSelectMatchRulesTableVsr(form);
                                    if (particularSurvivRulesTableComposite != null && dialogType == MATCHGROUP_TYPE) {
                                        particularSurvivRulesTableComposite.dispose();
                                        particularSurvivRulesTableComposite = null;
                                        form.setWeights(new int[] { 3, 2 });
                                    } else if (particularSurvivRulesTableComposite != null && dialogType == MATCH_ANALYSIS_TYPE) {
                                        particularSurvivRulesTableComposite.dispose();
                                        particularSurvivRulesTableComposite = null;
                                        form.setWeights(new int[] { 5, 3, 2 });
                                    }
                                }
                                matchingRulesTable.setInput(getMatchRulesFromNodes(array, true));
                                // refresh the dialog
                                matchRulesTableComposite.getParent().layout();
                                matchRulesTableComposite.getParent().redraw();
                            }
                        }
                    }
                }
            }
        }
    });
    if (dialogType == GENKEY_TYPE) {
        createSelectBlockingKeysTable(form);
        form.setWeights(new int[] { 3, 2 });
    } else if (dialogType == MATCHGROUP_TYPE) {
        createSelectMatchRulesTableVsr(form);
        createParticularSurvivorshipRulesTableTswoosh(form);
        form.setWeights(new int[] { 5, 3, 2 });
    } else if (dialogType == RECORD_MATCHING_TYPE) {
        createSelectMatchRulesTableVsr(form);
        form.setWeights(new int[] { 3, 2 });
    } else if (dialogType == MATCH_ANALYSIS_TYPE) {
        createSelectBlockingKeysTable(form);
        createSelectMatchRulesTableVsr(form);
        createParticularSurvivorshipRulesTableTswoosh(form);
        form.setWeights(new int[] { 4, 2, 2, 2 });
    } else if (dialogType == SUGGEST_TYPE) {
        createSelectBlockingKeysTable(form);
        createSelectMatchRulesTableVsr(form);
        form.setWeights(new int[] { 5, 2, 3 });
        if (blockingKeysTable != null) {
            blockingKeysTable.setInput(getBlockingKeysFromRules(matchRuleDefinitionInput, true));
        }
        if (matchingRulesTable != null) {
            matchingRulesTable.setInput(getMatchRulesFromRules(matchRuleDefinitionInput, true));
        }
    }
    createCheckerArea(composite);
    return composite;
}
Also used : SashForm(org.eclipse.swt.custom.SashForm) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) GridData(org.eclipse.swt.layout.GridData) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) MatchRuleDefinition(org.talend.dataquality.rules.MatchRuleDefinition) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) RuleRepNode(org.talend.dq.nodes.RuleRepNode)

Example 9 with RuleRepNode

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

the class MatchRuleElementTreeSelectionDialog method getMatchRulesFromNodes.

/**
 * DOC sizhaoliu Comment method "getMatchRulesFromNodes".
 *
 * @param nodes
 * @param retrieveDisplayValue get the display value when this parameter is set to true, otherwise, get the
 * component value.
 * @return
 */
public List<Map<String, String>> getMatchRulesFromNodes(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(getMatchRulesFromRules(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)

Example 10 with RuleRepNode

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

the class RepositoryNodeHelper method recursiveFindRuleSql.

public static RuleRepNode recursiveFindRuleSql(DQRule rule) {
    if (rule == null) {
        return null;
    }
    String uuid = getUUID(rule);
    if (uuid == null) {
        return null;
    }
    IRepositoryNode ruleSQLFolderNode = getRuleSQLFolderNode(rule);
    List<RuleRepNode> ruleRepNodes = getRuleRepNodes(ruleSQLFolderNode, true, true);
    if (ruleRepNodes.size() > 0) {
        for (RuleRepNode childNode : ruleRepNodes) {
            if (uuid.equals(getUUID(childNode.getRule()))) {
                return childNode;
            }
        }
    }
    return null;
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) RuleRepNode(org.talend.dq.nodes.RuleRepNode)

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