Search in sources :

Example 1 with TokenizedResolutionMethod

use of org.talend.dataquality.record.linkage.constant.TokenizedResolutionMethod in project tdq-studio-se by Talend.

the class MatchRuleCellModifier 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) {
        MatchKeyDefinition mkd = (MatchKeyDefinition) ((TableItem) element).getData();
        String newValue = String.valueOf(value);
        if (MatchAnalysisConstant.HANDLE_NULL.equalsIgnoreCase(property)) {
            HandleNullEnum valueByIndex = HandleNullEnum.values()[Integer.valueOf(newValue)];
            if (StringUtils.equals(mkd.getHandleNull(), valueByIndex.getValue())) {
                return;
            }
            mkd.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(mkd.getAlgorithm().getAlgorithmType(), valueByIndex.name())) {
                return;
            }
            mkd.getAlgorithm().setAlgorithmType(valueByIndex.name());
            mkd.getAlgorithm().setAlgorithmParameters(StringUtils.EMPTY);
        } else if (MatchAnalysisConstant.CUSTOM_MATCHER.equalsIgnoreCase(property)) {
            if (StringUtils.equals(mkd.getAlgorithm().getAlgorithmParameters(), newValue)) {
                return;
            }
            mkd.getAlgorithm().setAlgorithmParameters(String.valueOf(value));
        } else if (MatchAnalysisConstant.INPUT_COLUMN.equalsIgnoreCase(property)) {
            if (Integer.parseInt(newValue) == -1) {
                return;
            }
            String columnName = columnList.get(Integer.parseInt(newValue)).getName();
            if (StringUtils.equals(mkd.getColumn(), columnName)) {
                return;
            }
            mkd.setColumn(columnName);
            tableViewer.noticeColumnSelectChange();
        } else if (MatchAnalysisConstant.CONFIDENCE_WEIGHT.equalsIgnoreCase(property)) {
            if (!validIntegerType(newValue)) {
                return;
            }
            if (mkd.getConfidenceWeight() == Integer.valueOf(newValue).intValue()) {
                return;
            }
            mkd.setConfidenceWeight(Integer.valueOf(newValue).intValue());
        } else if (MatchAnalysisConstant.MATCH_KEY_NAME.equalsIgnoreCase(property)) {
            if (StringUtils.equals(mkd.getName(), newValue)) {
                return;
            }
            mkd.setName(newValue);
        } else if (MatchAnalysisConstant.THRESHOLD.equalsIgnoreCase(property)) {
            if (mkd.getThreshold() == Double.parseDouble(newValue)) {
                return;
            }
            try {
                mkd.setThreshold(Double.parseDouble(newValue));
            } catch (NumberFormatException e) {
            // revert user change at here so don't need do anything
            }
        } else if (MatchAnalysisConstant.TOKENIZATION_TYPE.equalsIgnoreCase(property)) {
            TokenizedResolutionMethod valueByIndex = TokenizedResolutionMethod.values()[Integer.valueOf(newValue)];
            if (StringUtils.equals(mkd.getTokenizationType(), valueByIndex.getComponentValue())) {
                return;
            }
            mkd.setTokenizationType(valueByIndex.getComponentValue());
        } else {
            return;
        }
        tableViewer.update(mkd, null);
    }
}
Also used : 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) HandleNullEnum(org.talend.dataquality.record.linkage.utils.HandleNullEnum)

Example 2 with TokenizedResolutionMethod

use of org.talend.dataquality.record.linkage.constant.TokenizedResolutionMethod 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

TableItem (org.eclipse.swt.widgets.TableItem)2 AttributeMatcherType (org.talend.dataquality.record.linkage.constant.AttributeMatcherType)2 TokenizedResolutionMethod (org.talend.dataquality.record.linkage.constant.TokenizedResolutionMethod)2 HandleNullEnum (org.talend.dataquality.record.linkage.utils.HandleNullEnum)2 MatchKeyDefinition (org.talend.dataquality.rules.MatchKeyDefinition)2 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)1 MatchKeyAndSurvivorDefinition (org.talend.dataquality.record.linkage.ui.composite.tableviewer.definition.MatchKeyAndSurvivorDefinition)1 SurvivorShipAlgorithmEnum (org.talend.dataquality.record.linkage.utils.SurvivorShipAlgorithmEnum)1