Search in sources :

Example 11 with SurvivorshipKeyDefinition

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

the class MatchingKeySection method checkSurvivorshipFunction.

/**
 * check the survivorship function fit the column or not.
 *
 * @param mkDef
 * @param mrDef
 * @return
 */
private ReturnCode checkSurvivorshipFunction(MatchKeyDefinition mkDef, MatchRuleDefinition mrDef) {
    ReturnCode rc = new ReturnCode(true);
    EList<SurvivorshipKeyDefinition> survivorshipKeys = mrDef.getSurvivorshipKeys();
    for (SurvivorshipKeyDefinition skDef : survivorshipKeys) {
        if (StringUtils.equals(mkDef.getName(), skDef.getName())) {
            MetadataColumn metadataColumn = getMetadataColumnByName(mkDef.getColumn());
            if (metadataColumn != null) {
                String algorithmType = skDef.getFunction().getAlgorithmType();
                if (!MatchRuleAnlaysisUtils.isSurvivorShipFunctionConsistentWithType(algorithmType, metadataColumn.getTalendType())) {
                    rc.setOk(false);
                    rc.setMessage(DefaultMessagesImpl.getString(// $NON-NLS-1$
                    "MatchingKeySection.survivorshipFunctionNotMatch", // $NON-NLS-1$
                    metadataColumn.getName(), SurvivorShipAlgorithmEnum.getTypeBySavedValue(algorithmType).getValue()));
                    return rc;
                }
            }
        }
    }
    return rc;
}
Also used : MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) TypedReturnCode(org.talend.utils.sugars.TypedReturnCode) ReturnCode(org.talend.utils.sugars.ReturnCode) SurvivorshipKeyDefinition(org.talend.dataquality.rules.SurvivorshipKeyDefinition)

Example 12 with SurvivorshipKeyDefinition

use of org.talend.dataquality.rules.SurvivorshipKeyDefinition 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 13 with SurvivorshipKeyDefinition

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

the class SurvivorshipDefinitionSection method checkResultStatus.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dataquality.record.linkage.ui.section.AbstractMatchAnaysisTableSection#checkResultStatus()
     */
@Override
public ReturnCode checkResultStatus() {
    ReturnCode returnCode = new ReturnCode(false);
    List<String> uniqueNameList = new ArrayList<String>();
    List<String> duplicateNameList = new ArrayList<String>();
    for (SurvivorshipKeyDefinition ssdk : getSurvivorshipKeys()) {
        String currentName = ssdk.getName();
        if (currentName.equals(StringUtils.EMPTY)) {
            // $NON-NLS-1$
            returnCode.setMessage(DefaultMessagesImpl.getString("BlockingKeySection.emptyKeys.message", getSectionName()));
            return returnCode;
        }
        boolean currentNameIsDuplicate = false;
        for (String uniqueName : uniqueNameList) {
            if (currentName.equals(uniqueName)) {
                duplicateNameList.add(currentName);
                currentNameIsDuplicate = true;
            }
        }
        if (!currentNameIsDuplicate) {
            uniqueNameList.add(currentName);
        }
    }
    if (duplicateNameList.size() > 0) {
        // $NON-NLS-1$
        returnCode.setMessage(DefaultMessagesImpl.getString("BlockingKeySection.duplicateKeys.message", getSectionName()));
        return returnCode;
    } else {
        returnCode.setOk(true);
        return returnCode;
    }
}
Also used : ReturnCode(org.talend.utils.sugars.ReturnCode) ArrayList(java.util.ArrayList) SurvivorshipKeyDefinition(org.talend.dataquality.rules.SurvivorshipKeyDefinition)

Example 14 with SurvivorshipKeyDefinition

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

the class SurvivorshipDefinitionSection method moveDownTableItem.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dataquality.record.linkage.ui.section.AbstractMatchAnaysisTableSection#moveUpTableItem()
     */
