Search in sources :

Example 21 with AlgorithmDefinition

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

the class DefaultSurvivorShipTableViewer method createNewKeyDefinition.

@Override
protected DefaultSurvivorshipDefinition createNewKeyDefinition(String columnName) {
    DefaultSurvivorshipDefinition skd = RulesFactory.eINSTANCE.createDefaultSurvivorshipDefinition();
    skd.setDataType(DefaultSurvivorShipDataTypeEnum.getTypeByIndex(0).getValue());
    AlgorithmDefinition createAlgorithmDefinition = RulesFactory.eINSTANCE.createAlgorithmDefinition();
    createAlgorithmDefinition.setAlgorithmType(SurvivorShipAlgorithmEnum.getTypeByIndex(3).getComponentValueName());
    skd.setFunction(createAlgorithmDefinition);
    return skd;
}
Also used : DefaultSurvivorshipDefinition(org.talend.dataquality.rules.DefaultSurvivorshipDefinition) AlgorithmDefinition(org.talend.dataquality.rules.AlgorithmDefinition)

Example 22 with AlgorithmDefinition

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

the class SurvivorShipTableViewer method createNewKeyDefinition.

/*
     * (non-Javadoc) columnList.toArray(new String[0])
     * 
     * @see org.talend.dataquality.record.linkage.ui.composite.tableviewer.AbstractMatchAnalysisTableViewer#
     * createNewKeyDefinition(java.lang.String)
     */
@Override
protected SurvivorshipKeyDefinition createNewKeyDefinition(String columnName) {
    SurvivorshipKeyDefinition skd = RulesFactory.eINSTANCE.createSurvivorshipKeyDefinition();
    skd.setName(MatchAnalysisConstant.SURVIVORSHIP_KEY_DEFAULT_VALUE);
    skd.setColumn(columnName);
    AlgorithmDefinition createAlgorithmDefinition = RulesFactory.eINSTANCE.createAlgorithmDefinition();
    createAlgorithmDefinition.setAlgorithmType(SurvivorShipAlgorithmEnum.getTypeByIndex(3).getComponentValueName());
    skd.setFunction(createAlgorithmDefinition);
    skd.setAllowManualResolution(true);
    return skd;
}
Also used : SurvivorshipKeyDefinition(org.talend.dataquality.rules.SurvivorshipKeyDefinition) AlgorithmDefinition(org.talend.dataquality.rules.AlgorithmDefinition)

Example 23 with AlgorithmDefinition

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

the class MatchRuleAnlaysisUtils method createDefaultMatchRow.

/**
 * DOC zshen Comment method "createDefaultRow".
 *
 * @param columnName
 * @return
 */
public static MatchKeyDefinition createDefaultMatchRow(String columnName) {
    MatchKeyDefinition createMatchKeyDefinition1 = RulesFactory.eINSTANCE.createMatchKeyDefinition();
    AlgorithmDefinition createAlgorithmDefinition1 = RulesFactory.eINSTANCE.createAlgorithmDefinition();
    // by default the name of the match attribute rule is the name of the selected column
    createMatchKeyDefinition1.setName(columnName);
    createMatchKeyDefinition1.setColumn(columnName);
    createMatchKeyDefinition1.setConfidenceWeight(1);
    createMatchKeyDefinition1.setHandleNull(HandleNullEnum.NULL_MATCH_NULL.getValue());
    createMatchKeyDefinition1.setTokenizationType(TokenizedResolutionMethod.NO.getComponentValue());
    createAlgorithmDefinition1.setAlgorithmParameters(StringUtils.EMPTY);
    createAlgorithmDefinition1.setAlgorithmType(AttributeMatcherType.values()[0].name());
    createMatchKeyDefinition1.setAlgorithm(createAlgorithmDefinition1);
    createMatchKeyDefinition1.setThreshold(1.0);
    return createMatchKeyDefinition1;
}
Also used : MatchKeyDefinition(org.talend.dataquality.rules.MatchKeyDefinition) AlgorithmDefinition(org.talend.dataquality.rules.AlgorithmDefinition)

Example 24 with AlgorithmDefinition

use of org.talend.dataquality.rules.AlgorithmDefinition 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

AlgorithmDefinition (org.talend.dataquality.rules.AlgorithmDefinition)24 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)7 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)7 MatchKeyDefinition (org.talend.dataquality.rules.MatchKeyDefinition)7 RecordMatchingIndicator (org.talend.dataquality.indicators.columnset.RecordMatchingIndicator)6 MatchRule (org.talend.dataquality.rules.MatchRule)6 MatchRuleDefinition (org.talend.dataquality.rules.MatchRuleDefinition)6 Test (org.junit.Test)5 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)5 MatchGroupResultConsumer (org.talend.dataquality.record.linkage.grouping.MatchGroupResultConsumer)5 BlockKeyDefinition (org.talend.dataquality.rules.BlockKeyDefinition)5 BlockKeyIndicator (org.talend.dataquality.indicators.columnset.BlockKeyIndicator)4 SurvivorshipKeyDefinition (org.talend.dataquality.rules.SurvivorshipKeyDefinition)4 ExecuteMatchRuleHandler (org.talend.dq.analysis.match.ExecuteMatchRuleHandler)4 Map (java.util.Map)3 ParticularDefaultSurvivorshipDefinitions (org.talend.dataquality.rules.ParticularDefaultSurvivorshipDefinitions)3 DefaultSurvivorshipDefinition (org.talend.dataquality.rules.DefaultSurvivorshipDefinition)2 List (java.util.List)1 EList (org.eclipse.emf.common.util.EList)1