Search in sources :

Example 1 with SurvivorShipAlgorithmEnum

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);
    }
}
Also used : MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) ParticularDefaultSurvivorshipDefinitions(org.talend.dataquality.rules.ParticularDefaultSurvivorshipDefinitions) TableItem(org.eclipse.swt.widgets.TableItem) SurvivorShipAlgorithmEnum(org.talend.dataquality.record.linkage.utils.SurvivorShipAlgorithmEnum)

Example 2 with SurvivorShipAlgorithmEnum

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

Example 3 with SurvivorShipAlgorithmEnum

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);
    }
}
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 4 with SurvivorShipAlgorithmEnum

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

Example 5 with SurvivorShipAlgorithmEnum

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

Aggregations

SurvivorShipAlgorithmEnum (org.talend.dataquality.record.linkage.utils.SurvivorShipAlgorithmEnum)9 TableItem (org.eclipse.swt.widgets.TableItem)4 DefaultSurvivorShipDataTypeEnum (org.talend.dataquality.record.linkage.utils.DefaultSurvivorShipDataTypeEnum)3 ParticularDefaultSurvivorshipDefinitions (org.talend.dataquality.rules.ParticularDefaultSurvivorshipDefinitions)3 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)2 CellEditor (org.eclipse.jface.viewers.CellEditor)1 ComboBoxCellEditor (org.eclipse.jface.viewers.ComboBoxCellEditor)1 AttributeMatcherType (org.talend.dataquality.record.linkage.constant.AttributeMatcherType)1 TokenizedResolutionMethod (org.talend.dataquality.record.linkage.constant.TokenizedResolutionMethod)1 MatchKeyAndSurvivorDefinition (org.talend.dataquality.record.linkage.ui.composite.tableviewer.definition.MatchKeyAndSurvivorDefinition)1 HandleNullEnum (org.talend.dataquality.record.linkage.utils.HandleNullEnum)1 AlgorithmDefinition (org.talend.dataquality.rules.AlgorithmDefinition)1 DefaultSurvivorshipDefinition (org.talend.dataquality.rules.DefaultSurvivorshipDefinition)1 MatchKeyDefinition (org.talend.dataquality.rules.MatchKeyDefinition)1 SurvivorshipKeyDefinition (org.talend.dataquality.rules.SurvivorshipKeyDefinition)1