@Override
public void moveDownTableItem() {
    ISelection selectItems = tableComposite.getSelectItems();
    if (selectItems instanceof StructuredSelection) {
        if (selectItems.isEmpty()) {
            return;
        }
        List<SurvivorshipKeyDefinition> currentElements = this.matchRuleDef.getSurvivorshipKeys();
        List<SurvivorshipKeyDefinition> survivorshipKeyDefinitionlist = ((StructuredSelection) selectItems).toList();
        for (int index = survivorshipKeyDefinitionlist.size() - 1; 0 <= index; index--) {
            if (!isSameWithCurrentModel(currentElements.get(currentElements.size() - survivorshipKeyDefinitionlist.size() + index), survivorshipKeyDefinitionlist.get(index))) {
                continue;
            }
            SurvivorshipKeyDefinition next = survivorshipKeyDefinitionlist.get(index);
            tableComposite.moveDownKeyDefinition(next, currentElements);
        }
        tableComposite.selectAllItem(((StructuredSelection) selectItems).toList());
    }
}
Also used : ISelection(org.eclipse.jface.viewers.ISelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) SurvivorshipKeyDefinition(org.talend.dataquality.rules.SurvivorshipKeyDefinition)

Example 15 with SurvivorshipKeyDefinition

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

the class SurvivorShipCellModifier method modify.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.viewers.ICellModifier#modify(java.lang.Object, java.lang.String, java.lang.Object)
     */
@Override
public void modify(Object element, String property, Object value) {
    if (element instanceof TableItem) {
        SurvivorshipKeyDefinition skd = (SurvivorshipKeyDefinition) ((TableItem) element).getData();
        String newValue = String.valueOf(value);
        if (MatchAnalysisConstant.SURVIVORSHIP_KEY_NAME.equalsIgnoreCase(property)) {
            if (StringUtils.equals(skd.getName(), newValue)) {
                return;
            }
            skd.setName(newValue);
        } else if (MatchAnalysisConstant.COLUMN.equalsIgnoreCase(property)) {
            if (StringUtils.equals(skd.getColumn(), newValue)) {
                return;
            }
            skd.setColumn(newValue);
        } else if (MatchAnalysisConstant.FUNCTION.equalsIgnoreCase(property)) {
            SurvivorShipAlgorithmEnum valueByIndex = SurvivorShipAlgorithmEnum.getTypeByIndex(Integer.valueOf(newValue).intValue());
            if (StringUtils.equals(skd.getFunction().getAlgorithmType(), valueByIndex.getComponentValueName())) {
                return;
            }
            skd.getFunction().setAlgorithmType(valueByIndex.getComponentValueName());
        } else if (MatchAnalysisConstant.ALLOW_MANUAL_RESOLUTION.equalsIgnoreCase(property)) {
            if (skd.isAllowManualResolution() == Boolean.valueOf(newValue)) {
                return;
            }
            skd.setAllowManualResolution(Boolean.valueOf(newValue));
        } else {
            return;
        }
        tableViewer.update(skd, null);
    }
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) SurvivorshipKeyDefinition(org.talend.dataquality.rules.SurvivorshipKeyDefinition) SurvivorShipAlgorithmEnum(org.talend.dataquality.record.linkage.utils.SurvivorShipAlgorithmEnum)

Aggregations

SurvivorshipKeyDefinition (org.talend.dataquality.rules.SurvivorshipKeyDefinition)17 AlgorithmDefinition (org.talend.dataquality.rules.AlgorithmDefinition)4 ArrayList (java.util.ArrayList)3 ISelection (org.eclipse.jface.viewers.ISelection)3 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)3 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)2 SurvivorShipAlgorithmParams (org.talend.dataquality.record.linkage.grouping.swoosh.SurvivorShipAlgorithmParams)2 SurvivorshipFunction (org.talend.dataquality.record.linkage.grouping.swoosh.SurvivorShipAlgorithmParams.SurvivorshipFunction)2 MatchKeyDefinition (org.talend.dataquality.rules.MatchKeyDefinition)2 MatchRuleDefinition (org.talend.dataquality.rules.MatchRuleDefinition)2 ReturnCode (org.talend.utils.sugars.ReturnCode)2 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 EList (org.eclipse.emf.common.util.EList)1 CTabItem (org.eclipse.swt.custom.CTabItem)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 TableItem (org.eclipse.swt.widgets.TableItem)1