Search in sources :

Example 6 with DefaultSurvivorshipDefinition

use of org.talend.dataquality.rules.DefaultSurvivorshipDefinition 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 7 with DefaultSurvivorshipDefinition

use of org.talend.dataquality.rules.DefaultSurvivorshipDefinition in project tdq-studio-se by Talend.

the class DefaultSurvivorshipDefinitionSection method moveUpTableItem.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dataquality.record.linkage.ui.section.AbstractMatchAnaysisTableSection#moveUpTableItem()
     */
@Override
public void moveUpTableItem() {
    ISelection selectItems = tableComposite.getSelectItems();
    if (selectItems instanceof StructuredSelection) {
        if (selectItems.isEmpty()) {
            return;
        }
        List<DefaultSurvivorshipDefinition> currentElements = this.matchRuleDef.getDefaultSurvivorshipDefinitions();
        List<DefaultSurvivorshipDefinition> defaultSurvivorshipKeyDefinitionlist = ((StructuredSelection) selectItems).toList();
        for (int index = 0; index < defaultSurvivorshipKeyDefinitionlist.size(); index++) {
            if (!isSameWithCurrentModel(currentElements.get(index), defaultSurvivorshipKeyDefinitionlist.get(index))) {
                continue;
            }
            DefaultSurvivorshipDefinition next = defaultSurvivorshipKeyDefinitionlist.get(index);
            tableComposite.moveUpKeyDefinition(next, currentElements);
        }
        tableComposite.selectAllItem(((StructuredSelection) selectItems).toList());
    }
}
Also used : DefaultSurvivorshipDefinition(org.talend.dataquality.rules.DefaultSurvivorshipDefinition) ISelection(org.eclipse.jface.viewers.ISelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection)

Example 8 with DefaultSurvivorshipDefinition

use of org.talend.dataquality.rules.DefaultSurvivorshipDefinition in project tdq-studio-se by Talend.

the class DefaultSurvivorshipDefinitionSection method moveDownTableItem.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dataquality.record.linkage.ui.section.AbstractMatchAnaysisTableSection#moveDownTableItem()
     */
@Override
public void moveDownTableItem() {
    ISelection selectItems = tableComposite.getSelectItems();
    if (selectItems instanceof StructuredSelection) {
        if (selectItems.isEmpty()) {
            return;
        }
        List<DefaultSurvivorshipDefinition> currentElements = this.matchRuleDef.getDefaultSurvivorshipDefinitions();
        List<DefaultSurvivorshipDefinition> defaultSurvivorshipKeyDefinitionlist = ((StructuredSelection) selectItems).toList();
        for (int index = defaultSurvivorshipKeyDefinitionlist.size() - 1; 0 <= index; index--) {
            if (!isSameWithCurrentModel(currentElements.get(currentElements.size() - defaultSurvivorshipKeyDefinitionlist.size() + index), defaultSurvivorshipKeyDefinitionlist.get(index))) {
                continue;
            }
            DefaultSurvivorshipDefinition next = defaultSurvivorshipKeyDefinitionlist.get(index);
            tableComposite.moveDownKeyDefinition(next, currentElements);
        }
        tableComposite.selectAllItem(((StructuredSelection) selectItems).toList());
    }
}
Also used : DefaultSurvivorshipDefinition(org.talend.dataquality.rules.DefaultSurvivorshipDefinition) ISelection(org.eclipse.jface.viewers.ISelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection)

Example 9 with DefaultSurvivorshipDefinition

use of org.talend.dataquality.rules.DefaultSurvivorshipDefinition in project tdq-studio-se by Talend.

the class DefaultSurvivorshipDefinitionSection method importDefaultSurvivorshipFunctions.

/**
 * import the DefaultSurvivorshipFunctions, if overwrite, clear the DefaultSurvivorshipFunctions before import.
 *
 * @param matchRuleDef
 * @param overwrite
 */
@SuppressWarnings("unchecked")
public void importDefaultSurvivorshipFunctions(MatchRuleDefinition matchRuleDef, boolean overwrite) {
    EList<DefaultSurvivorshipDefinition> functions = null;
    Object input = tableComposite.getInput();
    if (input != null) {
        functions = (EList<DefaultSurvivorshipDefinition>) input;
    }
    if (functions == null) {
        functions = new BasicEList<DefaultSurvivorshipDefinition>();
    }
    if (overwrite) {
        functions.clear();
    }
    for (DefaultSurvivorshipDefinition def : matchRuleDef.getDefaultSurvivorshipDefinitions()) {
        functions.add(EcoreUtil.copy(def));
    }
    tableComposite.setInput(functions);
}
Also used : DefaultSurvivorshipDefinition(org.talend.dataquality.rules.DefaultSurvivorshipDefinition)

Example 10 with DefaultSurvivorshipDefinition

use of org.talend.dataquality.rules.DefaultSurvivorshipDefinition in project tdq-studio-se by Talend.

the class DefaultSurvivorShipTableViewer method removeElement.

public void removeElement(DefaultSurvivorshipDefinition keyDef, MatchRuleDefinition matchRuleDef) {
    List<DefaultSurvivorshipDefinition> skdList = matchRuleDef.getDefaultSurvivorshipDefinitions();
    Iterator<DefaultSurvivorshipDefinition> keyIterator = skdList.iterator();
    while (keyIterator.hasNext()) {
        DefaultSurvivorshipDefinition tmpKeyDef = keyIterator.next();
        if (StringUtils.equals(keyDef.getDataType(), tmpKeyDef.getDataType())) {
            skdList.remove(keyDef);
            // Update table view.
            remove(keyDef);
            break;
        }
    }
}
Also used : DefaultSurvivorshipDefinition(org.talend.dataquality.rules.DefaultSurvivorshipDefinition)

Aggregations

DefaultSurvivorshipDefinition (org.talend.dataquality.rules.DefaultSurvivorshipDefinition)11 ISelection (org.eclipse.jface.viewers.ISelection)3 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)3 HashMap (java.util.HashMap)2 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)2 SurvivorshipFunction (org.talend.dataquality.record.linkage.grouping.swoosh.SurvivorShipAlgorithmParams.SurvivorshipFunction)2 AlgorithmDefinition (org.talend.dataquality.rules.AlgorithmDefinition)2 ParticularDefaultSurvivorshipDefinitions (org.talend.dataquality.rules.ParticularDefaultSurvivorshipDefinitions)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 EList (org.eclipse.emf.common.util.EList)1 TableItem (org.eclipse.swt.widgets.TableItem)1 Test (org.junit.Test)1 RecordMatchingIndicator (org.talend.dataquality.indicators.columnset.RecordMatchingIndicator)1 AnalysisMatchRecordGrouping (org.talend.dataquality.record.linkage.grouping.AnalysisMatchRecordGrouping)1 MatchGroupResultConsumer (org.talend.dataquality.record.linkage.grouping.MatchGroupResultConsumer)1 DQMFBRecordMatcher (org.talend.dataquality.record.linkage.grouping.swoosh.DQMFBRecordMatcher)1 SurvivorShipAlgorithmParams (org.talend.dataquality.record.linkage.grouping.swoosh.SurvivorShipAlgorithmParams)1 CombinedRecordMatcher (org.talend.dataquality.record.linkage.record.CombinedRecordMatcher)1