Search in sources :

Example 21 with MatchRule

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

the class MatchingKeySection method isKeyDefinitionAdded.

/*
     * The policy of comparing the key's name is: case INsensitive
     * 
     * @see org.talend.dataquality.record.linkage.ui.section.AbstractMatchAnaysisTableSection#isKeyDefinitionAdded()
     */
@Override
public Boolean isKeyDefinitionAdded(String colummName) throws Exception {
    Boolean isAddded = Boolean.FALSE;
    MatchRule matchRule = getCurrentMatchRule();
    for (KeyDefinition keyDef : matchRule.getMatchKeys()) {
        if (StringUtils.equals(colummName, keyDef.getColumn())) {
            isAddded = Boolean.TRUE;
            break;
        }
    }
    return isAddded;
}
Also used : MatchRule(org.talend.dataquality.rules.MatchRule) MatchKeyDefinition(org.talend.dataquality.rules.MatchKeyDefinition) SurvivorshipKeyDefinition(org.talend.dataquality.rules.SurvivorshipKeyDefinition) KeyDefinition(org.talend.dataquality.rules.KeyDefinition)

Example 22 with MatchRule

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

the class MatchingKeySection method deleteMatchRuleTab.

protected void deleteMatchRuleTab(CTabItem tabItem) {
    MatchRule matchRule = getMatchRule(tabItem);
    // Remove it from anaysis.
    boolean removed = getMatchRuleList().remove(matchRule);
    if (removed) {
        listeners.firePropertyChange(MatchAnalysisConstant.ISDIRTY_PROPERTY, true, false);
        fireSwitchRuleTabEvent();
    }
}
Also used : MatchRule(org.talend.dataquality.rules.MatchRule)

Example 23 with MatchRule

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

the class MatchingKeySection method checkResultStatus.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dataquality.record.linkage.ui.section.AbstractMatchAnaysisTableSection#checkResultStatus()
     */
@Override
public ReturnCode checkResultStatus() {
    ReturnCode returnCode = new ReturnCode(false);
    if (!hasMatchKey(false)) {
        // $NON-NLS-1$
        returnCode.setMessage(DefaultMessagesImpl.getString("MatchMasterDetailsPage.NoMatchKey"));
        return returnCode;
    }
    List<String> uniqueNameList = new ArrayList<String>();
    for (MatchRule currentRule : getMatchRuleList()) {
        EList<MatchKeyDefinition> matchKeys = currentRule.getMatchKeys();
        for (MatchKeyDefinition mdk : matchKeys) {
            String currentName = mdk.getName();
            if (currentName.equals(StringUtils.EMPTY)) {
                returnCode.setMessage(DefaultMessagesImpl.getString("BlockingKeySection.emptyKeys.message", // $NON-NLS-1$ //$NON-NLS-2$
                getSectionName() + " , " + currentRule.getName()));
                return returnCode;
            }
            if (uniqueNameList.contains(currentName)) {
                returnCode.setMessage(DefaultMessagesImpl.getString("BlockingKeySection.duplicateKeys.message", // $NON-NLS-1$ //$NON-NLS-2$
                getSectionName() + "--" + currentName));
                return returnCode;
            }
            uniqueNameList.add(currentName);
            if (checkColumnNameIsEmpty(mdk)) {
                returnCode.setMessage(DefaultMessagesImpl.getString("BlockingKeySection.emptyColumn.message", // $NON-NLS-1$ //$NON-NLS-2$
                getSectionName() + " , " + currentRule.getName()));
                return returnCode;
            }
            if (// $NON-NLS-1$
            "CUSTOM".equals(mdk.getAlgorithm().getAlgorithmType()) && StringUtils.EMPTY.equals(mdk.getAlgorithm().getAlgorithmParameters().trim())) {
                returnCode.setMessage(DefaultMessagesImpl.getString("BlockingKeySection.invalidCustomAlgorithmError", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                getSectionName() + " , " + currentRule.getName() + " , " + currentName));
                return returnCode;
            }
            if (mdk.getConfidenceWeight() <= 0) {
                returnCode.setMessage(DefaultMessagesImpl.getString("BlockingKeySection.invalidConfidenceWeight.message", // $NON-NLS-1$
                getSectionName()));
                return returnCode;
            }
            ReturnCode checkSurvivorshipFunction = checkSurvivorshipFunction(mdk, this.getMatchRuleDefinition());
            if (!checkSurvivorshipFunction.isOk()) {
                returnCode.setMessage(// $NON-NLS-1$
                DefaultMessagesImpl.getString(// $NON-NLS-1$
                "MatchingKeySection.invalidSurvivorshipFunction", getSectionName(), checkSurvivorshipFunction.getMessage()));
                return returnCode;
            }
        }
    }
    returnCode.setOk(true);
    return returnCode;
}
Also used : TypedReturnCode(org.talend.utils.sugars.TypedReturnCode) ReturnCode(org.talend.utils.sugars.ReturnCode) ArrayList(java.util.ArrayList) MatchKeyDefinition(org.talend.dataquality.rules.MatchKeyDefinition) MatchRule(org.talend.dataquality.rules.MatchRule)

