use of org.talend.dataquality.rules.MatchRule 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;
}
use of org.talend.dataquality.rules.MatchRule in project tdq-studio-se by Talend.
the class MatchingKeySection method deleteMatchRuleTab.
protected void deleteMatchRuleTab(CTabItem tabItem) {
MatchRule matchRule = getMatchRule(tabItem);
// Remove it from anaysis.
boolean removed = getMatchRuleList().remove(matchRule);
if (removed) {
listeners.firePropertyChange(MatchAnalysisConstant.ISDIRTY_PROPERTY, true, false);
fireSwitchRuleTabEvent();
}
}
use of org.talend.dataquality.rules.MatchRule in project tdq-studio-se by Talend.
the class MatchingKeySection method checkResultStatus.
/*
* (non-Javadoc)
*
* @see org.talend.dataquality.record.linkage.ui.section.AbstractMatchAnaysisTableSection#checkResultStatus()
*/
@Override
public ReturnCode checkResultStatus() {
ReturnCode returnCode = new ReturnCode(false);
if (!hasMatchKey(false)) {
// $NON-NLS-1$
returnCode.setMessage(DefaultMessagesImpl.getString("MatchMasterDetailsPage.NoMatchKey"));
return returnCode;
}
List<String> uniqueNameList = new ArrayList<String>();
for (MatchRule currentRule : getMatchRuleList()) {
EList<MatchKeyDefinition> matchKeys = currentRule.getMatchKeys();
for (MatchKeyDefinition mdk : matchKeys) {
String currentName = mdk.getName();
if (currentName.equals(StringUtils.EMPTY)) {
returnCode.setMessage(DefaultMessagesImpl.getString("BlockingKeySection.emptyKeys.message", // $NON-NLS-1$ //$NON-NLS-2$
getSectionName() + " , " + currentRule.getName()));
return returnCode;
}
if (uniqueNameList.contains(currentName)) {
returnCode.setMessage(DefaultMessagesImpl.getString("BlockingKeySection.duplicateKeys.message", // $NON-NLS-1$ //$NON-NLS-2$
getSectionName() + "--" + currentName));
return returnCode;
}
uniqueNameList.add(currentName);
if (checkColumnNameIsEmpty(mdk)) {
returnCode.setMessage(DefaultMessagesImpl.getString("BlockingKeySection.emptyColumn.message", // $NON-NLS-1$ //$NON-NLS-2$
getSectionName() + " , " + currentRule.getName()));
return returnCode;
}
if (// $NON-NLS-1$
"CUSTOM".equals(mdk.getAlgorithm().getAlgorithmType()) && StringUtils.EMPTY.equals(mdk.getAlgorithm().getAlgorithmParameters().trim())) {
returnCode.setMessage(DefaultMessagesImpl.getString("BlockingKeySection.invalidCustomAlgorithmError", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
getSectionName() + " , " + currentRule.getName() + " , " + currentName));
return returnCode;
}
if (mdk.getConfidenceWeight() <= 0) {
returnCode.setMessage(DefaultMessagesImpl.getString("BlockingKeySection.invalidConfidenceWeight.message", // $NON-NLS-1$
getSectionName()));
return returnCode;
}
ReturnCode checkSurvivorshipFunction = checkSurvivorshipFunction(mdk, this.getMatchRuleDefinition());
if (!checkSurvivorshipFunction.isOk()) {
returnCode.setMessage(// $NON-NLS-1$
DefaultMessagesImpl.getString(// $NON-NLS-1$
"MatchingKeySection.invalidSurvivorshipFunction", getSectionName(), checkSurvivorshipFunction.getMessage()));
return returnCode;
}
}
}
returnCode.setOk(true);
return returnCode;
}
use of org.talend.dataquality.rules.MatchRule in project tdq-studio-se by Talend.
the class MatchingKeySection method importMatchRule.
/**
* if overwrite: need to delete all current tabs, and create the tab according to the parameter:matchRule else: only
* add the tab in the parameter matchrule, to the current matchrule.
*
* @param matchRuleDefinition
* @param overwrite
*/
public void importMatchRule(MatchRuleDefinition matchRuleDefinition, boolean overwrite) {
if (overwrite) {
// delete all tab in UI
CTabItem[] tabItems = ruleFolder.getItems();
if (tabItems != null && tabItems.length > 0) {
for (CTabItem oneTab : tabItems) {
@SuppressWarnings("rawtypes") AbsMatchAnalysisTableComposite matchRuleTableComp = getMatchRuleComposite(oneTab);
matchRuleTableComp.dispose();
oneTab.dispose();
}
}
// clear all survivorship keys
getMatchRuleDefinition().getSurvivorshipKeys().clear();
// clear all match rules in matchrule definition
getMatchRuleDefinition().getMatchRules().clear();
// overwrite the threshold
groupQualityThresholdText.setText(String.valueOf(matchRuleDefinition.getMatchGroupQualityThreshold()));
}
// import survivorship keys
for (SurvivorshipKeyDefinition skd : matchRuleDefinition.getSurvivorshipKeys()) {
SurvivorshipKeyDefinition survivorshipKeyDefinition = EcoreUtil.copy(skd);
setColumnValueIfMatch(survivorshipKeyDefinition);
getMatchRuleDefinition().getSurvivorshipKeys().add(survivorshipKeyDefinition);
}
// create the tab from the parameter:matchRule
for (MatchRule oneMatchRule : matchRuleDefinition.getMatchRules()) {
MatchRule matchRule2 = createMatchRuleByCopy(oneMatchRule);
// MOD msjian TDQ-8484: set the name of the match rule by the old name
matchRule2.setName(oneMatchRule.getName());
// if the key name= some column name, set the column to this key
for (MatchKeyDefinition key : matchRule2.getMatchKeys()) {
setColumnValueIfMatch(key);
}
// auto add the tab name order
addRuleTab(false, matchRule2);
getMatchRuleDefinition().getMatchRules().add(matchRule2);
}
}
use of org.talend.dataquality.rules.MatchRule in project tdq-studio-se by Talend.
the class MatchingKeySection method getCurrentMatchKeyColumn.
/**
* find the current columns which has been selected as match key on the current Tab(Match rule)
*
* @return
*/
public List<String> getCurrentMatchKeyColumn() {
List<String> columnAsKey = new ArrayList<String>();
MatchRule matchRule;
try {
matchRule = getCurrentMatchRule();
} catch (Exception e) {
return columnAsKey;
}
for (KeyDefinition keyDef : matchRule.getMatchKeys()) {
columnAsKey.add(keyDef.getColumn());
}
return columnAsKey;
}
Aggregations