Search in sources :

Example 1 with AppliedBlockKey

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

the class AnalysisRecordGroupingUtils method createAppliedBlockKeyByGenKey.

/**
 * By default for analysis, the applied blocking key will be the key from key generation definition. This will be
 * refined when there is a need to define the applied blocking key manually by user later.
 *
 * @param recordMatchingIndicator
 */
public static void createAppliedBlockKeyByGenKey(RecordMatchingIndicator recordMatchingIndicator) {
    List<AppliedBlockKey> appliedBlockKeys = recordMatchingIndicator.getBuiltInMatchRuleDefinition().getAppliedBlockKeys();
    appliedBlockKeys.clear();
    List<BlockKeyDefinition> blockKeyDefs = recordMatchingIndicator.getBuiltInMatchRuleDefinition().getBlockKeys();
    if (blockKeyDefs != null && blockKeyDefs.size() > 0) {
        AppliedBlockKey appliedBlockKey = RulesPackage.eINSTANCE.getRulesFactory().createAppliedBlockKey();
        appliedBlockKey.setColumn(PluginConstant.BLOCK_KEY);
        appliedBlockKey.setName(PluginConstant.BLOCK_KEY);
        appliedBlockKeys.add(appliedBlockKey);
    }
}
Also used : BlockKeyDefinition(org.talend.dataquality.rules.BlockKeyDefinition) AppliedBlockKey(org.talend.dataquality.rules.AppliedBlockKey)

Example 2 with AppliedBlockKey

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

Aggregations

AppliedBlockKey (org.talend.dataquality.rules.AppliedBlockKey)2 BlockKeyDefinition (org.talend.dataquality.rules.BlockKeyDefinition)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 KeyDefinition (org.talend.dataquality.rules.KeyDefinition)1 MatchKeyDefinition (org.talend.dataquality.rules.MatchKeyDefinition)1