use of org.talend.dataquality.record.linkage.utils.BlockingKeyPreAlgorithmEnum in project tdq-studio-se by Talend.
the class BlockingKeyCellModeifier 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) {
BlockKeyDefinition bkd = (BlockKeyDefinition) ((TableItem) element).getData();
String newValue = String.valueOf(value);
if (MatchAnalysisConstant.PRE_ALGO.equalsIgnoreCase(property)) {
BlockingKeyPreAlgorithmEnum valueByIndex = BlockingKeyPreAlgorithmEnum.getTypeByIndex(Integer.valueOf(newValue).intValue());
if (StringUtils.equals(bkd.getPreAlgorithm().getAlgorithmType(), valueByIndex.getComponentValueName())) {
return;
}
bkd.getPreAlgorithm().setAlgorithmType(valueByIndex.getComponentValueName());
bkd.getPreAlgorithm().setAlgorithmParameters(valueByIndex.getDefaultValue());
} else if (MatchAnalysisConstant.PRE_VALUE.equalsIgnoreCase(property)) {
if (StringUtils.equals(bkd.getPreAlgorithm().getAlgorithmParameters(), newValue)) {
return;
}
BlockingKeyPreAlgorithmEnum valueBySavedValue = BlockingKeyPreAlgorithmEnum.getTypeBySavedValue(bkd.getPreAlgorithm().getAlgorithmType());
if (isParameterInValid(valueBySavedValue.getDefaultValue(), newValue)) {
return;
}
bkd.getPreAlgorithm().setAlgorithmParameters(String.valueOf(value));
} else if (MatchAnalysisConstant.KEY_ALGO.equalsIgnoreCase(property)) {
BlockingKeyAlgorithmEnum valueByIndex = BlockingKeyAlgorithmEnum.getTypeByIndex(Integer.valueOf(newValue).intValue());
if (StringUtils.equals(bkd.getAlgorithm().getAlgorithmType(), valueByIndex.getComponentValueName())) {
return;
}
bkd.getAlgorithm().setAlgorithmType(valueByIndex.getComponentValueName());
bkd.getAlgorithm().setAlgorithmParameters(valueByIndex.getDefaultValue());
} else if (MatchAnalysisConstant.KEY_VALUE.equalsIgnoreCase(property)) {
if (StringUtils.equals(bkd.getAlgorithm().getAlgorithmParameters(), newValue)) {
return;
}
BlockingKeyAlgorithmEnum valueBySavedValue = BlockingKeyAlgorithmEnum.getTypeBySavedValue(bkd.getAlgorithm().getAlgorithmType());
if (isParameterInValid(valueBySavedValue.getDefaultValue(), newValue)) {
return;
}
bkd.getAlgorithm().setAlgorithmParameters(newValue);
} else if (MatchAnalysisConstant.POST_ALGO.equalsIgnoreCase(property)) {
BlockingKeyPostAlgorithmEnum valueByIndex = BlockingKeyPostAlgorithmEnum.getTypeByIndex(Integer.valueOf(newValue).intValue());
if (StringUtils.equals(bkd.getPostAlgorithm().getAlgorithmType(), valueByIndex.getComponentValueName())) {
return;
}
bkd.getPostAlgorithm().setAlgorithmType(valueByIndex.getComponentValueName());
bkd.getPostAlgorithm().setAlgorithmParameters(valueByIndex.getDefaultValue());
} else if (MatchAnalysisConstant.POST_VALUE.equalsIgnoreCase(property)) {
if (StringUtils.equals(bkd.getPostAlgorithm().getAlgorithmParameters(), newValue)) {
return;
}
BlockingKeyPostAlgorithmEnum valueBySavedValue = BlockingKeyPostAlgorithmEnum.getTypeBySavedValue(bkd.getPostAlgorithm().getAlgorithmType());
if (isParameterInValid(valueBySavedValue.getDefaultValue(), newValue)) {
return;
}
bkd.getPostAlgorithm().setAlgorithmParameters(newValue);
} else if (MatchAnalysisConstant.PRECOLUMN.equalsIgnoreCase(property)) {
if (Integer.parseInt(newValue) == -1) {
return;
}
String columnName = columnList.get(Integer.parseInt(newValue)).getName();
if (StringUtils.equals(bkd.getColumn(), columnName)) {
return;
}
bkd.setColumn(columnName);
tableViewer.noticeColumnSelectChange();
} else if (MatchAnalysisConstant.BLOCKING_KEY_NAME.equalsIgnoreCase(property)) {
if (StringUtils.equals(bkd.getName(), newValue)) {
return;
}
bkd.setName(newValue);
} else {
return;
}
tableViewer.update(bkd, null);
}
}
Aggregations