Example 24 with MatchRule

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

the class MatchingKeySection method importMatchRule.

/**
 * if overwrite: need to delete all current tabs, and create the tab according to the parameter:matchRule else: only
 * add the tab in the parameter matchrule, to the current matchrule.
 *
 * @param matchRuleDefinition
 * @param overwrite
 */
public void importMatchRule(MatchRuleDefinition matchRuleDefinition, boolean overwrite) {
    if (overwrite) {
        // delete all tab in UI
        CTabItem[] tabItems = ruleFolder.getItems();
        if (tabItems != null && tabItems.length > 0) {
            for (CTabItem oneTab : tabItems) {
                @SuppressWarnings("rawtypes") AbsMatchAnalysisTableComposite matchRuleTableComp = getMatchRuleComposite(oneTab);
                matchRuleTableComp.dispose();
                oneTab.dispose();
            }
        }
        // clear all survivorship keys
        getMatchRuleDefinition().getSurvivorshipKeys().clear();
        // clear all match rules in matchrule definition
        getMatchRuleDefinition().getMatchRules().clear();
        // overwrite the threshold
        groupQualityThresholdText.setText(String.valueOf(matchRuleDefinition.getMatchGroupQualityThreshold()));
    }
    // import survivorship keys
    for (SurvivorshipKeyDefinition skd : matchRuleDefinition.getSurvivorshipKeys()) {
        SurvivorshipKeyDefinition survivorshipKeyDefinition = EcoreUtil.copy(skd);
        setColumnValueIfMatch(survivorshipKeyDefinition);
        getMatchRuleDefinition().getSurvivorshipKeys().add(survivorshipKeyDefinition);
    }
    // create the tab from the parameter:matchRule
    for (MatchRule oneMatchRule : matchRuleDefinition.getMatchRules()) {
        MatchRule matchRule2 = createMatchRuleByCopy(oneMatchRule);
        // MOD msjian TDQ-8484: set the name of the match rule by the old name
        matchRule2.setName(oneMatchRule.getName());
        // if the key name= some column name, set the column to this key
        for (MatchKeyDefinition key : matchRule2.getMatchKeys()) {
            setColumnValueIfMatch(key);
        }
        // auto add the tab name order
        addRuleTab(false, matchRule2);
        getMatchRuleDefinition().getMatchRules().add(matchRule2);
    }
}
Also used : AbsMatchAnalysisTableComposite(org.talend.dataquality.record.linkage.ui.composite.AbsMatchAnalysisTableComposite) SurvivorshipKeyDefinition(org.talend.dataquality.rules.SurvivorshipKeyDefinition) MatchKeyDefinition(org.talend.dataquality.rules.MatchKeyDefinition) MatchRule(org.talend.dataquality.rules.MatchRule) CTabItem(org.eclipse.swt.custom.CTabItem)

Example 25 with MatchRule

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

the class MatchingKeySection method getCurrentMatchKeyColumn.

/**
 * find the current columns which has been selected as match key on the current Tab(Match rule)
 *
 * @return
 */
public List<String> getCurrentMatchKeyColumn() {
    List<String> columnAsKey = new ArrayList<String>();
    MatchRule matchRule;
    try {
        matchRule = getCurrentMatchRule();
    } catch (Exception e) {
        return columnAsKey;
    }
    for (KeyDefinition keyDef : matchRule.getMatchKeys()) {
        columnAsKey.add(keyDef.getColumn());
    }
    return columnAsKey;
}
Also used : ArrayList(java.util.ArrayList) MatchRule(org.talend.dataquality.rules.MatchRule) MatchKeyDefinition(org.talend.dataquality.rules.MatchKeyDefinition) SurvivorshipKeyDefinition(org.talend.dataquality.rules.SurvivorshipKeyDefinition) KeyDefinition(org.talend.dataquality.rules.KeyDefinition)

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