Search in sources :

Example 26 with MatchRule

use of org.talend.dataquality.rules.MatchRule in project tdq-studio-se by Talend.

the class MatchingKeySection method addNewMatchRule.

/**
 * add a new match rule when the user click "+" button.
 */
protected void addNewMatchRule() {
    MatchRule newMatchRule = getNewMatchRule();
    addRuleTab(true, newMatchRule);
    addMatchRuleToAnalysis(newMatchRule);
    listeners.firePropertyChange(MatchAnalysisConstant.ISDIRTY_PROPERTY, true, false);
}
Also used : MatchRule(org.talend.dataquality.rules.MatchRule)

Example 27 with MatchRule

use of org.talend.dataquality.rules.MatchRule in project tdq-studio-se by Talend.

the class MatchingKeySection method getNewMatchRule.

/**
 * DOC yyin Comment method "getNewRuleMatcher".
 */
private MatchRule getNewMatchRule() {
    MatchRule ruleMatcher = RulesFactory.eINSTANCE.createMatchRule();
    String tabName = getMatchRuleNameByOrder();
    ruleMatcher.setName(tabName);
    return ruleMatcher;
}
Also used : MatchRule(org.talend.dataquality.rules.MatchRule)

Example 28 with MatchRule

use of org.talend.dataquality.rules.MatchRule in project tdq-studio-se by Talend.

the class MatchRuleAnlaysisUtils method convertDataMapToRuleMatcher.

public static List<MatchRule> convertDataMapToRuleMatcher(Map<String, String> columnMap) {
    List<MatchRule> matcherList = new ArrayList<MatchRule>();
    if (columnMap == null) {
        return matcherList;
    }
    MatchRule createRuleMatcher = RulesFactory.eINSTANCE.createMatchRule();
    for (String columnName : columnMap.keySet()) {
        MatchKeyDefinition createDefaultMatchRow = createDefaultMatchRow(columnName);
        createRuleMatcher.getMatchKeys().add(createDefaultMatchRow);
    }
    matcherList.add(createRuleMatcher);
    return matcherList;
}
Also used : ArrayList(java.util.ArrayList) MatchKeyDefinition(org.talend.dataquality.rules.MatchKeyDefinition) MatchRule(org.talend.dataquality.rules.MatchRule)

Example 29 with MatchRule

use of org.talend.dataquality.rules.MatchRule in project tdq-studio-se by Talend.

the class MatchRuleElementTreeSelectionDialog method getMatchRulesFromRules.

