Search in sources :

Example 6 with MatchKeyAndSurvivorDefinition

use of org.talend.dataquality.record.linkage.ui.composite.tableviewer.definition.MatchKeyAndSurvivorDefinition in project tdq-studio-se by Talend.

the class AnaMatchSurvivorSection method getCurrentTabDefinitions.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dataquality.record.linkage.ui.section.MatchingKeySection#getCurrentTabDefinitions()
     */
@Override
protected List<?> getCurrentTabDefinitions() {
    MatchKeyAndSurvivorTableComposite matchRuleTableComp = (MatchKeyAndSurvivorTableComposite) getCurrentMatchRuleTableComposite();
    MatchRule matchRule = matchRuleTableComp.getMatchRule();
    List<MatchKeyAndSurvivorDefinition> matchAndSurvDefList = matchRuleWithSurvMap.get(matchRule);
    return matchAndSurvDefList;
}
Also used : MatchKeyAndSurvivorTableComposite(org.talend.dataquality.record.linkage.ui.composite.MatchKeyAndSurvivorTableComposite) MatchRule(org.talend.dataquality.rules.MatchRule) MatchKeyAndSurvivorDefinition(org.talend.dataquality.record.linkage.ui.composite.tableviewer.definition.MatchKeyAndSurvivorDefinition)

Example 7 with MatchKeyAndSurvivorDefinition

use of org.talend.dataquality.record.linkage.ui.composite.tableviewer.definition.MatchKeyAndSurvivorDefinition in project tdq-studio-se by Talend.

the class AnaMatchSurvivorSection method deleteMatchRuleTab.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.dataquality.record.linkage.ui.section.MatchingKeySection#deleteMatchRuleTab(org.eclipse.swt.custom
     * .CTabItem)
     */
@Override
protected void deleteMatchRuleTab(CTabItem tabItem) {
    MatchRule matchRule = getMatchRule(tabItem);
    List<MatchKeyAndSurvivorDefinition> matchAndSurvDefList = matchRuleWithSurvMap.get(matchRule);
    MatchRuleDefinition matchRuleDefinition = getMatchRuleDefinition();
    for (MatchKeyAndSurvivorDefinition matchAndSurvDef : matchAndSurvDefList) {
        matchRuleDefinition.getSurvivorshipKeys().remove(matchAndSurvDef.getSurvivorShipKey());
    }
    matchRuleWithSurvMap.remove(matchRule);
    super.deleteMatchRuleTab(tabItem);
}
Also used : MatchRuleDefinition(org.talend.dataquality.rules.MatchRuleDefinition) MatchRule(org.talend.dataquality.rules.MatchRule) MatchKeyAndSurvivorDefinition(org.talend.dataquality.record.linkage.ui.composite.tableviewer.definition.MatchKeyAndSurvivorDefinition)

Example 8 with MatchKeyAndSurvivorDefinition

use of org.talend.dataquality.record.linkage.ui.composite.tableviewer.definition.MatchKeyAndSurvivorDefinition in project tdq-studio-se by Talend.

the class AnaMatchSurvivorSection method removeTableItem.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dataquality.record.linkage.ui.section.MatchingKeySection#removeTableItem()
     */
@Override
public void removeTableItem() {
    boolean success = false;
    ISelection selectItems = getCurrentMatchRuleTableComposite().getSelectItems();
    if (selectItems instanceof StructuredSelection) {
        Iterator<MatchKeyAndSurvivorDefinition> iterator = ((StructuredSelection) selectItems).iterator();
        while (iterator.hasNext()) {
            MatchKeyAndSurvivorDefinition next = iterator.next();
            removeMatchKeyFromCurrentMatchRule(next);
            success = true;
        }
        if (success) {
            listeners.firePropertyChange(MatchAnalysisConstant.ISDIRTY_PROPERTY, true, false);
            listeners.firePropertyChange(MatchAnalysisConstant.MATCH_RULE_TAB_SWITCH, true, false);
        }
    }
}
Also used : ISelection(org.eclipse.jface.viewers.ISelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) MatchKeyAndSurvivorDefinition(org.talend.dataquality.record.linkage.ui.composite.tableviewer.definition.MatchKeyAndSurvivorDefinition)

Example 9 with MatchKeyAndSurvivorDefinition

use of org.talend.dataquality.record.linkage.ui.composite.tableviewer.definition.MatchKeyAndSurvivorDefinition in project tdq-studio-se by Talend.

the class AnaMatchSurvivorSection method createMatchKeyFromCurrentMatchRule.

