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);
}
}
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());
}
}
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());
}
}
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);
}
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;
}
}
}
Aggregations