Search in sources :

Example 1 with KeyDefinition

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

the class BlockingKeySection method isKeyDefinitionAdded.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.dataquality.record.linkage.ui.section.AbstractMatchAnaysisTableSection#isKeyDefinitionAdded(java.lang
     * .String)
     */
@Override
public Boolean isKeyDefinitionAdded(String columnName) {
    Boolean isAdded = Boolean.FALSE;
    RecordMatchingIndicator recordMatchingIndicator = MatchRuleAnlaysisUtils.getRecordMatchIndicatorFromAna(analysis);
    List<BlockKeyDefinition> keyDefs = recordMatchingIndicator.getBuiltInMatchRuleDefinition().getBlockKeys();
    for (KeyDefinition keyDef : keyDefs) {
        // the key's name can NOT be same, the column can be same
        if (StringUtils.equals(columnName, keyDef.getName())) {
            isAdded = Boolean.TRUE;
            break;
        }
    }
    return isAdded;
}
Also used : BlockKeyDefinition(org.talend.dataquality.rules.BlockKeyDefinition) RecordMatchingIndicator(org.talend.dataquality.indicators.columnset.RecordMatchingIndicator) BlockKeyDefinition(org.talend.dataquality.rules.BlockKeyDefinition) KeyDefinition(org.talend.dataquality.rules.KeyDefinition)

Example 2 with KeyDefinition

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

the class BlockingKeySection method getSelectedColumnAsBlockKeys.

/**
 * get all columns which is selected as blocking key
 *
 * @return
 */
public List<String> getSelectedColumnAsBlockKeys() {
    List<String> keyColumns = new ArrayList<String>();
    RecordMatchingIndicator recordMatchingIndicator = MatchRuleAnlaysisUtils.getRecordMatchIndicatorFromAna(analysis);
    List<BlockKeyDefinition> keyDefs = recordMatchingIndicator.getBuiltInMatchRuleDefinition().getBlockKeys();
    if (keyDefs.size() > 0) {
        for (KeyDefinition keydef : keyDefs) {
            keyColumns.add(keydef.getColumn());
        }
    }
    return keyColumns;
}
Also used : ArrayList(java.util.ArrayList) BlockKeyDefinition(org.talend.dataquality.rules.BlockKeyDefinition) RecordMatchingIndicator(org.talend.dataquality.indicators.columnset.RecordMatchingIndicator) BlockKeyDefinition(org.talend.dataquality.rules.BlockKeyDefinition) KeyDefinition(org.talend.dataquality.rules.KeyDefinition)

Example 3 with KeyDefinition

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

the class AnalysisRecordGroupingUtils method getBlockKeySchema.

/**
 * mzhao Get block key schema given the record matching indicator.
 *
 * @param recordMatchingIndicator
 * @return
 */
public static List<Map<String, String>> getBlockKeySchema(RecordMatchingIndicator recordMatchingIndicator) {
    List<AppliedBlockKey> appliedBlockKeys = recordMatchingIndicator.getBuiltInMatchRuleDefinition().getAppliedBlockKeys();
    List<Map<String, String>> blockKeySchema = new ArrayList<Map<String, String>>();
    for (KeyDefinition keyDef : appliedBlockKeys) {
        AppliedBlockKey appliedKeyDefinition = (AppliedBlockKey) keyDef;
        String column = appliedKeyDefinition.getColumn();
        if (StringUtils.equals(PluginConstant.BLOCK_KEY, column)) {
            // If there exist customized block key defined, get the key
            // parameters.
            List<BlockKeyDefinition> blockKeyDefs = recordMatchingIndicator.getBuiltInMatchRuleDefinition().getBlockKeys();
            for (BlockKeyDefinition blockKeyDef : blockKeyDefs) {
                Map<String, String> blockKeyDefMap = new HashMap<String, String>();
                blockKeyDefMap.putAll(getCustomizedBlockKeyParameter(blockKeyDef, blockKeyDef.getColumn()));
                blockKeySchema.add(blockKeyDefMap);
            }
        } else {
            Map<String, String> blockKeyDefMap = new HashMap<String, String>();
            blockKeyDefMap.put(MatchAnalysisConstant.PRECOLUMN, column);
            blockKeySchema.add(blockKeyDefMap);
        }
    }
    return blockKeySchema;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) BlockKeyDefinition(org.talend.dataquality.rules.BlockKeyDefinition) AppliedBlockKey(org.talend.dataquality.rules.AppliedBlockKey) HashMap(java.util.HashMap) Map(java.util.Map) BlockKeyDefinition(org.talend.dataquality.rules.BlockKeyDefinition) KeyDefinition(org.talend.dataquality.rules.KeyDefinition) MatchKeyDefinition(org.talend.dataquality.rules.MatchKeyDefinition)

Example 4 with KeyDefinition

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

the class BlockingKeySection method computeResult.

/**
 * DOC zshen Comment method "computeRusult". <br>
 * TODO Handle the return value: return the result directly instead of action instance.
 *
 * @return
 */
protected BlockingKeyHandler computeResult() {
    List<Map<String, String>> blockingKeyData = MatchRuleAnlaysisUtils.blockingKeyDataConvert((List<KeyDefinition>) tableComposite.getInput());
    Map<String, String> colName2IndexMap = new HashMap<String, String>();
    for (MetadataColumn metaCol : columnMap.keySet()) {
        colName2IndexMap.put(metaCol.getName(), columnMap.get(metaCol));
    }
    BlockingKeyHandler executeGenerateBlockingAction = new BlockingKeyHandler(blockingKeyData, colName2IndexMap);
    if (hasBlockingKey()) {
        executeGenerateBlockingAction.setInputData(matchRows);
        executeGenerateBlockingAction.run();
    }
    return executeGenerateBlockingAction;
}
Also used : MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) HashMap(java.util.HashMap) HashMap(java.util.HashMap) Map(java.util.Map) BlockKeyDefinition(org.talend.dataquality.rules.BlockKeyDefinition) KeyDefinition(org.talend.dataquality.rules.KeyDefinition) BlockingKeyHandler(org.talend.dataquality.record.linkage.genkey.BlockingKeyHandler)

Example 5 with KeyDefinition

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

Aggregations

KeyDefinition (org.talend.dataquality.rules.KeyDefinition)7 BlockKeyDefinition (org.talend.dataquality.rules.BlockKeyDefinition)5 ArrayList (java.util.ArrayList)4 MatchKeyDefinition (org.talend.dataquality.rules.MatchKeyDefinition)4 Map (java.util.Map)3 HashMap (java.util.HashMap)2 RecordMatchingIndicator (org.talend.dataquality.indicators.columnset.RecordMatchingIndicator)2 MatchRule (org.talend.dataquality.rules.MatchRule)2 SurvivorshipKeyDefinition (org.talend.dataquality.rules.SurvivorshipKeyDefinition)2 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)1 BlockingKeyHandler (org.talend.dataquality.record.linkage.genkey.BlockingKeyHandler)1 AppliedBlockKey (org.talend.dataquality.rules.AppliedBlockKey)1