private List<Map<String, String>> getMatchRulesFromRules(MatchRuleDefinition matchRuleDefinition, boolean retrieveDisplayValue) {
    if (matchRuleDefinition != null) {
        List<Map<String, String>> ruleValues = new ArrayList<Map<String, String>>();
        for (MatchRule matchRule : matchRuleDefinition.getMatchRules()) {
            for (MatchKeyDefinition matchKey : matchRule.getMatchKeys()) {
                Map<String, String> pr = new HashMap<String, String>();
                pr.put(MatchRulesTableLabelProvider.MATCH_KEY_NAME, null == matchKey.getName() ? StringUtils.EMPTY : matchKey.getName());
                String matchedColumnName = matchExistingColumnForKey(matchKey);
                pr.put(MatchRulesTableLabelProvider.INPUT_COLUMN, null == matchedColumnName ? StringUtils.EMPTY : matchedColumnName);
                if (getLookupColumnNames().size() > 0) {
                    for (String lookupColumnName : getLookupColumnNames()) {
                        if (isColumnNameEqualsWithKey(matchKey, lookupColumnName)) {
                            // $NON-NLS-1$
                            pr.put("LOOKUP_COLUMN", null == matchKey.getColumn() ? StringUtils.EMPTY : lookupColumnName);
                            break;
                        }
                    }
                }
                String algorithmType = matchKey.getAlgorithm().getAlgorithmType();
                if (retrieveDisplayValue) {
                    pr.put(MatchRulesTableLabelProvider.MATCHING_TYPE, null == algorithmType ? StringUtils.EMPTY : AttributeMatcherType.valueOf(algorithmType).getLabel());
                } else {
                    pr.put(MatchRulesTableLabelProvider.MATCHING_TYPE, null == algorithmType ? StringUtils.EMPTY : AttributeMatcherType.valueOf(algorithmType).getComponentValue());
                }
                // MOD sizhaoliu TDQ-8431 split the value by "||" and take the second part as custom class value
                String algoParams = matchKey.getAlgorithm().getAlgorithmParameters();
                if (algoParams != null) {
                    // $NON-NLS-1$
                    int idxSeparator = algoParams.indexOf("||");
                    if (idxSeparator > 0 && algoParams.length() > idxSeparator + 2) {
                        // $NON-NLS-1$ //$NON-NLS-2$
                        algoParams = "\"" + algoParams.substring(idxSeparator + 2) + "\"";
                    }
                }
                pr.put(MatchRulesTableLabelProvider.CUSTOM_MATCHER, null == algoParams ? StringUtils.EMPTY : algoParams);
                pr.put(MatchRulesTableLabelProvider.CONFIDENCE_WEIGHT, String.valueOf(matchKey.getConfidenceWeight()));
                if (retrieveDisplayValue) {
                    pr.put(MatchRulesTableLabelProvider.HANDLE_NULL, null == matchKey.getHandleNull() ? StringUtils.EMPTY : HandleNullEnum.getTypeByValue(matchKey.getHandleNull()).getLabel());
                } else {
                    pr.put(MatchRulesTableLabelProvider.HANDLE_NULL, null == matchKey.getHandleNull() ? StringUtils.EMPTY : matchKey.getHandleNull());
                }
                // set threshold
                pr.put(MatchRulesTableLabelProvider.THRESHOLD, String.valueOf(matchKey.getThreshold()));
                pr.put(MatchRulesTableLabelProvider.TOKENIZATION_TYPE, String.valueOf(matchKey.getTokenizationType()));
                // set survivorship function and parameter
                AlgorithmDefinition algorithmDefinition = getSurvivorshipFunctionAlgorithm(matchKey, matchRuleDefinition);
                pr.put(MatchRulesTableLabelProvider.SURVIVORSHIP_FUNCTION, algorithmDefinition != null && algorithmDefinition.getAlgorithmType() != null ? algorithmDefinition.getAlgorithmType() : StringUtils.EMPTY);
                pr.put(MatchRulesTableLabelProvider.PARAMETER, algorithmDefinition != null && algorithmDefinition.getAlgorithmParameters() != null ? algorithmDefinition.getAlgorithmParameters() : StringUtils.EMPTY);
                ruleValues.add(pr);
            }
        }
        return ruleValues;
    }
    return null;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) MatchKeyDefinition(org.talend.dataquality.rules.MatchKeyDefinition) AlgorithmDefinition(org.talend.dataquality.rules.AlgorithmDefinition) MatchRule(org.talend.dataquality.rules.MatchRule) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

MatchRule (org.talend.dataquality.rules.MatchRule)29 MatchKeyDefinition (org.talend.dataquality.rules.MatchKeyDefinition)14 ArrayList (java.util.ArrayList)10 MatchRuleDefinition (org.talend.dataquality.rules.MatchRuleDefinition)8 HashMap (java.util.HashMap)7 RecordMatchingIndicator (org.talend.dataquality.indicators.columnset.RecordMatchingIndicator)6 AlgorithmDefinition (org.talend.dataquality.rules.AlgorithmDefinition)6 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)5 BlockKeyDefinition (org.talend.dataquality.rules.BlockKeyDefinition)5 Test (org.junit.Test)4 BlockKeyIndicator (org.talend.dataquality.indicators.columnset.BlockKeyIndicator)4 MatchGroupResultConsumer (org.talend.dataquality.record.linkage.grouping.MatchGroupResultConsumer)4 MatchKeyAndSurvivorDefinition (org.talend.dataquality.record.linkage.ui.composite.tableviewer.definition.MatchKeyAndSurvivorDefinition)4 ExecuteMatchRuleHandler (org.talend.dq.analysis.match.ExecuteMatchRuleHandler)4 CTabItem (org.eclipse.swt.custom.CTabItem)3 MatchKeyAndSurvivorTableComposite (org.talend.dataquality.record.linkage.ui.composite.MatchKeyAndSurvivorTableComposite)3 SurvivorshipKeyDefinition (org.talend.dataquality.rules.SurvivorshipKeyDefinition)3 Map (java.util.Map)2 MatchRuleTableComposite (org.talend.dataquality.record.linkage.ui.composite.MatchRuleTableComposite)2 KeyDefinition (org.talend.dataquality.rules.KeyDefinition)2