use of org.talend.dataquality.rules.MatchRule in project tdq-studio-se by Talend.
the class MatchingKeySection method addNewMatchRule.
/**
* add a new match rule when the user click "+" button.
*/
protected void addNewMatchRule() {
MatchRule newMatchRule = getNewMatchRule();
addRuleTab(true, newMatchRule);
addMatchRuleToAnalysis(newMatchRule);
listeners.firePropertyChange(MatchAnalysisConstant.ISDIRTY_PROPERTY, true, false);
}
use of org.talend.dataquality.rules.MatchRule in project tdq-studio-se by Talend.
the class MatchingKeySection method getNewMatchRule.
/**
* DOC yyin Comment method "getNewRuleMatcher".
*/
private MatchRule getNewMatchRule() {
MatchRule ruleMatcher = RulesFactory.eINSTANCE.createMatchRule();
String tabName = getMatchRuleNameByOrder();
ruleMatcher.setName(tabName);
return ruleMatcher;
}
use of org.talend.dataquality.rules.MatchRule in project tdq-studio-se by Talend.
the class MatchRuleAnlaysisUtils method convertDataMapToRuleMatcher.
public static List<MatchRule> convertDataMapToRuleMatcher(Map<String, String> columnMap) {
List<MatchRule> matcherList = new ArrayList<MatchRule>();
if (columnMap == null) {
return matcherList;
}
MatchRule createRuleMatcher = RulesFactory.eINSTANCE.createMatchRule();
for (String columnName : columnMap.keySet()) {
MatchKeyDefinition createDefaultMatchRow = createDefaultMatchRow(columnName);
createRuleMatcher.getMatchKeys().add(createDefaultMatchRow);
}
matcherList.add(createRuleMatcher);
return matcherList;
}
use of org.talend.dataquality.rules.MatchRule 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;
}
Aggregations