use of org.talend.dataquality.record.linkage.utils.SurvivorShipAlgorithmEnum in project tdq-studio-se by Talend.
the class ParticularDefaultSurvivorShipCellModifier 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) {
ParticularDefaultSurvivorshipDefinitions pdskd = (ParticularDefaultSurvivorshipDefinitions) ((TableItem) element).getData();
String newValue = String.valueOf(value);
if (MatchAnalysisConstant.PRECOLUMN.equalsIgnoreCase(property)) {
if (Integer.parseInt(newValue) == -1) {
return;
}
MetadataColumn metadataColumn = columnList.get(Integer.parseInt(newValue));
String columnName = metadataColumn.getName();
if (StringUtils.equals(pdskd.getColumn(), columnName)) {
return;
}
pdskd.setColumn(columnName);
pdskd.setDataType(metadataColumn.getTalendType());
if (isFunctionInvalid(pdskd, metadataColumn.getTalendType())) {
resetFunction(pdskd);
}
} else if (MatchAnalysisConstant.FUNCTION.equalsIgnoreCase(property)) {
SurvivorShipAlgorithmEnum valueByIndex = SurvivorShipAlgorithmEnum.getTypeByIndex(Integer.valueOf(newValue).intValue());
if (StringUtils.equals(pdskd.getFunction().getAlgorithmType(), valueByIndex.getComponentValueName())) {
return;
}
setFunction(pdskd, valueByIndex);
} else if (MatchAnalysisConstant.PARAMETER.equalsIgnoreCase(property)) {
pdskd.getFunction().setAlgorithmParameters(newValue);
} else {
return;
}
tableViewer.update(pdskd, null);
}
}
use of org.talend.dataquality.record.linkage.utils.SurvivorShipAlgorithmEnum in project tdq-studio-se by Talend.
the class MatchRuleElementTreeSelectionDialog method checkFunctionValid.
/**
* Check validity of function
*
* @param functionType the type of function
* @param matchedColumnName the name of column
* @param dataType the data type of column
* @return true if function is valid else false
*/
private boolean checkFunctionValid(String functionType, String matchedColumnName, String dataType) {
SurvivorShipAlgorithmEnum functionEnum = SurvivorShipAlgorithmEnum.getTypeBySavedValue(functionType);
// for most common, no need to check, it fixes all type.
if (SurvivorShipAlgorithmEnum.MOST_COMMON.equals(functionEnum)) {
return true;
}
DefaultSurvivorShipDataTypeEnum[] valudDataType = functionEnum.getDataType();
return FunctionEditingSupport.isSupportDataType(valudDataType, dataType);
}
use of org.talend.dataquality.record.linkage.utils.SurvivorShipAlgorithmEnum in project tdq-studio-se by Talend.
the class DefaultSurvivorShipCellModifier 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) {
DefaultSurvivorshipDefinition skd = (DefaultSurvivorshipDefinition) ((TableItem) element).getData();
String newValue = String.valueOf(value);
if (MatchAnalysisConstant.DATA_TYPE.equalsIgnoreCase(property)) {
DefaultSurvivorShipDataTypeEnum valueByIndex = DefaultSurvivorShipDataTypeEnum.getTypeByIndex(Integer.valueOf(newValue).intValue());
if (StringUtils.equals(skd.getDataType(), valueByIndex.getValue())) {
return;
}
skd.setDataType(valueByIndex.getValue());
} 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());
if (!(isSurvivorShipAlgorithm(skd, SurvivorShipAlgorithmEnum.MOST_TRUSTED_SOURCE) | isSurvivorShipAlgorithm(skd, SurvivorShipAlgorithmEnum.CONCATENATE))) {
skd.getFunction().setAlgorithmParameters(StringUtils.EMPTY);
CellEditor[] cellEditors = tableViewer.getCellEditors();
if (cellEditors.length == 3) {
cellEditors[2].setValue(StringUtils.EMPTY);
}
}
} else if (MatchAnalysisConstant.PARAMETER.equalsIgnoreCase(property)) {
skd.getFunction().setAlgorithmParameters(newValue);
} else {
return;
}
tableViewer.update(skd, null);
}
}
use of org.talend.dataquality.record.linkage.utils.SurvivorShipAlgorithmEnum in project tdq-studio-se by Talend.
the class ParticularDefSurshipDefinitionSection method checkFunctionValid.
/**
* Check validity of function
*
* @param functionType the type of function
* @param matchedColumnName the name of column
* @param dataType the data type of column
* @return true if function is valid else false
*/
private boolean checkFunctionValid(ParticularDefaultSurvivorshipDefinitions partucykarDefinition) {
AlgorithmDefinition algorithmDefinition = partucykarDefinition.getFunction();
String functionType = algorithmDefinition != null && algorithmDefinition.getAlgorithmType() != null ? algorithmDefinition.getAlgorithmType() : StringUtils.EMPTY;
String dataType = partucykarDefinition.getDataType();
SurvivorShipAlgorithmEnum functionEnum = SurvivorShipAlgorithmEnum.getTypeBySavedValue(functionType);
DefaultSurvivorShipDataTypeEnum[] valudDataType = functionEnum.getDataType();
return FunctionEditingSupport.isSupportDataType(valudDataType, dataType);
}
use of org.talend.dataquality.record.linkage.utils.SurvivorShipAlgorithmEnum 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