@Override
public void createMatchKeyFromCurrentMatchRule(String column) {
    MatchKeyAndSurvivorTableComposite matchRuleTableComp = (MatchKeyAndSurvivorTableComposite) getCurrentMatchRuleTableComposite();
    List<MatchKeyAndSurvivorDefinition> matchAndSurvKeyList = matchRuleWithSurvMap.get(matchRuleTableComp.getMatchRule());
    matchRuleTableComp.addKeyDefinition(column, matchAndSurvKeyList);
}
Also used : MatchKeyAndSurvivorTableComposite(org.talend.dataquality.record.linkage.ui.composite.MatchKeyAndSurvivorTableComposite) MatchKeyAndSurvivorDefinition(org.talend.dataquality.record.linkage.ui.composite.tableviewer.definition.MatchKeyAndSurvivorDefinition)

Example 10 with MatchKeyAndSurvivorDefinition

use of org.talend.dataquality.record.linkage.ui.composite.tableviewer.definition.MatchKeyAndSurvivorDefinition in project tdq-studio-se by Talend.

the class MatchAndSurvivorCellModifer 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) {
        MatchKeyAndSurvivorDefinition mkd = (MatchKeyAndSurvivorDefinition) ((TableItem) element).getData();
        String newValue = String.valueOf(value);
        MatchKeyDefinition matchKey = mkd.getMatchKey();
        if (MatchAnalysisConstant.HANDLE_NULL.equalsIgnoreCase(property)) {
            HandleNullEnum valueByIndex = HandleNullEnum.values()[Integer.valueOf(newValue)];
            if (StringUtils.equals(matchKey.getHandleNull(), valueByIndex.getValue())) {
                return;
            }
            matchKey.setHandleNull(valueByIndex.getValue());
        } else if (MatchAnalysisConstant.MATCHING_TYPE.equalsIgnoreCase(property)) {
            int idx = Integer.valueOf(newValue);
            if (idx == AttributeMatcherType.DUMMY.ordinal()) {
                // The DUMMY algorithm is internal and does not exist in the combo lists of
                idx += 1;
            // MatchRuleItemEditor or MatchRuleAnalysisEditor. So we increment the index by 1 in order
            // to get the correct Matcher.
            }
            AttributeMatcherType valueByIndex = AttributeMatcherType.values()[idx];
            if (StringUtils.equals(matchKey.getAlgorithm().getAlgorithmType(), valueByIndex.name())) {
                return;
            }
            matchKey.getAlgorithm().setAlgorithmType(valueByIndex.name());
            matchKey.getAlgorithm().setAlgorithmParameters(StringUtils.EMPTY);
            if (isMatcherType(mkd, AttributeMatcherType.EXACT)) {
                matchKey.setThreshold(1.0d);
            }
        } else if (MatchAnalysisConstant.CUSTOM_MATCHER.equalsIgnoreCase(property)) {
            if (StringUtils.equals(matchKey.getAlgorithm().getAlgorithmParameters(), newValue)) {
                return;
            }
            matchKey.getAlgorithm().setAlgorithmParameters(String.valueOf(value));
        } else if (MatchAnalysisConstant.CONFIDENCE_WEIGHT.equalsIgnoreCase(property)) {
            if (!org.apache.commons.lang.math.NumberUtils.isDigits(newValue)) {
                return;
            }
            if (matchKey.getConfidenceWeight() == Integer.valueOf(newValue).intValue()) {
                return;
            }
            matchKey.setConfidenceWeight(Integer.valueOf(newValue).intValue());
        } else if (MatchAnalysisConstant.MATCH_KEY_NAME.equalsIgnoreCase(property)) {
            if (StringUtils.equals(matchKey.getName(), newValue)) {
                return;
            }
            matchKey.setName(newValue);
            mkd.getSurvivorShipKey().setName(newValue);
        } else if (MatchAnalysisConstant.INPUT_COLUMN.equalsIgnoreCase(property)) {
            int idx = Integer.valueOf(newValue);
            if (columnList == null || columnList.isEmpty()) {
                return;
            }
            MetadataColumn metaColumn = columnList.get(idx);
            if (metaColumn == null) {
                return;
            }
            if (StringUtils.equals(metaColumn.getName(), newValue)) {
                return;
            }
            matchKey.setColumn(metaColumn.getName());
            mkd.getSurvivorShipKey().setColumn(metaColumn.getName());
            // added TDQ-9296, nodify the change to let the upper layer know this
            tableViewer.noticeColumnSelectChange();
        } else if (MatchAnalysisConstant.THRESHOLD.equalsIgnoreCase(property)) {
            if (!org.apache.commons.lang.math.NumberUtils.isNumber(newValue)) {
                return;
            }
            if (matchKey.getThreshold() == Double.parseDouble(newValue)) {
                return;
            }
            try {
                matchKey.setThreshold(Double.parseDouble(newValue));
            } catch (NumberFormatException e) {
            // revert user change at here so don't need do anything
            }
        } else if (MatchAnalysisConstant.FUNCTION.equalsIgnoreCase(property)) {
            SurvivorShipAlgorithmEnum valueByIndex = SurvivorShipAlgorithmEnum.getTypeByIndex(Integer.valueOf(newValue).intValue());
            if (StringUtils.equals(mkd.getSurvivorShipKey().getFunction().getAlgorithmType(), valueByIndex.getComponentValueName())) {
                return;
            }
            mkd.getSurvivorShipKey().getFunction().setAlgorithmType(valueByIndex.getComponentValueName());
            if (!(isSurvivorShipAlgorithm(mkd, SurvivorShipAlgorithmEnum.MOST_TRUSTED_SOURCE) | (isSurvivorShipAlgorithm(mkd, SurvivorShipAlgorithmEnum.CONCATENATE)))) {
                mkd.getSurvivorShipKey().getFunction().setAlgorithmParameters(StringUtils.EMPTY);
            // MOD mzhao 2014-7-22 there will be an exception here, when switching the surv functions. Confirmed
            // with haibo (MDM team), removed this code.
            // CellEditor[] cellEditors = tableViewer.getCellEditors();
            // if (cellEditors.length == 9) {
            // cellEditors[7].setValue(StringUtils.EMPTY);
            // }
            }
        } else if (MatchAnalysisConstant.PARAMETER.equalsIgnoreCase(property)) {
            mkd.getSurvivorShipKey().getFunction().setAlgorithmParameters(newValue);
        } else if (MatchAnalysisConstant.TOKENIZATION_TYPE.equalsIgnoreCase(property)) {
            TokenizedResolutionMethod valueByIndex = TokenizedResolutionMethod.values()[Integer.valueOf(newValue)];
            if (StringUtils.equals(mkd.getMatchKey().getTokenizationType(), valueByIndex.getComponentValue())) {
                return;
            }
            mkd.getMatchKey().setTokenizationType(valueByIndex.getComponentValue());
        } else {
            return;
        }
        tableViewer.update(mkd, null);
    }
}
Also used : MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) AttributeMatcherType(org.talend.dataquality.record.linkage.constant.AttributeMatcherType) TokenizedResolutionMethod(org.talend.dataquality.record.linkage.constant.TokenizedResolutionMethod) TableItem(org.eclipse.swt.widgets.TableItem) MatchKeyDefinition(org.talend.dataquality.rules.MatchKeyDefinition) SurvivorShipAlgorithmEnum(org.talend.dataquality.record.linkage.utils.SurvivorShipAlgorithmEnum) MatchKeyAndSurvivorDefinition(org.talend.dataquality.record.linkage.ui.composite.tableviewer.definition.MatchKeyAndSurvivorDefinition) HandleNullEnum(org.talend.dataquality.record.linkage.utils.HandleNullEnum)

Aggregations

MatchKeyAndSurvivorDefinition (org.talend.dataquality.record.linkage.ui.composite.tableviewer.definition.MatchKeyAndSurvivorDefinition)10 MatchKeyAndSurvivorTableComposite (org.talend.dataquality.record.linkage.ui.composite.MatchKeyAndSurvivorTableComposite)4 MatchRule (org.talend.dataquality.rules.MatchRule)4 MatchKeyDefinition (org.talend.dataquality.rules.MatchKeyDefinition)2 MatchRuleDefinition (org.talend.dataquality.rules.MatchRuleDefinition)2 ISelection (org.eclipse.jface.viewers.ISelection)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 TableItem (org.eclipse.swt.widgets.TableItem)1 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)1 AttributeMatcherType (org.talend.dataquality.record.linkage.constant.AttributeMatcherType)1 TokenizedResolutionMethod (org.talend.dataquality.record.linkage.constant.TokenizedResolutionMethod)1 HandleNullEnum (org.talend.dataquality.record.linkage.utils.HandleNullEnum)1 SurvivorShipAlgorithmEnum (org.talend.dataquality.record.linkage.utils.SurvivorShipAlgorithmEnum)1