use of org.talend.dataquality.rules.SurvivorshipKeyDefinition in project tdq-studio-se by Talend.
the class MatchingKeySection method checkSurvivorshipFunction.
/**
* check the survivorship function fit the column or not.
*
* @param mkDef
* @param mrDef
* @return
*/
private ReturnCode checkSurvivorshipFunction(MatchKeyDefinition mkDef, MatchRuleDefinition mrDef) {
ReturnCode rc = new ReturnCode(true);
EList<SurvivorshipKeyDefinition> survivorshipKeys = mrDef.getSurvivorshipKeys();
for (SurvivorshipKeyDefinition skDef : survivorshipKeys) {
if (StringUtils.equals(mkDef.getName(), skDef.getName())) {
MetadataColumn metadataColumn = getMetadataColumnByName(mkDef.getColumn());
if (metadataColumn != null) {
String algorithmType = skDef.getFunction().getAlgorithmType();
if (!MatchRuleAnlaysisUtils.isSurvivorShipFunctionConsistentWithType(algorithmType, metadataColumn.getTalendType())) {
rc.setOk(false);
rc.setMessage(DefaultMessagesImpl.getString(// $NON-NLS-1$
"MatchingKeySection.survivorshipFunctionNotMatch", // $NON-NLS-1$
metadataColumn.getName(), SurvivorShipAlgorithmEnum.getTypeBySavedValue(algorithmType).getValue()));
return rc;
}
}
}
}
return rc;
}
use of org.talend.dataquality.rules.SurvivorshipKeyDefinition 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.SurvivorshipKeyDefinition in project tdq-studio-se by Talend.
the class SurvivorshipDefinitionSection method checkResultStatus.
/*
* (non-Javadoc)
*
* @see org.talend.dataquality.record.linkage.ui.section.AbstractMatchAnaysisTableSection#checkResultStatus()
*/
@Override
public ReturnCode checkResultStatus() {
ReturnCode returnCode = new ReturnCode(false);
List<String> uniqueNameList = new ArrayList<String>();
List<String> duplicateNameList = new ArrayList<String>();
for (SurvivorshipKeyDefinition ssdk : getSurvivorshipKeys()) {
String currentName = ssdk.getName();
if (currentName.equals(StringUtils.EMPTY)) {
// $NON-NLS-1$
returnCode.setMessage(DefaultMessagesImpl.getString("BlockingKeySection.emptyKeys.message", getSectionName()));
return returnCode;
}
boolean currentNameIsDuplicate = false;
for (String uniqueName : uniqueNameList) {
if (currentName.equals(uniqueName)) {
duplicateNameList.add(currentName);
currentNameIsDuplicate = true;
}
}
if (!currentNameIsDuplicate) {
uniqueNameList.add(currentName);
}
}
if (duplicateNameList.size() > 0) {
// $NON-NLS-1$
returnCode.setMessage(DefaultMessagesImpl.getString("BlockingKeySection.duplicateKeys.message", getSectionName()));
return returnCode;
} else {
returnCode.setOk(true);
return returnCode;
}
}
use of org.talend.dataquality.rules.SurvivorshipKeyDefinition in project tdq-studio-se by Talend.
the class SurvivorshipDefinitionSection method moveDownTableItem.
/*
* (non-Javadoc)
*
* @see org.talend.dataquality.record.linkage.ui.section.AbstractMatchAnaysisTableSection#moveUpTableItem()
*/
@Override
public void moveDownTableItem() {
ISelection selectItems = tableComposite.getSelectItems();
if (selectItems instanceof StructuredSelection) {
if (selectItems.isEmpty()) {
return;
}
List<SurvivorshipKeyDefinition> currentElements = this.matchRuleDef.getSurvivorshipKeys();
List<SurvivorshipKeyDefinition> survivorshipKeyDefinitionlist = ((StructuredSelection) selectItems).toList();
for (int index = survivorshipKeyDefinitionlist.size() - 1; 0 <= index; index--) {
if (!isSameWithCurrentModel(currentElements.get(currentElements.size() - survivorshipKeyDefinitionlist.size() + index), survivorshipKeyDefinitionlist.get(index))) {
continue;
}
SurvivorshipKeyDefinition next = survivorshipKeyDefinitionlist.get(index);
tableComposite.moveDownKeyDefinition(next, currentElements);
}
tableComposite.selectAllItem(((StructuredSelection) selectItems).toList());
}
}
use of org.talend.dataquality.rules.SurvivorshipKeyDefinition in project tdq-studio-se by Talend.
the class SurvivorShipCellModifier method modify.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.ICellModifier#modify(java.lang.Object, java.lang.String, java.lang.Object)
*/
@Override
public void modify(Object element, String property, Object value) {
if (element instanceof TableItem) {
SurvivorshipKeyDefinition skd = (SurvivorshipKeyDefinition) ((TableItem) element).getData();
String newValue = String.valueOf(value);
if (MatchAnalysisConstant.SURVIVORSHIP_KEY_NAME.equalsIgnoreCase(property)) {
if (StringUtils.equals(skd.getName(), newValue)) {
return;
}
skd.setName(newValue);
} else if (MatchAnalysisConstant.COLUMN.equalsIgnoreCase(property)) {
if (StringUtils.equals(skd.getColumn(), newValue)) {
return;
}
skd.setColumn(newValue);
} else if (MatchAnalysisConstant.FUNCTION.equalsIgnoreCase(property)) {
SurvivorShipAlgorithmEnum valueByIndex = SurvivorShipAlgorithmEnum.getTypeByIndex(Integer.valueOf(newValue).intValue());
if (StringUtils.equals(skd.getFunction().getAlgorithmType(), valueByIndex.getComponentValueName())) {
return;
}
skd.getFunction().setAlgorithmType(valueByIndex.getComponentValueName());
} else if (MatchAnalysisConstant.ALLOW_MANUAL_RESOLUTION.equalsIgnoreCase(property)) {
if (skd.isAllowManualResolution() == Boolean.valueOf(newValue)) {
return;
}
skd.setAllowManualResolution(Boolean.valueOf(newValue));
} else {
return;
}
tableViewer.update(skd, null);
}
}
Aggregations