Search in sources :

Example 1 with DefaultSurvivorShipDataTypeEnum

use of org.talend.dataquality.record.linkage.utils.DefaultSurvivorShipDataTypeEnum 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);
}
Also used : DefaultSurvivorShipDataTypeEnum(org.talend.dataquality.record.linkage.utils.DefaultSurvivorShipDataTypeEnum) SurvivorShipAlgorithmEnum(org.talend.dataquality.record.linkage.utils.SurvivorShipAlgorithmEnum)

Example 2 with DefaultSurvivorShipDataTypeEnum

use of org.talend.dataquality.record.linkage.utils.DefaultSurvivorShipDataTypeEnum 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);
    }
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) DefaultSurvivorshipDefinition(org.talend.dataquality.rules.DefaultSurvivorshipDefinition) DefaultSurvivorShipDataTypeEnum(org.talend.dataquality.record.linkage.utils.DefaultSurvivorShipDataTypeEnum) SurvivorShipAlgorithmEnum(org.talend.dataquality.record.linkage.utils.SurvivorShipAlgorithmEnum)

Example 3 with DefaultSurvivorShipDataTypeEnum

use of org.talend.dataquality.record.linkage.utils.DefaultSurvivorShipDataTypeEnum 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);
}
Also used : DefaultSurvivorShipDataTypeEnum(org.talend.dataquality.record.linkage.utils.DefaultSurvivorShipDataTypeEnum) AlgorithmDefinition(org.talend.dataquality.rules.AlgorithmDefinition) SurvivorShipAlgorithmEnum(org.talend.dataquality.record.linkage.utils.SurvivorShipAlgorithmEnum)

Aggregations

DefaultSurvivorShipDataTypeEnum (org.talend.dataquality.record.linkage.utils.DefaultSurvivorShipDataTypeEnum)3 SurvivorShipAlgorithmEnum (org.talend.dataquality.record.linkage.utils.SurvivorShipAlgorithmEnum)3 TableItem (org.eclipse.swt.widgets.TableItem)1 AlgorithmDefinition (org.talend.dataquality.rules.AlgorithmDefinition)1 DefaultSurvivorshipDefinition (org.talend.dataquality.rules.DefaultSurvivorshipDefinition)1